From 7df983802eeb7e924afe8e6fb64843382831f334 Mon Sep 17 00:00:00 2001 From: Debjit Bhowal Date: Thu, 16 Jan 2025 21:14:15 +0530 Subject: [PATCH] Higher limit for total_difficulty.bit_len (#13820) --- crates/net/eth-wire/src/ethstream.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/net/eth-wire/src/ethstream.rs b/crates/net/eth-wire/src/ethstream.rs index ccc80594b..212fd8e46 100644 --- a/crates/net/eth-wire/src/ethstream.rs +++ b/crates/net/eth-wire/src/ethstream.rs @@ -158,12 +158,12 @@ where } // TD at mainnet block #7753254 is 76 bits. If it becomes 100 million times - // larger, it will still fit within 100 bits - if status.total_difficulty.bit_len() > 100 { + // larger, it will still fit within 160 bits + if status.total_difficulty.bit_len() > 160 { self.inner.disconnect(DisconnectReason::ProtocolBreach).await?; return Err(EthHandshakeError::TotalDifficultyBitLenTooLarge { got: status.total_difficulty.bit_len(), - maximum: 100, + maximum: 160, } .into()) } @@ -498,7 +498,7 @@ mod tests { let status = Status { version: EthVersion::Eth67, chain: NamedChain::Mainnet.into(), - total_difficulty: U256::from(2).pow(U256::from(100)), + total_difficulty: U256::from(2).pow(U256::from(164)), blockhash: B256::random(), genesis, // Pass the current fork id. @@ -522,7 +522,7 @@ mod tests { assert!(matches!( handshake_res, Err(EthStreamError::EthHandshakeError( - EthHandshakeError::TotalDifficultyBitLenTooLarge { got: 101, maximum: 100 } + EthHandshakeError::TotalDifficultyBitLenTooLarge { got: 165, maximum: 160 } )) )); }); @@ -539,7 +539,7 @@ mod tests { assert!(matches!( handshake_res, Err(EthStreamError::EthHandshakeError( - EthHandshakeError::TotalDifficultyBitLenTooLarge { got: 101, maximum: 100 } + EthHandshakeError::TotalDifficultyBitLenTooLarge { got: 165, maximum: 160 } )) ));