Skip to content

Commit

Permalink
types: ensure digests are formatted with their Display impls
Browse files Browse the repository at this point in the history
  • Loading branch information
bmwill committed Feb 2, 2023
1 parent e5a8dbc commit 4db8497
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
11 changes: 5 additions & 6 deletions crates/sui-core/src/checkpoints/checkpoint_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::authority::StableSyncAuthoritySigner;
use crate::consensus_adapter::SubmitToConsensus;
use crate::epoch::reconfiguration::ReconfigurationInitiator;
use async_trait::async_trait;
use fastcrypto::encoding::{Encoding, Hex};
use std::sync::Arc;
use sui_types::base_types::AuthorityName;
use sui_types::error::SuiResult;
Expand Down Expand Up @@ -102,12 +101,12 @@ impl CheckpointOutput for LogCheckpointOutput {
);
info!(
"Creating checkpoint {:?} at epoch {}, sequence {}, previous digest {:?}, transactions count {}, content digest {:?}, next_epoch_committee {:?}",
Hex::encode(summary.digest()),
summary.digest(),
summary.epoch,
summary.sequence_number,
summary.previous_digest.map(Hex::encode),
summary.previous_digest,
contents.size(),
Hex::encode(summary.content_digest),
summary.content_digest,
summary.next_epoch_committee,
);

Expand All @@ -124,7 +123,7 @@ impl CertifiedCheckpointOutput for LogCheckpointOutput {
info!(
"Certified checkpoint with sequence {} and digest {}",
summary.summary.sequence_number,
Hex::encode(summary.summary.digest())
summary.summary.digest()
);
Ok(())
}
Expand All @@ -149,7 +148,7 @@ impl CertifiedCheckpointOutput for SendCheckpointToStateSync {
info!(
"Certified checkpoint with sequence {} and digest {}",
summary.summary.sequence_number,
Hex::encode(summary.summary.digest())
summary.summary.digest()
);
self.handle
.send_checkpoint(VerifiedCheckpoint::new_unchecked(summary.to_owned()))
Expand Down
7 changes: 3 additions & 4 deletions crates/sui-core/src/checkpoints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub use crate::checkpoints::checkpoint_output::{
};
pub use crate::checkpoints::metrics::CheckpointMetrics;
use crate::stake_aggregator::{InsertResult, StakeAggregator};
use fastcrypto::encoding::{Encoding, Hex};
use futures::future::{select, Either};
use futures::FutureExt;
use mysten_metrics::{monitored_scope, spawn_monitored_task, MonitoredFutureExt};
Expand Down Expand Up @@ -916,9 +915,9 @@ impl CheckpointSignatureAggregator {
warn!(
"Validator {:?} has mismatching checkpoint digest {} at seq {}, we have digest {}",
author.concise(),
Hex::encode(their_digest),
their_digest,
self.summary.sequence_number,
Hex::encode(self.digest)
self.digest
);
return Err(());
}
Expand Down Expand Up @@ -1072,7 +1071,7 @@ impl CheckpointServiceNotify for CheckpointService {
debug!(
"Received signature for checkpoint sequence {}, digest {} from {}",
sequence,
Hex::encode(info.summary.summary.digest()),
info.summary.summary.digest(),
info.summary.auth_signature.authority.concise(),
);
// While it can be tempting to make last_signature_index into AtomicU64, this won't work
Expand Down
3 changes: 1 addition & 2 deletions crates/sui-types/src/messages_checkpoint.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

use fastcrypto::encoding::{Encoding, Hex};
use std::fmt::{Debug, Display, Formatter};
use std::slice::Iter;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
Expand Down Expand Up @@ -120,7 +119,7 @@ impl Display for CheckpointSummary {
epoch_rolling_gas_cost_summary: {:?}}}",
self.epoch,
self.sequence_number,
Hex::encode(self.content_digest),
self.content_digest,
self.epoch_rolling_gas_cost_summary,
)
}
Expand Down
4 changes: 2 additions & 2 deletions crates/sui/src/genesis_ceremony.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ pub fn run(cmd: Ceremony) -> Result<()> {
let mut builder = Builder::load(&dir)?;
let (unsigned_checkpoint, ..) = builder.build_unsigned_genesis_checkpoint();
println!(
"Successfully built unsigned checkpoint: {:?}",
"Successfully built unsigned checkpoint: {}",
unsigned_checkpoint.digest()
);

Expand All @@ -185,7 +185,7 @@ pub fn run(cmd: Ceremony) -> Result<()> {
builder.save(dir)?;

println!(
"Successfully verified and signed genesis checkpoint: {:?}",
"Successfully verified and signed genesis checkpoint: {}",
checkpoint.digest()
);
}
Expand Down

0 comments on commit 4db8497

Please sign in to comment.