reth_optimism_consensus/validation/
canyon.rs

1//! Canyon consensus rule checks.
2
3use alloy_consensus::BlockHeader;
4use alloy_trie::EMPTY_ROOT_HASH;
5use reth_consensus::ConsensusError;
6use reth_primitives_traits::GotExpected;
7
8/// Verifies that withdrawals root in block header (Shanghai) is always [`EMPTY_ROOT_HASH`] in
9/// Canyon.
10#[inline]
11pub fn ensure_empty_withdrawals_root<H: BlockHeader>(header: &H) -> Result<(), ConsensusError> {
12    // Shanghai rule
13    let header_withdrawals_root =
14        &header.withdrawals_root().ok_or(ConsensusError::WithdrawalsRootMissing)?;
15
16    //  Canyon rules
17    if *header_withdrawals_root != EMPTY_ROOT_HASH {
18        return Err(ConsensusError::BodyWithdrawalsRootDiff(
19            GotExpected { got: *header_withdrawals_root, expected: EMPTY_ROOT_HASH }.into(),
20        ));
21    }
22
23    Ok(())
24}