From 3917f0c9f482271ce4daf30525abbab1d7c8877a Mon Sep 17 00:00:00 2001 From: driftluo Date: Thu, 21 Sep 2023 10:02:02 +0800 Subject: [PATCH] dirty data in extra data is not allowed --- core/consensus/src/engine.rs | 33 ++++++++++++++++++++++----------- core/consensus/src/lib.rs | 4 ++-- 2 files changed, 24 insertions(+), 13 deletions(-) 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)]