Replace dev chain special case with preset
Add --min-gas-price (does the same as legacy --gasprice) and tweak gas_pricer_config() and test cases. Dev preset will still be overridden by CLI arguments, including --gasprice.
This commit is contained in:
parent
451ef7f09b
commit
e0b15116a5
@ -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"
|
||||
|
@ -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<String> = 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<String>,
|
||||
tx_time_limit: Option<u64>,
|
||||
relay_set: Option<String>,
|
||||
min_gas_price: Option<String>,
|
||||
usd_per_tx: Option<String>,
|
||||
usd_per_eth: Option<String>,
|
||||
price_update_period: Option<String>,
|
||||
@ -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()),
|
||||
|
6
parity/cli/presets/config.dev.toml
Normal file
6
parity/cli/presets/config.dev.toml
Normal file
@ -0,0 +1,6 @@
|
||||
[parity]
|
||||
chain = "dev"
|
||||
|
||||
[mining]
|
||||
reseal_min_period = 0
|
||||
min_gas_price = "0"
|
@ -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())
|
||||
}
|
||||
}
|
@ -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.
|
||||
|
@ -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()));
|
||||
|
Loading…
Reference in New Issue
Block a user