Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make execution_optimistic required field in GetProposerDuties #7054

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,6 @@ private AttesterDuties getAttesterDutiesFromIndicesAndState(
: spec.atEpoch(epoch).getBeaconStateUtil().getPreviousDutyDependentRoot(state);
return new AttesterDuties(
combinedChainDataClient.isChainHeadOptimistic(),
combinedChainDataClient.isFinalizedEpoch(epoch),
dependentRoot,
validatorIndices
.intStream()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
{
"title" : "GetAttesterDutiesResponse",
"type" : "object",
"required" : [ "execution_optimistic", "finalized", "dependent_root", "data" ],
"required" : [ "dependent_root", "execution_optimistic", "data" ],
"properties" : {
"execution_optimistic" : {
"type" : "boolean"
},
"finalized" : {
"type" : "boolean"
},
"dependent_root" : {
"type" : "string",
"description" : "Bytes32 hexadecimal",
"example" : "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
"format" : "byte"
},
"execution_optimistic" : {
"type" : "boolean"
},
"data" : {
"type" : "array",
"items" : {
Expand Down
Original file line number Diff line number Diff line change
@@ -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" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,8 @@ public class GetProposerDuties extends RestApiEndpoint {
private static final SerializableTypeDefinition<ProposerDuties> 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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
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.FINALIZED;
import static tech.pegasys.teku.infrastructure.http.RestApiConstants.TAG_VALIDATOR;
import static tech.pegasys.teku.infrastructure.http.RestApiConstants.TAG_VALIDATOR_REQUIRED;
import static tech.pegasys.teku.infrastructure.json.types.CoreTypes.BOOLEAN_TYPE;
Expand Down Expand Up @@ -66,9 +65,8 @@ public class PostAttesterDuties extends RestApiEndpoint {
private static final SerializableTypeDefinition<AttesterDuties> RESPONSE_TYPE =
SerializableTypeDefinition.object(AttesterDuties.class)
.name("GetAttesterDutiesResponse")
.withField(EXECUTION_OPTIMISTIC, BOOLEAN_TYPE, AttesterDuties::isExecutionOptimistic)
.withField(FINALIZED, BOOLEAN_TYPE, AttesterDuties::isFinalized)
.withField("dependent_root", BYTES32_TYPE, AttesterDuties::getDependentRoot)
.withField(EXECUTION_OPTIMISTIC, BOOLEAN_TYPE, AttesterDuties::isExecutionOptimistic)
.withField(
"data",
SerializableTypeDefinition.listOf(ATTESTER_DUTY_TYPE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -61,8 +62,7 @@ public class PostSyncDuties extends RestApiEndpoint {
private static final SerializableTypeDefinition<SyncCommitteeDuties> 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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class PostAttesterDutiesTest extends AbstractMigratedBeaconHandlerTest {
final AttesterDuty duty =
new AttesterDuty(dataStructureUtil.randomPublicKey(), 1, 2, 0, 2, 1, UInt64.ONE);
final AttesterDuties attesterDuties =
new AttesterDuties(false, false, dataStructureUtil.randomBytes32(), List.of(duty));
new AttesterDuties(false, dataStructureUtil.randomBytes32(), List.of(duty));

@BeforeEach
public void setup() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"dependent_root":"0x0000000000000000000000000000000000000000000000000000000000001234","data":[{"pubkey":"0x8c43edcff6f1d56f2a42072637c0cfd9467ddfccb918ce1a8c2d1babb9cdd6584b601dde9b2bafe027be489bbdcf82ef","validator_index":"2","slot":"800"}]}
{"dependent_root":"0x0000000000000000000000000000000000000000000000000000000000001234","execution_optimistic":false,"data":[{"pubkey":"0x8c43edcff6f1d56f2a42072637c0cfd9467ddfccb918ce1a8c2d1babb9cdd6584b601dde9b2bafe027be489bbdcf82ef","validator_index":"2","slot":"800"}]}
Original file line number Diff line number Diff line change
@@ -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"}]}
{"dependent_root":"0x367cbd40ac7318427aadb97345a91fa2e965daf3158d7f1846f1306305f41bef","execution_optimistic":false,"data":[{"pubkey":"0xa4654ac3105a58c7634031b5718c4880c87300f72091cfbc69fe490b71d93a671e00e80a388e1ceb8ea1de112003e976","validator_index":"1","committee_index":"0","committee_length":"2","committees_at_slot":"2","validator_committee_index":"1","slot":"1"}]}
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public void getAttesterDuties_shouldHandleEmptyIndicesList() {
when(validatorApiChannel.getAttestationDuties(eq(ONE), any()))
.thenReturn(
completedFuture(
Optional.of(new AttesterDuties(false, false, previousTargetRoot, emptyList()))));
Optional.of(new AttesterDuties(false, previousTargetRoot, emptyList()))));
final SafeFuture<Optional<AttesterDuties>> future =
provider.getAttesterDuties(UInt64.ONE, IntList.of());
assertThat(future).isCompleted();
Expand All @@ -395,7 +395,7 @@ public void getAttesterDuties_shouldReturnDutiesForKnownValidator() {
completedFuture(
Optional.of(
new AttesterDuties(
false, false, dataStructureUtil.randomBytes32(), List.of(v1, v2)))));
false, dataStructureUtil.randomBytes32(), List.of(v1, v2)))));

final SafeFuture<Optional<AttesterDuties>> future =
provider.getAttesterDuties(ONE, IntList.of(1, 11));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,14 @@ public class PostAttesterDutiesResponse {
@JsonProperty("execution_optimistic")
public final boolean executionOptimistic;

@JsonProperty(value = "finalized")
public final boolean finalized;

@JsonCreator
public PostAttesterDutiesResponse(
@JsonProperty("dependent_root") final Bytes32 dependentRoot,
@JsonProperty("data") final List<AttesterDuty> data,
@JsonProperty("execution_optimistic") final boolean executionOptimistic,
@JsonProperty("finalized") final boolean finalized) {
@JsonProperty("execution_optimistic") final boolean executionOptimistic) {
this.dependentRoot = dependentRoot;
this.data = data;
this.executionOptimistic = executionOptimistic;
this.finalized = finalized;
}

@Override
Expand All @@ -63,14 +58,13 @@ public boolean equals(final Object o) {
}
final PostAttesterDutiesResponse that = (PostAttesterDutiesResponse) o;
return executionOptimistic == that.executionOptimistic
&& finalized == that.finalized
&& Objects.equals(dependentRoot, that.dependentRoot)
&& Objects.equals(data, that.data);
}

@Override
public int hashCode() {
return Objects.hash(dependentRoot, data, executionOptimistic, finalized);
return Objects.hash(dependentRoot, data, executionOptimistic);
}

@Override
Expand All @@ -79,7 +73,6 @@ public String toString() {
.add("dependentRoot", dependentRoot)
.add("data", data)
.add("executionOptimistic", executionOptimistic)
.add("finalized", finalized)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,14 @@

public class AttesterDuties {
private final boolean executionOptimistic;
private final boolean finalized;
private final Bytes32 dependentRoot;
private final List<AttesterDuty> duties;

public AttesterDuties(
final boolean executionOptimistic,
final boolean finalized,
final Bytes32 dependentRoot,
final List<AttesterDuty> duties) {
this.executionOptimistic = executionOptimistic;
this.finalized = finalized;
this.dependentRoot = dependentRoot;
this.duties = duties;
}
Expand All @@ -39,10 +36,6 @@ public boolean isExecutionOptimistic() {
return executionOptimistic;
}

public boolean isFinalized() {
return finalized;
}

public Bytes32 getDependentRoot() {
return dependentRoot;
}
Expand All @@ -61,21 +54,19 @@ public boolean equals(final Object o) {
}
final AttesterDuties that = (AttesterDuties) o;
return executionOptimistic == that.executionOptimistic
&& finalized == that.finalized
&& Objects.equals(dependentRoot, that.dependentRoot)
&& Objects.equals(duties, that.duties);
}

@Override
public int hashCode() {
return Objects.hash(executionOptimistic, finalized, dependentRoot, duties);
return Objects.hash(executionOptimistic, dependentRoot, duties);
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("executionOptimistic", executionOptimistic)
.add("finalized", finalized)
.add("dependentRoot", dependentRoot)
.add("duties", duties)
.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ void shouldSubscribeToSubnetWhenValidatorIsAggregator() {
.thenReturn(
SafeFuture.completedFuture(
Optional.of(
new AttesterDuties(
false, false, dataStructureUtil.randomBytes32(), List.of(duty)))));
new AttesterDuties(false, dataStructureUtil.randomBytes32(), List.of(duty)))));

when(scheduledDuties.scheduleProduction(any(), any(), any())).thenReturn(new SafeFuture<>());
when(signer.signAggregationSlot(slot, forkInfo))
Expand Down Expand Up @@ -143,8 +142,7 @@ void shouldSubscribeToSubnetWhenValidatorIsNotAggregator() {
.thenReturn(
SafeFuture.completedFuture(
Optional.of(
new AttesterDuties(
false, false, dataStructureUtil.randomBytes32(), List.of(duty)))));
new AttesterDuties(false, dataStructureUtil.randomBytes32(), List.of(duty)))));

when(scheduledDuties.scheduleProduction(any(), any(), any())).thenReturn(new SafeFuture<>());
when(signer.signAggregationSlot(slot, forkInfo))
Expand All @@ -167,8 +165,7 @@ void shouldSendSubscriptionRequestsWhenAllDutiesAreScheduled() {
.thenReturn(
SafeFuture.completedFuture(
Optional.of(
new AttesterDuties(
false, false, dataStructureUtil.randomBytes32(), emptyList()))));
new AttesterDuties(false, dataStructureUtil.randomBytes32(), emptyList()))));
final SafeFuture<Optional<SlotBasedScheduledDuties<?, ?>>> result =
dutyLoader.loadDutiesForEpoch(UInt64.ONE);

Expand Down
Loading