Open ufoscout opened 5 months ago
cc @rkrasiuk @klkvr
Should we also add these helpers in this crate?
I'm hitting this too, here's a simpler repro:
let mut builder = alloy_trie::HashBuilder::default();
for i in [0x01, 0x02, 0x80] {
let nibbles = alloy_trie::Nibbles::unpack([i]);
builder.add_leaf(nibbles, &[])
}
builder.root(); // boom
alloy-trie = "0.4.1"
thread 'main' panicked at /../alloy-trie-0.4.1/src/nodes/branch.rs:164:35:
cannot convert a slice of length 21 to FixedBytes<32>
stack backtrace:
0: rust_begin_unwind
at /rustc/../library/std/src/panicking.rs:652:5
1: core::panicking::panic_fmt
at /rustc/../library/core/src/panicking.rs:72:14
2: alloy_primitives::bits::fixed::FixedBytes<_>::from_slice
at /../alloy-primitives-0.7.7/src/bits/fixed.rs:476:23
3: alloy_trie::nodes::branch::BranchNodeRef::child_hashes
at /../alloy-trie-0.4.1/src/nodes/branch.rs:164:35
4: alloy_trie::hash_builder::HashBuilder::push_branch_node
at /../alloy-trie-0.4.1/src/hash_builder/mod.rs:314:24
5: alloy_trie::hash_builder::HashBuilder::update
at /../alloy-trie-0.4.1/src/hash_builder/mod.rs:279:32
6: alloy_trie::hash_builder::HashBuilder::root
at /../alloy-trie-0.4.1/src/hash_builder/mod.rs:137:13
7: sketchbook::main
at ./src/main.rs:7:5
I am trying to replace
triehash::ordered_trie_root
with an equivalent function based onalloy-trie
. Even if it works pretty well, sometimesalloy-trie
panics with acannot convert a slice of length 29 to FixedBytes<32>
error. Here is a complete reproducer for the issue: