From 02f08c70e8fdd406d4534a01eefcc6ea77d071ed Mon Sep 17 00:00:00 2001 From: nk_ysg Date: Thu, 22 Aug 2024 18:16:14 +0800 Subject: [PATCH 1/3] Make js-feature non default --- Cargo.lock | 4 ++-- crates/rpc/rpc-eth-api/Cargo.toml | 1 - crates/rpc/rpc-eth-types/Cargo.toml | 1 - crates/rpc/rpc/Cargo.toml | 1 - crates/rpc/rpc/src/debug.rs | 18 +++++++++++++++--- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f3c40d8afe9a..408972b00cce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8950,9 +8950,9 @@ dependencies = [ [[package]] name = "revm-inspectors" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43cbb1576a147317c6990cf69d6cd5ef402df99f638616ba911006e9ec45866b" +checksum = "ec16f9b9d3cdaaf2f4b7ceaf004eb2c89df04e7ea29622584c0a6ec676bd0a83" dependencies = [ "alloy-primitives", "alloy-rpc-types", diff --git a/crates/rpc/rpc-eth-api/Cargo.toml b/crates/rpc/rpc-eth-api/Cargo.toml index af747fb322ef..d571e4f82f48 100644 --- a/crates/rpc/rpc-eth-api/Cargo.toml +++ b/crates/rpc/rpc-eth-api/Cargo.toml @@ -50,7 +50,6 @@ dyn-clone.workspace = true tracing.workspace = true [features] -default = ["js-tracer"] js-tracer = ["revm-inspectors/js-tracer", "reth-rpc-eth-types/js-tracer"] client = ["jsonrpsee/client", "jsonrpsee/async-client"] optimism = [ diff --git a/crates/rpc/rpc-eth-types/Cargo.toml b/crates/rpc/rpc-eth-types/Cargo.toml index d2460a276301..25be4a246735 100644 --- a/crates/rpc/rpc-eth-types/Cargo.toml +++ b/crates/rpc/rpc-eth-types/Cargo.toml @@ -59,5 +59,4 @@ serde_json.workspace = true [features] -default = ["js-tracer"] js-tracer = ["revm-inspectors/js-tracer"] \ No newline at end of file diff --git a/crates/rpc/rpc/Cargo.toml b/crates/rpc/rpc/Cargo.toml index 572f59b81867..0142545f45c9 100644 --- a/crates/rpc/rpc/Cargo.toml +++ b/crates/rpc/rpc/Cargo.toml @@ -84,7 +84,6 @@ jsonrpsee-types.workspace = true jsonrpsee = { workspace = true, features = ["client"] } [features] -default = ["js-tracer"] js-tracer = ["revm-inspectors/js-tracer", "reth-rpc-eth-types/js-tracer"] optimism = [ "reth-primitives/optimism", diff --git a/crates/rpc/rpc/src/debug.rs b/crates/rpc/rpc/src/debug.rs index d41c986128ea..f6c294142875 100644 --- a/crates/rpc/rpc/src/debug.rs +++ b/crates/rpc/rpc/src/debug.rs @@ -33,9 +33,10 @@ use revm::{ primitives::{db::DatabaseCommit, BlockEnv, CfgEnvWithHandlerCfg, Env, EnvWithHandlerCfg}, StateBuilder, }; +#[cfg(feature = "js-tracer")] +use revm_inspectors::tracing::js::JsInspector; use revm_inspectors::tracing::{ - js::{JsInspector, TransactionContext}, - FourByteInspector, MuxInspector, TracingInspector, TracingInspectorConfig, + FourByteInspector, MuxInspector, TracingInspector, TracingInspectorConfig, TransactionContext, }; use revm_primitives::{keccak256, HashMap}; use std::sync::Arc; @@ -388,6 +389,11 @@ where return Ok(frame) } }, + #[cfg(not(feature = "js-tracer"))] + GethDebugTracerType::JsTracer(_) => { + Err(EthApiError::Unsupported("JS Tracer is not enabled").into()) + } + #[cfg(feature = "js-tracer")] GethDebugTracerType::JsTracer(code) => { let config = tracer_config.into_json(); @@ -671,7 +677,8 @@ where opts: GethDebugTracingOptions, env: EnvWithHandlerCfg, db: &mut StateCacheDb<'_>, - transaction_context: Option, + #[cfg(not(feature = "js-tracer"))] _transaction_context: Option, + #[cfg(feature = "js-tracer")] transaction_context: Option, ) -> Result<(GethTrace, revm_primitives::EvmState), Eth::Error> { let GethDebugTracingOptions { config, tracer, tracer_config, .. } = opts; @@ -737,6 +744,11 @@ where return Ok((frame.into(), res.state)) } }, + #[cfg(not(feature = "js-tracer"))] + GethDebugTracerType::JsTracer(_) => { + Err(EthApiError::Unsupported("JS Tracer is not enabled").into()) + } + #[cfg(feature = "js-tracer")] GethDebugTracerType::JsTracer(code) => { let config = tracer_config.into_json(); let mut inspector = JsInspector::with_transaction_context( From 8c662315d4776f9090592a1c1968129f6ab5578e Mon Sep 17 00:00:00 2001 From: nk_ysg Date: Thu, 22 Aug 2024 18:45:06 +0800 Subject: [PATCH 2/3] update style --- crates/rpc/rpc/src/debug.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/rpc/rpc/src/debug.rs b/crates/rpc/rpc/src/debug.rs index f6c294142875..b7173c44c13b 100644 --- a/crates/rpc/rpc/src/debug.rs +++ b/crates/rpc/rpc/src/debug.rs @@ -33,8 +33,6 @@ use revm::{ primitives::{db::DatabaseCommit, BlockEnv, CfgEnvWithHandlerCfg, Env, EnvWithHandlerCfg}, StateBuilder, }; -#[cfg(feature = "js-tracer")] -use revm_inspectors::tracing::js::JsInspector; use revm_inspectors::tracing::{ FourByteInspector, MuxInspector, TracingInspector, TracingInspectorConfig, TransactionContext, }; @@ -408,7 +406,8 @@ where let db = db.0; let mut inspector = - JsInspector::new(code, config).map_err(Eth::Error::from_eth_err)?; + revm_inspectors::tracing::js::JsInspector::new(code, config) + .map_err(Eth::Error::from_eth_err)?; let (res, _) = this.eth_api().inspect(&mut *db, env.clone(), &mut inspector)?; inspector.json_result(res, &env, db).map_err(Eth::Error::from_eth_err) @@ -751,12 +750,13 @@ where #[cfg(feature = "js-tracer")] GethDebugTracerType::JsTracer(code) => { let config = tracer_config.into_json(); - let mut inspector = JsInspector::with_transaction_context( - code, - config, - transaction_context.unwrap_or_default(), - ) - .map_err(Eth::Error::from_eth_err)?; + let mut inspector = + revm_inspectors::tracing::js::JsInspector::with_transaction_context( + code, + config, + transaction_context.unwrap_or_default(), + ) + .map_err(Eth::Error::from_eth_err)?; let (res, env) = self.eth_api().inspect(&mut *db, env, &mut inspector)?; let state = res.state.clone(); From 780cf5de9746fc6543a3a8f84ec72c4f867aef1e Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 22 Aug 2024 14:12:16 +0200 Subject: [PATCH 3/3] touchups --- crates/rpc/rpc-builder/Cargo.toml | 2 +- crates/rpc/rpc/src/debug.rs | 5 ++--- crates/rpc/rpc/src/lib.rs | 3 +++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/rpc/rpc-builder/Cargo.toml b/crates/rpc/rpc-builder/Cargo.toml index d410268a2df2..1e693ceb0d9f 100644 --- a/crates/rpc/rpc-builder/Cargo.toml +++ b/crates/rpc/rpc-builder/Cargo.toml @@ -17,7 +17,7 @@ reth-ipc.workspace = true reth-network-api.workspace = true reth-node-core.workspace = true reth-provider.workspace = true -reth-rpc.workspace = true +reth-rpc = { workspace = true, features = ["js-tracer"] } reth-rpc-api.workspace = true reth-rpc-eth-api.workspace = true reth-rpc-layer.workspace = true diff --git a/crates/rpc/rpc/src/debug.rs b/crates/rpc/rpc/src/debug.rs index b7173c44c13b..d467392a4dfa 100644 --- a/crates/rpc/rpc/src/debug.rs +++ b/crates/rpc/rpc/src/debug.rs @@ -676,8 +676,7 @@ where opts: GethDebugTracingOptions, env: EnvWithHandlerCfg, db: &mut StateCacheDb<'_>, - #[cfg(not(feature = "js-tracer"))] _transaction_context: Option, - #[cfg(feature = "js-tracer")] transaction_context: Option, + _transaction_context: Option, ) -> Result<(GethTrace, revm_primitives::EvmState), Eth::Error> { let GethDebugTracingOptions { config, tracer, tracer_config, .. } = opts; @@ -754,7 +753,7 @@ where revm_inspectors::tracing::js::JsInspector::with_transaction_context( code, config, - transaction_context.unwrap_or_default(), + _transaction_context.unwrap_or_default(), ) .map_err(Eth::Error::from_eth_err)?; let (res, env) = self.eth_api().inspect(&mut *db, env, &mut inspector)?; diff --git a/crates/rpc/rpc/src/lib.rs b/crates/rpc/rpc/src/lib.rs index eec14981bf57..8954dd305a1e 100644 --- a/crates/rpc/rpc/src/lib.rs +++ b/crates/rpc/rpc/src/lib.rs @@ -2,6 +2,9 @@ //! //! Provides the implementation of all RPC interfaces. //! +//! ## Feature Flags +//! +//! - `js-tracer`: Enables support for `debug_` Javascript tracer. //! //! ## Note on blocking behaviour //!