-
-
Notifications
You must be signed in to change notification settings - Fork 348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: duplicated block attestations #7455
Conversation
Performance Report🚀🚀 Significant benchmark improvement detected
Full benchmark results
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## unstable #7455 +/- ##
=========================================
Coverage 50.25% 50.25%
=========================================
Files 602 602
Lines 40401 40416 +15
Branches 2204 2203 -1
=========================================
+ Hits 20305 20313 +8
- Misses 20056 20063 +7
Partials 40 40 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably best if @twoeths give this a review
@@ -385,19 +383,22 @@ export class AggregatedAttestationPool { | |||
if (score < minScore) { | |||
minScore = score; | |||
} | |||
consolidations.push({...consolidation, score}); | |||
|
|||
consolidations.set(consolidation, score); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this would override the record? might be better to just continue if it already exists.
But why do we have duplicates in sameAttDataCons
shouldn't this be aggregated earlier into a single one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this would override the record? might be better to just continue if it already exists.
That's the whole point. The current implementation would insert the same consolidation with different score into consolidations
, hence the duplication.
But why do we have duplicates in sameAttDataCons shouldn't this be aggregated earlier into a single one?
The aggregation earlier only aggregates the SignedAggregateAndProof
s from the same committee. Notice how they are stored by committee index and MatchingDataAttestationGroup
only store aggregated attestations from the same committee.
private readonly attestationGroupByIndexByDataHexBySlot = new MapDef<
Slot,
Map<DataRootHex, Map<CommitteeIndex, MatchingDataAttestationGroup>>>
.slice(0, MAX_ATTESTATIONS_ELECTRA); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticed we are not cloning here
lodestar/packages/beacon-node/src/chain/opPools/aggregatedAttestationPool.ts
Lines 288 to 289 in e45e0eb
// attestations could be modified in this op pool, so we need to clone for block | |
attestationsForBlock.push(ssz.phase0.Attestation.clone(attestationWithScore.attestation)); |
but might be fine due to aggregateConsolidation
packages/beacon-node/src/chain/opPools/aggregatedAttestationPool.ts
Outdated
Show resolved
Hide resolved
It took me a while to understand what Suppose you have committee 100 and committee 101 both contain members who vote for the same attestation data. Then they will share the same In the first iteration of the above for loop,
and then each In the second iteration,
and again
where each element's |
…ol.ts Co-authored-by: Nico Flaig <nflaig@protonmail.com>
Can confirm this PR fixes the issue. https://dora.pectra-devnet-6.ethpandaops.io/slot/66426 no longer sees duplicates. |
@ensi321 could you reproduce the issue in a unit test? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could add tests in a follow-up PR since the branch has been tested on the devnet
🎉 This PR is included in v1.27.0 🎉 |
Follow up on #7455 (comment) to add unit test of the changes introduced in #7455. --------- Co-authored-by: Nico Flaig <nflaig@protonmail.com>
Background
Raise by Teku team on discord https://discord.com/channels/595666850260713488/1338793076491026486/1338793635386228756,
Lodestar will generate duplicated attestations and include them in the block body when proposing.
For example https://dora.pectra-devnet-6.ethpandaops.io/slot/54933 has 6 copies of the same attestation with signature
0xae6b928e4866d5a43ae6d4ced869e3aa53f38617d42da5862c76e9a928942783a108e4e281d208766b8a9b2adb286aff0e0af7c14f24d1b013f4ccb47c000a11c256112fab37945d2e5bb3671b997a23b1d57d67d3fe69835ecc06f1f57b1210
.This is due to
getAttestationsForBlockElectra
putting multiple copies of the same attestations inconsolidations
when there are attestations coming from different committees with the same attestation data.The above attestation having 6 copies because the attestation contains 6 committees (0, 2, 3, 6, 7 and 12).
Proposal
Remove
AttestationsConsolidation.score
and convertconsolidations
to aMap<AttestationsConsolidation, number>()
to track the score while eliminating duplicates.