diff --git a/parity/cli/config.full.toml b/parity/cli/config.full.toml index 624c0ccdf..0cc365231 100644 --- a/parity/cli/config.full.toml +++ b/parity/cli/config.full.toml @@ -101,6 +101,7 @@ reseal_min_period = 4000 reseal_max_period = 60000 work_queue_size = 20 relay_set = "cheap" +min_gas_price = "" usd_per_tx = "0.0025" usd_per_eth = "auto" price_update_period = "hourly" diff --git a/parity/cli/mod.rs b/parity/cli/mod.rs index 22dda5090..02dc18d38 100644 --- a/parity/cli/mod.rs +++ b/parity/cli/mod.rs @@ -269,6 +269,8 @@ usage! { or |c: &Config| otry!(c.mining).tx_time_limit.clone().map(Some), flag_relay_set: String = "cheap", or |c: &Config| otry!(c.mining).relay_set.clone(), + flag_min_gas_price: Option = None, + or |c: &Config| otry!(c.mining).min_gas_price.clone().map(Some), flag_usd_per_tx: String = "0.0025", or |c: &Config| otry!(c.mining).usd_per_tx.clone(), flag_usd_per_eth: String = "auto", @@ -542,6 +544,7 @@ struct Mining { tx_gas_limit: Option, tx_time_limit: Option, relay_set: Option, + min_gas_price: Option, usd_per_tx: Option, usd_per_eth: Option, price_update_period: Option, @@ -808,6 +811,7 @@ mod tests { flag_tx_gas_limit: Some("6283184".into()), flag_tx_time_limit: Some(100u64), flag_relay_set: "cheap".into(), + flag_min_gas_price: Some("".into()), flag_usd_per_tx: "0.0025".into(), flag_usd_per_eth: "auto".into(), flag_price_update_period: "hourly".into(), @@ -1035,6 +1039,7 @@ mod tests { reseal_max_period: Some(60000), work_queue_size: None, relay_set: None, + min_gas_price: None, usd_per_tx: None, usd_per_eth: None, price_update_period: Some("hourly".into()), diff --git a/parity/cli/presets/config.dev.toml b/parity/cli/presets/config.dev.toml new file mode 100644 index 000000000..912a9ffac --- /dev/null +++ b/parity/cli/presets/config.dev.toml @@ -0,0 +1,6 @@ +[parity] +chain = "dev" + +[mining] +reseal_min_period = 0 +min_gas_price = "0" \ No newline at end of file diff --git a/parity/cli/presets/mod.rs b/parity/cli/presets/mod.rs index c13bb788c..5b38ea0cb 100644 --- a/parity/cli/presets/mod.rs +++ b/parity/cli/presets/mod.rs @@ -16,8 +16,7 @@ pub fn preset_config_string(arg: &str) -> Result<&'static str, &str> { match arg.to_lowercase().as_ref() { - "poa" => Ok(include_str!("./config.poa.toml")), - "pow" => Ok(include_str!("./config.pow.toml")), + "dev" => Ok(include_str!("./config.dev.toml")), _ => Err(arg.clone()) } } \ No newline at end of file diff --git a/parity/cli/usage.txt b/parity/cli/usage.txt index 09900a296..60a8229ed 100644 --- a/parity/cli/usage.txt +++ b/parity/cli/usage.txt @@ -295,6 +295,10 @@ Sealing/Mining Options: means we relay nothing if not mining); lenient - Same as strict when mining, and cheap when not (default: {flag_relay_set}). + --min-gas-price STRING Minimum amount of Wei per GAS to be paid for a + transaction to be accepted for mining. Overrides + --basic-tx-usd. + (default: {flag_min_gas_price:?}) --usd-per-tx USD Amount of USD to be paid for a basic transaction (default: {flag_usd_per_tx}). The minimum gas price is set accordingly. diff --git a/parity/configuration.rs b/parity/configuration.rs index 5abe23dca..14c927c10 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -36,7 +36,7 @@ use parity_rpc::NetworkSettings; use cache::CacheConfig; use helpers::{to_duration, to_mode, to_block_id, to_u256, to_pending_set, to_price, replace_home, replace_home_and_local, geth_ipc_path, parity_ipc_path, to_bootnodes, to_addresses, to_address, to_gas_limit, to_queue_strategy}; -use params::{SpecType, ResealPolicy, AccountsConfig, GasPricerConfig, MinerExtras, Pruning, Switch}; +use params::{ResealPolicy, AccountsConfig, GasPricerConfig, MinerExtras, Pruning, Switch}; use ethcore_logger::Config as LogConfig; use dir::{self, Directories, default_hypervisor_path, default_local_path, default_data_path}; use dapps::Configuration as DappsConfiguration; @@ -332,12 +332,6 @@ impl Configuration { let verifier_settings = self.verifier_settings(); - // Special presets are present for the dev chain. - let (gas_pricer, miner_options) = match spec { - SpecType::Dev => (GasPricerConfig::Fixed(0.into()), self.miner_options(0)?), - _ => (self.gas_pricer_config()?, self.miner_options(self.args.flag_reseal_min_period)?), - }; - let run_cmd = RunCmd { cache_config: cache_config, dirs: dirs, @@ -347,14 +341,14 @@ impl Configuration { pruning_memory: self.args.flag_pruning_memory, daemon: daemon, logger_config: logger_config.clone(), - miner_options: miner_options, + miner_options: self.miner_options(self.args.flag_reseal_min_period)?, ws_conf: ws_conf, http_conf: http_conf, ipc_conf: ipc_conf, net_conf: net_conf, network_id: network_id, acc_conf: self.accounts_config()?, - gas_pricer: gas_pricer, + gas_pricer: self.gas_pricer_config()?, miner_extras: self.miner_extras()?, stratum: self.stratum_options()?, update_policy: update_policy, @@ -625,8 +619,10 @@ impl Configuration { U256::from_dec_str(&format!("{:.0}", wei_per_gas)).unwrap() } - if let Some(d) = self.args.flag_gasprice.as_ref() { - return Ok(GasPricerConfig::Fixed(to_u256(d)?)); + if let Some(dec) = self.args.flag_gasprice.as_ref() { + return Ok(GasPricerConfig::Fixed(to_u256(dec)?)); + } else if let Some(dec) = self.args.flag_min_gas_price.as_ref() { + return Ok(GasPricerConfig::Fixed(to_u256(dec)?)); } let usd_per_tx = to_price(&self.args.flag_usd_per_tx)?; @@ -1586,9 +1582,9 @@ mod tests { } #[test] - fn test_dev_chain() { - let args = vec!["parity", "--chain", "dev"]; - let conf = parse(&args); + fn test_dev_preset() { + let args = vec!["parity", "preset", "dev"]; + let conf = Configuration::parse(&args, None).unwrap(); match conf.into_command().unwrap().cmd { Cmd::Run(c) => { assert_eq!(c.gas_pricer, GasPricerConfig::Fixed(0.into()));