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

feat: run revm-inspectors via CLI hooks #1850

Merged
merged 3 commits into from
Mar 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
feat(cli): expose inspector hooks
  • Loading branch information
gakonst committed Mar 19, 2023
commit 1deed17cbdc64ba598a0fb95a6f934e526abca1c
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions bin/reth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ reth-primitives = { path = "../../crates/primitives", features = ["arbitrary"] }
reth-db = { path = "../../crates/storage/db", features = ["mdbx", "test-utils"] }
# TODO: Temporary use of the test-utils feature
reth-provider = { path = "../../crates/storage/provider", features = ["test-utils"] }
reth-revm-inspectors = { path = "../../crates/revm/revm-inspectors" }
reth-staged-sync = { path = "../../crates/staged-sync" }
reth-stages = { path = "../../crates/stages"}
reth-interfaces = { path = "../../crates/interfaces", features = ["test-utils"] }
Expand Down
31 changes: 30 additions & 1 deletion bin/reth/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ use reth_network::{
error::NetworkError, FetchClient, NetworkConfig, NetworkHandle, NetworkManager,
};
use reth_network_api::NetworkInfo;
use reth_primitives::{BlockHashOrNumber, ChainSpec, Head, Header, SealedHeader, H256};
use reth_primitives::{BlockHashOrNumber, ChainSpec, Head, Header, SealedHeader, TxHash, H256};
use reth_provider::{BlockProvider, HeaderProvider, ShareableDatabase};
use reth_revm_inspectors::stack::Hook;
use reth_rpc_engine_api::{EngineApi, EngineApiHandle};
use reth_staged_sync::{
utils::{
Expand Down Expand Up @@ -128,6 +129,18 @@ pub struct Command {

#[clap(flatten)]
rpc: RpcServerArgs,

#[arg(long = "debug.print-inspector", help_heading = "Debug")]
print_inspector: bool,

#[arg(long = "debug.hook-block", help_heading = "Debug")]
hook_block: Option<u64>,

#[arg(long = "debug.hook-transaction", help_heading = "Debug")]
hook_transaction: Option<TxHash>,

#[arg(long = "debug.hook-all", help_heading = "Debug")]
hook_all: bool,
}

impl Command {
Expand Down Expand Up @@ -478,8 +491,24 @@ impl Command {
}

let (tip_tx, tip_rx) = watch::channel(H256::zero());
use reth_revm_inspectors::stack::InspectorStackConfig;
let factory = reth_executor::Factory::new(self.chain.clone());

let stack_config = InspectorStackConfig {
use_printer_tracer: self.print_inspector,
hook: if let Some(hook_block) = self.hook_block {
Hook::Block(hook_block)
} else if let Some(tx) = self.hook_transaction {
Hook::Transaction(tx)
} else if self.hook_all {
Hook::All
} else {
Hook::None
},
};

let factory = factory.with_stack_config(stack_config);

let header_mode =
if continuous { HeaderSyncMode::Continuous } else { HeaderSyncMode::Tip(tip_rx) };
let pipeline = builder
Expand Down