From 4c8f31a8c128122a24e473f3c5d26a7409be1349 Mon Sep 17 00:00:00 2001 From: rakita Date: Wed, 14 Feb 2024 03:01:48 +0100 Subject: [PATCH] fix(op): Add optimism in node api, few cfg transitions (#6598) --- bin/reth/Cargo.toml | 1 + crates/consensus/beacon/Cargo.toml | 1 + crates/node-api/Cargo.toml | 5 ++++- crates/node-api/src/engine/traits.rs | 14 ++++++++++---- crates/node-core/Cargo.toml | 7 ++++++- crates/node-optimism/Cargo.toml | 2 +- crates/payload/builder/Cargo.toml | 3 ++- crates/revm/Cargo.toml | 1 + crates/rpc/rpc-api/Cargo.toml | 1 + crates/rpc/rpc-builder/Cargo.toml | 2 +- crates/rpc/rpc-engine-api/Cargo.toml | 6 +++++- crates/rpc/rpc/Cargo.toml | 11 +++++++++-- crates/rpc/rpc/src/debug.rs | 25 +++++++++++++------------ crates/storage/provider/Cargo.toml | 3 ++- 14 files changed, 57 insertions(+), 25 deletions(-) diff --git a/bin/reth/Cargo.toml b/bin/reth/Cargo.toml index 1d1d4639f..e1744a3ac 100644 --- a/bin/reth/Cargo.toml +++ b/bin/reth/Cargo.toml @@ -164,6 +164,7 @@ optimism = [ "reth-node-ethereum/optimism", "dep:reth-node-optimism", "reth-node-core/optimism", + "reth-node-api/optimism", ] # no-op feature flag for switching between the `optimism` and default functionality in CI matrices diff --git a/crates/consensus/beacon/Cargo.toml b/crates/consensus/beacon/Cargo.toml index 9672b98ca..938b3b4db 100644 --- a/crates/consensus/beacon/Cargo.toml +++ b/crates/consensus/beacon/Cargo.toml @@ -68,4 +68,5 @@ optimism = [ "reth-rpc-types/optimism", "reth-payload-builder/optimism", "reth-blockchain-tree/optimism", + "reth-node-api/optimism", ] diff --git a/crates/node-api/Cargo.toml b/crates/node-api/Cargo.toml index 411ba8f99..311b0c804 100644 --- a/crates/node-api/Cargo.toml +++ b/crates/node-api/Cargo.toml @@ -18,4 +18,7 @@ revm-primitives.workspace = true thiserror.workspace = true # io -serde.workspace = true \ No newline at end of file +serde.workspace = true + +[features] +optimism = [] \ No newline at end of file diff --git a/crates/node-api/src/engine/traits.rs b/crates/node-api/src/engine/traits.rs index 96c7cfbad..07ab94243 100644 --- a/crates/node-api/src/engine/traits.rs +++ b/crates/node-api/src/engine/traits.rs @@ -126,16 +126,22 @@ pub trait PayloadBuilderAttributes: Send + Sync + std::fmt::Debug { blob_excess_gas_and_price, }; + let cfg_with_handler_cfg; #[cfg(feature = "optimism")] { - let cfg_with_handler_cfg = CfgEnvWithHandlerCfg { + cfg_with_handler_cfg = CfgEnvWithHandlerCfg { cfg_env: cfg, - handler_cfg: HandlerCfg { spec_id, is_optimism: chain_spec.is_optimism() }, + handler_cfg: revm_primitives::HandlerCfg { + spec_id, + is_optimism: chain_spec.is_optimism(), + }, }; } #[cfg(not(feature = "optimism"))] - let cfg_with_handler_cfg = CfgEnvWithHandlerCfg::new(cfg, spec_id); + { + cfg_with_handler_cfg = CfgEnvWithHandlerCfg::new(cfg, spec_id); + } (cfg_with_handler_cfg, block_env) } @@ -211,7 +217,7 @@ impl PayloadAttributes for OptimismPayloadAttributes { if self.gas_limit.is_none() && chain_spec.is_optimism() { return Err(AttributesValidationError::InvalidParams( "MissingGasLimitInPayloadAttributes".to_string().into(), - )) + )); } Ok(()) diff --git a/crates/node-core/Cargo.toml b/crates/node-core/Cargo.toml index 6448161c4..18246f69d 100644 --- a/crates/node-core/Cargo.toml +++ b/crates/node-core/Cargo.toml @@ -82,7 +82,11 @@ tracing.workspace = true # crypto alloy-rlp.workspace = true alloy-chains.workspace = true -secp256k1 = { workspace = true, features = ["global-context", "rand-std", "recovery"] } +secp256k1 = { workspace = true, features = [ + "global-context", + "rand-std", + "recovery", +] } # async futures.workspace = true @@ -118,6 +122,7 @@ optimism = [ "reth-blockchain-tree/optimism", "reth-beacon-consensus/optimism", "reth-optimism-payload-builder/optimism", + "reth-node-api/optimism", ] jemalloc = ["dep:jemalloc-ctl"] diff --git a/crates/node-optimism/Cargo.toml b/crates/node-optimism/Cargo.toml index 30f6a0014..13df047f1 100644 --- a/crates/node-optimism/Cargo.toml +++ b/crates/node-optimism/Cargo.toml @@ -21,4 +21,4 @@ reth-node-api.workspace = true serde.workspace = true [features] -optimism = [] +optimism = ["reth-node-api/optimism"] diff --git a/crates/payload/builder/Cargo.toml b/crates/payload/builder/Cargo.toml index 26c9fae1e..be3013329 100644 --- a/crates/payload/builder/Cargo.toml +++ b/crates/payload/builder/Cargo.toml @@ -54,5 +54,6 @@ optimism = [ "reth-rpc-types/optimism", "reth-rpc-types-compat/optimism", "reth-interfaces/optimism", - "reth-transaction-pool/optimism" + "reth-transaction-pool/optimism", + "reth-node-api/optimism", ] diff --git a/crates/revm/Cargo.toml b/crates/revm/Cargo.toml index 64a525bfb..1f51767d0 100644 --- a/crates/revm/Cargo.toml +++ b/crates/revm/Cargo.toml @@ -37,5 +37,6 @@ optimism = [ "reth-primitives/optimism", "reth-consensus-common/optimism", "reth-interfaces/optimism", + "reth-node-api/optimism", ] js-tracer = ["revm-inspectors/js-tracer"] diff --git a/crates/rpc/rpc-api/Cargo.toml b/crates/rpc/rpc-api/Cargo.toml index f66f20ec4..2ce60ff6f 100644 --- a/crates/rpc/rpc-api/Cargo.toml +++ b/crates/rpc/rpc-api/Cargo.toml @@ -24,3 +24,4 @@ serde_json.workspace = true [features] client = ["jsonrpsee/client", "jsonrpsee/async-client"] +optimism = ["reth-node-api/optimism"] diff --git a/crates/rpc/rpc-builder/Cargo.toml b/crates/rpc/rpc-builder/Cargo.toml index 3c278bafc..a5c9f9157 100644 --- a/crates/rpc/rpc-builder/Cargo.toml +++ b/crates/rpc/rpc-builder/Cargo.toml @@ -54,4 +54,4 @@ reth-tracing.workspace = true reth-transaction-pool = { workspace = true, features = ["test-utils"] } tokio = { workspace = true, features = ["rt", "rt-multi-thread"] } -serde_json.workspace = true +serde_json.workspace = true \ No newline at end of file diff --git a/crates/rpc/rpc-engine-api/Cargo.toml b/crates/rpc/rpc-engine-api/Cargo.toml index 342600c32..ba309df1e 100644 --- a/crates/rpc/rpc-engine-api/Cargo.toml +++ b/crates/rpc/rpc-engine-api/Cargo.toml @@ -49,4 +49,8 @@ reth-payload-builder = { workspace = true, features = ["test-utils"] } assert_matches.workspace = true [features] -optimism = ["reth-primitives/optimism", "reth-rpc-types/optimism"] +optimism = [ + "reth-primitives/optimism", + "reth-rpc-types/optimism", + "reth-node-api/optimism", +] diff --git a/crates/rpc/rpc/Cargo.toml b/crates/rpc/rpc/Cargo.toml index 3199e320e..c792710cb 100644 --- a/crates/rpc/rpc/Cargo.toml +++ b/crates/rpc/rpc/Cargo.toml @@ -49,7 +49,9 @@ hyper = "0.14.24" jsonwebtoken = "8" ## required for optimism sequencer delegation -reqwest = { version = "0.11", default-features = false, features = ["rustls-tls"], optional = true } +reqwest = { version = "0.11", default-features = false, features = [ + "rustls-tls", +], optional = true } # async async-trait.workspace = true @@ -66,7 +68,11 @@ metrics.workspace = true # misc bytes.workspace = true -secp256k1 = { workspace = true, features = ["global-context", "rand-std", "recovery"] } +secp256k1 = { workspace = true, features = [ + "global-context", + "rand-std", + "recovery", +] } serde = { workspace = true, features = ["derive"] } serde_json.workspace = true thiserror.workspace = true @@ -95,4 +101,5 @@ optimism = [ "reth-network/optimism", "reth-provider/optimism", "reth-transaction-pool/optimism", + "reth-node-api/optimism", ] diff --git a/crates/rpc/rpc/src/debug.rs b/crates/rpc/rpc/src/debug.rs index 60e2ca904..75c90d520 100644 --- a/crates/rpc/rpc/src/debug.rs +++ b/crates/rpc/rpc/src/debug.rs @@ -90,10 +90,10 @@ where while let Some((index, tx)) = transactions.next() { let tx_hash = tx.hash; let tx = tx_env_with_recovered(&tx); - let env = EnvWithHandlerCfg::new( - Env::boxed(cfg.cfg_env.clone(), block_env.clone(), tx), - cfg.handler_cfg.spec_id, - ); + let env = EnvWithHandlerCfg { + env: Env::boxed(cfg.cfg_env.clone(), block_env.clone(), tx), + handler_cfg: cfg.handler_cfg, + }; let (result, state_changes) = this .trace_transaction( opts.clone(), @@ -237,10 +237,11 @@ where tx.hash, )?; - let env = EnvWithHandlerCfg::new( - Env::boxed(cfg.cfg_env.clone(), block_env, tx_env_with_recovered(&tx)), - cfg.handler_cfg.spec_id, - ); + let env = EnvWithHandlerCfg { + env: Env::boxed(cfg.cfg_env.clone(), block_env, tx_env_with_recovered(&tx)), + handler_cfg: cfg.handler_cfg, + }; + this.trace_transaction( opts, env, @@ -436,10 +437,10 @@ where // Execute all transactions until index for tx in transactions { let tx = tx_env_with_recovered(&tx); - let env = EnvWithHandlerCfg::new( - Env::boxed(cfg.cfg_env.clone(), block_env.clone(), tx), - cfg.handler_cfg.spec_id, - ); + let env = EnvWithHandlerCfg { + env: Env::boxed(cfg.cfg_env.clone(), block_env.clone(), tx), + handler_cfg: cfg.handler_cfg, + }; let (res, _) = transact(&mut db, env)?; db.commit(res.state); } diff --git a/crates/storage/provider/Cargo.toml b/crates/storage/provider/Cargo.toml index aec57e38c..7f47c76bc 100644 --- a/crates/storage/provider/Cargo.toml +++ b/crates/storage/provider/Cargo.toml @@ -63,5 +63,6 @@ rand.workspace = true test-utils = ["alloy-rlp", "reth-db/test-utils"] optimism = [ "reth-primitives/optimism", - "reth-interfaces/optimism" + "reth-interfaces/optimism", + "reth-node-api/optimism" ]