mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: Add required trait impls for OpEthApi (#9341)
This commit is contained in:
8
Cargo.lock
generated
8
Cargo.lock
generated
@ -7959,13 +7959,17 @@ name = "reth-optimism-rpc"
|
||||
version = "1.0.0"
|
||||
dependencies = [
|
||||
"alloy-primitives",
|
||||
"parking_lot 0.12.3",
|
||||
"reth-chainspec",
|
||||
"reth-errors",
|
||||
"reth-rpc",
|
||||
"reth-evm",
|
||||
"reth-provider",
|
||||
"reth-rpc-eth-api",
|
||||
"reth-rpc-eth-types",
|
||||
"reth-rpc-server-types",
|
||||
"reth-rpc-types",
|
||||
"reth-tasks",
|
||||
"reth-transaction-pool",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@ -12,13 +12,19 @@ workspace = true
|
||||
|
||||
[dependencies]
|
||||
# reth
|
||||
reth-rpc.workspace = true
|
||||
reth-errors.workspace = true
|
||||
reth-evm.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-errors.workspace = true
|
||||
reth-chainspec.workspace = true
|
||||
reth-provider.workspace = true
|
||||
reth-tasks = { workspace = true, features = ["rayon"] }
|
||||
reth-transaction-pool.workspace = true
|
||||
|
||||
# ethereum
|
||||
alloy-primitives.workspace = true
|
||||
alloy-primitives.workspace = true
|
||||
|
||||
# async
|
||||
parking_lot.workspace = true
|
||||
tokio.workspace = true
|
||||
@ -3,9 +3,24 @@
|
||||
use alloy_primitives::{Address, U64};
|
||||
use reth_chainspec::ChainInfo;
|
||||
use reth_errors::RethResult;
|
||||
use reth_rpc_eth_api::helpers::EthApiSpec;
|
||||
use reth_evm::ConfigureEvm;
|
||||
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};
|
||||
use reth_transaction_pool::TransactionPool;
|
||||
use std::future::Future;
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
/// OP-Reth `Eth` API implementation.
|
||||
///
|
||||
@ -54,3 +69,143 @@ impl<Eth: EthApiSpec> EthApiSpec for OpEthApi<Eth> {
|
||||
self.inner.sync_status()
|
||||
}
|
||||
}
|
||||
|
||||
impl<Eth: LoadBlock> LoadBlock for OpEthApi<Eth> {
|
||||
fn provider(&self) -> impl BlockReaderIdExt {
|
||||
LoadBlock::provider(&self.inner)
|
||||
}
|
||||
|
||||
fn cache(&self) -> &reth_rpc_eth_types::EthStateCache {
|
||||
self.inner.cache()
|
||||
}
|
||||
}
|
||||
|
||||
impl<Eth: LoadPendingBlock> LoadPendingBlock for OpEthApi<Eth> {
|
||||
fn provider(
|
||||
&self,
|
||||
) -> impl BlockReaderIdExt + EvmEnvProvider + ChainSpecProvider + StateProviderFactory {
|
||||
self.inner.provider()
|
||||
}
|
||||
|
||||
fn pool(&self) -> impl TransactionPool {
|
||||
self.inner.pool()
|
||||
}
|
||||
|
||||
fn pending_block(&self) -> &Mutex<Option<PendingBlock>> {
|
||||
self.inner.pending_block()
|
||||
}
|
||||
|
||||
fn evm_config(&self) -> &impl ConfigureEvm {
|
||||
self.inner.evm_config()
|
||||
}
|
||||
}
|
||||
|
||||
impl<Eth: SpawnBlocking> SpawnBlocking for OpEthApi<Eth> {
|
||||
fn io_task_spawner(&self) -> impl TaskSpawner {
|
||||
self.inner.io_task_spawner()
|
||||
}
|
||||
|
||||
fn tracing_task_pool(&self) -> &BlockingTaskPool {
|
||||
self.inner.tracing_task_pool()
|
||||
}
|
||||
}
|
||||
|
||||
impl<Eth: LoadReceipt> LoadReceipt for OpEthApi<Eth> {
|
||||
fn cache(&self) -> &EthStateCache {
|
||||
self.inner.cache()
|
||||
}
|
||||
}
|
||||
|
||||
impl<Eth: LoadFee> LoadFee for OpEthApi<Eth> {
|
||||
fn provider(&self) -> impl reth_provider::BlockIdReader + HeaderProvider + ChainSpecProvider {
|
||||
LoadFee::provider(&self.inner)
|
||||
}
|
||||
|
||||
fn cache(&self) -> &EthStateCache {
|
||||
LoadFee::cache(&self.inner)
|
||||
}
|
||||
|
||||
fn gas_oracle(&self) -> &reth_rpc_eth_types::GasPriceOracle<impl BlockReaderIdExt> {
|
||||
self.inner.gas_oracle()
|
||||
}
|
||||
|
||||
fn fee_history_cache(&self) -> &reth_rpc_eth_types::FeeHistoryCache {
|
||||
self.inner.fee_history_cache()
|
||||
}
|
||||
}
|
||||
|
||||
impl<Eth: Call> Call for OpEthApi<Eth> {
|
||||
fn call_gas_limit(&self) -> u64 {
|
||||
self.inner.call_gas_limit()
|
||||
}
|
||||
|
||||
fn evm_config(&self) -> &impl ConfigureEvm {
|
||||
self.inner.evm_config()
|
||||
}
|
||||
}
|
||||
|
||||
impl<Eth: LoadState> LoadState for OpEthApi<Eth> {
|
||||
fn provider(&self) -> impl StateProviderFactory {
|
||||
LoadState::provider(&self.inner)
|
||||
}
|
||||
|
||||
fn cache(&self) -> &EthStateCache {
|
||||
LoadState::cache(&self.inner)
|
||||
}
|
||||
|
||||
fn pool(&self) -> impl TransactionPool {
|
||||
LoadState::pool(&self.inner)
|
||||
}
|
||||
}
|
||||
|
||||
impl<Eth: LoadTransaction> LoadTransaction for OpEthApi<Eth> {
|
||||
type Pool = Eth::Pool;
|
||||
|
||||
fn provider(&self) -> impl reth_provider::TransactionsProvider {
|
||||
LoadTransaction::provider(&self.inner)
|
||||
}
|
||||
|
||||
fn cache(&self) -> &EthStateCache {
|
||||
LoadTransaction::cache(&self.inner)
|
||||
}
|
||||
|
||||
fn pool(&self) -> &Self::Pool {
|
||||
LoadTransaction::pool(&self.inner)
|
||||
}
|
||||
}
|
||||
|
||||
impl<Eth: EthTransactions> EthTransactions for OpEthApi<Eth> {
|
||||
fn provider(&self) -> impl BlockReaderIdExt {
|
||||
EthTransactions::provider(&self.inner)
|
||||
}
|
||||
|
||||
fn raw_tx_forwarder(&self) -> Option<std::sync::Arc<dyn RawTransactionForwarder>> {
|
||||
self.inner.raw_tx_forwarder()
|
||||
}
|
||||
|
||||
fn signers(&self) -> &parking_lot::RwLock<Vec<Box<dyn EthSigner>>> {
|
||||
self.inner.signers()
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user