Use adjust_index_for_rlp from alloy (#12815)

This commit is contained in:
morito
2024-11-24 20:08:30 +09:00
committed by GitHub
parent 736edf70ad
commit c8e5b233ef
2 changed files with 2 additions and 12 deletions

View File

@ -7,17 +7,6 @@ use alloy_trie::HashBuilder;
use itertools::Itertools;
use nybbles::Nibbles;
/// Adjust the index of an item for rlp encoding.
pub const fn adjust_index_for_rlp(i: usize, len: usize) -> usize {
if i > 0x7f {
i
} else if i == 0x7f || i + 1 == len {
0
} else {
i + 1
}
}
/// Hashes and sorts account keys, then proceeds to calculating the root hash of the state
/// represented as MPT.
/// See [`state_root_unsorted`] for more info.

View File

@ -44,7 +44,8 @@ criterion_main!(benches);
mod implementations {
use super::*;
use alloy_rlp::Encodable;
use reth_trie_common::{root::adjust_index_for_rlp, HashBuilder, Nibbles};
use alloy_trie::root::adjust_index_for_rlp;
use reth_trie_common::{HashBuilder, Nibbles};
pub fn trie_hash_ordered_trie_root(receipts: &[ReceiptWithBloom]) -> B256 {
triehash::ordered_trie_root::<KeccakHasher, _>(receipts.iter().map(|receipt| {