mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-31 08:46:57 +00:00
avoid needlessly rescoring aggregates during block attestation packing (#5471)
This commit is contained in:
parent
672fc33586
commit
89686fa274
@ -643,7 +643,7 @@ proc getAttestationsForBlock*(pool: var AttestationPool,
|
||||
var res: seq[Attestation]
|
||||
let totalCandidates = candidates.len()
|
||||
while candidates.len > 0 and res.lenu64() < MAX_ATTESTATIONS:
|
||||
block:
|
||||
let entryCacheKey = block:
|
||||
# Find the candidate with the highest score - slot is used as a
|
||||
# tie-breaker so that more recent attestations are added first
|
||||
let
|
||||
@ -667,10 +667,16 @@ proc getAttestationsForBlock*(pool: var AttestationPool,
|
||||
# the score below
|
||||
attCache.add(entry[].data, entry[].aggregates[j].aggregation_bits)
|
||||
|
||||
entry[].data.getAttestationCacheKey
|
||||
|
||||
block:
|
||||
# Because we added some votes, it's quite possible that some candidates
|
||||
# are no longer interesting - update the scores of the existing candidates
|
||||
for it in candidates.mitems():
|
||||
# Aggregates not on the same (slot, committee) pair don't change scores
|
||||
if it.entry[].data.getAttestationCacheKey != entryCacheKey:
|
||||
continue
|
||||
|
||||
it.score = attCache.score(
|
||||
it.entry[].data,
|
||||
it.entry[].aggregates[it.validation].aggregation_bits)
|
||||
|
Loading…
x
Reference in New Issue
Block a user