Skip to content

Commit

Permalink
Fix a bug in verifying checkpoint (MystenLabs#3952)
Browse files Browse the repository at this point in the history
  • Loading branch information
lxfind authored Aug 15, 2022
1 parent 2b4003f commit 22b8256
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/sui-core/src/epoch/reconfiguration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ where
self.state.unhalt_validator();
info!(?epoch, "Validator unhalted.");
info!(
"Epoch change finished. We are now at epoch {:?}",
"===== Epoch change finished. We are now at epoch {:?} =====",
next_epoch
);
Ok(())
Expand Down
15 changes: 13 additions & 2 deletions crates/sui-core/src/safe_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl SafeClientMetrics {
.unwrap(),
follower_streaming_from_seq_number_by_address: register_int_gauge_vec_with_registry!(
"safe_client_follower_streaming_from_seq_number_by_address",
"The seq nubmer with which to request follower streaming, group by address",
"The seq number with which to request follower streaming, group by address",
&["address"],
registry,
)
Expand Down Expand Up @@ -615,13 +615,24 @@ where
{
// Verify signature.
if let Some(signed_proposal) = proposal {
let committee =
let mut committee =
self.get_committee(&signed_proposal.auth_signature.epoch)?;
signed_proposal.verify(&committee, response.detail.as_ref())?;
if signed_proposal.summary.sequence_number > 0 {
let cert = prev_cert.as_ref().ok_or_else(|| {
SuiError::from("No checkpoint cert provided along with proposal")
})?;
if cert.auth_signature.epoch != signed_proposal.auth_signature.epoch {
// It's possible that the previous checkpoint cert is from the
// previous epoch, and in that case we verify them using different
// committee.
fp_ensure!(
cert.auth_signature.epoch + 1
== signed_proposal.auth_signature.epoch,
SuiError::from("Unexpected epoch for checkpoint cert")
);
committee = self.get_committee(&cert.auth_signature.epoch)?;
}
cert.verify(&committee, None)?;
fp_ensure!(
signed_proposal.summary.sequence_number - 1 == cert.summary.sequence_number,
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-types/src/messages_checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ impl SignedCheckpointSummary {
contents: Option<&CheckpointContents>,
) -> Result<(), SuiError> {
fp_ensure!(
self.summary.epoch == self.auth_signature.epoch,
self.summary.epoch == committee.epoch,
SuiError::from("Epoch in the summary doesn't match with the signature")
);

Expand Down

0 comments on commit 22b8256

Please sign in to comment.