[ethcore] remove error_chain (#10616)

* Derive Display for BlockError

* Convert error_chain errors

* Convert ethcore usages of errors

* Fix remaining compile errors in ethcore

* Fix other crates

* Fix tests compilation

* Implement error for Snapshot error

* Remove redundant into
This commit is contained in:
Andrew Jones 2019-05-06 14:06:20 +01:00 committed by Andronik Ordian
parent b30b54e446
commit 98b89c8e4f
23 changed files with 265 additions and 241 deletions

2
Cargo.lock generated
View File

@ -710,8 +710,8 @@ dependencies = [
"common-types 0.1.0", "common-types 0.1.0",
"criterion 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "criterion 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)",
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethabi 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethabi 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethabi-contract 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethabi-contract 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethabi-derive 6.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethabi-derive 6.0.2 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -13,8 +13,8 @@ bn = { git = "https://github.com/paritytech/bn", default-features = false }
byteorder = "1.0" byteorder = "1.0"
common-types = { path = "types" } common-types = { path = "types" }
crossbeam = "0.4" crossbeam = "0.4"
derive_more = "0.14.0"
env_logger = { version = "0.5", optional = true } env_logger = { version = "0.5", optional = true }
error-chain = { version = "0.12", default-features = false }
ethabi = "6.0" ethabi = "6.0"
ethabi-contract = "6.0" ethabi-contract = "6.0"
ethabi-derive = "6.0" ethabi-derive = "6.0"

View File

@ -35,7 +35,7 @@ use common_types::encoded;
use common_types::header::Header; use common_types::header::Header;
use common_types::ids::BlockId; use common_types::ids::BlockId;
use ethcore::engines::epoch::{Transition as EpochTransition, PendingTransition as PendingEpochTransition}; use ethcore::engines::epoch::{Transition as EpochTransition, PendingTransition as PendingEpochTransition};
use ethcore::error::{Error, EthcoreResult, ErrorKind as EthcoreErrorKind, BlockError}; use ethcore::error::{Error, EthcoreResult, BlockError};
use ethcore::spec::{Spec, SpecHardcodedSync}; use ethcore::spec::{Spec, SpecHardcodedSync};
use ethereum_types::{H256, H264, U256}; use ethereum_types::{H256, H264, U256};
use heapsize::HeapSizeOf; use heapsize::HeapSizeOf;
@ -403,7 +403,7 @@ impl HeaderChain {
.and_then(|entry| entry.candidates.iter().find(|c| c.hash == parent_hash)) .and_then(|entry| entry.candidates.iter().find(|c| c.hash == parent_hash))
.map(|c| c.total_difficulty) .map(|c| c.total_difficulty)
.ok_or_else(|| BlockError::UnknownParent(parent_hash)) .ok_or_else(|| BlockError::UnknownParent(parent_hash))
.map_err(EthcoreErrorKind::Block)? .map_err(Error::Block)?
}; };
parent_td + *header.difficulty() parent_td + *header.difficulty()

View File

@ -63,8 +63,8 @@ use client::bad_blocks;
use engines::{MAX_UNCLE_AGE, EthEngine, EpochTransition, ForkChoice, EngineError}; use engines::{MAX_UNCLE_AGE, EthEngine, EpochTransition, ForkChoice, EngineError};
use engines::epoch::PendingTransition; use engines::epoch::PendingTransition;
use error::{ use error::{
ImportErrorKind, ExecutionError, CallError, BlockError, ImportError, ExecutionError, CallError, BlockError,
QueueError, QueueErrorKind, Error as EthcoreError, EthcoreResult, ErrorKind as EthcoreErrorKind QueueError, Error as EthcoreError, EthcoreResult,
}; };
use executive::{Executive, Executed, TransactOptions, contract_address}; use executive::{Executive, Executed, TransactOptions, contract_address};
use factory::{Factories, VmFactory}; use factory::{Factories, VmFactory};
@ -357,7 +357,7 @@ impl Importer {
let best_block_number = client.chain.read().best_block_number(); let best_block_number = client.chain.read().best_block_number();
if client.pruning_info().earliest_state > header.number() { if client.pruning_info().earliest_state > header.number() {
warn!(target: "client", "Block import failed for #{} ({})\nBlock is ancient (current best block: #{}).", header.number(), header.hash(), best_block_number); warn!(target: "client", "Block import failed for #{} ({})\nBlock is ancient (current best block: #{}).", header.number(), header.hash(), best_block_number);
bail!("Block is ancient"); return Err("Block is ancient".into());
} }
// Check if parent is in chain // Check if parent is in chain
@ -365,7 +365,7 @@ impl Importer {
Some(h) => h, Some(h) => h,
None => { None => {
warn!(target: "client", "Block import failed for #{} ({}): Parent not found ({}) ", header.number(), header.hash(), header.parent_hash()); warn!(target: "client", "Block import failed for #{} ({}): Parent not found ({}) ", header.number(), header.hash(), header.parent_hash());
bail!("Parent not found"); return Err("Parent not found".into());
} }
}; };
@ -384,13 +384,13 @@ impl Importer {
if let Err(e) = verify_family_result { if let Err(e) = verify_family_result {
warn!(target: "client", "Stage 3 block verification failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e); warn!(target: "client", "Stage 3 block verification failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e);
bail!(e); return Err(e.into());
}; };
let verify_external_result = self.verifier.verify_block_external(&header, engine); let verify_external_result = self.verifier.verify_block_external(&header, engine);
if let Err(e) = verify_external_result { if let Err(e) = verify_external_result {
warn!(target: "client", "Stage 4 block verification failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e); warn!(target: "client", "Stage 4 block verification failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e);
bail!(e); return Err(e.into());
}; };
// Enact Verified Block // Enact Verified Block
@ -415,7 +415,7 @@ impl Importer {
Ok(b) => b, Ok(b) => b,
Err(e) => { Err(e) => {
warn!(target: "client", "Block import failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e); warn!(target: "client", "Block import failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e);
bail!(e); return Err(e.into());
} }
}; };
@ -431,7 +431,7 @@ impl Importer {
// Final Verification // Final Verification
if let Err(e) = self.verifier.verify_block_final(&header, &locked_block.header) { if let Err(e) = self.verifier.verify_block_final(&header, &locked_block.header) {
warn!(target: "client", "Stage 5 block verification failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e); warn!(target: "client", "Stage 5 block verification failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e);
bail!(e); return Err(e.into());
} }
let pending = self.check_epoch_end_signal( let pending = self.check_epoch_end_signal(
@ -1453,12 +1453,12 @@ impl CallContract for Client {
impl ImportBlock for Client { impl ImportBlock for Client {
fn import_block(&self, unverified: Unverified) -> EthcoreResult<H256> { fn import_block(&self, unverified: Unverified) -> EthcoreResult<H256> {
if self.chain.read().is_known(&unverified.hash()) { if self.chain.read().is_known(&unverified.hash()) {
bail!(EthcoreErrorKind::Import(ImportErrorKind::AlreadyInChain)); return Err(EthcoreError::Import(ImportError::AlreadyInChain));
} }
let status = self.block_status(BlockId::Hash(unverified.parent_hash())); let status = self.block_status(BlockId::Hash(unverified.parent_hash()));
if status == BlockStatus::Unknown { if status == BlockStatus::Unknown {
bail!(EthcoreErrorKind::Block(BlockError::UnknownParent(unverified.parent_hash()))); return Err(EthcoreError::Block(BlockError::UnknownParent(unverified.parent_hash())));
} }
let raw = if self.importer.block_queue.is_empty() { let raw = if self.importer.block_queue.is_empty() {
@ -1477,9 +1477,9 @@ impl ImportBlock for Client {
Ok(hash) Ok(hash)
}, },
// we only care about block errors (not import errors) // we only care about block errors (not import errors)
Err((block, EthcoreError(EthcoreErrorKind::Block(err), _))) => { Err((block, EthcoreError::Block(err))) => {
self.importer.bad_blocks.report(block.bytes, format!("{:?}", err)); self.importer.bad_blocks.report(block.bytes, format!("{:?}", err));
bail!(EthcoreErrorKind::Block(err)) return Err(EthcoreError::Block(err))
}, },
Err((_, e)) => Err(e), Err((_, e)) => Err(e),
} }
@ -2214,14 +2214,14 @@ impl IoClient for Client {
{ {
// check block order // check block order
if self.chain.read().is_known(&hash) { if self.chain.read().is_known(&hash) {
bail!(EthcoreErrorKind::Import(ImportErrorKind::AlreadyInChain)); return Err(EthcoreError::Import(ImportError::AlreadyInChain));
} }
let parent_hash = unverified.parent_hash(); let parent_hash = unverified.parent_hash();
// NOTE To prevent race condition with import, make sure to check queued blocks first // NOTE To prevent race condition with import, make sure to check queued blocks first
// (and attempt to acquire lock) // (and attempt to acquire lock)
let is_parent_pending = self.queued_ancient_blocks.read().0.contains(&parent_hash); let is_parent_pending = self.queued_ancient_blocks.read().0.contains(&parent_hash);
if !is_parent_pending && !self.chain.read().is_known(&parent_hash) { if !is_parent_pending && !self.chain.read().is_known(&parent_hash) {
bail!(EthcoreErrorKind::Block(BlockError::UnknownParent(parent_hash))); return Err(EthcoreError::Block(BlockError::UnknownParent(parent_hash)));
} }
} }
@ -2752,7 +2752,9 @@ impl IoChannelQueue {
F: Fn(&Client) + Send + Sync + 'static, F: Fn(&Client) + Send + Sync + 'static,
{ {
let queue_size = self.currently_queued.load(AtomicOrdering::Relaxed); let queue_size = self.currently_queued.load(AtomicOrdering::Relaxed);
ensure!(queue_size < self.limit, QueueErrorKind::Full(self.limit)); if queue_size >= self.limit {
return Err(QueueError::Full(self.limit))
};
let currently_queued = self.currently_queued.clone(); let currently_queued = self.currently_queued.clone();
let result = channel.send(ClientIoMessage::execute(move |client| { let result = channel.send(ClientIoMessage::execute(move |client| {
@ -2765,7 +2767,7 @@ impl IoChannelQueue {
self.currently_queued.fetch_add(count, AtomicOrdering::SeqCst); self.currently_queued.fetch_add(count, AtomicOrdering::SeqCst);
Ok(()) Ok(())
}, },
Err(e) => bail!(QueueErrorKind::Channel(e)), Err(e) => return Err(QueueError::Channel(e)),
} }
} }
} }

View File

@ -29,7 +29,7 @@ use client::EngineClient;
use engines::{Engine, Seal, EngineError, ConstructedVerifier}; use engines::{Engine, Seal, EngineError, ConstructedVerifier};
use engines::block_reward; use engines::block_reward;
use engines::block_reward::{BlockRewardContract, RewardKind}; use engines::block_reward::{BlockRewardContract, RewardKind};
use error::{Error, ErrorKind, BlockError}; use error::{Error, BlockError};
use ethjson; use ethjson;
use machine::{AuxiliaryData, Call, EthereumMachine}; use machine::{AuxiliaryData, Call, EthereumMachine};
use hash::keccak; use hash::keccak;
@ -585,7 +585,7 @@ fn verify_timestamp(step: &Step, header_step: u64) -> Result<(), BlockError> {
let new_oob = OutOfBounds { min, max, found }; let new_oob = OutOfBounds { min, max, found };
Err(BlockError::TemporarilyInvalid(new_oob).into()) Err(BlockError::TemporarilyInvalid(new_oob.into()))
}, },
Ok(_) => Ok(()), Ok(_) => Ok(()),
} }
@ -1342,7 +1342,7 @@ impl Engine<EthereumMachine> for AuthorityRound {
// contract itself. // contract itself.
let res = verify_external(header, &*validators, self.empty_steps_transition); let res = verify_external(header, &*validators, self.empty_steps_transition);
match res { match res {
Err(Error(ErrorKind::Engine(EngineError::NotProposer(_)), _)) => { Err(Error::Engine(EngineError::NotProposer(_))) => {
self.validators.report_benign(header.author(), set_number, header.number()); self.validators.report_benign(header.author(), set_number, header.number());
}, },
Ok(_) => { Ok(_) => {
@ -1570,7 +1570,7 @@ mod tests {
use types::transaction::{Action, Transaction}; use types::transaction::{Action, Transaction};
use engines::{Seal, Engine, EngineError, EthEngine}; use engines::{Seal, Engine, EngineError, EthEngine};
use engines::validator_set::{TestSet, SimpleList}; use engines::validator_set::{TestSet, SimpleList};
use error::{Error, ErrorKind}; use error::Error;
use super::{AuthorityRoundParams, AuthorityRound, EmptyStep, SealedEmptyStep, calculate_score}; use super::{AuthorityRoundParams, AuthorityRound, EmptyStep, SealedEmptyStep, calculate_score};
fn aura<F>(f: F) -> Arc<AuthorityRound> where fn aura<F>(f: F) -> Arc<AuthorityRound> where
@ -1883,7 +1883,7 @@ mod tests {
fn assert_insufficient_proof<T: ::std::fmt::Debug>(result: Result<T, Error>, contains: &str) { fn assert_insufficient_proof<T: ::std::fmt::Debug>(result: Result<T, Error>, contains: &str) {
match result { match result {
Err(Error(ErrorKind::Engine(EngineError::InsufficientProof(ref s)), _)) =>{ Err(Error::Engine(EngineError::InsufficientProof(ref s))) =>{
assert!(s.contains(contains), "Expected {:?} to contain {:?}", s, contains); assert!(s.contains(contains), "Expected {:?} to contain {:?}", s, contains);
}, },
e => assert!(false, "Unexpected result: {:?}", e), e => assert!(false, "Unexpected result: {:?}", e),

View File

@ -551,7 +551,7 @@ impl Engine<EthereumMachine> for Clique {
min: None, min: None,
max: Some(limit), max: Some(limit),
found, found,
}))? }.into()))?
} }
} }
@ -664,7 +664,7 @@ impl Engine<EthereumMachine> for Clique {
min: None, min: None,
max, max,
found, found,
}))? }.into()))?
} }
// Retrieve the parent state // Retrieve the parent state

View File

@ -18,7 +18,7 @@
use block::*; use block::*;
use engines::Engine; use engines::Engine;
use error::{Error, ErrorKind}; use error::Error;
use ethereum_types::{Address, H256}; use ethereum_types::{Address, H256};
use ethkey::{Secret, KeyPair}; use ethkey::{Secret, KeyPair};
use state_db::StateDB; use state_db::StateDB;
@ -715,8 +715,8 @@ fn unauthorized_signer_should_not_be_able_to_sign_block() {
let tester = CliqueTester::with(3, 1, vec!['A']); let tester = CliqueTester::with(3, 1, vec!['A']);
let err = tester.new_block_and_import(CliqueBlockType::Empty, &tester.genesis, None, 'B').unwrap_err(); let err = tester.new_block_and_import(CliqueBlockType::Empty, &tester.genesis, None, 'B').unwrap_err();
match err.kind() { match err {
ErrorKind::Engine(EngineError::NotAuthorized(_)) => (), Error::Engine(EngineError::NotAuthorized(_)) => (),
_ => assert!(true == false, "Wrong error kind"), _ => assert!(true == false, "Wrong error kind"),
} }
} }
@ -727,8 +727,8 @@ fn signer_should_not_be_able_to_sign_two_consequtive_blocks() {
let b = tester.new_block_and_import(CliqueBlockType::Empty, &tester.genesis, None, 'A').unwrap(); let b = tester.new_block_and_import(CliqueBlockType::Empty, &tester.genesis, None, 'A').unwrap();
let err = tester.new_block_and_import(CliqueBlockType::Empty, &b, None, 'A').unwrap_err(); let err = tester.new_block_and_import(CliqueBlockType::Empty, &b, None, 'A').unwrap_err();
match err.kind() { match err {
ErrorKind::Engine(EngineError::CliqueTooRecentlySigned(_)) => (), Error::Engine(EngineError::CliqueTooRecentlySigned(_)) => (),
_ => assert!(true == false, "Wrong error kind"), _ => assert!(true == false, "Wrong error kind"),
} }
} }
@ -744,8 +744,8 @@ fn recent_signers_should_not_reset_on_checkpoint() {
let err = tester.new_block_and_import(CliqueBlockType::Empty, &block, None, 'A').unwrap_err(); let err = tester.new_block_and_import(CliqueBlockType::Empty, &block, None, 'A').unwrap_err();
match err.kind() { match err {
ErrorKind::Engine(EngineError::CliqueTooRecentlySigned(_)) => (), Error::Engine(EngineError::CliqueTooRecentlySigned(_)) => (),
_ => assert!(true == false, "Wrong error kind"), _ => assert!(true == false, "Wrong error kind"),
} }
} }

View File

@ -16,13 +16,10 @@
//! General error types for use in ethcore. //! General error types for use in ethcore.
// Silence: `use of deprecated item 'std::error::Error::cause': replaced by Error::source, which can support downcasting`
// https://github.com/paritytech/parity-ethereum/issues/10302
#![allow(deprecated)]
use std::{fmt, error}; use std::{fmt, error};
use std::time::SystemTime; use std::time::SystemTime;
use derive_more::{Display, From};
use ethereum_types::{H256, U256, Address, Bloom}; use ethereum_types::{H256, U256, Address, Bloom};
use ethkey::Error as EthkeyError; use ethkey::Error as EthkeyError;
use ethtrie::TrieError; use ethtrie::TrieError;
@ -37,118 +34,113 @@ use engines::EngineError;
pub use executed::{ExecutionError, CallError}; pub use executed::{ExecutionError, CallError};
#[derive(Debug, PartialEq, Clone, Eq)]
/// Errors concerning block processing. /// Errors concerning block processing.
#[derive(Debug, Display, PartialEq, Clone, Eq)]
pub enum BlockError { pub enum BlockError {
/// Block has too many uncles. /// Block has too many uncles.
#[display(fmt = "Block has too many uncles. {}", _0)]
TooManyUncles(OutOfBounds<usize>), TooManyUncles(OutOfBounds<usize>),
/// Extra data is of an invalid length. /// Extra data is of an invalid length.
#[display(fmt = "Extra block data too long. {}", _0)]
ExtraDataOutOfBounds(OutOfBounds<usize>), ExtraDataOutOfBounds(OutOfBounds<usize>),
/// Seal is incorrect format. /// Seal is incorrect format.
#[display(fmt = "Block seal in incorrect format: {}", _0)]
InvalidSealArity(Mismatch<usize>), InvalidSealArity(Mismatch<usize>),
/// Block has too much gas used. /// Block has too much gas used.
#[display(fmt = "Block has too much gas used. {}", _0)]
TooMuchGasUsed(OutOfBounds<U256>), TooMuchGasUsed(OutOfBounds<U256>),
/// Uncles hash in header is invalid. /// Uncles hash in header is invalid.
#[display(fmt = "Block has invalid uncles hash: {}", _0)]
InvalidUnclesHash(Mismatch<H256>), InvalidUnclesHash(Mismatch<H256>),
/// An uncle is from a generation too old. /// An uncle is from a generation too old.
#[display(fmt = "Uncle block is too old. {}", _0)]
UncleTooOld(OutOfBounds<BlockNumber>), UncleTooOld(OutOfBounds<BlockNumber>),
/// An uncle is from the same generation as the block. /// An uncle is from the same generation as the block.
#[display(fmt = "Uncle from same generation as block. {}", _0)]
UncleIsBrother(OutOfBounds<BlockNumber>), UncleIsBrother(OutOfBounds<BlockNumber>),
/// An uncle is already in the chain. /// An uncle is already in the chain.
#[display(fmt = "Uncle {} already in chain", _0)]
UncleInChain(H256), UncleInChain(H256),
/// An uncle is included twice. /// An uncle is included twice.
#[display(fmt = "Uncle {} already in the header", _0)]
DuplicateUncle(H256), DuplicateUncle(H256),
/// An uncle has a parent not in the chain. /// An uncle has a parent not in the chain.
#[display(fmt = "Uncle {} has a parent not in the chain", _0)]
UncleParentNotInChain(H256), UncleParentNotInChain(H256),
/// State root header field is invalid. /// State root header field is invalid.
#[display(fmt = "Invalid state root in header: {}", _0)]
InvalidStateRoot(Mismatch<H256>), InvalidStateRoot(Mismatch<H256>),
/// Gas used header field is invalid. /// Gas used header field is invalid.
#[display(fmt = "Invalid gas used in header: {}", _0)]
InvalidGasUsed(Mismatch<U256>), InvalidGasUsed(Mismatch<U256>),
/// Transactions root header field is invalid. /// Transactions root header field is invalid.
#[display(fmt = "Invalid transactions root in header: {}", _0)]
InvalidTransactionsRoot(Mismatch<H256>), InvalidTransactionsRoot(Mismatch<H256>),
/// Difficulty is out of range; this can be used as an looser error prior to getting a definitive /// Difficulty is out of range; this can be used as an looser error prior to getting a definitive
/// value for difficulty. This error needs only provide bounds of which it is out. /// value for difficulty. This error needs only provide bounds of which it is out.
#[display(fmt = "Difficulty out of bounds: {}", _0)]
DifficultyOutOfBounds(OutOfBounds<U256>), DifficultyOutOfBounds(OutOfBounds<U256>),
/// Difficulty header field is invalid; this is a strong error used after getting a definitive /// Difficulty header field is invalid; this is a strong error used after getting a definitive
/// value for difficulty (which is provided). /// value for difficulty (which is provided).
#[display(fmt = "Invalid block difficulty: {}", _0)]
InvalidDifficulty(Mismatch<U256>), InvalidDifficulty(Mismatch<U256>),
/// Seal element of type H256 (max_hash for Ethash, but could be something else for /// Seal element of type H256 (max_hash for Ethash, but could be something else for
/// other seal engines) is out of bounds. /// other seal engines) is out of bounds.
#[display(fmt = "Seal element out of bounds: {}", _0)]
MismatchedH256SealElement(Mismatch<H256>), MismatchedH256SealElement(Mismatch<H256>),
/// Proof-of-work aspect of seal, which we assume is a 256-bit value, is invalid. /// Proof-of-work aspect of seal, which we assume is a 256-bit value, is invalid.
#[display(fmt = "Block has invalid PoW: {}", _0)]
InvalidProofOfWork(OutOfBounds<U256>), InvalidProofOfWork(OutOfBounds<U256>),
/// Some low-level aspect of the seal is incorrect. /// Some low-level aspect of the seal is incorrect.
#[display(fmt = "Block has invalid seal.")]
InvalidSeal, InvalidSeal,
/// Gas limit header field is invalid. /// Gas limit header field is invalid.
#[display(fmt = "Invalid gas limit: {}", _0)]
InvalidGasLimit(OutOfBounds<U256>), InvalidGasLimit(OutOfBounds<U256>),
/// Receipts trie root header field is invalid. /// Receipts trie root header field is invalid.
#[display(fmt = "Invalid receipts trie root in header: {}", _0)]
InvalidReceiptsRoot(Mismatch<H256>), InvalidReceiptsRoot(Mismatch<H256>),
/// Timestamp header field is invalid. /// Timestamp header field is invalid.
InvalidTimestamp(OutOfBounds<SystemTime>), #[display(fmt = "Invalid timestamp in header: {}", _0)]
InvalidTimestamp(OutOfBoundsTime),
/// Timestamp header field is too far in future. /// Timestamp header field is too far in future.
TemporarilyInvalid(OutOfBounds<SystemTime>), #[display(fmt = "Future timestamp in header: {}", _0)]
TemporarilyInvalid(OutOfBoundsTime),
/// Log bloom header field is invalid. /// Log bloom header field is invalid.
#[display(fmt = "Invalid log bloom in header: {}", _0)]
InvalidLogBloom(Box<Mismatch<Bloom>>), InvalidLogBloom(Box<Mismatch<Bloom>>),
/// Number field of header is invalid. /// Number field of header is invalid.
#[display(fmt = "Invalid number in header: {}", _0)]
InvalidNumber(Mismatch<BlockNumber>), InvalidNumber(Mismatch<BlockNumber>),
/// Block number isn't sensible. /// Block number isn't sensible.
#[display(fmt = "Implausible block number. {}", _0)]
RidiculousNumber(OutOfBounds<BlockNumber>), RidiculousNumber(OutOfBounds<BlockNumber>),
/// Timestamp header overflowed /// Timestamp header overflowed
#[display(fmt = "Timestamp overflow")]
TimestampOverflow, TimestampOverflow,
/// Too many transactions from a particular address. /// Too many transactions from a particular address.
#[display(fmt = "Too many transactions from: {}", _0)]
TooManyTransactions(Address), TooManyTransactions(Address),
/// Parent given is unknown. /// Parent given is unknown.
#[display(fmt = "Unknown parent: {}", _0)]
UnknownParent(H256), UnknownParent(H256),
/// Uncle parent given is unknown. /// Uncle parent given is unknown.
#[display(fmt = "Unknown uncle parent: {}", _0)]
UnknownUncleParent(H256), UnknownUncleParent(H256),
/// No transition to epoch number. /// No transition to epoch number.
#[display(fmt = "Unknown transition to epoch number: {}", _0)]
UnknownEpochTransition(u64), UnknownEpochTransition(u64),
} }
impl fmt::Display for BlockError { /// Newtype for Display impl to show seconds
#[derive(Debug, Clone, From, PartialEq, Eq)]
pub struct OutOfBoundsTime(OutOfBounds<SystemTime>);
impl fmt::Display for OutOfBoundsTime {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use self::BlockError::*; let seconds = self.0
.map(|st| st.elapsed().unwrap_or_default().as_secs());
let msg = match *self { f.write_fmt(format_args!("{}", seconds))
TooManyUncles(ref oob) => format!("Block has too many uncles. {}", oob),
ExtraDataOutOfBounds(ref oob) => format!("Extra block data too long. {}", oob),
InvalidSealArity(ref mis) => format!("Block seal in incorrect format: {}", mis),
TooMuchGasUsed(ref oob) => format!("Block has too much gas used. {}", oob),
InvalidUnclesHash(ref mis) => format!("Block has invalid uncles hash: {}", mis),
UncleTooOld(ref oob) => format!("Uncle block is too old. {}", oob),
UncleIsBrother(ref oob) => format!("Uncle from same generation as block. {}", oob),
UncleInChain(ref hash) => format!("Uncle {} already in chain", hash),
DuplicateUncle(ref hash) => format!("Uncle {} already in the header", hash),
UncleParentNotInChain(ref hash) => format!("Uncle {} has a parent not in the chain", hash),
InvalidStateRoot(ref mis) => format!("Invalid state root in header: {}", mis),
InvalidGasUsed(ref mis) => format!("Invalid gas used in header: {}", mis),
InvalidTransactionsRoot(ref mis) => format!("Invalid transactions root in header: {}", mis),
DifficultyOutOfBounds(ref oob) => format!("Invalid block difficulty: {}", oob),
InvalidDifficulty(ref mis) => format!("Invalid block difficulty: {}", mis),
MismatchedH256SealElement(ref mis) => format!("Seal element out of bounds: {}", mis),
InvalidProofOfWork(ref oob) => format!("Block has invalid PoW: {}", oob),
InvalidSeal => "Block has invalid seal.".into(),
InvalidGasLimit(ref oob) => format!("Invalid gas limit: {}", oob),
InvalidReceiptsRoot(ref mis) => format!("Invalid receipts trie root in header: {}", mis),
InvalidTimestamp(ref oob) => {
let oob = oob.map(|st| st.elapsed().unwrap_or_default().as_secs());
format!("Invalid timestamp in header: {}", oob)
},
TemporarilyInvalid(ref oob) => {
let oob = oob.map(|st| st.elapsed().unwrap_or_default().as_secs());
format!("Future timestamp in header: {}", oob)
},
InvalidLogBloom(ref oob) => format!("Invalid log bloom in header: {}", oob),
InvalidNumber(ref mis) => format!("Invalid number in header: {}", mis),
RidiculousNumber(ref oob) => format!("Implausible block number. {}", oob),
UnknownParent(ref hash) => format!("Unknown parent: {}", hash),
UnknownUncleParent(ref hash) => format!("Unknown uncle parent: {}", hash),
UnknownEpochTransition(ref num) => format!("Unknown transition to epoch number: {}", num),
TimestampOverflow => format!("Timestamp overflow"),
TooManyTransactions(ref address) => format!("Too many transactions from: {}", address),
};
f.write_fmt(format_args!("Block error ({})", msg))
} }
} }
@ -158,50 +150,42 @@ impl error::Error for BlockError {
} }
} }
error_chain! { /// Queue error
types { #[derive(Debug, Display, From)]
QueueError, QueueErrorKind, QueueErrorResultExt, QueueErrorResult; pub enum QueueError {
} /// Queue is full
#[display(fmt = "Queue is full ({})", _0)]
Full(usize),
/// Io channel error
#[display(fmt = "Io channel error: {}", _0)]
Channel(::io::IoError)
}
errors { impl error::Error for QueueError {
#[doc = "Queue is full"] fn source(&self) -> Option<&(error::Error + 'static)> {
Full(limit: usize) { match self {
description("Queue is full") QueueError::Channel(e) => Some(e),
display("The queue is full ({})", limit) _ => None,
} }
} }
foreign_links {
Channel(::io::IoError) #[doc = "Io channel error"];
}
} }
error_chain! { /// Block import Error
types { #[derive(Debug, Display)]
ImportError, ImportErrorKind, ImportErrorResultExt, ImportErrorResult; pub enum ImportError {
} /// Already in the block chain.
#[display(fmt = "Block already in chain")]
errors { AlreadyInChain,
#[doc = "Already in the block chain."] /// Already in the block queue
AlreadyInChain { #[display(fmt = "block already in the block queue")]
description("Block already in chain") AlreadyQueued,
display("Block already in chain") /// Already marked as bad from a previous import (could mean parent is bad)
} #[display(fmt = "block known to be bad")]
KnownBad,
#[doc = "Already in the block queue"]
AlreadyQueued {
description("block already in the block queue")
display("block already in the block queue")
}
#[doc = "Already marked as bad from a previous import (could mean parent is bad)."]
KnownBad {
description("block known to be bad")
display("block known to be bad")
}
}
} }
impl error::Error for ImportError {}
/// Api-level error for transaction import /// Api-level error for transaction import
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum TransactionImportError { pub enum TransactionImportError {
@ -214,70 +198,99 @@ pub enum TransactionImportError {
impl From<Error> for TransactionImportError { impl From<Error> for TransactionImportError {
fn from(e: Error) -> Self { fn from(e: Error) -> Self {
match e { match e {
Error(ErrorKind::Transaction(transaction_error), _) => TransactionImportError::Transaction(transaction_error), Error::Transaction(transaction_error) => TransactionImportError::Transaction(transaction_error),
_ => TransactionImportError::Other(format!("other block import error: {:?}", e)), _ => TransactionImportError::Other(format!("other block import error: {:?}", e)),
} }
} }
} }
error_chain! { /// Ethcore Result
types { pub type EthcoreResult<T> = Result<T, Error>;
Error, ErrorKind, ErrorResultExt, EthcoreResult;
}
links { /// Ethcore Error
Import(ImportError, ImportErrorKind) #[doc = "Error concerning block import." ]; #[derive(Debug, Display, From)]
Queue(QueueError, QueueErrorKind) #[doc = "Io channel queue error"]; pub enum Error {
} /// Error concerning block import.
#[display(fmt = "Import error: {}", _0)]
Import(ImportError),
/// Io channel queue error
#[display(fmt = "Queue error: {}", _0)]
Queue(QueueError),
/// Io create error
#[display(fmt = "Io error: {}", _0)]
Io(::io::IoError),
/// Error concerning the Rust standard library's IO subsystem.
#[display(fmt = "Std Io error: {}", _0)]
StdIo(::std::io::Error),
/// Error concerning TrieDBs.
#[display(fmt = "Trie error: {}", _0)]
Trie(TrieError),
/// Error concerning EVM code execution.
#[display(fmt = "Execution error: {}", _0)]
Execution(ExecutionError),
/// Error concerning block processing.
#[display(fmt = "Block error: {}", _0)]
Block(BlockError),
/// Error concerning transaction processing.
#[display(fmt = "Transaction error: {}", _0)]
Transaction(TransactionError),
/// Snappy error
#[display(fmt = "Snappy error: {}", _0)]
Snappy(InvalidInput),
/// Consensus vote error.
#[display(fmt = "Engine error: {}", _0)]
Engine(EngineError),
/// Ethkey error."
#[display(fmt = "Ethkey error: {}", _0)]
Ethkey(EthkeyError),
/// RLP decoding errors
#[display(fmt = "Decoder error: {}", _0)]
Decoder(rlp::DecoderError),
/// Snapshot error.
#[display(fmt = "Snapshot error {}", _0)]
Snapshot(SnapshotError),
/// PoW hash is invalid or out of date.
#[display(fmt = "PoW hash is invalid or out of date.")]
PowHashInvalid,
/// The value of the nonce or mishash is invalid.
#[display(fmt = "The value of the nonce or mishash is invalid.")]
PowInvalid,
/// Unknown engine given
#[display(fmt = "Unknown engine name ({})", _0)]
UnknownEngineName(String),
/// A convenient variant for String.
#[display(fmt = "{}", _0)]
Msg(String),
}
foreign_links { impl error::Error for Error {
Io(::io::IoError) #[doc = "Io create error"]; fn source(&self) -> Option<&(error::Error + 'static)> {
StdIo(::std::io::Error) #[doc = "Error concerning the Rust standard library's IO subsystem."]; match self {
Trie(TrieError) #[doc = "Error concerning TrieDBs."]; Error::Io(e) => Some(e),
Execution(ExecutionError) #[doc = "Error concerning EVM code execution."]; Error::StdIo(e) => Some(e),
Block(BlockError) #[doc = "Error concerning block processing."]; Error::Trie(e) => Some(e),
Transaction(TransactionError) #[doc = "Error concerning transaction processing."]; Error::Execution(e) => Some(e),
Snappy(InvalidInput) #[doc = "Snappy error."]; Error::Block(e) => Some(e),
Engine(EngineError) #[doc = "Consensus vote error."]; Error::Transaction(e) => Some(e),
Ethkey(EthkeyError) #[doc = "Ethkey error."]; Error::Snappy(e) => Some(e),
Decoder(rlp::DecoderError) #[doc = "RLP decoding errors"]; Error::Engine(e) => Some(e),
} Error::Ethkey(e) => Some(e),
Error::Decoder(e) => Some(e),
errors { Error::Snapshot(e) => Some(e),
#[doc = "Snapshot error."] _ => None,
Snapshot(err: SnapshotError) {
description("Snapshot error.")
display("Snapshot error {}", err)
}
#[doc = "PoW hash is invalid or out of date."]
PowHashInvalid {
description("PoW hash is invalid or out of date.")
display("PoW hash is invalid or out of date.")
}
#[doc = "The value of the nonce or mishash is invalid."]
PowInvalid {
description("The value of the nonce or mishash is invalid.")
display("The value of the nonce or mishash is invalid.")
}
#[doc = "Unknown engine given"]
UnknownEngineName(name: String) {
description("Unknown engine name")
display("Unknown engine name ({})", name)
} }
} }
} }
impl From<SnapshotError> for Error { impl From<String> for Error {
fn from(err: SnapshotError) -> Error { fn from(s: String) -> Self {
match err { Error::Msg(s)
SnapshotError::Io(err) => ErrorKind::StdIo(err).into(), }
SnapshotError::Trie(err) => ErrorKind::Trie(err).into(), }
SnapshotError::Decoder(err) => err.into(),
other => ErrorKind::Snapshot(other).into(), impl From<&str> for Error {
} fn from(s: &str) -> Self {
Error::Msg(s.into())
} }
} }

View File

@ -490,7 +490,7 @@ mod tests {
use ethereum_types::{H64, H256, U256, Address}; use ethereum_types::{H64, H256, U256, Address};
use block::*; use block::*;
use test_helpers::get_temp_state_db; use test_helpers::get_temp_state_db;
use error::{BlockError, Error, ErrorKind}; use error::{BlockError, Error};
use types::header::Header; use types::header::Header;
use spec::Spec; use spec::Spec;
use engines::Engine; use engines::Engine;
@ -641,7 +641,7 @@ mod tests {
let verify_result = engine.verify_block_basic(&header); let verify_result = engine.verify_block_basic(&header);
match verify_result { match verify_result {
Err(Error(ErrorKind::Block(BlockError::InvalidSealArity(_)), _)) => {}, Err(Error::Block(BlockError::InvalidSealArity(_))) => {},
Err(_) => { panic!("should be block seal-arity mismatch error (got {:?})", verify_result); }, Err(_) => { panic!("should be block seal-arity mismatch error (got {:?})", verify_result); },
_ => { panic!("Should be error, got Ok"); }, _ => { panic!("Should be error, got Ok"); },
} }
@ -656,7 +656,7 @@ mod tests {
let verify_result = engine.verify_block_basic(&header); let verify_result = engine.verify_block_basic(&header);
match verify_result { match verify_result {
Err(Error(ErrorKind::Block(BlockError::DifficultyOutOfBounds(_)), _)) => {}, Err(Error::Block(BlockError::DifficultyOutOfBounds(_))) => {},
Err(_) => { panic!("should be block difficulty error (got {:?})", verify_result); }, Err(_) => { panic!("should be block difficulty error (got {:?})", verify_result); },
_ => { panic!("Should be error, got Ok"); }, _ => { panic!("Should be error, got Ok"); },
} }
@ -672,7 +672,7 @@ mod tests {
let verify_result = engine.verify_block_basic(&header); let verify_result = engine.verify_block_basic(&header);
match verify_result { match verify_result {
Err(Error(ErrorKind::Block(BlockError::InvalidProofOfWork(_)), _)) => {}, Err(Error::Block(BlockError::InvalidProofOfWork(_))) => {},
Err(_) => { panic!("should be invalid proof of work error (got {:?})", verify_result); }, Err(_) => { panic!("should be invalid proof of work error (got {:?})", verify_result); },
_ => { panic!("Should be error, got Ok"); }, _ => { panic!("Should be error, got Ok"); },
} }
@ -686,7 +686,7 @@ mod tests {
let verify_result = engine.verify_block_unordered(&header); let verify_result = engine.verify_block_unordered(&header);
match verify_result { match verify_result {
Err(Error(ErrorKind::Block(BlockError::InvalidSealArity(_)), _)) => {}, Err(Error::Block(BlockError::InvalidSealArity(_))) => {},
Err(_) => { panic!("should be block seal-arity mismatch error (got {:?})", verify_result); }, Err(_) => { panic!("should be block seal-arity mismatch error (got {:?})", verify_result); },
_ => { panic!("Should be error, got Ok"); }, _ => { panic!("Should be error, got Ok"); },
} }
@ -711,7 +711,7 @@ mod tests {
let verify_result = engine.verify_block_unordered(&header); let verify_result = engine.verify_block_unordered(&header);
match verify_result { match verify_result {
Err(Error(ErrorKind::Block(BlockError::MismatchedH256SealElement(_)), _)) => {}, Err(Error::Block(BlockError::MismatchedH256SealElement(_))) => {},
Err(_) => { panic!("should be invalid 256-bit seal fail (got {:?})", verify_result); }, Err(_) => { panic!("should be invalid 256-bit seal fail (got {:?})", verify_result); },
_ => { panic!("Should be error, got Ok"); }, _ => { panic!("Should be error, got Ok"); },
} }
@ -727,7 +727,7 @@ mod tests {
let verify_result = engine.verify_block_unordered(&header); let verify_result = engine.verify_block_unordered(&header);
match verify_result { match verify_result {
Err(Error(ErrorKind::Block(BlockError::InvalidProofOfWork(_)), _)) => {}, Err(Error::Block(BlockError::InvalidProofOfWork(_))) => {},
Err(_) => { panic!("should be invalid proof-of-work fail (got {:?})", verify_result); }, Err(_) => { panic!("should be invalid proof-of-work fail (got {:?})", verify_result); },
_ => { panic!("Should be error, got Ok"); }, _ => { panic!("Should be error, got Ok"); },
} }
@ -742,7 +742,7 @@ mod tests {
let verify_result = engine.verify_block_family(&header, &parent_header); let verify_result = engine.verify_block_family(&header, &parent_header);
match verify_result { match verify_result {
Err(Error(ErrorKind::Block(BlockError::RidiculousNumber(_)), _)) => {}, Err(Error::Block(BlockError::RidiculousNumber(_))) => {},
Err(_) => { panic!("should be invalid block number fail (got {:?})", verify_result); }, Err(_) => { panic!("should be invalid block number fail (got {:?})", verify_result); },
_ => { panic!("Should be error, got Ok"); }, _ => { panic!("Should be error, got Ok"); },
} }
@ -759,7 +759,7 @@ mod tests {
let verify_result = engine.verify_block_family(&header, &parent_header); let verify_result = engine.verify_block_family(&header, &parent_header);
match verify_result { match verify_result {
Err(Error(ErrorKind::Block(BlockError::InvalidDifficulty(_)), _)) => {}, Err(Error::Block(BlockError::InvalidDifficulty(_))) => {},
Err(_) => { panic!("should be invalid difficulty fail (got {:?})", verify_result); }, Err(_) => { panic!("should be invalid difficulty fail (got {:?})", verify_result); },
_ => { panic!("Should be error, got Ok"); }, _ => { panic!("Should be error, got Ok"); },
} }

View File

@ -126,8 +126,7 @@ extern crate rlp_compress;
extern crate ethabi_derive; extern crate ethabi_derive;
#[macro_use] #[macro_use]
extern crate ethabi_contract; extern crate ethabi_contract;
#[macro_use] extern crate derive_more;
extern crate error_chain;
#[macro_use] #[macro_use]
extern crate log; extern crate log;
#[macro_use] #[macro_use]

View File

@ -54,7 +54,7 @@ use client::{
}; };
use client::{BlockId, ClientIoMessage}; use client::{BlockId, ClientIoMessage};
use engines::{EthEngine, Seal, EngineSigner}; use engines::{EthEngine, Seal, EngineSigner};
use error::{Error, ErrorKind}; use error::Error;
use executed::ExecutionError; use executed::ExecutionError;
use executive::contract_address; use executive::contract_address;
use spec::Spec; use spec::Spec;
@ -521,7 +521,7 @@ impl Miner {
debug!(target: "miner", "Adding tx {:?} took {} ms", hash, took_ms(&took)); debug!(target: "miner", "Adding tx {:?} took {} ms", hash, took_ms(&took));
match result { match result {
Err(Error(ErrorKind::Execution(ExecutionError::BlockGasLimitReached { gas_limit, gas_used, gas }), _)) => { Err(Error::Execution(ExecutionError::BlockGasLimitReached { gas_limit, gas_used, gas })) => {
debug!(target: "miner", "Skipping adding transaction to block because of gas limit: {:?} (limit: {:?}, used: {:?}, gas: {:?})", hash, gas_limit, gas_used, gas); debug!(target: "miner", "Skipping adding transaction to block because of gas limit: {:?} (limit: {:?}, used: {:?}, gas: {:?})", hash, gas_limit, gas_used, gas);
// Penalize transaction if it's above current gas limit // Penalize transaction if it's above current gas limit
@ -546,12 +546,12 @@ impl Miner {
}, },
// Invalid nonce error can happen only if previous transaction is skipped because of gas limit. // Invalid nonce error can happen only if previous transaction is skipped because of gas limit.
// If there is errornous state of transaction queue it will be fixed when next block is imported. // If there is errornous state of transaction queue it will be fixed when next block is imported.
Err(Error(ErrorKind::Execution(ExecutionError::InvalidNonce { expected, got }), _)) => { Err(Error::Execution(ExecutionError::InvalidNonce { expected, got })) => {
debug!(target: "miner", "Skipping adding transaction to block because of invalid nonce: {:?} (expected: {:?}, got: {:?})", hash, expected, got); debug!(target: "miner", "Skipping adding transaction to block because of invalid nonce: {:?} (expected: {:?}, got: {:?})", hash, expected, got);
}, },
// already have transaction - ignore // already have transaction - ignore
Err(Error(ErrorKind::Transaction(transaction::Error::AlreadyImported), _)) => {}, Err(Error::Transaction(transaction::Error::AlreadyImported)) => {},
Err(Error(ErrorKind::Transaction(transaction::Error::NotAllowed), _)) => { Err(Error::Transaction(transaction::Error::NotAllowed)) => {
not_allowed_transactions.insert(hash); not_allowed_transactions.insert(hash);
debug!(target: "miner", "Skipping non-allowed transaction for sender {:?}", hash); debug!(target: "miner", "Skipping non-allowed transaction for sender {:?}", hash);
}, },
@ -1222,11 +1222,11 @@ impl miner::MinerService for Miner {
trace!(target: "miner", "Submitted block {}={} with seal {:?}", block_hash, b.header.bare_hash(), seal); trace!(target: "miner", "Submitted block {}={} with seal {:?}", block_hash, b.header.bare_hash(), seal);
b.lock().try_seal(&*self.engine, seal).or_else(|e| { b.lock().try_seal(&*self.engine, seal).or_else(|e| {
warn!(target: "miner", "Mined solution rejected: {}", e); warn!(target: "miner", "Mined solution rejected: {}", e);
Err(ErrorKind::PowInvalid.into()) Err(Error::PowInvalid.into())
}) })
} else { } else {
warn!(target: "miner", "Submitted solution rejected: Block unknown or out of date."); warn!(target: "miner", "Submitted solution rejected: Block unknown or out of date.");
Err(ErrorKind::PowHashInvalid.into()) Err(Error::PowHashInvalid.into())
}; };
result.and_then(|sealed| { result.and_then(|sealed| {

View File

@ -16,6 +16,7 @@
//! Snapshot-related errors. //! Snapshot-related errors.
use std::error;
use std::fmt; use std::fmt;
use types::ids::BlockId; use types::ids::BlockId;
@ -69,6 +70,17 @@ pub enum Error {
UnlinkedAncientBlockChain, UnlinkedAncientBlockChain,
} }
impl error::Error for Error {
fn source(&self) -> Option<&(error::Error + 'static)> {
match self {
Error::Trie(e) => Some(e),
Error::Decoder(e) => Some(e),
Error::Io(e) => Some(e),
_ => None,
}
}
}
impl fmt::Display for Error { impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self { match *self {

View File

@ -30,7 +30,7 @@ use super::io::{SnapshotReader, LooseReader, SnapshotWriter, LooseWriter};
use blockchain::{BlockChain, BlockChainDB, BlockChainDBHandler}; use blockchain::{BlockChain, BlockChainDB, BlockChainDBHandler};
use client::{BlockInfo, BlockChainClient, Client, ChainInfo, ClientIoMessage}; use client::{BlockInfo, BlockChainClient, Client, ChainInfo, ClientIoMessage};
use engines::EthEngine; use engines::EthEngine;
use error::{Error, ErrorKind as SnapshotErrorKind}; use error::Error;
use snapshot::{Error as SnapshotError}; use snapshot::{Error as SnapshotError};
use hash::keccak; use hash::keccak;
use types::ids::BlockId; use types::ids::BlockId;
@ -697,7 +697,7 @@ impl Service {
let mut restoration = self.restoration.lock(); let mut restoration = self.restoration.lock();
match self.feed_chunk_with_restoration(&mut restoration, hash, chunk, is_state) { match self.feed_chunk_with_restoration(&mut restoration, hash, chunk, is_state) {
Ok(()) | Ok(()) |
Err(Error(SnapshotErrorKind::Snapshot(SnapshotError::RestorationAborted), _)) => (), Err(Error::Snapshot(SnapshotError::RestorationAborted)) => (),
Err(e) => { Err(e) => {
warn!("Encountered error during snapshot restoration: {}", e); warn!("Encountered error during snapshot restoration: {}", e);
*self.restoration.lock() = None; *self.restoration.lock() = None;

View File

@ -18,7 +18,7 @@
use std::sync::atomic::AtomicBool; use std::sync::atomic::AtomicBool;
use tempdir::TempDir; use tempdir::TempDir;
use error::{Error, ErrorKind}; use error::Error;
use blockchain::generator::{BlockGenerator, BlockBuilder}; use blockchain::generator::{BlockGenerator, BlockBuilder};
use blockchain::{BlockChain, ExtrasInsert}; use blockchain::{BlockChain, ExtrasInsert};
@ -143,7 +143,7 @@ fn checks_flag() {
let mut rebuilder = SNAPSHOT_MODE.rebuilder(chain, db.clone(), &manifest).unwrap(); let mut rebuilder = SNAPSHOT_MODE.rebuilder(chain, db.clone(), &manifest).unwrap();
match rebuilder.feed(&chunk, engine.as_ref(), &AtomicBool::new(false)) { match rebuilder.feed(&chunk, engine.as_ref(), &AtomicBool::new(false)) {
Err(Error(ErrorKind::Snapshot(SnapshotError::RestorationAborted), _)) => {} Err(Error::Snapshot(SnapshotError::RestorationAborted)) => {}
_ => panic!("Wrong result on abort flag set") _ => panic!("Wrong result on abort flag set")
} }
} }

View File

@ -26,7 +26,7 @@ use snapshot::{chunk_state, Error as SnapshotError, Progress, StateRebuilder, SN
use snapshot::io::{PackedReader, PackedWriter, SnapshotReader, SnapshotWriter}; use snapshot::io::{PackedReader, PackedWriter, SnapshotReader, SnapshotWriter};
use super::helpers::StateProducer; use super::helpers::StateProducer;
use error::{Error, ErrorKind}; use error::Error;
use rand::{XorShiftRng, SeedableRng}; use rand::{XorShiftRng, SeedableRng};
use ethereum_types::H256; use ethereum_types::H256;
@ -196,7 +196,7 @@ fn checks_flag() {
let chunk = ::snappy::decompress(&raw).unwrap(); let chunk = ::snappy::decompress(&raw).unwrap();
match rebuilder.feed(&chunk, &flag) { match rebuilder.feed(&chunk, &flag) {
Err(Error(ErrorKind::Snapshot(SnapshotError::RestorationAborted), _)) => {}, Err(Error::Snapshot(SnapshotError::RestorationAborted)) => {},
_ => panic!("unexpected result when feeding with flag off"), _ => panic!("unexpected result when feeding with flag off"),
} }
} }

View File

@ -69,7 +69,7 @@ pub mod blocks {
use super::{Kind, BlockLike}; use super::{Kind, BlockLike};
use engines::EthEngine; use engines::EthEngine;
use error::{Error, ErrorKind, BlockError}; use error::{Error, BlockError};
use types::header::Header; use types::header::Header;
use verification::{PreverifiedBlock, verify_block_basic, verify_block_unordered}; use verification::{PreverifiedBlock, verify_block_basic, verify_block_unordered};
use types::transaction::UnverifiedTransaction; use types::transaction::UnverifiedTransaction;
@ -89,7 +89,7 @@ pub mod blocks {
fn create(input: Self::Input, engine: &EthEngine, check_seal: bool) -> Result<Self::Unverified, (Self::Input, Error)> { fn create(input: Self::Input, engine: &EthEngine, check_seal: bool) -> Result<Self::Unverified, (Self::Input, Error)> {
match verify_block_basic(&input, engine, check_seal) { match verify_block_basic(&input, engine, check_seal) {
Ok(()) => Ok(input), Ok(()) => Ok(input),
Err(Error(ErrorKind::Block(BlockError::TemporarilyInvalid(oob)), _)) => { Err(Error::Block(BlockError::TemporarilyInvalid(oob))) => {
debug!(target: "client", "Block received too early {}: {:?}", input.hash(), oob); debug!(target: "client", "Block received too early {}: {:?}", input.hash(), oob);
Err((input, BlockError::TemporarilyInvalid(oob).into())) Err((input, BlockError::TemporarilyInvalid(oob).into()))
}, },

View File

@ -26,7 +26,7 @@ use heapsize::HeapSizeOf;
use ethereum_types::{H256, U256}; use ethereum_types::{H256, U256};
use parking_lot::{Condvar, Mutex, RwLock}; use parking_lot::{Condvar, Mutex, RwLock};
use io::*; use io::*;
use error::{BlockError, ImportErrorKind, ErrorKind, Error}; use error::{BlockError, ImportError, Error};
use engines::EthEngine; use engines::EthEngine;
use client::ClientIoMessage; use client::ClientIoMessage;
use len_caching_lock::LenCachingMutex; use len_caching_lock::LenCachingMutex;
@ -474,17 +474,17 @@ impl<K: Kind> VerificationQueue<K> {
let hash = input.hash(); let hash = input.hash();
{ {
if self.processing.read().contains_key(&hash) { if self.processing.read().contains_key(&hash) {
bail!((input, ErrorKind::Import(ImportErrorKind::AlreadyQueued).into())); return Err((input, Error::Import(ImportError::AlreadyQueued).into()));
} }
let mut bad = self.verification.bad.lock(); let mut bad = self.verification.bad.lock();
if bad.contains(&hash) { if bad.contains(&hash) {
bail!((input, ErrorKind::Import(ImportErrorKind::KnownBad).into())); return Err((input, Error::Import(ImportError::KnownBad).into()));
} }
if bad.contains(&input.parent_hash()) { if bad.contains(&input.parent_hash()) {
bad.insert(hash); bad.insert(hash);
bail!((input, ErrorKind::Import(ImportErrorKind::KnownBad).into())); return Err((input, Error::Import(ImportError::KnownBad).into()));
} }
} }
@ -504,7 +504,7 @@ impl<K: Kind> VerificationQueue<K> {
Err((input, err)) => { Err((input, err)) => {
match err { match err {
// Don't mark future blocks as bad. // Don't mark future blocks as bad.
Error(ErrorKind::Block(BlockError::TemporarilyInvalid(_)), _) => {}, Error::Block(BlockError::TemporarilyInvalid(_)) => {},
_ => { _ => {
self.verification.bad.lock().insert(hash); self.verification.bad.lock().insert(hash);
} }
@ -797,7 +797,7 @@ mod tests {
match duplicate_import { match duplicate_import {
Err((_, e)) => { Err((_, e)) => {
match e { match e {
Error(ErrorKind::Import(ImportErrorKind::AlreadyQueued), _) => {}, Error::Import(ImportError::AlreadyQueued) => {},
_ => { panic!("must return AlreadyQueued error"); } _ => { panic!("must return AlreadyQueued error"); }
} }
} }

View File

@ -314,11 +314,11 @@ pub fn verify_header_params(header: &Header, engine: &EthEngine, is_full: bool,
.ok_or(BlockError::TimestampOverflow)?; .ok_or(BlockError::TimestampOverflow)?;
if timestamp > invalid_threshold { if timestamp > invalid_threshold {
return Err(From::from(BlockError::InvalidTimestamp(OutOfBounds { max: Some(max_time), min: None, found: timestamp }))) return Err(From::from(BlockError::InvalidTimestamp(OutOfBounds { max: Some(max_time), min: None, found: timestamp }.into())))
} }
if timestamp > max_time { if timestamp > max_time {
return Err(From::from(BlockError::TemporarilyInvalid(OutOfBounds { max: Some(max_time), min: None, found: timestamp }))) return Err(From::from(BlockError::TemporarilyInvalid(OutOfBounds { max: Some(max_time), min: None, found: timestamp }.into())))
} }
} }
@ -338,7 +338,7 @@ fn verify_parent(header: &Header, parent: &Header, engine: &EthEngine) -> Result
.ok_or(BlockError::TimestampOverflow)?; .ok_or(BlockError::TimestampOverflow)?;
let found = now.checked_add(Duration::from_secs(header.timestamp())) let found = now.checked_add(Duration::from_secs(header.timestamp()))
.ok_or(BlockError::TimestampOverflow)?; .ok_or(BlockError::TimestampOverflow)?;
return Err(From::from(BlockError::InvalidTimestamp(OutOfBounds { max: None, min: Some(min), found }))) return Err(From::from(BlockError::InvalidTimestamp(OutOfBounds { max: None, min: Some(min), found }.into())))
} }
if header.number() != parent.number() + 1 { if header.number() != parent.number() + 1 {
return Err(From::from(BlockError::InvalidNumber(Mismatch { expected: parent.number() + 1, found: header.number() }))); return Err(From::from(BlockError::InvalidNumber(Mismatch { expected: parent.number() + 1, found: header.number() })));
@ -364,17 +364,17 @@ fn verify_block_integrity(block: &Unverified) -> Result<(), Error> {
let tx = block_rlp.at(1)?; let tx = block_rlp.at(1)?;
let expected_root = ordered_trie_root(tx.iter().map(|r| r.as_raw())); let expected_root = ordered_trie_root(tx.iter().map(|r| r.as_raw()));
if &expected_root != block.header.transactions_root() { if &expected_root != block.header.transactions_root() {
bail!(BlockError::InvalidTransactionsRoot(Mismatch { return Err(BlockError::InvalidTransactionsRoot(Mismatch {
expected: expected_root, expected: expected_root,
found: *block.header.transactions_root(), found: *block.header.transactions_root(),
})); }).into());
} }
let expected_uncles = keccak(block_rlp.at(2)?.as_raw()); let expected_uncles = keccak(block_rlp.at(2)?.as_raw());
if &expected_uncles != block.header.uncles_hash(){ if &expected_uncles != block.header.uncles_hash(){
bail!(BlockError::InvalidUnclesHash(Mismatch { return Err(BlockError::InvalidUnclesHash(Mismatch {
expected: expected_uncles, expected: expected_uncles,
found: *block.header.uncles_hash(), found: *block.header.uncles_hash(),
})); }).into());
} }
Ok(()) Ok(())
} }
@ -391,7 +391,6 @@ mod tests {
use hash::keccak; use hash::keccak;
use engines::EthEngine; use engines::EthEngine;
use error::BlockError::*; use error::BlockError::*;
use error::ErrorKind;
use ethkey::{Random, Generator}; use ethkey::{Random, Generator};
use spec::{CommonParams, Spec}; use spec::{CommonParams, Spec};
use test_helpers::{create_test_block_with_data, create_test_block}; use test_helpers::{create_test_block_with_data, create_test_block};
@ -406,7 +405,7 @@ mod tests {
fn check_fail(result: Result<(), Error>, e: BlockError) { fn check_fail(result: Result<(), Error>, e: BlockError) {
match result { match result {
Err(Error(ErrorKind::Block(ref error), _)) if *error == e => (), Err(Error::Block(ref error)) if *error == e => (),
Err(other) => panic!("Block verification failed.\nExpected: {:?}\nGot: {:?}", e, other), Err(other) => panic!("Block verification failed.\nExpected: {:?}\nGot: {:?}", e, other),
Ok(_) => panic!("Block verification failed.\nExpected: {:?}\nGot: Ok", e), Ok(_) => panic!("Block verification failed.\nExpected: {:?}\nGot: Ok", e),
} }
@ -415,8 +414,8 @@ mod tests {
fn check_fail_timestamp(result: Result<(), Error>, temp: bool) { fn check_fail_timestamp(result: Result<(), Error>, temp: bool) {
let name = if temp { "TemporarilyInvalid" } else { "InvalidTimestamp" }; let name = if temp { "TemporarilyInvalid" } else { "InvalidTimestamp" };
match result { match result {
Err(Error(ErrorKind::Block(BlockError::InvalidTimestamp(_)), _)) if !temp => (), Err(Error::Block(BlockError::InvalidTimestamp(_))) if !temp => (),
Err(Error(ErrorKind::Block(BlockError::TemporarilyInvalid(_)), _)) if temp => (), Err(Error::Block(BlockError::TemporarilyInvalid(_))) if temp => (),
Err(other) => panic!("Block verification failed.\nExpected: {}\nGot: {:?}", name, other), Err(other) => panic!("Block verification failed.\nExpected: {}\nGot: {:?}", name, other),
Ok(_) => panic!("Block verification failed.\nExpected: {}\nGot: Ok", name), Ok(_) => panic!("Block verification failed.\nExpected: {}\nGot: Ok", name),
} }
@ -690,7 +689,7 @@ mod tests {
bad_header.set_transactions_root(eip86_transactions_root.clone()); bad_header.set_transactions_root(eip86_transactions_root.clone());
bad_header.set_uncles_hash(good_uncles_hash.clone()); bad_header.set_uncles_hash(good_uncles_hash.clone());
match basic_test(&create_test_block_with_data(&bad_header, &eip86_transactions, &good_uncles), engine) { match basic_test(&create_test_block_with_data(&bad_header, &eip86_transactions, &good_uncles), engine) {
Err(Error(ErrorKind::Transaction(ref e), _)) if e == &::ethkey::Error::InvalidSignature.into() => (), Err(Error::Transaction(ref e)) if e == &::ethkey::Error::InvalidSignature.into() => (),
e => panic!("Block verification failed.\nExpected: Transaction Error (Invalid Signature)\nGot: {:?}", e), e => panic!("Block verification failed.\nExpected: Transaction Error (Invalid Signature)\nGot: {:?}", e),
} }
@ -785,7 +784,7 @@ mod tests {
header.set_gas_limit(0.into()); header.set_gas_limit(0.into());
header.set_difficulty("0000000000000000000000000000000000000000000000000000000000020000".parse::<U256>().unwrap()); header.set_difficulty("0000000000000000000000000000000000000000000000000000000000020000".parse::<U256>().unwrap());
match family_test(&create_test_block(&header), engine, &bc) { match family_test(&create_test_block(&header), engine, &bc) {
Err(Error(ErrorKind::Block(InvalidGasLimit(_)), _)) => {}, Err(Error::Block(InvalidGasLimit(_))) => {},
Err(_) => { panic!("should be invalid difficulty fail"); }, Err(_) => { panic!("should be invalid difficulty fail"); },
_ => { panic!("Should be error, got Ok"); }, _ => { panic!("Should be error, got Ok"); },
} }

View File

@ -25,7 +25,7 @@ use ethereum_types::H256;
use rlp::{self, Rlp}; use rlp::{self, Rlp};
use types::BlockNumber; use types::BlockNumber;
use ethcore::client::{BlockStatus, BlockId}; use ethcore::client::{BlockStatus, BlockId};
use ethcore::error::{ImportErrorKind, QueueErrorKind, BlockError, Error as EthcoreError, ErrorKind as EthcoreErrorKind}; use ethcore::error::{ImportError, QueueError, BlockError, Error as EthcoreError};
use sync_io::SyncIo; use sync_io::SyncIo;
use blocks::{BlockCollection, SyncBody, SyncHeader}; use blocks::{BlockCollection, SyncBody, SyncHeader};
use chain::BlockSet; use chain::BlockSet;
@ -556,11 +556,11 @@ impl BlockDownloader {
}; };
match result { match result {
Err(EthcoreError(EthcoreErrorKind::Import(ImportErrorKind::AlreadyInChain), _)) => { Err(EthcoreError::Import(ImportError::AlreadyInChain)) => {
trace_sync!(self, "Block already in chain {:?}", h); trace_sync!(self, "Block already in chain {:?}", h);
self.block_imported(&h, number, &parent); self.block_imported(&h, number, &parent);
}, },
Err(EthcoreError(EthcoreErrorKind::Import(ImportErrorKind::AlreadyQueued), _)) => { Err(EthcoreError::Import(ImportError::AlreadyQueued)) => {
trace_sync!(self, "Block already queued {:?}", h); trace_sync!(self, "Block already queued {:?}", h);
self.block_imported(&h, number, &parent); self.block_imported(&h, number, &parent);
}, },
@ -569,18 +569,18 @@ impl BlockDownloader {
imported.insert(h.clone()); imported.insert(h.clone());
self.block_imported(&h, number, &parent); self.block_imported(&h, number, &parent);
}, },
Err(EthcoreError(EthcoreErrorKind::Block(BlockError::UnknownParent(_)), _)) if allow_out_of_order => { Err(EthcoreError::Block(BlockError::UnknownParent(_))) if allow_out_of_order => {
break; break;
}, },
Err(EthcoreError(EthcoreErrorKind::Block(BlockError::UnknownParent(_)), _)) => { Err(EthcoreError::Block(BlockError::UnknownParent(_))) => {
trace_sync!(self, "Unknown new block parent, restarting sync"); trace_sync!(self, "Unknown new block parent, restarting sync");
break; break;
}, },
Err(EthcoreError(EthcoreErrorKind::Block(BlockError::TemporarilyInvalid(_)), _)) => { Err(EthcoreError::Block(BlockError::TemporarilyInvalid(_))) => {
debug_sync!(self, "Block temporarily invalid: {:?}, restarting sync", h); debug_sync!(self, "Block temporarily invalid: {:?}, restarting sync", h);
break; break;
}, },
Err(EthcoreError(EthcoreErrorKind::Queue(QueueErrorKind::Full(limit)), _)) => { Err(EthcoreError::Queue(QueueError::Full(limit))) => {
debug_sync!(self, "Block import queue full ({}), restarting sync", limit); debug_sync!(self, "Block import queue full ({}), restarting sync", limit);
download_action = DownloadAction::Reset; download_action = DownloadAction::Reset;
break; break;

View File

@ -18,7 +18,7 @@ use api::WARP_SYNC_PROTOCOL_ID;
use block_sync::{BlockDownloaderImportError as DownloaderImportError, DownloadAction}; use block_sync::{BlockDownloaderImportError as DownloaderImportError, DownloadAction};
use bytes::Bytes; use bytes::Bytes;
use enum_primitive::FromPrimitive; use enum_primitive::FromPrimitive;
use ethcore::error::{Error as EthcoreError, ErrorKind as EthcoreErrorKind, ImportErrorKind, BlockError}; use ethcore::error::{Error as EthcoreError, ImportError, BlockError};
use ethcore::snapshot::{ManifestData, RestorationStatus}; use ethcore::snapshot::{ManifestData, RestorationStatus};
use ethcore::verification::queue::kind::blocks::Unverified; use ethcore::verification::queue::kind::blocks::Unverified;
use ethereum_types::{H256, U256}; use ethereum_types::{H256, U256};
@ -183,10 +183,10 @@ impl SyncHandler {
return Err(DownloaderImportError::Invalid); return Err(DownloaderImportError::Invalid);
} }
match io.chain().import_block(block) { match io.chain().import_block(block) {
Err(EthcoreError(EthcoreErrorKind::Import(ImportErrorKind::AlreadyInChain), _)) => { Err(EthcoreError::Import(ImportError::AlreadyInChain)) => {
trace!(target: "sync", "New block already in chain {:?}", hash); trace!(target: "sync", "New block already in chain {:?}", hash);
}, },
Err(EthcoreError(EthcoreErrorKind::Import(ImportErrorKind::AlreadyQueued), _)) => { Err(EthcoreError::Import(ImportError::AlreadyQueued)) => {
trace!(target: "sync", "New block already queued {:?}", hash); trace!(target: "sync", "New block already queued {:?}", hash);
}, },
Ok(_) => { Ok(_) => {
@ -195,7 +195,7 @@ impl SyncHandler {
sync.new_blocks.mark_as_known(&hash, number); sync.new_blocks.mark_as_known(&hash, number);
trace!(target: "sync", "New block queued {:?} ({})", hash, number); trace!(target: "sync", "New block queued {:?} ({})", hash, number);
}, },
Err(EthcoreError(EthcoreErrorKind::Block(BlockError::UnknownParent(p)), _)) => { Err(EthcoreError::Block(BlockError::UnknownParent(p))) => {
unknown = true; unknown = true;
trace!(target: "sync", "New block with unknown parent ({:?}) {:?}", p, hash); trace!(target: "sync", "New block with unknown parent ({:?}) {:?}", p, hash);
}, },

View File

@ -493,7 +493,7 @@ impl<L: AsLightClient> LightSync<L> {
// handles request dispatch, block import, state machine transitions, and timeouts. // handles request dispatch, block import, state machine transitions, and timeouts.
fn maintain_sync(&self, ctx: &BasicContext) { fn maintain_sync(&self, ctx: &BasicContext) {
use ethcore::error::{Error as EthcoreError, ErrorKind as EthcoreErrorKind, ImportErrorKind}; use ethcore::error::{Error as EthcoreError, ImportError};
const DRAIN_AMOUNT: usize = 128; const DRAIN_AMOUNT: usize = 128;
@ -524,10 +524,10 @@ impl<L: AsLightClient> LightSync<L> {
for header in sink.drain(..) { for header in sink.drain(..) {
match client.queue_header(header) { match client.queue_header(header) {
Ok(_) => {} Ok(_) => {}
Err(EthcoreError(EthcoreErrorKind::Import(ImportErrorKind::AlreadyInChain), _)) => { Err(EthcoreError::Import(ImportError::AlreadyInChain)) => {
trace!(target: "sync", "Block already in chain. Continuing."); trace!(target: "sync", "Block already in chain. Continuing.");
}, },
Err(EthcoreError(EthcoreErrorKind::Import(ImportErrorKind::AlreadyQueued), _)) => { Err(EthcoreError::Import(ImportError::AlreadyQueued)) => {
trace!(target: "sync", "Block already queued. Continuing."); trace!(target: "sync", "Block already queued. Continuing.");
}, },
Err(e) => { Err(e) => {

View File

@ -28,7 +28,7 @@ use rlp::PayloadInfo;
use ethcore::client::{ use ethcore::client::{
Mode, DatabaseCompactionProfile, VMType, Nonce, Balance, BlockChainClient, BlockId, BlockInfo, ImportBlock, BlockChainReset Mode, DatabaseCompactionProfile, VMType, Nonce, Balance, BlockChainClient, BlockId, BlockInfo, ImportBlock, BlockChainReset
}; };
use ethcore::error::{ImportErrorKind, ErrorKind as EthcoreErrorKind, Error as EthcoreError}; use ethcore::error::{ImportError, Error as EthcoreError};
use ethcore::miner::Miner; use ethcore::miner::Miner;
use ethcore::verification::queue::VerifierSettings; use ethcore::verification::queue::VerifierSettings;
use ethcore::verification::queue::kind::blocks::Unverified; use ethcore::verification::queue::kind::blocks::Unverified;
@ -272,7 +272,7 @@ fn execute_import_light(cmd: ImportBlockchain) -> Result<(), String> {
} }
match client.import_header(header) { match client.import_header(header) {
Err(EthcoreError(EthcoreErrorKind::Import(ImportErrorKind::AlreadyInChain), _)) => { Err(EthcoreError::Import(ImportError::AlreadyInChain)) => {
trace!("Skipping block already in chain."); trace!("Skipping block already in chain.");
} }
Err(e) => { Err(e) => {
@ -444,7 +444,7 @@ fn execute_import(cmd: ImportBlockchain) -> Result<(), String> {
let block = Unverified::from_rlp(bytes).map_err(|_| "Invalid block rlp")?; let block = Unverified::from_rlp(bytes).map_err(|_| "Invalid block rlp")?;
while client.queue_info().is_full() { sleep(Duration::from_secs(1)); } while client.queue_info().is_full() { sleep(Duration::from_secs(1)); }
match client.import_block(block) { match client.import_block(block) {
Err(EthcoreError(EthcoreErrorKind::Import(ImportErrorKind::AlreadyInChain), _)) => { Err(EthcoreError::Import(ImportError::AlreadyInChain)) => {
trace!("Skipping block already in chain."); trace!("Skipping block already in chain.");
} }
Err(e) => { Err(e) => {

View File

@ -18,7 +18,7 @@
use std::fmt; use std::fmt;
use ethcore::error::{Error as EthcoreError, ErrorKind, CallError}; use ethcore::error::{Error as EthcoreError, CallError};
use ethcore::client::BlockId; use ethcore::client::BlockId;
use jsonrpc_core::{futures, Result as RpcResult, Error, ErrorCode, Value}; use jsonrpc_core::{futures, Result as RpcResult, Error, ErrorCode, Value};
use rlp::DecoderError; use rlp::DecoderError;
@ -440,7 +440,7 @@ pub fn transaction_message(error: &TransactionError) -> String {
pub fn transaction<T: Into<EthcoreError>>(error: T) -> Error { pub fn transaction<T: Into<EthcoreError>>(error: T) -> Error {
let error = error.into(); let error = error.into();
if let ErrorKind::Transaction(ref e) = *error.kind() { if let EthcoreError::Transaction(ref e) = error {
Error { Error {
code: ErrorCode::ServerError(codes::TRANSACTION_ERROR), code: ErrorCode::ServerError(codes::TRANSACTION_ERROR),
message: transaction_message(e), message: transaction_message(e),
@ -456,9 +456,8 @@ pub fn transaction<T: Into<EthcoreError>>(error: T) -> Error {
} }
pub fn decode<T: Into<EthcoreError>>(error: T) -> Error { pub fn decode<T: Into<EthcoreError>>(error: T) -> Error {
let error = error.into(); match error.into() {
match *error.kind() { EthcoreError::Decoder(ref dec_err) => rlp(dec_err.clone()),
ErrorKind::Decoder(ref dec_err) => rlp(dec_err.clone()),
_ => Error { _ => Error {
code: ErrorCode::InternalError, code: ErrorCode::InternalError,
message: "decoding error".into(), message: "decoding error".into(),