1616 state_transition_with_full_block ,
1717)
1818from eth2spec .test .helpers .constants import (
19- PHASE0 , ALTAIR , BELLATRIX , CAPELLA , DENEB ,
19+ ALTAIR , BELLATRIX , CAPELLA , DENEB ,
2020 MINIMAL ,
21- ALL_PHASES ,
2221)
2322from eth2spec .test .helpers .fork_transition import (
2423 do_fork ,
2524)
2625from eth2spec .test .helpers .forks import (
26+ get_spec_for_fork_version ,
2727 is_post_capella , is_post_deneb ,
28- is_post_fork ,
2928)
3029from eth2spec .test .helpers .light_client import (
3130 compute_start_slot_at_next_sync_committee_period ,
4039)
4140
4241
43- def get_spec_for_fork_version (spec , fork_version , phases ):
44- if phases is None :
45- return spec
46- for fork in [fork for fork in ALL_PHASES if is_post_fork (spec .fork , fork )]:
47- if fork == PHASE0 :
48- fork_version_field = 'GENESIS_FORK_VERSION'
49- else :
50- fork_version_field = fork .upper () + '_FORK_VERSION'
51- if fork_version == getattr (spec .config , fork_version_field ):
52- return phases [fork ]
53- raise ValueError ("Unknown fork version %s" % fork_version )
54-
55-
5642class LightClientSyncTest (object ):
5743 steps : List [Dict [str , Any ]]
5844 genesis_validators_root : Any
@@ -535,7 +521,7 @@ def run_test_single_fork(spec, phases, state, fork):
535521 finalized_state = state .copy ()
536522 attested_block = state_transition_with_full_block (spec , state , True , True )
537523 attested_state = state .copy ()
538- sync_aggregate , _ = get_sync_aggregate (spec , state )
524+ sync_aggregate , _ = get_sync_aggregate (spec , state , phases = phases )
539525 block = state_transition_with_full_block (spec , state , True , True , sync_aggregate = sync_aggregate )
540526 yield from emit_update (test , spec , state , block , attested_state , attested_block , finalized_block , phases = phases )
541527 assert test .store .finalized_header .beacon .slot == finalized_state .slot
@@ -548,7 +534,7 @@ def run_test_single_fork(spec, phases, state, fork):
548534 transition_to (spec , state , spec .compute_start_slot_at_epoch (fork_epoch ) - 4 )
549535 attested_block = state_transition_with_full_block (spec , state , True , True )
550536 attested_state = state .copy ()
551- sync_aggregate , _ = get_sync_aggregate (spec , state )
537+ sync_aggregate , _ = get_sync_aggregate (spec , state , phases = phases )
552538 block = state_transition_with_full_block (spec , state , True , True , sync_aggregate = sync_aggregate )
553539 update = yield from emit_update (
554540 test , spec , state , block , attested_state , attested_block , finalized_block , phases = phases )
@@ -564,7 +550,7 @@ def run_test_single_fork(spec, phases, state, fork):
564550 # Final slot before fork, check that importing the pre-fork format still works
565551 attested_block = block .copy ()
566552 attested_state = state .copy ()
567- sync_aggregate , _ = get_sync_aggregate (spec , state )
553+ sync_aggregate , _ = get_sync_aggregate (spec , state , phases = phases )
568554 block = state_transition_with_full_block (spec , state , True , True , sync_aggregate = sync_aggregate )
569555 yield from emit_update (test , spec , state , block , attested_state , attested_block , finalized_block , phases = phases )
570556 assert test .store .finalized_header .beacon .slot == finalized_state .slot
@@ -575,7 +561,7 @@ def run_test_single_fork(spec, phases, state, fork):
575561 # Upgrade to post-fork spec, attested block is still before the fork
576562 attested_block = block .copy ()
577563 attested_state = state .copy ()
578- sync_aggregate , _ = get_sync_aggregate (phases [fork ], state )
564+ sync_aggregate , _ = get_sync_aggregate (phases [fork ], state , phases = phases )
579565 state , block = do_fork (state , spec , phases [fork ], fork_epoch , sync_aggregate = sync_aggregate )
580566 spec = phases [fork ]
581567 yield from emit_update (test , spec , state , block , attested_state , attested_block , finalized_block , phases = phases )
@@ -587,7 +573,7 @@ def run_test_single_fork(spec, phases, state, fork):
587573 # Another block after the fork, this time attested block is after the fork
588574 attested_block = block .copy ()
589575 attested_state = state .copy ()
590- sync_aggregate , _ = get_sync_aggregate (spec , state )
576+ sync_aggregate , _ = get_sync_aggregate (spec , state , phases = phases )
591577 block = state_transition_with_full_block (spec , state , True , True , sync_aggregate = sync_aggregate )
592578 yield from emit_update (test , spec , state , block , attested_state , attested_block , finalized_block , phases = phases )
593579 assert test .store .finalized_header .beacon .slot == finalized_state .slot
@@ -599,7 +585,7 @@ def run_test_single_fork(spec, phases, state, fork):
599585 transition_to (spec , state , spec .compute_start_slot_at_epoch (fork_epoch + 1 ) - 2 )
600586 attested_block = state_transition_with_full_block (spec , state , True , True )
601587 attested_state = state .copy ()
602- sync_aggregate , _ = get_sync_aggregate (spec , state )
588+ sync_aggregate , _ = get_sync_aggregate (spec , state , phases = phases )
603589 block = state_transition_with_full_block (spec , state , True , True , sync_aggregate = sync_aggregate )
604590 yield from emit_update (test , spec , state , block , attested_state , attested_block , finalized_block , phases = phases )
605591 assert test .store .finalized_header .beacon .slot == finalized_state .slot
@@ -613,7 +599,7 @@ def run_test_single_fork(spec, phases, state, fork):
613599 _ , _ , state = next_slots_with_attestations (spec , state , 2 * spec .SLOTS_PER_EPOCH - 1 , True , True )
614600 attested_block = state_transition_with_full_block (spec , state , True , True )
615601 attested_state = state .copy ()
616- sync_aggregate , _ = get_sync_aggregate (spec , state )
602+ sync_aggregate , _ = get_sync_aggregate (spec , state , phases = phases )
617603 block = state_transition_with_full_block (spec , state , True , True , sync_aggregate = sync_aggregate )
618604 yield from emit_update (test , spec , state , block , attested_state , attested_block , finalized_block , phases = phases )
619605 assert test .store .finalized_header .beacon .slot == finalized_state .slot
0 commit comments