Skip to content

Commit

Permalink
fix(cleanup nits)
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasad1 committed Mar 13, 2019
1 parent 3a999a6 commit 98218fe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
10 changes: 5 additions & 5 deletions ethcore/src/engines/clique/block_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ impl CliqueBlockState {
Err(EngineError::CliqueTooRecentlySigned(creator))?
}


// Wrong difficulty
let inturn = self.is_inturn(header.number(), &creator);

Expand Down Expand Up @@ -187,11 +186,12 @@ impl CliqueBlockState {

// Contains vote
if *header.author() != NULL_AUTHOR {
let nonce: H64 = header.decode_seal::<Vec<_>>()?.get(1)
.cloned()
.map(Into::into)
.ok_or(BlockError::InvalidSeal)?;
let decoded_seal = header.decode_seal::<Vec<_>>()?;
if decoded_seal.len() != 2 {
Err(BlockError::InvalidSealArity(Mismatch { expected: 2, found: decoded_seal.len() }))?
}

let nonce: H64 = decoded_seal[1].into();
self.update_signers_on_vote(VoteType::from_nonce(nonce)?, creator, *header.author(), header.number())?;
}

Expand Down
9 changes: 4 additions & 5 deletions ethcore/src/engines/clique/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ impl Clique {
// Catching up state, note that we don't really store block state for intermediary blocks,
// for speed.
let backfill_start = time::Instant::now();
info!(target: "engine",
trace!(target: "engine",
"Back-filling block state. last_checkpoint_number: {}, target: {}({}).",
last_checkpoint_number, header.number(), header.hash());

Expand Down Expand Up @@ -404,9 +404,9 @@ impl Engine<EthereumMachine> for Clique {
let mut seal: Vec<u8> = Vec::with_capacity(VANITY_LENGTH + SIGNATURE_LENGTH);

// At this point, extra_data should only contain miner vanity.
if header.extra_data().len() > VANITY_LENGTH {
return Err(EngineError::BadExtraDataFieldSize(OutOfBounds {
min: Some(0),
if header.extra_data().len() != VANITY_LENGTH {
Err(BlockError::ExtraDataOutOfBounds(OutOfBounds {
min: Some(VANITY_LENGTH),
max: Some(VANITY_LENGTH),
found: header.extra_data().len()
}))?;
Expand Down Expand Up @@ -688,7 +688,6 @@ impl Engine<EthereumMachine> for Clique {
Ok(state) => state,
};


// It's unclear how to prevent creating new blocks unless we are authorized, the best way (and geth does this too)
// it's just to ignore setting an correct difficulty here, we will check authorization in next step in generate_seal anyway.
if let Some(signer) = self.signer.read().as_ref() {
Expand Down
3 changes: 0 additions & 3 deletions ethcore/src/engines/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ pub enum EngineError {
NotProposer(Mismatch<Address>),
/// Message was not expected.
UnexpectedMessage,
/// Extra data field has an unexpected size.
BadExtraDataFieldSize(OutOfBounds<usize>),
/// Seal field has an unexpected size.
BadSealFieldSize(OutOfBounds<usize>),
/// Validation proof insufficient.
Expand Down Expand Up @@ -129,7 +127,6 @@ impl fmt::Display for EngineError {
NotProposer(ref mis) => format!("Author is not a current proposer: {}", mis),
NotAuthorized(ref address) => format!("Signer {} is not authorized.", address),
UnexpectedMessage => "This Engine should not be fed messages.".into(),
BadExtraDataFieldSize(ref oob) => format!("Extra data field has an unexpected length: {}", oob),
BadSealFieldSize(ref oob) => format!("Seal field has an unexpected length: {}", oob),
InsufficientProof(ref msg) => format!("Insufficient validation proof: {}", msg),
FailedSystemCall(ref msg) => format!("Failed to make system call: {}", msg),
Expand Down

0 comments on commit 98218fe

Please sign in to comment.