Skip to content
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

[checkpoint] Fragment verification should check seq number consistency #4497

Merged
merged 1 commit into from
Sep 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions crates/sui-types/src/messages_checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,10 @@ pub struct CheckpointFragment {

impl CheckpointFragment {
pub fn verify(&self, committee: &Committee) -> SuiResult {
fp_ensure!(
self.proposer.summary.sequence_number == self.other.summary.sequence_number,
SuiError::from("Proposer and other have inconsistent sequence number")
);
// Check the signatures of proposer and other
self.proposer.verify(committee, None)?;
self.other.verify(committee, None)?;
Expand Down Expand Up @@ -758,4 +762,25 @@ mod tests {

assert!(CertifiedCheckpointSummary::aggregate(signed_checkpoints, &committee).is_err());
}

#[test]
fn test_fragment() {
let mut rng = StdRng::from_seed(RNG_SEED);
let (authority_key, committee) = make_committee_key(&mut rng);
let name1: AuthorityName = authority_key[0].public().into();
let name2: AuthorityName = authority_key[1].public().into();

let set = CheckpointProposalContents::new([ExecutionDigests::random()].into_iter());

let proposal1 =
CheckpointProposal::new(committee.epoch, 1, name1, &authority_key[0], set.clone());
let proposal2 =
CheckpointProposal::new(committee.epoch, 1, name2, &authority_key[1], set.clone());
let fragment1 = proposal1.fragment_with(&proposal2);
assert!(fragment1.verify(&committee).is_ok());

let proposal3 = CheckpointProposal::new(committee.epoch, 2, name2, &authority_key[1], set);
let fragment2 = proposal1.fragment_with(&proposal3);
assert!(fragment2.verify(&committee).is_err());
}
}