From b8a424991d4f8590f5e5364b18ffeabef72e1ff4 Mon Sep 17 00:00:00 2001 From: tersec Date: Wed, 9 Oct 2024 04:33:17 +0000 Subject: [PATCH] use EF consensus spec v1.5.0-alpha.8 test vectors (#6616) --- ConsensusSpecPreset-mainnet.md | 13 ++++++++++--- ConsensusSpecPreset-minimal.md | 13 ++++++++++--- beacon_chain/nimbus_beacon_node.nim | 3 --- beacon_chain/spec/beaconstate.nim | 6 +++--- beacon_chain/spec/datatypes/base.nim | 2 +- beacon_chain/spec/helpers.nim | 6 ------ tests/consensus_spec/test_fixture_sanity_blocks.nim | 11 +---------- vendor/nim-eth2-scenarios | 2 +- 8 files changed, 26 insertions(+), 30 deletions(-) diff --git a/ConsensusSpecPreset-mainnet.md b/ConsensusSpecPreset-mainnet.md index ed2f46bf9..c08408b0d 100644 --- a/ConsensusSpecPreset-mainnet.md +++ b/ConsensusSpecPreset-mainnet.md @@ -2983,6 +2983,7 @@ OK: 18/18 Fail: 0/18 Skip: 0/18 + [Invalid] EF - Electra - Operations - Withdrawals - invalid_two_expected_partial_withdrawa OK + [Valid] EF - Electra - Operations - Withdrawals - all_withdrawal OK + [Valid] EF - Electra - Operations - Withdrawals - no_withdrawals_but_some_next_epoch OK ++ [Valid] EF - Electra - Operations - Withdrawals - pending_withdrawals_one_skipped_one_ef OK + [Valid] EF - Electra - Operations - Withdrawals - random_0 OK + [Valid] EF - Electra - Operations - Withdrawals - random_full_withdrawals_0 OK + [Valid] EF - Electra - Operations - Withdrawals - random_full_withdrawals_1 OK @@ -2996,10 +2997,14 @@ OK: 18/18 Fail: 0/18 Skip: 0/18 + [Valid] EF - Electra - Operations - Withdrawals - success_all_fully_withdrawable_in_one_ OK + [Valid] EF - Electra - Operations - Withdrawals - success_all_partially_withdrawable_in_ OK + [Valid] EF - Electra - Operations - Withdrawals - success_excess_balance_but_no_max_effe OK ++ [Valid] EF - Electra - Operations - Withdrawals - success_excess_balance_but_no_max_effe OK + [Valid] EF - Electra - Operations - Withdrawals - success_max_partial_withdrawable OK + [Valid] EF - Electra - Operations - Withdrawals - success_mixed_fully_and_partial_withdr OK ++ [Valid] EF - Electra - Operations - Withdrawals - success_mixed_fully_and_partial_withdr OK + [Valid] EF - Electra - Operations - Withdrawals - success_no_excess_balance OK ++ [Valid] EF - Electra - Operations - Withdrawals - success_no_excess_balance_compounding OK + [Valid] EF - Electra - Operations - Withdrawals - success_no_max_effective_balance OK ++ [Valid] EF - Electra - Operations - Withdrawals - success_no_max_effective_balance_compo OK + [Valid] EF - Electra - Operations - Withdrawals - success_one_full_withdrawal OK + [Valid] EF - Electra - Operations - Withdrawals - success_one_partial_withdrawable_activ OK + [Valid] EF - Electra - Operations - Withdrawals - success_one_partial_withdrawable_exite OK @@ -3013,7 +3018,7 @@ OK: 18/18 Fail: 0/18 Skip: 0/18 + [Valid] EF - Electra - Operations - Withdrawals - withdrawable_epoch_but_0_effective_bal OK + [Valid] EF - Electra - Operations - Withdrawals - withdrawable_epoch_but_0_effective_bal OK ``` -OK: 50/50 Fail: 0/50 Skip: 0/50 +OK: 55/55 Fail: 0/55 Skip: 0/55 ## EF - Electra - Random [Preset: mainnet] ```diff + [Valid] EF - Electra - Random - randomized_0 [Preset: mainnet] OK @@ -3162,8 +3167,10 @@ OK: 55/55 Fail: 0/55 Skip: 0/55 + [Valid] EF - Electra - Sanity - Blocks - balance_driven_status_transitions [Preset: main OK + [Valid] EF - Electra - Sanity - Blocks - basic_btec_and_el_withdrawal_request_in_same_bl OK + [Valid] EF - Electra - Sanity - Blocks - basic_btec_before_el_withdrawal_request [Preset OK ++ [Valid] EF - Electra - Sanity - Blocks - basic_el_withdrawal_request [Preset: mainnet] OK + [Valid] EF - Electra - Sanity - Blocks - block_transition_randomized_payload [Preset: ma OK + [Valid] EF - Electra - Sanity - Blocks - bls_change [Preset: mainnet] OK ++ [Valid] EF - Electra - Sanity - Blocks - cl_exit_and_el_withdrawal_request_in_same_block OK + [Valid] EF - Electra - Sanity - Blocks - deposit_and_bls_change [Preset: mainnet] OK + [Valid] EF - Electra - Sanity - Blocks - deposit_in_block [Preset: mainnet] OK + [Valid] EF - Electra - Sanity - Blocks - deposit_top_up [Preset: mainnet] OK @@ -3212,7 +3219,7 @@ OK: 55/55 Fail: 0/55 Skip: 0/55 + [Valid] EF - Electra - Sanity - Blocks - withdrawal_success_two_blocks [Preset: mainnet] OK + [Valid] EF - Electra - Sanity - Blocks - zero_blob [Preset: mainnet] OK ``` -OK: 78/78 Fail: 0/78 Skip: 0/78 +OK: 80/80 Fail: 0/80 Skip: 0/80 ## EF - Electra - Sanity - Slots [Preset: mainnet] ```diff + EF - Electra - Slots - double_empty_epoch [Preset: mainnet] OK @@ -3797,4 +3804,4 @@ OK: 69/88 Fail: 0/88 Skip: 19/88 OK: 3/3 Fail: 0/3 Skip: 0/3 ---TOTAL--- -OK: 3071/3091 Fail: 0/3091 Skip: 20/3091 +OK: 3078/3098 Fail: 0/3098 Skip: 20/3098 diff --git a/ConsensusSpecPreset-minimal.md b/ConsensusSpecPreset-minimal.md index 8ba4c44fe..3990cb4a0 100644 --- a/ConsensusSpecPreset-minimal.md +++ b/ConsensusSpecPreset-minimal.md @@ -3136,6 +3136,7 @@ OK: 28/28 Fail: 0/28 Skip: 0/28 + [Invalid] EF - Electra - Operations - Withdrawals - invalid_two_expected_partial_withdrawa OK + [Valid] EF - Electra - Operations - Withdrawals - all_withdrawal OK + [Valid] EF - Electra - Operations - Withdrawals - no_withdrawals_but_some_next_epoch OK ++ [Valid] EF - Electra - Operations - Withdrawals - pending_withdrawals_one_skipped_one_ef OK + [Valid] EF - Electra - Operations - Withdrawals - random_0 OK + [Valid] EF - Electra - Operations - Withdrawals - random_full_withdrawals_0 OK + [Valid] EF - Electra - Operations - Withdrawals - random_full_withdrawals_1 OK @@ -3149,11 +3150,15 @@ OK: 28/28 Fail: 0/28 Skip: 0/28 + [Valid] EF - Electra - Operations - Withdrawals - success_all_fully_withdrawable OK + [Valid] EF - Electra - Operations - Withdrawals - success_all_partially_withdrawable OK + [Valid] EF - Electra - Operations - Withdrawals - success_excess_balance_but_no_max_effe OK ++ [Valid] EF - Electra - Operations - Withdrawals - success_excess_balance_but_no_max_effe OK + [Valid] EF - Electra - Operations - Withdrawals - success_max_partial_withdrawable OK + [Valid] EF - Electra - Operations - Withdrawals - success_max_plus_one_withdrawable OK + [Valid] EF - Electra - Operations - Withdrawals - success_mixed_fully_and_partial_withdr OK ++ [Valid] EF - Electra - Operations - Withdrawals - success_mixed_fully_and_partial_withdr OK + [Valid] EF - Electra - Operations - Withdrawals - success_no_excess_balance OK ++ [Valid] EF - Electra - Operations - Withdrawals - success_no_excess_balance_compounding OK + [Valid] EF - Electra - Operations - Withdrawals - success_no_max_effective_balance OK ++ [Valid] EF - Electra - Operations - Withdrawals - success_no_max_effective_balance_compo OK + [Valid] EF - Electra - Operations - Withdrawals - success_one_full_withdrawal OK + [Valid] EF - Electra - Operations - Withdrawals - success_one_partial_withdrawable_activ OK + [Valid] EF - Electra - Operations - Withdrawals - success_one_partial_withdrawable_exite OK @@ -3167,7 +3172,7 @@ OK: 28/28 Fail: 0/28 Skip: 0/28 + [Valid] EF - Electra - Operations - Withdrawals - withdrawable_epoch_but_0_effective_bal OK + [Valid] EF - Electra - Operations - Withdrawals - withdrawable_epoch_but_0_effective_bal OK ``` -OK: 51/51 Fail: 0/51 Skip: 0/51 +OK: 56/56 Fail: 0/56 Skip: 0/56 ## EF - Electra - Random [Preset: minimal] ```diff + [Valid] EF - Electra - Random - randomized_0 [Preset: minimal] OK @@ -3318,8 +3323,10 @@ OK: 55/55 Fail: 0/55 Skip: 0/55 + [Valid] EF - Electra - Sanity - Blocks - balance_driven_status_transitions [Preset: mini OK + [Valid] EF - Electra - Sanity - Blocks - basic_btec_and_el_withdrawal_request_in_same_bl OK + [Valid] EF - Electra - Sanity - Blocks - basic_btec_before_el_withdrawal_request [Preset OK ++ [Valid] EF - Electra - Sanity - Blocks - basic_el_withdrawal_request [Preset: minimal] OK + [Valid] EF - Electra - Sanity - Blocks - block_transition_randomized_payload [Preset: mi OK + [Valid] EF - Electra - Sanity - Blocks - bls_change [Preset: minimal] OK ++ [Valid] EF - Electra - Sanity - Blocks - cl_exit_and_el_withdrawal_request_in_same_block OK + [Valid] EF - Electra - Sanity - Blocks - deposit_and_bls_change [Preset: minimal] OK + [Valid] EF - Electra - Sanity - Blocks - deposit_in_block [Preset: minimal] OK + [Valid] EF - Electra - Sanity - Blocks - deposit_top_up [Preset: minimal] OK @@ -3373,7 +3380,7 @@ OK: 55/55 Fail: 0/55 Skip: 0/55 + [Valid] EF - Electra - Sanity - Blocks - withdrawal_success_two_blocks [Preset: minimal] OK + [Valid] EF - Electra - Sanity - Blocks - zero_blob [Preset: minimal] OK ``` -OK: 85/85 Fail: 0/85 Skip: 0/85 +OK: 87/87 Fail: 0/87 Skip: 0/87 ## EF - Electra - Sanity - Slots [Preset: minimal] ```diff + EF - Electra - Slots - double_empty_epoch [Preset: minimal] OK @@ -4135,4 +4142,4 @@ OK: 185/207 Fail: 0/207 Skip: 22/207 OK: 3/3 Fail: 0/3 Skip: 0/3 ---TOTAL--- -OK: 3378/3401 Fail: 0/3401 Skip: 23/3401 +OK: 3385/3408 Fail: 0/3408 Skip: 23/3408 diff --git a/beacon_chain/nimbus_beacon_node.nim b/beacon_chain/nimbus_beacon_node.nim index 8fb8cdb21..d90200fc9 100644 --- a/beacon_chain/nimbus_beacon_node.nim +++ b/beacon_chain/nimbus_beacon_node.nim @@ -865,9 +865,6 @@ proc init*(T: type BeaconNode, func getDenebForkEpoch(): Opt[Epoch] = Opt.some(cfg.DENEB_FORK_EPOCH) - func getElectraForkEpoch(): Opt[Epoch] = - Opt.some(cfg.ELECTRA_FORK_EPOCH) - proc getForkForEpoch(epoch: Epoch): Opt[Fork] = Opt.some(dag.forkAtEpoch(epoch)) diff --git a/beacon_chain/spec/beaconstate.nim b/beacon_chain/spec/beaconstate.nim index 9c25d5610..36369a27a 100644 --- a/beacon_chain/spec/beaconstate.nim +++ b/beacon_chain/spec/beaconstate.nim @@ -1292,7 +1292,7 @@ func switch_to_compounding_validator*( validator.withdrawal_credentials.data[0] = COMPOUNDING_WITHDRAWAL_PREFIX queue_excess_active_balance(state, index.uint64) -# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/electra/beacon-chain.md#new-get_pending_balance_to_withdraw +# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.8/specs/electra/beacon-chain.md#new-get_pending_balance_to_withdraw func get_pending_balance_to_withdraw*( state: electra.BeaconState, validator_index: ValidatorIndex): Gwei = var pending_balance: Gwei @@ -1383,7 +1383,7 @@ func get_expected_withdrawals*( get_expected_withdrawals_aux(state, get_current_epoch(state)) do: state.balances[validator_index] -# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/electra/beacon-chain.md#modified-get_expected_withdrawals +# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.8/specs/electra/beacon-chain.md#modified-get_expected_withdrawals # This partials count is used in exactly one place, while in general being able # to cleanly treat the results of get_expected_withdrawals as a seq[Withdrawal] # are valuable enough to make that the default version of this spec function. @@ -1437,7 +1437,7 @@ template get_expected_withdrawals_with_partial_count_aux*( withdrawals.add w withdrawal_index += 1 - inc partial_withdrawals_count + partial_withdrawals_count += 1 let bound = min(len(state.validators), MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP) diff --git a/beacon_chain/spec/datatypes/base.nim b/beacon_chain/spec/datatypes/base.nim index bd743a051..88faa8ee2 100644 --- a/beacon_chain/spec/datatypes/base.nim +++ b/beacon_chain/spec/datatypes/base.nim @@ -74,7 +74,7 @@ export tables, results, endians2, json_serialization, sszTypes, beacon_time, crypto, digest, presets -const SPEC_VERSION* = "1.5.0-alpha.7" +const SPEC_VERSION* = "1.5.0-alpha.8" ## Spec version we're aiming to be compatible with, right now const diff --git a/beacon_chain/spec/helpers.nim b/beacon_chain/spec/helpers.nim index 80c961b47..a98f39421 100644 --- a/beacon_chain/spec/helpers.nim +++ b/beacon_chain/spec/helpers.nim @@ -454,12 +454,6 @@ proc computeTransactionsTrieRoot( payload: ForkyExecutionPayload): ExecutionHash256 = orderedTrieRoot(payload.transactions.asSeq) -# https://eips.ethereum.org/EIPS/eip-4895 -proc computeWithdrawalsTrieRoot( - payload: capella.ExecutionPayload | deneb.ExecutionPayload | - electra.ExecutionPayload): ExecutionHash256 = - orderedTrieRoot(payload.withdrawals.asSeq) - func append*(w: var RlpWriter, request: electra.DepositRequest) = w.append ExecutionDepositRequest( pubkey: Bytes48 request.pubkey.blob, diff --git a/tests/consensus_spec/test_fixture_sanity_blocks.nim b/tests/consensus_spec/test_fixture_sanity_blocks.nim index 1c92b3239..650028fde 100644 --- a/tests/consensus_spec/test_fixture_sanity_blocks.nim +++ b/tests/consensus_spec/test_fixture_sanity_blocks.nim @@ -16,7 +16,7 @@ import ../testutil from std/sequtils import toSeq -from std/strutils import contains, toLowerAscii +from std/strutils import toLowerAscii from ../../beacon_chain/spec/presets import const_preset, defaultRuntimeConfig from ./fixtures_utils import @@ -32,15 +32,6 @@ proc runTest( hasPostState = fileExists(testPath/"post.ssz_snappy") prefix = if hasPostState: "[Valid] " else: "[Invalid] " - # TODO these tests might be buggy, or at least they're strange - # they're failing before any state transition calculations, in - # the block parent == latest_block_header check within 1-block - # tests, i.e. those latest_block_headers are just baked in. - if consensusFork == ConsensusFork.Electra and ( - unitTestName.contains("cl_exit_and_el_withdrawal_request_in_same_block") or - unitTestName.contains("basic_el_withdrawal_request")): - return - test prefix & testName & " - " & unitTestName & preset(): let preState = newClone(parseTest(testPath/"pre.ssz_snappy", SSZ, consensusFork.BeaconState)) diff --git a/vendor/nim-eth2-scenarios b/vendor/nim-eth2-scenarios index 1732d9573..93996ec08 160000 --- a/vendor/nim-eth2-scenarios +++ b/vendor/nim-eth2-scenarios @@ -1 +1 @@ -Subproject commit 1732d9573da2807c6b1cc3aede9f53612b3196b7 +Subproject commit 93996ec0865765d94b1f72825bd98a5aef215a12