Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
cab888f
Make on_blocking_task method accessible in default trait method impls
emhane Jun 1, 2024
b902f35
Minimise thread interface eth api
emhane Jun 1, 2024
c35b40e
Update docs and symbol name
emhane Jun 1, 2024
8ccddd3
Add missing reth primitives to op feature
emhane Jun 1, 2024
257dc5d
Remove feature gate to fix broken test
emhane Jun 1, 2024
40194d6
Fix flaky test
emhane Jun 1, 2024
68e64b4
fixup! Fix flaky test
emhane Jun 1, 2024
30b63cc
fixup! Fix flaky test
emhane Jun 1, 2024
fcc64ea
Update lock file
emhane Jun 1, 2024
734ac99
Reinsert functions for spawning blocking threads into EthTransactions
emhane Jun 4, 2024
c000f43
Drive-by, update docs
emhane Jun 4, 2024
d1b91ad
Move spawn cpu heavy to trait
emhane Jun 4, 2024
eec99b8
Fix lint
emhane Jun 4, 2024
924024f
Revert impl for spawning blocking io
emhane Jun 4, 2024
ea6cbd3
Make impl of spawn blocking default trait methods
emhane Jun 4, 2024
ecb6771
Update docs
emhane Jun 5, 2024
fe494dc
Revert unrelated changes
emhane Jun 5, 2024
ba6f403
Merge branch 'main' into emhane/blocking-read
emhane Jun 5, 2024
55d2649
Merge branch 'matt/scaffold-ethapi' into emhane/blocking-read
emhane Jun 5, 2024
139f97f
Merge branch 'matt/scaffold-ethapi' into emhane/blocking-read
emhane Jun 5, 2024
8b8ed16
Fix lint
emhane Jun 5, 2024
f3ed6bd
Add super traits to spawn blocking
emhane Jun 5, 2024
16334cd
Move impl of methods using evm config to default trait methods
emhane Jun 5, 2024
20d2489
Move EthApi state access methods into trait
emhane Jun 5, 2024
4a40032
Move EthTransaction impls to default trait methods
emhane Jun 5, 2024
f2df915
Move state rpc methods into new trait default impl
emhane Jun 5, 2024
ca19811
fixup! Move state rpc methods into new trait default impl
emhane Jun 5, 2024
8ee373c
Move EthTransactions impl to default trait methods
emhane Jun 6, 2024
6dfac1a
Add trait for pending block
emhane Jun 6, 2024
90f67b6
Merge branch 'matt/scaffold-ethapi' into emhane/ethapi-txns
emhane Jun 6, 2024
0db764e
Merge branch 'matt/scaffold-ethapi' into emhane/ethapi-txns
emhane Jun 6, 2024
2340e87
Merge branch 'emhane/ethapi-txns' into emhane/ethapi-pending-block
emhane Jun 6, 2024
3c0b7ab
Fix lint
emhane Jun 6, 2024
6634723
Merge branch 'emhane/ethapi-txns' into emhane/ethapi-pending-block
emhane Jun 6, 2024
5e27f32
Move impl to get evm env at block to EthTransactions default trait me…
emhane Jun 6, 2024
e69b697
Move EthTransactions impl using evm_env_at into default trait methods
emhane Jun 6, 2024
ee101bc
Move block EthApi methods to EthBlocks default trait methods
emhane Jun 6, 2024
2ff0191
Move trace and call helper methods out of EthTransactions to use as d…
emhane Jun 7, 2024
cdd356b
Move EthApi fee methods to trait for reuse on any network and in eth_…
emhane Jun 7, 2024
bd029ff
Debug EthCall
emhane Jun 7, 2024
3211cfc
fixup! Debug EthCall
emhane Jun 8, 2024
42c494e
Keep hack wrappers in super scope
emhane Jun 8, 2024
c9d56e0
Merge matt/scaffold-ethapi
emhane Jun 8, 2024
9d12c70
Merge branch 'matt/scaffold-ethapi' into emhane/ethapi-call
emhane Jun 8, 2024
82de288
Debug EthFees trait
emhane Jun 8, 2024
3880ac0
Fix lint
emhane Jun 8, 2024
52ca8d9
Fix lint
emhane Jun 8, 2024
a414947
Elide lifetimes
emhane Jun 8, 2024
024a61b
Revert method name
emhane Jun 8, 2024
d613ccd
fixup! Revert method name
emhane Jun 8, 2024
9a38b37
Merge branch 'main' into matt/scaffold-ethapi
emhane Jun 10, 2024
92c1750
Merge branch 'matt/scaffold-ethapi' into emhane/ethapi-call
emhane Jun 10, 2024
4c31bbe
Move block rpc method impl for EthApi to default trait methods of Eth…
emhane Jun 10, 2024
23bcb79
Move impl of rpc block impl for EthApi to EthBlocks default trait met…
emhane Jun 10, 2024
f28e550
Move EthApi impl to EthTransactions default impl
emhane Jun 10, 2024
1a6ac3f
Upadte docs and uniform symbol name for LoadReceipt
emhane Jun 10, 2024
aa20bb4
fixup! Upadte docs and uniform symbol name for LoadReceipt
emhane Jun 10, 2024
331fc3b
Revert unrelated changes
emhane Jun 10, 2024
6f4c5da
Return oppaque provider type
emhane Jun 10, 2024
43e64ee
Remove redundant trait bounds
emhane Jun 10, 2024
f69daca
Make extension trait for loading state
emhane Jun 10, 2024
7817e3c
Add extension traits
emhane Jun 11, 2024
7928b8d
Update module docs
emhane Jun 11, 2024
651f27e
Merge branch 'emhane/ethapi-call' into emhane/ethapi-blocks
emhane Jun 11, 2024
02c2ccd
Clean up rpc crate interface
emhane Jun 11, 2024
f1855f8
Merge branch 'matt/scaffold-ethapi' into emhane/ethapi-blocks
emhane Jun 11, 2024
7f2df31
Fix merge conflicts
emhane Jun 11, 2024
c8fcf13
Move tx signing to default EthTransactions trait method impl
emhane Jun 11, 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
58 changes: 30 additions & 28 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions crates/optimism/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ reth-rpc-types.workspace = true
reth-primitives = { workspace = true, features = ["optimism"] }
reth-provider.workspace = true
reth-transaction-pool.workspace = true
reth-tasks.workspace = true

# async
futures.workspace = true
tokio = { workspace = true, features = ["sync"] }

# rpc
jsonrpsee.workspace = true
Expand Down
52 changes: 48 additions & 4 deletions crates/optimism/rpc/src/block.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
//! Loads and formats OP block RPC response.

use reth_evm::ConfigureEvm;
use reth_primitives::TransactionMeta;
use reth_provider::{BlockReaderIdExt, ChainSpecProvider};
use reth_provider::{
BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, HeaderProvider, StateProviderFactory,
};
use reth_rpc::eth::{
api::{BuildReceipt, EthBlocks, LoadBlock, ReceiptBuilder},
api::{
EthBlocks, LoadBlock, LoadPendingBlock, LoadReceipt, PendingBlock, ReceiptBuilder,
SpawnBlocking,
},
cache::EthStateCache,
error::EthResult,
};
use reth_rpc_types::{AnyTransactionReceipt, BlockId};
use reth_transaction_pool::TransactionPool;
use tokio::sync::Mutex;

use crate::receipt::op_receipt_fields;

Expand All @@ -16,14 +24,19 @@ use super::OptimismApi;
impl<Provider, Pool, Network, EvmConfig> EthBlocks
for OptimismApi<Provider, Pool, Network, EvmConfig>
where
Provider: BlockReaderIdExt + ChainSpecProvider,
Self: LoadBlock,
Provider: BlockReaderIdExt + ChainSpecProvider + HeaderProvider,
{
fn provider(&self) -> impl HeaderProvider {
self.inner.provider()
}

async fn block_receipts(
&self,
block_id: BlockId,
) -> EthResult<Option<Vec<AnyTransactionReceipt>>>
where
Self: BuildReceipt,
Self: LoadReceipt,
{
if let Some((block, receipts)) = self.load_block_and_receipts(block_id).await? {
let block_number = block.number;
Expand Down Expand Up @@ -69,6 +82,7 @@ where
impl<Provider, Pool, Network, EvmConfig> LoadBlock
for OptimismApi<Provider, Pool, Network, EvmConfig>
where
Self: LoadPendingBlock + SpawnBlocking,
Provider: BlockReaderIdExt,
{
#[inline]
Expand All @@ -81,3 +95,33 @@ where
self.inner.cache()
}
}

impl<Provider, Pool, Network, EvmConfig> LoadPendingBlock
for OptimismApi<Provider, Pool, Network, EvmConfig>
where
Provider: BlockReaderIdExt + EvmEnvProvider + ChainSpecProvider + StateProviderFactory,
Pool: TransactionPool,
EvmConfig: ConfigureEvm,
{
#[inline]
fn provider(
&self,
) -> impl BlockReaderIdExt + EvmEnvProvider + ChainSpecProvider + StateProviderFactory {
self.inner.provider()
}

#[inline]
fn pool(&self) -> impl TransactionPool {
self.inner.pool()
}

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

#[inline]
fn evm_config(&self) -> &impl ConfigureEvm {
self.inner.evm_config()
}
}
19 changes: 13 additions & 6 deletions crates/optimism/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

use std::sync::Arc;

use reth_rpc::eth::api::EthApiInner;
use reth_rpc::eth::api::{EthApiInner, SpawnBlocking};
use reth_tasks::{pool::BlockingTaskPool, TaskSpawner};

pub mod block;
pub mod error;
Expand All @@ -22,16 +23,22 @@ pub mod transaction;
/// requests. See [`EthApi`](reth_rpc::EthApi) for the default L1 implementation.
#[allow(missing_debug_implementations)]
#[allow(dead_code)]
#[derive(Clone)]
pub struct OptimismApi<Provider, Pool, Network, EvmConfig> {
/// All nested fields bundled together.
inner: Arc<EthApiInner<Provider, Pool, Network, EvmConfig>>,
}

unsafe impl<Provider, Pool, Network, EvmConfig> Send
for OptimismApi<Provider, Pool, Network, EvmConfig>
{
}
unsafe impl<Provider, Pool, Network, EvmConfig> Sync
impl<Provider, Pool, Network, EvmConfig> SpawnBlocking
for OptimismApi<Provider, Pool, Network, EvmConfig>
where
Self: Clone + Send + Sync + 'static,
{
fn io_task_spawner(&self) -> impl TaskSpawner {
self.inner.task_spawner()
}

fn tracing_task_pool(&self) -> &BlockingTaskPool {
self.inner.blocking_task_pool()
}
}
10 changes: 4 additions & 6 deletions crates/optimism/rpc/src/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ use crate::{transaction::OptimismTxMeta, OptimismApi};
use reth_primitives::{Receipt, TransactionMeta, TransactionSigned};
use reth_provider::{BlockIdReader, ChainSpecProvider};
use reth_rpc::eth::{
api::{BuildReceipt, ReceiptBuilder},
api::{LoadReceipt, ReceiptBuilder},
cache::EthStateCache,
error::{EthApiError, EthResult},
};
use reth_rpc_types::{AnyTransactionReceipt, OptimismTransactionReceiptFields};

impl<Provider, Pool, Network, EvmConfig> BuildReceipt
impl<Provider, Pool, Network, EvmConfig> LoadReceipt
for OptimismApi<Provider, Pool, Network, EvmConfig>
where
Self: Send + Sync,
Provider: BlockIdReader + ChainSpecProvider,
{
#[inline]
Expand All @@ -25,10 +26,7 @@ where
tx: TransactionSigned,
meta: TransactionMeta,
receipt: Receipt,
) -> EthResult<AnyTransactionReceipt>
where
Self: Send + Sync,
{
) -> EthResult<AnyTransactionReceipt> {
let (block, receipts) = self
.cache()
.get_block_and_receipts(meta.block_hash)
Expand Down
4 changes: 2 additions & 2 deletions crates/rpc/rpc/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use tokio::sync::{AcquireError, OwnedSemaphorePermit};

use crate::{
eth::{
api::{LoadBlock, LoadTransaction, StateCacheDB, TraceExt},
api::{EthTransactions, LoadBlock, LoadTransaction, StateCacheDB, TraceExt},
error::{EthApiError, EthResult},
revm_utils::{prepare_call_env, EvmOverrides},
},
Expand Down Expand Up @@ -639,7 +639,7 @@ where
+ StateProviderFactory
+ EvmEnvProvider
+ 'static,
Eth: EthApiSpec + LoadBlock + TraceExt + 'static,
Eth: EthApiSpec + EthTransactions + LoadBlock + TraceExt + 'static,
{
/// Handler for `debug_getRawHeader`
async fn raw_header(&self, block_id: BlockId) -> RpcResult<Bytes> {
Expand Down
Loading