Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,9 @@ mod tests {
Address::from_raw_public_key(&coinbase_key.public_key().serialize_uncompressed()[1..]);
let mut senders = keys
.iter()
.map(|key| Address::from_raw_public_key(&key.public_key().serialize_uncompressed()[1..]))
.map(|key| {
Address::from_raw_public_key(&key.public_key().serialize_uncompressed()[1..])
})
.collect::<Vec<_>>();
senders.push(coinbase);

Expand Down
2 changes: 1 addition & 1 deletion crates/firehose-tests/src/prestate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ pub fn parse_fire_block_for(raw: &[u8], block_number: u64) -> eyre::Result<Fireh
// Skip flash_idx, hash, prev_num, prev_hash, lib_num, ts_ns to reach payload (8th token,
// 0-indexed token #8 from the start of the line — i.e. the last token).
let payload =
parts.last().context("FIRE BLOCK line missing base64 payload (last token)")?;
parts.next_back().context("FIRE BLOCK line missing base64 payload (last token)")?;
let bytes = general_purpose::STANDARD
.decode(payload)
.context("base64-decoding FIRE BLOCK payload")?;
Expand Down
12 changes: 6 additions & 6 deletions crates/firehose-tests/tests/prestate.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! End-to-end Firehose integration tests driven by `prestate.json` fixtures.

use std::path::PathBuf;
use std::path::{Path, PathBuf};

use firehose_tracer::pb::sf::ethereum::r#type::v2::{CallType, TransactionTraceStatus};
use reth_firehose_tests::{assert_block_equals_golden, run_prestate};
Expand Down Expand Up @@ -77,10 +77,10 @@ fn amsterdam_block_access_list_hash_mismatch() {
/// the `EXCESS_INHIBITOR` sentinel to 0 — a storage change that belongs to no transaction.
///
/// Nothing in the Firehose code reaches for these calls specifically: they go through
/// `Evm::transact_system_call`, which the StreamingFast `alloy-evm` fork routes to the inspector,
/// inside the window `run_wrapped_block` already opens around `apply_post_execution_changes`. That
/// is exactly why the case is worth having — the coverage is incidental, so nothing would catch it
/// being lost.
/// `Evm::transact_system_call`, which evm2 routes to the inspector once system-call inspection is
/// on, inside the window `run_wrapped_block` already opens around `apply_post_execution_changes`.
/// That is exactly why the case is worth having — the coverage is incidental, so nothing would
/// catch it being lost.
///
/// The fixture stands the predeploys up with the EIP-7002 withdrawal-request runtime code. EIP-8282
/// does not publish its own bytecode in anything we depend on, and it specifies the same design:
Expand Down Expand Up @@ -137,6 +137,6 @@ fn case_dir(name: &str) -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests").join("cases").join(name)
}

fn golden_dir(case_dir: &PathBuf, name: &str) -> PathBuf {
fn golden_dir(case_dir: &Path, name: &str) -> PathBuf {
case_dir.join(name)
}
2 changes: 1 addition & 1 deletion crates/firehose/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub struct SynchronizedStdout {

impl SynchronizedStdout {
/// Creates a new `SynchronizedStdout` backed by the given lock.
pub fn new(lock: Arc<Mutex<()>>) -> Self {
pub const fn new(lock: Arc<Mutex<()>>) -> Self {
Self { lock }
}
}
Expand Down
29 changes: 13 additions & 16 deletions crates/firehose/src/mapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub(crate) fn to_genesis_alloc(genesis: &Genesis) -> GenesisAlloc {
*address,
firehose_tracer::types::GenesisAccount {
code: account.code.clone(),
balance: Some(account.balance.clone()),
balance: Some(account.balance),
nonce: account.nonce.unwrap_or_default(),
storage: map_genesis_storage(&account.storage),
},
Expand Down Expand Up @@ -128,7 +128,7 @@ where
/// finalized block's number/hash, if known.
///
/// Callers on the live engine path read this from the in-memory canonical state (updated by
/// forkchoiceUpdated); a `None` num_hash means no finalized head is known yet.
/// forkchoiceUpdated); a `None` `num_hash` means no finalized head is known yet.
pub fn finalized_ref_from_num_hash(
num_hash: Option<alloy_eips::BlockNumHash>,
) -> Option<firehose_tracer::types::FinalizedBlockRef> {
Expand Down Expand Up @@ -164,7 +164,7 @@ where
}
}

/// SignatureFields provides generic access to transaction signature (r, s, v) bytes.
/// `SignatureFields` provides generic access to transaction signature (r, s, v) bytes.
///
/// This trait is needed because reth's `SignedTransaction` does not expose a generic
/// `signature()` method — only concrete types like `EthereumTxEnvelope` have it.
Expand All @@ -184,7 +184,7 @@ where
let v = match self {
// Legacy without EIP-155: V = 27 or 28
// Legacy with EIP-155: V = chain_id * 2 + 35 + y_parity
EthereumTxEnvelope::Legacy(signed) => {
Self::Legacy(signed) => {
if let Some(chain_id) = signed.tx().chain_id {
chain_id * 2 + 35 + y_parity
} else {
Expand All @@ -202,14 +202,15 @@ where
}
}

/// Encodes a u64 as big-endian bytes with no leading zeros (matching go-ethereum big.Int.Bytes()).
/// Encodes a u64 as big-endian bytes with no leading zeros (matching go-ethereum
/// `big.Int.Bytes()`).
pub fn u64_to_trimmed_bytes(v: u64) -> Bytes {
let bytes = v.to_be_bytes();
let start = bytes.iter().position(|&b| b != 0).unwrap_or(8);
Bytes::copy_from_slice(&bytes[start..])
}

/// Converts a signed transaction to a firehose TxEvent.
/// Converts a signed transaction to a firehose `TxEvent`.
pub fn signed_tx_to_tx_event<Tx>(
tx: &Tx,
signer: Address,
Expand Down Expand Up @@ -238,11 +239,7 @@ where
r,
s,
v: Some(v),
max_fee_per_gas: if tx.is_dynamic_fee() {
Some(U256::from(tx.max_fee_per_gas()))
} else {
None
},
max_fee_per_gas: tx.is_dynamic_fee().then(|| U256::from(tx.max_fee_per_gas())),
max_priority_fee_per_gas: tx.max_priority_fee_per_gas().map(U256::from),
access_list: tx
.access_list()
Expand All @@ -265,10 +262,10 @@ where
}
}

/// Wraps a StateProviderBox to implement the firehose StateReader trait.
/// Wraps a `StateProviderBox` to implement the firehose `StateReader` trait.
///
/// StateProviderBox is Box<dyn StateProvider + Send + 'static>, so StateReaderAdapter
/// is automatically Send + 'static, satisfying the Box<dyn StateReader + Send> bound.
/// `StateProviderBox` is Box<dyn `StateProvider` + Send + 'static>, so `StateReaderAdapter`
/// is automatically Send + 'static, satisfying the Box<dyn `StateReader` + Send> bound.
pub struct StateReaderAdapter(pub StateProviderBox);

impl Debug for StateReaderAdapter {
Expand Down Expand Up @@ -326,10 +323,10 @@ pub fn receipt_data_from_parts(
receipt_data
}

/// Converts a receipt to a firehose ReceiptData.
/// Converts a receipt to a firehose `ReceiptData`.
///
/// - `tx_index`: 0-based index of this transaction in the block
/// - `gas_used`: gas consumed by this transaction alone (cumulative_gas - prev_cumulative_gas)
/// - `gas_used`: gas consumed by this transaction alone (`cumulative_gas` - `prev_cumulative_gas`)
/// - `log_index_start`: block-wide log index of the first log in this receipt
/// - `blob_gas_used`: total blob gas consumed by this tx (0 for non-EIP-4844 transactions)
/// - `blob_gas_price`: per-unit blob gas price from the block (None pre-Cancun)
Expand Down
7 changes: 4 additions & 3 deletions crates/firehose/src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ pub use alloy_primitives::{B256, U256};
// Other common imports
pub use eyre;

/// Type alias for RecoveredBlock that can be used with any Node that implements FullNodeComponents
/// Type alias for `RecoveredBlock` that can be used with any Node that implements
/// `FullNodeComponents`
pub type RecoveredBlock<Node> = reth_primitives_traits::RecoveredBlock<
<<<Node as reth_node_api::FullNodeTypes>::Types as reth_node_api::NodeTypes>::Primitives as reth_node_api::NodePrimitives>::Block,
>;

/// Type alias for ChainSpec that can be used with any Node that implements FullNodeComponents
/// Type alias for `ChainSpec` that can be used with any Node that implements `FullNodeComponents`
pub type ChainSpec<Node> =
<<Node as reth_node_api::FullNodeTypes>::Types as reth_node_api::NodeTypes>::ChainSpec;

/// Type alias for SignedTx from a Node primitives
/// Type alias for `SignedTx` from a Node primitives
pub type SignedTx<Node> =
<<<Node as reth_node_api::FullNodeTypes>::Types as reth_node_api::NodeTypes>::Primitives as reth_node_api::NodePrimitives>::SignedTx;

Expand Down
Loading