From 9072ab4f6482d693610bb70ed84b713e8e19f667 Mon Sep 17 00:00:00 2001 From: pistomat Date: Tue, 25 Jul 2023 10:59:42 +0200 Subject: [PATCH] add an alias and add mining mode as an argument --- bin/reth/src/args/dev_args.rs | 5 ++++- bin/reth/src/node/mod.rs | 14 +++++++++++--- crates/consensus/auto-seal/src/lib.rs | 12 +----------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/bin/reth/src/args/dev_args.rs b/bin/reth/src/args/dev_args.rs index aac9f7eaadeb..5cc02522d1fa 100644 --- a/bin/reth/src/args/dev_args.rs +++ b/bin/reth/src/args/dev_args.rs @@ -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. @@ -60,6 +60,9 @@ mod tests { let args = CommandParser::::parse_from(["reth", "--dev"]).args; assert_eq!(args, DevArgs { dev: true, block_max_transactions: None, block_time: None }); + let args = CommandParser::::parse_from(["reth", "--auto-mine"]).args; + assert_eq!(args, DevArgs { dev: true, block_max_transactions: None, block_time: None }); + let args = CommandParser::::parse_from([ "reth", "--dev", diff --git a/bin/reth/src/node/mod.rs b/bin/reth/src/node/mod.rs index a16dad165e1e..d032f66fc36f 100644 --- a/bin/reth/src/node/mod.rs +++ b/bin/reth/src/node/mod.rs @@ -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::{ @@ -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(); diff --git a/crates/consensus/auto-seal/src/lib.rs b/crates/consensus/auto-seal/src/lib.rs index eca71d7eee63..1f74802804ba 100644 --- a/crates/consensus/auto-seal/src/lib.rs +++ b/crates/consensus/auto-seal/src/lib.rs @@ -115,8 +115,7 @@ where pool: Pool, to_engine: UnboundedSender, canon_state_notification: CanonStateNotificationSender, - block_max_transactions: Option, - block_time: Option, + mode: MiningMode, ) -> Self { let latest_header = client .latest_header() @@ -124,15 +123,6 @@ where .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,