diff --git a/FixtureAll-mainnet.md b/FixtureAll-mainnet.md index eca16fd3e..295b59c3f 100644 --- a/FixtureAll-mainnet.md +++ b/FixtureAll-mainnet.md @@ -55,20 +55,35 @@ FixtureAll-mainnet + Slots - slots_2 OK + [Invalid] bad_merkle_proof OK + [Invalid] wrong_deposit_for_deposit_count OK -+ [Invalid] Official - Sanity - Blocks - double_same_proposer_slashings_same_block [Preset: OK -+ [Invalid] Official - Sanity - Blocks - double_similar_proposer_slashings_same_block [Prese OK -+ [Invalid] Official - Sanity - Blocks - double_validator_exit_same_block [Preset: mainnet] OK -+ [Invalid] Official - Sanity - Blocks - duplicate_attester_slashing [Preset: mainnet] OK -+ [Invalid] Official - Sanity - Blocks - expected_deposit_in_block [Preset: mainnet] OK -+ [Invalid] Official - Sanity - Blocks - invalid_block_sig [Preset: mainnet] OK -+ [Invalid] Official - Sanity - Blocks - invalid_proposer_index_sig_from_expected_proposer [ OK -+ [Invalid] Official - Sanity - Blocks - invalid_proposer_index_sig_from_proposer_index [Pre OK -+ [Invalid] Official - Sanity - Blocks - invalid_state_root [Preset: mainnet] OK -+ [Invalid] Official - Sanity - Blocks - parent_from_same_slot [Preset: mainnet] OK -+ [Invalid] Official - Sanity - Blocks - prev_slot_block_transition [Preset: mainnet] OK -+ [Invalid] Official - Sanity - Blocks - same_slot_block_transition [Preset: mainnet] OK -+ [Invalid] Official - Sanity - Blocks - slash_and_exit_same_index [Preset: mainnet] OK -+ [Invalid] Official - Sanity - Blocks - zero_block_sig [Preset: mainnet] OK ++ [Invalid] Official - Altair - Sanity - Blocks - double_same_proposer_slashings_same_block OK ++ [Invalid] Official - Altair - Sanity - Blocks - double_similar_proposer_slashings_same_blo OK ++ [Invalid] Official - Altair - Sanity - Blocks - double_validator_exit_same_block [Preset: OK ++ [Invalid] Official - Altair - Sanity - Blocks - duplicate_attester_slashing [Preset: mainn OK ++ [Invalid] Official - Altair - Sanity - Blocks - expected_deposit_in_block [Preset: mainnet OK ++ [Invalid] Official - Altair - Sanity - Blocks - invalid_block_sig [Preset: mainnet] OK ++ [Invalid] Official - Altair - Sanity - Blocks - invalid_proposer_index_sig_from_expected_p OK ++ [Invalid] Official - Altair - Sanity - Blocks - invalid_proposer_index_sig_from_proposer_i OK ++ [Invalid] Official - Altair - Sanity - Blocks - invalid_state_root [Preset: mainnet] OK ++ [Invalid] Official - Altair - Sanity - Blocks - parent_from_same_slot [Preset: mainnet] OK ++ [Invalid] Official - Altair - Sanity - Blocks - prev_slot_block_transition [Preset: mainne OK ++ [Invalid] Official - Altair - Sanity - Blocks - same_slot_block_transition [Preset: mainne OK ++ [Invalid] Official - Altair - Sanity - Blocks - slash_and_exit_same_index [Preset: mainnet OK ++ [Invalid] Official - Altair - Sanity - Blocks - zero_block_sig [Preset: mainnet] OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - double_same_proposer_slashings_same_block OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - double_similar_proposer_slashings_same_bl OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - double_validator_exit_same_block [Preset: OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - duplicate_attester_slashing [Preset: main OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - expected_deposit_in_block [Preset: mainne OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - invalid_block_sig [Preset: mainnet] OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - invalid_proposer_index_sig_from_expected_ OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - invalid_proposer_index_sig_from_proposer_ OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - invalid_state_root [Preset: mainnet] OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - parent_from_same_slot [Preset: mainnet] OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - prev_slot_block_transition [Preset: mainn OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - proposal_for_genesis_slot [Preset: mainne OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - same_slot_block_transition [Preset: mainn OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - slash_and_exit_same_index [Preset: mainne OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - zero_block_sig [Preset: mainnet] OK + [Invalid] after_epoch_slots OK + [Invalid] all_empty_indices OK + [Invalid] att1_bad_extra_index OK @@ -146,25 +161,48 @@ FixtureAll-mainnet + [Valid] new_deposit_under_max OK + [Valid] success_top_up OK + [Valid] valid_sig_but_forked_state OK -+ [Valid] Official - Sanity - Blocks - attestation [Preset: mainnet] OK -+ [Valid] Official - Sanity - Blocks - attester_slashing [Preset: mainnet] OK -+ [Valid] Official - Sanity - Blocks - balance_driven_status_transitions [Preset: mainnet] OK -+ [Valid] Official - Sanity - Blocks - deposit_in_block [Preset: mainnet] OK -+ [Valid] Official - Sanity - Blocks - deposit_top_up [Preset: mainnet] OK -+ [Valid] Official - Sanity - Blocks - empty_block_transition [Preset: mainnet] OK -+ [Valid] Official - Sanity - Blocks - empty_epoch_transition [Preset: mainnet] OK -+ [Valid] Official - Sanity - Blocks - high_proposer_index [Preset: mainnet] OK -+ [Valid] Official - Sanity - Blocks - historical_batch [Preset: mainnet] OK -+ [Valid] Official - Sanity - Blocks - multiple_attester_slashings_no_overlap [Preset: mai OK -+ [Valid] Official - Sanity - Blocks - multiple_attester_slashings_partial_overlap [Preset OK -+ [Valid] Official - Sanity - Blocks - multiple_different_proposer_slashings_same_block [P OK -+ [Valid] Official - Sanity - Blocks - multiple_different_validator_exits_same_block [Pres OK -+ [Valid] Official - Sanity - Blocks - proposer_after_inactive_index [Preset: mainnet] OK -+ [Valid] Official - Sanity - Blocks - proposer_self_slashing [Preset: mainnet] OK -+ [Valid] Official - Sanity - Blocks - proposer_slashing [Preset: mainnet] OK -+ [Valid] Official - Sanity - Blocks - skipped_slots [Preset: mainnet] OK -+ [Valid] Official - Sanity - Blocks - slash_and_exit_diff_index [Preset: mainnet] OK -+ [Valid] Official - Sanity - Blocks - voluntary_exit [Preset: mainnet] OK ++ [Valid] Official - Altair - Sanity - Blocks - attestation [Preset: mainnet] OK ++ [Valid] Official - Altair - Sanity - Blocks - attester_slashing [Preset: mainnet] OK ++ [Valid] Official - Altair - Sanity - Blocks - balance_driven_status_transitions [Preset: OK ++ [Valid] Official - Altair - Sanity - Blocks - deposit_in_block [Preset: mainnet] OK ++ [Valid] Official - Altair - Sanity - Blocks - deposit_top_up [Preset: mainnet] OK ++ [Valid] Official - Altair - Sanity - Blocks - empty_block_transition [Preset: mainnet] OK ++ [Valid] Official - Altair - Sanity - Blocks - empty_epoch_transition [Preset: mainnet] OK ++ [Valid] Official - Altair - Sanity - Blocks - high_proposer_index [Preset: mainnet] OK ++ [Valid] Official - Altair - Sanity - Blocks - historical_batch [Preset: mainnet] OK ++ [Valid] Official - Altair - Sanity - Blocks - multiple_attester_slashings_no_overlap [Pr OK ++ [Valid] Official - Altair - Sanity - Blocks - multiple_attester_slashings_partial_overla OK ++ [Valid] Official - Altair - Sanity - Blocks - multiple_different_proposer_slashings_same OK ++ [Valid] Official - Altair - Sanity - Blocks - multiple_different_validator_exits_same_bl OK ++ [Valid] Official - Altair - Sanity - Blocks - proposer_after_inactive_index [Preset: mai OK ++ [Valid] Official - Altair - Sanity - Blocks - proposer_self_slashing [Preset: mainnet] OK ++ [Valid] Official - Altair - Sanity - Blocks - proposer_slashing [Preset: mainnet] OK ++ [Valid] Official - Altair - Sanity - Blocks - skipped_slots [Preset: mainnet] OK ++ [Valid] Official - Altair - Sanity - Blocks - slash_and_exit_diff_index [Preset: mainnet OK ++ [Valid] Official - Altair - Sanity - Blocks - voluntary_exit [Preset: mainnet] OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - attestation [Preset: mainnet] OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - attester_slashing [Preset: mainnet] OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - balance_driven_status_transitions [Preset OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - deposit_in_block [Preset: mainnet] OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - deposit_top_up [Preset: mainnet] OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - empty_block_transition [Preset: mainnet] OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - empty_epoch_transition [Preset: mainnet] OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - full_random_operations_0 [Preset: mainnet OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - full_random_operations_1 [Preset: mainnet OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - full_random_operations_2 [Preset: mainnet OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - full_random_operations_3 [Preset: mainnet OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - high_proposer_index [Preset: mainnet] OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - historical_batch [Preset: mainnet] OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - multiple_attester_slashings_no_overlap [P OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - multiple_attester_slashings_partial_overl OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - multiple_different_proposer_slashings_sam OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - multiple_different_validator_exits_same_b OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - proposer_after_inactive_index [Preset: ma OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - proposer_self_slashing [Preset: mainnet] OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - proposer_slashing [Preset: mainnet] OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - skipped_slots [Preset: mainnet] OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - slash_and_exit_diff_index [Preset: mainne OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - voluntary_exit [Preset: mainnet] OK + [Valid] correct_epoch_delay OK + [Valid] correct_min_inclusion_delay OK + [Valid] correct_sqrt_epoch_delay OK @@ -195,29 +233,29 @@ FixtureAll-mainnet + [Valid] sync_committee_rewards_empty_participants OK + [Valid] sync_committee_rewards_not_full_participants OK ``` -OK: 192/192 Fail: 0/192 Skip: 0/192 -## Official - Epoch Processing - Effective balance updates [Preset: mainnet] +OK: 230/230 Fail: 0/230 Skip: 0/230 +## Official - Altair - Epoch Processing - Effective balance updates [Preset: mainnet] ```diff + Effective balance updates - effective_balance_hysteresis [Preset: mainnet] OK ``` OK: 1/1 Fail: 0/1 Skip: 0/1 -## Official - Epoch Processing - Eth1 data reset [Preset: mainnet] +## Official - Altair - Epoch Processing - Eth1 data reset [Preset: mainnet] ```diff + Eth1 data reset - eth1_vote_no_reset [Preset: mainnet] OK + Eth1 data reset - eth1_vote_reset [Preset: mainnet] OK ``` OK: 2/2 Fail: 0/2 Skip: 0/2 -## Official - Epoch Processing - Historical roots update [Preset: mainnet] +## Official - Altair - Epoch Processing - Historical roots update [Preset: mainnet] ```diff + Historical roots update - historical_root_accumulator [Preset: mainnet] OK ``` OK: 1/1 Fail: 0/1 Skip: 0/1 -## Official - Epoch Processing - RANDAO mixes reset [Preset: mainnet] +## Official - Altair - Epoch Processing - RANDAO mixes reset [Preset: mainnet] ```diff + RANDAO mixes reset - updated_randao_mixes [Preset: mainnet] OK ``` OK: 1/1 Fail: 0/1 Skip: 0/1 -## Official - Epoch Processing - Registry updates [Preset: mainnet] +## Official - Altair - Epoch Processing - Registry updates [Preset: mainnet] ```diff + Registry updates - activation_queue_activation_and_ejection [Preset: mainnet] OK + Registry updates - activation_queue_efficiency [Preset: mainnet] OK @@ -229,11 +267,146 @@ OK: 1/1 Fail: 0/1 Skip: 0/1 + Registry updates - ejection_past_churn_limit [Preset: mainnet] OK ``` OK: 8/8 Fail: 0/8 Skip: 0/8 -## Official - Epoch Processing - Slashings reset [Preset: mainnet] +## Official - Altair - Epoch Processing - Slashings reset [Preset: mainnet] ```diff + Slashings reset - flush_slashings [Preset: mainnet] OK ``` OK: 1/1 Fail: 0/1 Skip: 0/1 +## Official - Altair - SSZ consensus objects [Preset: mainnet] +```diff ++ Testing AggregateAndProof OK ++ Testing Attestation OK ++ Testing AttestationData OK ++ Testing AttesterSlashing OK ++ Testing BeaconBlock OK ++ Testing BeaconBlockBody OK ++ Testing BeaconBlockHeader OK ++ Testing BeaconState OK ++ Testing Checkpoint OK ++ Testing ContributionAndProof OK ++ Testing Deposit OK ++ Testing DepositData OK ++ Testing DepositMessage OK ++ Testing Eth1Block OK ++ Testing Eth1Data OK ++ Testing Fork OK ++ Testing ForkData OK ++ Testing HistoricalBatch OK ++ Testing IndexedAttestation OK ++ Testing LightClientSnapshot OK ++ Testing LightClientUpdate OK ++ Testing PendingAttestation OK ++ Testing ProposerSlashing OK ++ Testing SignedAggregateAndProof OK ++ Testing SignedBeaconBlock OK ++ Testing SignedBeaconBlockHeader OK ++ Testing SignedContributionAndProof OK ++ Testing SignedVoluntaryExit OK ++ Testing SigningData OK ++ Testing SyncAggregate OK ++ Testing SyncAggregatorSelectionData OK ++ Testing SyncCommittee OK ++ Testing SyncCommitteeContribution OK ++ Testing SyncCommitteeSignature OK ++ Testing Validator OK ++ Testing VoluntaryExit OK +``` +OK: 36/36 Fail: 0/36 Skip: 0/36 +## Official - Phase 0 - Epoch Processing - Effective balance updates [Preset: mainnet] +```diff ++ Effective balance updates - effective_balance_hysteresis [Preset: mainnet] OK +``` +OK: 1/1 Fail: 0/1 Skip: 0/1 +## Official - Phase 0 - Epoch Processing - Eth1 data reset [Preset: mainnet] +```diff ++ Eth1 data reset - eth1_vote_no_reset [Preset: mainnet] OK ++ Eth1 data reset - eth1_vote_reset [Preset: mainnet] OK +``` +OK: 2/2 Fail: 0/2 Skip: 0/2 +## Official - Phase 0 - Epoch Processing - Historical roots update [Preset: mainnet] +```diff ++ Historical roots update - historical_root_accumulator [Preset: mainnet] OK +``` +OK: 1/1 Fail: 0/1 Skip: 0/1 +## Official - Phase 0 - Epoch Processing - Justification & Finalization [Preset: mainnet] +```diff ++ Justification & Finalization - 123_ok_support [Preset: mainnet] OK ++ Justification & Finalization - 123_poor_support [Preset: mainnet] OK ++ Justification & Finalization - 12_ok_support [Preset: mainnet] OK ++ Justification & Finalization - 12_ok_support_messed_target [Preset: mainnet] OK ++ Justification & Finalization - 12_poor_support [Preset: mainnet] OK ++ Justification & Finalization - 234_ok_support [Preset: mainnet] OK ++ Justification & Finalization - 234_poor_support [Preset: mainnet] OK ++ Justification & Finalization - 23_ok_support [Preset: mainnet] OK ++ Justification & Finalization - 23_poor_support [Preset: mainnet] OK +``` +OK: 9/9 Fail: 0/9 Skip: 0/9 +## Official - Phase 0 - Epoch Processing - Participation record updates [Preset: mainnet] +```diff ++ Participation record updates - updated_participation_record [Preset: mainnet] OK +``` +OK: 1/1 Fail: 0/1 Skip: 0/1 +## Official - Phase 0 - Epoch Processing - RANDAO mixes reset [Preset: mainnet] +```diff ++ RANDAO mixes reset - updated_randao_mixes [Preset: mainnet] OK +``` +OK: 1/1 Fail: 0/1 Skip: 0/1 +## Official - Phase 0 - Epoch Processing - Registry updates [Preset: mainnet] +```diff ++ Registry updates - activation_queue_activation_and_ejection [Preset: mainnet] OK ++ Registry updates - activation_queue_efficiency [Preset: mainnet] OK ++ Registry updates - activation_queue_no_activation_no_finality [Preset: mainnet] OK ++ Registry updates - activation_queue_sorting [Preset: mainnet] OK ++ Registry updates - activation_queue_to_activated_if_finalized [Preset: mainnet] OK ++ Registry updates - add_to_activation_queue [Preset: mainnet] OK ++ Registry updates - ejection [Preset: mainnet] OK ++ Registry updates - ejection_past_churn_limit [Preset: mainnet] OK +``` +OK: 8/8 Fail: 0/8 Skip: 0/8 +## Official - Phase 0 - Epoch Processing - Slashings [Preset: mainnet] +```diff ++ Slashings - low_penalty [Preset: mainnet] OK ++ Slashings - max_penalties [Preset: mainnet] OK ++ Slashings - minimal_penalty [Preset: mainnet] OK ++ Slashings - scaled_penalties [Preset: mainnet] OK +``` +OK: 4/4 Fail: 0/4 Skip: 0/4 +## Official - Phase 0 - Epoch Processing - Slashings reset [Preset: mainnet] +```diff ++ Slashings reset - flush_slashings [Preset: mainnet] OK +``` +OK: 1/1 Fail: 0/1 Skip: 0/1 +## Official - Phase 0 - SSZ consensus objects [Preset: mainnet] +```diff ++ Testing AggregateAndProof OK ++ Testing Attestation OK ++ Testing AttestationData OK ++ Testing AttesterSlashing OK ++ Testing BeaconBlock OK ++ Testing BeaconBlockBody OK ++ Testing BeaconBlockHeader OK ++ Testing BeaconState OK ++ Testing Checkpoint OK ++ Testing Deposit OK ++ Testing DepositData OK ++ Testing DepositMessage OK ++ Testing Eth1Block OK ++ Testing Eth1Data OK ++ Testing Fork OK ++ Testing ForkData OK ++ Testing HistoricalBatch OK ++ Testing IndexedAttestation OK ++ Testing PendingAttestation OK ++ Testing ProposerSlashing OK ++ Testing SignedAggregateAndProof OK ++ Testing SignedBeaconBlock OK ++ Testing SignedBeaconBlockHeader OK ++ Testing SignedVoluntaryExit OK ++ Testing SigningData OK ++ Testing Validator OK ++ Testing VoluntaryExit OK +``` +OK: 27/27 Fail: 0/27 Skip: 0/27 ---TOTAL--- -OK: 206/206 Fail: 0/206 Skip: 0/206 +OK: 335/335 Fail: 0/335 Skip: 0/335 diff --git a/FixtureSSZConsensus-mainnet.md b/FixtureSSZConsensus-mainnet.md index e7c7906d3..6510e603c 100644 --- a/FixtureSSZConsensus-mainnet.md +++ b/FixtureSSZConsensus-mainnet.md @@ -1,6 +1,201 @@ FixtureSSZConsensus-mainnet === -## Official - SSZ consensus objects [Preset: mainnet] +## +```diff ++ Rewards - all_balances_too_low_for_reward [Preset: mainnet] OK ++ Rewards - duplicate_attestations_at_later_slots [Preset: mainnet] OK ++ Rewards - empty [Preset: mainnet] OK ++ Rewards - empty_leak [Preset: mainnet] OK ++ Rewards - full_all_correct [Preset: mainnet] OK ++ Rewards - full_but_partial_participation [Preset: mainnet] OK ++ Rewards - full_but_partial_participation_leak [Preset: mainnet] OK ++ Rewards - full_correct_target_incorrect_head [Preset: mainnet] OK ++ Rewards - full_correct_target_incorrect_head_leak [Preset: mainnet] OK ++ Rewards - full_delay_max_slots [Preset: mainnet] OK ++ Rewards - full_delay_one_slot [Preset: mainnet] OK ++ Rewards - full_half_correct_target_incorrect_head [Preset: mainnet] OK ++ Rewards - full_half_correct_target_incorrect_head_leak [Preset: mainnet] OK ++ Rewards - full_half_incorrect_target_correct_head [Preset: mainnet] OK ++ Rewards - full_half_incorrect_target_correct_head_leak [Preset: mainnet] OK ++ Rewards - full_half_incorrect_target_incorrect_head [Preset: mainnet] OK ++ Rewards - full_half_incorrect_target_incorrect_head_leak [Preset: mainnet] OK ++ Rewards - full_leak [Preset: mainnet] OK ++ Rewards - full_mixed_delay [Preset: mainnet] OK ++ Rewards - full_random_0 [Preset: mainnet] OK ++ Rewards - full_random_1 [Preset: mainnet] OK ++ Rewards - full_random_2 [Preset: mainnet] OK ++ Rewards - full_random_3 [Preset: mainnet] OK ++ Rewards - full_random_five_epoch_leak [Preset: mainnet] OK ++ Rewards - full_random_leak [Preset: mainnet] OK ++ Rewards - full_random_low_balances_0 [Preset: mainnet] OK ++ Rewards - full_random_low_balances_1 [Preset: mainnet] OK ++ Rewards - full_random_misc_balances [Preset: mainnet] OK ++ Rewards - full_random_ten_epoch_leak [Preset: mainnet] OK ++ Rewards - half_full [Preset: mainnet] OK ++ Rewards - half_full_leak [Preset: mainnet] OK ++ Rewards - one_attestation_one_correct [Preset: mainnet] OK ++ Rewards - one_attestation_one_correct_leak [Preset: mainnet] OK ++ Rewards - proposer_not_in_attestations [Preset: mainnet] OK ++ Rewards - quarter_full [Preset: mainnet] OK ++ Rewards - quarter_full_leak [Preset: mainnet] OK ++ Rewards - some_very_low_effective_balances_that_attested [Preset: mainnet] OK ++ Rewards - some_very_low_effective_balances_that_attested_leak [Preset: mainnet] OK ++ Rewards - some_very_low_effective_balances_that_did_not_attest [Preset: mainnet] OK ++ Rewards - some_very_low_effective_balances_that_did_not_attest_leak [Preset: mainnet] OK ++ Rewards - with_exited_validators [Preset: mainnet] OK ++ Rewards - with_exited_validators_leak [Preset: mainnet] OK ++ Rewards - with_not_yet_activated_validators [Preset: mainnet] OK ++ Rewards - with_not_yet_activated_validators_leak [Preset: mainnet] OK ++ Rewards - with_slashed_validators [Preset: mainnet] OK ++ Rewards - with_slashed_validators_leak [Preset: mainnet] OK ++ Slots - double_empty_epoch OK ++ Slots - empty_epoch OK ++ Slots - over_epoch_boundary OK ++ Slots - slots_1 OK ++ Slots - slots_2 OK ++ [Invalid] bad_merkle_proof OK ++ [Invalid] wrong_deposit_for_deposit_count OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - double_same_proposer_slashings_same_block OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - double_similar_proposer_slashings_same_bl OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - double_validator_exit_same_block [Preset: OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - duplicate_attester_slashing [Preset: main OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - expected_deposit_in_block [Preset: mainne OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - invalid_block_sig [Preset: mainnet] OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - invalid_proposer_index_sig_from_expected_ OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - invalid_proposer_index_sig_from_proposer_ OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - invalid_state_root [Preset: mainnet] OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - parent_from_same_slot [Preset: mainnet] OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - prev_slot_block_transition [Preset: mainn OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - proposal_for_genesis_slot [Preset: mainne OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - same_slot_block_transition [Preset: mainn OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - slash_and_exit_same_index [Preset: mainne OK ++ [Invalid] Official - Phase 0 - Sanity - Blocks - zero_block_sig [Preset: mainnet] OK ++ [Invalid] after_epoch_slots OK ++ [Invalid] all_empty_indices OK ++ [Invalid] att1_bad_extra_index OK ++ [Invalid] att1_bad_replaced_index OK ++ [Invalid] att1_duplicate_index_double_signed OK ++ [Invalid] att1_duplicate_index_normal_signed OK ++ [Invalid] att1_empty_indices OK ++ [Invalid] att1_high_index OK ++ [Invalid] att2_bad_extra_index OK ++ [Invalid] att2_bad_replaced_index OK ++ [Invalid] att2_duplicate_index_double_signed OK ++ [Invalid] att2_duplicate_index_normal_signed OK ++ [Invalid] att2_empty_indices OK ++ [Invalid] att2_high_index OK ++ [Invalid] bad_source_root OK ++ [Invalid] before_inclusion_delay OK ++ [Invalid] correct_after_epoch_delay OK ++ [Invalid] empty_participants_seemingly_valid_sig OK ++ [Invalid] empty_participants_zeroes_sig OK ++ [Invalid] epochs_are_different OK ++ [Invalid] future_target_epoch OK ++ [Invalid] headers_are_same_sigs_are_different OK ++ [Invalid] headers_are_same_sigs_are_same OK ++ [Invalid] incorrect_head_after_epoch_delay OK ++ [Invalid] incorrect_head_and_target_after_epoch_delay OK ++ [Invalid] incorrect_target_after_epoch_delay OK ++ [Invalid] invalid_attestation_signature OK ++ [Invalid] invalid_current_source_root OK ++ [Invalid] invalid_different_proposer_indices OK ++ [Invalid] invalid_index OK ++ [Invalid] invalid_multiple_blocks_single_slot OK ++ [Invalid] invalid_parent_root OK ++ [Invalid] invalid_proposer_index OK ++ [Invalid] invalid_sig_1 OK ++ [Invalid] invalid_sig_1_and_2 OK ++ [Invalid] invalid_sig_1_and_2_swap OK ++ [Invalid] invalid_sig_2 OK ++ [Invalid] invalid_signature OK ++ [Invalid] invalid_slot_block_header OK ++ [Invalid] mismatched_target_and_slot OK ++ [Invalid] new_source_epoch OK ++ [Invalid] no_double_or_surround OK ++ [Invalid] old_source_epoch OK ++ [Invalid] old_target_epoch OK ++ [Invalid] participants_already_slashed OK ++ [Invalid] proposer_is_not_activated OK ++ [Invalid] proposer_is_slashed OK ++ [Invalid] proposer_is_withdrawn OK ++ [Invalid] proposer_slashed OK ++ [Invalid] same_data OK ++ [Invalid] source_root_is_target_root OK ++ [Invalid] too_few_aggregation_bits OK ++ [Invalid] too_many_aggregation_bits OK ++ [Invalid] unsorted_att_1 OK ++ [Invalid] unsorted_att_2 OK ++ [Invalid] validator_already_exited OK ++ [Invalid] validator_exit_in_future OK ++ [Invalid] validator_invalid_validator_index OK ++ [Invalid] validator_not_active OK ++ [Invalid] validator_not_active_long_enough OK ++ [Invalid] wrong_index_for_committee_signature OK ++ [Invalid] wrong_index_for_slot_0 OK ++ [Invalid] wrong_index_for_slot_1 OK ++ [Valid] invalid_sig_new_deposit OK ++ [Valid] invalid_sig_other_version OK ++ [Valid] invalid_sig_top_up OK ++ [Valid] invalid_withdrawal_credentials_top_up OK ++ [Valid] new_deposit_eth1_withdrawal_credentials OK ++ [Valid] new_deposit_max OK ++ [Valid] new_deposit_non_versioned_withdrawal_credentials OK ++ [Valid] new_deposit_over_max OK ++ [Valid] new_deposit_under_max OK ++ [Valid] success_top_up OK ++ [Valid] valid_sig_but_forked_state OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - attestation [Preset: mainnet] OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - attester_slashing [Preset: mainnet] OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - balance_driven_status_transitions [Preset OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - deposit_in_block [Preset: mainnet] OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - deposit_top_up [Preset: mainnet] OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - empty_block_transition [Preset: mainnet] OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - empty_epoch_transition [Preset: mainnet] OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - full_random_operations_0 [Preset: mainnet OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - full_random_operations_1 [Preset: mainnet OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - full_random_operations_2 [Preset: mainnet OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - full_random_operations_3 [Preset: mainnet OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - high_proposer_index [Preset: mainnet] OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - historical_batch [Preset: mainnet] OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - multiple_attester_slashings_no_overlap [P OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - multiple_attester_slashings_partial_overl OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - multiple_different_proposer_slashings_sam OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - multiple_different_validator_exits_same_b OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - proposer_after_inactive_index [Preset: ma OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - proposer_self_slashing [Preset: mainnet] OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - proposer_slashing [Preset: mainnet] OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - skipped_slots [Preset: mainnet] OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - slash_and_exit_diff_index [Preset: mainne OK ++ [Valid] Official - Phase 0 - Sanity - Blocks - voluntary_exit [Preset: mainnet] OK ++ [Valid] correct_epoch_delay OK ++ [Valid] correct_min_inclusion_delay OK ++ [Valid] correct_sqrt_epoch_delay OK ++ [Valid] default_exit_epoch_subsequent_exit OK ++ [Valid] incorrect_head_and_target_epoch_delay OK ++ [Valid] incorrect_head_and_target_min_inclusion_delay OK ++ [Valid] incorrect_head_and_target_sqrt_epoch_delay OK ++ [Valid] incorrect_head_epoch_delay OK ++ [Valid] incorrect_head_min_inclusion_delay OK ++ [Valid] incorrect_head_sqrt_epoch_delay OK ++ [Valid] incorrect_target_epoch_delay OK ++ [Valid] incorrect_target_min_inclusion_delay OK ++ [Valid] incorrect_target_sqrt_epoch_delay OK ++ [Valid] success OK ++ [Valid] success_already_exited_long_ago OK ++ [Valid] success_already_exited_recent OK ++ [Valid] success_block_header OK ++ [Valid] success_double OK ++ [Valid] success_exit_queue OK ++ [Valid] success_low_balances OK ++ [Valid] success_misc_balances OK ++ [Valid] success_multi_proposer_index_iterations OK ++ [Valid] success_previous_epoch OK ++ [Valid] success_slashed_and_proposer_index_the_same OK ++ [Valid] success_surround OK ++ [Valid] success_with_effective_balance_disparity OK +``` +OK: 191/191 Fail: 0/191 Skip: 0/191 +## Official - Altair - SSZ consensus objects [Preset: mainnet] ```diff + Testing AggregateAndProof OK + Testing Attestation OK @@ -40,6 +235,101 @@ FixtureSSZConsensus-mainnet + Testing VoluntaryExit OK ``` OK: 36/36 Fail: 0/36 Skip: 0/36 +## Official - Phase 0 - Epoch Processing - Effective balance updates [Preset: mainnet] +```diff ++ Effective balance updates - effective_balance_hysteresis [Preset: mainnet] OK +``` +OK: 1/1 Fail: 0/1 Skip: 0/1 +## Official - Phase 0 - Epoch Processing - Eth1 data reset [Preset: mainnet] +```diff ++ Eth1 data reset - eth1_vote_no_reset [Preset: mainnet] OK ++ Eth1 data reset - eth1_vote_reset [Preset: mainnet] OK +``` +OK: 2/2 Fail: 0/2 Skip: 0/2 +## Official - Phase 0 - Epoch Processing - Historical roots update [Preset: mainnet] +```diff ++ Historical roots update - historical_root_accumulator [Preset: mainnet] OK +``` +OK: 1/1 Fail: 0/1 Skip: 0/1 +## Official - Phase 0 - Epoch Processing - Justification & Finalization [Preset: mainnet] +```diff ++ Justification & Finalization - 123_ok_support [Preset: mainnet] OK ++ Justification & Finalization - 123_poor_support [Preset: mainnet] OK ++ Justification & Finalization - 12_ok_support [Preset: mainnet] OK ++ Justification & Finalization - 12_ok_support_messed_target [Preset: mainnet] OK ++ Justification & Finalization - 12_poor_support [Preset: mainnet] OK ++ Justification & Finalization - 234_ok_support [Preset: mainnet] OK ++ Justification & Finalization - 234_poor_support [Preset: mainnet] OK ++ Justification & Finalization - 23_ok_support [Preset: mainnet] OK ++ Justification & Finalization - 23_poor_support [Preset: mainnet] OK +``` +OK: 9/9 Fail: 0/9 Skip: 0/9 +## Official - Phase 0 - Epoch Processing - Participation record updates [Preset: mainnet] +```diff ++ Participation record updates - updated_participation_record [Preset: mainnet] OK +``` +OK: 1/1 Fail: 0/1 Skip: 0/1 +## Official - Phase 0 - Epoch Processing - RANDAO mixes reset [Preset: mainnet] +```diff ++ RANDAO mixes reset - updated_randao_mixes [Preset: mainnet] OK +``` +OK: 1/1 Fail: 0/1 Skip: 0/1 +## Official - Phase 0 - Epoch Processing - Registry updates [Preset: mainnet] +```diff ++ Registry updates - activation_queue_activation_and_ejection [Preset: mainnet] OK ++ Registry updates - activation_queue_efficiency [Preset: mainnet] OK ++ Registry updates - activation_queue_no_activation_no_finality [Preset: mainnet] OK ++ Registry updates - activation_queue_sorting [Preset: mainnet] OK ++ Registry updates - activation_queue_to_activated_if_finalized [Preset: mainnet] OK ++ Registry updates - add_to_activation_queue [Preset: mainnet] OK ++ Registry updates - ejection [Preset: mainnet] OK ++ Registry updates - ejection_past_churn_limit [Preset: mainnet] OK +``` +OK: 8/8 Fail: 0/8 Skip: 0/8 +## Official - Phase 0 - Epoch Processing - Slashings [Preset: mainnet] +```diff ++ Slashings - low_penalty [Preset: mainnet] OK ++ Slashings - max_penalties [Preset: mainnet] OK ++ Slashings - minimal_penalty [Preset: mainnet] OK ++ Slashings - scaled_penalties [Preset: mainnet] OK +``` +OK: 4/4 Fail: 0/4 Skip: 0/4 +## Official - Phase 0 - Epoch Processing - Slashings reset [Preset: mainnet] +```diff ++ Slashings reset - flush_slashings [Preset: mainnet] OK +``` +OK: 1/1 Fail: 0/1 Skip: 0/1 +## Official - Phase 0 - SSZ consensus objects [Preset: mainnet] +```diff ++ Testing AggregateAndProof OK ++ Testing Attestation OK ++ Testing AttestationData OK ++ Testing AttesterSlashing OK ++ Testing BeaconBlock OK ++ Testing BeaconBlockBody OK ++ Testing BeaconBlockHeader OK ++ Testing BeaconState OK ++ Testing Checkpoint OK ++ Testing Deposit OK ++ Testing DepositData OK ++ Testing DepositMessage OK ++ Testing Eth1Block OK ++ Testing Eth1Data OK ++ Testing Fork OK ++ Testing ForkData OK ++ Testing HistoricalBatch OK ++ Testing IndexedAttestation OK ++ Testing PendingAttestation OK ++ Testing ProposerSlashing OK ++ Testing SignedAggregateAndProof OK ++ Testing SignedBeaconBlock OK ++ Testing SignedBeaconBlockHeader OK ++ Testing SignedVoluntaryExit OK ++ Testing SigningData OK ++ Testing Validator OK ++ Testing VoluntaryExit OK +``` +OK: 27/27 Fail: 0/27 Skip: 0/27 ---TOTAL--- -OK: 36/36 Fail: 0/36 Skip: 0/36 +OK: 282/282 Fail: 0/282 Skip: 0/282 diff --git a/Makefile b/Makefile index ce980b552..75922b631 100644 --- a/Makefile +++ b/Makefile @@ -151,7 +151,6 @@ XML_TEST_BINARIES := \ test_fixture_const_sanity_check_minimal \ test_fixture_const_sanity_check_mainnet \ test_fixture_ssz_generic_types \ - test_fixture_ssz_consensus_objects \ all_fixtures_require_ssz \ test_official_interchange_vectors \ all_tests \ @@ -191,15 +190,6 @@ test_fixture_ssz_generic_types: | build deps $(NIM_PARAMS) -d:chronicles_log_level=TRACE -d:chronicles_sinks="json[file]" && \ echo -e $(BUILD_END_MSG) "build/$@" -# Consensus object SSZ tests -test_fixture_ssz_consensus_objects: | build deps - + echo -e $(BUILD_MSG) "build/$@" && \ - MAKE="$(MAKE)" V="$(V)" $(ENV_SCRIPT) scripts/compile_nim_program.sh \ - $@ \ - "tests/official/$@.nim" \ - $(NIM_PARAMS) -d:chronicles_log_level=TRACE -d:chronicles_sinks="json[file]" && \ - echo -e $(BUILD_END_MSG) "build/$@" - # EF tests all_fixtures_require_ssz: | build deps + echo -e $(BUILD_MSG) "build/$@" && \ diff --git a/tests/official/all_fixtures_require_ssz.nim b/tests/official/all_fixtures_require_ssz.nim index 648278493..8ee77cd6a 100644 --- a/tests/official/all_fixtures_require_ssz.nim +++ b/tests/official/all_fixtures_require_ssz.nim @@ -12,15 +12,7 @@ import ../testutil import - ./test_fixture_sanity_slots, - ./test_fixture_sanity_blocks, - ./test_fixture_operations_deposits, - ./test_fixture_state_transition_epoch, - ./test_fixture_operations_attestations, - ./test_fixture_operations_attester_slashings, - ./test_fixture_operations_block_header, - ./test_fixture_operations_proposer_slashings, - ./test_fixture_operations_sync_committee, - ./test_fixture_operations_voluntary_exit + ./phase0/all_phase0_fixtures_require_ssz, + ./altair/all_altair_fixtures_require_ssz summarizeLongTests("FixtureAll") diff --git a/tests/official/altair/all_altair_fixtures_require_ssz.nim b/tests/official/altair/all_altair_fixtures_require_ssz.nim new file mode 100644 index 000000000..a7d5fb5c0 --- /dev/null +++ b/tests/official/altair/all_altair_fixtures_require_ssz.nim @@ -0,0 +1,25 @@ +# beacon_chain +# Copyright (c) 2021 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. + +# All non-pure SSZ tests that require the -d:ssz_testing +# to ignore invalid BLS signature in EF test vectors +# https://github.com/status-im/nimbus-eth2/issues/374 + +{.used.} + +import + ./test_fixture_ssz_consensus_objects, + ./test_fixture_sanity_slots, + ./test_fixture_sanity_blocks, + ./test_fixture_operations_deposits, + ./test_fixture_state_transition_epoch, + ./test_fixture_operations_attestations, + ./test_fixture_operations_attester_slashings, + ./test_fixture_operations_block_header, + ./test_fixture_operations_proposer_slashings, + ./test_fixture_operations_sync_committee, + ./test_fixture_operations_voluntary_exit diff --git a/tests/official/test_fixture_operations_attestations.nim b/tests/official/altair/test_fixture_operations_attestations.nim similarity index 89% rename from tests/official/test_fixture_operations_attestations.nim rename to tests/official/altair/test_fixture_operations_attestations.nim index 33fa2155c..496952549 100644 --- a/tests/official/test_fixture_operations_attestations.nim +++ b/tests/official/altair/test_fixture_operations_attestations.nim @@ -14,13 +14,13 @@ import unittest2, stew/results, # Beacon chain internals - ../../beacon_chain/spec/beaconstate, - ../../beacon_chain/spec/datatypes/altair, - ../../beacon_chain/ssz, + ../../../beacon_chain/spec/beaconstate, + ../../../beacon_chain/spec/datatypes/altair, + ../../../beacon_chain/ssz, # Test utilities - ../testutil, - ./fixtures_utils, - ../helpers/debug_state + ../../testutil, + ../fixtures_utils, + ../../helpers/debug_state const OperationsAttestationsDir = SszTestsDir/const_preset/"altair"/"operations"/"attestation"/"pyspec_tests" @@ -61,6 +61,6 @@ proc runTest(identifier: string) = `testImpl _ operations_attestations _ identifier`() -suite "Official - Operations - Attestations " & preset(): +suite "Official - Altair - Operations - Attestations " & preset(): for kind, path in walkDir(OperationsAttestationsDir, true): runTest(path) diff --git a/tests/official/test_fixture_operations_attester_slashings.nim b/tests/official/altair/test_fixture_operations_attester_slashings.nim similarity index 89% rename from tests/official/test_fixture_operations_attester_slashings.nim rename to tests/official/altair/test_fixture_operations_attester_slashings.nim index b683c8174..dceed5fc9 100644 --- a/tests/official/test_fixture_operations_attester_slashings.nim +++ b/tests/official/altair/test_fixture_operations_attester_slashings.nim @@ -13,13 +13,13 @@ import # Utilities stew/results, # Beacon chain internals - ../../beacon_chain/spec/state_transition_block, - ../../beacon_chain/spec/datatypes/altair, - ../../beacon_chain/ssz, + ../../../beacon_chain/spec/state_transition_block, + ../../../beacon_chain/spec/datatypes/altair, + ../../../beacon_chain/ssz, # Test utilities - ../testutil, - ./fixtures_utils, - ../helpers/debug_state + ../../testutil, + ../fixtures_utils, + ../../helpers/debug_state const OpAttSlashingDir = SszTestsDir/const_preset/"altair"/"operations"/"attester_slashing"/"pyspec_tests" @@ -63,6 +63,6 @@ proc runTest(identifier: string) = `testImpl _ operations_attester_slashing _ identifier`() -suite "Official - Operations - Attester slashing " & preset(): +suite "Official - Altair - Operations - Attester slashing " & preset(): for kind, path in walkDir(OpAttSlashingDir, true): runTest(path) diff --git a/tests/official/test_fixture_operations_block_header.nim b/tests/official/altair/test_fixture_operations_block_header.nim similarity index 88% rename from tests/official/test_fixture_operations_block_header.nim rename to tests/official/altair/test_fixture_operations_block_header.nim index 4b38ddbad..3a982cf36 100644 --- a/tests/official/test_fixture_operations_block_header.nim +++ b/tests/official/altair/test_fixture_operations_block_header.nim @@ -13,13 +13,13 @@ import # Utilities stew/results, # Beacon chain internals - ../../beacon_chain/spec/[state_transition_block, crypto], - ../../beacon_chain/spec/datatypes/altair, - ../../beacon_chain/ssz, + ../../../beacon_chain/spec/[state_transition_block, crypto], + ../../../beacon_chain/spec/datatypes/altair, + ../../../beacon_chain/ssz, # Test utilities - ../testutil, - ./fixtures_utils, - ../helpers/debug_state + ../../testutil, + ../fixtures_utils, + ../../helpers/debug_state const OpBlockHeaderDir = SszTestsDir/const_preset/"altair"/"operations"/"block_header"/"pyspec_tests" @@ -60,6 +60,6 @@ proc runTest(identifier: string) = `testImpl _ blockheader _ identifier`() -suite "Official - Operations - Block header " & preset(): +suite "Official - Altair - Operations - Block header " & preset(): for kind, path in walkDir(OpBlockHeaderDir, true): runTest(path) diff --git a/tests/official/test_fixture_operations_deposits.nim b/tests/official/altair/test_fixture_operations_deposits.nim similarity index 87% rename from tests/official/test_fixture_operations_deposits.nim rename to tests/official/altair/test_fixture_operations_deposits.nim index 876005da0..5829bcf6f 100644 --- a/tests/official/test_fixture_operations_deposits.nim +++ b/tests/official/altair/test_fixture_operations_deposits.nim @@ -13,13 +13,13 @@ import # Utilities stew/results, # Beacon chain internals - ../../beacon_chain/spec/[beaconstate, presets], - ../../beacon_chain/spec/datatypes/altair, - ../../beacon_chain/ssz, + ../../../beacon_chain/spec/[beaconstate, presets], + ../../../beacon_chain/spec/datatypes/altair, + ../../../beacon_chain/ssz, # Test utilities - ../testutil, - ./fixtures_utils, - ../helpers/debug_state + ../../testutil, + ../fixtures_utils, + ../../helpers/debug_state const OperationsDepositsDir = SszTestsDir/const_preset/"altair"/"operations"/"deposit"/"pyspec_tests" @@ -54,6 +54,6 @@ proc runTest(identifier: string) = `testImpl _ operations_deposits _ identifier`() -suite "Official - Operations - Deposits " & preset(): +suite "Official - Altair - Operations - Deposits " & preset(): for kind, path in walkDir(OperationsDepositsDir, true): runTest(path) diff --git a/tests/official/test_fixture_operations_proposer_slashings.nim b/tests/official/altair/test_fixture_operations_proposer_slashings.nim similarity index 89% rename from tests/official/test_fixture_operations_proposer_slashings.nim rename to tests/official/altair/test_fixture_operations_proposer_slashings.nim index 776feb117..3591371cb 100644 --- a/tests/official/test_fixture_operations_proposer_slashings.nim +++ b/tests/official/altair/test_fixture_operations_proposer_slashings.nim @@ -13,13 +13,13 @@ import # Utilities stew/results, # Beacon chain internals - ../../beacon_chain/spec/state_transition_block, - ../../beacon_chain/spec/datatypes/altair, - ../../beacon_chain/ssz, + ../../../beacon_chain/spec/state_transition_block, + ../../../beacon_chain/spec/datatypes/altair, + ../../../beacon_chain/ssz, # Test utilities - ../testutil, - ./fixtures_utils, - ../helpers/debug_state + ../../testutil, + ../fixtures_utils, + ../../helpers/debug_state when isMainModule: import chronicles # or some random compile error happens... @@ -65,6 +65,6 @@ proc runTest(identifier: string) = `testImpl_proposer_slashing _ identifier`() -suite "Official - Operations - Proposer slashing " & preset(): +suite "Official - Altair - Operations - Proposer slashing " & preset(): for kind, path in walkDir(OpProposerSlashingDir, true): runTest(path) diff --git a/tests/official/test_fixture_operations_sync_committee.nim b/tests/official/altair/test_fixture_operations_sync_committee.nim similarity index 89% rename from tests/official/test_fixture_operations_sync_committee.nim rename to tests/official/altair/test_fixture_operations_sync_committee.nim index d16a31ec1..53ec9613e 100644 --- a/tests/official/test_fixture_operations_sync_committee.nim +++ b/tests/official/altair/test_fixture_operations_sync_committee.nim @@ -13,13 +13,13 @@ import # Utilities stew/results, # Beacon chain internals - ../../beacon_chain/spec/state_transition_block, - ../../beacon_chain/spec/datatypes/altair, - ../../beacon_chain/ssz, + ../../../beacon_chain/spec/state_transition_block, + ../../../beacon_chain/spec/datatypes/altair, + ../../../beacon_chain/ssz, # Test utilities - ../testutil, - ./fixtures_utils, - ../helpers/debug_state + ../../testutil, + ../fixtures_utils, + ../../helpers/debug_state when isMainModule: import chronicles # or some random compile error happens... @@ -65,6 +65,6 @@ proc runTest(identifier: string) = `testImpl_sync_committee _ identifier`() -suite "Official - Operations - Sync Committee " & preset(): +suite "Official - Altair - Operations - Sync Committee " & preset(): for kind, path in walkDir(OpSyncCommitteeDir, true): runTest(path) diff --git a/tests/official/test_fixture_operations_voluntary_exit.nim b/tests/official/altair/test_fixture_operations_voluntary_exit.nim similarity index 89% rename from tests/official/test_fixture_operations_voluntary_exit.nim rename to tests/official/altair/test_fixture_operations_voluntary_exit.nim index ef70bd0bf..7cd309e79 100644 --- a/tests/official/test_fixture_operations_voluntary_exit.nim +++ b/tests/official/altair/test_fixture_operations_voluntary_exit.nim @@ -13,13 +13,13 @@ import # Utilities stew/results, # Beacon chain internals - ../../beacon_chain/spec/state_transition_block, - ../../beacon_chain/spec/datatypes/altair, - ../../beacon_chain/ssz, + ../../../beacon_chain/spec/state_transition_block, + ../../../beacon_chain/spec/datatypes/altair, + ../../../beacon_chain/ssz, # Test utilities - ../testutil, - ./fixtures_utils, - ../helpers/debug_state + ../../testutil, + ../fixtures_utils, + ../../helpers/debug_state const OpVoluntaryExitDir = SszTestsDir/const_preset/"altair"/"operations"/"voluntary_exit"/"pyspec_tests" @@ -63,6 +63,6 @@ proc runTest(identifier: string) = `testImpl _ voluntary_exit _ identifier`() -suite "Official - Operations - Voluntary exit " & preset(): +suite "Official - Altair - Operations - Voluntary exit " & preset(): for kind, path in walkDir(OpVoluntaryExitDir, true): runTest(path) diff --git a/tests/official/test_fixture_sanity_blocks.nim b/tests/official/altair/test_fixture_sanity_blocks.nim similarity index 87% rename from tests/official/test_fixture_sanity_blocks.nim rename to tests/official/altair/test_fixture_sanity_blocks.nim index f575e873a..a985f86ce 100644 --- a/tests/official/test_fixture_sanity_blocks.nim +++ b/tests/official/altair/test_fixture_sanity_blocks.nim @@ -11,12 +11,12 @@ import # Standard library os, sequtils, chronicles, # Beacon chain internals - ../../beacon_chain/spec/[crypto, state_transition, presets], - ../../beacon_chain/spec/datatypes/altair, - ../../beacon_chain/ssz, + ../../../beacon_chain/spec/[crypto, state_transition, presets], + ../../../beacon_chain/spec/datatypes/altair, + ../../../beacon_chain/ssz, # Test utilities - ../testutil, - ./fixtures_utils + ../../testutil, + ../fixtures_utils const FinalityDir = SszTestsDir/const_preset/"altair"/"finality"/"finality"/"pyspec_tests" @@ -69,11 +69,11 @@ proc runTest(testName, testDir, unitTestName: string) = `testImpl _ blck _ testName`() -suite "Official - Sanity - Blocks " & preset(): +suite "Official - Altair - Sanity - Blocks " & preset(): for kind, path in walkDir(SanityBlocksDir, true): - runTest("Official - Sanity - Blocks", SanityBlocksDir, path) + runTest("Official - Altair - Sanity - Blocks", SanityBlocksDir, path) -suite "Official - Finality " & preset(): +suite "Official - Altair - Finality " & preset(): # these seem to only exist in minimal presets, both for phase0 and altair for kind, path in walkDir(FinalityDir, true): - runTest("Official - Finality", FinalityDir, path) + runTest("Official - Altair - Finality", FinalityDir, path) diff --git a/tests/official/test_fixture_sanity_slots.nim b/tests/official/altair/test_fixture_sanity_slots.nim similarity index 88% rename from tests/official/test_fixture_sanity_slots.nim rename to tests/official/altair/test_fixture_sanity_slots.nim index 0b832812f..1afc51fba 100644 --- a/tests/official/test_fixture_sanity_slots.nim +++ b/tests/official/altair/test_fixture_sanity_slots.nim @@ -12,12 +12,12 @@ import # Standard library os, strutils, # Beacon chain internals - ../../beacon_chain/spec/state_transition, - ../../beacon_chain/spec/datatypes/altair, + ../../../beacon_chain/spec/state_transition, + ../../../beacon_chain/spec/datatypes/altair, # Test utilities - ../testutil, - ./fixtures_utils, - ../helpers/debug_state + ../../testutil, + ../fixtures_utils, + ../../helpers/debug_state const SanitySlotsDir = SszTestsDir/const_preset/"altair"/"sanity"/"slots"/"pyspec_tests" @@ -46,6 +46,6 @@ proc runTest(identifier: string) = `testImpl _ slots _ identifier`() -suite "Official - Sanity - Slots " & preset(): +suite "Official - Altair - Sanity - Slots " & preset(): for kind, path in walkDir(SanitySlotsDir, true): runTest(path) diff --git a/tests/official/test_fixture_ssz_consensus_objects.nim b/tests/official/altair/test_fixture_ssz_consensus_objects.nim similarity index 98% rename from tests/official/test_fixture_ssz_consensus_objects.nim rename to tests/official/altair/test_fixture_ssz_consensus_objects.nim index 52fe63b9e..fec847827 100644 --- a/tests/official/test_fixture_ssz_consensus_objects.nim +++ b/tests/official/altair/test_fixture_ssz_consensus_objects.nim @@ -5,6 +5,8 @@ # * 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, streams, strformat, @@ -18,7 +20,7 @@ import # Status libraries snappy, # Test utilities - ../testutil, ./fixtures_utils + ../../testutil, ../fixtures_utils # SSZ tests of consensus objects (minimal/mainnet preset specific) @@ -85,7 +87,7 @@ proc loadExpectedHashTreeRoot(dir: string): SSZHashTreeRoot = # Test runner # ---------------------------------------------------------------- -suite "Official - SSZ consensus objects " & preset(): +suite "Official - Altair - SSZ consensus objects " & preset(): doAssert existsDir(SSZDir), "You need to run the \"download_test_vectors.sh\" script to retrieve the official test vectors." for pathKind, sszType in walkDir(SSZDir, relative = true): doAssert pathKind == pcDir diff --git a/tests/official/test_fixture_state_transition_epoch.nim b/tests/official/altair/test_fixture_state_transition_epoch.nim similarity index 92% rename from tests/official/test_fixture_state_transition_epoch.nim rename to tests/official/altair/test_fixture_state_transition_epoch.nim index 28492d440..01c9fd304 100644 --- a/tests/official/test_fixture_state_transition_epoch.nim +++ b/tests/official/altair/test_fixture_state_transition_epoch.nim @@ -11,19 +11,19 @@ import # Standard library os, strutils, # Beacon chain internals - ../../beacon_chain/spec/state_transition_epoch, - ../../beacon_chain/spec/datatypes/altair, + ../../../beacon_chain/spec/state_transition_epoch, + ../../../beacon_chain/spec/datatypes/altair, # Test utilities - ../testutil, - ./fixtures_utils, - ./test_fixture_rewards, - ../helpers/debug_state + ../../testutil, + ../fixtures_utils, + ../test_fixture_rewards, + ../../helpers/debug_state -from ../../beacon_chain/spec/beaconstate import process_registry_updates +from ../../../beacon_chain/spec/beaconstate import process_registry_updates # XXX: move to state_transition_epoch? template runSuite(suiteDir, testName: string, transitionProc: untyped{ident}, useCache: static bool): untyped = - suite "Official - Epoch Processing - " & testName & preset(): + suite "Official - Altair - Epoch Processing - " & testName & preset(): doAssert dirExists(suiteDir) for testDir in walkDirRec(suiteDir, yieldFilter = {pcDir}): diff --git a/tests/official/phase0/all_phase0_fixtures_require_ssz.nim b/tests/official/phase0/all_phase0_fixtures_require_ssz.nim new file mode 100644 index 000000000..7753999c6 --- /dev/null +++ b/tests/official/phase0/all_phase0_fixtures_require_ssz.nim @@ -0,0 +1,24 @@ +# beacon_chain +# Copyright (c) 2021 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. + +# All non-pure SSZ tests that require the -d:ssz_testing +# to ignore invalid BLS signature in EF test vectors +# https://github.com/status-im/nimbus-eth2/issues/374 + +{.used.} + +import + ./test_fixture_ssz_consensus_objects, + ./test_fixture_sanity_slots, + ./test_fixture_sanity_blocks, + ./test_fixture_operations_deposits, + ./test_fixture_state_transition_epoch, + ./test_fixture_operations_attestations, + ./test_fixture_operations_attester_slashings, + ./test_fixture_operations_block_header, + ./test_fixture_operations_proposer_slashings, + ./test_fixture_operations_voluntary_exit diff --git a/tests/official/phase0/test_fixture_operations_attestations.nim b/tests/official/phase0/test_fixture_operations_attestations.nim new file mode 100644 index 000000000..ddc1c66b5 --- /dev/null +++ b/tests/official/phase0/test_fixture_operations_attestations.nim @@ -0,0 +1,66 @@ +# beacon_chain +# Copyright (c) 2018-Present 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, + # Utilities + unittest2, + stew/results, + # Beacon chain internals + ../../../beacon_chain/spec/beaconstate, + ../../../beacon_chain/spec/datatypes/phase0, + ../../../beacon_chain/ssz, + # Test utilities + ../../testutil, + ../fixtures_utils, + ../../helpers/debug_state + +const OperationsAttestationsDir = SszTestsDir/const_preset/"phase0"/"operations"/"attestation"/"pyspec_tests" + +proc runTest(identifier: string) = + # We wrap the tests in a proc to avoid running out of globals + # in the future: Nim supports up to 3500 globals + # but unittest with the macro/templates put everything as globals + # https://github.com/nim-lang/Nim/issues/12084#issue-486866402 + + let testDir = OperationsAttestationsDir / identifier + + proc `testImpl _ operations_attestations _ identifier`() = + + var prefix: string + if existsFile(testDir/"post.ssz_snappy"): + prefix = "[Valid] " + else: + prefix = "[Invalid] " + + test prefix & identifier: + var cache = StateCache() + + let attestation = + parseTest(testDir/"attestation.ssz_snappy", SSZ, Attestation) + var preState = + newClone(parseTest(testDir/"pre.ssz_snappy", SSZ, BeaconState)) + + if existsFile(testDir/"post.ssz_snappy"): + let postState = + newClone(parseTest(testDir/"post.ssz_snappy", SSZ, BeaconState)) + let done = process_attestation(preState[], attestation, {}, cache).isOk + doAssert done, "Valid attestation not processed" + check: preState[].hash_tree_root() == postState[].hash_tree_root() + reportDiff(preState, postState) + else: + let done = process_attestation(preState[], attestation, {}, cache).isOk + doAssert done == false, "We didn't expect this invalid attestation to be processed." + + `testImpl _ operations_attestations _ identifier`() + +suite "Official - Phase 0 - Operations - Attestations " & preset(): + for kind, path in walkDir(OperationsAttestationsDir, true): + runTest(path) diff --git a/tests/official/phase0/test_fixture_operations_attester_slashings.nim b/tests/official/phase0/test_fixture_operations_attester_slashings.nim new file mode 100644 index 000000000..1f0efd0c1 --- /dev/null +++ b/tests/official/phase0/test_fixture_operations_attester_slashings.nim @@ -0,0 +1,68 @@ +# beacon_chain +# Copyright (c) 2018-Present 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, + # Utilities + stew/results, + # Beacon chain internals + ../../../beacon_chain/spec/state_transition_block, + ../../../beacon_chain/spec/datatypes/phase0, + ../../../beacon_chain/ssz, + # Test utilities + ../../testutil, + ../fixtures_utils, + ../../helpers/debug_state + +const OpAttSlashingDir = SszTestsDir/const_preset/"phase0"/"operations"/"attester_slashing"/"pyspec_tests" + +proc runTest(identifier: string) = + # We wrap the tests in a proc to avoid running out of globals + # in the future: Nim supports up to 3500 globals + # but unittest with the macro/templates put everything as globals + # https://github.com/nim-lang/Nim/issues/12084#issue-486866402 + + let testDir = OpAttSlashingDir / identifier + + proc `testImpl _ operations_attester_slashing _ identifier`() = + + var prefix: string + if existsFile(testDir/"post.ssz_snappy"): + prefix = "[Valid] " + else: + prefix = "[Invalid] " + + test prefix & identifier: + let attesterSlashing = + parseTest(testDir/"attester_slashing.ssz_snappy", SSZ, AttesterSlashing) + var + cache = StateCache() + preState = + newClone(parseTest(testDir/"pre.ssz_snappy", SSZ, BeaconState)) + + if existsFile(testDir/"post.ssz_snappy"): + let + postState = + newClone(parseTest(testDir/"post.ssz_snappy", SSZ, BeaconState)) + done = process_attester_slashing(preState[], attesterSlashing, + {}, cache).isOk + doAssert done, "Valid attestater slashing not processed" + check: preState[].hash_tree_root() == postState[].hash_tree_root() + reportDiff(preState, postState) + else: + let done = process_attester_slashing(preState[], attesterSlashing, + {}, cache).isOk + doAssert done == false, "We didn't expect this invalid attester slashing to be processed." + + `testImpl _ operations_attester_slashing _ identifier`() + +suite "Official - Phase 0 - Operations - Attester slashing " & preset(): + for kind, path in walkDir(OpAttSlashingDir, true): + runTest(path) diff --git a/tests/official/phase0/test_fixture_operations_block_header.nim b/tests/official/phase0/test_fixture_operations_block_header.nim new file mode 100644 index 000000000..7f7112eae --- /dev/null +++ b/tests/official/phase0/test_fixture_operations_block_header.nim @@ -0,0 +1,65 @@ +# beacon_chain +# Copyright (c) 2018-Present 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, + # Utilities + stew/results, + # Beacon chain internals + ../../../beacon_chain/spec/[state_transition_block, crypto], + ../../../beacon_chain/spec/datatypes/phase0, + ../../../beacon_chain/ssz, + # Test utilities + ../../testutil, + ../fixtures_utils, + ../../helpers/debug_state + +const OpBlockHeaderDir = SszTestsDir/const_preset/"phase0"/"operations"/"block_header"/"pyspec_tests" + +proc runTest(identifier: string) = + # We wrap the tests in a proc to avoid running out of globals + # in the future: Nim supports up to 3500 globals + # but unittest with the macro/templates put everything as globals + # https://github.com/nim-lang/Nim/issues/12084#issue-486866402 + + let testDir = OpBlockHeaderDir / identifier + + proc `testImpl _ blockheader _ identifier`() = + + var prefix: string + if existsFile(testDir/"post.ssz_snappy"): + prefix = "[Valid] " + else: + prefix = "[Invalid] " + + test prefix & identifier: + let blck = parseTest(testDir/"block.ssz_snappy", SSZ, BeaconBlock) + var + cache = StateCache() + preState = + newClone(parseTest(testDir/"pre.ssz_snappy", SSZ, BeaconState)) + + if existsFile(testDir/"post.ssz_snappy"): + let + postState = + newClone(parseTest(testDir/"post.ssz_snappy", SSZ, BeaconState)) + done = process_block_header(preState[], blck, {}, cache).isOk + doAssert done, "Valid block header not processed" + check: preState[].hash_tree_root() == postState[].hash_tree_root() + reportDiff(preState, postState) + else: + let done = process_block_header(preState[], blck, {}, cache).isOk + doAssert done == false, "We didn't expect this invalid block header to be processed." + + `testImpl _ blockheader _ identifier`() + +suite "Official - Phase 0 - Operations - Block header " & preset(): + for kind, path in walkDir(OpBlockHeaderDir, true): + runTest(path) diff --git a/tests/official/phase0/test_fixture_operations_deposits.nim b/tests/official/phase0/test_fixture_operations_deposits.nim new file mode 100644 index 000000000..9a001b7d7 --- /dev/null +++ b/tests/official/phase0/test_fixture_operations_deposits.nim @@ -0,0 +1,59 @@ +# beacon_chain +# Copyright (c) 2018-Present 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, + # Utilities + stew/results, + # Beacon chain internals + ../../../beacon_chain/spec/[beaconstate, presets], + ../../../beacon_chain/spec/datatypes/phase0, + ../../../beacon_chain/ssz, + # Test utilities + ../../testutil, + ../fixtures_utils, + ../../helpers/debug_state + +const OperationsDepositsDir = SszTestsDir/const_preset/"phase0"/"operations"/"deposit"/"pyspec_tests" + +proc runTest(identifier: string) = + # We wrap the tests in a proc to avoid running out of globals + # in the future: Nim supports up to 3500 globals + # but unittest with the macro/templates put everything as globals + # https://github.com/nim-lang/Nim/issues/12084#issue-486866402 + + let testDir = OperationsDepositsDir / identifier + + proc `testImpl _ operations_deposits _ identifier`() = + + var prefix: string + if existsFile(testDir/"post.ssz_snappy"): + prefix = "[Valid] " + else: + prefix = "[Invalid] " + + test prefix & " " & identifier: + let deposit = parseTest(testDir/"deposit.ssz_snappy", SSZ, Deposit) + var preState = + newClone(parseTest(testDir/"pre.ssz_snappy", SSZ, BeaconState)) + + if existsFile(testDir/"post.ssz_snappy"): + let postState = + newClone(parseTest(testDir/"post.ssz_snappy", SSZ, BeaconState)) + discard process_deposit(defaultRuntimePreset, preState[], deposit) + reportDiff(preState, postState) + else: + check process_deposit(defaultRuntimePreset, preState[], deposit).isErr + + `testImpl _ operations_deposits _ identifier`() + +suite "Official - Phase 0 - Operations - Deposits " & preset(): + for kind, path in walkDir(OperationsDepositsDir, true): + runTest(path) diff --git a/tests/official/phase0/test_fixture_operations_proposer_slashings.nim b/tests/official/phase0/test_fixture_operations_proposer_slashings.nim new file mode 100644 index 000000000..fd28377cf --- /dev/null +++ b/tests/official/phase0/test_fixture_operations_proposer_slashings.nim @@ -0,0 +1,70 @@ +# beacon_chain +# Copyright (c) 2018-Present 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, + # Utilities + stew/results, + # Beacon chain internals + ../../../beacon_chain/spec/state_transition_block, + ../../../beacon_chain/spec/datatypes/phase0, + ../../../beacon_chain/ssz, + # Test utilities + ../../testutil, + ../fixtures_utils, + ../../helpers/debug_state + +when isMainModule: + import chronicles # or some random compile error happens... + +const OpProposerSlashingDir = SszTestsDir/const_preset/"phase0"/"operations"/"proposer_slashing"/"pyspec_tests" + +proc runTest(identifier: string) = + # We wrap the tests in a proc to avoid running out of globals + # in the future: Nim supports up to 3500 globals + # but unittest with the macro/templates put everything as globals + # https://github.com/nim-lang/Nim/issues/12084#issue-486866402 + + let testDir = OpProposerSlashingDir / identifier + + proc `testImpl_proposer_slashing _ identifier`() = + + var prefix: string + if existsFile(testDir/"post.ssz_snappy"): + prefix = "[Valid] " + else: + prefix = "[Invalid] " + + test prefix & identifier: + let proposerSlashing = parseTest( + testDir/"proposer_slashing.ssz_snappy", SSZ, ProposerSlashing) + var + preState = + newClone(parseTest(testDir/"pre.ssz_snappy", SSZ, BeaconState)) + cache = StateCache() + + if existsFile(testDir/"post.ssz_snappy"): + let + postState = + newClone(parseTest(testDir/"post.ssz_snappy", SSZ, BeaconState)) + done = process_proposer_slashing( + preState[], proposerSlashing, {}, cache).isOk + doAssert done, "Valid proposer slashing not processed" + check: preState[].hash_tree_root() == postState[].hash_tree_root() + reportDiff(preState, postState) + else: + let done = process_proposer_slashing(preState[], proposerSlashing, {}, cache).isOk + doAssert done == false, "We didn't expect this invalid proposer slashing to be processed." + + `testImpl_proposer_slashing _ identifier`() + +suite "Official - Phase 0 - Operations - Proposer slashing " & preset(): + for kind, path in walkDir(OpProposerSlashingDir, true): + runTest(path) diff --git a/tests/official/phase0/test_fixture_operations_voluntary_exit.nim b/tests/official/phase0/test_fixture_operations_voluntary_exit.nim new file mode 100644 index 000000000..35e04d31d --- /dev/null +++ b/tests/official/phase0/test_fixture_operations_voluntary_exit.nim @@ -0,0 +1,68 @@ +# beacon_chain +# Copyright (c) 2018-Present 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, + # Utilities + stew/results, + # Beacon chain internals + ../../../beacon_chain/spec/state_transition_block, + ../../../beacon_chain/spec/datatypes/phase0, + ../../../beacon_chain/ssz, + # Test utilities + ../../testutil, + ../fixtures_utils, + ../../helpers/debug_state + +const OpVoluntaryExitDir = SszTestsDir/const_preset/"phase0"/"operations"/"voluntary_exit"/"pyspec_tests" + +proc runTest(identifier: string) = + # We wrap the tests in a proc to avoid running out of globals + # in the future: Nim supports up to 3500 globals + # but unittest with the macro/templates put everything as globals + # https://github.com/nim-lang/Nim/issues/12084#issue-486866402 + + let testDir = OpVoluntaryExitDir / identifier + + proc `testImpl _ voluntary_exit _ identifier`() = + + var prefix: string + if existsFile(testDir/"post.ssz_snappy"): + prefix = "[Valid] " + else: + prefix = "[Invalid] " + + test prefix & identifier: + let voluntaryExit = parseTest( + testDir/"voluntary_exit.ssz_snappy", SSZ, SignedVoluntaryExit) + var + preState = + newClone(parseTest(testDir/"pre.ssz_snappy", SSZ, BeaconState)) + cache = StateCache() + + if existsFile(testDir/"post.ssz_snappy"): + let + postState = + newClone(parseTest(testDir/"post.ssz_snappy", SSZ, BeaconState)) + done = + process_voluntary_exit(preState[], voluntaryExit, {}, cache).isOk + doAssert done, "Valid voluntary exit not processed" + check: preState[].hash_tree_root() == postState[].hash_tree_root() + reportDiff(preState, postState) + else: + let done = + process_voluntary_exit(preState[], voluntaryExit, {}, cache).isOk + doAssert done == false, "We didn't expect this invalid voluntary exit to be processed." + + `testImpl _ voluntary_exit _ identifier`() + +suite "Official - Phase 0 - Operations - Voluntary exit " & preset(): + for kind, path in walkDir(OpVoluntaryExitDir, true): + runTest(path) diff --git a/tests/official/phase0/test_fixture_sanity_blocks.nim b/tests/official/phase0/test_fixture_sanity_blocks.nim new file mode 100644 index 000000000..cb7827fe7 --- /dev/null +++ b/tests/official/phase0/test_fixture_sanity_blocks.nim @@ -0,0 +1,79 @@ +# beacon_chain +# Copyright (c) 2018-Present 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, sequtils, chronicles, + # Beacon chain internals + ../../../beacon_chain/spec/[crypto, state_transition, presets], + ../../../beacon_chain/spec/datatypes/phase0, + ../../../beacon_chain/ssz, + # Test utilities + ../../testutil, + ../fixtures_utils + +const + FinalityDir = SszTestsDir/const_preset/"phase0"/"finality"/"finality"/"pyspec_tests" + SanityBlocksDir = SszTestsDir/const_preset/"phase0"/"sanity"/"blocks"/"pyspec_tests" + +proc runTest(testName, testDir, unitTestName: string) = + # We wrap the tests in a proc to avoid running out of globals + # in the future: Nim supports up to 3500 globals + # but unittest with the macro/templates put everything as globals + # https://github.com/nim-lang/Nim/issues/12084#issue-486866402 + + let testPath = testDir / unitTestName + + proc `testImpl _ blck _ testName`() = + let + hasPostState = existsFile(testPath/"post.ssz_snappy") + prefix = if hasPostState: "[Valid] " else: "[Invalid] " + + test prefix & testName & " - " & unitTestName & preset(): + var + preState = newClone(parseTest(testPath/"pre.ssz_snappy", SSZ, BeaconState)) + hashedPreState = (ref HashedBeaconState)( + data: preState[], root: hash_tree_root(preState[])) + cache = StateCache() + rewards = RewardInfo() + + # 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: + let blck = parseTest(testPath/"blocks_" & $i & ".ssz_snappy", SSZ, SignedBeaconBlock) + + if hasPostState: + let success = state_transition( + defaultRuntimePreset, hashedPreState[], blck, cache, rewards, flags = {}, + noRollback) + doAssert success, "Failure when applying block " & $i + else: + let success = state_transition( + defaultRuntimePreset, hashedPreState[], blck, cache, rewards, flags = {}, + noRollback) + doAssert (i + 1 < numBlocks) or not success, + "We didn't expect these invalid blocks to be processed" + + if hasPostState: + let postState = newClone(parseTest(testPath/"post.ssz_snappy", SSZ, BeaconState)) + when false: + reportDiff(hashedPreState.data, postState) + doAssert hashedPreState.root == postState[].hash_tree_root() + + `testImpl _ blck _ testName`() + +suite "Official - Phase 0 - Sanity - Blocks " & preset(): + for kind, path in walkDir(SanityBlocksDir, true): + runTest("Official - Phase 0 - Sanity - Blocks", SanityBlocksDir, path) + +suite "Official - Phase 0 - Finality " & preset(): + # these seem to only exist in minimal presets, both for phase0 and altair + for kind, path in walkDir(FinalityDir, true): + runTest("Official - Phase 0 - Finality", FinalityDir, path) diff --git a/tests/official/phase0/test_fixture_sanity_slots.nim b/tests/official/phase0/test_fixture_sanity_slots.nim new file mode 100644 index 000000000..3f2484584 --- /dev/null +++ b/tests/official/phase0/test_fixture_sanity_slots.nim @@ -0,0 +1,51 @@ +# beacon_chain +# Copyright (c) 2018-Present 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 + chronicles, + # Standard library + os, strutils, + # Beacon chain internals + ../../../beacon_chain/spec/state_transition, + ../../../beacon_chain/spec/datatypes/phase0, + # Test utilities + ../../testutil, + ../fixtures_utils, + ../../helpers/debug_state + +const SanitySlotsDir = SszTestsDir/const_preset/"phase0"/"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, BeaconState)) + hashedPreState = (ref HashedBeaconState)( + data: preState[], root: hash_tree_root(preState[])) + cache = StateCache() + rewards: RewardInfo + let postState = newClone(parseTest(testDir/"post.ssz_snappy", SSZ, BeaconState)) + + check: + process_slots( + hashedPreState[], hashedPreState.data.slot + num_slots, cache, rewards) + + hashedPreState.root == postState[].hash_tree_root() + let newPreState = newClone(hashedPreState.data) + reportDiff(newPreState, postState) + + `testImpl _ slots _ identifier`() + +suite "Official - Phase 0 - Sanity - Slots " & preset(): + for kind, path in walkDir(SanitySlotsDir, true): + runTest(path) diff --git a/tests/official/phase0/test_fixture_ssz_consensus_objects.nim b/tests/official/phase0/test_fixture_ssz_consensus_objects.nim new file mode 100644 index 000000000..921a1ec9e --- /dev/null +++ b/tests/official/phase0/test_fixture_ssz_consensus_objects.nim @@ -0,0 +1,137 @@ +# beacon_chain +# Copyright (c) 2018-2021 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, streams, strformat, + macros, sets, + # Third-party + yaml, + # Beacon chain internals + ../../beacon_chain/spec/[crypto, digest], + ../../beacon_chain/spec/datatypes/phase0, + ../../beacon_chain/ssz, + # Status libraries + snappy, + # Test utilities + ../../testutil, ../fixtures_utils + +# SSZ tests of consensus objects (minimal/mainnet preset specific) + +# Parsing definitions +# ---------------------------------------------------------------- + +const + SSZDir = SszTestsDir/const_preset/"phase0"/"ssz_static" + +type + SSZHashTreeRoot = object + # The test files have the values at the "root" + # so we **must** use "root" as a field name + root: string + # Some have a signing_root field + signing_root {.defaultVal: "".}: string + + # https://github.com/ethereum/eth2.0-specs/blob/v1.0.1/specs/phase0/validator.md#eth1block + Eth1Block* = object + timestamp*: uint64 + deposit_root*: Eth2Digest + deposit_count*: uint64 + # All other eth1 block fields + +# Note this only tracks HashTreeRoot +# Checking the values against the yaml file is TODO (require more flexible Yaml parser) + +proc checkSSZ(T: type SignedBeaconBlock, dir: string, expectedHash: SSZHashTreeRoot) = + # Deserialize into a ref object to not fill Nim stack + let encoded = snappy.decode( + readFileBytes(dir/"serialized.ssz_snappy"), MaxObjectSize) + var deserialized = newClone(sszDecodeEntireInput(encoded, T)) + + # SignedBeaconBlocks usually not hashed because they're identified by + # htr(BeaconBlock), so do it manually + check: expectedHash.root == "0x" & toLowerASCII($hash_tree_root( + [hash_tree_root(deserialized.message), + hash_tree_root(deserialized.signature)])) + + check deserialized.root == hash_tree_root(deserialized.message) + check SSZ.encode(deserialized[]) == encoded + check sszSize(deserialized[]) == encoded.len + + # TODO check the value (requires YAML loader) + +proc checkSSZ(T: type, dir: string, expectedHash: SSZHashTreeRoot) = + # Deserialize into a ref object to not fill Nim stack + let encoded = snappy.decode( + readFileBytes(dir/"serialized.ssz_snappy"), MaxObjectSize) + var deserialized = newClone(sszDecodeEntireInput(encoded, T)) + + check: expectedHash.root == "0x" & toLowerASCII($hash_tree_root(deserialized[])) + + check SSZ.encode(deserialized[]) == encoded + check sszSize(deserialized[]) == encoded.len + + # TODO check the value (requires YAML loader) + +proc loadExpectedHashTreeRoot(dir: string): SSZHashTreeRoot = + var s = openFileStream(dir/"roots.yaml") + yaml.load(s, result) + s.close() + +# Test runner +# ---------------------------------------------------------------- + +suite "Official - Phase 0 - SSZ consensus objects " & preset(): + doAssert existsDir(SSZDir), "You need to run the \"download_test_vectors.sh\" script to retrieve the official test vectors." + for pathKind, sszType in walkDir(SSZDir, relative = true): + doAssert pathKind == pcDir + + test &" Testing {sszType}": + let path = SSZDir/sszType + for pathKind, sszTestKind in walkDir(path, relative = true): + doAssert pathKind == pcDir + let path = SSZDir/sszType/sszTestKind + for pathKind, sszTestCase in walkDir(path, relative = true): + let path = SSZDir/sszType/sszTestKind/sszTestCase + let hash = loadExpectedHashTreeRoot(path) + + case sszType: + of "AggregateAndProof": checkSSZ(AggregateAndProof, path, hash) + of "Attestation": checkSSZ(Attestation, path, hash) + of "AttestationData": checkSSZ(AttestationData, path, hash) + of "AttesterSlashing": checkSSZ(AttesterSlashing, path, hash) + of "BeaconBlock": checkSSZ(BeaconBlock, path, hash) + of "BeaconBlockBody": checkSSZ(BeaconBlockBody, path, hash) + of "BeaconBlockHeader": checkSSZ(BeaconBlockHeader, path, hash) + of "BeaconState": checkSSZ(BeaconState, path, hash) + of "Checkpoint": checkSSZ(Checkpoint, path, hash) + of "Deposit": checkSSZ(Deposit, path, hash) + of "DepositData": checkSSZ(DepositData, path, hash) + of "DepositMessage": checkSSZ(DepositMessage, path, hash) + of "Eth1Block": checkSSZ(Eth1Block, path, hash) + of "Eth1Data": checkSSZ(Eth1Data, path, hash) + of "Fork": checkSSZ(Fork, path, hash) + of "ForkData": checkSSZ(ForkData, path, hash) + of "HistoricalBatch": checkSSZ(HistoricalBatch, path, hash) + of "IndexedAttestation": checkSSZ(IndexedAttestation, path, hash) + of "PendingAttestation": checkSSZ(PendingAttestation, path, hash) + of "ProposerSlashing": checkSSZ(ProposerSlashing, path, hash) + of "SignedAggregateAndProof": + checkSSZ(SignedAggregateAndProof, path, hash) + of "SignedBeaconBlock": checkSSZ(SignedBeaconBlock, path, hash) + of "SignedBeaconBlockHeader": + checkSSZ(SignedBeaconBlockHeader, path, hash) + of "SignedVoluntaryExit": checkSSZ(SignedVoluntaryExit, path, hash) + of "SigningData": checkSSZ(SigningData, path, hash) + of "Validator": checkSSZ(Validator, path, hash) + of "VoluntaryExit": checkSSZ(VoluntaryExit, path, hash) + else: + raise newException(ValueError, "Unsupported test: " & sszType) + +summarizeLongTests("FixtureSSZConsensus") diff --git a/tests/official/phase0/test_fixture_state_transition_epoch.nim b/tests/official/phase0/test_fixture_state_transition_epoch.nim new file mode 100644 index 000000000..dab24f02c --- /dev/null +++ b/tests/official/phase0/test_fixture_state_transition_epoch.nim @@ -0,0 +1,86 @@ +# beacon_chain +# Copyright (c) 2018-Present 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/state_transition_epoch, + ../../../beacon_chain/spec/datatypes/phase0, + # Test utilities + ../../testutil, + ../fixtures_utils, + ../test_fixture_rewards, + ../../helpers/debug_state + +from ../../../beacon_chain/spec/beaconstate import process_registry_updates + # XXX: move to state_transition_epoch? + +template runSuite(suiteDir, testName: string, transitionProc: untyped{ident}, useCache: static bool): untyped = + suite "Official - Phase 0 - Epoch Processing - " & testName & preset(): + doAssert dirExists(suiteDir) + for testDir in walkDirRec(suiteDir, yieldFilter = {pcDir}): + + let unitTestName = testDir.rsplit(DirSep, 1)[1] + test testName & " - " & unitTestName & preset(): + # BeaconState objects are stored on the heap to avoid stack overflow + var preState = newClone(parseTest(testDir/"pre.ssz_snappy", SSZ, BeaconState)) + let postState = newClone(parseTest(testDir/"post.ssz_snappy", SSZ, BeaconState)) + + when useCache: + var cache = StateCache() + transitionProc(preState[], cache) + else: + transitionProc(preState[]) + + reportDiff(preState, postState) + +# Justification & Finalization +# --------------------------------------------------------------- + +const JustificationFinalizationDir = SszTestsDir/const_preset/"phase0"/"epoch_processing"/"justification_and_finalization"/"pyspec_tests" +runSuite(JustificationFinalizationDir, "Justification & Finalization", process_justification_and_finalization, useCache = false) + +# Rewards & Penalties +# --------------------------------------------------------------- + +# in test_fixture_rewards + +# Registry updates +# --------------------------------------------------------------- + +const RegistryUpdatesDir = SszTestsDir/const_preset/"phase0"/"epoch_processing"/"registry_updates"/"pyspec_tests" +runSuite(RegistryUpdatesDir, "Registry updates", process_registry_updates, useCache = true) + +# Slashings +# --------------------------------------------------------------- + +const SlashingsDir = SszTestsDir/const_preset/"phase0"/"epoch_processing"/"slashings"/"pyspec_tests" +runSuite(SlashingsDir, "Slashings", process_slashings, useCache = false) + +# Final updates +# --------------------------------------------------------------- + +const Eth1DataResetDir = SszTestsDir/const_preset/"phase0"/"epoch_processing"/"eth1_data_reset/"/"pyspec_tests" +runSuite(Eth1DataResetDir, "Eth1 data reset", process_eth1_data_reset, useCache = false) + +const EffectiveBalanceUpdatesDir = SszTestsDir/const_preset/"phase0"/"epoch_processing"/"effective_balance_updates"/"pyspec_tests" +runSuite(EffectiveBalanceUpdatesDir, "Effective balance updates", process_effective_balance_updates, useCache = false) + +const SlashingsResetDir = SszTestsDir/const_preset/"phase0"/"epoch_processing"/"slashings_reset"/"pyspec_tests" +runSuite(SlashingsResetDir, "Slashings reset", process_slashings_reset, useCache = false) + +const RandaoMixesResetDir = SszTestsDir/const_preset/"phase0"/"epoch_processing"/"randao_mixes_reset"/"pyspec_tests" +runSuite(RandaoMixesResetDir, "RANDAO mixes reset", process_randao_mixes_reset, useCache = false) + +const HistoricalRootsUpdateDir = SszTestsDir/const_preset/"phase0"/"epoch_processing"/"historical_roots_update"/"pyspec_tests" +runSuite(HistoricalRootsUpdateDir, "Historical roots update", process_historical_roots_update, useCache = false) + +const ParticipationRecordsDir = SszTestsDir/const_preset/"phase0"/"epoch_processing"/"participation_record_updates"/"pyspec_tests" +runSuite(ParticipationRecordsDir, "Participation record updates", process_participation_record_updates, useCache = false) diff --git a/tests/official/test_fixture_ssz_consensus_objects.nim.cfg b/tests/official/test_fixture_ssz_consensus_objects.nim.cfg deleted file mode 100644 index 81e51f08b..000000000 --- a/tests/official/test_fixture_ssz_consensus_objects.nim.cfg +++ /dev/null @@ -1 +0,0 @@ --d:ssz_testing