From 74fcf67cf45d0c80472bb6a177ff055ab6e171f9 Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Thu, 26 Aug 2021 13:42:12 -0700 Subject: [PATCH] Fix a performance bug with the randomized block tests from #2560 --- tests/core/pyspec/eth2spec/test/helpers/multi_operations.py | 3 ++- .../core/pyspec/eth2spec/test/utils/randomized_block_tests.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/core/pyspec/eth2spec/test/helpers/multi_operations.py b/tests/core/pyspec/eth2spec/test/helpers/multi_operations.py index 14b281a95..7528c4f0b 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/multi_operations.py +++ b/tests/core/pyspec/eth2spec/test/helpers/multi_operations.py @@ -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))], diff --git a/tests/core/pyspec/eth2spec/test/utils/randomized_block_tests.py b/tests/core/pyspec/eth2spec/test/utils/randomized_block_tests.py index 44dab0e0e..e055285d6 100644 --- a/tests/core/pyspec/eth2spec/test/utils/randomized_block_tests.py +++ b/tests/core/pyspec/eth2spec/test/utils/randomized_block_tests.py @@ -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