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

Move processWithdrawalRequests to BlockProcessorElectra #8711

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ public class SanityBlocksTestExecutor implements TestExecutor {
"Block state root does NOT match the calculated state root";

// TODO re-enable tests as part of https://github.com/Consensys/teku/issues/8680
private static final List<String> IGNORED_TEST_NAMES =
List.of(
"basic_el_withdrawal_request",
"basic_btec_and_el_withdrawal_request_in_same_block",
"cl_exit_and_el_withdrawal_request_in_same_block");
private static final List<String> IGNORED_TEST_NAMES = List.of();
gfukushima marked this conversation as resolved.
Show resolved Hide resolved

@Override
public void runTest(final TestDefinition testDefinition) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,13 @@ protected void processBlock(
processBlockHeader(state, block);
processRandaoNoValidation(state, block.getBody());
processEth1Data(state, block.getBody());
processOperationsNoValidation(state, block.getBody(), indexedAttestationCache);
processOperationsNoValidation(
state, block.getBody(), indexedAttestationCache, getValidatorExitContextSupplier(state));
}

protected Supplier<ValidatorExitContext> getValidatorExitContextSupplier(
final MutableBeaconState state) {
return beaconStateMutators.createValidatorExitContextSupplier(state);
}

@Override
Expand Down Expand Up @@ -431,15 +437,13 @@ public long getVoteCount(final BeaconState state, final Eth1Data eth1Data) {
protected void processOperationsNoValidation(
final MutableBeaconState state,
final BeaconBlockBody body,
final IndexedAttestationCache indexedAttestationCache)
final IndexedAttestationCache indexedAttestationCache,
final Supplier<ValidatorExitContext> validatorExitContextSupplier)
throws BlockProcessingException {
safelyProcess(
() -> {
verifyOutstandingDepositsAreProcessed(state, body);

final Supplier<ValidatorExitContext> validatorExitContextSupplier =
beaconStateMutators.createValidatorExitContextSupplier(state);

processProposerSlashingsNoValidation(
state, body.getProposerSlashings(), validatorExitContextSupplier);
processAttesterSlashings(
Expand All @@ -448,7 +452,6 @@ protected void processOperationsNoValidation(
processDeposits(state, body.getDeposits());
processVoluntaryExitsNoValidation(
state, body.getVoluntaryExits(), validatorExitContextSupplier);
processWithdrawalRequests(state, body, validatorExitContextSupplier);
});
}

Expand All @@ -471,7 +474,7 @@ public void processProposerSlashings(
final BLSSignatureVerifier signatureVerifier)
throws BlockProcessingException {
final Supplier<ValidatorExitContext> validatorExitContextSupplier =
beaconStateMutators.createValidatorExitContextSupplier(state);
getValidatorExitContextSupplier(state);
processProposerSlashingsNoValidation(state, proposerSlashings, validatorExitContextSupplier);
final BlockValidationResult validationResult =
verifyProposerSlashings(state, proposerSlashings, signatureVerifier);
Expand Down Expand Up @@ -530,7 +533,7 @@ public void processAttesterSlashings(
safelyProcess(
() -> {
final Supplier<ValidatorExitContext> validatorExitContextSupplier =
beaconStateMutators.createValidatorExitContextSupplier(state);
getValidatorExitContextSupplier(state);
processAttesterSlashings(state, attesterSlashings, validatorExitContextSupplier);
});
}
Expand Down Expand Up @@ -851,7 +854,7 @@ public void processVoluntaryExits(
final BLSSignatureVerifier signatureVerifier)
throws BlockProcessingException {
final Supplier<ValidatorExitContext> validatorExitContextSupplier =
beaconStateMutators.createValidatorExitContextSupplier(state);
getValidatorExitContextSupplier(state);
processVoluntaryExitsNoValidation(state, exits, validatorExitContextSupplier);
BlockValidationResult signaturesValid = verifyVoluntaryExits(state, exits, signatureVerifier);
if (!signaturesValid.isValid()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ public void processBlock(
}
processRandaoNoValidation(state, block.getBody());
processEth1Data(state, block.getBody());
processOperationsNoValidation(state, block.getBody(), indexedAttestationCache);
processOperationsNoValidation(
state, block.getBody(), indexedAttestationCache, getValidatorExitContextSupplier(state));
processSyncAggregate(
state, blockBody.getOptionalSyncAggregate().orElseThrow(), signatureVerifier);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import java.util.function.Supplier;
import javax.annotation.CheckReturnValue;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
Expand Down Expand Up @@ -130,9 +131,11 @@ protected BlockValidationResult validateBlockPreProcessing(
protected void processOperationsNoValidation(
final MutableBeaconState state,
final BeaconBlockBody body,
final IndexedAttestationCache indexedAttestationCache)
final IndexedAttestationCache indexedAttestationCache,
final Supplier<BeaconStateMutators.ValidatorExitContext> validatorExitContextSupplier)
throws BlockProcessingException {
super.processOperationsNoValidation(state, body, indexedAttestationCache);
super.processOperationsNoValidation(
state, body, indexedAttestationCache, validatorExitContextSupplier);

safelyProcess(
() ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,20 @@ public NewPayloadRequest computeNewPayloadRequest(
protected void processOperationsNoValidation(
final MutableBeaconState state,
final BeaconBlockBody body,
final IndexedAttestationCache indexedAttestationCache)
final IndexedAttestationCache indexedAttestationCache,
final Supplier<ValidatorExitContext> validatorExitContextSupplier)
throws BlockProcessingException {
super.processOperationsNoValidation(state, body, indexedAttestationCache);
super.processOperationsNoValidation(
state, body, indexedAttestationCache, validatorExitContextSupplier);

safelyProcess(
() -> {
final ExecutionRequests executionRequests =
BeaconBlockBodyElectra.required(body).getExecutionRequests();

this.processDepositRequests(state, executionRequests.getDeposits());
this.processWithdrawalRequests(
state, executionRequests.getWithdrawals(), validatorExitContextSupplier);
this.processConsolidationRequests(state, executionRequests.getConsolidations());
});
}
Expand Down