diff --git a/ethcore/src/block.rs b/ethcore/src/block.rs index 2f14d8d0ad0..56cfc1c4c14 100644 --- a/ethcore/src/block.rs +++ b/ethcore/src/block.rs @@ -497,7 +497,7 @@ pub(crate) fn enact( last_hashes, // Engine such as Clique will calculate author from extra_data. // this is only important for executing contracts as the 'executive_author'. - engine.executive_author(&header), + engine.executive_author(&header)?, (3141562.into(), 31415620.into()), vec![], is_epoch_begin, diff --git a/ethcore/src/engines/clique/mod.rs b/ethcore/src/engines/clique/mod.rs index 01553f76e84..efd7ece6cb3 100644 --- a/ethcore/src/engines/clique/mod.rs +++ b/ethcore/src/engines/clique/mod.rs @@ -153,7 +153,7 @@ impl VoteType { } /// Clique Engine implementation -/// block_state_by_hash -> block state indexed by header hash. +// block_state_by_hash -> block state indexed by header hash. #[cfg(not(test))] pub struct Clique { epoch_length: u64, @@ -688,7 +688,6 @@ impl Engine for Clique { } // Our task here is to set difficulty - // TODO:(niklasad1): Return `Result<(), Error>` here instead fn populate_from_parent(&self, header: &mut Header, parent: &Header) { // TODO(https://github.com/paritytech/parity-ethereum/issues/10410): this is a horrible hack, // it is due to the fact that enact and miner both use OpenBlock::new() which will both call @@ -742,6 +741,8 @@ impl Engine for Clique { fn stop(&mut self) { if let Some(mut s) = self.step_service.as_mut() { Arc::get_mut(&mut s).map(|x| x.stop()); + } else { + warn!(target: "engine", "Stopping `CliqueStepService` failed requires mutable access"); } } @@ -759,8 +760,7 @@ impl Engine for Clique { super::total_difficulty_fork_choice(new, current) } - fn executive_author(&self, header: &Header) -> Address { - // Should have been verified now. - recover_creator(header).expect("Unable to extract creator.") + fn executive_author(&self, header: &Header) -> Result { + recover_creator(header) } } diff --git a/ethcore/src/engines/mod.rs b/ethcore/src/engines/mod.rs index fb8b53f38a9..5124f079db2 100644 --- a/ethcore/src/engines/mod.rs +++ b/ethcore/src/engines/mod.rs @@ -135,7 +135,7 @@ impl fmt::Display for EngineError { FailedSystemCall(ref msg) => format!("Failed to make system call: {}", msg), MalformedMessage(ref msg) => format!("Received malformed consensus message: {}", msg), RequiresClient => format!("Call requires client but none registered"), - RequiresSigner => format!("Call requires client but none registered"), + RequiresSigner => format!("Call requires signer but none registered"), InvalidEngine => format!("Invalid engine specification or implementation"), }; @@ -462,7 +462,9 @@ pub trait Engine: Sync + Send { fn fork_choice(&self, new: &ExtendedHeader, best: &ExtendedHeader) -> ForkChoice; /// Returns author should used when executing tx's for this block. - fn executive_author(&self, header: &Header) -> Address { *header.author() } + fn executive_author(&self, header: &Header) -> Result { + Ok(*header.author()) + } } /// Check whether a given block is the best block based on the default total difficulty rule. diff --git a/json/src/spec/engine.rs b/json/src/spec/engine.rs index 5de42eb22df..cfa1d8cafd1 100644 --- a/json/src/spec/engine.rs +++ b/json/src/spec/engine.rs @@ -136,7 +136,7 @@ mod tests { let s = r#"{ "clique": { "params": { - "peorid" : 15, + "period": 15, "epoch": 30000 } }