diff --git a/consensus/src/proposal/handler.rs b/consensus/src/proposal/handler.rs index abec8c450d..56ad6df31d 100644 --- a/consensus/src/proposal/handler.rs +++ b/consensus/src/proposal/handler.rs @@ -90,13 +90,20 @@ impl ProposalHandler { return Err(ConsensusError::InvalidBlockHash); } - let tx_hashes: Vec<[u8; 32]> = + let tx_hashes: Vec<_> = p.candidate.txs().iter().map(|t| t.hash()).collect(); let tx_root = merkle_root(&tx_hashes[..]); if tx_root != p.candidate.header().txroot { return Err(ConsensusError::InvalidBlock); } + let fault_hashes: Vec<_> = + p.candidate.faults().iter().map(|t| t.hash()).collect(); + let fault_root = merkle_root(&fault_hashes[..]); + if fault_root != p.candidate.header().faultroot { + return Err(ConsensusError::InvalidBlock); + } + if expected_generator != p.sign_info.signer.bytes() { return Err(ConsensusError::NotCommitteeMember); } diff --git a/consensus/src/validation/step.rs b/consensus/src/validation/step.rs index fadb4a3f13..2876ba7666 100644 --- a/consensus/src/validation/step.rs +++ b/consensus/src/validation/step.rs @@ -86,7 +86,6 @@ impl ValidationStep { // Call Verify State Transition to make sure transactions set is // valid - // TODO: Verify Faults if let Err(err) = executor .verify_faults(header.height, candidate.faults()) .await diff --git a/node-data/src/ledger.rs b/node-data/src/ledger.rs index 574ecc96d6..8c21a5195d 100644 --- a/node-data/src/ledger.rs +++ b/node-data/src/ledger.rs @@ -14,7 +14,7 @@ mod transaction; pub use transaction::{SpentTransaction, Transaction}; mod faults; -pub use faults::{Fault, Slash, SlashType, InvalidFault}; +pub use faults::{Fault, InvalidFault, Slash, SlashType}; mod attestation; pub use attestation::{ diff --git a/node/src/chain/acceptor.rs b/node/src/chain/acceptor.rs index f5b4b13fcc..059a2de667 100644 --- a/node/src/chain/acceptor.rs +++ b/node/src/chain/acceptor.rs @@ -29,7 +29,7 @@ use tokio::sync::RwLock; use tracing::{debug, info, warn}; use super::consensus::Task; -use crate::chain::header_validation::Validator; +use crate::chain::header_validation::{verify_faults, Validator}; use crate::chain::metrics::AverageElapsedTime; use crate::database::rocksdb::{ MD_AVG_PROPOSAL, MD_AVG_RATIFICATION, MD_AVG_VALIDATION, MD_HASH_KEY, @@ -451,12 +451,11 @@ impl Acceptor { // Persist block in consistency with the VM state update let (label, finalized) = { let header = blk.header(); + verify_faults(self.db.clone, header.height, blk.faults()).await?; let vm = self.vm.write().await; + let (txs, rolling_result) = self.db.read().await.update(|db| { - - // TODO: Verify Faults - let (txs, verification_output) = vm.accept(blk, Some(&prev_block_voters[..]))?;