mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-02-02 22:03:37 +00:00
fix bug with proposer search
This commit is contained in:
parent
2db01ba6d0
commit
361d97c54b
@ -150,7 +150,7 @@ def get_random_voluntary_exits(spec, state, to_be_slashed_indices, rng):
|
||||
return prepare_signed_exits(spec, state, exit_indices)
|
||||
|
||||
|
||||
def build_random_block_from_state(spec, state, rng=Random(2188)):
|
||||
def build_random_block_from_state_for_next_slot(spec, state, rng=Random(2188)):
|
||||
# prepare state for deposits before building block
|
||||
deposits = prepare_state_and_get_random_deposits(spec, state, rng)
|
||||
|
||||
@ -177,7 +177,7 @@ 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)
|
||||
block = build_random_block_from_state_for_next_slot(spec, state, rng)
|
||||
|
||||
yield 'pre', state
|
||||
|
||||
|
@ -9,7 +9,7 @@ from tests.core.pyspec.eth2spec.test.context import (
|
||||
zero_activation_threshold,
|
||||
)
|
||||
from eth2spec.test.helpers.multi_operations import (
|
||||
build_random_block_from_state,
|
||||
build_random_block_from_state_for_next_slot,
|
||||
)
|
||||
from eth2spec.test.helpers.state import (
|
||||
next_epoch,
|
||||
@ -103,13 +103,16 @@ def _random_block(spec, state, _signed_blocks):
|
||||
to produce a block over ``BLOCK_ATTEMPTS`` slots in order
|
||||
to find a valid block in the event that the proposer has already been slashed.
|
||||
"""
|
||||
block = build_random_block_from_state(spec, state, rng)
|
||||
temp_state = state.copy()
|
||||
next_slot(spec, temp_state)
|
||||
for _ in range(BLOCK_ATTEMPTS):
|
||||
proposer = state.validators[block.proposer_index]
|
||||
proposer_index = spec.get_beacon_proposer_index(temp_state)
|
||||
proposer = state.validators[proposer_index]
|
||||
if proposer.slashed:
|
||||
next_slot(spec, state)
|
||||
block = build_random_block_from_state(spec, state)
|
||||
next_slot(spec, temp_state)
|
||||
else:
|
||||
block = build_random_block_from_state_for_next_slot(spec, state)
|
||||
_warn_if_empty_operations(block)
|
||||
return block
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user