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
3 changes: 2 additions & 1 deletion src/retrieval/failure.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: 2025 Semiotic AI, Inc.
// SPDX-FileCopyrightText: 2026 Joseph Livesey <jlivesey@gmail.com>
//
// SPDX-License-Identifier: Apache-2.0

Expand Down Expand Up @@ -91,7 +92,7 @@ pub(crate) fn lookup_request_failed(
error: TransportError,
) -> RetrievalError {
RetrievalError::Rpc(crate::errors::RpcError::request_failed(
format!("{operation}({tx_hash})", operation = stage.operation_name()),
format!("{stage}({tx_hash})"),
error,
))
}
Expand Down
22 changes: 22 additions & 0 deletions src/retrieval/types.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// SPDX-FileCopyrightText: 2025 Semiotic AI, Inc.
// SPDX-FileCopyrightText: 2026 Joseph Livesey <jlivesey@gmail.com>
//
// SPDX-License-Identifier: Apache-2.0

//! Data types for combined gas and amount retrieval

use std::fmt;

use alloy_chains::NamedChain;
use alloy_primitives::{Address, BlockNumber, TxHash, U256};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -48,6 +51,7 @@ pub enum CombinedDataLookupStage {
}

impl CombinedDataLookupStage {
/// Stable RPC operation label used in logs and operator-facing errors.
#[must_use]
pub const fn operation_name(self) -> &'static str {
match self {
Expand All @@ -57,6 +61,12 @@ impl CombinedDataLookupStage {
}
}

impl fmt::Display for CombinedDataLookupStage {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str((*self).operation_name())
}
}

/// Which pass produced a lookup error while enriching a decoded transfer log.
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
pub enum CombinedDataLookupPass {
Expand Down Expand Up @@ -249,6 +259,18 @@ mod tests {
}
}

#[test]
fn test_combined_lookup_stage_display_matches_rpc_operation_name() {
assert_eq!(
CombinedDataLookupStage::Transaction.to_string(),
"get_transaction_by_hash"
);
assert_eq!(
CombinedDataLookupStage::Receipt.to_string(),
"get_transaction_receipt"
);
}

#[test]
fn test_total_gas_cost_basic() {
// Test basic calculation with L2 gas only
Expand Down