-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
trie panics with cannot convert a slice of length 29 to FixedBytes<32>
with small data
#9
Comments
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"
|
6 tasks
This was referenced Aug 13, 2024
let key = load_infura_key_from_env();
println!("Key: {}", key);
let rpc_url = "https://mainnet.infura.io/v3/".to_string() + &key;
let provider = Provider::try_from(rpc_url).expect("Failed to construct provider!");
let block_hash = "0x8230bd00f36e52e68dd4a46bfcddeceacbb689d808327f4c76dbdf8d33d58ca8";
//let untrusted_hash = "0xacb81623523bbabccb1638a907686bc2f3229c70e3ab51777bef0a635f3ac03f";
let block = provider
.get_block_with_txs(H256::from_str(block_hash).unwrap())
.await
.expect("Failed to get Block!")
.expect("Block not found!");
let mut builder = alloy_trie::HashBuilder::default();
for (index, tx) in block.transactions.iter().enumerate() {
let bytes = alloy_rlp::encode(index);
println!("bytes: {:?}", &bytes);
let nibbles = alloy_trie::Nibbles::unpack(bytes);
println!("Nibbles: {:?}", &nibbles);
builder.add_leaf(nibbles, &tx.rlp())
}
let root = builder.root();
println!("Root: {:?}", &root);
println!("Expected Root: {:?}", &block.transactions_root); I'm having a hard time verifying the transaction trie root, can you help :)? |
@jonas089 all indexes need to be adjusted by calling Lines 8 to 17 in 25c252f
e.g. Lines 33 to 38 in afc50b7
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:The text was updated successfully, but these errors were encountered: