Skip to content

Commit c585055

Browse files
authored
Move processWithdrawalRequests to BlockProcessorElectra (#8711)
* remove test fixed from the list of ignored tests * move processWithdrawalRequests to BlockProcessorElectra * expose supplier so it can be accessed from ElectraBLockProcessor --------- Signed-off-by: Gabriel Fukushima <[email protected]>
1 parent 7ed548e commit c585055

File tree

5 files changed

+27
-20
lines changed

5 files changed

+27
-20
lines changed

eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/phase0/sanity/SanityBlocksTestExecutor.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,7 @@ public class SanityBlocksTestExecutor implements TestExecutor {
4141
private static final String STATE_ROOT_MISMATCH_ERROR_MESSAGE =
4242
"Block state root does NOT match the calculated state root";
4343

44-
// TODO re-enable tests as part of https://github.com/Consensys/teku/issues/8680
45-
private static final List<String> IGNORED_TEST_NAMES =
46-
List.of(
47-
"basic_el_withdrawal_request",
48-
"basic_btec_and_el_withdrawal_request_in_same_block",
49-
"cl_exit_and_el_withdrawal_request_in_same_block");
44+
private static final List<String> IGNORED_TEST_NAMES = List.of();
5045

5146
@Override
5247
public void runTest(final TestDefinition testDefinition) throws Exception {

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,13 @@ protected void processBlock(
340340
processBlockHeader(state, block);
341341
processRandaoNoValidation(state, block.getBody());
342342
processEth1Data(state, block.getBody());
343-
processOperationsNoValidation(state, block.getBody(), indexedAttestationCache);
343+
processOperationsNoValidation(
344+
state, block.getBody(), indexedAttestationCache, getValidatorExitContextSupplier(state));
345+
}
346+
347+
protected Supplier<ValidatorExitContext> getValidatorExitContextSupplier(
348+
final MutableBeaconState state) {
349+
return beaconStateMutators.createValidatorExitContextSupplier(state);
344350
}
345351

346352
@Override
@@ -431,15 +437,13 @@ public long getVoteCount(final BeaconState state, final Eth1Data eth1Data) {
431437
protected void processOperationsNoValidation(
432438
final MutableBeaconState state,
433439
final BeaconBlockBody body,
434-
final IndexedAttestationCache indexedAttestationCache)
440+
final IndexedAttestationCache indexedAttestationCache,
441+
final Supplier<ValidatorExitContext> validatorExitContextSupplier)
435442
throws BlockProcessingException {
436443
safelyProcess(
437444
() -> {
438445
verifyOutstandingDepositsAreProcessed(state, body);
439446

440-
final Supplier<ValidatorExitContext> validatorExitContextSupplier =
441-
beaconStateMutators.createValidatorExitContextSupplier(state);
442-
443447
processProposerSlashingsNoValidation(
444448
state, body.getProposerSlashings(), validatorExitContextSupplier);
445449
processAttesterSlashings(
@@ -448,7 +452,6 @@ protected void processOperationsNoValidation(
448452
processDeposits(state, body.getDeposits());
449453
processVoluntaryExitsNoValidation(
450454
state, body.getVoluntaryExits(), validatorExitContextSupplier);
451-
processWithdrawalRequests(state, body, validatorExitContextSupplier);
452455
});
453456
}
454457

@@ -471,7 +474,7 @@ public void processProposerSlashings(
471474
final BLSSignatureVerifier signatureVerifier)
472475
throws BlockProcessingException {
473476
final Supplier<ValidatorExitContext> validatorExitContextSupplier =
474-
beaconStateMutators.createValidatorExitContextSupplier(state);
477+
getValidatorExitContextSupplier(state);
475478
processProposerSlashingsNoValidation(state, proposerSlashings, validatorExitContextSupplier);
476479
final BlockValidationResult validationResult =
477480
verifyProposerSlashings(state, proposerSlashings, signatureVerifier);
@@ -530,7 +533,7 @@ public void processAttesterSlashings(
530533
safelyProcess(
531534
() -> {
532535
final Supplier<ValidatorExitContext> validatorExitContextSupplier =
533-
beaconStateMutators.createValidatorExitContextSupplier(state);
536+
getValidatorExitContextSupplier(state);
534537
processAttesterSlashings(state, attesterSlashings, validatorExitContextSupplier);
535538
});
536539
}
@@ -851,7 +854,7 @@ public void processVoluntaryExits(
851854
final BLSSignatureVerifier signatureVerifier)
852855
throws BlockProcessingException {
853856
final Supplier<ValidatorExitContext> validatorExitContextSupplier =
854-
beaconStateMutators.createValidatorExitContextSupplier(state);
857+
getValidatorExitContextSupplier(state);
855858
processVoluntaryExitsNoValidation(state, exits, validatorExitContextSupplier);
856859
BlockValidationResult signaturesValid = verifyVoluntaryExits(state, exits, signatureVerifier);
857860
if (!signaturesValid.isValid()) {

ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/bellatrix/block/BlockProcessorBellatrix.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ public void processBlock(
101101
}
102102
processRandaoNoValidation(state, block.getBody());
103103
processEth1Data(state, block.getBody());
104-
processOperationsNoValidation(state, block.getBody(), indexedAttestationCache);
104+
processOperationsNoValidation(
105+
state, block.getBody(), indexedAttestationCache, getValidatorExitContextSupplier(state));
105106
processSyncAggregate(
106107
state, blockBody.getOptionalSyncAggregate().orElseThrow(), signatureVerifier);
107108
}

ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/capella/block/BlockProcessorCapella.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.HashSet;
2020
import java.util.Optional;
2121
import java.util.Set;
22+
import java.util.function.Supplier;
2223
import javax.annotation.CheckReturnValue;
2324
import org.apache.tuweni.bytes.Bytes;
2425
import org.apache.tuweni.bytes.Bytes32;
@@ -130,9 +131,11 @@ protected BlockValidationResult validateBlockPreProcessing(
130131
protected void processOperationsNoValidation(
131132
final MutableBeaconState state,
132133
final BeaconBlockBody body,
133-
final IndexedAttestationCache indexedAttestationCache)
134+
final IndexedAttestationCache indexedAttestationCache,
135+
final Supplier<BeaconStateMutators.ValidatorExitContext> validatorExitContextSupplier)
134136
throws BlockProcessingException {
135-
super.processOperationsNoValidation(state, body, indexedAttestationCache);
137+
super.processOperationsNoValidation(
138+
state, body, indexedAttestationCache, validatorExitContextSupplier);
136139

137140
safelyProcess(
138141
() ->

ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/block/BlockProcessorElectra.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,20 @@ public NewPayloadRequest computeNewPayloadRequest(
153153
protected void processOperationsNoValidation(
154154
final MutableBeaconState state,
155155
final BeaconBlockBody body,
156-
final IndexedAttestationCache indexedAttestationCache)
156+
final IndexedAttestationCache indexedAttestationCache,
157+
final Supplier<ValidatorExitContext> validatorExitContextSupplier)
157158
throws BlockProcessingException {
158-
super.processOperationsNoValidation(state, body, indexedAttestationCache);
159+
super.processOperationsNoValidation(
160+
state, body, indexedAttestationCache, validatorExitContextSupplier);
159161

160162
safelyProcess(
161163
() -> {
162164
final ExecutionRequests executionRequests =
163165
BeaconBlockBodyElectra.required(body).getExecutionRequests();
166+
164167
this.processDepositRequests(state, executionRequests.getDeposits());
168+
this.processWithdrawalRequests(
169+
state, executionRequests.getWithdrawals(), validatorExitContextSupplier);
165170
this.processConsolidationRequests(state, executionRequests.getConsolidations());
166171
});
167172
}

0 commit comments

Comments
 (0)