Skip to content
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 @@ -75,7 +75,8 @@ public void shouldIncludeRejectReasonWhenOperationValidatorRejectsOperation() th

@Test
public void shouldReturnServerErrorWhenUnexpectedErrorHappens() throws Exception {
final SignedVoluntaryExit signedVoluntaryExit = dataStructureUtil.randomSignedVoluntaryExit();
final SignedVoluntaryExit signedVoluntaryExit =
dataStructureUtil.randomSignedVoluntaryExit(UInt64.ZERO);
doThrow(new RuntimeException()).when(voluntaryExitPool).addLocal(signedVoluntaryExit);

final Response response = getResponse(signedVoluntaryExit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"DOMAIN_VOLUNTARY_EXIT" : "0x04000000",
"SYNC_MESSAGE_DUE_BPS_GLOAS" : "2500",
"ALTAIR_FORK_EPOCH" : "74240",
"DOMAIN_INCLUSION_LIST_COMMITTEE" : "0x0e000000",
"DOMAIN_INCLUSION_LIST_COMMITTEE" : "0x0f000000",
"ALTAIR_FORK_VERSION" : "0x01000000",
"INCLUSION_LIST_COMMITTEE_SIZE" : "16",
"PROPOSER_REWARD_QUOTIENT" : "8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
import tech.pegasys.teku.spec.logic.common.statetransition.epoch.status.ValidatorStatuses;
import tech.pegasys.teku.spec.logic.common.statetransition.exceptions.EpochProcessingException;
import tech.pegasys.teku.spec.logic.common.statetransition.exceptions.SlotProcessingException;
import tech.pegasys.teku.spec.logic.versions.gloas.helpers.PredicatesGloas;
import tech.pegasys.teku.storage.client.BlobReconstructionProvider;
import tech.pegasys.teku.storage.client.BlobSidecarReconstructionProvider;
import tech.pegasys.teku.storage.client.ChainDataUnavailableException;
Expand Down Expand Up @@ -597,10 +598,7 @@ private int getBuilderStatus(final BeaconStateGloas state, final int builderInde
if (!builder.getWithdrawableEpoch().equals(FAR_FUTURE_EPOCH)) {
return StateBuilderData.STATUS_EXITED;
}
return spec.atSlot(state.getSlot())
.miscHelpers()
.toVersionGloas()
.orElseThrow()
return PredicatesGloas.required(spec.atSlot(state.getSlot()).predicates())
.isActiveBuilder(state, UInt64.valueOf(builderIndex))
? StateBuilderData.STATUS_ACTIVE
: StateBuilderData.STATUS_PENDING;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import tech.pegasys.teku.infrastructure.ssz.SszList;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.config.SpecConfigGloas;
import tech.pegasys.teku.spec.datastructures.attestation.ProcessedAttestationListener;
import tech.pegasys.teku.spec.datastructures.epbs.versions.gloas.PayloadAttestation;
import tech.pegasys.teku.spec.datastructures.epbs.versions.gloas.PayloadAttestationMessage;
Expand Down Expand Up @@ -215,17 +214,10 @@ public SafeFuture<InternalValidationResult> postVoluntaryExit(final SignedVolunt
.thenApply(
state -> {
final SszList<Validator> validators = state.getValidators();
// TODO-GLOAS This would have a flow for builders, and they have 40th bit
// set (it requires more validation)
final UInt64 validatorId = exit.getValidatorId();
if ((validatorId.longValue()
& SpecConfigGloas.BUILDER_INDEX_FLAG.longValue())
!= 0) {
return InternalValidationResult.ACCEPT;
}
if (validatorId.isGreaterThanOrEqualTo(validators.size())) {
return InternalValidationResult.reject(
"Validator index %s was not found", validatorId);
"Validator index %s was not found", exit.getValidatorId());
} else if (validators
.get(validatorId.intValue())
.getExitEpoch()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@
import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.SpecVersion;
import tech.pegasys.teku.spec.TestSpecFactory;
import tech.pegasys.teku.spec.config.SpecConfigGloas;
import tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing;
import tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing;
import tech.pegasys.teku.spec.datastructures.operations.SignedBlsToExecutionChange;
import tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit;
import tech.pegasys.teku.spec.datastructures.operations.VoluntaryExit;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState;
import tech.pegasys.teku.spec.util.DataStructureUtil;
import tech.pegasys.teku.statetransition.OperationPool;
import tech.pegasys.teku.statetransition.attestation.AggregatingAttestationPool;
Expand Down Expand Up @@ -209,30 +206,6 @@ void attesterSlashingsMetaDataLookUp_UseSlotZero_WhenEmptyList_NoCurrentSlot() {
verify(specMock).atSlot(eq(UInt64.ZERO));
}

@Test
void shouldAcceptBuilderVoluntaryExitWithoutCheckingValidatorList()
throws ExecutionException, InterruptedException {
final BeaconState state = mock(BeaconState.class);
when(recentChainData.getBestState()).thenReturn(Optional.of(SafeFuture.completedFuture(state)));

final UInt64 builderValidatorIndex =
UInt64.fromLongBits(
UInt64.valueOf(3).longValue() | SpecConfigGloas.BUILDER_INDEX_FLAG.longValue());
final SignedVoluntaryExit builderExit =
new SignedVoluntaryExit(
new VoluntaryExit(UInt64.ZERO, builderValidatorIndex),
dataStructureUtil.randomSignature());

when(voluntaryExitPool.addLocal(builderExit))
.thenReturn(SafeFuture.completedFuture(InternalValidationResult.ACCEPT));

final SafeFuture<InternalValidationResult> result = provider.postVoluntaryExit(builderExit);

assertThat(result).isCompleted();
assertThat(result.get().isAccept()).isTrue();
verify(voluntaryExitPool).addLocal(builderExit);
}

private Spec setUpMockedSpec() {
final Spec specMock = mock(Spec.class);
final SpecVersion specVersionMock = mock(SpecVersion.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class Domain {
public static final Bytes4 BUILDER_DEPOSIT = Bytes4.fromHexString("0x0E000000");

// Heze
public static final Bytes4 INCLUSION_LIST_COMMITTEE = Bytes4.fromHexString("0x0E000000");
public static final Bytes4 INCLUSION_LIST_COMMITTEE = Bytes4.fromHexString("0x0F000000");

// builder-specs
public static final Bytes4 REQUEST_AUTH = Bytes4.fromHexString("0x0B000001");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

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

import static com.google.common.base.Preconditions.checkArgument;

import java.util.List;
import java.util.Optional;
import tech.pegasys.teku.infrastructure.ssz.SszList;
Expand All @@ -33,6 +35,14 @@ public class ExecutionRequestsGloas
SszList<BuilderExitRequest>>
implements ExecutionRequests {

public static ExecutionRequestsGloas required(final ExecutionRequests executionRequests) {
checkArgument(
executionRequests instanceof ExecutionRequestsGloas,
"Expected ExecutionRequestsGloas but was %s",
executionRequests.getClass());
return (ExecutionRequestsGloas) executionRequests;
}

ExecutionRequestsGloas(
final ExecutionRequestsSchemaGloas schema,
final List<DepositRequest> deposits,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -818,23 +818,15 @@ protected void processVoluntaryExitsNoValidation(
invalidReason.isEmpty(),
"process_voluntary_exits: %s",
invalidReason.map(OperationInvalidReason::describe).orElse(""));

initiateExit(state, signedExit, validatorExitContextSupplier);
// - Run initiate_validator_exit(state, exit.validator_index)
beaconStateMutators.initiateValidatorExit(
state,
signedExit.getMessage().getValidatorIndex().intValue(),
validatorExitContextSupplier);
Comment thread
cursor[bot] marked this conversation as resolved.
}
});
}

protected void initiateExit(
final MutableBeaconState state,
final SignedVoluntaryExit signedExit,
final Supplier<ValidatorExitContext> validatorExitContextSupplier) {
// - Run initiate_validator_exit(state, exit.validator_index)
beaconStateMutators.initiateValidatorExit(
state,
signedExit.getMessage().getValidatorIndex().intValue(),
validatorExitContextSupplier);
}

protected BlockValidationResult verifyVoluntaryExits(
final BeaconState state,
final SszList<SignedVoluntaryExit> exits,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ConsolidationRequest;
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.DepositRequest;
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.WithdrawalRequest;
import tech.pegasys.teku.spec.datastructures.execution.versions.gloas.BuilderDepositRequest;
import tech.pegasys.teku.spec.datastructures.execution.versions.gloas.BuilderExitRequest;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.MutableBeaconState;
import tech.pegasys.teku.spec.logic.common.helpers.BeaconStateMutators.ValidatorExitContext;

Expand All @@ -34,4 +36,10 @@ void processWithdrawalRequests(

void processConsolidationRequests(
MutableBeaconState state, List<ConsolidationRequest> consolidationRequests);

void processBuilderDepositRequests(
MutableBeaconState state, List<BuilderDepositRequest> builderDepositRequests);

void processBuilderExitRequests(
MutableBeaconState state, List<BuilderExitRequest> builderExitRequests);
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ConsolidationRequest;
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.DepositRequest;
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.WithdrawalRequest;
import tech.pegasys.teku.spec.datastructures.execution.versions.gloas.BuilderDepositRequest;
import tech.pegasys.teku.spec.datastructures.execution.versions.gloas.BuilderExitRequest;
import tech.pegasys.teku.spec.datastructures.state.Validator;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.MutableBeaconState;
Expand Down Expand Up @@ -473,4 +475,16 @@ private boolean isValidSwitchToCompoundingRequest(
// Verify exit for source has not been initiated
return sourceValidator.getExitEpoch().equals(FAR_FUTURE_EPOCH);
}

@Override
public void processBuilderDepositRequests(
final MutableBeaconState state, final List<BuilderDepositRequest> builderDepositRequests) {
// NO-OP (until Gloas)
}

@Override
public void processBuilderExitRequests(
final MutableBeaconState state, final List<BuilderExitRequest> builderExitRequests) {
// NO-OP (until Gloas)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import tech.pegasys.teku.spec.logic.versions.capella.operations.validation.OperationValidatorCapella;
import tech.pegasys.teku.spec.logic.versions.electra.execution.ExecutionRequestsProcessorElectra;
import tech.pegasys.teku.spec.logic.versions.electra.helpers.BeaconStateMutatorsElectra;
import tech.pegasys.teku.spec.logic.versions.electra.operations.validation.VoluntaryExitValidatorElectra;
import tech.pegasys.teku.spec.logic.versions.fulu.util.BlindBlockUtilFulu;
import tech.pegasys.teku.spec.logic.versions.fulu.util.BlockProposalUtilFulu;
import tech.pegasys.teku.spec.logic.versions.gloas.block.BlockProcessorGloas;
Expand All @@ -49,7 +50,6 @@
import tech.pegasys.teku.spec.logic.versions.gloas.helpers.PredicatesGloas;
import tech.pegasys.teku.spec.logic.versions.gloas.operations.OperationSignatureVerifierGloas;
import tech.pegasys.teku.spec.logic.versions.gloas.operations.validation.AttestationDataValidatorGloas;
import tech.pegasys.teku.spec.logic.versions.gloas.operations.validation.VoluntaryExitValidatorGloas;
import tech.pegasys.teku.spec.logic.versions.gloas.statetransition.epoch.EpochProcessorGloas;
import tech.pegasys.teku.spec.logic.versions.gloas.util.AttestationUtilGloas;
import tech.pegasys.teku.spec.logic.versions.gloas.util.DataColumnSidecarUtilGloas;
Expand Down Expand Up @@ -155,8 +155,8 @@ public static SpecLogicGloas create(
new AttestationUtilGloas(config, schemaDefinitions, beaconStateAccessors, miscHelpers);
final AttestationDataValidatorGloas attestationDataValidator =
new AttestationDataValidatorGloas(config, miscHelpers, beaconStateAccessors);
final VoluntaryExitValidatorGloas voluntaryExitValidator =
new VoluntaryExitValidatorGloas(config, predicates, beaconStateAccessors, miscHelpers);
final VoluntaryExitValidatorElectra voluntaryExitValidator =
new VoluntaryExitValidatorElectra(config, predicates, beaconStateAccessors);
final OperationValidator operationValidator =
new OperationValidatorCapella(
predicates,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadSummary;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionRequests;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionRequestsDataCodec;
import tech.pegasys.teku.spec.datastructures.execution.versions.gloas.ExecutionRequestsGloas;
import tech.pegasys.teku.spec.datastructures.operations.AttestationData;
import tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing;
import tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.MutableBeaconState;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.gloas.BeaconStateGloas;
Expand Down Expand Up @@ -142,18 +142,17 @@ public void processParentExecutionPayload(
final ExecutionPayloadBid bid = body.getSignedExecutionPayloadBid().getMessage();
final ExecutionRequests requests = body.getParentExecutionRequests();

if (!miscHelpersGloas.isExecutionPayloadBidForFullParent(state, bid)) {
if (!miscHelpersGloas.isBidBuildingOnFullParent(stateGloas, bid)) {
// Parent was EMPTY -- no execution requests expected
if (!miscHelpersGloas.isEmptyExecutionRequests(requests)) {
if (!requests.isDefault()) {
throw new BlockProcessingException(
"No execution requests were expected for an EMPTY parent");
}
return;
}

// Parent was FULL -- verify the bid commitment and apply the payload
if (!miscHelpersGloas.isExecutionRequestsRootMatchingLatestExecutionPayloadBid(
state, requests)) {
if (!miscHelpersGloas.isExecutionRequestsRootMatchingLatestBid(stateGloas, requests)) {
throw new BlockProcessingException(
"The execution requests root in the latest committed bid does not match the parent execution requests in the block");
}
Expand Down Expand Up @@ -184,6 +183,11 @@ public void applyParentExecutionPayload(
state, requests.getWithdrawals(), validatorExitContextSupplier);
executionRequestsProcessorGloas.processConsolidationRequests(
state, requests.getConsolidations());
final ExecutionRequestsGloas requestsGloas = ExecutionRequestsGloas.required(requests);
executionRequestsProcessorGloas.processBuilderDepositRequests(
state, requestsGloas.getBuilderDeposits());
executionRequestsProcessorGloas.processBuilderExitRequests(
state, requestsGloas.getBuilderExits());

// Settle the builder payment
if (parentEpoch.equals(beaconStateAccessorsGloas.getCurrentEpoch(state))) {
Expand Down Expand Up @@ -423,23 +427,6 @@ protected void processOperationsNoValidation(
"Payload attestations expected as part of the body"))));
}

@Override
protected void initiateExit(
final MutableBeaconState state,
final SignedVoluntaryExit signedExit,
final Supplier<ValidatorExitContext> validatorExitContextSupplier) {
final UInt64 validatorIndex = signedExit.getMessage().getValidatorIndex();
if (predicatesGloas.isBuilderIndex(validatorIndex)) {
// - Run initiate_builder_exit(state, builder_index)
beaconStateMutatorsGloas.initiateBuilderExit(
state, miscHelpersGloas.convertValidatorIndexToBuilderIndex(validatorIndex));
} else {
// - Run initiate_validator_exit(state, exit.validator_index)
beaconStateMutators.initiateValidatorExit(
state, validatorIndex.intValue(), validatorExitContextSupplier);
}
}

@Override
public void processExecutionRequests(
final MutableBeaconState state,
Expand Down
Loading
Loading