Skip to content

Commit

Permalink
use EF consensus spec v1.5.0-alpha.8 test vectors (#6616)
Browse files Browse the repository at this point in the history
  • Loading branch information
tersec authored Oct 9, 2024
1 parent fc2b232 commit b8a4249
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 30 deletions.
13 changes: 10 additions & 3 deletions ConsensusSpecPreset-mainnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
13 changes: 10 additions & 3 deletions ConsensusSpecPreset-minimal.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
3 changes: 0 additions & 3 deletions beacon_chain/nimbus_beacon_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
6 changes: 3 additions & 3 deletions beacon_chain/spec/beaconstate.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion beacon_chain/spec/datatypes/base.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions beacon_chain/spec/helpers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 1 addition & 10 deletions tests/consensus_spec/test_fixture_sanity_blocks.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion vendor/nim-eth2-scenarios

0 comments on commit b8a4249

Please sign in to comment.