mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: pass generic header and body to validate_shanghai_withdrawals (#12923)
This commit is contained in:
@ -19,6 +19,7 @@ reth-consensus.workspace = true
|
||||
# ethereum
|
||||
alloy-primitives.workspace = true
|
||||
revm-primitives.workspace = true
|
||||
reth-primitives-traits.workspace = true
|
||||
alloy-consensus.workspace = true
|
||||
alloy-eips.workspace = true
|
||||
|
||||
|
||||
@ -41,15 +41,16 @@ pub fn validate_header_base_fee<H: BlockHeader, ChainSpec: EthereumHardforks>(
|
||||
///
|
||||
/// [EIP-4895]: https://eips.ethereum.org/EIPS/eip-4895
|
||||
#[inline]
|
||||
pub fn validate_shanghai_withdrawals(block: &SealedBlock) -> Result<(), ConsensusError> {
|
||||
let withdrawals =
|
||||
block.body.withdrawals.as_ref().ok_or(ConsensusError::BodyWithdrawalsMissing)?;
|
||||
pub fn validate_shanghai_withdrawals<H: BlockHeader, B: reth_primitives_traits::BlockBody>(
|
||||
block: &SealedBlock<H, B>,
|
||||
) -> Result<(), ConsensusError> {
|
||||
let withdrawals = block.body.withdrawals().ok_or(ConsensusError::BodyWithdrawalsMissing)?;
|
||||
let withdrawals_root = reth_primitives::proofs::calculate_withdrawals_root(withdrawals);
|
||||
let header_withdrawals_root =
|
||||
block.withdrawals_root.as_ref().ok_or(ConsensusError::WithdrawalsRootMissing)?;
|
||||
block.withdrawals_root().ok_or(ConsensusError::WithdrawalsRootMissing)?;
|
||||
if withdrawals_root != *header_withdrawals_root {
|
||||
return Err(ConsensusError::BodyWithdrawalsRootDiff(
|
||||
GotExpected { got: withdrawals_root, expected: *header_withdrawals_root }.into(),
|
||||
GotExpected { got: withdrawals_root, expected: header_withdrawals_root }.into(),
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user