Skip to content

Commit

Permalink
add required trait impls for OpEthApi
Browse files Browse the repository at this point in the history
  • Loading branch information
shiowp committed Jul 8, 2024
1 parent 67f38e8 commit 83886cb
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 39 deletions.
10 changes: 0 additions & 10 deletions Cargo.lock

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

10 changes: 0 additions & 10 deletions crates/optimism/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,19 @@ workspace = true

[dependencies]
# reth
revm.workspace = true
revm-inspectors = { workspace = true, features = ["js-tracer"] }
revm-primitives = { workspace = true, features = ["dev"] }
reth-errors.workspace = true
reth-evm.workspace = true
reth-rpc.workspace = true
reth-rpc-eth-api.workspace = true
reth-rpc-eth-types.workspace = true
reth-rpc-server-types.workspace = true
reth-rpc-types.workspace = true
reth-chainspec.workspace = true
reth-provider.workspace = true
reth-revm.workspace = true
reth-rpc-types-compat.workspace = true
reth-tasks = { workspace = true, features = ["rayon"] }
reth-transaction-pool.workspace = true
reth-execution-types.workspace = true

# ethereum
alloy-primitives.workspace = true

# async
async-trait.workspace = true
futures.workspace = true
parking_lot.workspace = true
tokio.workspace = true
61 changes: 43 additions & 18 deletions crates/optimism/rpc/src/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@ use alloy_primitives::{Address, U64};
use reth_chainspec::ChainInfo;
use reth_errors::RethResult;
use reth_evm::ConfigureEvm;
use reth_provider::{BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, HeaderProvider, StateProviderFactory};
use reth_rpc_eth_api::{helpers::{Call, EthApiSpec, EthBlocks, EthSigner, EthTransactions, LoadBlock, LoadFee, LoadPendingBlock, LoadReceipt, LoadState, LoadTransaction, SpawnBlocking}, RawTransactionForwarder};
use reth_provider::{
BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, HeaderProvider, StateProviderFactory,
};
use reth_rpc_eth_api::{
helpers::{
Call, EthApiSpec, EthBlocks, EthCall, EthFees, EthSigner, EthState, EthTransactions,
LoadBlock, LoadFee, LoadPendingBlock, LoadReceipt, LoadState, LoadTransaction,
SpawnBlocking, Trace,
},
RawTransactionForwarder,
};
use reth_rpc_eth_types::{EthStateCache, PendingBlock};
use reth_rpc_types::SyncStatus;
use reth_tasks::{pool::BlockingTaskPool, TaskSpawner};
Expand Down Expand Up @@ -72,21 +81,23 @@ impl<Eth: LoadBlock> LoadBlock for OpEthApi<Eth> {
}

impl<Eth: LoadPendingBlock> LoadPendingBlock for OpEthApi<Eth> {
fn provider(&self,) -> impl BlockReaderIdExt+EvmEnvProvider+ChainSpecProvider+StateProviderFactory {
self.inner.provider()
}
fn provider(
&self,
) -> impl BlockReaderIdExt + EvmEnvProvider + ChainSpecProvider + StateProviderFactory {
self.inner.provider()
}

fn pool(&self) -> impl TransactionPool {
self.inner.pool()
}
self.inner.pool()
}

fn pending_block(&self) -> &Mutex<Option<PendingBlock> > {
self.inner.pending_block()
}
fn pending_block(&self) -> &Mutex<Option<PendingBlock>> {
self.inner.pending_block()
}

fn evm_config(&self) -> &impl ConfigureEvm {
self.inner.evm_config()
}
fn evm_config(&self) -> &impl ConfigureEvm {
self.inner.evm_config()
}
}

impl<Eth: SpawnBlocking> SpawnBlocking for OpEthApi<Eth> {
Expand All @@ -100,7 +111,7 @@ impl<Eth: SpawnBlocking> SpawnBlocking for OpEthApi<Eth> {
}

impl<Eth: LoadReceipt> LoadReceipt for OpEthApi<Eth> {
fn cache(&self) -> &EthStateCache {
fn cache(&self) -> &EthStateCache {
self.inner.cache()
}
}
Expand Down Expand Up @@ -168,9 +179,7 @@ impl<Eth: EthTransactions> EthTransactions for OpEthApi<Eth> {
EthTransactions::provider(&self.inner)
}

fn raw_tx_forwarder(
&self,
) -> Option<std::sync::Arc<dyn RawTransactionForwarder>> {
fn raw_tx_forwarder(&self) -> Option<std::sync::Arc<dyn RawTransactionForwarder>> {
self.inner.raw_tx_forwarder()
}

Expand All @@ -183,4 +192,20 @@ impl<Eth: EthBlocks> EthBlocks for OpEthApi<Eth> {
fn provider(&self) -> impl HeaderProvider {
EthBlocks::provider(&self.inner)
}
}
}

impl<Eth: EthState> EthState for OpEthApi<Eth> {
fn max_proof_window(&self) -> u64 {
self.inner.max_proof_window()
}
}

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

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

impl<Eth: Trace> Trace for OpEthApi<Eth> {
fn evm_config(&self) -> &impl ConfigureEvm {
self.inner.evm_config()
}
}
2 changes: 1 addition & 1 deletion crates/optimism/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
)]
// #![cfg_attr(not(test), warn(unused_crate_dependencies))] TODO: enable
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

pub mod eth;

0 comments on commit 83886cb

Please sign in to comment.