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(rpc): remove use of extensible transaction + receipt types #9774

Merged
merged 114 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
64777ff
Add EthApiTypes with error as AT and helper traits for conversion fro…
emhane Jul 17, 2024
2f9b4d4
Make it possible to reference EthApiTypes via EthApiServer helper traits
emhane Jul 18, 2024
494b3d9
Fix rpc API impls
emhane Jul 18, 2024
e05fd6f
Merge branch 'main' into emhane/rpc-error
emhane Jul 18, 2024
916e509
Fix OpEthApi impl
emhane Jul 18, 2024
f1d02a7
Merge branch 'main' into emhane/rpc-error
emhane Jul 24, 2024
09a4192
Merge branch 'main' into emhane/rpc-error
emhane Jul 24, 2024
20fae32
Extend EthApiTypes with alloy_network::Network AT
emhane Jul 24, 2024
ade6b8f
Merge branch 'emhane/rpc-error' into emhane/ethapi-types
emhane Jul 24, 2024
8a631dc
Merge branch 'main' into emhane/ethapi-types
emhane Jul 26, 2024
83bd53b
Import OP rpc types from op-alloy-network
emhane Jul 26, 2024
ad29246
Rename EthApiTypes::Types to EthApiTypes::NetworkTypes
emhane Jul 26, 2024
6bd0f60
Remove optimism feature from reth-rpc-types-compat lib
emhane Jul 26, 2024
e248a65
Incorporate TransactionBuilder into EthTransactions
emhane Jul 26, 2024
624e938
Revert unrelated change
emhane Jul 27, 2024
91ace3a
Fix conflicts from making rpc comapt generic over network for transac…
emhane Jul 27, 2024
c506e8e
Add trait for building rpc block response
emhane Jul 27, 2024
0860e1c
Add adapter for network type builders to EthApi and OpEthApi
emhane Jul 27, 2024
f48038e
Fix conflicts, resp ty has non-unique builder
emhane Jul 29, 2024
91fe6e0
Merge branch 'main' into emhane/ethapi-types
emhane Aug 1, 2024
b052000
Add generics to EthApi trait that are compatible with jsonrpsee
emhane Aug 1, 2024
359eae7
Add temp constraint Network::TransactionResponse = reth_rpc_types::Tr…
emhane Aug 1, 2024
e12d811
Replace EthFilterApi and EthPubSubApi generics with jsonrpsee compati…
emhane Aug 1, 2024
fa58787
Fix lint
emhane Aug 1, 2024
ce48b0f
Merge branch 'main' into emhane/ethapi-types
emhane Aug 2, 2024
4e1d95f
Remove redundant trait bounds
emhane Aug 2, 2024
d859c5e
Flatten trait ResponseTypeBuilders into EthApiTypes
emhane Aug 2, 2024
b733699
Remove duplicate file
emhane Aug 2, 2024
179bd6b
Add noop impl for EthApiTypes
emhane Aug 2, 2024
626c877
Add EthApiTypes trait bounds to node builder
emhane Aug 2, 2024
f24dee5
fixup! Flatten trait ResponseTypeBuilders into EthApiTypes
emhane Aug 2, 2024
34c56e6
Fix tests
emhane Aug 2, 2024
fe0297f
Fix optimism crates
emhane Aug 2, 2024
f7c7206
Set explicit Ethereum network for reth_e2e_test_utils::TransactionTes…
emhane Aug 2, 2024
75ff7da
Fix docs
emhane Aug 2, 2024
de9f909
Merge branch 'main' into emhane/ethapi-types
emhane Aug 3, 2024
43f6808
Remove redundant autotrait impls for EthApi
emhane Aug 3, 2024
57995de
Remove redundant attribute
emhane Aug 3, 2024
b62ec37
Make generic naming unfiorm
emhane Aug 3, 2024
7e11a17
Merge branch 'main' into emhane/ethapi-types
emhane Aug 5, 2024
1cb4f44
Merge branch 'main' into emhane/ethapi-types
emhane Aug 5, 2024
a499898
Merge branch 'main' into emhane/ethapi-types
emhane Aug 8, 2024
7121475
Merge branch 'main' into emhane/ethapi-types
emhane Aug 14, 2024
474367c
Merge branch 'main' into emhane/ethapi-types
emhane Aug 15, 2024
1b8197f
Remove trait bound TransactionBuilder on EthApiTypes::TransationBuilder
emhane Aug 15, 2024
61ce9bf
Merge branch 'main' into emhane/ethapi-types
emhane Aug 20, 2024
a186867
fixup! Remove trait bound TransactionBuilder on EthApiTypes::Transati…
emhane Aug 20, 2024
a784b7a
Fix lint
emhane Aug 20, 2024
856f37e
Rename TransactionBuilder to TransactionCompat
emhane Aug 20, 2024
9d911bb
Rename BlockBuilder to BlockCompat
emhane Aug 21, 2024
2bb8a75
Delay trait bound for EthApiTypes::BlockCompat
emhane Aug 21, 2024
e5b47e8
Merge branch 'main' into emhane/ethapi-types
emhane Aug 21, 2024
b6a2cc9
Remove EthApiTypes::BlockCompat
emhane Aug 21, 2024
9705100
Fix lint
emhane Aug 21, 2024
729716e
Merge branch 'emhane/fix-lint' into emhane/ethapi-types
emhane Aug 21, 2024
a5d95bd
Fix lint
emhane Aug 21, 2024
16cc68e
Fix docs
emhane Aug 21, 2024
a0a2f35
Checkout EthApiTypes::NetworkTypes from emhane/ethapi-types
emhane Aug 21, 2024
e991d9e
Merge branch 'emhane/ethapi-networktypes' into emhane/ethapi-types
emhane Aug 21, 2024
2d6d702
Shrink scope of TransactionCompat trait
emhane Aug 21, 2024
443e9b2
Rename reth_rpc_eth_api::Transaction to RpcTransaction
emhane Aug 22, 2024
fe2bf75
Move crates/rpc/rpc-eth-api/src/helpers/types.rs up one dir
emhane Aug 22, 2024
02b38c7
Update docs
emhane Aug 22, 2024
689c67c
Merge branch 'main' into emhane/ethapi-networktypes
emhane Aug 22, 2024
46bad2e
Fix lint
emhane Aug 22, 2024
d50649e
Merge branch 'emhane/ethapi-networktypes' into emhane/ethapi-types
emhane Aug 22, 2024
64facc7
Merge branch 'main' into emhane/ethapi-types
emhane Aug 22, 2024
5e09011
Revert unrelated change
emhane Aug 22, 2024
148d4e3
Fix lint
emhane Aug 22, 2024
406848d
Merge branch 'main' into emhane/ethapi-types
emhane Aug 24, 2024
145b71d
Merge branch 'main' into emhane/ethapi-types
emhane Sep 6, 2024
07f2e9f
Fix merge conflicts
emhane Sep 6, 2024
cc4dddc
Merge branch 'main' into emhane/ethapi-types
emhane Sep 8, 2024
2dff25a
Fix merge conflicts
emhane Sep 8, 2024
963dab3
Define type reth_optimism_rpc::OpReceiptBuilder
emhane Sep 9, 2024
4ff2ab2
Merge branch 'emhane/op-receipt' into emhane/ethapi-types
emhane Sep 9, 2024
ecddc97
Move EthBlocks::block_receipts default impl to impl for EthApi
emhane Sep 9, 2024
a0b5cfd
Move LoadReceipt::build_transaction_receipt default impl to impl for …
emhane Sep 9, 2024
2d735fa
Merge branch 'emhane/mv-block-receipts' into emhane/ethapi-types
emhane Sep 9, 2024
7d53b1b
Merge branch 'emhane/mv-build-tx-receipt' into emhane/ethapi-types
emhane Sep 9, 2024
b6ad116
Merge branch 'main' into emhane/ethapi-types
emhane Sep 11, 2024
30bd98e
Fix merge conflicts
emhane Sep 11, 2024
00c5adc
Merge branch 'main' into emhane/ethapi-types
emhane Sep 11, 2024
3187093
Merge branch 'main' into emhane/ethapi-types
emhane Sep 11, 2024
79de341
Revert formatting changes
emhane Sep 11, 2024
604df14
Add helper trait FullEthApiTypes linking EthApiTypes::NetworkTypes to…
emhane Sep 11, 2024
68d5c9a
Fix merge conflicts
emhane Sep 11, 2024
3841450
Revert formatting changes
emhane Sep 11, 2024
1756510
Revert formatting changes
emhane Sep 11, 2024
3c1b2cd
Revert bad formatting changes
emhane Sep 11, 2024
472a338
Remove redundant trait bound on RPC transaction response type
emhane Sep 11, 2024
509939f
Bump deps
emhane Sep 13, 2024
fd4d588
Merge branch 'emhane/bump-deps' into emhane/ethapi-types
emhane Sep 13, 2024
dd61e57
Fix lint
emhane Sep 13, 2024
769fb0a
Merge branch 'main' into emhane/ethapi-types
emhane Sep 16, 2024
237a78a
Fix conflicts eth filter API
emhane Sep 16, 2024
461e7a7
Fix conflicts eth pubsub API
emhane Sep 16, 2024
89ba917
Fix conflicts rpc builder
emhane Sep 16, 2024
011b80b
Fix conflicts tx pool API
emhane Sep 16, 2024
87f8f51
Fix conflicts otterscan API
emhane Sep 16, 2024
15112eb
Fix conflicts optimism
emhane Sep 16, 2024
4794fd4
Fix lint
emhane Sep 16, 2024
a430d61
Fix lint
emhane Sep 16, 2024
e51f52a
Remove completed todos
emhane Sep 16, 2024
67d4ba8
Revert unrelated changes
emhane Sep 16, 2024
a3c203b
Merge branch 'main' into emhane/ethapi-types
emhane Sep 18, 2024
d24e7f5
Merge branch 'main' into emhane/ethapi-types
emhane Sep 18, 2024
9ccf619
Update docs
emhane Sep 19, 2024
dc7d4d1
Add lost code comment
emhane Sep 19, 2024
a625312
Add todo
emhane Sep 19, 2024
5555173
Merge branch 'main' into emhane/ethapi-types
emhane Sep 19, 2024
614cb7f
Fix merge conflicts
emhane Sep 19, 2024
2c6bb1d
Fix merge conflicts
emhane Sep 19, 2024
16dc6df
Merge branch 'main' into emhane/ethapi-types
emhane Sep 20, 2024
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
5 changes: 5 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion bin/reth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ optimism = [
"reth-blockchain-tree/optimism",
"dep:reth-node-optimism",
"reth-node-core/optimism",
"reth-rpc-eth-types/optimism",
]

# no-op feature flag for switching between the `optimism` and default functionality in CI matrices
Expand Down
11 changes: 4 additions & 7 deletions crates/e2e-test-utils/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ use alloy_consensus::TxEnvelope;
use alloy_network::eip2718::Decodable2718;
use reth::{
builder::{rpc::RpcRegistry, FullNodeComponents},
rpc::{
api::{
eth::helpers::{EthApiSpec, EthTransactions, TraceExt},
DebugApiServer,
},
server_types::eth::EthResult,
rpc::api::{
eth::helpers::{EthApiSpec, EthTransactions, TraceExt},
DebugApiServer,
},
};
use reth_primitives::{Bytes, B256};
Expand All @@ -21,7 +18,7 @@ where
EthApi: EthApiSpec + EthTransactions + TraceExt,
{
/// Injects a raw transaction into the node tx pool via RPC server
pub async fn inject_tx(&mut self, raw_tx: Bytes) -> EthResult<B256> {
pub async fn inject_tx(&mut self, raw_tx: Bytes) -> Result<B256, EthApi::Error> {
let eth_api = self.inner.eth_api();
eth_api.send_raw_transaction(raw_tx).await
}
Expand Down
1 change: 0 additions & 1 deletion crates/node/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ optimism = [
"reth-provider/optimism",
"reth-rpc-types-compat/optimism",
"reth-rpc-eth-api/optimism",
"reth-rpc-eth-types/optimism",
]

jemalloc = ["dep:tikv-jemalloc-ctl"]
Expand Down
1 change: 0 additions & 1 deletion crates/optimism/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ optimism = [
"reth-beacon-consensus/optimism",
"reth-revm/optimism",
"reth-auto-seal-consensus/optimism",
"reth-rpc-eth-types/optimism",
"reth-optimism-rpc/optimism"
]
test-utils = ["reth-node-builder/test-utils"]
6 changes: 5 additions & 1 deletion crates/optimism/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ repository.workspace = true
description = "OP primitive types"

[lints]
workspace = true
workspace = true

[dependencies]
# ethereum
alloy-network.workspace = true
1 change: 1 addition & 0 deletions crates/optimism/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

pub mod bedrock_import;
pub mod types;
6 changes: 6 additions & 0 deletions crates/optimism/primitives/src/types.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use alloy_network::Network;

#[derive(Debug, Clone, Copy)]
pub struct Optimism;

impl Network for Optimism {}
emhane marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion crates/optimism/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ tokio.workspace = true

# rpc
jsonrpsee.workspace = true
jsonrpsee-types.workspace = true

# misc
thiserror.workspace = true
Expand All @@ -59,6 +60,5 @@ optimism = [
"reth-primitives/optimism",
"reth-provider/optimism",
"reth-rpc-eth-api/optimism",
"reth-rpc-eth-types/optimism",
"revm/optimism"
]
66 changes: 59 additions & 7 deletions crates/optimism/rpc/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,83 @@
//! RPC errors specific to OP.

use jsonrpsee::types::ErrorObject;
use reth_primitives::revm_primitives::{InvalidTransaction, OptimismInvalidTransaction};
use reth_rpc_eth_api::AsEthApiError;
use reth_rpc_eth_types::EthApiError;
use reth_rpc_server_types::result::internal_rpc_err;
use reth_rpc_types::ToRpcError;
use reth_rpc_server_types::result::{internal_rpc_err, rpc_err};
use reth_rpc_types::{error::EthRpcErrorCode, IntoRpcError};

/// Optimism specific errors, that extend [`EthApiError`].
#[derive(Debug, thiserror::Error)]
pub enum OpEthApiError {
/// L1 ethereum error.
#[error(transparent)]
Core(#[from] EthApiError),
/// Thrown when calculating L1 gas fee.
#[error("failed to calculate l1 gas fee")]
L1BlockFeeError,
/// Thrown when calculating L1 gas used
#[error("failed to calculate l1 gas used")]
L1BlockGasError,
/// Wrapper for [`revm_primitives::InvalidTransaction`](InvalidTransaction).
#[error(transparent)]
InvalidTransaction(OptimismInvalidTransactionError),
}

impl ToRpcError for OpEthApiError {
fn to_rpc_error(&self) -> ErrorObject<'static> {
impl IntoRpcError for OpEthApiError {
fn into_rpc_err(self) -> ErrorObject<'static> {
match self {
Self::Core(err) => err.into_rpc_err(),
Self::L1BlockFeeError | Self::L1BlockGasError => internal_rpc_err(self.to_string()),
Self::InvalidTransaction(err) => err.into_rpc_err(),
}
}
}

impl From<OpEthApiError> for EthApiError {
fn from(err: OpEthApiError) -> Self {
Self::other(err)
impl AsEthApiError for OpEthApiError {
fn as_err(&self) -> Option<&EthApiError> {
match self {
Self::Core(err) => Some(err),
_ => None,
}
}
}

/// Optimism specific invalid transaction errors
#[derive(thiserror::Error, Debug)]
pub enum OptimismInvalidTransactionError {
/// A deposit transaction was submitted as a system transaction post-regolith.
#[error("no system transactions allowed after regolith")]
DepositSystemTxPostRegolith,
/// A deposit transaction halted post-regolith
#[error("deposit transaction halted after regolith")]
HaltedDepositPostRegolith,
}

impl IntoRpcError for OptimismInvalidTransactionError {
fn into_rpc_err(self) -> jsonrpsee_types::error::ErrorObject<'static> {
match self {
Self::DepositSystemTxPostRegolith | Self::HaltedDepositPostRegolith => {
rpc_err(EthRpcErrorCode::TransactionRejected.code(), self.to_string(), None)
}
}
}
}

impl TryFrom<InvalidTransaction> for OptimismInvalidTransactionError {
type Error = InvalidTransaction;

fn try_from(err: InvalidTransaction) -> Result<Self, Self::Error> {
match err {
InvalidTransaction::OptimismError(err) => match err {
OptimismInvalidTransaction::DepositSystemTxPostRegolith => {
Ok(Self::DepositSystemTxPostRegolith)
}
OptimismInvalidTransaction::HaltedDepositPostRegolith => {
Ok(Self::HaltedDepositPostRegolith)
}
},
_ => Err(err),
}
}
}
19 changes: 12 additions & 7 deletions crates/optimism/rpc/src/eth/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

use reth_primitives::TransactionMeta;
use reth_provider::{BlockReaderIdExt, HeaderProvider};
use reth_rpc_eth_api::helpers::{EthApiSpec, EthBlocks, LoadBlock, LoadReceipt, LoadTransaction};
use reth_rpc_eth_types::{EthResult, EthStateCache, ReceiptBuilder};
use reth_rpc_eth_api::{
helpers::{EthApiSpec, EthBlocks, LoadBlock, LoadReceipt, LoadTransaction},
FromEthApiError,
};
use reth_rpc_eth_types::{EthStateCache, ReceiptBuilder};
use reth_rpc_types::{AnyTransactionReceipt, BlockId};

use crate::{op_receipt_fields, OpEthApi};
Expand All @@ -19,7 +22,7 @@ where
async fn block_receipts(
&self,
block_id: BlockId,
) -> EthResult<Option<Vec<AnyTransactionReceipt>>>
) -> Result<Option<Vec<AnyTransactionReceipt>>, Self::Error>
where
Self: LoadReceipt,
{
Expand Down Expand Up @@ -52,11 +55,13 @@ where
let optimism_tx_meta =
self.build_op_tx_meta(tx, l1_block_info.clone(), timestamp)?;

ReceiptBuilder::new(tx, meta, receipt, &receipts).map(|builder| {
op_receipt_fields(builder, tx, receipt, optimism_tx_meta).build()
})
ReceiptBuilder::new(tx, meta, receipt, &receipts)
.map(|builder| {
op_receipt_fields(builder, tx, receipt, optimism_tx_meta).build()
})
.map_err(Self::Error::from_err)
})
.collect::<EthResult<Vec<_>>>();
.collect::<Result<Vec<_>, Self::Error>>();
return receipts.map(Some)
}

Expand Down
19 changes: 14 additions & 5 deletions crates/optimism/rpc/src/eth/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@ use reth_primitives::{
revm_primitives::{BlockEnv, OptimismFields, TxEnv},
Bytes,
};
use reth_rpc_eth_api::helpers::Call;
use reth_rpc_eth_types::EthResult;
use reth_rpc_eth_api::{
helpers::{Call, EthCall},
EthApiTypes, FromEthApiError,
};
use reth_rpc_eth_types::EthApiError;
use reth_rpc_types::TransactionRequest;

use crate::OpEthApi;

impl<Eth: Call> Call for OpEthApi<Eth> {
impl<Eth: EthCall> EthCall for OpEthApi<Eth> where EthApiError: From<Eth::Error> {}

impl<Eth: Call + EthApiTypes> Call for OpEthApi<Eth>
where
EthApiError: From<Eth::Error>,
{
fn call_gas_limit(&self) -> u64 {
self.inner.call_gas_limit()
}
Expand All @@ -22,8 +30,9 @@ impl<Eth: Call> Call for OpEthApi<Eth> {
&self,
block_env: &BlockEnv,
request: TransactionRequest,
) -> EthResult<TxEnv> {
let mut env = Eth::create_txn_env(&self.inner, block_env, request)?;
) -> Result<TxEnv, Self::Error> {
let mut env =
self.inner.create_txn_env(block_env, request).map_err(Self::Error::from_err)?;

env.optimism = OptimismFields { enveloped_tx: Some(Bytes::new()), ..Default::default() };

Expand Down
17 changes: 12 additions & 5 deletions crates/optimism/rpc/src/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ use reth_provider::{BlockReaderIdExt, ChainSpecProvider, HeaderProvider, StatePr
use reth_rpc::eth::DevSigner;
use reth_rpc_eth_api::{
helpers::{
AddDevSigners, EthApiSpec, EthCall, EthFees, EthSigner, EthState, LoadFee, LoadState,
SpawnBlocking, Trace, UpdateRawTxForwarder,
AddDevSigners, EthApiSpec, EthFees, EthSigner, EthState, LoadFee, LoadState, SpawnBlocking,
Trace, UpdateRawTxForwarder,
},
RawTransactionForwarder,
EthApiTypes, RawTransactionForwarder,
};
use reth_rpc_eth_types::EthStateCache;
use reth_rpc_types::SyncStatus;
use reth_tasks::{pool::BlockingTaskPool, TaskSpawner};
use reth_transaction_pool::TransactionPool;
use tokio::sync::{AcquireError, OwnedSemaphorePermit};

use crate::OpEthApiError;

/// OP-Reth `Eth` API implementation.
///
/// This type provides the functionality for handling `eth_` related requests.
Expand All @@ -51,6 +53,13 @@ impl<Eth> OpEthApi<Eth> {
}
}

impl<Eth> EthApiTypes for OpEthApi<Eth>
where
Eth: Send + Sync,
{
type Error = OpEthApiError;
}

impl<Eth: EthApiSpec> EthApiSpec for OpEthApi<Eth> {
fn protocol_version(&self) -> impl Future<Output = RethResult<U64>> + Send {
self.inner.protocol_version()
Expand Down Expand Up @@ -142,8 +151,6 @@ impl<Eth: EthState> EthState for OpEthApi<Eth> {
}
}

impl<Eth: EthCall> EthCall for OpEthApi<Eth> {}

impl<Eth: EthFees> EthFees for OpEthApi<Eth> {}

impl<Eth: Trace> Trace for OpEthApi<Eth> {
Expand Down
17 changes: 11 additions & 6 deletions crates/optimism/rpc/src/eth/receipt.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
//! Loads and formats OP receipt RPC response.

use reth_primitives::{Receipt, TransactionMeta, TransactionSigned};
use reth_rpc_eth_api::helpers::{EthApiSpec, LoadReceipt, LoadTransaction};
use reth_rpc_eth_types::{EthApiError, EthResult, EthStateCache, ReceiptBuilder};
use reth_rpc_eth_api::{
helpers::{EthApiSpec, LoadReceipt, LoadTransaction},
FromEthApiError,
};
use reth_rpc_eth_types::{EthApiError, EthStateCache, ReceiptBuilder};
use reth_rpc_types::{AnyTransactionReceipt, OptimismTransactionReceiptFields};

use crate::{OpEthApi, OptimismTxMeta};
Expand All @@ -21,17 +24,19 @@ where
tx: TransactionSigned,
meta: TransactionMeta,
receipt: Receipt,
) -> EthResult<AnyTransactionReceipt> {
) -> Result<AnyTransactionReceipt, Self::Error> {
let (block, receipts) = LoadReceipt::cache(self)
.get_block_and_receipts(meta.block_hash)
.await?
.ok_or(EthApiError::UnknownBlockNumber)?;
.await
.map_err(Self::Error::from_err)?
.ok_or(Self::Error::from_err(EthApiError::UnknownBlockNumber))?;

let block = block.unseal();
let l1_block_info = reth_evm_optimism::extract_l1_info(&block).ok();
let optimism_tx_meta = self.build_op_tx_meta(&tx, l1_block_info, block.timestamp)?;

let resp_builder = ReceiptBuilder::new(&tx, meta, &receipt, &receipts)?;
let resp_builder =
ReceiptBuilder::new(&tx, meta, &receipt, &receipts).map_err(Self::Error::from_err)?;
let resp_builder = op_receipt_fields(resp_builder, &tx, &receipt, optimism_tx_meta);

Ok(resp_builder.build())
Expand Down
6 changes: 3 additions & 3 deletions crates/optimism/rpc/src/eth/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use reth_primitives::TransactionSigned;
use reth_provider::{BlockReaderIdExt, TransactionsProvider};
use reth_rpc_eth_api::{
helpers::{EthApiSpec, EthSigner, EthTransactions, LoadTransaction},
RawTransactionForwarder,
EthApiTypes, RawTransactionForwarder,
};
use reth_rpc_eth_types::{EthResult, EthStateCache};
use reth_rpc_eth_types::EthStateCache;
use revm::L1BlockInfo;

use crate::{OpEthApi, OpEthApiError};
Expand Down Expand Up @@ -79,7 +79,7 @@ where
tx: &TransactionSigned,
l1_block_info: Option<L1BlockInfo>,
block_timestamp: u64,
) -> EthResult<OptimismTxMeta> {
) -> Result<OptimismTxMeta, <Self as EthApiTypes>::Error> {
let Some(l1_block_info) = l1_block_info else { return Ok(OptimismTxMeta::default()) };

let (l1_fee, l1_data_gas) = if !tx.is_deposit() {
Expand Down
Loading
Loading