From 4d4f4e89f48aa4d5c14a41159d6bcb021f8ec1a3 Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Wed, 25 Aug 2021 10:38:01 -0700 Subject: [PATCH] be specific about which slot we want a sync committee root for --- .../core/pyspec/eth2spec/test/helpers/multi_operations.py | 4 ++-- tests/core/pyspec/eth2spec/test/utils/random.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/core/pyspec/eth2spec/test/helpers/multi_operations.py b/tests/core/pyspec/eth2spec/test/helpers/multi_operations.py index c0a58dbca..075b03aa0 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/multi_operations.py +++ b/tests/core/pyspec/eth2spec/test/helpers/multi_operations.py @@ -213,7 +213,7 @@ def run_test_full_random_operations(spec, state, rng=Random(2080)): yield 'post', state -def get_random_sync_aggregate(spec, state, fraction_participated=1.0, rng=Random(2099)): +def get_random_sync_aggregate(spec, state, slot, 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) @@ -224,7 +224,7 @@ def get_random_sync_aggregate(spec, state, fraction_participated=1.0, rng=Random signature = compute_aggregate_sync_committee_signature( spec, state, - state.slot - 1, + slot, participants, ) return spec.SyncAggregate( diff --git a/tests/core/pyspec/eth2spec/test/utils/random.py b/tests/core/pyspec/eth2spec/test/utils/random.py index 2f727e749..d17a3a9b2 100644 --- a/tests/core/pyspec/eth2spec/test/utils/random.py +++ b/tests/core/pyspec/eth2spec/test/utils/random.py @@ -123,7 +123,12 @@ def random_block_altair(spec, state, signed_blocks): block = random_block(spec, state, signed_blocks) fraction_missed = len(signed_blocks) / SYNC_AGGREGATE_PARTICIPATION_BUCKETS fraction_participated = 1.0 - fraction_missed - block.body.sync_aggregate = get_random_sync_aggregate(spec, state, fraction_participated=fraction_participated) + block.body.sync_aggregate = get_random_sync_aggregate( + spec, + state, + block.slot - 1, + fraction_participated=fraction_participated, + ) return block