use `SyncAggregate.init()` everywhere (#2932)

The initialization of a `SyncAggregate` to its default value is not very
intuitive. There is an `init` function in `sync_committee_msg_pool` that
provides a convenience wrapper. This patch exports that initializer so
that the rest of the code base can also take advantage of it.
This commit is contained in:
Etan Kissling 2021-09-30 15:56:07 +02:00 committed by GitHub
parent 850bec6ae1
commit 2e9fa87f8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 6 deletions

View File

@ -34,9 +34,6 @@ func init*(T: type SyncCommitteeMsgPool,
): SyncCommitteeMsgPool =
T(onContributionReceived: onSyncContribution)
func init(T: type SyncAggregate): SyncAggregate =
SyncAggregate(sync_committee_signature: ValidatorSig.infinity)
func pruneData*(pool: var SyncCommitteeMsgPool, slot: Slot) =
## This should be called at the end of slot.
clear pool.seenContributionByAuthor

View File

@ -491,6 +491,9 @@ func shortLog*(v: SyncCommitteeMessage): auto =
signature: shortLog(v.signature)
)
func init*(T: type SyncAggregate): SyncAggregate =
SyncAggregate(sync_committee_signature: ValidatorSig.infinity)
func shortLog*(v: SyncAggregate): auto =
$(v.sync_committee_bits)

View File

@ -454,7 +454,7 @@ proc makeBeaconBlockForHeadAndSlot*(node: BeaconNode,
let doPhase0 = slot.epoch < node.dag.cfg.ALTAIR_FORK_EPOCH
return if doPhase0:
let sync_aggregate = SyncAggregate(sync_committee_signature: ValidatorSig.infinity)
let sync_aggregate = SyncAggregate.init()
makeBeaconBlock(phase0)
else:
let sync_aggregate = node.sync_committee_msg_pool[].produceSyncAggregate(head.root)

View File

@ -238,7 +238,7 @@ cli do(slots = SLOTS_PER_EPOCH * 6,
finalizedEpochRef.eth1_deposit_index)
sync_aggregate =
when T is phase0.SignedBeaconBlock:
SyncAggregate(sync_committee_signature: ValidatorSig.infinity)
SyncAggregate.init()
elif T is altair.SignedBeaconBlock or T is merge.SignedBeaconBlock:
syncCommitteePool[].produceSyncAggregate(dag.head.root)
else:

View File

@ -120,7 +120,7 @@ proc addTestBlock*(
@[],
@[],
@[],
SyncAggregate(sync_committee_signature: ValidatorSig.infinity),
SyncAggregate.init(),
default(ExecutionPayload),
noRollback,
cache)