From 548a3040786c5e95cd50e9b9cf4030a41e3f8cea Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Tue, 17 Jul 2018 08:20:28 +0800 Subject: [PATCH 1/3] Fix bugfix hard fork logic --- ethcore/src/miner/miner.rs | 10 ++++++---- ethcore/src/spec/spec.rs | 28 ++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/ethcore/src/miner/miner.rs b/ethcore/src/miner/miner.rs index 167a58d2359..90d28f44ecc 100644 --- a/ethcore/src/miner/miner.rs +++ b/ethcore/src/miner/miner.rs @@ -1088,10 +1088,12 @@ impl miner::MinerService for Miner { // refuse to seal the first block of the chain if it contains hard forks // which should be on by default. - if block.block().header().number() == 1 && self.engine.params().contains_bugfix_hard_fork() { - warn!("Your chain specification contains one or more hard forks which are required to be \ - on by default. Please remove these forks and start your chain again."); - return; + if block.block().header().number() == 1 { + if let Some(name) = self.engine.params().nonzero_bugfix_hard_fork() { + warn!("Your chain specification contains one or more hard forks which are required to be \ + on by default. Please remove these forks and start your chain again: {}.", name); + return; + } } match self.engine.seals_internally() { diff --git a/ethcore/src/spec/spec.rs b/ethcore/src/spec/spec.rs index e8c316be5f2..6c4ca3b2c1d 100644 --- a/ethcore/src/spec/spec.rs +++ b/ethcore/src/spec/spec.rs @@ -57,7 +57,7 @@ fn fmt_err(f: F) -> String { /// Parameters common to ethereum-like blockchains. /// NOTE: when adding bugfix hard-fork parameters, -/// add to `contains_bugfix_hard_fork` +/// add to `nonzero_bugfix_hard_fork` /// /// we define a "bugfix" hard fork as any hard fork which /// you would put on-by-default in a new chain. @@ -188,13 +188,25 @@ impl CommonParams { } } - /// Whether these params contain any bug-fix hard forks. - pub fn contains_bugfix_hard_fork(&self) -> bool { - self.eip98_transition != 0 && self.eip155_transition != 0 && - self.validate_receipts_transition != 0 && self.eip86_transition != 0 && - self.eip140_transition != 0 && self.eip210_transition != 0 && - self.eip211_transition != 0 && self.eip214_transition != 0 && - self.validate_chain_id_transition != 0 && self.dust_protection_transition != 0 + /// Return Some if the current parameters contain a bugfix hard fork not on block 0. + pub fn nonzero_bugfix_hard_fork(&self) -> Option<&'static str> { + if self.eip155_transition != 0 { + return Some("eip155Transition"); + } + + if self.validate_receipts_transition != 0 { + return Some("validateReceiptsTransition"); + } + + if self.validate_chain_id_transition != 0 { + return Some("validateChainIdTransition"); + } + + if self.dust_protection_transition != 0 { + return Some("dustProtectionTransition"); + } + + None } } From 13d50006102170d8121b196582428d022619c6b5 Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Tue, 17 Jul 2018 10:16:03 +0800 Subject: [PATCH 2/3] Remove dustProtectionTransition from bugfix category EIP-168 is not enabled by default --- ethcore/src/spec/spec.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ethcore/src/spec/spec.rs b/ethcore/src/spec/spec.rs index 6c4ca3b2c1d..95ec4a43e8d 100644 --- a/ethcore/src/spec/spec.rs +++ b/ethcore/src/spec/spec.rs @@ -202,10 +202,6 @@ impl CommonParams { return Some("validateChainIdTransition"); } - if self.dust_protection_transition != 0 { - return Some("dustProtectionTransition"); - } - None } } From f6489423ec626d7a64cdbce86b9082a64eb840ae Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Wed, 18 Jul 2018 19:39:03 +0800 Subject: [PATCH 3/3] Remove unnecessary 'static --- ethcore/src/spec/spec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethcore/src/spec/spec.rs b/ethcore/src/spec/spec.rs index 95ec4a43e8d..d88bdb83364 100644 --- a/ethcore/src/spec/spec.rs +++ b/ethcore/src/spec/spec.rs @@ -189,7 +189,7 @@ impl CommonParams { } /// Return Some if the current parameters contain a bugfix hard fork not on block 0. - pub fn nonzero_bugfix_hard_fork(&self) -> Option<&'static str> { + pub fn nonzero_bugfix_hard_fork(&self) -> Option<&str> { if self.eip155_transition != 0 { return Some("eip155Transition"); }