From 33bf9f3003ff049dcc812f5aaa529802df8df2b2 Mon Sep 17 00:00:00 2001 From: Stefan Bratanov Date: Tue, 18 Apr 2023 16:21:05 +0100 Subject: [PATCH] Make `execution_optimistic` required field in GetProposerDuties --- .../beacon/schema/GetAttesterDutiesResponse.json | 14 +++++++------- .../beacon/schema/GetProposerDutiesResponse.json | 8 ++++---- .../handlers/v1/validator/GetProposerDuties.java | 6 +----- .../handlers/v1/validator/PostAttesterDuties.java | 2 +- .../handlers/v1/validator/PostSyncDuties.java | 4 ++-- .../handlers/v1/validator/getProposerDuties.json | 2 +- .../handlers/v1/validator/postAttesterDuties.json | 2 +- 7 files changed, 17 insertions(+), 21 deletions(-) diff --git a/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/GetAttesterDutiesResponse.json b/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/GetAttesterDutiesResponse.json index cc521f15cab..0c22713e55a 100644 --- a/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/GetAttesterDutiesResponse.json +++ b/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/GetAttesterDutiesResponse.json @@ -1,20 +1,20 @@ { "title" : "GetAttesterDutiesResponse", "type" : "object", - "required" : [ "execution_optimistic", "finalized", "dependent_root", "data" ], + "required" : [ "dependent_root", "execution_optimistic", "finalized", "data" ], "properties" : { - "execution_optimistic" : { - "type" : "boolean" - }, - "finalized" : { - "type" : "boolean" - }, "dependent_root" : { "type" : "string", "description" : "Bytes32 hexadecimal", "example" : "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", "format" : "byte" }, + "execution_optimistic" : { + "type" : "boolean" + }, + "finalized" : { + "type" : "boolean" + }, "data" : { "type" : "array", "items" : { diff --git a/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/GetProposerDutiesResponse.json b/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/GetProposerDutiesResponse.json index d867343e41c..3deb3bdce4a 100644 --- a/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/GetProposerDutiesResponse.json +++ b/data/beaconrestapi/src/integration-test/resources/tech/pegasys/teku/beaconrestapi/beacon/schema/GetProposerDutiesResponse.json @@ -1,17 +1,17 @@ { "title" : "GetProposerDutiesResponse", "type" : "object", - "required" : [ "dependent_root", "data" ], + "required" : [ "dependent_root", "execution_optimistic", "data" ], "properties" : { - "execution_optimistic" : { - "type" : "boolean" - }, "dependent_root" : { "type" : "string", "description" : "Bytes32 hexadecimal", "example" : "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", "format" : "byte" }, + "execution_optimistic" : { + "type" : "boolean" + }, "data" : { "type" : "array", "items" : { diff --git a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/validator/GetProposerDuties.java b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/validator/GetProposerDuties.java index 9bf1f43c5e8..a4bd22ee5c6 100644 --- a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/validator/GetProposerDuties.java +++ b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/validator/GetProposerDuties.java @@ -56,12 +56,8 @@ public class GetProposerDuties extends RestApiEndpoint { private static final SerializableTypeDefinition RESPONSE_TYPE = SerializableTypeDefinition.object(ProposerDuties.class) .name("GetProposerDutiesResponse") - .withOptionalField( - EXECUTION_OPTIMISTIC, - BOOLEAN_TYPE, - (proposerDuties) -> - proposerDuties.isExecutionOptimistic() ? Optional.of(true) : Optional.empty()) .withField("dependent_root", BYTES32_TYPE, ProposerDuties::getDependentRoot) + .withField(EXECUTION_OPTIMISTIC, BOOLEAN_TYPE, ProposerDuties::isExecutionOptimistic) .withField("data", listOf(PROPOSER_DUTY_TYPE), ProposerDuties::getDuties) .build(); diff --git a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/validator/PostAttesterDuties.java b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/validator/PostAttesterDuties.java index 50f502a1c32..e7d930d8185 100644 --- a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/validator/PostAttesterDuties.java +++ b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/validator/PostAttesterDuties.java @@ -66,9 +66,9 @@ public class PostAttesterDuties extends RestApiEndpoint { private static final SerializableTypeDefinition RESPONSE_TYPE = SerializableTypeDefinition.object(AttesterDuties.class) .name("GetAttesterDutiesResponse") + .withField("dependent_root", BYTES32_TYPE, AttesterDuties::getDependentRoot) .withField(EXECUTION_OPTIMISTIC, BOOLEAN_TYPE, AttesterDuties::isExecutionOptimistic) .withField(FINALIZED, BOOLEAN_TYPE, AttesterDuties::isFinalized) - .withField("dependent_root", BYTES32_TYPE, AttesterDuties::getDependentRoot) .withField( "data", SerializableTypeDefinition.listOf(ATTESTER_DUTY_TYPE), diff --git a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/validator/PostSyncDuties.java b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/validator/PostSyncDuties.java index 9c417e1c78e..0d10fa0a465 100644 --- a/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/validator/PostSyncDuties.java +++ b/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/validator/PostSyncDuties.java @@ -17,6 +17,7 @@ import static tech.pegasys.teku.ethereum.json.types.EthereumTypes.PUBLIC_KEY_TYPE; import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_OK; import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_SERVICE_UNAVAILABLE; +import static tech.pegasys.teku.infrastructure.http.RestApiConstants.EXECUTION_OPTIMISTIC; import static tech.pegasys.teku.infrastructure.http.RestApiConstants.SERVICE_UNAVAILABLE; import static tech.pegasys.teku.infrastructure.http.RestApiConstants.TAG_VALIDATOR; import static tech.pegasys.teku.infrastructure.http.RestApiConstants.TAG_VALIDATOR_REQUIRED; @@ -61,8 +62,7 @@ public class PostSyncDuties extends RestApiEndpoint { private static final SerializableTypeDefinition RESPONSE_TYPE = SerializableTypeDefinition.object(SyncCommitteeDuties.class) .name("GetSyncCommitteeDutiesResponse") - .withField( - "execution_optimistic", BOOLEAN_TYPE, SyncCommitteeDuties::isExecutionOptimistic) + .withField(EXECUTION_OPTIMISTIC, BOOLEAN_TYPE, SyncCommitteeDuties::isExecutionOptimistic) .withField( "data", SerializableTypeDefinition.listOf(SYNC_COMMITTEE_DUTY_TYPE), diff --git a/data/beaconrestapi/src/test/resources/tech/pegasys/teku/beaconrestapi/handlers/v1/validator/getProposerDuties.json b/data/beaconrestapi/src/test/resources/tech/pegasys/teku/beaconrestapi/handlers/v1/validator/getProposerDuties.json index 59c50602bec..9d9a0d6934e 100644 --- a/data/beaconrestapi/src/test/resources/tech/pegasys/teku/beaconrestapi/handlers/v1/validator/getProposerDuties.json +++ b/data/beaconrestapi/src/test/resources/tech/pegasys/teku/beaconrestapi/handlers/v1/validator/getProposerDuties.json @@ -1 +1 @@ -{"dependent_root":"0x0000000000000000000000000000000000000000000000000000000000001234","data":[{"pubkey":"0x8c43edcff6f1d56f2a42072637c0cfd9467ddfccb918ce1a8c2d1babb9cdd6584b601dde9b2bafe027be489bbdcf82ef","validator_index":"2","slot":"800"}]} \ No newline at end of file +{"dependent_root":"0x0000000000000000000000000000000000000000000000000000000000001234","execution_optimistic":false,"data":[{"pubkey":"0x8c43edcff6f1d56f2a42072637c0cfd9467ddfccb918ce1a8c2d1babb9cdd6584b601dde9b2bafe027be489bbdcf82ef","validator_index":"2","slot":"800"}]} \ No newline at end of file diff --git a/data/beaconrestapi/src/test/resources/tech/pegasys/teku/beaconrestapi/handlers/v1/validator/postAttesterDuties.json b/data/beaconrestapi/src/test/resources/tech/pegasys/teku/beaconrestapi/handlers/v1/validator/postAttesterDuties.json index e3e1845d29d..5f96a81cde4 100644 --- a/data/beaconrestapi/src/test/resources/tech/pegasys/teku/beaconrestapi/handlers/v1/validator/postAttesterDuties.json +++ b/data/beaconrestapi/src/test/resources/tech/pegasys/teku/beaconrestapi/handlers/v1/validator/postAttesterDuties.json @@ -1 +1 @@ -{"execution_optimistic":false,"finalized":false,"dependent_root":"0x367cbd40ac7318427aadb97345a91fa2e965daf3158d7f1846f1306305f41bef","data":[{"pubkey":"0xa4654ac3105a58c7634031b5718c4880c87300f72091cfbc69fe490b71d93a671e00e80a388e1ceb8ea1de112003e976","validator_index":"1","committee_index":"0","committee_length":"2","committees_at_slot":"2","validator_committee_index":"1","slot":"1"}]} \ No newline at end of file +{"dependent_root":"0x367cbd40ac7318427aadb97345a91fa2e965daf3158d7f1846f1306305f41bef","execution_optimistic":false,"finalized":false,"data":[{"pubkey":"0xa4654ac3105a58c7634031b5718c4880c87300f72091cfbc69fe490b71d93a671e00e80a388e1ceb8ea1de112003e976","validator_index":"1","committee_index":"0","committee_length":"2","committees_at_slot":"2","validator_committee_index":"1","slot":"1"}]} \ No newline at end of file