mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Higher limit for total_difficulty.bit_len (#13820)
This commit is contained in:
@ -158,12 +158,12 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TD at mainnet block #7753254 is 76 bits. If it becomes 100 million times
|
// TD at mainnet block #7753254 is 76 bits. If it becomes 100 million times
|
||||||
// larger, it will still fit within 100 bits
|
// larger, it will still fit within 160 bits
|
||||||
if status.total_difficulty.bit_len() > 100 {
|
if status.total_difficulty.bit_len() > 160 {
|
||||||
self.inner.disconnect(DisconnectReason::ProtocolBreach).await?;
|
self.inner.disconnect(DisconnectReason::ProtocolBreach).await?;
|
||||||
return Err(EthHandshakeError::TotalDifficultyBitLenTooLarge {
|
return Err(EthHandshakeError::TotalDifficultyBitLenTooLarge {
|
||||||
got: status.total_difficulty.bit_len(),
|
got: status.total_difficulty.bit_len(),
|
||||||
maximum: 100,
|
maximum: 160,
|
||||||
}
|
}
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
@ -498,7 +498,7 @@ mod tests {
|
|||||||
let status = Status {
|
let status = Status {
|
||||||
version: EthVersion::Eth67,
|
version: EthVersion::Eth67,
|
||||||
chain: NamedChain::Mainnet.into(),
|
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(),
|
blockhash: B256::random(),
|
||||||
genesis,
|
genesis,
|
||||||
// Pass the current fork id.
|
// Pass the current fork id.
|
||||||
@ -522,7 +522,7 @@ mod tests {
|
|||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
handshake_res,
|
handshake_res,
|
||||||
Err(EthStreamError::EthHandshakeError(
|
Err(EthStreamError::EthHandshakeError(
|
||||||
EthHandshakeError::TotalDifficultyBitLenTooLarge { got: 101, maximum: 100 }
|
EthHandshakeError::TotalDifficultyBitLenTooLarge { got: 165, maximum: 160 }
|
||||||
))
|
))
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
@ -539,7 +539,7 @@ mod tests {
|
|||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
handshake_res,
|
handshake_res,
|
||||||
Err(EthStreamError::EthHandshakeError(
|
Err(EthStreamError::EthHandshakeError(
|
||||||
EthHandshakeError::TotalDifficultyBitLenTooLarge { got: 101, maximum: 100 }
|
EthHandshakeError::TotalDifficultyBitLenTooLarge { got: 165, maximum: 160 }
|
||||||
))
|
))
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user