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

Disable uncles by default #7006

Merged
merged 1 commit into from
Nov 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ethcore/res/ethereum/kovan.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
]
},
"validateScoreTransition": 1000000,
"validateStepTransition": 1500000
"validateStepTransition": 1500000,
"maximumUncleCount": 2
}
}
},
Expand Down
8 changes: 8 additions & 0 deletions ethcore/src/engines/authority_round/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ethjson::spec::AuthorityRoundParams> for AuthorityRoundParams {
Expand All @@ -77,6 +79,7 @@ impl From<ethjson::spec::AuthorityRoundParams> 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),
}
}
}
Expand Down Expand Up @@ -218,6 +221,7 @@ pub struct AuthorityRound {
epoch_manager: Mutex<EpochManager>,
immediate_transitions: bool,
block_reward: U256,
maximum_uncle_count: usize,
machine: EthereumMachine,
}

Expand Down Expand Up @@ -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,
});

Expand Down Expand Up @@ -436,6 +441,8 @@ impl Engine<EthereumMachine> 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();
Expand Down Expand Up @@ -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(),
};

Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/engines/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub trait Engine<M: Machine>: Sync + Send {
fn extra_info(&self, _header: &M::Header) -> BTreeMap<String, String> { 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 }

Expand Down
2 changes: 2 additions & 0 deletions ethcore/src/engines/null_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ impl<M: WithBalances> Engine<M> for NullEngine<M> {
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(())
}
Expand Down
2 changes: 2 additions & 0 deletions ethcore/src/ethereum/ethash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ impl Engine<EthereumMachine> for Arc<Ethash> {
}
}

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);
Expand Down
2 changes: 2 additions & 0 deletions json/src/spec/authority_round.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ pub struct AuthorityRoundParams {
/// Reward per block in wei.
#[serde(rename="blockReward")]
pub block_reward: Option<Uint>,
#[serde(rename="maximumUncleCount")]
pub maximum_uncle_count: Option<Uint>,
}

/// Authority engine deserialization.
Expand Down