Skip to content
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

chore(trie): early return EMPTY_ROOT_HASH #10957

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions crates/rpc/rpc-types-compat/src/engine/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
use alloy_primitives::{B256, U256};
use reth_primitives::{
constants::{EMPTY_OMMER_ROOT_HASH, MAXIMUM_EXTRA_DATA_SIZE},
proofs::{self},
Block, Header, Request, SealedBlock, TransactionSigned, UintTryTo, Withdrawals,
proofs, Block, Header, Request, SealedBlock, TransactionSigned, Withdrawals,
};
use reth_rpc_types::engine::{
payload::{ExecutionPayloadBodyV1, ExecutionPayloadFieldV2, ExecutionPayloadInputV2},
Expand All @@ -25,7 +24,7 @@ pub fn try_payload_v1_to_block(payload: ExecutionPayloadV1) -> Result<Block, Pay

let transactions = payload
.transactions
.into_iter()
.iter()
.map(|tx| TransactionSigned::decode_enveloped(&mut tx.as_ref()))
.collect::<Result<Vec<_>, _>>()?;
let transactions_root = proofs::calculate_transaction_root(&transactions);
Expand All @@ -50,7 +49,7 @@ pub fn try_payload_v1_to_block(payload: ExecutionPayloadV1) -> Result<Block, Pay
base_fee_per_gas: Some(
payload
.base_fee_per_gas
.uint_try_to()
.try_into()
.map_err(|_| PayloadError::BaseFee(payload.base_fee_per_gas))?,
),
blob_gas_used: None,
Expand Down
4 changes: 4 additions & 0 deletions crates/trie/common/src/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ pub fn ordered_trie_root_with_encoder<T, F>(items: &[T], mut encode: F) -> B256
where
F: FnMut(&T, &mut Vec<u8>),
{
if items.is_empty() {
return alloy_trie::EMPTY_ROOT_HASH;
}

let mut value_buffer = Vec::new();

let mut hb = HashBuilder::default();
Expand Down
Loading