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 redundant EthTransactions::provider #12121

Merged
merged 1 commit into from
Oct 28, 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
10 changes: 3 additions & 7 deletions crates/optimism/rpc/src/eth/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@ use crate::{OpEthApi, SequencerClient};

impl<N> EthTransactions for OpEthApi<N>
where
Self: LoadTransaction,
N: FullNodeComponents,
Self: LoadTransaction<Provider: BlockReaderIdExt>,
N: RpcNodeCore,
{
fn provider(&self) -> impl BlockReaderIdExt {
self.inner.provider()
}

fn signers(&self) -> &parking_lot::RwLock<Vec<Box<dyn EthSigner>>> {
self.inner.signers()
}
Expand Down Expand Up @@ -71,7 +67,7 @@ where

impl<N> OpEthApi<N>
where
N: FullNodeComponents,
N: RpcNodeCore,
{
/// Returns the [`SequencerClient`] if one is set.
pub fn raw_tx_forwarder(&self) -> Option<SequencerClient> {
Expand Down
27 changes: 11 additions & 16 deletions crates/rpc/rpc-eth-api/src/helpers/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,7 @@ use super::{
/// See also <https://github.com/paradigmxyz/reth/issues/6240>
///
/// This implementation follows the behaviour of Geth and disables the basefee check for tracing.
pub trait EthTransactions: LoadTransaction {
/// Returns a handle for reading data from disk.
///
/// Data access in default (L1) trait method implementations.
fn provider(&self) -> impl BlockReaderIdExt;

pub trait EthTransactions: LoadTransaction<Provider: BlockReaderIdExt> {
/// Returns a handle for signing data.
///
/// Singer access in default (L1) trait method implementations.
Expand Down Expand Up @@ -111,7 +106,8 @@ pub trait EthTransactions: LoadTransaction {
}

self.spawn_blocking_io(move |ref this| {
Ok(RpcNodeCore::provider(this)
Ok(this
.provider()
.transaction_by_hash(hash)
.map_err(Self::Error::from_eth_err)?
.map(|tx| tx.encoded_2718().into()))
Expand Down Expand Up @@ -166,21 +162,20 @@ pub trait EthTransactions: LoadTransaction {
{
let this = self.clone();
self.spawn_blocking_io(move |_| {
let (tx, meta) = match RpcNodeCore::provider(&this)
let (tx, meta) = match this
.provider()
.transaction_by_hash_with_meta(hash)
.map_err(Self::Error::from_eth_err)?
{
Some((tx, meta)) => (tx, meta),
None => return Ok(None),
};

let receipt = match EthTransactions::provider(&this)
.receipt_by_hash(hash)
.map_err(Self::Error::from_eth_err)?
{
Some(recpt) => recpt,
None => return Ok(None),
};
let receipt =
match this.provider().receipt_by_hash(hash).map_err(Self::Error::from_eth_err)? {
Some(recpt) => recpt,
None => return Ok(None),
};

Ok(Some((tx, meta, receipt)))
})
Expand Down Expand Up @@ -257,7 +252,7 @@ pub trait EthTransactions: LoadTransaction {
return Ok(None);
}

let Ok(high) = RpcNodeCore::provider(self).best_block_number() else {
let Ok(high) = self.provider().best_block_number() else {
return Err(EthApiError::HeaderNotFound(BlockNumberOrTag::Latest.into()).into());
};

Expand Down
9 changes: 1 addition & 8 deletions crates/rpc/rpc/src/eth/helpers/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,8 @@ use crate::EthApi;
impl<Provider, Pool, Network, EvmConfig> EthTransactions
for EthApi<Provider, Pool, Network, EvmConfig>
where
Self: LoadTransaction,
Pool: TransactionPool + 'static,
Provider: BlockReaderIdExt,
Self: LoadTransaction<Provider: BlockReaderIdExt>,
{
#[inline]
fn provider(&self) -> impl BlockReaderIdExt {
self.inner.provider()
}

#[inline]
fn signers(&self) -> &parking_lot::RwLock<Vec<Box<dyn EthSigner>>> {
self.inner.signers()
Expand Down
Loading