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): reth-eth-api crate #8887

Merged
merged 66 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
a0cfb0c
scaffold eth api
mattsse May 22, 2024
8a2379b
chore(rpc): decouple op receipt response (#8353)
emhane May 27, 2024
f4f7786
chore(op): remove redundant trait `NetworkEthApi` (#8411)
emhane May 27, 2024
a737ae0
chore(op): L1 receipt rpc methods default trait methods (#8437)
emhane May 31, 2024
39d4366
Merge branch 'main' into matt/scaffold-ethapi
emhane Jun 1, 2024
7913c07
Merge branch 'main' into matt/scaffold-ethapi
emhane Jun 5, 2024
9ba4cd2
Merge branch 'main' into matt/scaffold-ethapi
emhane Jun 5, 2024
3d42231
chore(rpc): trait for blocking task (#8538)
emhane Jun 5, 2024
da5c170
Merge branch 'main' into matt/scaffold-ethapi
emhane Jun 6, 2024
67d276b
Merge branch 'matt/scaffold-ethapi' of github.com:paradigmxyz/reth in…
emhane Jun 6, 2024
f04b38c
Merge branch 'main' into matt/scaffold-ethapi
emhane Jun 8, 2024
ade9d40
Fix lint
emhane Jun 8, 2024
a30c184
chore(rpc): default trait methods `EthTransactions` (#8639)
emhane Jun 8, 2024
cea088d
chore(rpc): pending block helper trait (#8640)
emhane Jun 8, 2024
bc24e8e
chore(rpc): `EthTransactions` default trait methods using pending blo…
emhane Jun 8, 2024
f89077b
chore(rpc): reusable eth api `EthCall` (#8683)
emhane Jun 11, 2024
f8276cc
Merge branch 'main' into matt/scaffold-ethapi
emhane Jun 11, 2024
197b182
chore(rpc): `EthBlocks` default impl (#8723)
emhane Jun 11, 2024
e4f9fdc
chore(rpc): move message signing to `EthTransactions` (#8759)
emhane Jun 12, 2024
ba562d1
Merge branch 'main' into matt/scaffold-ethapi
emhane Jun 13, 2024
0c04916
Fix merge conflicts
emhane Jun 13, 2024
9c579e1
chore(rpc): impl `EthApiServer` helper traits on type like `EthApi` (…
emhane Jun 13, 2024
56ed575
chore(rpc): remove `FillableTransaction` (#8800)
emhane Jun 14, 2024
926c86f
Move EthApi trait to own crate
emhane Jun 14, 2024
2c78d29
Impl EthApiServer for generic type
emhane Jun 14, 2024
f6fe8b5
Move eth api trait and impl into reth-rpc-eth-api
emhane Jun 14, 2024
53a97b8
Run fmt
emhane Jun 14, 2024
6a3b059
Structure reth-rpc-eth-api fs
emhane Jun 15, 2024
dd8920c
Add missing docs
emhane Jun 17, 2024
713923e
Fix deps
emhane Jun 17, 2024
592ab02
Fix docs
emhane Jun 17, 2024
e466faf
Merge branch 'main' into matt/scaffold-ethapi
emhane Jun 17, 2024
e2a9be3
Bump secp256k1
emhane Jun 17, 2024
1de7000
Merge branch 'emhane/bump-secp256k1' into matt/scaffold-ethapi
emhane Jun 17, 2024
fffcc9f
Fix merge conflicts
emhane Jun 17, 2024
db5df93
Merge branch 'matt/scaffold-ethapi' into emhane/move-ethapi
emhane Jun 17, 2024
9ec86df
Fix docs
emhane Jun 17, 2024
90a9c4f
Fix lint
emhane Jun 17, 2024
fda6a66
Fix lint
emhane Jun 17, 2024
76db237
Fix deps
emhane Jun 17, 2024
a7642a9
Fix deps
emhane Jun 17, 2024
c5f6c5a
Enable dev feature for revm primitives
emhane Jun 17, 2024
9ecf026
Feature gate api client export
emhane Jun 17, 2024
fb78bdb
Fix deps
emhane Jun 17, 2024
abff53f
Re-impl op behaviour for EthApi
emhane Jun 17, 2024
4934521
Merge branch 'main' into emhane/ethapi-crate
emhane Jun 17, 2024
85055be
Fix docs
emhane Jun 17, 2024
0b8c131
Fix manifest
emhane Jun 17, 2024
15fc4d8
Remove op default trait method impl
emhane Jun 17, 2024
ce9d876
Add missing op dep
emhane Jun 17, 2024
1237462
fixup! Remove op default trait method impl
emhane Jun 17, 2024
8cba5b8
Merge branch 'main' into emhane/ethapi-crate
emhane Jun 19, 2024
3833795
Fix merge conflicts
emhane Jun 19, 2024
4c4ec2e
Shrink scope, remove reth-optimism-rpc crate
emhane Jun 19, 2024
66560bb
Merge branch 'main' into emhane/ethapi-crate
emhane Jun 19, 2024
e9bba83
Fix merge conflicts
emhane Jun 19, 2024
99c0dcf
fixup! Fix merge conflicts
emhane Jun 19, 2024
7f1335e
Merge branch 'main' into emhane/ethapi-crate
emhane Jun 20, 2024
921ac96
Merge branch 'main' into emhane/ethapi-crate
emhane Jun 21, 2024
715ede0
Merge branch 'main' into emhane/ethapi-crate
emhane Jun 26, 2024
c741859
Fix lint
emhane Jun 26, 2024
afc92d4
Simplify EthBlocks trait method signatures
emhane Jun 26, 2024
d8558ff
Improve usability TraceExt trait
emhane Jun 26, 2024
0f1afac
Merge branch 'main' into emhane/ethapi-crate
emhane Jun 26, 2024
d55c5d9
Use concrete type BlockId as helper trait method param
emhane Jun 27, 2024
9249967
Add 'test-utils' feature to dev-deps
emhane Jun 27, 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
72 changes: 52 additions & 20 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ members = [
"crates/rpc/rpc-api/",
"crates/rpc/rpc-builder/",
"crates/rpc/rpc-engine-api/",
"crates/rpc/rpc-eth-api/",
"crates/rpc/rpc-layer",
"crates/rpc/rpc-testing-util/",
"crates/rpc/rpc-types-compat/",
Expand Down Expand Up @@ -332,6 +333,7 @@ reth-rpc-api = { path = "crates/rpc/rpc-api" }
reth-rpc-api-testing-util = { path = "crates/rpc/rpc-testing-util" }
reth-rpc-builder = { path = "crates/rpc/rpc-builder" }
reth-rpc-engine-api = { path = "crates/rpc/rpc-engine-api" }
reth-rpc-eth-api = { path = "crates/rpc/rpc-eth-api" }
reth-rpc-layer = { path = "crates/rpc/rpc-layer" }
reth-rpc-server-types = { path = "crates/rpc/rpc-server-types" }
reth-rpc-types = { path = "crates/rpc/rpc-types" }
Expand Down
2 changes: 1 addition & 1 deletion crates/e2e-test-utils/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use alloy_consensus::TxEnvelope;
use alloy_network::eip2718::Decodable2718;
use reth::{api::FullNodeComponents, builder::rpc::RpcRegistry, rpc::api::DebugApiServer};
use reth_primitives::{Bytes, B256};
use reth_rpc::eth::{error::EthResult, EthTransactions};
use reth_rpc::eth::{servers::EthTransactions, EthResult};

pub struct RpcTestContext<Node: FullNodeComponents> {
pub inner: RpcRegistry<Node>,
Expand Down
2 changes: 1 addition & 1 deletion crates/ethereum/evm/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ where
.into())
}

EvmConfig::fill_tx_env(evm.tx_mut(), transaction, *sender);
self.evm_config.fill_tx_env(evm.tx_mut(), transaction, *sender);

// Execute transaction.
let ResultAndState { result, state } = evm.transact().map_err(move |err| {
Expand Down
42 changes: 7 additions & 35 deletions crates/ethereum/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@
#[cfg(not(feature = "std"))]
extern crate alloc;

use reth_chainspec::ChainSpec;
use reth_evm::{ConfigureEvm, ConfigureEvmEnv};
use reth_primitives::{
revm::{config::revm_spec, env::fill_tx_env},
revm_primitives::{AnalysisKind, CfgEnvWithHandlerCfg, TxEnv},
Address, Head, Header, TransactionSigned, U256,
};
use reth_revm::{Database, EvmBuilder};

pub mod execute;
Expand All @@ -34,34 +28,7 @@ pub mod eip6110;
#[non_exhaustive]
pub struct EthEvmConfig;

impl ConfigureEvmEnv for EthEvmConfig {
fn fill_tx_env(tx_env: &mut TxEnv, transaction: &TransactionSigned, sender: Address) {
fill_tx_env(tx_env, transaction, sender)
}

fn fill_cfg_env(
cfg_env: &mut CfgEnvWithHandlerCfg,
chain_spec: &ChainSpec,
header: &Header,
total_difficulty: U256,
) {
let spec_id = revm_spec(
chain_spec,
Head {
number: header.number,
timestamp: header.timestamp,
difficulty: header.difficulty,
total_difficulty,
hash: Default::default(),
},
);

cfg_env.chain_id = chain_spec.chain().id();
cfg_env.perf_analyse_created_bytecodes = AnalysisKind::Analyse;

cfg_env.handler_cfg.spec_id = spec_id;
}
}
impl ConfigureEvmEnv for EthEvmConfig {}

impl ConfigureEvm for EthEvmConfig {
type DefaultExternalContext<'a> = ();
Expand All @@ -77,7 +44,12 @@ impl ConfigureEvm for EthEvmConfig {
#[cfg(test)]
mod tests {
use super::*;
use reth_primitives::revm_primitives::{BlockEnv, CfgEnv, SpecId};
use reth_chainspec::ChainSpec;
use reth_primitives::{
revm_primitives::{BlockEnv, CfgEnv, SpecId},
Header, U256,
};
use revm_primitives::CfgEnvWithHandlerCfg;

#[test]
#[ignore]
Expand Down
2 changes: 1 addition & 1 deletion crates/ethereum/node/tests/e2e/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::utils::EthNode;
use alloy_genesis::Genesis;
use alloy_primitives::{b256, hex};
use futures::StreamExt;
use reth::rpc::eth::EthTransactions;
use reth::rpc::eth::servers::EthTransactions;
use reth_chainspec::ChainSpec;
use reth_e2e_test_utils::setup;
use reth_provider::CanonStateSubscriptions;
Expand Down
38 changes: 34 additions & 4 deletions crates/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@
extern crate alloc;

use reth_chainspec::ChainSpec;
use reth_primitives::{revm::env::fill_block_env, Address, Header, TransactionSigned, U256};
use reth_primitives::{
revm::{
config::revm_spec,
env::{fill_block_env, fill_tx_env},
},
Address, Head, Header, TransactionSigned, U256,
};
use revm::{inspector_handle_register, Database, Evm, EvmBuilder, GetInspector};
use revm_primitives::{BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, SpecId, TxEnv};
use revm_primitives::{
AnalysisKind, BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, SpecId, TxEnv,
};

pub mod either;
pub mod execute;
Expand All @@ -27,6 +35,7 @@ pub mod provider;
pub mod test_utils;

/// Trait for configuring the EVM for executing full blocks.
#[auto_impl::auto_impl(&, Arc)]
pub trait ConfigureEvm: ConfigureEvmEnv {
/// Associated type for the default external context that should be configured for the EVM.
type DefaultExternalContext<'a>;
Expand Down Expand Up @@ -98,17 +107,38 @@ pub trait ConfigureEvm: ConfigureEvmEnv {

/// This represents the set of methods used to configure the EVM's environment before block
/// execution.
///
/// Default trait method implementation is done w.r.t. L1.
#[auto_impl::auto_impl(&, Arc)]
pub trait ConfigureEvmEnv: Send + Sync + Unpin + Clone + 'static {
/// Fill transaction environment from a [`TransactionSigned`] and the given sender address.
fn fill_tx_env(tx_env: &mut TxEnv, transaction: &TransactionSigned, sender: Address);
fn fill_tx_env(&self, tx_env: &mut TxEnv, transaction: &TransactionSigned, sender: Address) {
fill_tx_env(tx_env, transaction, sender)
}

/// Fill [`CfgEnvWithHandlerCfg`] fields according to the chain spec and given header
fn fill_cfg_env(
cfg_env: &mut CfgEnvWithHandlerCfg,
chain_spec: &ChainSpec,
header: &Header,
total_difficulty: U256,
);
) {
let spec_id = revm_spec(
chain_spec,
Head {
number: header.number,
timestamp: header.timestamp,
difficulty: header.difficulty,
total_difficulty,
hash: Default::default(),
},
);

cfg_env.chain_id = chain_spec.chain().id();
cfg_env.perf_analyse_created_bytecodes = AnalysisKind::Analyse;

cfg_env.handler_cfg.spec_id = spec_id;
}

/// Convenience function to call both [`fill_cfg_env`](ConfigureEvmEnv::fill_cfg_env) and
/// [`fill_block_env`].
Expand Down
12 changes: 6 additions & 6 deletions crates/evm/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ use reth_storage_errors::provider::ProviderResult;
use revm::primitives::{BlockEnv, CfgEnv, CfgEnvWithHandlerCfg, SpecId};

/// A provider type that knows chain specific information required to configure a
/// [CfgEnvWithHandlerCfg].
/// [`CfgEnvWithHandlerCfg`].
///
/// This type is mainly used to provide required data to configure the EVM environment that is
/// usually stored on disk.
#[auto_impl::auto_impl(&, Arc)]
pub trait EvmEnvProvider: Send + Sync {
/// Fills the [CfgEnvWithHandlerCfg] and [BlockEnv] fields with values specific to the given
/// Fills the [`CfgEnvWithHandlerCfg`] and [BlockEnv] fields with values specific to the given
/// [BlockHashOrNumber].
fn fill_env_at<EvmConfig>(
&self,
Expand All @@ -24,7 +24,7 @@ pub trait EvmEnvProvider: Send + Sync {
where
EvmConfig: ConfigureEvmEnv;

/// Fills the default [CfgEnvWithHandlerCfg] and [BlockEnv] fields with values specific to the
/// Fills the default [`CfgEnvWithHandlerCfg`] and [BlockEnv] fields with values specific to the
/// given [Header].
fn env_with_header<EvmConfig>(
&self,
Expand All @@ -40,7 +40,7 @@ pub trait EvmEnvProvider: Send + Sync {
Ok((cfg, block_env))
}

/// Fills the [CfgEnvWithHandlerCfg] and [BlockEnv] fields with values specific to the given
/// Fills the [`CfgEnvWithHandlerCfg`] and [BlockEnv] fields with values specific to the given
/// [Header].
fn fill_env_with_header<EvmConfig>(
&self,
Expand All @@ -66,7 +66,7 @@ pub trait EvmEnvProvider: Send + Sync {
header: &Header,
) -> ProviderResult<()>;

/// Fills the [CfgEnvWithHandlerCfg] fields with values specific to the given
/// Fills the [`CfgEnvWithHandlerCfg`] fields with values specific to the given
/// [BlockHashOrNumber].
fn fill_cfg_env_at<EvmConfig>(
&self,
Expand All @@ -77,7 +77,7 @@ pub trait EvmEnvProvider: Send + Sync {
where
EvmConfig: ConfigureEvmEnv;

/// Fills the [CfgEnvWithHandlerCfg] fields with values specific to the given [Header].
/// Fills the [`CfgEnvWithHandlerCfg`] fields with values specific to the given [Header].
fn fill_cfg_env_with_header<EvmConfig>(
&self,
cfg: &mut CfgEnvWithHandlerCfg,
Expand Down
Loading
Loading