-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GET /highWatermark endpoint to eth2 API
- Loading branch information
Showing
6 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...rc/main/java/tech/pegasys/web3signer/core/service/http/handlers/HighWatermarkHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2023 ConsenSys AG. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
package tech.pegasys.web3signer.core.service.http.handlers; | ||
|
||
import static io.vertx.core.http.HttpHeaders.CONTENT_TYPE; | ||
import static tech.pegasys.web3signer.core.service.http.handlers.ContentTypes.JSON_UTF_8; | ||
|
||
import tech.pegasys.web3signer.slashingprotection.SlashingProtection; | ||
|
||
import java.util.Map; | ||
|
||
import io.vertx.core.Handler; | ||
import io.vertx.core.json.JsonObject; | ||
import io.vertx.ext.web.RoutingContext; | ||
|
||
public class HighWatermarkHandler implements Handler<RoutingContext> { | ||
private final SlashingProtection slashingProtection; | ||
|
||
public HighWatermarkHandler(final SlashingProtection slashingProtection) { | ||
this.slashingProtection = slashingProtection; | ||
} | ||
|
||
@Override | ||
public void handle(final RoutingContext context) { | ||
JsonObject response = | ||
slashingProtection | ||
.getHighWatermark() | ||
.map( | ||
hw -> | ||
new JsonObject( | ||
Map.of( | ||
"epoch", String.valueOf(hw.getEpoch()), | ||
"slot", String.valueOf(hw.getSlot())))) | ||
.orElse(new JsonObject()); | ||
|
||
context.response().putHeader(CONTENT_TYPE, JSON_UTF_8).end(response.encode()); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
core/src/main/resources/openapi-specs/eth2/signing/paths/high_watermark.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
get: | ||
tags: | ||
- 'High Watermark' | ||
summary: 'The High Watermark epoch and slot applicable to all validators' | ||
description: 'Returns the uint64 epoch and slot of the high watermark. Signing of attestations or blocks are prevented at or beyond this high watermark' | ||
operationId: 'HIGH_WATERMARK' | ||
responses: | ||
'200': | ||
description: 'high watermark' | ||
content: | ||
application/json: | ||
schema: | ||
type: "object" | ||
properties: | ||
epoch: | ||
type: "string" | ||
format: "uint64" | ||
slot: | ||
type: "string" | ||
format: "uint64" | ||
'400': | ||
description: 'Bad request format' | ||
'500': | ||
description: 'Internal Web3Signer server error' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters