From e6e95cbab7ffe0302292dad0da50cf1e85d150ea Mon Sep 17 00:00:00 2001 From: tersec Date: Tue, 23 Apr 2024 07:58:32 +0000 Subject: [PATCH] add Electra slot sanity tests (#6230) --- ConsensusSpecPreset-mainnet.md | 12 +++++++++++- ConsensusSpecPreset-minimal.md | 12 +++++++++++- beacon_chain/spec/forks.nim | 5 ++++- tests/consensus_spec/test_fixture_sanity_slots.nim | 9 +++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/ConsensusSpecPreset-mainnet.md b/ConsensusSpecPreset-mainnet.md index 5199007be..876d7c7fe 100644 --- a/ConsensusSpecPreset-mainnet.md +++ b/ConsensusSpecPreset-mainnet.md @@ -2674,6 +2674,16 @@ OK: 50/50 Fail: 0/50 Skip: 0/50 + Testing Withdrawal OK ``` OK: 55/55 Fail: 0/55 Skip: 0/55 +## EF - Electra - Sanity - Slots [Preset: mainnet] +```diff ++ EF - Electra - Slots - double_empty_epoch [Preset: mainnet] OK ++ EF - Electra - Slots - empty_epoch [Preset: mainnet] OK ++ EF - Electra - Slots - historical_accumulator [Preset: mainnet] OK ++ EF - Electra - Slots - over_epoch_boundary [Preset: mainnet] OK ++ EF - Electra - Slots - slots_1 [Preset: mainnet] OK ++ EF - Electra - Slots - slots_2 [Preset: mainnet] OK +``` +OK: 6/6 Fail: 0/6 Skip: 0/6 ## EF - Light client - Single merkle proof [Preset: mainnet] ```diff + Light client - Single merkle proof - mainnet/altair/light_client/single_merkle_proof/Beaco OK @@ -3202,4 +3212,4 @@ OK: 69/88 Fail: 0/88 Skip: 19/88 OK: 3/3 Fail: 0/3 Skip: 0/3 ---TOTAL--- -OK: 2561/2580 Fail: 0/2580 Skip: 19/2580 +OK: 2567/2586 Fail: 0/2586 Skip: 19/2586 diff --git a/ConsensusSpecPreset-minimal.md b/ConsensusSpecPreset-minimal.md index a1ce5133a..d901a73b9 100644 --- a/ConsensusSpecPreset-minimal.md +++ b/ConsensusSpecPreset-minimal.md @@ -2793,6 +2793,16 @@ OK: 51/51 Fail: 0/51 Skip: 0/51 + Testing Withdrawal OK ``` OK: 55/55 Fail: 0/55 Skip: 0/55 +## EF - Electra - Sanity - Slots [Preset: minimal] +```diff ++ EF - Electra - Slots - double_empty_epoch [Preset: minimal] OK ++ EF - Electra - Slots - empty_epoch [Preset: minimal] OK ++ EF - Electra - Slots - historical_accumulator [Preset: minimal] OK ++ EF - Electra - Slots - over_epoch_boundary [Preset: minimal] OK ++ EF - Electra - Slots - slots_1 [Preset: minimal] OK ++ EF - Electra - Slots - slots_2 [Preset: minimal] OK +``` +OK: 6/6 Fail: 0/6 Skip: 0/6 ## EF - Light client - Single merkle proof [Preset: minimal] ```diff + Light client - Single merkle proof - minimal/altair/light_client/single_merkle_proof/Beaco OK @@ -3482,4 +3492,4 @@ OK: 185/207 Fail: 0/207 Skip: 22/207 OK: 3/3 Fail: 0/3 Skip: 0/3 ---TOTAL--- -OK: 2810/2832 Fail: 0/2832 Skip: 22/2832 +OK: 2816/2838 Fail: 0/2838 Skip: 22/2838 diff --git a/beacon_chain/spec/forks.nim b/beacon_chain/spec/forks.nim index 25d081736..4a0856e16 100644 --- a/beacon_chain/spec/forks.nim +++ b/beacon_chain/spec/forks.nim @@ -617,7 +617,6 @@ template PayloadAttributes*( static: doAssert ConsensusFork.high == ConsensusFork.Electra, "eth2_merkleization has been checked and `hash_tree_root` is up to date" -# TODO are these used? # TODO when https://github.com/nim-lang/Nim/issues/21086 fixed, use return type # `ref T` func new*(T: type ForkedHashedBeaconState, data: phase0.BeaconState): @@ -640,6 +639,10 @@ func new*(T: type ForkedHashedBeaconState, data: deneb.BeaconState): ref ForkedHashedBeaconState = (ref T)(kind: ConsensusFork.Deneb, denebData: deneb.HashedBeaconState( data: data, root: hash_tree_root(data))) +func new*(T: type ForkedHashedBeaconState, data: electra.BeaconState): + ref ForkedHashedBeaconState = + (ref T)(kind: ConsensusFork.Electra, electraData: electra.HashedBeaconState( + data: data, root: hash_tree_root(data))) template init*(T: type ForkedBeaconBlock, blck: phase0.BeaconBlock): T = T(kind: ConsensusFork.Phase0, phase0Data: blck) diff --git a/tests/consensus_spec/test_fixture_sanity_slots.nim b/tests/consensus_spec/test_fixture_sanity_slots.nim index 74c640240..44fb99d9e 100644 --- a/tests/consensus_spec/test_fixture_sanity_slots.nim +++ b/tests/consensus_spec/test_fixture_sanity_slots.nim @@ -89,3 +89,12 @@ suite "EF - Deneb - Sanity - Slots " & preset(): for kind, path in walkDir( denebSanitySlotsDir, relative = true, checkDir = true): runTest(deneb.BeaconState, denebSanitySlotsDir, "Deneb", suiteName, path) + +from ../../beacon_chain/spec/datatypes/electra import BeaconState + +suite "EF - Electra - Sanity - Slots " & preset(): + const electraSanitySlotsDir = sanitySlotsDir("electra") + for kind, path in walkDir( + electraSanitySlotsDir, relative = true, checkDir = true): + runTest( + electra.BeaconState, electraSanitySlotsDir, "Electra", suiteName, path) \ No newline at end of file