Skip to content

Commit

Permalink
update round source
Browse files Browse the repository at this point in the history
  • Loading branch information
lanvidr committed Dec 6, 2022
1 parent 38458d9 commit bad51ad
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
9 changes: 4 additions & 5 deletions crates/sui-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2153,21 +2153,20 @@ impl AuthorityState {
.map_err(|err| {
warn!(
"Ignoring malformed transaction (failed to verify) from {}: {:?}",
transaction.certificate.header.author, err
transaction.sender_authority(),
err
);
})?;
}
ConsensusTransactionKind::CheckpointSignature(data) => {
if AuthorityName::from(&transaction.certificate.origin())
!= data.summary.auth_signature.authority
{
if transaction.sender_authority() != data.summary.auth_signature.authority {
warn!("CheckpointSignature authority {} does not match narwhal certificate source {}", data.summary.auth_signature.authority, transaction.certificate.origin() );
return Err(());
}
data.verify(&self.committee()).map_err(|err|{
warn!(
"Ignoring malformed checkpoint signature (failed to verify) from {}, sequence {}: {:?}",
transaction.certificate.header.author, data.summary.summary.sequence_number, err
transaction.sender_authority(), data.summary.summary.sequence_number, err
);
})?;
}
Expand Down
13 changes: 10 additions & 3 deletions crates/sui-core/src/consensus_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use narwhal_types::ConsensusOutput;
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
use std::sync::{Arc, Mutex};
use sui_types::base_types::AuthorityName;
use sui_types::messages::ConsensusTransaction;
use tracing::{debug, instrument, warn};

Expand Down Expand Up @@ -69,12 +70,12 @@ impl ExecutionState for ConsensusHandler {
// TODO [2533]: use this once integrating Narwhal reconfiguration
consensus_output: ConsensusOutput,
) {
let _scope = monitored_scope("HandleConsensusOutputFull");
let _scope = monitored_scope("HandleConsensusOutput");
let mut sequenced_transactions = Vec::new();
let mut seq = 0;

let round = consensus_output.sub_dag.round();
for (cert, batches) in consensus_output.batches {
let round = cert.header.round;
let author = cert.header.author.clone();
let output_cert = Arc::new(cert);
for batch in batches {
Expand Down Expand Up @@ -125,7 +126,7 @@ impl ExecutionState for ConsensusHandler {
.verify_consensus_transaction(sequenced_transaction)
{
Ok(verified_transaction) => verified_transaction,
Err(()) => return,
Err(()) => continue,
};

self.state
Expand Down Expand Up @@ -156,6 +157,12 @@ pub struct SequencedConsensusTransaction {
pub transaction: ConsensusTransaction,
}

impl SequencedConsensusTransaction {
pub fn sender_authority(&self) -> AuthorityName {
(&self.certificate.header.author).into()
}
}

pub struct VerifiedSequencedConsensusTransaction(pub SequencedConsensusTransaction);

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion narwhal/node/tests/reconfigure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl SimpleExecutionState {
// Change epoch every few certificates. Note that empty certificates are not provided to
// this function (they are immediately skipped).
let mut epoch = self.committee.lock().unwrap().epoch();
if transaction >= epoch && change_epoch {
if change_epoch {
epoch += 1;
{
let mut guard = self.committee.lock().unwrap();
Expand Down

0 comments on commit bad51ad

Please sign in to comment.