diff --git a/ethcore/res/ethereum/kovan.json b/ethcore/res/ethereum/kovan.json index 325b7cdf6..71eab873d 100644 --- a/ethcore/res/ethereum/kovan.json +++ b/ethcore/res/ethereum/kovan.json @@ -23,7 +23,8 @@ ] }, "validateScoreTransition": 1000000, - "validateStepTransition": 1500000 + "validateStepTransition": 1500000, + "maximumUncleCount": 2 } } }, diff --git a/ethcore/src/engines/authority_round/mod.rs b/ethcore/src/engines/authority_round/mod.rs index 27bd678a9..8c693ca07 100644 --- a/ethcore/src/engines/authority_round/mod.rs +++ b/ethcore/src/engines/authority_round/mod.rs @@ -65,6 +65,8 @@ pub struct AuthorityRoundParams { pub immediate_transitions: bool, /// Block reward in base units. pub block_reward: U256, + /// Number of accepted uncles. + pub maximum_uncle_count: usize, } impl From for AuthorityRoundParams { @@ -77,6 +79,7 @@ impl From for AuthorityRoundParams { validate_step_transition: p.validate_step_transition.map_or(0, Into::into), immediate_transitions: p.immediate_transitions.unwrap_or(false), block_reward: p.block_reward.map_or_else(Default::default, Into::into), + maximum_uncle_count: p.maximum_uncle_count.map_or(0, Into::into), } } } @@ -218,6 +221,7 @@ pub struct AuthorityRound { epoch_manager: Mutex, immediate_transitions: bool, block_reward: U256, + maximum_uncle_count: usize, machine: EthereumMachine, } @@ -365,6 +369,7 @@ impl AuthorityRound { epoch_manager: Mutex::new(EpochManager::blank()), immediate_transitions: our_params.immediate_transitions, block_reward: our_params.block_reward, + maximum_uncle_count: our_params.maximum_uncle_count, machine: machine, }); @@ -436,6 +441,8 @@ impl Engine for AuthorityRound { ] } + fn maximum_uncle_count(&self) -> usize { self.maximum_uncle_count } + fn populate_from_parent(&self, header: &mut Header, parent: &Header) { // Chain scoring: total weight is sqrt(U256::max_value())*height - step let new_difficulty = U256::from(U128::max_value()) + header_step(parent).expect("Header has been verified; qed").into() - self.step.load().into(); @@ -949,6 +956,7 @@ mod tests { validate_score_transition: 0, validate_step_transition: 0, immediate_transitions: true, + maximum_uncle_count: 0, block_reward: Default::default(), }; diff --git a/ethcore/src/engines/mod.rs b/ethcore/src/engines/mod.rs index 802b4ab88..89de861bb 100644 --- a/ethcore/src/engines/mod.rs +++ b/ethcore/src/engines/mod.rs @@ -192,7 +192,7 @@ pub trait Engine: Sync + Send { fn extra_info(&self, _header: &M::Header) -> BTreeMap { BTreeMap::new() } /// Maximum number of uncles a block is allowed to declare. - fn maximum_uncle_count(&self) -> usize { 2 } + fn maximum_uncle_count(&self) -> usize { 0 } /// The number of generations back that uncles can be. fn maximum_uncle_age(&self) -> usize { 6 } diff --git a/ethcore/src/engines/null_engine.rs b/ethcore/src/engines/null_engine.rs index 1c7edc99b..518f0f8f5 100644 --- a/ethcore/src/engines/null_engine.rs +++ b/ethcore/src/engines/null_engine.rs @@ -95,6 +95,8 @@ impl Engine for NullEngine { self.machine.note_rewards(block, &[(author, result_block_reward)], &uncle_rewards) } + fn maximum_uncle_count(&self) -> usize { 2 } + fn verify_local_seal(&self, _header: &M::Header) -> Result<(), M::Error> { Ok(()) } diff --git a/ethcore/src/ethereum/ethash.rs b/ethcore/src/ethereum/ethash.rs index a49ba2e2a..3ecccd9a8 100644 --- a/ethcore/src/ethereum/ethash.rs +++ b/ethcore/src/ethereum/ethash.rs @@ -181,6 +181,8 @@ impl Engine for Arc { } } + fn maximum_uncle_count(&self) -> usize { 2 } + fn populate_from_parent(&self, header: &mut Header, parent: &Header) { let difficulty = self.calculate_difficulty(header, parent); header.set_difficulty(difficulty); diff --git a/json/src/spec/authority_round.rs b/json/src/spec/authority_round.rs index 984e2eff2..b3e75a6b4 100644 --- a/json/src/spec/authority_round.rs +++ b/json/src/spec/authority_round.rs @@ -43,6 +43,8 @@ pub struct AuthorityRoundParams { /// Reward per block in wei. #[serde(rename="blockReward")] pub block_reward: Option, + #[serde(rename="maximumUncleCount")] + pub maximum_uncle_count: Option, } /// Authority engine deserialization.