alloy-rs / trie

Fast Merkle-Patricia Trie (MPT) state root calculator and proof generator for prefix-sorted nibbles
Apache License 2.0
74 stars 26 forks source link

Empty proof for small trie #7

Open klkvr opened 5 months ago

klkvr commented 5 months ago

If trie consists of a single leaf node, no proofs would be collected if only non-existent prefixes are passed into proof retainer.

Example:

let mut builder =
    HashBuilder::default().with_proof_retainer(vec![Nibbles::from_nibbles(&[0x01])]);

builder.add_leaf(Nibbles::from_nibbles(&[0x00]), &[0x00]);

let _ = builder.root();

// Empty but should include root node
assert!(builder.take_proofs().is_empty());