-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Optimistic signature verification for votes and order votes #14642
Conversation
⏱️ 10h 19m total CI duration on this PR
🚨 2 jobs on the last run were significantly faster/slower than expected
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
} | ||
|
||
pub fn verified_voters(&self) -> impl Iterator<Item = &AccountAddress> { | ||
self.verified_signatures.signatures().keys() | ||
self.signatures.iter().filter_map(|(voter, signature)| { |
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.
nit: can shorten as
self.signatures.iter()
.filter(|(_, sig)| sig.is_verified())
.map(|(voter, _)| voter)
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
consensus/src/pending_votes.rs
Outdated
VoteStatus::NotEnoughVotes(li) => { | ||
write!( | ||
f, | ||
"LI {} has {} verified votes {:?}, {} unverified votes {:?}", |
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.
please don't use debug format, it spams the log
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.
Done.
types/src/ledger_info.rs
Outdated
Ok(_) => { | ||
self.merge_signatures(&epoch_state.verifier, false); | ||
self.filter_invalid_signatures(verifier, false); |
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.
in some sense we don't really need this since the aggregation already succeeds and returns?
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.
Yeah, we don't. But it still makes the data structure complete, and makes it easy in test cases to check that after aggregate_and_verify function is called, we have x number of verified signatures.
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.
Alin was telling me that even if the aggregation succeeds, it doesn't necessarily mean all individual signatures are valid, some validators can collude to produce two invalid signatures that can be aggregated to be valid. in that sense, for the sake of sanity, I think we probably shouldn't mark them as "valid"
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.
Done.
OrderVoteReceptionResult::VoteAdded(1) | ||
); | ||
|
||
vote_0.set_verified(); |
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.
what are we trying to do by setting it to verified?
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.
Just wanted to make sure that the data structure works when it receives a mix of verified and unverified signatures.
pending_order_votes.insert_order_vote(&vote_2, &verifier, None), | ||
OrderVoteReceptionResult::VoteAdded(2) | ||
); | ||
assert_eq!(verifier.pessimistic_verify_set().len(), 1); |
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.
instead, here we should check if valid signatures are set to verified?
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.
Added the check.
partial_sigs.add_signature(signers[0].author(), vote_0.signature().clone()); | ||
|
||
// same author voting for the same thing -> DuplicateVote | ||
vote_0.set_verified(); |
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.
same q here
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.
Just wanted to make sure that the data structure works when it receives a mix of verified and unverified signatures.
@@ -213,6 +213,54 @@ async fn test_no_failures() { | |||
.unwrap(); | |||
} | |||
|
|||
#[tokio::test] | |||
async fn test_faulty_votes() { |
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.
how did you verify this works as expected? we don't have any logs showing pessimistic validators being added?
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ Forge suite
|
✅ Forge suite
|
✅ Forge suite
|
@@ -78,6 +78,7 @@ pub struct ConsensusConfig { | |||
// must match one of the CHAIN_HEALTH_WINDOW_SIZES values. | |||
pub window_for_chain_health: usize, | |||
pub chain_health_backoff: Vec<ChainHealthBackoffValues>, | |||
// Deprecated | |||
pub qc_aggregator_type: QcAggregatorType, |
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.
Since it's local config, why not remove it?
Description
This PR implements optimistic signature verification to reduce the time required to verify proposal votes and order votes.
When the optimistic signature verification feature flag is enabled, we will not verify these messages up front. We will accumulate the unverified messages, and when the accumulated voting power is higher than a threshold, we will aggregate all the signatures and verify the aggregated signature.
If the verification fails, we need to verify each individual signature. The ValidatorVerifier stores the list of authors that submitted bad messages, and will disable the optimistic signature verification for these malicious voters.
Type of Change
Which Components or Systems Does This Change Impact?
How Has This Been Tested?
Key Areas to Review
Checklist