use EF consensus spec v1.5.0-alpha.8 test vectors (#6616)

This commit is contained in:
tersec 2024-10-09 04:33:17 +00:00 committed by GitHub
parent fc2b232b9e
commit b8a424991d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 26 additions and 30 deletions

View File

@ -2983,6 +2983,7 @@ OK: 18/18 Fail: 0/18 Skip: 0/18
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_two_expected_partial_withdrawa OK + [Invalid] EF - Electra - Operations - Withdrawals - invalid_two_expected_partial_withdrawa OK
+ [Valid] EF - Electra - Operations - Withdrawals - all_withdrawal 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 - 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_0 OK
+ [Valid] EF - Electra - Operations - Withdrawals - random_full_withdrawals_0 OK + [Valid] EF - Electra - Operations - Withdrawals - random_full_withdrawals_0 OK
+ [Valid] EF - Electra - Operations - Withdrawals - random_full_withdrawals_1 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_fully_withdrawable_in_one_ OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_all_partially_withdrawable_in_ 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_excess_balance_but_no_max_effe OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_max_partial_withdrawable 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_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 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 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_full_withdrawal OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_one_partial_withdrawable_activ OK + [Valid] EF - Electra - Operations - Withdrawals - success_one_partial_withdrawable_activ OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_one_partial_withdrawable_exite 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
+ [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] ## EF - Electra - Random [Preset: mainnet]
```diff ```diff
+ [Valid] EF - Electra - Random - randomized_0 [Preset: mainnet] OK + [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 - 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_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_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 - block_transition_randomized_payload [Preset: ma OK
+ [Valid] EF - Electra - Sanity - Blocks - bls_change [Preset: mainnet] 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_and_bls_change [Preset: mainnet] OK
+ [Valid] EF - Electra - Sanity - Blocks - deposit_in_block [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 + [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 - withdrawal_success_two_blocks [Preset: mainnet] OK
+ [Valid] EF - Electra - Sanity - Blocks - zero_blob [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] ## EF - Electra - Sanity - Slots [Preset: mainnet]
```diff ```diff
+ EF - Electra - Slots - double_empty_epoch [Preset: mainnet] OK + 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 OK: 3/3 Fail: 0/3 Skip: 0/3
---TOTAL--- ---TOTAL---
OK: 3071/3091 Fail: 0/3091 Skip: 20/3091 OK: 3078/3098 Fail: 0/3098 Skip: 20/3098

View File

@ -3136,6 +3136,7 @@ OK: 28/28 Fail: 0/28 Skip: 0/28
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_two_expected_partial_withdrawa OK + [Invalid] EF - Electra - Operations - Withdrawals - invalid_two_expected_partial_withdrawa OK
+ [Valid] EF - Electra - Operations - Withdrawals - all_withdrawal 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 - 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_0 OK
+ [Valid] EF - Electra - Operations - Withdrawals - random_full_withdrawals_0 OK + [Valid] EF - Electra - Operations - Withdrawals - random_full_withdrawals_0 OK
+ [Valid] EF - Electra - Operations - Withdrawals - random_full_withdrawals_1 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_fully_withdrawable OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_all_partially_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_excess_balance_but_no_max_effe OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_max_partial_withdrawable 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_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_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 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 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_full_withdrawal OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_one_partial_withdrawable_activ OK + [Valid] EF - Electra - Operations - Withdrawals - success_one_partial_withdrawable_activ OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_one_partial_withdrawable_exite 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
+ [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] ## EF - Electra - Random [Preset: minimal]
```diff ```diff
+ [Valid] EF - Electra - Random - randomized_0 [Preset: minimal] OK + [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 - 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_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_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 - block_transition_randomized_payload [Preset: mi OK
+ [Valid] EF - Electra - Sanity - Blocks - bls_change [Preset: minimal] 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_and_bls_change [Preset: minimal] OK
+ [Valid] EF - Electra - Sanity - Blocks - deposit_in_block [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 + [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 - withdrawal_success_two_blocks [Preset: minimal] OK
+ [Valid] EF - Electra - Sanity - Blocks - zero_blob [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] ## EF - Electra - Sanity - Slots [Preset: minimal]
```diff ```diff
+ EF - Electra - Slots - double_empty_epoch [Preset: minimal] OK + 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 OK: 3/3 Fail: 0/3 Skip: 0/3
---TOTAL--- ---TOTAL---
OK: 3378/3401 Fail: 0/3401 Skip: 23/3401 OK: 3385/3408 Fail: 0/3408 Skip: 23/3408

View File

@ -865,9 +865,6 @@ proc init*(T: type BeaconNode,
func getDenebForkEpoch(): Opt[Epoch] = func getDenebForkEpoch(): Opt[Epoch] =
Opt.some(cfg.DENEB_FORK_EPOCH) Opt.some(cfg.DENEB_FORK_EPOCH)
func getElectraForkEpoch(): Opt[Epoch] =
Opt.some(cfg.ELECTRA_FORK_EPOCH)
proc getForkForEpoch(epoch: Epoch): Opt[Fork] = proc getForkForEpoch(epoch: Epoch): Opt[Fork] =
Opt.some(dag.forkAtEpoch(epoch)) Opt.some(dag.forkAtEpoch(epoch))

View File

@ -1292,7 +1292,7 @@ func switch_to_compounding_validator*(
validator.withdrawal_credentials.data[0] = COMPOUNDING_WITHDRAWAL_PREFIX validator.withdrawal_credentials.data[0] = COMPOUNDING_WITHDRAWAL_PREFIX
queue_excess_active_balance(state, index.uint64) 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*( func get_pending_balance_to_withdraw*(
state: electra.BeaconState, validator_index: ValidatorIndex): Gwei = state: electra.BeaconState, validator_index: ValidatorIndex): Gwei =
var pending_balance: Gwei var pending_balance: Gwei
@ -1383,7 +1383,7 @@ func get_expected_withdrawals*(
get_expected_withdrawals_aux(state, get_current_epoch(state)) do: get_expected_withdrawals_aux(state, get_current_epoch(state)) do:
state.balances[validator_index] 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 # 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] # 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. # 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 withdrawals.add w
withdrawal_index += 1 withdrawal_index += 1
inc partial_withdrawals_count partial_withdrawals_count += 1
let let
bound = min(len(state.validators), MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP) bound = min(len(state.validators), MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP)

View File

@ -74,7 +74,7 @@ export
tables, results, endians2, json_serialization, sszTypes, beacon_time, crypto, tables, results, endians2, json_serialization, sszTypes, beacon_time, crypto,
digest, presets 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 ## Spec version we're aiming to be compatible with, right now
const const

View File

@ -454,12 +454,6 @@ proc computeTransactionsTrieRoot(
payload: ForkyExecutionPayload): ExecutionHash256 = payload: ForkyExecutionPayload): ExecutionHash256 =
orderedTrieRoot(payload.transactions.asSeq) 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) = func append*(w: var RlpWriter, request: electra.DepositRequest) =
w.append ExecutionDepositRequest( w.append ExecutionDepositRequest(
pubkey: Bytes48 request.pubkey.blob, pubkey: Bytes48 request.pubkey.blob,

View File

@ -16,7 +16,7 @@ import
../testutil ../testutil
from std/sequtils import toSeq from std/sequtils import toSeq
from std/strutils import contains, toLowerAscii from std/strutils import toLowerAscii
from ../../beacon_chain/spec/presets import from ../../beacon_chain/spec/presets import
const_preset, defaultRuntimeConfig const_preset, defaultRuntimeConfig
from ./fixtures_utils import from ./fixtures_utils import
@ -32,15 +32,6 @@ proc runTest(
hasPostState = fileExists(testPath/"post.ssz_snappy") hasPostState = fileExists(testPath/"post.ssz_snappy")
prefix = if hasPostState: "[Valid] " else: "[Invalid] " 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(): test prefix & testName & " - " & unitTestName & preset():
let preState = newClone(parseTest(testPath/"pre.ssz_snappy", let preState = newClone(parseTest(testPath/"pre.ssz_snappy",
SSZ, consensusFork.BeaconState)) SSZ, consensusFork.BeaconState))

@ -1 +1 @@
Subproject commit 1732d9573da2807c6b1cc3aede9f53612b3196b7 Subproject commit 93996ec0865765d94b1f72825bd98a5aef215a12