expose functionality to make random block

This commit is contained in:
Alex Stokes 2021-08-20 13:35:23 -06:00
parent eadefa274d
commit 00df808f59
No known key found for this signature in database
GPG Key ID: 99B3D88FD6C55A69

View File

@ -125,10 +125,7 @@ def get_random_voluntary_exits(spec, state, to_be_slashed_indices, rng):
return prepare_signed_exits(spec, state, exit_indices)
def run_test_full_random_operations(spec, state, rng=Random(2080)):
# move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
def build_random_block_from_state(spec, state, rng=Random(2188)):
# prepare state for deposits before building block
deposits = prepare_state_and_get_random_deposits(spec, state, rng)
@ -148,6 +145,15 @@ def run_test_full_random_operations(spec, state, rng=Random(2080)):
slashed_indices = slashed_indices.union(attester_slashing.attestation_2.attesting_indices)
block.body.voluntary_exits = get_random_voluntary_exits(spec, state, slashed_indices, rng)
return block
def run_test_full_random_operations(spec, state, rng=Random(2080)):
# move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
block = build_random_block_from_state(spec, state, rng)
yield 'pre', state
signed_block = state_transition_and_sign_block(spec, state, block)