From 4bcc4db889c89e812f71042e6903c556eb5fb963 Mon Sep 17 00:00:00 2001 From: Paul Harris Date: Tue, 17 Dec 2024 11:56:00 +1000 Subject: [PATCH] Updated consolidation rules for devnet5 (#8876) - updated fuzzUtil to use prettyJson to report diffs for the tests that broke... - currently the fuzz utils need some changes, will just raise a draft until we're ready... fixes #8875 Signed-off-by: Paul Harris --- .../beaconrestapi/handlers/v1/config/mainnetConfig.json | 2 +- .../common/operations/DefaultOperationProcessor.java | 2 +- .../reference/common/operations/OperationProcessor.java | 2 +- .../common/operations/OperationsTestExecutor.java | 6 +++--- .../versions/electra/block/BlockProcessorElectra.java | 9 ++------- .../teku/spec/config/presets/mainnet/electra.yaml | 2 +- .../teku/spec/config/presets/minimal/electra.yaml | 2 +- .../pegasys/teku/spec/config/presets/swift/electra.yaml | 2 +- fuzz/build.gradle | 2 ++ fuzz/src/main/java/tech/pegasys/teku/fuzz/FuzzUtil.java | 4 ++-- 10 files changed, 15 insertions(+), 18 deletions(-) diff --git a/data/beaconrestapi/src/test/resources/tech/pegasys/teku/beaconrestapi/handlers/v1/config/mainnetConfig.json b/data/beaconrestapi/src/test/resources/tech/pegasys/teku/beaconrestapi/handlers/v1/config/mainnetConfig.json index 1a551da743b..68f03baa8b2 100644 --- a/data/beaconrestapi/src/test/resources/tech/pegasys/teku/beaconrestapi/handlers/v1/config/mainnetConfig.json +++ b/data/beaconrestapi/src/test/resources/tech/pegasys/teku/beaconrestapi/handlers/v1/config/mainnetConfig.json @@ -131,7 +131,7 @@ "GENESIS_FORK_VERSION" : "0x00000000", "KZG_COMMITMENT_INCLUSION_PROOF_DEPTH" : "17", "DEPOSIT_NETWORK_ID" : "1", -"MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD" : "1", +"MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD" : "2", "MAX_REQUEST_BLOCKS_DENEB" : "128", "BLOB_SIDECAR_SUBNET_COUNT" : "6", "SYNC_COMMITTEE_SUBNET_COUNT" : "4", diff --git a/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/common/operations/DefaultOperationProcessor.java b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/common/operations/DefaultOperationProcessor.java index c861fbbab61..d0d8656dcfe 100644 --- a/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/common/operations/DefaultOperationProcessor.java +++ b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/common/operations/DefaultOperationProcessor.java @@ -160,7 +160,7 @@ public void processWithdrawalRequest( } @Override - public void processConsolidationRequest( + public void processConsolidationRequests( final MutableBeaconState state, final List consolidationRequests) throws BlockProcessingException { spec.getBlockProcessor(state.getSlot()) diff --git a/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/common/operations/OperationProcessor.java b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/common/operations/OperationProcessor.java index 519468ce32f..bae92e06718 100644 --- a/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/common/operations/OperationProcessor.java +++ b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/common/operations/OperationProcessor.java @@ -73,7 +73,7 @@ void processDepositRequest(MutableBeaconState state, List deposi void processWithdrawalRequest(MutableBeaconState state, List withdrawalRequest) throws BlockProcessingException; - void processConsolidationRequest( + void processConsolidationRequests( MutableBeaconState state, List consolidationRequest) throws BlockProcessingException; } diff --git a/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/common/operations/OperationsTestExecutor.java b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/common/operations/OperationsTestExecutor.java index df11615cc16..7f25fee5231 100644 --- a/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/common/operations/OperationsTestExecutor.java +++ b/eth-reference-tests/src/referenceTest/java/tech/pegasys/teku/reference/common/operations/OperationsTestExecutor.java @@ -320,7 +320,7 @@ private void processOperation( case WITHDRAWAL -> processWithdrawal(testDefinition, state, processor); case DEPOSIT_REQUEST -> processDepositRequest(testDefinition, state, processor); case WITHDRAWAL_REQUEST -> processWithdrawalRequest(testDefinition, state, processor); - case CONSOLIDATION_REQUEST -> processConsolidation(testDefinition, state, processor); + case CONSOLIDATION_REQUEST -> processConsolidations(testDefinition, state, processor); default -> throw new UnsupportedOperationException( "Operation " + operation + " not implemented in OperationTestExecutor"); @@ -381,7 +381,7 @@ private void processWithdrawalRequest( processor.processWithdrawalRequest(state, withdrawalRequests.asList()); } - private void processConsolidation( + private void processConsolidations( final TestDefinition testDefinition, final MutableBeaconState state, final OperationProcessor processor) @@ -394,7 +394,7 @@ private void processConsolidation( final SszList consolidationRequests = loadSsz(testDefinition, dataFileName, consolidationRequestsSchema); - processor.processConsolidationRequest(state, consolidationRequests.asList()); + processor.processConsolidationRequests(state, consolidationRequests.asList()); } private SignedVoluntaryExit loadVoluntaryExit(final TestDefinition testDefinition) { diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/block/BlockProcessorElectra.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/block/BlockProcessorElectra.java index 375e2b6dd0d..f28fc1a3772 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/block/BlockProcessorElectra.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/block/BlockProcessorElectra.java @@ -491,8 +491,8 @@ private void processConsolidationRequest( return; } - // Verify that target has execution withdrawal credentials - if (!predicatesElectra.hasExecutionWithdrawalCredential(targetValidator)) { + // Verify that target has compounding withdrawal credentials + if (!predicatesElectra.hasCompoundingWithdrawalCredential(targetValidator)) { LOG.debug("process_consolidation_request: invalid target credentials"); return; } @@ -560,11 +560,6 @@ private void processConsolidationRequest( SszUInt64.of(UInt64.valueOf(targetValidatorIndex))); state.getPendingConsolidations().append(pendingConsolidation); - // Churn any target excess active balance of target and raise its max - if (predicatesElectra.hasEth1WithdrawalCredential(targetValidator)) { - beaconStateMutatorsElectra.switchToCompoundingValidator(state, targetValidatorIndex); - } - LOG.debug("process_consolidation_request: created {}", pendingConsolidation); } diff --git a/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/mainnet/electra.yaml b/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/mainnet/electra.yaml index 0b594ff3404..4bb3ebe2fe5 100644 --- a/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/mainnet/electra.yaml +++ b/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/mainnet/electra.yaml @@ -30,7 +30,7 @@ MAX_ATTESTER_SLASHINGS_ELECTRA: 1 # `uint64(2**3)` (= 8) MAX_ATTESTATIONS_ELECTRA: 8 # `uint64(2**0)` (= 1) -MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 1 +MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 2 # Execution # --------------------------------------------------------------- diff --git a/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/minimal/electra.yaml b/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/minimal/electra.yaml index 71adaa4aaa0..c87a328472f 100644 --- a/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/minimal/electra.yaml +++ b/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/minimal/electra.yaml @@ -30,7 +30,7 @@ MAX_ATTESTER_SLASHINGS_ELECTRA: 1 # `uint64(2**3)` (= 8) MAX_ATTESTATIONS_ELECTRA: 8 # `uint64(2**0)` (= 1) -MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 1 +MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 2 # Execution # --------------------------------------------------------------- diff --git a/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/swift/electra.yaml b/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/swift/electra.yaml index 71adaa4aaa0..c87a328472f 100644 --- a/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/swift/electra.yaml +++ b/ethereum/spec/src/main/resources/tech/pegasys/teku/spec/config/presets/swift/electra.yaml @@ -30,7 +30,7 @@ MAX_ATTESTER_SLASHINGS_ELECTRA: 1 # `uint64(2**3)` (= 8) MAX_ATTESTATIONS_ELECTRA: 8 # `uint64(2**0)` (= 1) -MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 1 +MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 2 # Execution # --------------------------------------------------------------- diff --git a/fuzz/build.gradle b/fuzz/build.gradle index 66e809ff2e8..c8d19168de5 100644 --- a/fuzz/build.gradle +++ b/fuzz/build.gradle @@ -1,4 +1,5 @@ dependencies { + api 'com.fasterxml.jackson.core:jackson-databind' implementation project(':ethereum:networks') implementation project(':ethereum:spec') implementation testFixtures(project(':ethereum:spec')) @@ -10,6 +11,7 @@ dependencies { testImplementation 'org.xerial.snappy:snappy-java' testImplementation testFixtures(project(':ethereum:spec')) + testImplementation project(':infrastructure:json') } diff --git a/fuzz/src/main/java/tech/pegasys/teku/fuzz/FuzzUtil.java b/fuzz/src/main/java/tech/pegasys/teku/fuzz/FuzzUtil.java index 9aab8d8ef23..4a4bd3505f9 100644 --- a/fuzz/src/main/java/tech/pegasys/teku/fuzz/FuzzUtil.java +++ b/fuzz/src/main/java/tech/pegasys/teku/fuzz/FuzzUtil.java @@ -182,14 +182,14 @@ public Optional fuzzBlockHeader(final byte[] input) { deserialize(input, BlockHeaderFuzzInput.createType(specVersion)); try { - BeaconState postState = + final BeaconState postState = structuredInput .getState() .updated( state -> spec.getBlockProcessor(state.getSlot()) .processBlockHeader(state, structuredInput.getBlock())); - Bytes output = postState.sszSerialize(); + final Bytes output = postState.sszSerialize(); return Optional.of(output.toArrayUnsafe()); } catch (BlockProcessingException e) { // "expected error"