sync aggregate test with proposer in the committee

This commit is contained in:
Alex Stokes 2021-07-01 17:29:33 -07:00
parent faf1ba1f4f
commit 49c433746d
No known key found for this signature in database
GPG Key ID: 99B3D88FD6C55A69
1 changed files with 38 additions and 0 deletions

View File

@ -382,3 +382,41 @@ def test_valid_signature_future_committee(spec, state):
) )
yield from run_sync_committee_processing(spec, state, block) yield from run_sync_committee_processing(spec, state, block)
@with_altair_and_later
@spec_state_test
@always_bls
@with_presets([MINIMAL], reason="prefer short search to find matching proposer")
def test_proposer_in_committee_without_participation(spec, state):
committee_indices = compute_committee_indices(spec, state, state.current_sync_committee)
# NOTE: seem to reliably be getting a matching proposer in the first epoch w/ ``MINIMAL`` preset.
for _ in range(spec.SLOTS_PER_EPOCH):
block = build_empty_block_for_next_slot(spec, state)
proposer_index = block.proposer_index
proposer_pubkey = state.validators[proposer_index].pubkey
proposer_is_in_sync_committee = proposer_pubkey in state.current_sync_committee.pubkeys
if proposer_is_in_sync_committee:
participation = [index != proposer_index for index in committee_indices]
participants = [index for index in committee_indices if index != proposer_index]
else:
participation = [True for _ in committee_indices]
participants = committee_indices
# Valid sync committee signature here...
block.body.sync_aggregate = spec.SyncAggregate(
sync_committee_bits=participation,
sync_committee_signature=compute_aggregate_sync_committee_signature(
spec,
state,
block.slot - 1,
participants,
)
)
if proposer_is_in_sync_committee:
yield from run_sync_committee_processing(spec, state, block)
return
else:
state_transition_and_sign_block(spec, state, block)
raise AssertionError("failed to find a proposer in the sync committee set; check test setup")