diff --git a/Cargo.toml b/Cargo.toml index 6b60fddf1..6e1344775 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,32 +1,24 @@ [package] -description = "Ethcore utility library" +description = "Ethcore library" homepage = "http://ethcore.io" license = "GPL-3.0" -name = "ethcore-util" +name = "ethcore" version = "0.1.0" authors = ["Ethcore "] -build = "build.rs" - -[build-dependencies] -gcc = "0.3" [dependencies] log = "0.3" env_logger = "0.3" +ethcore-util = { path = "util" } rustc-serialize = "0.3" -arrayvec = "0.3" -mio = "0.5.0" -rand = "0.3.12" -time = "0.1.34" -tiny-keccak = "1.0" +flate2 = "0.2" rocksdb = "0.3" -lazy_static = "0.1" -eth-secp256k1 = { git = "https://github.com/arkpar/rust-secp256k1.git" } +heapsize = "0.2.0" rust-crypto = "0.2.34" -elastic-array = "0.4" -heapsize = "0.2" -itertools = "0.4" -slab = { git = "https://github.com/arkpar/slab.git" } +time = "0.1" +#interpolate_idents = { git = "https://github.com/SkylerLipthay/interpolate_idents" } +evmjit = { path = "rust-evmjit", optional = true } -[dev-dependencies] -json-tests = { path = "json-tests" } +[features] +jit = ["evmjit"] +evm_debug = [] diff --git a/README.md b/README.md index 744d98922..216ac8091 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# ethcore-util +# ethcore diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml deleted file mode 100644 index 04b99f707..000000000 --- a/ethcore/Cargo.toml +++ /dev/null @@ -1,24 +0,0 @@ -[package] -description = "Ethcore library" -homepage = "http://ethcore.io" -license = "GPL-3.0" -name = "ethcore" -version = "0.1.0" -authors = ["Ethcore "] - -[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 = [] diff --git a/ethcore/README.md b/ethcore/README.md deleted file mode 100644 index 216ac8091..000000000 --- a/ethcore/README.md +++ /dev/null @@ -1 +0,0 @@ -# ethcore diff --git a/ethcore/src/common.rs b/ethcore/src/common.rs deleted file mode 100644 index b699bd4c6..000000000 --- a/ethcore/src/common.rs +++ /dev/null @@ -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::*; \ No newline at end of file diff --git a/ethcore/src/error.rs b/ethcore/src/error.rs deleted file mode 100644 index 5be1074c1..000000000 --- a/ethcore/src/error.rs +++ /dev/null @@ -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 { - pub expected: T, - pub found: T, -} - -#[derive(Debug, PartialEq, Eq)] -pub struct OutOfBounds { - pub min: Option, - pub max: Option, - 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), -} - -#[derive(Debug, PartialEq, Eq)] -pub enum BlockError { - TooManyUncles(OutOfBounds), - UncleWrongGeneration, - ExtraDataOutOfBounds(OutOfBounds), - InvalidSealArity(Mismatch), - TooMuchGasUsed(OutOfBounds), - InvalidUnclesHash(Mismatch), - UncleTooOld(OutOfBounds), - UncleIsBrother(OutOfBounds), - UncleInChain(H256), - UncleParentNotInChain(H256), - InvalidStateRoot(Mismatch), - InvalidGasUsed(Mismatch), - InvalidTransactionsRoot(Mismatch), - InvalidDifficulty(Mismatch), - InvalidGasLimit(OutOfBounds), - InvalidReceiptsStateRoot(Mismatch), - InvalidTimestamp(OutOfBounds), - InvalidLogBloom(Mismatch), - InvalidBlockNonce(Mismatch), - InvalidParentHash(Mismatch), - InvalidNumber(OutOfBounds), - UnknownParent(H256), - UnknownUncleParent(H256), -} - -#[derive(Debug)] -pub enum ImportError { - Bad(Option), - AlreadyInChain, - AlreadyQueued, -} - -impl From 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 for Error { - fn from(err: TransactionError) -> Error { - Error::Transaction(err) - } -} - -impl From for Error { - fn from(err: BlockError) -> Error { - Error::Block(err) - } -} - -impl From for Error { - fn from(err: ExecutionError) -> Error { - Error::Execution(err) - } -} - -impl From for Error { - fn from(err: CryptoError) -> Error { - Error::Util(UtilError::Crypto(err)) - } -} - -impl From for Error { - fn from(err: DecoderError) -> Error { - Error::Util(UtilError::Decoder(err)) - } -} - -impl From for Error { - fn from(err: UtilError) -> Error { - Error::Util(err) - } -} - -impl From 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 for Error { - fn from(err: concat_idents!($name, Error)) -> Error { - Error:: $name (err) - } - } - ) -} -assimilate!(FromHex); -assimilate!(BaseData);*/ diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs deleted file mode 100644 index 7e4fdf33e..000000000 --- a/ethcore/src/lib.rs +++ /dev/null @@ -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; diff --git a/ethcore/res/ethereum/frontier.json b/res/ethereum/frontier.json similarity index 100% rename from ethcore/res/ethereum/frontier.json rename to res/ethereum/frontier.json diff --git a/ethcore/res/ethereum/frontier_like_test.json b/res/ethereum/frontier_like_test.json similarity index 100% rename from ethcore/res/ethereum/frontier_like_test.json rename to res/ethereum/frontier_like_test.json diff --git a/ethcore/res/ethereum/frontier_test.json b/res/ethereum/frontier_test.json similarity index 100% rename from ethcore/res/ethereum/frontier_test.json rename to res/ethereum/frontier_test.json diff --git a/ethcore/res/ethereum/homestead_test.json b/res/ethereum/homestead_test.json similarity index 100% rename from ethcore/res/ethereum/homestead_test.json rename to res/ethereum/homestead_test.json diff --git a/ethcore/res/ethereum/morden.json b/res/ethereum/morden.json similarity index 100% rename from ethcore/res/ethereum/morden.json rename to res/ethereum/morden.json diff --git a/ethcore/res/ethereum/olympic.json b/res/ethereum/olympic.json similarity index 100% rename from ethcore/res/ethereum/olympic.json rename to res/ethereum/olympic.json diff --git a/ethcore/res/ethereum/tests b/res/ethereum/tests similarity index 100% rename from ethcore/res/ethereum/tests rename to res/ethereum/tests diff --git a/ethcore/res/null_morden.json b/res/null_morden.json similarity index 100% rename from ethcore/res/null_morden.json rename to res/null_morden.json diff --git a/ethcore/rust-evmjit/.gitignore b/rust-evmjit/.gitignore similarity index 100% rename from ethcore/rust-evmjit/.gitignore rename to rust-evmjit/.gitignore diff --git a/ethcore/rust-evmjit/Cargo.toml b/rust-evmjit/Cargo.toml similarity index 100% rename from ethcore/rust-evmjit/Cargo.toml rename to rust-evmjit/Cargo.toml diff --git a/ethcore/rust-evmjit/src/lib.rs b/rust-evmjit/src/lib.rs similarity index 100% rename from ethcore/rust-evmjit/src/lib.rs rename to rust-evmjit/src/lib.rs diff --git a/ethcore/src/account.rs b/src/account.rs similarity index 100% rename from ethcore/src/account.rs rename to src/account.rs diff --git a/ethcore/src/account_diff.rs b/src/account_diff.rs similarity index 100% rename from ethcore/src/account_diff.rs rename to src/account_diff.rs diff --git a/ethcore/src/action_params.rs b/src/action_params.rs similarity index 100% rename from ethcore/src/action_params.rs rename to src/action_params.rs diff --git a/ethcore/src/basic_types.rs b/src/basic_types.rs similarity index 100% rename from ethcore/src/basic_types.rs rename to src/basic_types.rs diff --git a/ethcore/src/bin/client.rs b/src/bin/client.rs similarity index 100% rename from ethcore/src/bin/client.rs rename to src/bin/client.rs diff --git a/ethcore/src/block.rs b/src/block.rs similarity index 100% rename from ethcore/src/block.rs rename to src/block.rs diff --git a/ethcore/src/blockchain.rs b/src/blockchain.rs similarity index 100% rename from ethcore/src/blockchain.rs rename to src/blockchain.rs diff --git a/ethcore/src/builtin.rs b/src/builtin.rs similarity index 100% rename from ethcore/src/builtin.rs rename to src/builtin.rs diff --git a/ethcore/src/client.rs b/src/client.rs similarity index 100% rename from ethcore/src/client.rs rename to src/client.rs diff --git a/src/common.rs b/src/common.rs index 3ec02ad9b..b699bd4c6 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,57 +1,12 @@ -pub use standard::*; -pub use from_json::*; +pub use util::*; +pub use basic_types::*; pub use error::*; -pub use hash::*; -pub use uint::*; -pub use bytes::*; -pub use vector::*; -pub use sha3::*; - -#[macro_export] -macro_rules! map { - ( $( $x:expr => $y:expr ),* ) => { - vec![ $( ($x, $y) ),* ].into_iter().collect::>() - } -} - -#[macro_export] -macro_rules! mapx { - ( $( $x:expr => $y:expr ),* ) => { - vec![ $( ( From::from($x), From::from($y) ) ),* ].into_iter().collect::>() - } -} - -#[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); -} +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::*; \ No newline at end of file diff --git a/ethcore/src/engine.rs b/src/engine.rs similarity index 100% rename from ethcore/src/engine.rs rename to src/engine.rs diff --git a/ethcore/src/env_info.rs b/src/env_info.rs similarity index 100% rename from ethcore/src/env_info.rs rename to src/env_info.rs diff --git a/src/error.rs b/src/error.rs index 04f7b96ce..5be1074c1 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,75 +1,139 @@ //! General error types for use in ethcore. -use rustc_serialize::hex::FromHexError; -use network::NetworkError; -use rlp::DecoderError; -use io; +use util::*; +use header::BlockNumber; +use basic_types::LogBloom; + +#[derive(Debug, PartialEq, Eq)] +pub struct Mismatch { + pub expected: T, + pub found: T, +} + +#[derive(Debug, PartialEq, Eq)] +pub struct OutOfBounds { + pub min: Option, + pub max: Option, + 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 BaseDataError { - NegativelyReferencedHash, +pub enum TransactionError { + InvalidGasLimit(OutOfBounds), } +#[derive(Debug, PartialEq, Eq)] +pub enum BlockError { + TooManyUncles(OutOfBounds), + UncleWrongGeneration, + ExtraDataOutOfBounds(OutOfBounds), + InvalidSealArity(Mismatch), + TooMuchGasUsed(OutOfBounds), + InvalidUnclesHash(Mismatch), + UncleTooOld(OutOfBounds), + UncleIsBrother(OutOfBounds), + UncleInChain(H256), + UncleParentNotInChain(H256), + InvalidStateRoot(Mismatch), + InvalidGasUsed(Mismatch), + InvalidTransactionsRoot(Mismatch), + InvalidDifficulty(Mismatch), + InvalidGasLimit(OutOfBounds), + InvalidReceiptsStateRoot(Mismatch), + InvalidTimestamp(OutOfBounds), + InvalidLogBloom(Mismatch), + InvalidBlockNonce(Mismatch), + InvalidParentHash(Mismatch), + InvalidNumber(OutOfBounds), + UnknownParent(H256), + UnknownUncleParent(H256), +} + +#[derive(Debug)] +pub enum ImportError { + Bad(Option), + AlreadyInChain, + AlreadyQueued, +} + +impl From 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 UtilError { - Crypto(::crypto::CryptoError), - StdIo(::std::io::Error), - Io(io::IoError), - AddressParse(::std::net::AddrParseError), - AddressResolve(Option<::std::io::Error>), - FromHex(FromHexError), - BaseData(BaseDataError), - Network(NetworkError), - Decoder(DecoderError), - BadSize, +pub enum Error { + Util(UtilError), + Block(BlockError), + UnknownEngineName(String), + Execution(ExecutionError), + Transaction(TransactionError), } -impl From for UtilError { - fn from(err: FromHexError) -> UtilError { - UtilError::FromHex(err) +impl From for Error { + fn from(err: TransactionError) -> Error { + Error::Transaction(err) } } -impl From for UtilError { - fn from(err: BaseDataError) -> UtilError { - UtilError::BaseData(err) +impl From for Error { + fn from(err: BlockError) -> Error { + Error::Block(err) } } -impl From for UtilError { - fn from(err: NetworkError) -> UtilError { - UtilError::Network(err) +impl From for Error { + fn from(err: ExecutionError) -> Error { + Error::Execution(err) } } -impl From<::std::io::Error> for UtilError { - fn from(err: ::std::io::Error) -> UtilError { - UtilError::StdIo(err) +impl From for Error { + fn from(err: CryptoError) -> Error { + Error::Util(UtilError::Crypto(err)) } } -impl From for UtilError { - fn from(err: io::IoError) -> UtilError { - UtilError::Io(err) +impl From for Error { + fn from(err: DecoderError) -> Error { + Error::Util(UtilError::Decoder(err)) } } -impl From<::crypto::CryptoError> for UtilError { - fn from(err: ::crypto::CryptoError) -> UtilError { - UtilError::Crypto(err) +impl From for Error { + fn from(err: UtilError) -> Error { + Error::Util(err) } } -impl From<::std::net::AddrParseError> for UtilError { - fn from(err: ::std::net::AddrParseError) -> UtilError { - UtilError::AddressParse(err) - } -} - -impl From<::rlp::DecoderError> for UtilError { - fn from(err: ::rlp::DecoderError) -> UtilError { - UtilError::Decoder(err) +impl From for Error { + fn from(err: IoError) -> Error { + Error::Util(From::from(err)) } } diff --git a/ethcore/src/ethereum/denominations.rs b/src/ethereum/denominations.rs similarity index 100% rename from ethcore/src/ethereum/denominations.rs rename to src/ethereum/denominations.rs diff --git a/ethcore/src/ethereum/ethash.rs b/src/ethereum/ethash.rs similarity index 100% rename from ethcore/src/ethereum/ethash.rs rename to src/ethereum/ethash.rs diff --git a/ethcore/src/ethereum/mod.rs b/src/ethereum/mod.rs similarity index 100% rename from ethcore/src/ethereum/mod.rs rename to src/ethereum/mod.rs diff --git a/ethcore/src/evm/evm.rs b/src/evm/evm.rs similarity index 100% rename from ethcore/src/evm/evm.rs rename to src/evm/evm.rs diff --git a/ethcore/src/evm/ext.rs b/src/evm/ext.rs similarity index 100% rename from ethcore/src/evm/ext.rs rename to src/evm/ext.rs diff --git a/ethcore/src/evm/factory.rs b/src/evm/factory.rs similarity index 100% rename from ethcore/src/evm/factory.rs rename to src/evm/factory.rs diff --git a/ethcore/src/evm/instructions.rs b/src/evm/instructions.rs similarity index 100% rename from ethcore/src/evm/instructions.rs rename to src/evm/instructions.rs diff --git a/ethcore/src/evm/interpreter.rs b/src/evm/interpreter.rs similarity index 100% rename from ethcore/src/evm/interpreter.rs rename to src/evm/interpreter.rs diff --git a/ethcore/src/evm/jit.rs b/src/evm/jit.rs similarity index 100% rename from ethcore/src/evm/jit.rs rename to src/evm/jit.rs diff --git a/ethcore/src/evm/mod.rs b/src/evm/mod.rs similarity index 100% rename from ethcore/src/evm/mod.rs rename to src/evm/mod.rs diff --git a/ethcore/src/evm/schedule.rs b/src/evm/schedule.rs similarity index 100% rename from ethcore/src/evm/schedule.rs rename to src/evm/schedule.rs diff --git a/ethcore/src/evm/tests.rs b/src/evm/tests.rs similarity index 100% rename from ethcore/src/evm/tests.rs rename to src/evm/tests.rs diff --git a/ethcore/src/executive.rs b/src/executive.rs similarity index 100% rename from ethcore/src/executive.rs rename to src/executive.rs diff --git a/ethcore/src/externalities.rs b/src/externalities.rs similarity index 100% rename from ethcore/src/externalities.rs rename to src/externalities.rs diff --git a/ethcore/src/extras.rs b/src/extras.rs similarity index 100% rename from ethcore/src/extras.rs rename to src/extras.rs diff --git a/ethcore/src/header.rs b/src/header.rs similarity index 100% rename from ethcore/src/header.rs rename to src/header.rs diff --git a/src/lib.rs b/src/lib.rs index 4bc47e61c..7e4fdf33e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,101 +1,128 @@ -#![feature(op_assign_traits)] +#![feature(cell_extras)] #![feature(augmented_assignments)] -#![feature(associated_consts)] #![feature(wrapping)] -//! Ethcore-util library +//#![feature(plugin)] +//#![plugin(interpolate_idents)] +//! Ethcore's ethereum implementation //! -//! ### Rust version: +//! ### Rust version //! - beta //! - nightly //! //! ### Supported platforms: //! - OSX -//! - Linux +//! - Linux/Ubuntu //! //! ### Dependencies: //! - RocksDB 3.13 +//! - LLVM 3.7 (optional, required for `jit`) +//! - evmjit (optional, required for `jit`) //! -//! ### Dependencies Installation: +//! ### Dependencies Installation //! -//! - OSX: +//! - OSX //! +//! - rocksdb //! ```bash //! brew install rocksdb //! ``` //! -//! - From source: +//! - llvm //! -//! ```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 -//! ``` +//! - 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 +//! ``` -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] extern crate log; -#[macro_use] -extern crate lazy_static; -#[macro_use] -extern crate itertools; -extern crate env_logger; +extern crate rustc_serialize; +extern crate flate2; +extern crate rocksdb; +extern crate heapsize; +extern crate crypto; extern crate time; -extern crate crypto as rcrypto; -extern crate secp256k1; -extern crate arrayvec; -extern crate elastic_array; +extern crate env_logger; +#[cfg(feature = "jit" )] +extern crate evmjit; +#[macro_use] +extern crate ethcore_util as util; -pub mod standard; -#[macro_use] -pub mod from_json; -#[macro_use] pub mod common; +pub mod basic_types; +#[macro_use] +pub mod evm; pub mod error; -pub mod hash; -pub mod uint; -pub mod bytes; -pub mod rlp; -pub mod misc; -pub mod json_aid; -pub mod vector; -pub mod sha3; -pub mod hashdb; -pub mod memorydb; -pub mod overlaydb; -pub mod math; -pub mod chainfilter; -pub mod crypto; -pub mod triehash; -pub mod trie; -pub mod nibbleslice; -pub mod heapsizeof; -pub mod squeeze; -pub mod semantic_version; -pub mod io; -pub mod network; +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; -pub use common::*; -pub use misc::*; -pub use json_aid::*; -pub use rlp::*; -pub use hashdb::*; -pub use memorydb::*; -pub use overlaydb::*; -pub use math::*; -pub use chainfilter::*; -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::*; +#[cfg(test)] +mod tests; + +pub mod client; +pub mod sync; +pub mod block; +pub mod verification; +pub mod queue; +pub mod ethereum; diff --git a/ethcore/src/log_entry.rs b/src/log_entry.rs similarity index 100% rename from ethcore/src/log_entry.rs rename to src/log_entry.rs diff --git a/ethcore/src/null_engine.rs b/src/null_engine.rs similarity index 100% rename from ethcore/src/null_engine.rs rename to src/null_engine.rs diff --git a/ethcore/src/pod_account.rs b/src/pod_account.rs similarity index 100% rename from ethcore/src/pod_account.rs rename to src/pod_account.rs diff --git a/ethcore/src/pod_state.rs b/src/pod_state.rs similarity index 100% rename from ethcore/src/pod_state.rs rename to src/pod_state.rs diff --git a/ethcore/src/queue.rs b/src/queue.rs similarity index 100% rename from ethcore/src/queue.rs rename to src/queue.rs diff --git a/ethcore/src/receipt.rs b/src/receipt.rs similarity index 100% rename from ethcore/src/receipt.rs rename to src/receipt.rs diff --git a/ethcore/src/service.rs b/src/service.rs similarity index 100% rename from ethcore/src/service.rs rename to src/service.rs diff --git a/ethcore/src/spec.rs b/src/spec.rs similarity index 100% rename from ethcore/src/spec.rs rename to src/spec.rs diff --git a/ethcore/src/state.rs b/src/state.rs similarity index 100% rename from ethcore/src/state.rs rename to src/state.rs diff --git a/ethcore/src/state_diff.rs b/src/state_diff.rs similarity index 100% rename from ethcore/src/state_diff.rs rename to src/state_diff.rs diff --git a/ethcore/src/substate.rs b/src/substate.rs similarity index 100% rename from ethcore/src/substate.rs rename to src/substate.rs diff --git a/ethcore/src/sync/chain.rs b/src/sync/chain.rs similarity index 100% rename from ethcore/src/sync/chain.rs rename to src/sync/chain.rs diff --git a/ethcore/src/sync/io.rs b/src/sync/io.rs similarity index 100% rename from ethcore/src/sync/io.rs rename to src/sync/io.rs diff --git a/ethcore/src/sync/mod.rs b/src/sync/mod.rs similarity index 100% rename from ethcore/src/sync/mod.rs rename to src/sync/mod.rs diff --git a/ethcore/src/sync/range_collection.rs b/src/sync/range_collection.rs similarity index 100% rename from ethcore/src/sync/range_collection.rs rename to src/sync/range_collection.rs diff --git a/ethcore/src/sync/tests.rs b/src/sync/tests.rs similarity index 100% rename from ethcore/src/sync/tests.rs rename to src/sync/tests.rs diff --git a/ethcore/src/tests/executive.rs b/src/tests/executive.rs similarity index 100% rename from ethcore/src/tests/executive.rs rename to src/tests/executive.rs diff --git a/ethcore/src/tests/mod.rs b/src/tests/mod.rs similarity index 100% rename from ethcore/src/tests/mod.rs rename to src/tests/mod.rs diff --git a/ethcore/src/tests/state.rs b/src/tests/state.rs similarity index 100% rename from ethcore/src/tests/state.rs rename to src/tests/state.rs diff --git a/ethcore/src/tests/test_common.rs b/src/tests/test_common.rs similarity index 100% rename from ethcore/src/tests/test_common.rs rename to src/tests/test_common.rs diff --git a/ethcore/src/tests/transaction.rs b/src/tests/transaction.rs similarity index 100% rename from ethcore/src/tests/transaction.rs rename to src/tests/transaction.rs diff --git a/ethcore/src/transaction.rs b/src/transaction.rs similarity index 100% rename from ethcore/src/transaction.rs rename to src/transaction.rs diff --git a/ethcore/src/verification.rs b/src/verification.rs similarity index 100% rename from ethcore/src/verification.rs rename to src/verification.rs diff --git a/ethcore/src/views.rs b/src/views.rs similarity index 100% rename from ethcore/src/views.rs rename to src/views.rs diff --git a/.travis.yml b/util/.travis.yml similarity index 100% rename from .travis.yml rename to util/.travis.yml diff --git a/util/Cargo.toml b/util/Cargo.toml new file mode 100644 index 000000000..6b60fddf1 --- /dev/null +++ b/util/Cargo.toml @@ -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 "] +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" } diff --git a/ethcore/LICENSE b/util/LICENSE similarity index 100% rename from ethcore/LICENSE rename to util/LICENSE diff --git a/Makefile b/util/Makefile similarity index 100% rename from Makefile rename to util/Makefile diff --git a/util/README.md b/util/README.md new file mode 100644 index 000000000..744d98922 --- /dev/null +++ b/util/README.md @@ -0,0 +1 @@ +# ethcore-util diff --git a/benches/rlp.rs b/util/benches/rlp.rs similarity index 100% rename from benches/rlp.rs rename to util/benches/rlp.rs diff --git a/benches/trie.rs b/util/benches/trie.rs similarity index 100% rename from benches/trie.rs rename to util/benches/trie.rs diff --git a/build.rs b/util/build.rs similarity index 100% rename from build.rs rename to util/build.rs diff --git a/json-tests/Cargo.toml b/util/json-tests/Cargo.toml similarity index 100% rename from json-tests/Cargo.toml rename to util/json-tests/Cargo.toml diff --git a/json-tests/README.md b/util/json-tests/README.md similarity index 100% rename from json-tests/README.md rename to util/json-tests/README.md diff --git a/json-tests/json/.DS_Store b/util/json-tests/json/.DS_Store similarity index 100% rename from json-tests/json/.DS_Store rename to util/json-tests/json/.DS_Store diff --git a/json-tests/json/rlp/README.md b/util/json-tests/json/rlp/README.md similarity index 100% rename from json-tests/json/rlp/README.md rename to util/json-tests/json/rlp/README.md diff --git a/json-tests/json/rlp/stream/bytestring0.json b/util/json-tests/json/rlp/stream/bytestring0.json similarity index 100% rename from json-tests/json/rlp/stream/bytestring0.json rename to util/json-tests/json/rlp/stream/bytestring0.json diff --git a/json-tests/json/rlp/stream/bytestring1.json b/util/json-tests/json/rlp/stream/bytestring1.json similarity index 100% rename from json-tests/json/rlp/stream/bytestring1.json rename to util/json-tests/json/rlp/stream/bytestring1.json diff --git a/json-tests/json/rlp/stream/bytestring7.json b/util/json-tests/json/rlp/stream/bytestring7.json similarity index 100% rename from json-tests/json/rlp/stream/bytestring7.json rename to util/json-tests/json/rlp/stream/bytestring7.json diff --git a/json-tests/json/rlp/stream/catdog.json b/util/json-tests/json/rlp/stream/catdog.json similarity index 100% rename from json-tests/json/rlp/stream/catdog.json rename to util/json-tests/json/rlp/stream/catdog.json diff --git a/json-tests/json/rlp/stream/empty.json b/util/json-tests/json/rlp/stream/empty.json similarity index 100% rename from json-tests/json/rlp/stream/empty.json rename to util/json-tests/json/rlp/stream/empty.json diff --git a/json-tests/json/rlp/stream/empty_lists.json b/util/json-tests/json/rlp/stream/empty_lists.json similarity index 100% rename from json-tests/json/rlp/stream/empty_lists.json rename to util/json-tests/json/rlp/stream/empty_lists.json diff --git a/json-tests/json/rlp/stream/integer.json b/util/json-tests/json/rlp/stream/integer.json similarity index 100% rename from json-tests/json/rlp/stream/integer.json rename to util/json-tests/json/rlp/stream/integer.json diff --git a/json-tests/json/rlp/stream/list_of_empty_data.json b/util/json-tests/json/rlp/stream/list_of_empty_data.json similarity index 100% rename from json-tests/json/rlp/stream/list_of_empty_data.json rename to util/json-tests/json/rlp/stream/list_of_empty_data.json diff --git a/json-tests/json/rlp/stream/list_of_empty_data2.json b/util/json-tests/json/rlp/stream/list_of_empty_data2.json similarity index 100% rename from json-tests/json/rlp/stream/list_of_empty_data2.json rename to util/json-tests/json/rlp/stream/list_of_empty_data2.json diff --git a/json-tests/json/rlp/stream/longlist.json b/util/json-tests/json/rlp/stream/longlist.json similarity index 100% rename from json-tests/json/rlp/stream/longlist.json rename to util/json-tests/json/rlp/stream/longlist.json diff --git a/json-tests/json/rlp/stream/longstring.json b/util/json-tests/json/rlp/stream/longstring.json similarity index 100% rename from json-tests/json/rlp/stream/longstring.json rename to util/json-tests/json/rlp/stream/longstring.json diff --git a/json-tests/json/trie/README.md b/util/json-tests/json/trie/README.md similarity index 100% rename from json-tests/json/trie/README.md rename to util/json-tests/json/trie/README.md diff --git a/json-tests/json/trie/basic.json b/util/json-tests/json/trie/basic.json similarity index 100% rename from json-tests/json/trie/basic.json rename to util/json-tests/json/trie/basic.json diff --git a/json-tests/json/trie/branching.json b/util/json-tests/json/trie/branching.json similarity index 100% rename from json-tests/json/trie/branching.json rename to util/json-tests/json/trie/branching.json diff --git a/json-tests/json/trie/dogs.json b/util/json-tests/json/trie/dogs.json similarity index 100% rename from json-tests/json/trie/dogs.json rename to util/json-tests/json/trie/dogs.json diff --git a/json-tests/json/trie/empty.json b/util/json-tests/json/trie/empty.json similarity index 100% rename from json-tests/json/trie/empty.json rename to util/json-tests/json/trie/empty.json diff --git a/json-tests/json/trie/empty_values.json b/util/json-tests/json/trie/empty_values.json similarity index 100% rename from json-tests/json/trie/empty_values.json rename to util/json-tests/json/trie/empty_values.json diff --git a/json-tests/json/trie/foo.json b/util/json-tests/json/trie/foo.json similarity index 100% rename from json-tests/json/trie/foo.json rename to util/json-tests/json/trie/foo.json diff --git a/json-tests/json/trie/jeff.json b/util/json-tests/json/trie/jeff.json similarity index 100% rename from json-tests/json/trie/jeff.json rename to util/json-tests/json/trie/jeff.json diff --git a/json-tests/src/lib.rs b/util/json-tests/src/lib.rs similarity index 100% rename from json-tests/src/lib.rs rename to util/json-tests/src/lib.rs diff --git a/json-tests/src/rlp.rs b/util/json-tests/src/rlp.rs similarity index 100% rename from json-tests/src/rlp.rs rename to util/json-tests/src/rlp.rs diff --git a/json-tests/src/trie.rs b/util/json-tests/src/trie.rs similarity index 100% rename from json-tests/src/trie.rs rename to util/json-tests/src/trie.rs diff --git a/json-tests/src/util.rs b/util/json-tests/src/util.rs similarity index 100% rename from json-tests/src/util.rs rename to util/json-tests/src/util.rs diff --git a/rustfmt.toml b/util/rustfmt.toml similarity index 100% rename from rustfmt.toml rename to util/rustfmt.toml diff --git a/src/bytes.rs b/util/src/bytes.rs similarity index 100% rename from src/bytes.rs rename to util/src/bytes.rs diff --git a/src/chainfilter.rs b/util/src/chainfilter.rs similarity index 100% rename from src/chainfilter.rs rename to util/src/chainfilter.rs diff --git a/util/src/common.rs b/util/src/common.rs new file mode 100644 index 000000000..3ec02ad9b --- /dev/null +++ b/util/src/common.rs @@ -0,0 +1,57 @@ +pub use standard::*; +pub use from_json::*; +pub use error::*; +pub use hash::*; +pub use uint::*; +pub use bytes::*; +pub use vector::*; +pub use sha3::*; + +#[macro_export] +macro_rules! map { + ( $( $x:expr => $y:expr ),* ) => { + vec![ $( ($x, $y) ),* ].into_iter().collect::>() + } +} + +#[macro_export] +macro_rules! mapx { + ( $( $x:expr => $y:expr ),* ) => { + vec![ $( ( From::from($x), From::from($y) ) ),* ].into_iter().collect::>() + } +} + +#[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); +} diff --git a/src/crypto.rs b/util/src/crypto.rs similarity index 100% rename from src/crypto.rs rename to util/src/crypto.rs diff --git a/util/src/error.rs b/util/src/error.rs new file mode 100644 index 000000000..04f7b96ce --- /dev/null +++ b/util/src/error.rs @@ -0,0 +1,88 @@ +//! General error types for use in ethcore. + +use rustc_serialize::hex::FromHexError; +use network::NetworkError; +use rlp::DecoderError; +use io; + +#[derive(Debug)] +pub enum BaseDataError { + NegativelyReferencedHash, +} + +#[derive(Debug)] +/// General error type which should be capable of representing all errors in ethcore. +pub enum UtilError { + Crypto(::crypto::CryptoError), + StdIo(::std::io::Error), + Io(io::IoError), + AddressParse(::std::net::AddrParseError), + AddressResolve(Option<::std::io::Error>), + FromHex(FromHexError), + BaseData(BaseDataError), + Network(NetworkError), + Decoder(DecoderError), + BadSize, +} + +impl From for UtilError { + fn from(err: FromHexError) -> UtilError { + UtilError::FromHex(err) + } +} + +impl From for UtilError { + fn from(err: BaseDataError) -> UtilError { + UtilError::BaseData(err) + } +} + +impl From for UtilError { + fn from(err: NetworkError) -> UtilError { + UtilError::Network(err) + } +} + +impl From<::std::io::Error> for UtilError { + fn from(err: ::std::io::Error) -> UtilError { + UtilError::StdIo(err) + } +} + +impl From for UtilError { + fn from(err: io::IoError) -> UtilError { + UtilError::Io(err) + } +} + +impl From<::crypto::CryptoError> for UtilError { + fn from(err: ::crypto::CryptoError) -> UtilError { + UtilError::Crypto(err) + } +} + +impl From<::std::net::AddrParseError> for UtilError { + fn from(err: ::std::net::AddrParseError) -> UtilError { + UtilError::AddressParse(err) + } +} + +impl From<::rlp::DecoderError> for UtilError { + fn from(err: ::rlp::DecoderError) -> UtilError { + UtilError::Decoder(err) + } +} + +// TODO: uncomment below once https://github.com/rust-lang/rust/issues/27336 sorted. +/*#![feature(concat_idents)] +macro_rules! assimilate { + ($name:ident) => ( + impl From for Error { + fn from(err: concat_idents!($name, Error)) -> Error { + Error:: $name (err) + } + } + ) +} +assimilate!(FromHex); +assimilate!(BaseData);*/ diff --git a/src/from_json.rs b/util/src/from_json.rs similarity index 100% rename from src/from_json.rs rename to util/src/from_json.rs diff --git a/src/hash.rs b/util/src/hash.rs similarity index 100% rename from src/hash.rs rename to util/src/hash.rs diff --git a/src/hashdb.rs b/util/src/hashdb.rs similarity index 100% rename from src/hashdb.rs rename to util/src/hashdb.rs diff --git a/src/heapsizeof.rs b/util/src/heapsizeof.rs similarity index 100% rename from src/heapsizeof.rs rename to util/src/heapsizeof.rs diff --git a/src/io/mod.rs b/util/src/io/mod.rs similarity index 100% rename from src/io/mod.rs rename to util/src/io/mod.rs diff --git a/src/io/service.rs b/util/src/io/service.rs similarity index 100% rename from src/io/service.rs rename to util/src/io/service.rs diff --git a/src/json_aid.rs b/util/src/json_aid.rs similarity index 100% rename from src/json_aid.rs rename to util/src/json_aid.rs diff --git a/util/src/lib.rs b/util/src/lib.rs new file mode 100644 index 000000000..4bc47e61c --- /dev/null +++ b/util/src/lib.rs @@ -0,0 +1,101 @@ +#![feature(op_assign_traits)] +#![feature(augmented_assignments)] +#![feature(associated_consts)] +#![feature(wrapping)] +//! Ethcore-util library +//! +//! ### Rust version: +//! - beta +//! - nightly +//! +//! ### Supported platforms: +//! - OSX +//! - Linux +//! +//! ### Dependencies: +//! - RocksDB 3.13 +//! +//! ### Dependencies Installation: +//! +//! - OSX: +//! +//! ```bash +//! brew install rocksdb +//! ``` +//! +//! - From source: +//! +//! ```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 +//! ``` + +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] +extern crate log; +#[macro_use] +extern crate lazy_static; +#[macro_use] +extern crate itertools; +extern crate env_logger; +extern crate time; +extern crate crypto as rcrypto; +extern crate secp256k1; +extern crate arrayvec; +extern crate elastic_array; + +pub mod standard; +#[macro_use] +pub mod from_json; +#[macro_use] +pub mod common; +pub mod error; +pub mod hash; +pub mod uint; +pub mod bytes; +pub mod rlp; +pub mod misc; +pub mod json_aid; +pub mod vector; +pub mod sha3; +pub mod hashdb; +pub mod memorydb; +pub mod overlaydb; +pub mod math; +pub mod chainfilter; +pub mod crypto; +pub mod triehash; +pub mod trie; +pub mod nibbleslice; +pub mod heapsizeof; +pub mod squeeze; +pub mod semantic_version; +pub mod io; +pub mod network; + +pub use common::*; +pub use misc::*; +pub use json_aid::*; +pub use rlp::*; +pub use hashdb::*; +pub use memorydb::*; +pub use overlaydb::*; +pub use math::*; +pub use chainfilter::*; +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::*; diff --git a/src/math.rs b/util/src/math.rs similarity index 100% rename from src/math.rs rename to util/src/math.rs diff --git a/src/memorydb.rs b/util/src/memorydb.rs similarity index 100% rename from src/memorydb.rs rename to util/src/memorydb.rs diff --git a/src/misc.rs b/util/src/misc.rs similarity index 100% rename from src/misc.rs rename to util/src/misc.rs diff --git a/src/network/connection.rs b/util/src/network/connection.rs similarity index 100% rename from src/network/connection.rs rename to util/src/network/connection.rs diff --git a/src/network/discovery.rs b/util/src/network/discovery.rs similarity index 100% rename from src/network/discovery.rs rename to util/src/network/discovery.rs diff --git a/src/network/error.rs b/util/src/network/error.rs similarity index 100% rename from src/network/error.rs rename to util/src/network/error.rs diff --git a/src/network/handshake.rs b/util/src/network/handshake.rs similarity index 100% rename from src/network/handshake.rs rename to util/src/network/handshake.rs diff --git a/src/network/host.rs b/util/src/network/host.rs similarity index 100% rename from src/network/host.rs rename to util/src/network/host.rs diff --git a/src/network/mod.rs b/util/src/network/mod.rs similarity index 100% rename from src/network/mod.rs rename to util/src/network/mod.rs diff --git a/src/network/node.rs b/util/src/network/node.rs similarity index 100% rename from src/network/node.rs rename to util/src/network/node.rs diff --git a/src/network/service.rs b/util/src/network/service.rs similarity index 100% rename from src/network/service.rs rename to util/src/network/service.rs diff --git a/src/network/session.rs b/util/src/network/session.rs similarity index 100% rename from src/network/session.rs rename to util/src/network/session.rs diff --git a/src/nibbleslice.rs b/util/src/nibbleslice.rs similarity index 100% rename from src/nibbleslice.rs rename to util/src/nibbleslice.rs diff --git a/src/overlaydb.rs b/util/src/overlaydb.rs similarity index 100% rename from src/overlaydb.rs rename to util/src/overlaydb.rs diff --git a/src/rlp/mod.rs b/util/src/rlp/mod.rs similarity index 100% rename from src/rlp/mod.rs rename to util/src/rlp/mod.rs diff --git a/src/rlp/rlperrors.rs b/util/src/rlp/rlperrors.rs similarity index 100% rename from src/rlp/rlperrors.rs rename to util/src/rlp/rlperrors.rs diff --git a/src/rlp/rlpin.rs b/util/src/rlp/rlpin.rs similarity index 100% rename from src/rlp/rlpin.rs rename to util/src/rlp/rlpin.rs diff --git a/src/rlp/rlpstream.rs b/util/src/rlp/rlpstream.rs similarity index 100% rename from src/rlp/rlpstream.rs rename to util/src/rlp/rlpstream.rs diff --git a/src/rlp/rlptraits.rs b/util/src/rlp/rlptraits.rs similarity index 100% rename from src/rlp/rlptraits.rs rename to util/src/rlp/rlptraits.rs diff --git a/src/rlp/tests.rs b/util/src/rlp/tests.rs similarity index 100% rename from src/rlp/tests.rs rename to util/src/rlp/tests.rs diff --git a/src/rlp/untrusted_rlp.rs b/util/src/rlp/untrusted_rlp.rs similarity index 100% rename from src/rlp/untrusted_rlp.rs rename to util/src/rlp/untrusted_rlp.rs diff --git a/src/semantic_version.rs b/util/src/semantic_version.rs similarity index 100% rename from src/semantic_version.rs rename to util/src/semantic_version.rs diff --git a/src/sha3.rs b/util/src/sha3.rs similarity index 100% rename from src/sha3.rs rename to util/src/sha3.rs diff --git a/src/squeeze.rs b/util/src/squeeze.rs similarity index 100% rename from src/squeeze.rs rename to util/src/squeeze.rs diff --git a/src/standard.rs b/util/src/standard.rs similarity index 100% rename from src/standard.rs rename to util/src/standard.rs diff --git a/src/tinykeccak.c b/util/src/tinykeccak.c similarity index 100% rename from src/tinykeccak.c rename to util/src/tinykeccak.c diff --git a/src/trie/journal.rs b/util/src/trie/journal.rs similarity index 100% rename from src/trie/journal.rs rename to util/src/trie/journal.rs diff --git a/src/trie/mod.rs b/util/src/trie/mod.rs similarity index 100% rename from src/trie/mod.rs rename to util/src/trie/mod.rs diff --git a/src/trie/node.rs b/util/src/trie/node.rs similarity index 100% rename from src/trie/node.rs rename to util/src/trie/node.rs diff --git a/src/trie/sectriedb.rs b/util/src/trie/sectriedb.rs similarity index 100% rename from src/trie/sectriedb.rs rename to util/src/trie/sectriedb.rs diff --git a/src/trie/sectriedbmut.rs b/util/src/trie/sectriedbmut.rs similarity index 100% rename from src/trie/sectriedbmut.rs rename to util/src/trie/sectriedbmut.rs diff --git a/src/trie/standardmap.rs b/util/src/trie/standardmap.rs similarity index 100% rename from src/trie/standardmap.rs rename to util/src/trie/standardmap.rs diff --git a/src/trie/triedb.rs b/util/src/trie/triedb.rs similarity index 100% rename from src/trie/triedb.rs rename to util/src/trie/triedb.rs diff --git a/src/trie/triedbmut.rs b/util/src/trie/triedbmut.rs similarity index 100% rename from src/trie/triedbmut.rs rename to util/src/trie/triedbmut.rs diff --git a/src/trie/trietraits.rs b/util/src/trie/trietraits.rs similarity index 100% rename from src/trie/trietraits.rs rename to util/src/trie/trietraits.rs diff --git a/src/triehash.rs b/util/src/triehash.rs similarity index 100% rename from src/triehash.rs rename to util/src/triehash.rs diff --git a/src/uint.rs b/util/src/uint.rs similarity index 100% rename from src/uint.rs rename to util/src/uint.rs diff --git a/src/vector.rs b/util/src/vector.rs similarity index 100% rename from src/vector.rs rename to util/src/vector.rs