Skip to content

Commit

Permalink
add an alias and add mining mode as an argument
Browse files Browse the repository at this point in the history
  • Loading branch information
pistomat committed Jul 25, 2023
1 parent 0a86659 commit 9072ab4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
5 changes: 4 additions & 1 deletion bin/reth/src/args/dev_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct DevArgs {
/// Disables network discovery and enables local http server.
/// Prefunds 20 accounts derived by mnemonic "test test test test test test test test test test
/// test junk" with 10 000 ETH each.
#[arg(long = "dev", help_heading = "Dev testnet", verbatim_doc_comment)]
#[arg(long = "dev", alias = "auto-mine", help_heading = "Dev testnet", verbatim_doc_comment)]
pub dev: bool,

/// How many transactions to mine per block.
Expand Down Expand Up @@ -60,6 +60,9 @@ mod tests {
let args = CommandParser::<DevArgs>::parse_from(["reth", "--dev"]).args;
assert_eq!(args, DevArgs { dev: true, block_max_transactions: None, block_time: None });

let args = CommandParser::<DevArgs>::parse_from(["reth", "--auto-mine"]).args;
assert_eq!(args, DevArgs { dev: true, block_max_transactions: None, block_time: None });

let args = CommandParser::<DevArgs>::parse_from([
"reth",
"--dev",
Expand Down
14 changes: 11 additions & 3 deletions bin/reth/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use clap::Parser;
use eyre::Context;
use fdlimit::raise_fd_limit;
use futures::{future::Either, pin_mut, stream, stream_select, StreamExt};
use reth_auto_seal_consensus::{AutoSealBuilder, AutoSealConsensus};
use reth_auto_seal_consensus::{AutoSealBuilder, AutoSealConsensus, MiningMode};
use reth_basic_payload_builder::{BasicPayloadJobGenerator, BasicPayloadJobGeneratorConfig};
use reth_beacon_consensus::{BeaconConsensus, BeaconConsensusEngine, MIN_BLOCKS_FOR_PIPELINE_RUN};
use reth_blockchain_tree::{
Expand Down Expand Up @@ -308,14 +308,22 @@ impl Command {
let (mut pipeline, client) = if self.dev.dev {
info!(target: "reth::cli", "Starting Reth in dev mode");

let mining_mode = if let Some(interval) = self.dev.block_time {
MiningMode::interval(interval)
} else if let Some(max_transactions) = self.dev.block_max_transactions {
MiningMode::instant(max_transactions, transaction_pool.pending_transactions_listener())
} else {
info!(target: "reth::cli", "No mining mode specified, defaulting to ReadyTransaction");
MiningMode::instant(1, transaction_pool.pending_transactions_listener())
};

let (_, client, mut task) = AutoSealBuilder::new(
Arc::clone(&self.chain),
blockchain_db.clone(),
transaction_pool.clone(),
consensus_engine_tx.clone(),
canon_state_notification_sender,
self.dev.block_max_transactions,
self.dev.block_time,
mining_mode
)
.build();

Expand Down
12 changes: 1 addition & 11 deletions crates/consensus/auto-seal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,24 +115,14 @@ where
pool: Pool,
to_engine: UnboundedSender<BeaconEngineMessage>,
canon_state_notification: CanonStateNotificationSender,
block_max_transactions: Option<usize>,
block_time: Option<Duration>,
mode: MiningMode,
) -> Self {
let latest_header = client
.latest_header()
.ok()
.flatten()
.unwrap_or_else(|| chain_spec.sealed_genesis_header());

let mode = if let Some(interval) = block_time {
MiningMode::interval(interval)
} else if let Some(max_transactions) = block_max_transactions {
MiningMode::instant(max_transactions, pool.pending_transactions_listener())
} else {
warn!("No mining mode specified, defaulting to ReadyTransaction");
MiningMode::instant(1, pool.pending_transactions_listener())
};

Self {
storage: Storage::new(latest_header),
client,
Expand Down

0 comments on commit 9072ab4

Please sign in to comment.