mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-01-12 11:44:41 +00:00
expose functionality to make random block
This commit is contained in:
parent
eadefa274d
commit
00df808f59
@ -125,10 +125,7 @@ def get_random_voluntary_exits(spec, state, to_be_slashed_indices, rng):
|
|||||||
return prepare_signed_exits(spec, state, exit_indices)
|
return prepare_signed_exits(spec, state, exit_indices)
|
||||||
|
|
||||||
|
|
||||||
def run_test_full_random_operations(spec, state, rng=Random(2080)):
|
def build_random_block_from_state(spec, state, rng=Random(2188)):
|
||||||
# move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit
|
|
||||||
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
|
|
||||||
|
|
||||||
# prepare state for deposits before building block
|
# prepare state for deposits before building block
|
||||||
deposits = prepare_state_and_get_random_deposits(spec, state, rng)
|
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)
|
slashed_indices = slashed_indices.union(attester_slashing.attestation_2.attesting_indices)
|
||||||
block.body.voluntary_exits = get_random_voluntary_exits(spec, state, slashed_indices, rng)
|
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
|
yield 'pre', state
|
||||||
|
|
||||||
signed_block = state_transition_and_sign_block(spec, state, block)
|
signed_block = state_transition_and_sign_block(spec, state, block)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user