fix sync contribution validation for first slot per period (#5408)

Sync committee duties are performed by the sync committee as determined
by slot + 1. We did it correctly for individual messages, but selected
the incorrect participants for aggregate contributions for the very
first slot per period (roughly 1 per ~27 hrs on Mainnet). The faulty
participants selection code was originally introduced in #2925.
This commit is contained in:
Etan Kissling 2023-09-13 03:23:18 +02:00 committed by GitHub
parent 5c88e74c08
commit 4700030231
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 8 deletions

View File

@ -1170,14 +1170,11 @@ proc validateContribution*(
checkSignature: bool
): Future[Result[
(BlockId, CookedSig, seq[ValidatorIndex]), ValidationError]] {.async.} =
let
syncCommitteeSlot = msg.message.contribution.slot
block:
# [IGNORE] The contribution's slot is for the current slot
# (with a MAXIMUM_GOSSIP_CLOCK_DISPARITY allowance)
# i.e. contribution.slot == current_slot.
block:
let v = check_slot_exact(syncCommitteeSlot, wallTime)
let v = check_slot_exact(msg.message.contribution.slot, wallTime)
if v.isErr(): # [IGNORE]
return err(v.error())
@ -1220,7 +1217,7 @@ proc validateContribution*(
# between validation and use - nonetheless, a design that avoids it and
# stays safe would be nice
participants = dag.syncCommitteeParticipants(
msg.message.contribution.slot, subcommitteeIdx)
msg.message.contribution.slot + 1, subcommitteeIdx)
if aggregator_index notin participants:
return dag.checkedReject("Contribution: aggregator not in subcommittee")