add Electra BLS to Execution Change, Block Heaer, Sync Aggregate, and Withdrawals operations test fixtures (#6226)

This commit is contained in:
tersec 2024-04-22 12:37:38 +00:00 committed by GitHub
parent 87452374e4
commit 67a22b3887
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 465 additions and 2 deletions

View File

@ -2396,6 +2396,118 @@ OK: 25/25 Fail: 0/25 Skip: 0/25
+ test_process_light_client_update_not_timeout OK
```
OK: 4/4 Fail: 0/4 Skip: 0/4
## EF - Electra - Operations - BLS to execution change [Preset: mainnet]
```diff
+ [Invalid] EF - Electra - Operations - BLS to execution change - invalid_already_0x01 OK
+ [Invalid] EF - Electra - Operations - BLS to execution change - invalid_bad_signature OK
+ [Invalid] EF - Electra - Operations - BLS to execution change - invalid_current_fork_versi OK
+ [Invalid] EF - Electra - Operations - BLS to execution change - invalid_genesis_validators OK
+ [Invalid] EF - Electra - Operations - BLS to execution change - invalid_incorrect_from_bls OK
+ [Invalid] EF - Electra - Operations - BLS to execution change - invalid_previous_fork_vers OK
+ [Invalid] EF - Electra - Operations - BLS to execution change - invalid_val_index_out_of_r OK
+ [Valid] EF - Electra - Operations - BLS to execution change - genesis_fork_version OK
+ [Valid] EF - Electra - Operations - BLS to execution change - success OK
+ [Valid] EF - Electra - Operations - BLS to execution change - success_exited OK
+ [Valid] EF - Electra - Operations - BLS to execution change - success_in_activation_queu OK
+ [Valid] EF - Electra - Operations - BLS to execution change - success_in_exit_queue OK
+ [Valid] EF - Electra - Operations - BLS to execution change - success_not_activated OK
+ [Valid] EF - Electra - Operations - BLS to execution change - success_withdrawable OK
```
OK: 14/14 Fail: 0/14 Skip: 0/14
## EF - Electra - Operations - Block Header [Preset: mainnet]
```diff
+ [Invalid] EF - Electra - Operations - Block Header - invalid_multiple_blocks_single_slot OK
+ [Invalid] EF - Electra - Operations - Block Header - invalid_parent_root OK
+ [Invalid] EF - Electra - Operations - Block Header - invalid_proposer_index OK
+ [Invalid] EF - Electra - Operations - Block Header - invalid_proposer_slashed OK
+ [Invalid] EF - Electra - Operations - Block Header - invalid_slot_block_header OK
+ [Valid] EF - Electra - Operations - Block Header - basic_block_header OK
```
OK: 6/6 Fail: 0/6 Skip: 0/6
## EF - Electra - Operations - Sync Aggregate [Preset: mainnet]
```diff
+ [Invalid] EF - Electra - Operations - Sync Aggregate - invalid_signature_bad_domain OK
+ [Invalid] EF - Electra - Operations - Sync Aggregate - invalid_signature_extra_participant OK
+ [Invalid] EF - Electra - Operations - Sync Aggregate - invalid_signature_infinite_signatur OK
+ [Invalid] EF - Electra - Operations - Sync Aggregate - invalid_signature_infinite_signatur OK
+ [Invalid] EF - Electra - Operations - Sync Aggregate - invalid_signature_missing_participa OK
+ [Invalid] EF - Electra - Operations - Sync Aggregate - invalid_signature_no_participants OK
+ [Invalid] EF - Electra - Operations - Sync Aggregate - invalid_signature_past_block OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - random_all_but_one_participating_wi OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - random_high_participation_with_dupl OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - random_low_participation_with_dupli OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - random_misc_balances_and_half_parti OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - random_only_one_participant_with_du OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - random_with_exits_with_duplicates OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - sync_committee_rewards_duplicate_co OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - sync_committee_rewards_duplicate_co OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - sync_committee_rewards_duplicate_co OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - sync_committee_rewards_duplicate_co OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - sync_committee_rewards_duplicate_co OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - sync_committee_rewards_duplicate_co OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - sync_committee_rewards_duplicate_co OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - sync_committee_rewards_empty_partic OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - sync_committee_rewards_not_full_par OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - sync_committee_with_nonparticipatin OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - sync_committee_with_nonparticipatin OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - sync_committee_with_participating_e OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - sync_committee_with_participating_w OK
```
OK: 26/26 Fail: 0/26 Skip: 0/26
## EF - Electra - Operations - Withdrawals [Preset: mainnet]
```diff
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_a_lot_fully_withdrawable_too_f OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_a_lot_mixed_withdrawable_in_qu OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_a_lot_partially_withdrawable_t OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_incorrect_address_full OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_incorrect_address_partial OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_incorrect_amount_full OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_incorrect_amount_partial OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_incorrect_withdrawal_index OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_many_incorrectly_full OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_many_incorrectly_partial OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_max_per_slot_full_withdrawals_ OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_max_per_slot_partial_withdrawa OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_non_withdrawable_non_empty_wit OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_one_expected_full_withdrawal_a OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_one_expected_full_withdrawal_a OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_one_expected_partial_withdrawa OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_one_of_many_incorrectly_full OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_one_of_many_incorrectly_partia OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_two_expected_partial_withdrawa OK
+ [Valid] EF - Electra - Operations - Withdrawals - all_withdrawal OK
+ [Valid] EF - Electra - Operations - Withdrawals - no_withdrawals_but_some_next_epoch OK
+ [Valid] EF - Electra - Operations - Withdrawals - random_0 OK
+ [Valid] EF - Electra - Operations - Withdrawals - random_full_withdrawals_0 OK
+ [Valid] EF - Electra - Operations - Withdrawals - random_full_withdrawals_1 OK
+ [Valid] EF - Electra - Operations - Withdrawals - random_full_withdrawals_2 OK
+ [Valid] EF - Electra - Operations - Withdrawals - random_full_withdrawals_3 OK
+ [Valid] EF - Electra - Operations - Withdrawals - random_partial_withdrawals_1 OK
+ [Valid] EF - Electra - Operations - Withdrawals - random_partial_withdrawals_2 OK
+ [Valid] EF - Electra - Operations - Withdrawals - random_partial_withdrawals_3 OK
+ [Valid] EF - Electra - Operations - Withdrawals - random_partial_withdrawals_4 OK
+ [Valid] EF - Electra - Operations - Withdrawals - random_partial_withdrawals_5 OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_all_fully_withdrawable_in_one_ OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_all_partially_withdrawable_in_ OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_excess_balance_but_no_max_effe OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_max_partial_withdrawable OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_mixed_fully_and_partial_withdr OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_no_excess_balance OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_no_max_effective_balance OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_one_full_withdrawal OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_one_partial_withdrawable_activ OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_one_partial_withdrawable_exite OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_one_partial_withdrawable_exite OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_one_partial_withdrawable_in_ex OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_one_partial_withdrawable_not_y OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_one_partial_withdrawal OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_two_partial_withdrawable OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_zero_expected_withdrawals OK
+ [Valid] EF - Electra - Operations - Withdrawals - withdrawable_epoch_but_0_balance OK
+ [Valid] EF - Electra - Operations - Withdrawals - withdrawable_epoch_but_0_effective_bal OK
+ [Valid] EF - Electra - Operations - Withdrawals - withdrawable_epoch_but_0_effective_bal OK
```
OK: 50/50 Fail: 0/50 Skip: 0/50
## EF - Electra - SSZ consensus objects [Preset: mainnet]
```diff
+ Testing AggregateAndProof OK
@ -2983,4 +3095,4 @@ OK: 69/88 Fail: 0/88 Skip: 19/88
OK: 3/3 Fail: 0/3 Skip: 0/3
---TOTAL---
OK: 2398/2417 Fail: 0/2417 Skip: 19/2417
OK: 2494/2513 Fail: 0/2513 Skip: 19/2513

View File

@ -2505,6 +2505,117 @@ OK: 30/30 Fail: 0/30 Skip: 0/30
+ test_process_light_client_update_not_timeout OK
```
OK: 4/4 Fail: 0/4 Skip: 0/4
## EF - Electra - Operations - BLS to execution change [Preset: minimal]
```diff
+ [Invalid] EF - Electra - Operations - BLS to execution change - invalid_already_0x01 OK
+ [Invalid] EF - Electra - Operations - BLS to execution change - invalid_bad_signature OK
+ [Invalid] EF - Electra - Operations - BLS to execution change - invalid_current_fork_versi OK
+ [Invalid] EF - Electra - Operations - BLS to execution change - invalid_genesis_validators OK
+ [Invalid] EF - Electra - Operations - BLS to execution change - invalid_incorrect_from_bls OK
+ [Invalid] EF - Electra - Operations - BLS to execution change - invalid_previous_fork_vers OK
+ [Invalid] EF - Electra - Operations - BLS to execution change - invalid_val_index_out_of_r OK
+ [Valid] EF - Electra - Operations - BLS to execution change - genesis_fork_version OK
+ [Valid] EF - Electra - Operations - BLS to execution change - success OK
+ [Valid] EF - Electra - Operations - BLS to execution change - success_exited OK
+ [Valid] EF - Electra - Operations - BLS to execution change - success_in_activation_queu OK
+ [Valid] EF - Electra - Operations - BLS to execution change - success_in_exit_queue OK
+ [Valid] EF - Electra - Operations - BLS to execution change - success_not_activated OK
+ [Valid] EF - Electra - Operations - BLS to execution change - success_withdrawable OK
```
OK: 14/14 Fail: 0/14 Skip: 0/14
## EF - Electra - Operations - Block Header [Preset: minimal]
```diff
+ [Invalid] EF - Electra - Operations - Block Header - invalid_multiple_blocks_single_slot OK
+ [Invalid] EF - Electra - Operations - Block Header - invalid_parent_root OK
+ [Invalid] EF - Electra - Operations - Block Header - invalid_proposer_index OK
+ [Invalid] EF - Electra - Operations - Block Header - invalid_proposer_slashed OK
+ [Invalid] EF - Electra - Operations - Block Header - invalid_slot_block_header OK
+ [Valid] EF - Electra - Operations - Block Header - basic_block_header OK
```
OK: 6/6 Fail: 0/6 Skip: 0/6
## EF - Electra - Operations - Sync Aggregate [Preset: minimal]
```diff
+ [Invalid] EF - Electra - Operations - Sync Aggregate - invalid_signature_bad_domain OK
+ [Invalid] EF - Electra - Operations - Sync Aggregate - invalid_signature_extra_participant OK
+ [Invalid] EF - Electra - Operations - Sync Aggregate - invalid_signature_infinite_signatur OK
+ [Invalid] EF - Electra - Operations - Sync Aggregate - invalid_signature_infinite_signatur OK
+ [Invalid] EF - Electra - Operations - Sync Aggregate - invalid_signature_missing_participa OK
+ [Invalid] EF - Electra - Operations - Sync Aggregate - invalid_signature_no_participants OK
+ [Invalid] EF - Electra - Operations - Sync Aggregate - invalid_signature_past_block OK
+ [Invalid] EF - Electra - Operations - Sync Aggregate - invalid_signature_previous_committe OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - proposer_in_committee_with_particip OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - proposer_in_committee_without_parti OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - random_all_but_one_participating_wi OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - random_high_participation_without_d OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - random_low_participation_without_du OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - random_misc_balances_and_half_parti OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - random_only_one_participant_without OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - random_with_exits_without_duplicate OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - sync_committee_rewards_empty_partic OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - sync_committee_rewards_nonduplicate OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - sync_committee_rewards_not_full_par OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - sync_committee_with_nonparticipatin OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - sync_committee_with_nonparticipatin OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - sync_committee_with_participating_e OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - sync_committee_with_participating_w OK
+ [Valid] EF - Electra - Operations - Sync Aggregate - valid_signature_future_committee OK
```
OK: 24/24 Fail: 0/24 Skip: 0/24
## EF - Electra - Operations - Withdrawals [Preset: minimal]
```diff
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_a_lot_fully_withdrawable_too_f OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_a_lot_mixed_withdrawable_in_qu OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_a_lot_partially_withdrawable_t OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_incorrect_address_full OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_incorrect_address_partial OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_incorrect_amount_full OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_incorrect_amount_partial OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_incorrect_withdrawal_index OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_many_incorrectly_full OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_many_incorrectly_partial OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_max_per_slot_full_withdrawals_ OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_max_per_slot_partial_withdrawa OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_non_withdrawable_non_empty_wit OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_one_expected_full_withdrawal_a OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_one_expected_full_withdrawal_a OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_one_expected_partial_withdrawa OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_one_of_many_incorrectly_full OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_one_of_many_incorrectly_partia OK
+ [Invalid] EF - Electra - Operations - Withdrawals - invalid_two_expected_partial_withdrawa OK
+ [Valid] EF - Electra - Operations - Withdrawals - all_withdrawal OK
+ [Valid] EF - Electra - Operations - Withdrawals - no_withdrawals_but_some_next_epoch OK
+ [Valid] EF - Electra - Operations - Withdrawals - random_0 OK
+ [Valid] EF - Electra - Operations - Withdrawals - random_full_withdrawals_0 OK
+ [Valid] EF - Electra - Operations - Withdrawals - random_full_withdrawals_1 OK
+ [Valid] EF - Electra - Operations - Withdrawals - random_full_withdrawals_2 OK
+ [Valid] EF - Electra - Operations - Withdrawals - random_full_withdrawals_3 OK
+ [Valid] EF - Electra - Operations - Withdrawals - random_partial_withdrawals_1 OK
+ [Valid] EF - Electra - Operations - Withdrawals - random_partial_withdrawals_2 OK
+ [Valid] EF - Electra - Operations - Withdrawals - random_partial_withdrawals_3 OK
+ [Valid] EF - Electra - Operations - Withdrawals - random_partial_withdrawals_4 OK
+ [Valid] EF - Electra - Operations - Withdrawals - random_partial_withdrawals_5 OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_all_fully_withdrawable OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_all_partially_withdrawable OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_excess_balance_but_no_max_effe OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_max_partial_withdrawable OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_max_plus_one_withdrawable OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_mixed_fully_and_partial_withdr OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_no_excess_balance OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_no_max_effective_balance OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_one_full_withdrawal OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_one_partial_withdrawable_activ OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_one_partial_withdrawable_exite OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_one_partial_withdrawable_exite OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_one_partial_withdrawable_in_ex OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_one_partial_withdrawable_not_y OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_one_partial_withdrawal OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_two_partial_withdrawable OK
+ [Valid] EF - Electra - Operations - Withdrawals - success_zero_expected_withdrawals OK
+ [Valid] EF - Electra - Operations - Withdrawals - withdrawable_epoch_but_0_balance OK
+ [Valid] EF - Electra - Operations - Withdrawals - withdrawable_epoch_but_0_effective_bal OK
+ [Valid] EF - Electra - Operations - Withdrawals - withdrawable_epoch_but_0_effective_bal OK
```
OK: 51/51 Fail: 0/51 Skip: 0/51
## EF - Electra - SSZ consensus objects [Preset: minimal]
```diff
+ Testing AggregateAndProof OK
@ -3253,4 +3364,4 @@ OK: 185/207 Fail: 0/207 Skip: 22/207
OK: 3/3 Fail: 0/3 Skip: 0/3
---TOTAL---
OK: 2641/2663 Fail: 0/2663 Skip: 22/2663
OK: 2736/2758 Fail: 0/2758 Skip: 22/2758

View File

@ -9,4 +9,5 @@
{.used.}
import
./test_fixture_operations,
./test_fixture_ssz_consensus_objects

View File

@ -0,0 +1,239 @@
# beacon_chain
# Copyright (c) 2024 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.
{.push raises: [].}
{.used.}
import
# Utilities
chronicles,
unittest2,
stew/results,
# Beacon chain internals
../../../beacon_chain/spec/state_transition_block,
../../../beacon_chain/spec/datatypes/electra,
# Test utilities
../../testutil,
../fixtures_utils, ../os_ops,
../../helpers/debug_state
from std/sequtils import mapIt, toSeq
#from std/strutils import contains
from ../../../beacon_chain/spec/beaconstate import
get_base_reward_per_increment, get_state_exit_queue_info,
get_total_active_balance, process_attestation
const
OpDir = SszTestsDir/const_preset/"electra"/"operations"
OpAttestationsDir = OpDir/"attestation"
OpAttSlashingDir = OpDir/"attester_slashing"
OpBlockHeaderDir = OpDir/"block_header"
OpBlsToExecutionChangeDir = OpDir/"bls_to_execution_change"
OpDepositsDir = OpDir/"deposit"
OpExecutionPayloadDir = OpDir/"execution_payload"
OpProposerSlashingDir = OpDir/"proposer_slashing"
OpSyncAggregateDir = OpDir/"sync_aggregate"
OpVoluntaryExitDir = OpDir/"voluntary_exit"
OpWithdrawalsDir = OpDir/"withdrawals"
baseDescription = "EF - Electra - Operations - "
debugRaiseAssert "electra test_fixture_operations re-enable all subdirectories sanity check"
doAssert true or toHashSet(mapIt(toSeq(walkDir(OpDir, relative = false)), it.path)) ==
toHashSet([
OpAttestationsDir, OpAttSlashingDir, OpBlockHeaderDir,
OpBlsToExecutionChangeDir, OpDepositsDir, OpExecutionPayloadDir,
OpProposerSlashingDir, OpSyncAggregateDir, OpVoluntaryExitDir,
OpWithdrawalsDir])
proc runTest[T, U](
testSuiteDir, suiteName, opName, applyFile: string,
applyProc: U, identifier: string) =
let testDir = testSuiteDir / "pyspec_tests" / identifier
let prefix =
if fileExists(testDir/"post.ssz_snappy"):
"[Valid] "
else:
"[Invalid] "
test prefix & baseDescription & opName & " - " & identifier:
let preState = newClone(
parseTest(testDir/"pre.ssz_snappy", SSZ, electra.BeaconState))
let done = applyProc(
preState[], parseTest(testDir/(applyFile & ".ssz_snappy"), SSZ, T))
if fileExists(testDir/"post.ssz_snappy"):
let postState =
newClone(parseTest(
testDir/"post.ssz_snappy", SSZ, electra.BeaconState))
reportDiff(preState, postState)
check:
done.isOk()
preState[].hash_tree_root() == postState[].hash_tree_root()
else:
check: done.isErr() # No post state = processing should fail
when false:
debugRaiseAssert "when these are fixed..."
suite baseDescription & "Attestation " & preset():
proc applyAttestation(
preState: var electra.BeaconState, attestation: Attestation):
Result[void, cstring] =
var cache: StateCache
let
total_active_balance = get_total_active_balance(preState, cache)
base_reward_per_increment =
get_base_reward_per_increment(total_active_balance)
# This returns the proposer reward for including the attestation, which
# isn't tested here.
discard ? process_attestation(
preState, attestation, {strictVerification}, base_reward_per_increment, cache)
ok()
for path in walkTests(OpAttestationsDir):
runTest[Attestation, typeof applyAttestation](
OpAttestationsDir, suiteName, "Attestation", "attestation",
applyAttestation, path)
when false:
suite baseDescription & "Attester Slashing " & preset():
proc applyAttesterSlashing(
preState: var electra.BeaconState, attesterSlashing: AttesterSlashing):
Result[void, cstring] =
var cache: StateCache
doAssert (? process_attester_slashing(
defaultRuntimeConfig, preState, attesterSlashing, {strictVerification},
get_state_exit_queue_info(preState), cache))[0] > 0.Gwei
ok()
for path in walkTests(OpAttSlashingDir):
runTest[AttesterSlashing, typeof applyAttesterSlashing](
OpAttSlashingDir, suiteName, "Attester Slashing", "attester_slashing",
applyAttesterSlashing, path)
suite baseDescription & "Block Header " & preset():
func applyBlockHeader(
preState: var electra.BeaconState, blck: electra.BeaconBlock):
Result[void, cstring] =
var cache: StateCache
process_block_header(preState, blck, {}, cache)
for path in walkTests(OpBlockHeaderDir):
runTest[electra.BeaconBlock, typeof applyBlockHeader](
OpBlockHeaderDir, suiteName, "Block Header", "block",
applyBlockHeader, path)
from ../../../beacon_chain/spec/datatypes/capella import
SignedBLSToExecutionChange
suite baseDescription & "BLS to execution change " & preset():
proc applyBlsToExecutionChange(
preState: var electra.BeaconState,
signed_address_change: SignedBLSToExecutionChange):
Result[void, cstring] =
process_bls_to_execution_change(
defaultRuntimeConfig, preState, signed_address_change)
for path in walkTests(OpBlsToExecutionChangeDir):
runTest[SignedBLSToExecutionChange, typeof applyBlsToExecutionChange](
OpBlsToExecutionChangeDir, suiteName, "BLS to execution change", "address_change",
applyBlsToExecutionChange, path)
when false:
from ".."/".."/".."/beacon_chain/bloomfilter import constructBloomFilter
suite baseDescription & "Deposit " & preset():
proc applyDeposit(
preState: var electra.BeaconState, deposit: Deposit):
Result[void, cstring] =
process_deposit(
defaultRuntimeConfig, preState,
constructBloomFilter(preState.validators.asSeq)[], deposit, {})
for path in walkTests(OpDepositsDir):
runTest[Deposit, typeof applyDeposit](
OpDepositsDir, suiteName, "Deposit", "deposit", applyDeposit, path)
suite baseDescription & "Execution Payload " & preset():
proc makeApplyExecutionPayloadCb(path: string): auto =
return proc(
preState: var electra.BeaconState, body: electra.BeaconBlockBody):
Result[void, cstring] {.raises: [IOError].} =
let payloadValid = os_ops.readFile(
OpExecutionPayloadDir/"pyspec_tests"/path/"execution.yaml"
).contains("execution_valid: true")
func executePayload(_: electra.ExecutionPayload): bool = payloadValid
process_execution_payload(preState, body, executePayload)
for path in walkTests(OpExecutionPayloadDir):
let applyExecutionPayload = makeApplyExecutionPayloadCb(path)
runTest[electra.BeaconBlockBody, typeof applyExecutionPayload](
OpExecutionPayloadDir, suiteName, "Execution Payload", "body",
applyExecutionPayload, path)
suite baseDescription & "Proposer Slashing " & preset():
proc applyProposerSlashing(
preState: var electra.BeaconState, proposerSlashing: ProposerSlashing):
Result[void, cstring] =
var cache: StateCache
doAssert (? process_proposer_slashing(
defaultRuntimeConfig, preState, proposerSlashing, {},
get_state_exit_queue_info(preState), cache))[0] > 0.Gwei
ok()
for path in walkTests(OpProposerSlashingDir):
runTest[ProposerSlashing, typeof applyProposerSlashing](
OpProposerSlashingDir, suiteName, "Proposer Slashing", "proposer_slashing",
applyProposerSlashing, path)
suite baseDescription & "Sync Aggregate " & preset():
proc applySyncAggregate(
preState: var electra.BeaconState, syncAggregate: SyncAggregate):
Result[void, cstring] =
var cache: StateCache
doAssert (? process_sync_aggregate(
preState, syncAggregate, get_total_active_balance(preState, cache),
{}, cache)) > 0.Gwei
ok()
for path in walkTests(OpSyncAggregateDir):
runTest[SyncAggregate, typeof applySyncAggregate](
OpSyncAggregateDir, suiteName, "Sync Aggregate", "sync_aggregate",
applySyncAggregate, path)
when false:
debugRaiseAssert "re-enable electra voluntary exit tests"
suite baseDescription & "Voluntary Exit " & preset():
proc applyVoluntaryExit(
preState: var electra.BeaconState, voluntaryExit: SignedVoluntaryExit):
Result[void, cstring] =
var cache: StateCache
if process_voluntary_exit(
defaultRuntimeConfig, preState, voluntaryExit, {},
get_state_exit_queue_info(preState), cache).isOk:
ok()
else:
err("")
for path in walkTests(OpVoluntaryExitDir):
runTest[SignedVoluntaryExit, typeof applyVoluntaryExit](
OpVoluntaryExitDir, suiteName, "Voluntary Exit", "voluntary_exit",
applyVoluntaryExit, path)
suite baseDescription & "Withdrawals " & preset():
proc applyWithdrawals(
preState: var electra.BeaconState,
executionPayload: electra.ExecutionPayload): Result[void, cstring] =
process_withdrawals(preState, executionPayload)
for path in walkTests(OpWithdrawalsDir):
runTest[electra.ExecutionPayload, typeof applyWithdrawals](
OpWithdrawalsDir, suiteName, "Withdrawals", "execution_payload",
applyWithdrawals, path)