Move ethcore files back into root.
This commit is contained in:
parent
9b87bae322
commit
6ea8eaa3b5
30
Cargo.toml
30
Cargo.toml
@ -1,32 +1,24 @@
|
|||||||
[package]
|
[package]
|
||||||
description = "Ethcore utility library"
|
description = "Ethcore library"
|
||||||
homepage = "http://ethcore.io"
|
homepage = "http://ethcore.io"
|
||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
name = "ethcore-util"
|
name = "ethcore"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Ethcore <admin@ethcore.io>"]
|
authors = ["Ethcore <admin@ethcore.io>"]
|
||||||
build = "build.rs"
|
|
||||||
|
|
||||||
[build-dependencies]
|
|
||||||
gcc = "0.3"
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
log = "0.3"
|
log = "0.3"
|
||||||
env_logger = "0.3"
|
env_logger = "0.3"
|
||||||
|
ethcore-util = { path = "util" }
|
||||||
rustc-serialize = "0.3"
|
rustc-serialize = "0.3"
|
||||||
arrayvec = "0.3"
|
flate2 = "0.2"
|
||||||
mio = "0.5.0"
|
|
||||||
rand = "0.3.12"
|
|
||||||
time = "0.1.34"
|
|
||||||
tiny-keccak = "1.0"
|
|
||||||
rocksdb = "0.3"
|
rocksdb = "0.3"
|
||||||
lazy_static = "0.1"
|
heapsize = "0.2.0"
|
||||||
eth-secp256k1 = { git = "https://github.com/arkpar/rust-secp256k1.git" }
|
|
||||||
rust-crypto = "0.2.34"
|
rust-crypto = "0.2.34"
|
||||||
elastic-array = "0.4"
|
time = "0.1"
|
||||||
heapsize = "0.2"
|
#interpolate_idents = { git = "https://github.com/SkylerLipthay/interpolate_idents" }
|
||||||
itertools = "0.4"
|
evmjit = { path = "rust-evmjit", optional = true }
|
||||||
slab = { git = "https://github.com/arkpar/slab.git" }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[features]
|
||||||
json-tests = { path = "json-tests" }
|
jit = ["evmjit"]
|
||||||
|
evm_debug = []
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
[package]
|
|
||||||
description = "Ethcore library"
|
|
||||||
homepage = "http://ethcore.io"
|
|
||||||
license = "GPL-3.0"
|
|
||||||
name = "ethcore"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Ethcore <admin@ethcore.io>"]
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
log = "0.3"
|
|
||||||
env_logger = "0.3"
|
|
||||||
ethcore-util = { path = "../ethcore-util" }
|
|
||||||
rustc-serialize = "0.3"
|
|
||||||
flate2 = "0.2"
|
|
||||||
rocksdb = "0.3"
|
|
||||||
heapsize = "0.2.0"
|
|
||||||
rust-crypto = "0.2.34"
|
|
||||||
time = "0.1"
|
|
||||||
#interpolate_idents = { git = "https://github.com/SkylerLipthay/interpolate_idents" }
|
|
||||||
evmjit = { path = "rust-evmjit", optional = true }
|
|
||||||
|
|
||||||
[features]
|
|
||||||
jit = ["evmjit"]
|
|
||||||
evm_debug = []
|
|
@ -1 +0,0 @@
|
|||||||
# ethcore
|
|
@ -1,12 +0,0 @@
|
|||||||
pub use util::*;
|
|
||||||
pub use basic_types::*;
|
|
||||||
pub use error::*;
|
|
||||||
pub use env_info::*;
|
|
||||||
pub use views::*;
|
|
||||||
pub use builtin::*;
|
|
||||||
pub use header::*;
|
|
||||||
pub use account::*;
|
|
||||||
pub use transaction::*;
|
|
||||||
pub use log_entry::*;
|
|
||||||
pub use receipt::*;
|
|
||||||
pub use action_params::*;
|
|
@ -1,152 +0,0 @@
|
|||||||
//! General error types for use in ethcore.
|
|
||||||
|
|
||||||
use util::*;
|
|
||||||
use header::BlockNumber;
|
|
||||||
use basic_types::LogBloom;
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
|
||||||
pub struct Mismatch<T: fmt::Debug> {
|
|
||||||
pub expected: T,
|
|
||||||
pub found: T,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
|
||||||
pub struct OutOfBounds<T: fmt::Debug> {
|
|
||||||
pub min: Option<T>,
|
|
||||||
pub max: Option<T>,
|
|
||||||
pub found: T,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Result of executing the transaction.
|
|
||||||
#[derive(PartialEq, Debug)]
|
|
||||||
pub enum ExecutionError {
|
|
||||||
/// Returned when there gas paid for transaction execution is
|
|
||||||
/// lower than base gas required.
|
|
||||||
NotEnoughBaseGas { required: U256, got: U256 },
|
|
||||||
/// Returned when block (gas_used + gas) > gas_limit.
|
|
||||||
///
|
|
||||||
/// If gas =< gas_limit, upstream may try to execute the transaction
|
|
||||||
/// in next block.
|
|
||||||
BlockGasLimitReached { gas_limit: U256, gas_used: U256, gas: U256 },
|
|
||||||
/// Returned when transaction nonce does not match state nonce.
|
|
||||||
InvalidNonce { expected: U256, got: U256 },
|
|
||||||
/// Returned when cost of transaction (value + gas_price * gas) exceeds
|
|
||||||
/// current sender balance.
|
|
||||||
NotEnoughCash { required: U512, got: U512 },
|
|
||||||
/// Returned when internal evm error occurs.
|
|
||||||
Internal
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum TransactionError {
|
|
||||||
InvalidGasLimit(OutOfBounds<U256>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
|
||||||
pub enum BlockError {
|
|
||||||
TooManyUncles(OutOfBounds<usize>),
|
|
||||||
UncleWrongGeneration,
|
|
||||||
ExtraDataOutOfBounds(OutOfBounds<usize>),
|
|
||||||
InvalidSealArity(Mismatch<usize>),
|
|
||||||
TooMuchGasUsed(OutOfBounds<U256>),
|
|
||||||
InvalidUnclesHash(Mismatch<H256>),
|
|
||||||
UncleTooOld(OutOfBounds<BlockNumber>),
|
|
||||||
UncleIsBrother(OutOfBounds<BlockNumber>),
|
|
||||||
UncleInChain(H256),
|
|
||||||
UncleParentNotInChain(H256),
|
|
||||||
InvalidStateRoot(Mismatch<H256>),
|
|
||||||
InvalidGasUsed(Mismatch<U256>),
|
|
||||||
InvalidTransactionsRoot(Mismatch<H256>),
|
|
||||||
InvalidDifficulty(Mismatch<U256>),
|
|
||||||
InvalidGasLimit(OutOfBounds<U256>),
|
|
||||||
InvalidReceiptsStateRoot(Mismatch<H256>),
|
|
||||||
InvalidTimestamp(OutOfBounds<u64>),
|
|
||||||
InvalidLogBloom(Mismatch<LogBloom>),
|
|
||||||
InvalidBlockNonce(Mismatch<H256>),
|
|
||||||
InvalidParentHash(Mismatch<H256>),
|
|
||||||
InvalidNumber(OutOfBounds<BlockNumber>),
|
|
||||||
UnknownParent(H256),
|
|
||||||
UnknownUncleParent(H256),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum ImportError {
|
|
||||||
Bad(Option<Error>),
|
|
||||||
AlreadyInChain,
|
|
||||||
AlreadyQueued,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Error> for ImportError {
|
|
||||||
fn from(err: Error) -> ImportError {
|
|
||||||
ImportError::Bad(Some(err))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Result of import block operation.
|
|
||||||
pub type ImportResult = Result<(), ImportError>;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
/// General error type which should be capable of representing all errors in ethcore.
|
|
||||||
pub enum Error {
|
|
||||||
Util(UtilError),
|
|
||||||
Block(BlockError),
|
|
||||||
UnknownEngineName(String),
|
|
||||||
Execution(ExecutionError),
|
|
||||||
Transaction(TransactionError),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<TransactionError> for Error {
|
|
||||||
fn from(err: TransactionError) -> Error {
|
|
||||||
Error::Transaction(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<BlockError> for Error {
|
|
||||||
fn from(err: BlockError) -> Error {
|
|
||||||
Error::Block(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<ExecutionError> for Error {
|
|
||||||
fn from(err: ExecutionError) -> Error {
|
|
||||||
Error::Execution(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<CryptoError> for Error {
|
|
||||||
fn from(err: CryptoError) -> Error {
|
|
||||||
Error::Util(UtilError::Crypto(err))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<DecoderError> for Error {
|
|
||||||
fn from(err: DecoderError) -> Error {
|
|
||||||
Error::Util(UtilError::Decoder(err))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<UtilError> for Error {
|
|
||||||
fn from(err: UtilError) -> Error {
|
|
||||||
Error::Util(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<IoError> for Error {
|
|
||||||
fn from(err: IoError) -> Error {
|
|
||||||
Error::Util(From::from(err))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: uncomment below once https://github.com/rust-lang/rust/issues/27336 sorted.
|
|
||||||
/*#![feature(concat_idents)]
|
|
||||||
macro_rules! assimilate {
|
|
||||||
($name:ident) => (
|
|
||||||
impl From<concat_idents!($name, Error)> for Error {
|
|
||||||
fn from(err: concat_idents!($name, Error)) -> Error {
|
|
||||||
Error:: $name (err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
assimilate!(FromHex);
|
|
||||||
assimilate!(BaseData);*/
|
|
@ -1,128 +0,0 @@
|
|||||||
#![feature(cell_extras)]
|
|
||||||
#![feature(augmented_assignments)]
|
|
||||||
#![feature(wrapping)]
|
|
||||||
//#![feature(plugin)]
|
|
||||||
//#![plugin(interpolate_idents)]
|
|
||||||
//! Ethcore's ethereum implementation
|
|
||||||
//!
|
|
||||||
//! ### Rust version
|
|
||||||
//! - beta
|
|
||||||
//! - nightly
|
|
||||||
//!
|
|
||||||
//! ### Supported platforms:
|
|
||||||
//! - OSX
|
|
||||||
//! - Linux/Ubuntu
|
|
||||||
//!
|
|
||||||
//! ### Dependencies:
|
|
||||||
//! - RocksDB 3.13
|
|
||||||
//! - LLVM 3.7 (optional, required for `jit`)
|
|
||||||
//! - evmjit (optional, required for `jit`)
|
|
||||||
//!
|
|
||||||
//! ### Dependencies Installation
|
|
||||||
//!
|
|
||||||
//! - OSX
|
|
||||||
//!
|
|
||||||
//! - rocksdb
|
|
||||||
//! ```bash
|
|
||||||
//! brew install rocksdb
|
|
||||||
//! ```
|
|
||||||
//!
|
|
||||||
//! - llvm
|
|
||||||
//!
|
|
||||||
//! - download llvm 3.7 from http://llvm.org/apt/
|
|
||||||
//!
|
|
||||||
//! ```bash
|
|
||||||
//! cd llvm-3.7.0.src
|
|
||||||
//! mkdir build && cd $_
|
|
||||||
//! cmake -G "Unix Makefiles" .. -DCMAKE_C_FLAGS_RELEASE= -DCMAKE_CXX_FLAGS_RELEASE= -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/llvm/3.7 -DCMAKE_BUILD_TYPE=Release
|
|
||||||
//! make && make install
|
|
||||||
//! ```
|
|
||||||
//! - evmjit
|
|
||||||
//!
|
|
||||||
//! - download from https://github.com/debris/evmjit
|
|
||||||
//!
|
|
||||||
//! ```bash
|
|
||||||
//! cd evmjit
|
|
||||||
//! mkdir build && cd $_
|
|
||||||
//! cmake -DLLVM_DIR=/usr/local/lib/llvm-3.7/share/llvm/cmake ..
|
|
||||||
//! make && make install
|
|
||||||
//! ```
|
|
||||||
//!
|
|
||||||
//! - Linux/Ubuntu
|
|
||||||
//!
|
|
||||||
//! - rocksdb
|
|
||||||
//!
|
|
||||||
//! ```bash
|
|
||||||
//! wget https://github.com/facebook/rocksdb/archive/rocksdb-3.13.tar.gz
|
|
||||||
//! tar xvf rocksdb-3.13.tar.gz && cd rocksdb-rocksdb-3.13 && make shared_lib
|
|
||||||
//! sudo make install
|
|
||||||
//! ```
|
|
||||||
//!
|
|
||||||
//! - llvm
|
|
||||||
//!
|
|
||||||
//! - install using packages from http://llvm.org/apt/
|
|
||||||
//!
|
|
||||||
//! - evmjit
|
|
||||||
//!
|
|
||||||
//! - download from https://github.com/debris/evmjit
|
|
||||||
//!
|
|
||||||
//! ```bash
|
|
||||||
//! cd evmjit
|
|
||||||
//! mkdir build && cd $_
|
|
||||||
//! cmake .. && make
|
|
||||||
//! sudo make install
|
|
||||||
//! sudo ldconfig
|
|
||||||
//! ```
|
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate log;
|
|
||||||
extern crate rustc_serialize;
|
|
||||||
extern crate flate2;
|
|
||||||
extern crate rocksdb;
|
|
||||||
extern crate heapsize;
|
|
||||||
extern crate crypto;
|
|
||||||
extern crate time;
|
|
||||||
extern crate env_logger;
|
|
||||||
#[cfg(feature = "jit" )]
|
|
||||||
extern crate evmjit;
|
|
||||||
#[macro_use]
|
|
||||||
extern crate ethcore_util as util;
|
|
||||||
|
|
||||||
pub mod common;
|
|
||||||
pub mod basic_types;
|
|
||||||
#[macro_use]
|
|
||||||
pub mod evm;
|
|
||||||
pub mod error;
|
|
||||||
pub mod log_entry;
|
|
||||||
pub mod env_info;
|
|
||||||
pub mod pod_account;
|
|
||||||
pub mod pod_state;
|
|
||||||
pub mod account_diff;
|
|
||||||
pub mod state_diff;
|
|
||||||
pub mod engine;
|
|
||||||
pub mod state;
|
|
||||||
pub mod account;
|
|
||||||
pub mod action_params;
|
|
||||||
pub mod header;
|
|
||||||
pub mod transaction;
|
|
||||||
pub mod receipt;
|
|
||||||
pub mod null_engine;
|
|
||||||
pub mod builtin;
|
|
||||||
pub mod spec;
|
|
||||||
pub mod views;
|
|
||||||
pub mod blockchain;
|
|
||||||
pub mod extras;
|
|
||||||
pub mod substate;
|
|
||||||
pub mod service;
|
|
||||||
pub mod executive;
|
|
||||||
pub mod externalities;
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests;
|
|
||||||
|
|
||||||
pub mod client;
|
|
||||||
pub mod sync;
|
|
||||||
pub mod block;
|
|
||||||
pub mod verification;
|
|
||||||
pub mod queue;
|
|
||||||
pub mod ethereum;
|
|
@ -1,57 +1,12 @@
|
|||||||
pub use standard::*;
|
pub use util::*;
|
||||||
pub use from_json::*;
|
pub use basic_types::*;
|
||||||
pub use error::*;
|
pub use error::*;
|
||||||
pub use hash::*;
|
pub use env_info::*;
|
||||||
pub use uint::*;
|
pub use views::*;
|
||||||
pub use bytes::*;
|
pub use builtin::*;
|
||||||
pub use vector::*;
|
pub use header::*;
|
||||||
pub use sha3::*;
|
pub use account::*;
|
||||||
|
pub use transaction::*;
|
||||||
#[macro_export]
|
pub use log_entry::*;
|
||||||
macro_rules! map {
|
pub use receipt::*;
|
||||||
( $( $x:expr => $y:expr ),* ) => {
|
pub use action_params::*;
|
||||||
vec![ $( ($x, $y) ),* ].into_iter().collect::<BTreeMap<_, _>>()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! mapx {
|
|
||||||
( $( $x:expr => $y:expr ),* ) => {
|
|
||||||
vec![ $( ( From::from($x), From::from($y) ) ),* ].into_iter().collect::<BTreeMap<_, _>>()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! x {
|
|
||||||
( $x:expr ) => {
|
|
||||||
From::from($x)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! xx {
|
|
||||||
( $x:expr ) => {
|
|
||||||
From::from(From::from($x))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! flush {
|
|
||||||
($($arg:tt)*) => ($crate::flush(format!("{}", format_args!($($arg)*))));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! flushln {
|
|
||||||
($fmt:expr) => (flush!(concat!($fmt, "\n")));
|
|
||||||
($fmt:expr, $($arg:tt)*) => (flush!(concat!($fmt, "\n"), $($arg)*));
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn flush(s: String) {
|
|
||||||
::std::io::stdout().write(s.as_bytes()).unwrap();
|
|
||||||
::std::io::stdout().flush().unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_flush() {
|
|
||||||
flushln!("hello_world {:?}", 1);
|
|
||||||
}
|
|
152
src/error.rs
152
src/error.rs
@ -1,75 +1,139 @@
|
|||||||
//! General error types for use in ethcore.
|
//! General error types for use in ethcore.
|
||||||
|
|
||||||
use rustc_serialize::hex::FromHexError;
|
use util::*;
|
||||||
use network::NetworkError;
|
use header::BlockNumber;
|
||||||
use rlp::DecoderError;
|
use basic_types::LogBloom;
|
||||||
use io;
|
|
||||||
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
|
pub struct Mismatch<T: fmt::Debug> {
|
||||||
|
pub expected: T,
|
||||||
|
pub found: T,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
|
pub struct OutOfBounds<T: fmt::Debug> {
|
||||||
|
pub min: Option<T>,
|
||||||
|
pub max: Option<T>,
|
||||||
|
pub found: T,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Result of executing the transaction.
|
||||||
|
#[derive(PartialEq, Debug)]
|
||||||
|
pub enum ExecutionError {
|
||||||
|
/// Returned when there gas paid for transaction execution is
|
||||||
|
/// lower than base gas required.
|
||||||
|
NotEnoughBaseGas { required: U256, got: U256 },
|
||||||
|
/// Returned when block (gas_used + gas) > gas_limit.
|
||||||
|
///
|
||||||
|
/// If gas =< gas_limit, upstream may try to execute the transaction
|
||||||
|
/// in next block.
|
||||||
|
BlockGasLimitReached { gas_limit: U256, gas_used: U256, gas: U256 },
|
||||||
|
/// Returned when transaction nonce does not match state nonce.
|
||||||
|
InvalidNonce { expected: U256, got: U256 },
|
||||||
|
/// Returned when cost of transaction (value + gas_price * gas) exceeds
|
||||||
|
/// current sender balance.
|
||||||
|
NotEnoughCash { required: U512, got: U512 },
|
||||||
|
/// Returned when internal evm error occurs.
|
||||||
|
Internal
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum BaseDataError {
|
pub enum TransactionError {
|
||||||
NegativelyReferencedHash,
|
InvalidGasLimit(OutOfBounds<U256>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
|
pub enum BlockError {
|
||||||
|
TooManyUncles(OutOfBounds<usize>),
|
||||||
|
UncleWrongGeneration,
|
||||||
|
ExtraDataOutOfBounds(OutOfBounds<usize>),
|
||||||
|
InvalidSealArity(Mismatch<usize>),
|
||||||
|
TooMuchGasUsed(OutOfBounds<U256>),
|
||||||
|
InvalidUnclesHash(Mismatch<H256>),
|
||||||
|
UncleTooOld(OutOfBounds<BlockNumber>),
|
||||||
|
UncleIsBrother(OutOfBounds<BlockNumber>),
|
||||||
|
UncleInChain(H256),
|
||||||
|
UncleParentNotInChain(H256),
|
||||||
|
InvalidStateRoot(Mismatch<H256>),
|
||||||
|
InvalidGasUsed(Mismatch<U256>),
|
||||||
|
InvalidTransactionsRoot(Mismatch<H256>),
|
||||||
|
InvalidDifficulty(Mismatch<U256>),
|
||||||
|
InvalidGasLimit(OutOfBounds<U256>),
|
||||||
|
InvalidReceiptsStateRoot(Mismatch<H256>),
|
||||||
|
InvalidTimestamp(OutOfBounds<u64>),
|
||||||
|
InvalidLogBloom(Mismatch<LogBloom>),
|
||||||
|
InvalidBlockNonce(Mismatch<H256>),
|
||||||
|
InvalidParentHash(Mismatch<H256>),
|
||||||
|
InvalidNumber(OutOfBounds<BlockNumber>),
|
||||||
|
UnknownParent(H256),
|
||||||
|
UnknownUncleParent(H256),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum ImportError {
|
||||||
|
Bad(Option<Error>),
|
||||||
|
AlreadyInChain,
|
||||||
|
AlreadyQueued,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Error> for ImportError {
|
||||||
|
fn from(err: Error) -> ImportError {
|
||||||
|
ImportError::Bad(Some(err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Result of import block operation.
|
||||||
|
pub type ImportResult = Result<(), ImportError>;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
/// General error type which should be capable of representing all errors in ethcore.
|
/// General error type which should be capable of representing all errors in ethcore.
|
||||||
pub enum UtilError {
|
pub enum Error {
|
||||||
Crypto(::crypto::CryptoError),
|
Util(UtilError),
|
||||||
StdIo(::std::io::Error),
|
Block(BlockError),
|
||||||
Io(io::IoError),
|
UnknownEngineName(String),
|
||||||
AddressParse(::std::net::AddrParseError),
|
Execution(ExecutionError),
|
||||||
AddressResolve(Option<::std::io::Error>),
|
Transaction(TransactionError),
|
||||||
FromHex(FromHexError),
|
|
||||||
BaseData(BaseDataError),
|
|
||||||
Network(NetworkError),
|
|
||||||
Decoder(DecoderError),
|
|
||||||
BadSize,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<FromHexError> for UtilError {
|
impl From<TransactionError> for Error {
|
||||||
fn from(err: FromHexError) -> UtilError {
|
fn from(err: TransactionError) -> Error {
|
||||||
UtilError::FromHex(err)
|
Error::Transaction(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<BaseDataError> for UtilError {
|
impl From<BlockError> for Error {
|
||||||
fn from(err: BaseDataError) -> UtilError {
|
fn from(err: BlockError) -> Error {
|
||||||
UtilError::BaseData(err)
|
Error::Block(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<NetworkError> for UtilError {
|
impl From<ExecutionError> for Error {
|
||||||
fn from(err: NetworkError) -> UtilError {
|
fn from(err: ExecutionError) -> Error {
|
||||||
UtilError::Network(err)
|
Error::Execution(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<::std::io::Error> for UtilError {
|
impl From<CryptoError> for Error {
|
||||||
fn from(err: ::std::io::Error) -> UtilError {
|
fn from(err: CryptoError) -> Error {
|
||||||
UtilError::StdIo(err)
|
Error::Util(UtilError::Crypto(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<io::IoError> for UtilError {
|
impl From<DecoderError> for Error {
|
||||||
fn from(err: io::IoError) -> UtilError {
|
fn from(err: DecoderError) -> Error {
|
||||||
UtilError::Io(err)
|
Error::Util(UtilError::Decoder(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<::crypto::CryptoError> for UtilError {
|
impl From<UtilError> for Error {
|
||||||
fn from(err: ::crypto::CryptoError) -> UtilError {
|
fn from(err: UtilError) -> Error {
|
||||||
UtilError::Crypto(err)
|
Error::Util(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<::std::net::AddrParseError> for UtilError {
|
impl From<IoError> for Error {
|
||||||
fn from(err: ::std::net::AddrParseError) -> UtilError {
|
fn from(err: IoError) -> Error {
|
||||||
UtilError::AddressParse(err)
|
Error::Util(From::from(err))
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<::rlp::DecoderError> for UtilError {
|
|
||||||
fn from(err: ::rlp::DecoderError) -> UtilError {
|
|
||||||
UtilError::Decoder(err)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
165
src/lib.rs
165
src/lib.rs
@ -1,101 +1,128 @@
|
|||||||
#![feature(op_assign_traits)]
|
#![feature(cell_extras)]
|
||||||
#![feature(augmented_assignments)]
|
#![feature(augmented_assignments)]
|
||||||
#![feature(associated_consts)]
|
|
||||||
#![feature(wrapping)]
|
#![feature(wrapping)]
|
||||||
//! Ethcore-util library
|
//#![feature(plugin)]
|
||||||
|
//#![plugin(interpolate_idents)]
|
||||||
|
//! Ethcore's ethereum implementation
|
||||||
//!
|
//!
|
||||||
//! ### Rust version:
|
//! ### Rust version
|
||||||
//! - beta
|
//! - beta
|
||||||
//! - nightly
|
//! - nightly
|
||||||
//!
|
//!
|
||||||
//! ### Supported platforms:
|
//! ### Supported platforms:
|
||||||
//! - OSX
|
//! - OSX
|
||||||
//! - Linux
|
//! - Linux/Ubuntu
|
||||||
//!
|
//!
|
||||||
//! ### Dependencies:
|
//! ### Dependencies:
|
||||||
//! - RocksDB 3.13
|
//! - RocksDB 3.13
|
||||||
|
//! - LLVM 3.7 (optional, required for `jit`)
|
||||||
|
//! - evmjit (optional, required for `jit`)
|
||||||
//!
|
//!
|
||||||
//! ### Dependencies Installation:
|
//! ### Dependencies Installation
|
||||||
//!
|
//!
|
||||||
//! - OSX:
|
//! - OSX
|
||||||
//!
|
//!
|
||||||
|
//! - rocksdb
|
||||||
//! ```bash
|
//! ```bash
|
||||||
//! brew install rocksdb
|
//! brew install rocksdb
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! - From source:
|
//! - llvm
|
||||||
|
//!
|
||||||
|
//! - download llvm 3.7 from http://llvm.org/apt/
|
||||||
|
//!
|
||||||
|
//! ```bash
|
||||||
|
//! cd llvm-3.7.0.src
|
||||||
|
//! mkdir build && cd $_
|
||||||
|
//! cmake -G "Unix Makefiles" .. -DCMAKE_C_FLAGS_RELEASE= -DCMAKE_CXX_FLAGS_RELEASE= -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/llvm/3.7 -DCMAKE_BUILD_TYPE=Release
|
||||||
|
//! make && make install
|
||||||
|
//! ```
|
||||||
|
//! - evmjit
|
||||||
|
//!
|
||||||
|
//! - download from https://github.com/debris/evmjit
|
||||||
|
//!
|
||||||
|
//! ```bash
|
||||||
|
//! cd evmjit
|
||||||
|
//! mkdir build && cd $_
|
||||||
|
//! cmake -DLLVM_DIR=/usr/local/lib/llvm-3.7/share/llvm/cmake ..
|
||||||
|
//! make && make install
|
||||||
|
//! ```
|
||||||
|
//!
|
||||||
|
//! - Linux/Ubuntu
|
||||||
|
//!
|
||||||
|
//! - rocksdb
|
||||||
//!
|
//!
|
||||||
//! ```bash
|
//! ```bash
|
||||||
//! wget https://github.com/facebook/rocksdb/archive/rocksdb-3.13.tar.gz
|
//! wget https://github.com/facebook/rocksdb/archive/rocksdb-3.13.tar.gz
|
||||||
//! tar xvf rocksdb-3.13.tar.gz && cd rocksdb-rocksdb-3.13 && make shared_lib
|
//! tar xvf rocksdb-3.13.tar.gz && cd rocksdb-rocksdb-3.13 && make shared_lib
|
||||||
//! sudo make install
|
//! sudo make install
|
||||||
//! ```
|
//! ```
|
||||||
|
//!
|
||||||
|
//! - llvm
|
||||||
|
//!
|
||||||
|
//! - install using packages from http://llvm.org/apt/
|
||||||
|
//!
|
||||||
|
//! - evmjit
|
||||||
|
//!
|
||||||
|
//! - download from https://github.com/debris/evmjit
|
||||||
|
//!
|
||||||
|
//! ```bash
|
||||||
|
//! cd evmjit
|
||||||
|
//! mkdir build && cd $_
|
||||||
|
//! cmake .. && make
|
||||||
|
//! sudo make install
|
||||||
|
//! sudo ldconfig
|
||||||
|
//! ```
|
||||||
|
|
||||||
extern crate slab;
|
|
||||||
extern crate rustc_serialize;
|
|
||||||
extern crate mio;
|
|
||||||
extern crate rand;
|
|
||||||
extern crate rocksdb;
|
|
||||||
extern crate tiny_keccak;
|
|
||||||
#[macro_use]
|
|
||||||
extern crate heapsize;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
#[macro_use]
|
extern crate rustc_serialize;
|
||||||
extern crate lazy_static;
|
extern crate flate2;
|
||||||
#[macro_use]
|
extern crate rocksdb;
|
||||||
extern crate itertools;
|
extern crate heapsize;
|
||||||
extern crate env_logger;
|
extern crate crypto;
|
||||||
extern crate time;
|
extern crate time;
|
||||||
extern crate crypto as rcrypto;
|
extern crate env_logger;
|
||||||
extern crate secp256k1;
|
#[cfg(feature = "jit" )]
|
||||||
extern crate arrayvec;
|
extern crate evmjit;
|
||||||
extern crate elastic_array;
|
#[macro_use]
|
||||||
|
extern crate ethcore_util as util;
|
||||||
|
|
||||||
pub mod standard;
|
|
||||||
#[macro_use]
|
|
||||||
pub mod from_json;
|
|
||||||
#[macro_use]
|
|
||||||
pub mod common;
|
pub mod common;
|
||||||
|
pub mod basic_types;
|
||||||
|
#[macro_use]
|
||||||
|
pub mod evm;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
pub mod hash;
|
pub mod log_entry;
|
||||||
pub mod uint;
|
pub mod env_info;
|
||||||
pub mod bytes;
|
pub mod pod_account;
|
||||||
pub mod rlp;
|
pub mod pod_state;
|
||||||
pub mod misc;
|
pub mod account_diff;
|
||||||
pub mod json_aid;
|
pub mod state_diff;
|
||||||
pub mod vector;
|
pub mod engine;
|
||||||
pub mod sha3;
|
pub mod state;
|
||||||
pub mod hashdb;
|
pub mod account;
|
||||||
pub mod memorydb;
|
pub mod action_params;
|
||||||
pub mod overlaydb;
|
pub mod header;
|
||||||
pub mod math;
|
pub mod transaction;
|
||||||
pub mod chainfilter;
|
pub mod receipt;
|
||||||
pub mod crypto;
|
pub mod null_engine;
|
||||||
pub mod triehash;
|
pub mod builtin;
|
||||||
pub mod trie;
|
pub mod spec;
|
||||||
pub mod nibbleslice;
|
pub mod views;
|
||||||
pub mod heapsizeof;
|
pub mod blockchain;
|
||||||
pub mod squeeze;
|
pub mod extras;
|
||||||
pub mod semantic_version;
|
pub mod substate;
|
||||||
pub mod io;
|
pub mod service;
|
||||||
pub mod network;
|
pub mod executive;
|
||||||
|
pub mod externalities;
|
||||||
|
|
||||||
pub use common::*;
|
#[cfg(test)]
|
||||||
pub use misc::*;
|
mod tests;
|
||||||
pub use json_aid::*;
|
|
||||||
pub use rlp::*;
|
pub mod client;
|
||||||
pub use hashdb::*;
|
pub mod sync;
|
||||||
pub use memorydb::*;
|
pub mod block;
|
||||||
pub use overlaydb::*;
|
pub mod verification;
|
||||||
pub use math::*;
|
pub mod queue;
|
||||||
pub use chainfilter::*;
|
pub mod ethereum;
|
||||||
pub use crypto::*;
|
|
||||||
pub use triehash::*;
|
|
||||||
pub use trie::*;
|
|
||||||
pub use nibbleslice::*;
|
|
||||||
pub use heapsizeof::*;
|
|
||||||
pub use squeeze::*;
|
|
||||||
pub use semantic_version::*;
|
|
||||||
pub use network::*;
|
|
||||||
pub use io::*;
|
|
||||||
|
32
util/Cargo.toml
Normal file
32
util/Cargo.toml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
[package]
|
||||||
|
description = "Ethcore utility library"
|
||||||
|
homepage = "http://ethcore.io"
|
||||||
|
license = "GPL-3.0"
|
||||||
|
name = "ethcore-util"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Ethcore <admin@ethcore.io>"]
|
||||||
|
build = "build.rs"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
gcc = "0.3"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
log = "0.3"
|
||||||
|
env_logger = "0.3"
|
||||||
|
rustc-serialize = "0.3"
|
||||||
|
arrayvec = "0.3"
|
||||||
|
mio = "0.5.0"
|
||||||
|
rand = "0.3.12"
|
||||||
|
time = "0.1.34"
|
||||||
|
tiny-keccak = "1.0"
|
||||||
|
rocksdb = "0.3"
|
||||||
|
lazy_static = "0.1"
|
||||||
|
eth-secp256k1 = { git = "https://github.com/arkpar/rust-secp256k1.git" }
|
||||||
|
rust-crypto = "0.2.34"
|
||||||
|
elastic-array = "0.4"
|
||||||
|
heapsize = "0.2"
|
||||||
|
itertools = "0.4"
|
||||||
|
slab = { git = "https://github.com/arkpar/slab.git" }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
json-tests = { path = "json-tests" }
|
1
util/README.md
Normal file
1
util/README.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# ethcore-util
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user