Skip to content

Commit 67fdabf

Browse files
EIP-8282 Add builder execution requests (#10849)
1 parent cb23932 commit 67fdabf

24 files changed

Lines changed: 242 additions & 402 deletions

File tree

data/beaconrestapi/src/integration-test/java/tech/pegasys/teku/beaconrestapi/v1/beacon/PostVoluntaryExitIntegrationTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ public void shouldIncludeRejectReasonWhenOperationValidatorRejectsOperation() th
7575

7676
@Test
7777
public void shouldReturnServerErrorWhenUnexpectedErrorHappens() throws Exception {
78-
final SignedVoluntaryExit signedVoluntaryExit = dataStructureUtil.randomSignedVoluntaryExit();
78+
final SignedVoluntaryExit signedVoluntaryExit =
79+
dataStructureUtil.randomSignedVoluntaryExit(UInt64.ZERO);
7980
doThrow(new RuntimeException()).when(voluntaryExitPool).addLocal(signedVoluntaryExit);
8081

8182
final Response response = getResponse(signedVoluntaryExit);

data/beaconrestapi/src/test/resources/tech/pegasys/teku/beaconrestapi/handlers/v1/config/mainnetConfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
"DOMAIN_VOLUNTARY_EXIT" : "0x04000000",
109109
"SYNC_MESSAGE_DUE_BPS_GLOAS" : "2500",
110110
"ALTAIR_FORK_EPOCH" : "74240",
111-
"DOMAIN_INCLUSION_LIST_COMMITTEE" : "0x0e000000",
111+
"DOMAIN_INCLUSION_LIST_COMMITTEE" : "0x0f000000",
112112
"ALTAIR_FORK_VERSION" : "0x01000000",
113113
"INCLUSION_LIST_COMMITTEE_SIZE" : "16",
114114
"PROPOSER_REWARD_QUOTIENT" : "8",

data/provider/src/main/java/tech/pegasys/teku/api/ChainDataProvider.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
import tech.pegasys.teku.spec.logic.common.statetransition.epoch.status.ValidatorStatuses;
9393
import tech.pegasys.teku.spec.logic.common.statetransition.exceptions.EpochProcessingException;
9494
import tech.pegasys.teku.spec.logic.common.statetransition.exceptions.SlotProcessingException;
95+
import tech.pegasys.teku.spec.logic.versions.gloas.helpers.PredicatesGloas;
9596
import tech.pegasys.teku.storage.client.BlobReconstructionProvider;
9697
import tech.pegasys.teku.storage.client.BlobSidecarReconstructionProvider;
9798
import tech.pegasys.teku.storage.client.ChainDataUnavailableException;
@@ -597,10 +598,7 @@ private int getBuilderStatus(final BeaconStateGloas state, final int builderInde
597598
if (!builder.getWithdrawableEpoch().equals(FAR_FUTURE_EPOCH)) {
598599
return StateBuilderData.STATUS_EXITED;
599600
}
600-
return spec.atSlot(state.getSlot())
601-
.miscHelpers()
602-
.toVersionGloas()
603-
.orElseThrow()
601+
return PredicatesGloas.required(spec.atSlot(state.getSlot()).predicates())
604602
.isActiveBuilder(state, UInt64.valueOf(builderIndex))
605603
? StateBuilderData.STATUS_ACTIVE
606604
: StateBuilderData.STATUS_PENDING;

data/provider/src/main/java/tech/pegasys/teku/api/NodeDataProvider.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import tech.pegasys.teku.infrastructure.ssz.SszList;
3535
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
3636
import tech.pegasys.teku.spec.Spec;
37-
import tech.pegasys.teku.spec.config.SpecConfigGloas;
3837
import tech.pegasys.teku.spec.datastructures.attestation.ProcessedAttestationListener;
3938
import tech.pegasys.teku.spec.datastructures.epbs.versions.gloas.PayloadAttestation;
4039
import tech.pegasys.teku.spec.datastructures.epbs.versions.gloas.PayloadAttestationMessage;
@@ -215,17 +214,10 @@ public SafeFuture<InternalValidationResult> postVoluntaryExit(final SignedVolunt
215214
.thenApply(
216215
state -> {
217216
final SszList<Validator> validators = state.getValidators();
218-
// TODO-GLOAS This would have a flow for builders, and they have 40th bit
219-
// set (it requires more validation)
220217
final UInt64 validatorId = exit.getValidatorId();
221-
if ((validatorId.longValue()
222-
& SpecConfigGloas.BUILDER_INDEX_FLAG.longValue())
223-
!= 0) {
224-
return InternalValidationResult.ACCEPT;
225-
}
226218
if (validatorId.isGreaterThanOrEqualTo(validators.size())) {
227219
return InternalValidationResult.reject(
228-
"Validator index %s was not found", validatorId);
220+
"Validator index %s was not found", exit.getValidatorId());
229221
} else if (validators
230222
.get(validatorId.intValue())
231223
.getExitEpoch()

data/provider/src/test/java/tech/pegasys/teku/api/NodeDataProviderTest.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,10 @@
3333
import tech.pegasys.teku.spec.SpecMilestone;
3434
import tech.pegasys.teku.spec.SpecVersion;
3535
import tech.pegasys.teku.spec.TestSpecFactory;
36-
import tech.pegasys.teku.spec.config.SpecConfigGloas;
3736
import tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing;
3837
import tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing;
3938
import tech.pegasys.teku.spec.datastructures.operations.SignedBlsToExecutionChange;
4039
import tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit;
41-
import tech.pegasys.teku.spec.datastructures.operations.VoluntaryExit;
42-
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState;
4340
import tech.pegasys.teku.spec.util.DataStructureUtil;
4441
import tech.pegasys.teku.statetransition.OperationPool;
4542
import tech.pegasys.teku.statetransition.attestation.AggregatingAttestationPool;
@@ -209,30 +206,6 @@ void attesterSlashingsMetaDataLookUp_UseSlotZero_WhenEmptyList_NoCurrentSlot() {
209206
verify(specMock).atSlot(eq(UInt64.ZERO));
210207
}
211208

212-
@Test
213-
void shouldAcceptBuilderVoluntaryExitWithoutCheckingValidatorList()
214-
throws ExecutionException, InterruptedException {
215-
final BeaconState state = mock(BeaconState.class);
216-
when(recentChainData.getBestState()).thenReturn(Optional.of(SafeFuture.completedFuture(state)));
217-
218-
final UInt64 builderValidatorIndex =
219-
UInt64.fromLongBits(
220-
UInt64.valueOf(3).longValue() | SpecConfigGloas.BUILDER_INDEX_FLAG.longValue());
221-
final SignedVoluntaryExit builderExit =
222-
new SignedVoluntaryExit(
223-
new VoluntaryExit(UInt64.ZERO, builderValidatorIndex),
224-
dataStructureUtil.randomSignature());
225-
226-
when(voluntaryExitPool.addLocal(builderExit))
227-
.thenReturn(SafeFuture.completedFuture(InternalValidationResult.ACCEPT));
228-
229-
final SafeFuture<InternalValidationResult> result = provider.postVoluntaryExit(builderExit);
230-
231-
assertThat(result).isCompleted();
232-
assertThat(result.get().isAccept()).isTrue();
233-
verify(voluntaryExitPool).addLocal(builderExit);
234-
}
235-
236209
private Spec setUpMockedSpec() {
237210
final Spec specMock = mock(Spec.class);
238211
final SpecVersion specVersionMock = mock(SpecVersion.class);

ethereum/spec/src/main/java/tech/pegasys/teku/spec/constants/Domain.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class Domain {
4141
public static final Bytes4 BUILDER_DEPOSIT = Bytes4.fromHexString("0x0E000000");
4242

4343
// Heze
44-
public static final Bytes4 INCLUSION_LIST_COMMITTEE = Bytes4.fromHexString("0x0E000000");
44+
public static final Bytes4 INCLUSION_LIST_COMMITTEE = Bytes4.fromHexString("0x0F000000");
4545

4646
// builder-specs
4747
public static final Bytes4 REQUEST_AUTH = Bytes4.fromHexString("0x0B000001");

ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/execution/versions/gloas/ExecutionRequestsGloas.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
package tech.pegasys.teku.spec.datastructures.execution.versions.gloas;
1515

16+
import static com.google.common.base.Preconditions.checkArgument;
17+
1618
import java.util.List;
1719
import java.util.Optional;
1820
import tech.pegasys.teku.infrastructure.ssz.SszList;
@@ -33,6 +35,14 @@ public class ExecutionRequestsGloas
3335
SszList<BuilderExitRequest>>
3436
implements ExecutionRequests {
3537

38+
public static ExecutionRequestsGloas required(final ExecutionRequests executionRequests) {
39+
checkArgument(
40+
executionRequests instanceof ExecutionRequestsGloas,
41+
"Expected ExecutionRequestsGloas but was %s",
42+
executionRequests.getClass());
43+
return (ExecutionRequestsGloas) executionRequests;
44+
}
45+
3646
ExecutionRequestsGloas(
3747
final ExecutionRequestsSchemaGloas schema,
3848
final List<DepositRequest> deposits,

ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/common/block/AbstractBlockProcessor.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -818,23 +818,15 @@ protected void processVoluntaryExitsNoValidation(
818818
invalidReason.isEmpty(),
819819
"process_voluntary_exits: %s",
820820
invalidReason.map(OperationInvalidReason::describe).orElse(""));
821-
822-
initiateExit(state, signedExit, validatorExitContextSupplier);
821+
// - Run initiate_validator_exit(state, exit.validator_index)
822+
beaconStateMutators.initiateValidatorExit(
823+
state,
824+
signedExit.getMessage().getValidatorIndex().intValue(),
825+
validatorExitContextSupplier);
823826
}
824827
});
825828
}
826829

827-
protected void initiateExit(
828-
final MutableBeaconState state,
829-
final SignedVoluntaryExit signedExit,
830-
final Supplier<ValidatorExitContext> validatorExitContextSupplier) {
831-
// - Run initiate_validator_exit(state, exit.validator_index)
832-
beaconStateMutators.initiateValidatorExit(
833-
state,
834-
signedExit.getMessage().getValidatorIndex().intValue(),
835-
validatorExitContextSupplier);
836-
}
837-
838830
protected BlockValidationResult verifyVoluntaryExits(
839831
final BeaconState state,
840832
final SszList<SignedVoluntaryExit> exits,

ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/common/execution/ExecutionRequestsProcessor.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ConsolidationRequest;
2020
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.DepositRequest;
2121
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.WithdrawalRequest;
22+
import tech.pegasys.teku.spec.datastructures.execution.versions.gloas.BuilderDepositRequest;
23+
import tech.pegasys.teku.spec.datastructures.execution.versions.gloas.BuilderExitRequest;
2224
import tech.pegasys.teku.spec.datastructures.state.beaconstate.MutableBeaconState;
2325
import tech.pegasys.teku.spec.logic.common.helpers.BeaconStateMutators.ValidatorExitContext;
2426

@@ -34,4 +36,10 @@ void processWithdrawalRequests(
3436

3537
void processConsolidationRequests(
3638
MutableBeaconState state, List<ConsolidationRequest> consolidationRequests);
39+
40+
void processBuilderDepositRequests(
41+
MutableBeaconState state, List<BuilderDepositRequest> builderDepositRequests);
42+
43+
void processBuilderExitRequests(
44+
MutableBeaconState state, List<BuilderExitRequest> builderExitRequests);
3745
}

ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/execution/ExecutionRequestsProcessorElectra.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ConsolidationRequest;
3333
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.DepositRequest;
3434
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.WithdrawalRequest;
35+
import tech.pegasys.teku.spec.datastructures.execution.versions.gloas.BuilderDepositRequest;
36+
import tech.pegasys.teku.spec.datastructures.execution.versions.gloas.BuilderExitRequest;
3537
import tech.pegasys.teku.spec.datastructures.state.Validator;
3638
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState;
3739
import tech.pegasys.teku.spec.datastructures.state.beaconstate.MutableBeaconState;
@@ -473,4 +475,16 @@ private boolean isValidSwitchToCompoundingRequest(
473475
// Verify exit for source has not been initiated
474476
return sourceValidator.getExitEpoch().equals(FAR_FUTURE_EPOCH);
475477
}
478+
479+
@Override
480+
public void processBuilderDepositRequests(
481+
final MutableBeaconState state, final List<BuilderDepositRequest> builderDepositRequests) {
482+
// NO-OP (until Gloas)
483+
}
484+
485+
@Override
486+
public void processBuilderExitRequests(
487+
final MutableBeaconState state, final List<BuilderExitRequest> builderExitRequests) {
488+
// NO-OP (until Gloas)
489+
}
476490
}

0 commit comments

Comments
 (0)