Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Fix bugfix hard fork logic (#9138)
Browse files Browse the repository at this point in the history
* Fix bugfix hard fork logic

* Remove dustProtectionTransition from bugfix category

EIP-168 is not enabled by default

* Remove unnecessary 'static
  • Loading branch information
sorpaas authored and debris committed Jul 19, 2018
1 parent 0ce0484 commit b914912
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
10 changes: 6 additions & 4 deletions ethcore/src/miner/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
24 changes: 16 additions & 8 deletions ethcore/src/spec/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn fmt_err<F: ::std::fmt::Display>(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.
Expand Down Expand Up @@ -188,13 +188,21 @@ 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<&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");
}

None
}
}

Expand Down

0 comments on commit b914912

Please sign in to comment.