Skip to content

Commit

Permalink
Merge branch 'main' into feat/preload-cached-reads
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Jan 9, 2024
2 parents c42025b + 6ad221f commit e86b1c3
Show file tree
Hide file tree
Showing 11 changed files with 393 additions and 11 deletions.
7 changes: 7 additions & 0 deletions bin/reth/src/args/debug_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use clap::Args;
use reth_primitives::{TxHash, B256};
use std::path::PathBuf;

/// Parameters for debugging purposes
#[derive(Debug, Args, PartialEq, Default)]
Expand Down Expand Up @@ -57,6 +58,12 @@ pub struct DebugArgs {
conflicts_with = "hook_transaction"
)]
pub hook_all: bool,

/// The path to store engine API messages at.
/// If specified, all of the intercepted engine API messages
/// will be written to specified location.
#[arg(long = "debug.engine-api-store", help_heading = "Debug", value_name = "PATH")]
pub engine_api_store: Option<PathBuf>,
}

#[cfg(test)]
Expand Down
11 changes: 9 additions & 2 deletions bin/reth/src/args/txpool_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
use crate::cli::config::RethTransactionPoolConfig;
use clap::Args;
use reth_primitives::Address;
use reth_transaction_pool::{
LocalTransactionConfig, PoolConfig, PriceBumpConfig, SubPoolLimit, DEFAULT_PRICE_BUMP,
REPLACE_BLOB_PRICE_BUMP, TXPOOL_MAX_ACCOUNT_SLOTS_PER_SENDER,
TXPOOL_SUBPOOL_MAX_SIZE_MB_DEFAULT, TXPOOL_SUBPOOL_MAX_TXS_DEFAULT,
};

/// Parameters for debugging purposes
#[derive(Debug, Args, PartialEq)]
#[clap(next_help_heading = "TxPool")]
Expand Down Expand Up @@ -47,6 +47,9 @@ pub struct TxPoolArgs {
/// Flag to disable local transaction exemptions.
#[arg(long = "txpool.nolocals")]
pub no_locals: bool,
/// Flag to allow certain addresses as local
#[arg(long = "txpool.locals")]
pub locals: Vec<Address>,
}

impl Default for TxPoolArgs {
Expand All @@ -62,6 +65,7 @@ impl Default for TxPoolArgs {
price_bump: DEFAULT_PRICE_BUMP,
blob_transaction_price_bump: REPLACE_BLOB_PRICE_BUMP,
no_locals: false,
locals: Default::default(),
}
}
}
Expand All @@ -70,7 +74,10 @@ impl RethTransactionPoolConfig for TxPoolArgs {
/// Returns transaction pool configuration.
fn pool_config(&self) -> PoolConfig {
PoolConfig {
local_transactions_config: LocalTransactionConfig { no_exemptions: self.no_locals },
local_transactions_config: LocalTransactionConfig {
no_exemptions: self.no_locals,
local_addresses: self.locals.clone().into_iter().collect(),
},
pending_limit: SubPoolLimit {
max_txs: self.pending_max_count,
max_size: self.pending_max_size * 1024 * 1024,
Expand Down
16 changes: 14 additions & 2 deletions bin/reth/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ use crate::{
db_type::{DatabaseBuilder, DatabaseInstance},
ext::{RethCliExt, RethNodeCommandConfig},
},
commands::node::{cl_events::ConsensusLayerHealthEvents, events},
commands::{
debug_cmd::EngineApiStore,
node::{cl_events::ConsensusLayerHealthEvents, events},
},
dirs::{ChainPath, DataDirPath, MaybePlatformPath},
init::init_genesis,
prometheus_exporter,
Expand Down Expand Up @@ -1109,7 +1112,16 @@ impl<DB: Database + DatabaseMetrics + DatabaseMetadata + 'static> NodeBuilderWit
let payload_builder =
ext.spawn_payload_builder_service(&self.config.builder, &components)?;

let (consensus_engine_tx, consensus_engine_rx) = unbounded_channel();
let (consensus_engine_tx, mut consensus_engine_rx) = unbounded_channel();
if let Some(store_path) = self.config.debug.engine_api_store.clone() {
let (engine_intercept_tx, engine_intercept_rx) = unbounded_channel();
let engine_api_store = EngineApiStore::new(store_path);
executor.spawn_critical(
"engine api interceptor",
engine_api_store.intercept(consensus_engine_rx, engine_intercept_tx),
);
consensus_engine_rx = engine_intercept_rx;
};
let max_block = self.config.max_block(&network_client, provider_factory.clone()).await?;

// Configure the pipeline
Expand Down
6 changes: 6 additions & 0 deletions bin/reth/src/commands/debug_cmd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ mod execution;
mod in_memory_merkle;
mod merkle;

mod replay_engine;
pub(crate) use replay_engine::EngineApiStore;

/// `reth debug` command
#[derive(Debug, Parser)]
pub struct Command {
Expand All @@ -27,6 +30,8 @@ pub enum Subcommands {
InMemoryMerkle(in_memory_merkle::Command),
/// Debug block building.
BuildBlock(build_block::Command),
/// Debug engine API by replaying stored messages.
ReplayEngine(replay_engine::Command),
}

impl Command {
Expand All @@ -37,6 +42,7 @@ impl Command {
Subcommands::Merkle(command) => command.execute(ctx).await,
Subcommands::InMemoryMerkle(command) => command.execute(ctx).await,
Subcommands::BuildBlock(command) => command.execute(ctx).await,
Subcommands::ReplayEngine(command) => command.execute(ctx).await,
}
}
}
Loading

0 comments on commit e86b1c3

Please sign in to comment.