-
Notifications
You must be signed in to change notification settings - Fork 922
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
Attestation aggregation: remove proper set duplicates #8063
Conversation
5d0b3fa
to
b69f549
Compare
@@ -2105,27 +2105,6 @@ func TestProposer_DeleteAttsInPool_Aggregated(t *testing.T) { | |||
assert.Equal(t, 0, len(atts), "Did not delete unaggregated attestation") | |||
} | |||
|
|||
func TestProposer_SortProfitableAtts(t *testing.T) { |
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.
Any reason this test is removed?
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.
It is not removed, it is moved (proposer_utils_test.go
file was added, and this test, correctly, was moved there).
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.
atts[j] = atts[len(atts)-1] | ||
atts[len(atts)-1] = nil | ||
atts = atts[:len(atts)-1] | ||
j-- |
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.
Are you missing a break
after this line?
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.
No, definitely not.
We fixate on atts[i]
and can remove as many atts[j]
w/o breaking (I am swapping the current element for the last and decrease the len -- common idiom). I decrement j
so that swapped element is checked too.
The break in the second else if
is because when we need to remove atts[i]
(and we fixate on it), we swap the last and the current element, and need to break, and check that last element's index once again.
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.
Makes sense!
What type of PR is this?
What does this PR do? Why is it needed?
Which issues(s) does this PR fix?
Part of #7871
Other notes for review
attestations/kv/aggregated.go
we make sure that we do not add redundant bits (seeattestations/kv/seen_bits.go
). However, while our method is good enough to make sure that non-overlapping attestations all have some unseen bits present, after the aggregation situation can change (so, we still need to make sure we deduplicate before proposing).Here is a sample case:
So, seen bits are:
1101.0001
.Now, another aggregate comes in:
0100.0010
. It will not be marked as seen as it introduces new info at 0000.00X0 position. So, pool will be updated to:On aggregation, it will become:
And, clearly,
1100.0000
is redundant as it is a proper subset of the first aggregate, thus needs to be deduplicated.