From e3214c63c6a47e47c8920aeeb892b5998d2c6d41 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 29 Jun 2016 09:28:56 +0200 Subject: [PATCH] Rearrange fork CLI options. (#1476) * Rearrange fork CLI options. * Fixed compilation --- parity/cli.rs | 21 +++++++++------------ parity/configuration.rs | 26 +++++++++++++++++++++----- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/parity/cli.rs b/parity/cli.rs index 3ee6f31c8..27578df73 100644 --- a/parity/cli.rs +++ b/parity/cli.rs @@ -42,14 +42,12 @@ Protocol Options: --keys-path PATH Specify the path for JSON key files to be found [default: $HOME/.parity/keys]. --identity NAME Specify your node's name. - -DAO-Rescue Soft-fork Options: - --help-rescue-dao Does nothing - on by default. - --dont-help-rescue-dao Votes against the DAO-rescue soft-fork, but supports - it if it is triggered anyway. - Equivalent to --gas-floor-target=3141592. - --dogmatic Ignores all DAO-rescue soft-fork behaviour. Even if - it means losing mining rewards. + --fork POLICY Specifies the client's fork policy. POLICY must be + one of: + dogmatic - sticks rigidly to the standard chain. + dao-soft - votes for the DAO-rescue soft-fork. + normal - goes with whatever fork is decided but + votes for none. [default: normal]. Account Options: --unlock ACCOUNTS Unlock ACCOUNTS for the duration of the execution. @@ -157,9 +155,9 @@ Sealing/Mining Options: web service in turn and fallback on the last known good value [default: auto]. --gas-floor-target GAS Amount of gas per block to target when sealing a new - block [default: 3141592]. + block [default: 4700000]. --gas-cap GAS A cap on how large we will raise the gas limit per - block due to transaction volume [default: 3141592]. + block due to transaction volume [default: 6283184]. --extra-data STRING Specify a custom extra-data for authored blocks, no more than 32 characters. --tx-queue-size LIMIT Maximum amount of transactions in the queue (waiting @@ -262,8 +260,7 @@ pub struct Args { pub flag_chain: String, pub flag_db_path: String, pub flag_identity: String, - pub flag_dont_help_rescue_dao: bool, - pub flag_dogmatic: bool, + pub flag_fork: String, pub flag_unlock: Option, pub flag_password: Vec, pub flag_cache: Option, diff --git a/parity/configuration.rs b/parity/configuration.rs index 4bd0cd493..121d40e6e 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -45,6 +45,13 @@ pub struct Directories { pub signer: String, } +#[derive(Eq, PartialEq, Debug)] +pub enum Policy { + DaoSoft, + Normal, + Dogmatic, +} + impl Configuration { pub fn parse() -> Self { Configuration { @@ -107,9 +114,18 @@ impl Configuration { })) } + pub fn policy(&self) -> Policy { + match self.args.flag_fork.as_str() { + "dao-soft" => Policy::DaoSoft, + "normal" => Policy::Normal, + "dogmatic" => Policy::Dogmatic, + x => die!("{}: Invalid value given for --policy option. Use --help for more info.", x) + } + } + pub fn gas_floor_target(&self) -> U256 { - if self.args.flag_dont_help_rescue_dao || self.args.flag_dogmatic { - 4_700_000.into() + if self.policy() == Policy::DaoSoft { + 3_141_592.into() } else { let d = &self.args.flag_gas_floor_target; U256::from_dec_str(d).unwrap_or_else(|_| { @@ -119,8 +135,8 @@ impl Configuration { } pub fn gas_ceil_target(&self) -> U256 { - if self.args.flag_dont_help_rescue_dao || self.args.flag_dogmatic { - 10_000_000.into() + if self.policy() == Policy::DaoSoft { + 3_141_592.into() } else { let d = &self.args.flag_gas_cap; U256::from_dec_str(d).unwrap_or_else(|_| { @@ -172,7 +188,7 @@ impl Configuration { pub fn spec(&self) -> Spec { match self.chain().as_str() { - "frontier" | "homestead" | "mainnet" => ethereum::new_frontier(!self.args.flag_dogmatic), + "frontier" | "homestead" | "mainnet" => ethereum::new_frontier(self.policy() != Policy::Dogmatic), "morden" | "testnet" => ethereum::new_morden(), "olympic" => ethereum::new_olympic(), f => Spec::load(contents(f).unwrap_or_else(|_| {