diff --git a/core/consensus/src/engine.rs b/core/consensus/src/engine.rs index 040acb50b..fc857d743 100644 --- a/core/consensus/src/engine.rs +++ b/core/consensus/src/engine.rs @@ -164,17 +164,28 @@ impl Engine for ConsensusEngine { + if !self + .node_info + .hardfork_proposals + .read() + .unwrap() + .as_ref() + .map(|v| &data == v) + .unwrap_or_default() + { + return Err(ProtocolError::from(ConsensusError::Hardfork( + "hardfork proposal doesn't match".to_string(), + )) + .into()); + } + } + Err(_) => { + return Err(ProtocolError::from(ConsensusError::Hardfork( + "hardfork proposal can't decode".to_string(), + )) + .into()) } } } diff --git a/core/consensus/src/lib.rs b/core/consensus/src/lib.rs index af7faf66a..270dcabc1 100644 --- a/core/consensus/src/lib.rs +++ b/core/consensus/src/lib.rs @@ -184,8 +184,8 @@ pub enum ConsensusError { #[display(fmt = "Build trie merkle tree error {}", _0)] BuildMerkle(String), - #[display(fmt = "Proposal hardfork info don't match")] - HardforkDontMatch, + #[display(fmt = "Proposal hardfork info error {}", _0)] + Hardfork(String), } #[derive(Debug, Display)]