From d7c28d0bb114efc362760c31c635ddcb60a3d50e Mon Sep 17 00:00:00 2001 From: debris Date: Fri, 17 Nov 2017 11:28:51 +0100 Subject: [PATCH 1/3] parity-version module split from util removed unused util deps and features trigger buildbot again only kvdb links rocksdb snappy linker issues --- Cargo.lock | 36 ++++++++++------------- Cargo.toml | 4 +-- dapps/Cargo.toml | 3 +- dapps/src/handlers/content.rs | 2 +- dapps/src/lib.rs | 1 + ethcore/src/state/account.rs | 9 ++++++ parity/cli/usage.rs | 2 +- parity/configuration.rs | 3 +- parity/main.rs | 1 + parity/params.rs | 3 +- parity/run.rs | 2 +- rpc/Cargo.toml | 3 +- rpc/src/lib.rs | 1 + rpc/src/v1/impls/light/parity.rs | 2 +- rpc/src/v1/impls/parity.rs | 2 +- rpc/src/v1/impls/web3.rs | 2 +- rpc/src/v1/tests/mocked/parity.rs | 4 +-- sync/Cargo.toml | 2 +- updater/Cargo.toml | 1 + updater/src/lib.rs | 1 + updater/src/types/version_info.rs | 2 +- updater/src/updater.rs | 4 +-- util/Cargo.toml | 37 ++++-------------------- util/network/Cargo.toml | 2 +- util/network/src/host.rs | 2 +- util/network/src/lib.rs | 2 +- util/snappy/src/lib.rs | 1 + util/src/lib.rs | 24 --------------- util/version/Cargo.toml | 14 +++++++++ util/{ => version}/build.rs | 2 +- util/{src/misc.rs => version/src/lib.rs} | 15 ++++------ 31 files changed, 81 insertions(+), 108 deletions(-) create mode 100644 util/version/Cargo.toml rename util/{ => version}/build.rs (97%) rename util/{src/misc.rs => version/src/lib.rs} (93%) diff --git a/Cargo.lock b/Cargo.lock index 89cf7413d42..ae2013e0cc6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -643,7 +643,6 @@ dependencies = [ "ethcore-devtools 1.9.0", "ethcore-io 1.9.0", "ethcore-logger 1.9.0", - "ethcore-util 1.9.0", "ethcrypto 0.1.0", "ethkey 0.2.0", "igd 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -652,6 +651,7 @@ dependencies = [ "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-version 0.1.0", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "path 0.1.0", "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -722,33 +722,14 @@ dependencies = [ name = "ethcore-util" version = "1.9.0" dependencies = [ - "clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "eth-secp256k1 0.5.7 (git+https://github.com/paritytech/rust-secp256k1)", "ethcore-bigint 0.2.1", "ethcore-bytes 0.1.0", - "ethcore-logger 1.9.0", "hashdb 0.1.1", - "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "journaldb 0.1.0", "keccak-hash 0.1.0", - "kvdb 0.1.0", - "kvdb-memorydb 0.1.0", - "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "memorydb 0.1.1", - "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.1.0", - "rlp 0.2.1", - "rocksdb 0.4.5 (git+https://github.com/paritytech/rust-rocksdb)", - "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tiny-keccak 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "triehash 0.1.0", - "util-error 0.1.0", - "vergen 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1947,6 +1928,7 @@ dependencies = [ "parity-rpc 1.9.0", "parity-rpc-client 1.4.0", "parity-updater 1.9.0", + "parity-version 0.1.0", "parity-whisper 0.1.0", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "path 0.1.0", @@ -1993,6 +1975,7 @@ dependencies = [ "parity-hash-fetch 1.9.0", "parity-reactor 0.1.0", "parity-ui 1.9.0", + "parity-version 0.1.0", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2142,6 +2125,7 @@ dependencies = [ "order-stat 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-reactor 0.1.0", "parity-updater 1.9.0", + "parity-version 0.1.0", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2249,12 +2233,24 @@ dependencies = [ "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-hash-fetch 1.9.0", "parity-reactor 0.1.0", + "parity-version 0.1.0", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "path 0.1.0", "semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parity-version" +version = "0.1.0" +dependencies = [ + "ethcore-bytes 0.1.0", + "rlp 0.2.1", + "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "vergen 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "parity-wasm" version = "0.15.3" diff --git a/Cargo.toml b/Cargo.toml index 36d8255fc6e..c0f53bffcff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,6 +55,7 @@ parity-reactor = { path = "util/reactor" } parity-rpc = { path = "rpc" } parity-rpc-client = { path = "rpc_client" } parity-updater = { path = "updater" } +parity-version = { path = "util/version" } parity-whisper = { path = "whisper" } path = { path = "util/path" } panic_hook = { path = "panic_hook" } @@ -94,13 +95,12 @@ ui-precompiled = [ ui-enabled = ["dapps"] dapps = ["parity-dapps"] jit = ["ethcore/jit"] -dev = ["clippy", "ethcore/dev", "ethcore-util/dev", "ethsync/dev", "parity-rpc/dev", "parity-dapps/dev"] +dev = ["clippy", "ethcore/dev", "ethsync/dev", "parity-rpc/dev", "parity-dapps/dev"] json-tests = ["ethcore/json-tests"] test-heavy = ["ethcore/test-heavy"] evm-debug = ["ethcore/evm-debug"] evm-debug-tests = ["ethcore/evm-debug-tests"] slow-blocks = ["ethcore/slow-blocks"] -final = ["ethcore-util/final"] secretstore = ["ethcore-secretstore"] [[bin]] diff --git a/dapps/Cargo.toml b/dapps/Cargo.toml index f3e02826dbc..37818749387 100644 --- a/dapps/Cargo.toml +++ b/dapps/Cargo.toml @@ -37,6 +37,7 @@ parity-hash-fetch = { path = "../hash-fetch" } parity-reactor = { path = "../util/reactor" } parity-ui = { path = "./ui" } keccak-hash = { path = "../util/hash" } +parity-version = { path = "../util/version" } clippy = { version = "0.0.103", optional = true} @@ -45,7 +46,7 @@ env_logger = "0.4" ethcore-devtools = { path = "../devtools" } [features] -dev = ["clippy", "ethcore-util/dev"] +dev = ["clippy"] ui = ["parity-ui/no-precompiled-js"] ui-precompiled = ["parity-ui/use-precompiled-js"] diff --git a/dapps/src/handlers/content.rs b/dapps/src/handlers/content.rs index 13d1fb0b9aa..711a985bde5 100644 --- a/dapps/src/handlers/content.rs +++ b/dapps/src/handlers/content.rs @@ -19,7 +19,7 @@ use hyper::{self, mime, header}; use hyper::StatusCode; -use util::version; +use parity_version::version; use handlers::add_security_headers; use Embeddable; diff --git a/dapps/src/lib.rs b/dapps/src/lib.rs index 85087242b3c..b80fa4c2cdb 100644 --- a/dapps/src/lib.rs +++ b/dapps/src/lib.rs @@ -43,6 +43,7 @@ extern crate parity_dapps_glue as parity_dapps; extern crate parity_hash_fetch as hash_fetch; extern crate parity_ui; extern crate keccak_hash as hash; +extern crate parity_version; #[macro_use] extern crate futures; diff --git a/ethcore/src/state/account.rs b/ethcore/src/state/account.rs index 2d9a37e817f..f4b6f0b4b9f 100644 --- a/ethcore/src/state/account.rs +++ b/ethcore/src/state/account.rs @@ -35,6 +35,15 @@ use std::cell::{RefCell, Cell}; const STORAGE_CACHE_ITEMS: usize = 8192; +/// Boolean type for clean/dirty status. +#[derive(PartialEq, Eq, Clone, Copy, Debug)] +pub enum Filth { + /// Data has not been changed. + Clean, + /// Data has been changed. + Dirty, +} + /// Single account in the system. /// Keeps track of changes to the code and storage. /// The changes are applied in `commit_storage` and `commit_code` diff --git a/parity/cli/usage.rs b/parity/cli/usage.rs index 71ac01295a7..388afd1c1cb 100644 --- a/parity/cli/usage.rs +++ b/parity/cli/usage.rs @@ -152,7 +152,7 @@ macro_rules! usage { use toml; use std::{fs, io, process}; use std::io::{Read, Write}; - use util::version; + use parity_version::version; use clap::{Arg, App, SubCommand, AppSettings, ArgMatches as ClapArgMatches, Error as ClapError, ErrorKind as ClapErrorKind}; use helpers::replace_home; use std::ffi::OsStr; diff --git a/parity/configuration.rs b/parity/configuration.rs index 7cb3a84bda1..cc08402b1ce 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -25,7 +25,8 @@ use cli::{Args, ArgsError}; use hash::keccak; use bigint::prelude::U256; use bigint::hash::H256; -use util::{version_data, Address}; +use util::Address; +use parity_version::version_data; use bytes::Bytes; use ansi_term::Colour; use ethsync::{NetworkConfiguration, validate_node_url, self}; diff --git a/parity/main.rs b/parity/main.rs index eae471dce08..620e3b36c41 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -71,6 +71,7 @@ extern crate parity_local_store as local_store; extern crate parity_reactor; extern crate parity_rpc; extern crate parity_updater as updater; +extern crate parity_version; extern crate parity_whisper; extern crate path; extern crate rpc_cli; diff --git a/parity/params.rs b/parity/params.rs index 32353e1685e..ca9fb1e653f 100644 --- a/parity/params.rs +++ b/parity/params.rs @@ -17,7 +17,8 @@ use std::{str, fs, fmt}; use std::time::Duration; use bigint::prelude::U256; -use util::{Address, version_data}; +use util::Address; +use parity_version::version_data; use journaldb::Algorithm; use ethcore::spec::{Spec, SpecParams}; use ethcore::ethereum; diff --git a/parity/run.rs b/parity/run.rs index 13c3575d915..d676b2f102a 100644 --- a/parity/run.rs +++ b/parity/run.rs @@ -39,7 +39,7 @@ use parity_reactor::EventLoop; use parity_rpc::{NetworkSettings, informant, is_major_importing}; use updater::{UpdatePolicy, Updater}; use ansi_term::Colour; -use util::version; +use parity_version::version; use parking_lot::{Condvar, Mutex}; use node_filter::NodeFilter; use journaldb::Algorithm; diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 9ed55bc63b7..d7dcd4890cd 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -54,6 +54,7 @@ fetch = { path = "../util/fetch" } node-health = { path = "../dapps/node-health" } parity-reactor = { path = "../util/reactor" } parity-updater = { path = "../updater" } +parity-version = { path = "../util/version" } rlp = { path = "../util/rlp" } stats = { path = "../util/stats" } vm = { path = "../ethcore/vm" } @@ -69,4 +70,4 @@ ethcore-network = { path = "../util/network" } kvdb-memorydb = { path = "../util/kvdb-memorydb" } [features] -dev = ["clippy", "ethcore/dev", "ethcore-util/dev", "ethsync/dev"] +dev = ["clippy", "ethcore/dev", "ethsync/dev"] diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 2e689feb8e7..83589c24249 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -64,6 +64,7 @@ extern crate fetch; extern crate node_health; extern crate parity_reactor; extern crate parity_updater as updater; +extern crate parity_version as version; extern crate rlp; extern crate stats; extern crate keccak_hash as hash; diff --git a/rpc/src/v1/impls/light/parity.rs b/rpc/src/v1/impls/light/parity.rs index 6987f808284..1be734df444 100644 --- a/rpc/src/v1/impls/light/parity.rs +++ b/rpc/src/v1/impls/light/parity.rs @@ -18,7 +18,7 @@ use std::sync::Arc; use std::collections::{BTreeMap, HashSet}; -use util::misc::version_data; +use version::version_data; use crypto::{ecies, DEFAULT_MAC}; use ethkey::{Brain, Generator}; diff --git a/rpc/src/v1/impls/parity.rs b/rpc/src/v1/impls/parity.rs index b1065932247..4cb02f9cb3f 100644 --- a/rpc/src/v1/impls/parity.rs +++ b/rpc/src/v1/impls/parity.rs @@ -20,7 +20,7 @@ use std::str::FromStr; use std::collections::{BTreeMap, HashSet}; use util::Address; -use util::misc::version_data; +use version::version_data; use crypto::{DEFAULT_MAC, ecies}; use ethkey::{Brain, Generator}; diff --git a/rpc/src/v1/impls/web3.rs b/rpc/src/v1/impls/web3.rs index 44055507ff8..6915af1d1e0 100644 --- a/rpc/src/v1/impls/web3.rs +++ b/rpc/src/v1/impls/web3.rs @@ -17,7 +17,7 @@ //! Web3 rpc implementation. use hash::keccak; use jsonrpc_core::Result; -use util::version; +use version::version; use v1::traits::Web3; use v1::types::{H256, Bytes}; diff --git a/rpc/src/v1/tests/mocked/parity.rs b/rpc/src/v1/tests/mocked/parity.rs index 9153a17b3b6..e25f3e4d33c 100644 --- a/rpc/src/v1/tests/mocked/parity.rs +++ b/rpc/src/v1/tests/mocked/parity.rs @@ -234,14 +234,14 @@ fn rpc_parity_chain_id() { #[test] fn rpc_parity_default_extra_data() { - use util::misc; + use version::version_data; use bytes::ToPretty; let deps = Dependencies::new(); let io = deps.default_client(); let request = r#"{"jsonrpc": "2.0", "method": "parity_defaultExtraData", "params": [], "id": 1}"#; - let response = format!(r#"{{"jsonrpc":"2.0","result":"0x{}","id":1}}"#, misc::version_data().to_hex()); + let response = format!(r#"{{"jsonrpc":"2.0","result":"0x{}","id":1}}"#, version_data().to_hex()); assert_eq!(io.handle_request_sync(request), Some(response)); } diff --git a/sync/Cargo.toml b/sync/Cargo.toml index c2095c03200..3d5286324a2 100644 --- a/sync/Cargo.toml +++ b/sync/Cargo.toml @@ -37,4 +37,4 @@ kvdb-memorydb = { path = "../util/kvdb-memorydb" } [features] default = [] -dev = ["clippy", "ethcore/dev", "ethcore-util/dev"] +dev = ["clippy", "ethcore/dev"] diff --git a/updater/Cargo.toml b/updater/Cargo.toml index a67559f6890..ec1b99296ad 100644 --- a/updater/Cargo.toml +++ b/updater/Cargo.toml @@ -19,4 +19,5 @@ futures = "0.1" parking_lot = "0.4" parity-hash-fetch = { path = "../hash-fetch" } parity-reactor = { path = "../util/reactor" } +parity-version = { path = "../util/version" } path = { path = "../util/path" } diff --git a/updater/src/lib.rs b/updater/src/lib.rs index c0da3b6a162..73ebc7ec4a0 100644 --- a/updater/src/lib.rs +++ b/updater/src/lib.rs @@ -28,6 +28,7 @@ extern crate ethsync; extern crate futures; extern crate target_info; extern crate parity_reactor; +extern crate parity_version as version; extern crate path; extern crate semver; diff --git a/updater/src/types/version_info.rs b/updater/src/types/version_info.rs index 778e57087b8..ea9b4457770 100644 --- a/updater/src/types/version_info.rs +++ b/updater/src/types/version_info.rs @@ -19,7 +19,7 @@ use std::fmt; use semver::{Version}; use bigint::hash::H160; -use util::misc::raw_package_info; +use version::raw_package_info; use types::ReleaseTrack; /// Version information of a particular release. diff --git a/updater/src/updater.rs b/updater/src/updater.rs index 91c9181f849..72ddaa7fe88 100644 --- a/updater/src/updater.rs +++ b/updater/src/updater.rs @@ -34,7 +34,7 @@ use bigint::hash::{H160, H256}; use util::Address; use bytes::Bytes; use parking_lot::Mutex; -use util::misc; +use version; /// Filter for releases. #[derive(Debug, Eq, PartialEq, Clone)] @@ -115,7 +115,7 @@ fn platform() -> String { } else if cfg!(target_os = "linux") { format!("{}-unknown-linux-gnu", Target::arch()) } else { - misc::platform() + version::platform() } } diff --git a/util/Cargo.toml b/util/Cargo.toml index 65d1c88b424..e60b3c8ebc8 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -5,42 +5,15 @@ license = "GPL-3.0" name = "ethcore-util" version = "1.9.0" authors = ["Parity Technologies "] -build = "build.rs" [dependencies] -log = "0.3" -env_logger = "0.4" -rustc-hex = "1.0" -rocksdb = { git = "https://github.com/paritytech/rust-rocksdb" } -eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1" } -elastic-array = "0.9" -rlp = { path = "rlp" } -heapsize = "0.4" -keccak-hash = { path = "hash" } -clippy = { version = "0.0.103", optional = true} -libc = "0.2.7" -target_info = "0.1" ethcore-bigint = { path = "bigint", features = ["heapsizeof"] } -parking_lot = "0.4" -tiny-keccak= "1.0" -ethcore-logger = { path = "../logger" } -triehash = { path = "triehash" } hashdb = { path = "hashdb" } -patricia-trie = { path = "patricia_trie" } -ethcore-bytes = { path = "bytes" } memorydb = { path = "memorydb" } -util-error = { path = "error" } -kvdb = { path = "kvdb" } -journaldb = { path = "journaldb" } [dev-dependencies] -kvdb-memorydb = { path = "kvdb-memorydb" } - -[features] -default = [] -dev = ["clippy"] -final = [] - -[build-dependencies] -vergen = "0.1" -rustc_version = "0.1.0" +ethcore-bytes = { path = "bytes" } +keccak-hash = { path = "hash" } +log = "0.3" +patricia-trie = { path = "patricia_trie" } +triehash = { path = "triehash" } diff --git a/util/network/Cargo.toml b/util/network/Cargo.toml index b784df49c9d..13892528e57 100644 --- a/util/network/Cargo.toml +++ b/util/network/Cargo.toml @@ -22,7 +22,6 @@ parking_lot = "0.4" ansi_term = "0.9" rustc-hex = "1.0" ethcore-io = { path = "../io" } -ethcore-util = { path = ".." } ethcore-bigint = { path = "../bigint" } ethcore-bytes = { path = "../bytes" } ethkey = { path = "../../ethkey" } @@ -35,6 +34,7 @@ keccak-hash = { path = "../hash" } snappy = { path = "../snappy" } serde_json = "1.0" error-chain = { version = "0.11", default-features = false } +parity-version = { path = "../version" } [dev-dependencies] ethcore-devtools = { path = "../../devtools" } diff --git a/util/network/src/host.rs b/util/network/src/host.rs index ec22a8f63a2..c8ccd85e677 100644 --- a/util/network/src/host.rs +++ b/util/network/src/host.rs @@ -30,7 +30,7 @@ use mio::*; use mio::deprecated::{EventLoop}; use mio::tcp::*; use bigint::hash::*; -use util::version; +use parity_version::version; use rlp::*; use session::{Session, SessionInfo, SessionData}; use io::*; diff --git a/util/network/src/lib.rs b/util/network/src/lib.rs index 896aa7e0d89..cb361f0d079 100644 --- a/util/network/src/lib.rs +++ b/util/network/src/lib.rs @@ -59,7 +59,6 @@ #![recursion_limit="128"] extern crate ethcore_io as io; -extern crate ethcore_util as util; extern crate ethcore_bigint as bigint; extern crate ethcore_bytes; extern crate parking_lot; @@ -83,6 +82,7 @@ extern crate ipnetwork; extern crate keccak_hash as hash; extern crate serde_json; extern crate snappy; +extern crate parity_version; #[macro_use] extern crate error_chain; diff --git a/util/snappy/src/lib.rs b/util/snappy/src/lib.rs index 230c336b505..99b11df1386 100644 --- a/util/snappy/src/lib.rs +++ b/util/snappy/src/lib.rs @@ -162,3 +162,4 @@ pub fn validate_compressed_buffer(input: &[u8]) -> bool { let status = unsafe { snappy_validate_compressed_buffer(input.as_ptr() as *const c_char, input.len() as size_t )}; status == SNAPPY_OK } + diff --git a/util/src/lib.rs b/util/src/lib.rs index 321c85dd423..9dca2c21a4d 100644 --- a/util/src/lib.rs +++ b/util/src/lib.rs @@ -87,34 +87,10 @@ //! cargo build --release //! ``` -extern crate rustc_hex; -extern crate rocksdb; -extern crate env_logger; -extern crate secp256k1; -extern crate elastic_array; -extern crate libc; -extern crate target_info; extern crate ethcore_bigint as bigint; -extern crate ethcore_bytes as bytes; -extern crate parking_lot; -extern crate tiny_keccak; -extern crate rlp; -extern crate heapsize; -extern crate ethcore_logger; -extern crate keccak_hash as keccak; extern crate hashdb; extern crate memorydb; -extern crate patricia_trie as trie; -extern crate kvdb; -extern crate util_error as error; -#[cfg(test)] -extern crate kvdb_memorydb; - - -pub mod misc; - -pub use misc::*; pub use hashdb::*; pub use memorydb::MemoryDB; diff --git a/util/version/Cargo.toml b/util/version/Cargo.toml new file mode 100644 index 00000000000..22bf07fb175 --- /dev/null +++ b/util/version/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "parity-version" +version = "0.1.0" +authors = ["Parity Technologies "] +build = "build.rs" + +[dependencies] +ethcore-bytes = { path = "../bytes" } +rlp = { path = "../rlp" } +target_info = "0.1" + +[build-dependencies] +vergen = "0.1" +rustc_version = "0.1.0" diff --git a/util/build.rs b/util/version/build.rs similarity index 97% rename from util/build.rs rename to util/version/build.rs index 08ef8169785..b5d3dd81d42 100644 --- a/util/build.rs +++ b/util/version/build.rs @@ -17,11 +17,11 @@ extern crate vergen; extern crate rustc_version; -use vergen::*; use std::env; use std::fs::File; use std::io::Write; use std::path::Path; +use vergen::{vergen, OutputFns}; fn main() { vergen(OutputFns::all()).unwrap(); diff --git a/util/src/misc.rs b/util/version/src/lib.rs similarity index 93% rename from util/src/misc.rs rename to util/version/src/lib.rs index 6a1a1170865..236f1191420 100644 --- a/util/src/misc.rs +++ b/util/version/src/lib.rs @@ -16,9 +16,13 @@ //! Diff misc. -use rlp::RlpStream; +extern crate target_info; +extern crate ethcore_bytes as bytes; +extern crate rlp; + use target_info::Target; use bytes::Bytes; +use rlp::RlpStream; include!(concat!(env!("OUT_DIR"), "/version.rs")); include!(concat!(env!("OUT_DIR"), "/rustc_version.rs")); @@ -31,15 +35,6 @@ const THIS_TRACK: &'static str = "nightly"; const THIS_TRACK: &'static str = "unstable"; // ^^^ This gets used when we're not building a final release; should stay as "unstable". -/// Boolean type for clean/dirty status. -#[derive(PartialEq, Eq, Clone, Copy, Debug)] -pub enum Filth { - /// Data has not been changed. - Clean, - /// Data has been changed. - Dirty, -} - /// Get the platform identifier. pub fn platform() -> String { let env = Target::env(); From 356c61dc00f34243a6588a90a5d402d3feeffdb6 Mon Sep 17 00:00:00 2001 From: debris Date: Tue, 19 Dec 2017 09:31:07 -0400 Subject: [PATCH 2/3] rm snappy --- util/snappy/src/lib.rs | 165 ----------------------------------------- 1 file changed, 165 deletions(-) delete mode 100644 util/snappy/src/lib.rs diff --git a/util/snappy/src/lib.rs b/util/snappy/src/lib.rs deleted file mode 100644 index 99b11df1386..00000000000 --- a/util/snappy/src/lib.rs +++ /dev/null @@ -1,165 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -//! Snappy compression bindings. -extern crate libc; - -use std::fmt; -use libc::{c_char, c_int, size_t}; - -const SNAPPY_OK: c_int = 0; -const SNAPPY_INVALID_INPUT: c_int = 1; -const SNAPPY_BUFFER_TOO_SMALL: c_int = 2; - -#[link(name = "snappy", kind = "static")] -extern { - fn snappy_compress( - input: *const c_char, - input_len: size_t, - compressed: *mut c_char, - compressed_len: *mut size_t - ) -> c_int; - - fn snappy_max_compressed_length(source_len: size_t) -> size_t; - - fn snappy_uncompress( - compressed: *const c_char, - compressed_len: size_t, - uncompressed: *mut c_char, - uncompressed_len: *mut size_t, - ) -> c_int; - - fn snappy_uncompressed_length( - compressed: *const c_char, - compressed_len: size_t, - result: *mut size_t, - ) -> c_int; - - fn snappy_validate_compressed_buffer( - compressed: *const c_char, - compressed_len: size_t, - ) -> c_int; -} - -/// Attempted to decompress an uncompressed buffer. -#[derive(Debug)] -pub struct InvalidInput; - -impl std::error::Error for InvalidInput { - fn description(&self) -> &str { - "Attempted snappy decompression with invalid input" - } -} - -impl fmt::Display for InvalidInput { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "Attempted snappy decompression with invalid input") - } -} - -/// The maximum compressed length given a size. -pub fn max_compressed_len(len: usize) -> usize { - unsafe { snappy_max_compressed_length(len as size_t) as usize } -} - -/// How large the given data will be when decompressed. -pub fn decompressed_len(compressed: &[u8]) -> Result { - let mut size: size_t = 0; - let len = compressed.len() as size_t; - - let status = unsafe { snappy_uncompressed_length(compressed.as_ptr() as *const c_char, len, &mut size) }; - - if status == SNAPPY_INVALID_INPUT { - Err(InvalidInput) - } else { - Ok(size) - } -} - -/// Compress a buffer using snappy. -pub fn compress(input: &[u8]) -> Vec { - let mut buf = Vec::new(); - compress_into(input, &mut buf); - buf -} - -/// Compress a buffer using snappy, writing the result into -/// the given output buffer, growing it if necessary. -/// Otherwise, returns the length of the compressed data. -pub fn compress_into(input: &[u8], output: &mut Vec) -> usize { - let mut len = max_compressed_len(input.len()); - - if output.len() < len { - output.resize(len, 0); - } - - let status = unsafe { - snappy_compress( - input.as_ptr() as *const c_char, - input.len() as size_t, - output.as_mut_ptr() as *mut c_char, - &mut len as &mut size_t, - ) - }; - - match status { - SNAPPY_OK => len, - SNAPPY_INVALID_INPUT => panic!("snappy compression has no concept of invalid input"), - SNAPPY_BUFFER_TOO_SMALL => panic!("buffer cannot be too small, the capacity was just ensured."), - _ => panic!("snappy returned unspecified status"), - } -} - -/// Decompress a buffer using snappy. Will return an error if the buffer is not snappy-compressed. -pub fn decompress(input: &[u8]) -> Result, InvalidInput> { - let mut v = Vec::new(); - decompress_into(input, &mut v).map(|_| v) -} - -/// Decompress a buffer using snappy, writing the result into -/// the given output buffer, growing it if necessary. -/// Will error if the input buffer is not snappy-compressed. -/// Otherwise, returns the length of the decompressed data. -pub fn decompress_into(input: &[u8], output: &mut Vec) -> Result { - let mut len = decompressed_len(input)?; - - if output.len() < len { - output.resize(len, 0); - } - - let status = unsafe { - snappy_uncompress( - input.as_ptr() as *const c_char, - input.len() as size_t, - output.as_mut_ptr() as *mut c_char, - &mut len as &mut size_t, - ) - }; - - match status { - SNAPPY_OK => Ok(len as usize), - SNAPPY_INVALID_INPUT => Err(InvalidInput), - SNAPPY_BUFFER_TOO_SMALL => panic!("buffer cannot be too small, size was just set to large enough."), - _ => panic!("snappy returned unspecified status"), - } -} - -/// Validate a compressed buffer. True if valid, false if not. -pub fn validate_compressed_buffer(input: &[u8]) -> bool { - let status = unsafe { snappy_validate_compressed_buffer(input.as_ptr() as *const c_char, input.len() as size_t )}; - status == SNAPPY_OK -} - From 47eb6719a94244a2a69bd449eed81d2f56b4fcb4 Mon Sep 17 00:00:00 2001 From: debris Date: Fri, 22 Dec 2017 12:01:30 +0100 Subject: [PATCH 3/3] fixed old version imports --- parity/configuration.rs | 2 +- parity/helpers.rs | 2 +- rpc/src/v1/tests/mocked/web3.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/parity/configuration.rs b/parity/configuration.rs index a8540ce84e4..715e63db56a 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -26,7 +26,7 @@ use hash::keccak; use bigint::prelude::U256; use bigint::hash::H256; use util::Address; -use parity_version::version_data; +use parity_version::{version_data, version}; use bytes::Bytes; use ansi_term::Colour; use ethsync::{NetworkConfiguration, validate_node_url, self}; diff --git a/parity/helpers.rs b/parity/helpers.rs index dc16445974f..05dcd66774b 100644 --- a/parity/helpers.rs +++ b/parity/helpers.rs @@ -213,7 +213,7 @@ pub fn default_network_config() -> ::ethsync::NetworkConfiguration { ip_filter: IpFilter::default(), reserved_nodes: Vec::new(), allow_non_reserved: true, - client_version: ::util::version(), + client_version: ::parity_version::version(), } } diff --git a/rpc/src/v1/tests/mocked/web3.rs b/rpc/src/v1/tests/mocked/web3.rs index 46a83bb3db8..aceb36e5651 100644 --- a/rpc/src/v1/tests/mocked/web3.rs +++ b/rpc/src/v1/tests/mocked/web3.rs @@ -15,7 +15,7 @@ // along with Parity. If not, see . use jsonrpc_core::IoHandler; -use util::version; +use version::version; use v1::{Web3, Web3Client}; #[test]