diff --git a/crates/mpt/src/node.rs b/crates/mpt/src/node.rs index 6e4ad49d..d10bf446 100644 --- a/crates/mpt/src/node.rs +++ b/crates/mpt/src/node.rs @@ -109,7 +109,7 @@ impl TrieNode { } /// Returns the commitment of a [TrieNode::Blinded] node, if `self` is of the - /// [TrieNode::Blinded] variant. + /// [TrieNode::Blinded] or [TrieNode::Empty] variants. /// /// ## Returns /// - `Some(B256)` - The commitment of the blinded node @@ -117,6 +117,7 @@ impl TrieNode { pub const fn blinded_commitment(&self) -> Option { match self { Self::Blinded { commitment } => Some(*commitment), + Self::Empty => Some(EMPTY_ROOT_HASH), _ => None, } } @@ -681,6 +682,12 @@ mod test { use alloy_trie::{HashBuilder, Nibbles}; use rand::prelude::SliceRandom; + #[test] + fn test_empty_blinded() { + let trie_node = TrieNode::Empty; + assert_eq!(trie_node.blinded_commitment().unwrap(), EMPTY_ROOT_HASH); + } + #[test] fn test_decode_branch() { const BRANCH_RLP: [u8; 83] = hex!("f851a0eb08a66a94882454bec899d3e82952dcc918ba4b35a09a84acd98019aef4345080808080808080a05d87a81d9bbf5aee61a6bfeab3a5643347e2c751b36789d988a5b6b163d496518080808080808080");