From c8e5b233ef242c4c5eaebe6dc5ae66b98184d8a8 Mon Sep 17 00:00:00 2001 From: morito Date: Sun, 24 Nov 2024 20:08:30 +0900 Subject: [PATCH] Use `adjust_index_for_rlp` from alloy (#12815) --- crates/trie/common/src/root.rs | 11 ----------- crates/trie/trie/benches/trie_root.rs | 3 ++- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/crates/trie/common/src/root.rs b/crates/trie/common/src/root.rs index dbcbf4200..982dec988 100644 --- a/crates/trie/common/src/root.rs +++ b/crates/trie/common/src/root.rs @@ -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. diff --git a/crates/trie/trie/benches/trie_root.rs b/crates/trie/trie/benches/trie_root.rs index ad1699364..893e6e9e9 100644 --- a/crates/trie/trie/benches/trie_root.rs +++ b/crates/trie/trie/benches/trie_root.rs @@ -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::(receipts.iter().map(|receipt| {