Optimized sync committee signature verification#4687
Optimized sync committee signature verification#4687jtraglia merged 3 commits intoethereum:masterfrom
Conversation
…ed aggregate pubkey
jtraglia
left a comment
There was a problem hiding this comment.
Nice work, I think this looks great! I have confirmed that there is an existing test case (test_sync_committee_rewards_not_full_participants) which tests the middle part too. I would appreciate reviews from @mkalinin, @etan-status, @b-wagn, and @arnetheduck.
|
I find it a bit weird to have this arbitrary optimization as part of the spec function, as it reduces readability. Other parts of the spec generally focus on concepts. e.g., the fork choice specs are far from practical implementations where caching every possible intermediate state is a non-option. It is typically up to the client teams to figure out how to optimize the logic to be viable. The optimization itself looks correct though, and is what Nimbus also uses. |
b-wagn
left a comment
There was a problem hiding this comment.
LGTM, modulo the two minor comments below.
I totally agree that in general the specs should describe concepts, and implementations should do the optimizations. However, I think there are two arguments for having this in the spec:
There is also another argument against it: the second optimization that you described here would also not be in spec now. So we would have one optimization but not the other. |
|
For (2), a new, reusable helper function that solves this generically would at least allow the sync aggregate spec function to be clean of these random details. Also a bit more future proof if we have additional situations where the full aggregate pub key exists. |
…with singleton lists
yeah, having a function that separates this would be useful. But I wouldn't insist on it. |
I agree. We could pull this chunk out & put it in a helper function, but it's not necessary. I would lean towards going with what we have now & splitting it into multiple functions if/when it becomes necessary. |
ralexstokes
left a comment
There was a problem hiding this comment.
i'd echo others about not including the optimization in the spec like this
could instead have a note at the bottom here with some (psuedo)code to demonstrate
|
we could also move this function to the pytest files, although that would be harder to find |
|
would also be good to have explicit tests for each of the variants here (1 key, more than half, less than half), although we may have them already |
They aren't explicit, but yes there are many existing tests which use each variant. Eg:
|
jtraglia
left a comment
There was a problem hiding this comment.
There are opposing views on whether or not this should be a spec function or a note. I feel that the "spec function" side has a stronger argument. Part of the rationale for this change is so that the aggregate_pubkey field gets used in the specifications; currently it's not used anywhere which could be confusing for implementers. For these reasons, I've decided to merge this PR. In my opinion, this is a special situation and should not open the door to hyper-optimized specifications.

Enhanced sync committee signature verification to leverage precomputed aggregate pubkey for improved efficiency in high-participation scenarios, particularly for light clients, while ensuring compatibility with existing BLS operations and maintaining spec clarity with added explanatory notes.
Fixes #4195
SyncCommittee.aggregate_pubkey#4195