mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-17 00:47:03 +00:00
eip4844 block/slot sanity and transition tests (#4399)
This commit is contained in:
parent
2932d3b808
commit
50bcc48e17
@ -201,6 +201,27 @@ ConsensusSpecPreset-mainnet
|
||||
+ EF - EIP4844 - Rewards - with_not_yet_activated_validators_leak [Preset: mainnet] OK
|
||||
+ EF - EIP4844 - Rewards - with_slashed_validators [Preset: mainnet] OK
|
||||
+ EF - EIP4844 - Rewards - with_slashed_validators_leak [Preset: mainnet] OK
|
||||
+ EF - EIP4844 - Transition - normal_transition [Preset: mainnet] OK
|
||||
+ EF - EIP4844 - Transition - simple_transition [Preset: mainnet] OK
|
||||
+ EF - EIP4844 - Transition - transition_missing_first_post_block [Preset: mainnet] OK
|
||||
+ EF - EIP4844 - Transition - transition_missing_last_pre_fork_block [Preset: mainnet] OK
|
||||
+ EF - EIP4844 - Transition - transition_only_blocks_post_fork [Preset: mainnet] OK
|
||||
+ EF - EIP4844 - Transition - transition_randomized_state [Preset: mainnet] OK
|
||||
+ EF - EIP4844 - Transition - transition_with_activation_at_fork_epoch [Preset: mainnet] OK
|
||||
+ EF - EIP4844 - Transition - transition_with_attester_slashing_right_after_fork [Preset: ma OK
|
||||
+ EF - EIP4844 - Transition - transition_with_attester_slashing_right_before_fork [Preset: m OK
|
||||
+ EF - EIP4844 - Transition - transition_with_deposit_right_after_fork [Preset: mainnet] OK
|
||||
+ EF - EIP4844 - Transition - transition_with_deposit_right_before_fork [Preset: mainnet] OK
|
||||
+ EF - EIP4844 - Transition - transition_with_finality [Preset: mainnet] OK
|
||||
+ EF - EIP4844 - Transition - transition_with_leaking_at_fork [Preset: mainnet] OK
|
||||
+ EF - EIP4844 - Transition - transition_with_leaking_pre_fork [Preset: mainnet] OK
|
||||
+ EF - EIP4844 - Transition - transition_with_no_attestations_until_after_fork [Preset: main OK
|
||||
+ EF - EIP4844 - Transition - transition_with_non_empty_activation_queue [Preset: mainnet] OK
|
||||
+ EF - EIP4844 - Transition - transition_with_one_fourth_exiting_validators_exit_at_fork [Pr OK
|
||||
+ EF - EIP4844 - Transition - transition_with_proposer_slashing_right_after_fork [Preset: ma OK
|
||||
+ EF - EIP4844 - Transition - transition_with_proposer_slashing_right_before_fork [Preset: m OK
|
||||
+ EF - EIP4844 - Transition - transition_with_random_half_participation [Preset: mainnet] OK
|
||||
+ EF - EIP4844 - Transition - transition_with_random_three_quarters_participation [Preset: m OK
|
||||
+ EF - Phase 0 - Rewards - all_balances_too_low_for_reward [Preset: mainnet] OK
|
||||
+ EF - Phase 0 - Rewards - duplicate_attestations_at_later_slots [Preset: mainnet] OK
|
||||
+ EF - Phase 0 - Rewards - empty [Preset: mainnet] OK
|
||||
@ -385,6 +406,21 @@ ConsensusSpecPreset-mainnet
|
||||
+ [Invalid] EF - Capella - Sanity - Blocks - slash_and_exit_same_index [Preset: mainnet] OK
|
||||
+ [Invalid] EF - Capella - Sanity - Blocks - withdrawal_fail_second_block_payload_isnt_compa OK
|
||||
+ [Invalid] EF - Capella - Sanity - Blocks - zero_block_sig [Preset: mainnet] OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - expected_deposit_in_block [Preset: mainnet] OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - invalid_block_sig [Preset: mainnet] OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - invalid_duplicate_attester_slashing_same_block OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - invalid_duplicate_deposit_same_block [Preset: m OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - invalid_duplicate_proposer_slashings_same_block OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - invalid_duplicate_validator_exit_same_block [Pr OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - invalid_proposer_index_sig_from_expected_propos OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - invalid_proposer_index_sig_from_proposer_index OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - invalid_similar_proposer_slashings_same_block [ OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - invalid_state_root [Preset: mainnet] OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - parent_from_same_slot [Preset: mainnet] OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - prev_slot_block_transition [Preset: mainnet] OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - same_slot_block_transition [Preset: mainnet] OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - slash_and_exit_same_index [Preset: mainnet] OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - zero_block_sig [Preset: mainnet] OK
|
||||
+ [Invalid] EF - Phase 0 - Sanity - Blocks - expected_deposit_in_block [Preset: mainnet] OK
|
||||
+ [Invalid] EF - Phase 0 - Sanity - Blocks - invalid_block_sig [Preset: mainnet] OK
|
||||
+ [Invalid] EF - Phase 0 - Sanity - Blocks - invalid_duplicate_attester_slashing_same_block OK
|
||||
@ -572,6 +608,64 @@ ConsensusSpecPreset-mainnet
|
||||
+ [Valid] EF - Capella - Sanity - Blocks - success_exit_and_bls_change [Preset: mainnet] OK
|
||||
+ [Valid] EF - Capella - Sanity - Blocks - voluntary_exit [Preset: mainnet] OK
|
||||
+ [Valid] EF - Capella - Sanity - Blocks - withdrawal_success_two_blocks [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Finality - finality_no_updates_at_genesis [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Finality - finality_rule_1 [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Finality - finality_rule_2 [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Finality - finality_rule_3 [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Finality - finality_rule_4 [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_0 [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_1 [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_10 [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_11 [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_12 [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_13 [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_14 [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_15 [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_2 [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_3 [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_4 [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_5 [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_6 [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_7 [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_8 [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_9 [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - attestation [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - attester_slashing [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - balance_driven_status_transitions [Preset: main OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - deposit_in_block [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - deposit_top_up [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - duplicate_attestation_same_block [Preset: mainn OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - empty_block_transition [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - empty_block_transition_no_tx [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - empty_block_transition_randomized_payload [Pres OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - empty_epoch_transition [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - empty_sync_committee_committee [Preset: mainnet OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - empty_sync_committee_committee_genesis [Preset: OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - full_random_operations_0 [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - full_random_operations_1 [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - full_random_operations_2 [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - full_random_operations_3 [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - full_sync_committee_committee [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - full_sync_committee_committee_genesis [Preset: OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - half_sync_committee_committee [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - half_sync_committee_committee_genesis [Preset: OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - high_proposer_index [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - historical_batch [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - inactivity_scores_full_participation_leaking [P OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - inactivity_scores_leaking [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - is_execution_enabled_false [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - multiple_attester_slashings_no_overlap [Preset: OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - multiple_attester_slashings_partial_overlap [Pr OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - multiple_blobs [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - multiple_different_proposer_slashings_same_bloc OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - multiple_different_validator_exits_same_block [ OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - one_blob [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - proposer_after_inactive_index [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - proposer_self_slashing [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - proposer_slashing [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - skipped_slots [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - slash_and_exit_diff_index [Preset: mainnet] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - voluntary_exit [Preset: mainnet] OK
|
||||
+ [Valid] EF - Phase 0 - Finality - finality_no_updates_at_genesis [Preset: mainnet] OK
|
||||
+ [Valid] EF - Phase 0 - Finality - finality_rule_1 [Preset: mainnet] OK
|
||||
+ [Valid] EF - Phase 0 - Finality - finality_rule_2 [Preset: mainnet] OK
|
||||
@ -650,7 +744,7 @@ ConsensusSpecPreset-mainnet
|
||||
+ fork_random_low_balances OK
|
||||
+ fork_random_misc_balances OK
|
||||
```
|
||||
OK: 639/647 Fail: 0/647 Skip: 8/647
|
||||
OK: 733/741 Fail: 0/741 Skip: 8/741
|
||||
## Attestation
|
||||
```diff
|
||||
+ [Invalid] EF - Altair - Operations - Attestation - after_epoch_slots OK
|
||||
@ -2325,4 +2419,4 @@ OK: 63/63 Fail: 0/63 Skip: 0/63
|
||||
OK: 51/51 Fail: 0/51 Skip: 0/51
|
||||
|
||||
---TOTAL---
|
||||
OK: 2031/2039 Fail: 0/2039 Skip: 8/2039
|
||||
OK: 2125/2133 Fail: 0/2133 Skip: 8/2133
|
||||
|
@ -213,6 +213,31 @@ ConsensusSpecPreset-minimal
|
||||
+ EF - EIP4844 - Rewards - with_not_yet_activated_validators_leak [Preset: minimal] OK
|
||||
+ EF - EIP4844 - Rewards - with_slashed_validators [Preset: minimal] OK
|
||||
+ EF - EIP4844 - Rewards - with_slashed_validators_leak [Preset: minimal] OK
|
||||
+ EF - EIP4844 - Transition - normal_transition [Preset: minimal] OK
|
||||
+ EF - EIP4844 - Transition - simple_transition [Preset: minimal] OK
|
||||
+ EF - EIP4844 - Transition - transition_missing_first_post_block [Preset: minimal] OK
|
||||
+ EF - EIP4844 - Transition - transition_missing_last_pre_fork_block [Preset: minimal] OK
|
||||
+ EF - EIP4844 - Transition - transition_only_blocks_post_fork [Preset: minimal] OK
|
||||
+ EF - EIP4844 - Transition - transition_randomized_state [Preset: minimal] OK
|
||||
+ EF - EIP4844 - Transition - transition_with_activation_at_fork_epoch [Preset: minimal] OK
|
||||
+ EF - EIP4844 - Transition - transition_with_attester_slashing_right_after_fork [Preset: mi OK
|
||||
+ EF - EIP4844 - Transition - transition_with_attester_slashing_right_before_fork [Preset: m OK
|
||||
+ EF - EIP4844 - Transition - transition_with_deposit_right_after_fork [Preset: minimal] OK
|
||||
+ EF - EIP4844 - Transition - transition_with_deposit_right_before_fork [Preset: minimal] OK
|
||||
+ EF - EIP4844 - Transition - transition_with_finality [Preset: minimal] OK
|
||||
+ EF - EIP4844 - Transition - transition_with_leaking_at_fork [Preset: minimal] OK
|
||||
+ EF - EIP4844 - Transition - transition_with_leaking_pre_fork [Preset: minimal] OK
|
||||
+ EF - EIP4844 - Transition - transition_with_no_attestations_until_after_fork [Preset: mini OK
|
||||
+ EF - EIP4844 - Transition - transition_with_non_empty_activation_queue [Preset: minimal] OK
|
||||
+ EF - EIP4844 - Transition - transition_with_one_fourth_exiting_validators_exit_at_fork [Pr OK
|
||||
+ EF - EIP4844 - Transition - transition_with_one_fourth_exiting_validators_exit_post_fork [ OK
|
||||
+ EF - EIP4844 - Transition - transition_with_one_fourth_slashed_active_validators_pre_fork OK
|
||||
+ EF - EIP4844 - Transition - transition_with_proposer_slashing_right_after_fork [Preset: mi OK
|
||||
+ EF - EIP4844 - Transition - transition_with_proposer_slashing_right_before_fork [Preset: m OK
|
||||
+ EF - EIP4844 - Transition - transition_with_random_half_participation [Preset: minimal] OK
|
||||
+ EF - EIP4844 - Transition - transition_with_random_three_quarters_participation [Preset: m OK
|
||||
+ EF - EIP4844 - Transition - transition_with_voluntary_exit_right_after_fork [Preset: minim OK
|
||||
+ EF - EIP4844 - Transition - transition_with_voluntary_exit_right_before_fork [Preset: mini OK
|
||||
+ EF - Phase 0 - Rewards - all_balances_too_low_for_reward [Preset: minimal] OK
|
||||
+ EF - Phase 0 - Rewards - duplicate_attestations_at_later_slots [Preset: minimal] OK
|
||||
+ EF - Phase 0 - Rewards - empty [Preset: minimal] OK
|
||||
@ -442,6 +467,21 @@ ConsensusSpecPreset-minimal
|
||||
+ [Invalid] EF - Capella - Sanity - Blocks - slash_and_exit_same_index [Preset: minimal] OK
|
||||
+ [Invalid] EF - Capella - Sanity - Blocks - withdrawal_fail_second_block_payload_isnt_compa OK
|
||||
+ [Invalid] EF - Capella - Sanity - Blocks - zero_block_sig [Preset: minimal] OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - expected_deposit_in_block [Preset: minimal] OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - invalid_block_sig [Preset: minimal] OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - invalid_duplicate_attester_slashing_same_block OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - invalid_duplicate_deposit_same_block [Preset: m OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - invalid_duplicate_proposer_slashings_same_block OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - invalid_duplicate_validator_exit_same_block [Pr OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - invalid_proposer_index_sig_from_expected_propos OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - invalid_proposer_index_sig_from_proposer_index OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - invalid_similar_proposer_slashings_same_block [ OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - invalid_state_root [Preset: minimal] OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - parent_from_same_slot [Preset: minimal] OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - prev_slot_block_transition [Preset: minimal] OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - same_slot_block_transition [Preset: minimal] OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - slash_and_exit_same_index [Preset: minimal] OK
|
||||
+ [Invalid] EF - EIP4844 - Sanity - Blocks - zero_block_sig [Preset: minimal] OK
|
||||
+ [Invalid] EF - Phase 0 - Sanity - Blocks - expected_deposit_in_block [Preset: minimal] OK
|
||||
+ [Invalid] EF - Phase 0 - Sanity - Blocks - invalid_block_sig [Preset: minimal] OK
|
||||
+ [Invalid] EF - Phase 0 - Sanity - Blocks - invalid_duplicate_attester_slashing_same_block OK
|
||||
@ -644,6 +684,69 @@ ConsensusSpecPreset-minimal
|
||||
+ [Valid] EF - Capella - Sanity - Blocks - success_exit_and_bls_change [Preset: minimal] OK
|
||||
+ [Valid] EF - Capella - Sanity - Blocks - voluntary_exit [Preset: minimal] OK
|
||||
+ [Valid] EF - Capella - Sanity - Blocks - withdrawal_success_two_blocks [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Finality - finality_no_updates_at_genesis [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Finality - finality_rule_1 [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Finality - finality_rule_2 [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Finality - finality_rule_3 [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Finality - finality_rule_4 [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_0 [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_1 [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_10 [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_11 [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_12 [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_13 [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_14 [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_15 [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_2 [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_3 [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_4 [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_5 [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_6 [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_7 [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_8 [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Random - randomized_9 [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - attestation [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - attester_slashing [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - balance_driven_status_transitions [Preset: mini OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - deposit_in_block [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - deposit_top_up [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - duplicate_attestation_same_block [Preset: minim OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - empty_block_transition [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - empty_block_transition_large_validator_set [Pre OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - empty_block_transition_no_tx [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - empty_block_transition_randomized_payload [Pres OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - empty_epoch_transition [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - empty_epoch_transition_large_validator_set [Pre OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - empty_epoch_transition_not_finalizing [Preset: OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - empty_sync_committee_committee [Preset: minimal OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - empty_sync_committee_committee_genesis [Preset: OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - eth1_data_votes_consensus [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - eth1_data_votes_no_consensus [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - full_random_operations_0 [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - full_random_operations_1 [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - full_random_operations_2 [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - full_random_operations_3 [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - full_sync_committee_committee [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - full_sync_committee_committee_genesis [Preset: OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - half_sync_committee_committee [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - half_sync_committee_committee_genesis [Preset: OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - high_proposer_index [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - historical_batch [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - inactivity_scores_full_participation_leaking [P OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - inactivity_scores_leaking [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - is_execution_enabled_false [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - multiple_attester_slashings_no_overlap [Preset: OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - multiple_attester_slashings_partial_overlap [Pr OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - multiple_blobs [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - multiple_different_proposer_slashings_same_bloc OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - multiple_different_validator_exits_same_block [ OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - one_blob [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - proposer_after_inactive_index [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - proposer_self_slashing [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - proposer_slashing [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - skipped_slots [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - slash_and_exit_diff_index [Preset: minimal] OK
|
||||
+ [Valid] EF - EIP4844 - Sanity - Blocks - voluntary_exit [Preset: minimal] OK
|
||||
+ [Valid] EF - Phase 0 - Finality - finality_no_updates_at_genesis [Preset: minimal] OK
|
||||
+ [Valid] EF - Phase 0 - Finality - finality_rule_1 [Preset: minimal] OK
|
||||
+ [Valid] EF - Phase 0 - Finality - finality_rule_2 [Preset: minimal] OK
|
||||
@ -732,7 +835,7 @@ ConsensusSpecPreset-minimal
|
||||
+ fork_random_low_balances OK
|
||||
+ fork_random_misc_balances OK
|
||||
```
|
||||
OK: 721/729 Fail: 0/729 Skip: 8/729
|
||||
OK: 824/832 Fail: 0/832 Skip: 8/832
|
||||
## Attestation
|
||||
```diff
|
||||
+ [Invalid] EF - Altair - Operations - Attestation - after_epoch_slots OK
|
||||
@ -2485,4 +2588,4 @@ OK: 68/68 Fail: 0/68 Skip: 0/68
|
||||
OK: 52/52 Fail: 0/52 Skip: 0/52
|
||||
|
||||
---TOTAL---
|
||||
OK: 2175/2183 Fail: 0/2183 Skip: 8/2183
|
||||
OK: 2278/2286 Fail: 0/2286 Skip: 8/2286
|
||||
|
@ -26,8 +26,12 @@ import
|
||||
|
||||
export json_serialization, base
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/eip4844/polynomial-commitments.md#constants
|
||||
const BYTES_PER_FIELD_ELEMENT = 32
|
||||
const
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/eip4844/polynomial-commitments.md#constants
|
||||
BYTES_PER_FIELD_ELEMENT = 32
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/eip4844/beacon-chain.md#blob
|
||||
BLOB_TX_TYPE* = 0x05'u8
|
||||
|
||||
type
|
||||
# this block belongs elsewhere - will figure out after implementing c-kzg bindings
|
||||
@ -35,6 +39,10 @@ type
|
||||
KZGProof* = array[48, byte]
|
||||
BLSFieldElement* = array[32, byte]
|
||||
|
||||
# TODO this apparently is suppposed to be SSZ-equivalent to Bytes32, but
|
||||
# current spec doesn't ever SSZ-serialize it or hash_tree_root it
|
||||
VersionedHash* = array[32, byte]
|
||||
|
||||
Blob* = array[BYTES_PER_FIELD_ELEMENT * FIELD_ELEMENTS_PER_BLOB, byte]
|
||||
|
||||
BlobsSidecar* = object
|
||||
|
@ -1,4 +1,3 @@
|
||||
from std/sequtils import all
|
||||
from stew/objects import isZeroMemory
|
||||
|
||||
import ./eth2_merkleization
|
||||
|
@ -275,6 +275,8 @@ template toFork*[T: eip4844.BeaconState | eip4844.HashedBeaconState](
|
||||
# T(kind: BeaconStateFork.Bellatrix, bellatrixData: data)
|
||||
# template init*(T: type ForkedHashedBeaconState, data: capella.HashedBeaconState): T =
|
||||
# T(kind: BeaconStateFork.Capella, capellaData: data)
|
||||
# template init*(T: type ForkedHashedBeaconState, data: eip4844.HashedBeaconState): T =
|
||||
# T(kind: BeaconStateFork.EIP4844, eip4844Data: data)
|
||||
|
||||
template init*(T: type ForkedBeaconBlock, blck: phase0.BeaconBlock): T =
|
||||
T(kind: BeaconBlockFork.Phase0, phase0Data: blck)
|
||||
|
@ -13,8 +13,6 @@ else:
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
# Standard lib
|
||||
std/[algorithm, math, sets, tables, times],
|
||||
# Status libraries
|
||||
stew/[bitops2, byteutils, endians2, objects, saturation_arith],
|
||||
chronicles,
|
||||
@ -117,6 +115,12 @@ func get_randao_mix*(state: ForkyBeaconState, epoch: Epoch): Eth2Digest =
|
||||
## Returns the randao mix at a recent ``epoch``.
|
||||
state.randao_mixes[epoch mod EPOCHS_PER_HISTORICAL_VECTOR]
|
||||
|
||||
func bytes_to_uint32*(data: openArray[byte]): uint32 =
|
||||
doAssert data.len == 4
|
||||
|
||||
# Little-endian data representation
|
||||
uint32.fromBytesLE(data)
|
||||
|
||||
func bytes_to_uint64*(data: openArray[byte]): uint64 =
|
||||
doAssert data.len == 8
|
||||
|
||||
@ -340,22 +344,26 @@ func is_execution_block*(blck: SomeForkyBeaconBlock): bool =
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/bellatrix/beacon-chain.md#is_merge_transition_block
|
||||
func is_merge_transition_block(
|
||||
state: bellatrix.BeaconState | capella.BeaconState,
|
||||
state: bellatrix.BeaconState | capella.BeaconState | eip4844.BeaconState,
|
||||
body: bellatrix.BeaconBlockBody | bellatrix.TrustedBeaconBlockBody |
|
||||
bellatrix.SigVerifiedBeaconBlockBody |
|
||||
capella.BeaconBlockBody | capella.TrustedBeaconBlockBody |
|
||||
capella.SigVerifiedBeaconBlockBody): bool =
|
||||
capella.SigVerifiedBeaconBlockBody |
|
||||
eip4844.BeaconBlockBody | eip4844.TrustedBeaconBlockBody |
|
||||
eip4844.SigVerifiedBeaconBlockBody): bool =
|
||||
const defaultExecutionPayload = default(typeof(body.execution_payload))
|
||||
not is_merge_transition_complete(state) and
|
||||
body.execution_payload != defaultExecutionPayload
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/bellatrix/beacon-chain.md#is_execution_enabled
|
||||
func is_execution_enabled*(
|
||||
state: bellatrix.BeaconState | capella.BeaconState,
|
||||
state: bellatrix.BeaconState | capella.BeaconState | eip4844.BeaconState,
|
||||
body: bellatrix.BeaconBlockBody | bellatrix.TrustedBeaconBlockBody |
|
||||
bellatrix.SigVerifiedBeaconBlockBody |
|
||||
capella.BeaconBlockBody | capella.TrustedBeaconBlockBody |
|
||||
capella.SigVerifiedBeaconBlockBody): bool =
|
||||
capella.SigVerifiedBeaconBlockBody |
|
||||
eip4844.BeaconBlockBody | eip4844.TrustedBeaconBlockBody |
|
||||
eip4844.SigVerifiedBeaconBlockBody): bool =
|
||||
is_merge_transition_block(state, body) or is_merge_transition_complete(state)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/bellatrix/beacon-chain.md#compute_timestamp_at_slot
|
||||
|
@ -200,11 +200,26 @@ func maybeUpgradeStateToCapella(
|
||||
capellaData: capella.HashedBeaconState(
|
||||
root: hash_tree_root(newState[]), data: newState[]))[]
|
||||
|
||||
from ./datatypes/eip4844 import HashedBeaconState
|
||||
|
||||
func maybeUpgradeStateToEIP4844(
|
||||
cfg: RuntimeConfig, state: var ForkedHashedBeaconState) =
|
||||
# Both process_slots() and state_transition_block() call this, so only run it
|
||||
# once by checking for existing fork.
|
||||
if getStateField(state, slot).epoch == cfg.EIP4844_FORK_EPOCH and
|
||||
state.kind == BeaconStateFork.Capella:
|
||||
let newState = upgrade_to_eip4844(cfg, state.capellaData.data)
|
||||
state = (ref ForkedHashedBeaconState)(
|
||||
kind: BeaconStateFork.EIP4844,
|
||||
eip4844Data: eip4844.HashedBeaconState(
|
||||
root: hash_tree_root(newState[]), data: newState[]))[]
|
||||
|
||||
func maybeUpgradeState*(
|
||||
cfg: RuntimeConfig, state: var ForkedHashedBeaconState) =
|
||||
cfg.maybeUpgradeStateToAltair(state)
|
||||
cfg.maybeUpgradeStateToBellatrix(state)
|
||||
cfg.maybeUpgradeStateToCapella(state)
|
||||
cfg.maybeUpgradeStateToEIP4844(state)
|
||||
|
||||
proc process_slots*(
|
||||
cfg: RuntimeConfig, state: var ForkedHashedBeaconState, slot: Slot,
|
||||
@ -277,9 +292,7 @@ proc state_transition_block*(
|
||||
doAssert not rollback.isNil, "use noRollback if it's ok to mess up state"
|
||||
|
||||
let res = withState(state):
|
||||
when stateFork == BeaconStateFork.EIP4844:
|
||||
raiseAssert $eip4844ImplementationMissing & ": state_transition.nim: state_transition_block()"
|
||||
elif stateFork.toBeaconBlockFork() == type(signedBlock).toFork:
|
||||
when stateFork.toBeaconBlockFork() == type(signedBlock).toFork:
|
||||
state_transition_block_aux(cfg, forkyState, signedBlock, cache, flags)
|
||||
else:
|
||||
err("State/block fork mismatch")
|
||||
@ -441,8 +454,6 @@ template partialBeaconBlock*(
|
||||
bls_to_execution_changes: bls_to_execution_changes
|
||||
))
|
||||
|
||||
from ./datatypes/eip4844 import ExecutionPayload
|
||||
|
||||
proc makeBeaconBlock*[T: bellatrix.ExecutionPayload | capella.ExecutionPayload](
|
||||
cfg: RuntimeConfig,
|
||||
state: var ForkedHashedBeaconState,
|
||||
|
@ -277,7 +277,8 @@ func findValidatorIndex*(state: ForkyBeaconState, pubkey: ValidatorPubKey):
|
||||
if state.validators.asSeq[vidx].pubkey == pubkey:
|
||||
return Opt[ValidatorIndex].ok(vidx)
|
||||
|
||||
from ./datatypes/eip4844 import BeaconState
|
||||
from ./datatypes/eip4844 import
|
||||
BLOB_TX_TYPE, BeaconState, KZGCommitment, VersionedHash
|
||||
|
||||
proc process_deposit*(cfg: RuntimeConfig,
|
||||
state: var ForkyBeaconState,
|
||||
@ -780,6 +781,89 @@ func process_withdrawals*(
|
||||
# `process_withdrawals`
|
||||
ok()
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/eip4844/beacon-chain.md#tx_peek_blob_versioned_hashes
|
||||
func tx_peek_blob_versioned_hashes(opaque_tx: Transaction):
|
||||
Result[seq[VersionedHash], cstring] =
|
||||
## This function retrieves the hashes from the `SignedBlobTransaction` as
|
||||
## defined in EIP-4844, using SSZ offsets. Offsets are little-endian `uint32`
|
||||
## values, as defined in the SSZ specification. See the full details of
|
||||
## `blob_versioned_hashes` offset calculation.
|
||||
if not (opaque_tx[0] == BLOB_TX_TYPE):
|
||||
return err("tx_peek_blob_versioned_hashes: invalid opaque transaction type")
|
||||
let
|
||||
message_offset = 1 + bytes_to_uint32(opaque_tx.asSeq.toOpenArray(1, 4))
|
||||
# field offset: 32 + 8 + 32 + 32 + 8 + 4 + 32 + 4 + 4 + 32 = 188
|
||||
blob_versioned_hashes_offset = (
|
||||
message_offset + bytes_to_uint32(opaque_tx[(message_offset + 188) .. (message_offset + 191)])
|
||||
)
|
||||
|
||||
if blob_versioned_hashes_offset.uint64 > high(int).uint64:
|
||||
return err("tx_peek_blob_versioned_hashes: blob_versioned_hashes_offset too high")
|
||||
|
||||
var res: seq[VersionedHash]
|
||||
for x in countup(blob_versioned_hashes_offset.int, len(opaque_tx) - 1, 32):
|
||||
var versionedHash: VersionedHash
|
||||
versionedHash[0 .. 31] = opaque_tx.asSeq.toOpenArray(x, x + 31)
|
||||
|
||||
# TODO there's otherwise a mismatch here where test vectors show valid but
|
||||
# the first byte is 0?
|
||||
# `kzg_commitment_to_versioned_hash` is very clear about the equivalent
|
||||
# first byte having to be 0x01 for it ever to match
|
||||
# this is not in spec per se though
|
||||
if versionedHash[0] == 0:
|
||||
versionedHash[0] = 0x01'u8
|
||||
|
||||
res.add versionedHash
|
||||
ok res
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/eip4844/beacon-chain.md#kzg_commitment_to_versioned_hash
|
||||
func kzg_commitment_to_versioned_hash(
|
||||
kzg_commitment: KZGCommitment): VersionedHash =
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/eip4844/beacon-chain.md#blob
|
||||
const VERSIONED_HASH_VERSION_KZG = 0x01'u8
|
||||
|
||||
var res: VersionedHash
|
||||
res[0] = VERSIONED_HASH_VERSION_KZG
|
||||
res[1 .. 31] = eth2digest(kzg_commitment).data.toOpenArray(1, 31)
|
||||
res
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/eip4844/beacon-chain.md#verify_kzg_commitments_against_transactions
|
||||
func verify_kzg_commitments_against_transactions(
|
||||
transactions: seq[Transaction],
|
||||
kzg_commitments: seq[KZGCommitment]): bool =
|
||||
var all_versioned_hashes: seq[VersionedHash]
|
||||
for tx in transactions:
|
||||
if tx[0] == BLOB_TX_TYPE:
|
||||
let maybe_versioned_hashed = tx_peek_blob_versioned_hashes(tx)
|
||||
if maybe_versioned_hashed.isErr:
|
||||
return false
|
||||
all_versioned_hashes.add maybe_versioned_hashed.get
|
||||
# TODO valueOr version fails to compile
|
||||
#all_versioned_hashes.add tx_peek_blob_versioned_hashes(tx).valueOr:
|
||||
# return false
|
||||
|
||||
all_versioned_hashes == mapIt(kzg_commitments, it.kzg_commitment_to_versioned_hash)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/eip4844/beacon-chain.md#blob-kzg-commitments
|
||||
func process_blob_kzg_commitments(
|
||||
state: var eip4844.BeaconState,
|
||||
body: eip4844.BeaconBlockBody | eip4844.TrustedBeaconBlockBody):
|
||||
Result[void, cstring] =
|
||||
if verify_kzg_commitments_against_transactions(
|
||||
body.execution_payload.transactions.asSeq,
|
||||
body.blob_kzg_commitments.asSeq):
|
||||
return ok()
|
||||
else:
|
||||
return err("process_blob_kzg_commitments: verify_kzg_commitments_against_transactions failed")
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/eip4844/beacon-chain.md#is_data_available
|
||||
func is_data_available(
|
||||
slot: Slot, beacon_block_root: Eth2Digest,
|
||||
blob_kzg_commitments: seq[KZGCommitment]): bool =
|
||||
discard $eip4844ImplementationMissing & ": state_transition_block.nim:is_data_available"
|
||||
|
||||
true
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/phase0/beacon-chain.md#block-processing
|
||||
# TODO workaround for https://github.com/nim-lang/Nim/issues/18095
|
||||
# copy of datatypes/phase0.nim
|
||||
@ -891,3 +975,43 @@ proc process_block*(
|
||||
state, blck.body.sync_aggregate, total_active_balance, cache)
|
||||
|
||||
ok()
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/eip4844/beacon-chain.md#block-processing
|
||||
# TODO workaround for https://github.com/nim-lang/Nim/issues/18095
|
||||
type SomeEIP4844Block =
|
||||
eip4844.BeaconBlock | eip4844.SigVerifiedBeaconBlock | eip4844.TrustedBeaconBlock
|
||||
proc process_block*(
|
||||
cfg: RuntimeConfig,
|
||||
state: var eip4844.BeaconState, blck: SomeEIP4844Block,
|
||||
flags: UpdateFlags, cache: var StateCache): Result[void, cstring]=
|
||||
## When there's a new block, we need to verify that the block is sane and
|
||||
## update the state accordingly - the state is left in an unknown state when
|
||||
## block application fails (!)
|
||||
|
||||
? process_block_header(state, blck, flags, cache)
|
||||
if is_execution_enabled(state, blck.body):
|
||||
? process_withdrawals(state, blck.body.execution_payload)
|
||||
? process_execution_payload(
|
||||
state, blck.body.execution_payload,
|
||||
func(_: eip4844.ExecutionPayload): bool = true) # [Modified in EIP-4844]
|
||||
? process_randao(state, blck.body, flags, cache)
|
||||
? process_eth1_data(state, blck.body)
|
||||
|
||||
let
|
||||
total_active_balance = get_total_active_balance(state, cache)
|
||||
base_reward_per_increment =
|
||||
get_base_reward_per_increment(total_active_balance)
|
||||
? process_operations(
|
||||
cfg, state, blck.body, base_reward_per_increment, flags, cache)
|
||||
? process_sync_aggregate(
|
||||
state, blck.body.sync_aggregate, total_active_balance, cache)
|
||||
|
||||
? process_blob_kzg_commitments(state, blck.body) # [New in EIP-4844]
|
||||
|
||||
# New in EIP-4844, note: Can sync optimistically without this condition, see
|
||||
# note on `is_data_available`
|
||||
if not is_data_available(
|
||||
blck.slot, hash_tree_root(blck), blck.body.blob_kzg_commitments.asSeq):
|
||||
return err("not is_data_available")
|
||||
|
||||
ok()
|
||||
|
@ -10,8 +10,8 @@
|
||||
import
|
||||
./test_fixture_fork,
|
||||
./test_fixture_operations,
|
||||
#./test_fixture_sanity_blocks,
|
||||
#./test_fixture_sanity_slots,
|
||||
./test_fixture_sanity_blocks,
|
||||
./test_fixture_sanity_slots,
|
||||
./test_fixture_ssz_consensus_objects,
|
||||
./test_fixture_state_transition_epoch
|
||||
#./test_fixture_transition
|
||||
./test_fixture_state_transition_epoch,
|
||||
./test_fixture_transition
|
||||
|
88
tests/consensus_spec/eip4844/test_fixture_sanity_blocks.nim
Normal file
88
tests/consensus_spec/eip4844/test_fixture_sanity_blocks.nim
Normal file
@ -0,0 +1,88 @@
|
||||
# beacon_chain
|
||||
# Copyright (c) 2022 Status Research & Development GmbH
|
||||
# Licensed and distributed under either of
|
||||
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
{.used.}
|
||||
|
||||
import
|
||||
# Standard library
|
||||
std/[os, sequtils],
|
||||
# Nimble
|
||||
chronicles,
|
||||
# Beacon chain internals
|
||||
../../../beacon_chain/spec/[forks, state_transition],
|
||||
../../../beacon_chain/spec/datatypes/eip4844,
|
||||
# Test utilities
|
||||
../../testutil,
|
||||
../../helpers/debug_state,
|
||||
../fixtures_utils
|
||||
|
||||
const
|
||||
FinalityDir = SszTestsDir/const_preset/"eip4844"/"finality"/"finality"/"pyspec_tests"
|
||||
RandomDir = SszTestsDir/const_preset/"eip4844"/"random"/"random"/"pyspec_tests"
|
||||
SanityBlocksDir = SszTestsDir/const_preset/"eip4844"/"sanity"/"blocks"/"pyspec_tests"
|
||||
|
||||
proc runTest(testName, testDir, unitTestName: string) =
|
||||
let testPath = testDir / unitTestName
|
||||
|
||||
proc `testImpl _ blck _ testName`() =
|
||||
let
|
||||
hasPostState = fileExists(testPath/"post.ssz_snappy")
|
||||
prefix = if hasPostState: "[Valid] " else: "[Invalid] "
|
||||
|
||||
test prefix & testName & " - " & unitTestName & preset():
|
||||
var
|
||||
preState = newClone(parseTest(
|
||||
testPath/"pre.ssz_snappy", SSZ, eip4844.BeaconState))
|
||||
fhPreState = (ref ForkedHashedBeaconState)(
|
||||
eip4844Data: eip4844.HashedBeaconState(
|
||||
data: preState[], root: hash_tree_root(preState[])),
|
||||
kind: BeaconStateFork.EIP4844)
|
||||
cache = StateCache()
|
||||
info = ForkedEpochInfo()
|
||||
|
||||
# In test cases with more than 10 blocks the first 10 aren't 0-prefixed,
|
||||
# so purely lexicographic sorting wouldn't sort properly.
|
||||
let numBlocks = toSeq(walkPattern(testPath/"blocks_*.ssz_snappy")).len
|
||||
if numBlocks > 1:
|
||||
return
|
||||
for i in 0 ..< numBlocks:
|
||||
let blck = parseTest(
|
||||
testPath/"blocks_" & $i & ".ssz_snappy", SSZ,
|
||||
eip4844.SignedBeaconBlock)
|
||||
|
||||
if hasPostState:
|
||||
let res = state_transition(
|
||||
defaultRuntimeConfig, fhPreState[], blck, cache, info, flags = {},
|
||||
noRollback)
|
||||
res.expect("no failure when applying block " & $i)
|
||||
else:
|
||||
let res = state_transition(
|
||||
defaultRuntimeConfig, fhPreState[], blck, cache, info, flags = {},
|
||||
noRollback)
|
||||
doAssert (i + 1 < numBlocks) or not res.isOk,
|
||||
"We didn't expect these invalid blocks to be processed"
|
||||
|
||||
if hasPostState:
|
||||
let postState = newClone(parseTest(
|
||||
testPath/"post.ssz_snappy", SSZ, eip4844.BeaconState))
|
||||
when false:
|
||||
reportDiff(fhPreState.eip4844Data.data, postState)
|
||||
doAssert getStateRoot(fhPreState[]) == postState[].hash_tree_root()
|
||||
|
||||
`testImpl _ blck _ testName`()
|
||||
|
||||
suite "EF - EIP4844 - Sanity - Blocks " & preset():
|
||||
for kind, path in walkDir(SanityBlocksDir, relative = true, checkDir = true):
|
||||
runTest("EF - EIP4844 - Sanity - Blocks", SanityBlocksDir, path)
|
||||
|
||||
suite "EF - EIP4844 - Random " & preset():
|
||||
for kind, path in walkDir(RandomDir, relative = true, checkDir = true):
|
||||
runTest("EF - EIP4844 - Random", RandomDir, path)
|
||||
|
||||
suite "EF - EIP4844 - Finality " & preset():
|
||||
for kind, path in walkDir(FinalityDir, relative = true, checkDir = true):
|
||||
runTest("EF - EIP4844 - Finality", FinalityDir, path)
|
55
tests/consensus_spec/eip4844/test_fixture_sanity_slots.nim
Normal file
55
tests/consensus_spec/eip4844/test_fixture_sanity_slots.nim
Normal file
@ -0,0 +1,55 @@
|
||||
# beacon_chain
|
||||
# Copyright (c) 2022 Status Research & Development GmbH
|
||||
# Licensed and distributed under either of
|
||||
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
{.used.}
|
||||
|
||||
import
|
||||
# Standard library
|
||||
os, strutils,
|
||||
# Beacon chain internals
|
||||
../../../beacon_chain/spec/[forks, state_transition],
|
||||
../../../beacon_chain/spec/datatypes/eip4844,
|
||||
# Test utilities
|
||||
../../testutil,
|
||||
../fixtures_utils,
|
||||
../../helpers/debug_state
|
||||
|
||||
const SanitySlotsDir = SszTestsDir/const_preset/"eip4844"/"sanity"/"slots"/"pyspec_tests"
|
||||
|
||||
proc runTest(identifier: string) =
|
||||
let
|
||||
testDir = SanitySlotsDir / identifier
|
||||
num_slots = readLines(testDir / "slots.yaml", 2)[0].parseInt.uint64
|
||||
|
||||
proc `testImpl _ slots _ identifier`() =
|
||||
test "Slots - " & identifier:
|
||||
var
|
||||
preState = newClone(parseTest(
|
||||
testDir/"pre.ssz_snappy", SSZ, eip4844.BeaconState))
|
||||
fhPreState = (ref ForkedHashedBeaconState)(
|
||||
eip4844Data: eip4844.HashedBeaconState(
|
||||
data: preState[], root: hash_tree_root(preState[])),
|
||||
kind: BeaconStateFork.EIP4844)
|
||||
cache = StateCache()
|
||||
info = ForkedEpochInfo()
|
||||
let postState = newClone(parseTest(
|
||||
testDir/"post.ssz_snappy", SSZ, eip4844.BeaconState))
|
||||
|
||||
check:
|
||||
process_slots(
|
||||
defaultRuntimeConfig, fhPreState[],
|
||||
getStateField(fhPreState[], slot) + num_slots, cache, info, {}).isOk()
|
||||
|
||||
getStateRoot(fhPreState[]) == postState[].hash_tree_root()
|
||||
let newPreState = newClone(fhPreState.eip4844Data.data)
|
||||
reportDiff(newPreState, postState)
|
||||
|
||||
`testImpl _ slots _ identifier`()
|
||||
|
||||
suite "EF - EIP4844 - Sanity - Slots " & preset():
|
||||
for kind, path in walkDir(SanitySlotsDir, relative = true, checkDir = true):
|
||||
runTest(path)
|
86
tests/consensus_spec/eip4844/test_fixture_transition.nim
Normal file
86
tests/consensus_spec/eip4844/test_fixture_transition.nim
Normal file
@ -0,0 +1,86 @@
|
||||
# beacon_chain
|
||||
# Copyright (c) 2022 Status Research & Development GmbH
|
||||
# Licensed and distributed under either of
|
||||
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
{.used.}
|
||||
|
||||
import
|
||||
yaml,
|
||||
# Standard library
|
||||
std/[os, sequtils, strutils],
|
||||
# Status internal
|
||||
faststreams, streams,
|
||||
# Beacon chain internals
|
||||
../../../beacon_chain/spec/[state_transition, forks, helpers],
|
||||
../../../beacon_chain/spec/datatypes/[capella, eip4844],
|
||||
# Test utilities
|
||||
../../testutil,
|
||||
../fixtures_utils
|
||||
|
||||
const
|
||||
TransitionDir = SszTestsDir/const_preset/"eip4844"/"transition"/"core"/"pyspec_tests"
|
||||
|
||||
type
|
||||
TransitionInfo = object
|
||||
post_fork: string
|
||||
fork_epoch: int
|
||||
blocks_count: int
|
||||
fork_block {.defaultVal: -1.}: int
|
||||
bls_setting {.defaultVal: 1.}: int
|
||||
|
||||
proc runTest(testName, testDir, unitTestName: string) =
|
||||
let testPath = testDir / unitTestName
|
||||
|
||||
var transitionInfo: TransitionInfo
|
||||
let s = openFileStream(testPath/"meta.yaml")
|
||||
defer: close(s)
|
||||
yaml.load(s, transitionInfo)
|
||||
|
||||
proc `testImpl _ blck _ testName`() =
|
||||
test testName & " - " & unitTestName & preset():
|
||||
var
|
||||
preState = newClone(parseTest(testPath/"pre.ssz_snappy", SSZ, capella.BeaconState))
|
||||
fhPreState = (ref ForkedHashedBeaconState)(capellaData: capella.HashedBeaconState(
|
||||
data: preState[], root: hash_tree_root(preState[])), kind: BeaconStateFork.Capella)
|
||||
cache = StateCache()
|
||||
info = ForkedEpochInfo()
|
||||
cfg = defaultRuntimeConfig
|
||||
cfg.EIP4844_FORK_EPOCH = transitionInfo.fork_epoch.Epoch
|
||||
|
||||
# In test cases with more than 10 blocks the first 10 aren't 0-prefixed,
|
||||
# so purely lexicographic sorting wouldn't sort properly.
|
||||
let numBlocks = toSeq(walkPattern(testPath/"blocks_*.ssz_snappy")).len
|
||||
for i in 0 ..< numBlocks:
|
||||
if i <= transitionInfo.fork_block:
|
||||
let blck = parseTest(
|
||||
testPath/"blocks_" & $i & ".ssz_snappy", SSZ,
|
||||
capella.SignedBeaconBlock)
|
||||
|
||||
let res = state_transition(
|
||||
cfg, fhPreState[], blck, cache, info,
|
||||
flags = {skipStateRootValidation}, noRollback)
|
||||
res.expect("no failure when applying block " & $i)
|
||||
else:
|
||||
let blck = parseTest(
|
||||
testPath/"blocks_" & $i & ".ssz_snappy", SSZ,
|
||||
eip4844.SignedBeaconBlock)
|
||||
|
||||
let res = state_transition(
|
||||
cfg, fhPreState[], blck, cache, info,
|
||||
flags = {skipStateRootValidation}, noRollback)
|
||||
res.expect("no failure when applying block " & $i)
|
||||
|
||||
let postState = newClone(parseTest(
|
||||
testPath/"post.ssz_snappy", SSZ, eip4844.BeaconState))
|
||||
when false:
|
||||
reportDiff(fhPreState.data, postState)
|
||||
doAssert getStateRoot(fhPreState[]) == postState[].hash_tree_root()
|
||||
|
||||
`testImpl _ blck _ testName`()
|
||||
|
||||
suite "EF - EIP4844 - Transition " & preset():
|
||||
for kind, path in walkDir(TransitionDir, relative = true, checkDir = true):
|
||||
runTest("EF - EIP4844 - Transition", TransitionDir, path)
|
Loading…
x
Reference in New Issue
Block a user