Merge pull request #2572 from ralexstokes/fix-randomized-block-test-perf
Fix a performance bug with the randomized block tests from #2560
This commit is contained in:
commit
31b4d02f0a
|
@ -171,7 +171,7 @@ def get_random_voluntary_exits(spec, state, to_be_slashed_indices, rng):
|
|||
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)
|
||||
participant_count = int(len(committee_indices) * fraction_participated)
|
||||
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,
|
||||
slot,
|
||||
participants,
|
||||
block_root=block_root,
|
||||
)
|
||||
return spec.SyncAggregate(
|
||||
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
|
||||
fraction_missed = block_index * (1 / SYNC_AGGREGATE_PARTICIPATION_BUCKETS)
|
||||
fraction_participated = 1.0 - fraction_missed
|
||||
previous_root = block.parent_root
|
||||
block.body.sync_aggregate = get_random_sync_aggregate(
|
||||
spec,
|
||||
state,
|
||||
block.slot - 1,
|
||||
block_root=previous_root,
|
||||
fraction_participated=fraction_participated,
|
||||
)
|
||||
return block
|
||||
|
|
Loading…
Reference in New Issue