Fix a performance bug with the randomized block tests from #2560
This commit is contained in:
parent
17fece57b6
commit
74fcf67cf4
|
@ -171,7 +171,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 get_random_sync_aggregate(spec, state, slot, fraction_participated=1.0, rng=Random(2099)):
|
def get_random_sync_aggregate(spec, state, slot, block_root=None, fraction_participated=1.0, rng=Random(2099)):
|
||||||
committee_indices = compute_committee_indices(spec, state, state.current_sync_committee)
|
committee_indices = compute_committee_indices(spec, state, state.current_sync_committee)
|
||||||
participant_count = int(len(committee_indices) * fraction_participated)
|
participant_count = int(len(committee_indices) * fraction_participated)
|
||||||
participant_indices = rng.sample(range(len(committee_indices)), participant_count)
|
participant_indices = rng.sample(range(len(committee_indices)), participant_count)
|
||||||
|
@ -184,6 +184,7 @@ def get_random_sync_aggregate(spec, state, slot, fraction_participated=1.0, rng=
|
||||||
state,
|
state,
|
||||||
slot,
|
slot,
|
||||||
participants,
|
participants,
|
||||||
|
block_root=block_root,
|
||||||
)
|
)
|
||||||
return spec.SyncAggregate(
|
return spec.SyncAggregate(
|
||||||
sync_committee_bits=[index in participant_indices for index in range(len(committee_indices))],
|
sync_committee_bits=[index in participant_indices for index in range(len(committee_indices))],
|
||||||
|
|
|
@ -135,10 +135,12 @@ def random_block_altair_with_cycling_sync_committee_participation(spec,
|
||||||
block_index = len(signed_blocks) % SYNC_AGGREGATE_PARTICIPATION_BUCKETS
|
block_index = len(signed_blocks) % SYNC_AGGREGATE_PARTICIPATION_BUCKETS
|
||||||
fraction_missed = block_index * (1 / SYNC_AGGREGATE_PARTICIPATION_BUCKETS)
|
fraction_missed = block_index * (1 / SYNC_AGGREGATE_PARTICIPATION_BUCKETS)
|
||||||
fraction_participated = 1.0 - fraction_missed
|
fraction_participated = 1.0 - fraction_missed
|
||||||
|
previous_root = block.parent_root
|
||||||
block.body.sync_aggregate = get_random_sync_aggregate(
|
block.body.sync_aggregate = get_random_sync_aggregate(
|
||||||
spec,
|
spec,
|
||||||
state,
|
state,
|
||||||
block.slot - 1,
|
block.slot - 1,
|
||||||
|
block_root=previous_root,
|
||||||
fraction_participated=fraction_participated,
|
fraction_participated=fraction_participated,
|
||||||
)
|
)
|
||||||
return block
|
return block
|
||||||
|
|
Loading…
Reference in New Issue