From fbf425c4e21639c76b53e9f489750da1d1ae0e55 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 23 Aug 2019 15:32:58 +0200 Subject: [PATCH] Extract spec to own crate (#10978) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add client-traits crate Move the BlockInfo trait to new crate * New crate `machine` Contains code extracted from ethcore that defines `Machine`, `Externalities` and other execution related code. * Use new machine and client-traits crates in ethcore * Use new crates machine and client-traits instead of ethcore where appropriate * Fix tests * Don't re-export so many types from ethcore::client * Fixing more fallout from removing re-export * fix test * More fallout from not re-exporting types * Add some docs * cleanup * import the macro edition style * Tweak docs * Add missing import * remove unused ethabi_derive imports * Use latest ethabi-contract * Move many traits from ethcore/client/traits to client-traits crate Initial version of extracted Engine trait * Move snapshot related traits to the engine crate (eew) * Move a few snapshot related types to common_types Cleanup Executed as exported from machine crate * fix warning * Gradually introduce new engine crate: snapshot * ethcore typechecks with new engine crate * Sort out types outside ethcore * Add an EpochVerifier to ethash and use that in Engine.epoch_verifier() Cleanup * Document pub members * Sort out tests Sort out default impls for EpochVerifier * Add test-helpers feature and move EngineSigner impl to the right place * Sort out tests * Sort out tests and refactor verification types * Fix missing traits * More missing traits Fix Histogram * Fix tests and cleanup * cleanup * Put back needed logger import * Don't rexport common_types from ethcore/src/client Don't export ethcore::client::* * Remove files no longer used Use types from the engine crate Explicit exports from engine::engine * Get rid of itertools * Move a few more traits from ethcore to client-traits: BlockChainReset, ScheduleInfo, StateClient * Move ProvingBlockChainClient to client-traits * Don't re-export ForkChoice and Transition from ethcore * Address grumbles: sort imports, remove commented out code * Fix merge resolution error * Extract the Clique engine to own crate * Extract NullEngine and the block_reward module from ethcore * Extract InstantSeal engine to own crate * Extract remaining engines * Extract executive_state to own crate so it can be used by engine crates * Remove snapshot stuff from the engine crate * Put snapshot traits back in ethcore * cleanup * Remove stuff from ethcore * Don't use itertools * itertools in aura is legit-ish * More post-merge fixes * Re-export less types in client * cleanup * Extract spec to own crate * Put back the test-helpers from basic-authority * Fix ethcore benchmarks * Reduce the public api of ethcore/verification * Update ethcore/block-reward/Cargo.toml Co-Authored-By: Tomasz Drwięga * Update ethcore/engines/basic-authority/Cargo.toml Co-Authored-By: Tomasz Drwięga * Update ethcore/engines/ethash/Cargo.toml Co-Authored-By: Tomasz Drwięga * Update ethcore/engines/clique/src/lib.rs Co-Authored-By: Tomasz Drwięga * signers is already a ref * Add an EngineType enum to tighten up Engine.name() * Introduce Snapshotting enum to distinguish the type of snapshots a chain uses * Rename supports_warp to snapshot_mode * Missing import * Update ethcore/src/snapshot/consensus/mod.rs Co-Authored-By: Tomasz Drwięga * missing import * Fix import * double semi --- Cargo.lock | 59 +++++++++++++- Cargo.toml | 78 +++++++++---------- ethash/Cargo.toml | 1 + ethash/benches/basic.rs | 4 +- ethash/benches/progpow.rs | 4 +- ethash/src/cache.rs | 14 +--- ethash/src/lib.rs | 10 ++- ethash/src/progpow.rs | 3 +- ethcore/Cargo.toml | 26 ++++--- ethcore/block-reward/Cargo.toml | 1 + ethcore/block-reward/src/lib.rs | 3 +- ethcore/engines/authority-round/Cargo.toml | 1 + ethcore/engines/authority-round/src/lib.rs | 4 +- ethcore/engines/basic-authority/Cargo.toml | 1 + ethcore/engines/basic-authority/src/lib.rs | 1 - ethcore/engines/clique/Cargo.toml | 1 + ethcore/engines/clique/src/lib.rs | 2 - ethcore/engines/ethash/Cargo.toml | 1 + ethcore/engines/ethash/src/lib.rs | 5 +- ethcore/engines/instant-seal/Cargo.toml | 1 + ethcore/engines/instant-seal/src/lib.rs | 2 +- ethcore/engines/validator-set/Cargo.toml | 13 ++-- ethcore/engines/validator-set/src/contract.rs | 8 +- ethcore/engines/validator-set/src/multi.rs | 7 +- .../validator-set/src/safe_contract.rs | 4 +- ethcore/executive-state/Cargo.toml | 1 + ethcore/executive-state/src/lib.rs | 2 +- ethcore/light/Cargo.toml | 1 + ethcore/light/src/client/header_chain.rs | 4 +- ethcore/light/src/client/mod.rs | 6 +- ethcore/light/src/client/service.rs | 4 +- ethcore/light/src/lib.rs | 1 + ethcore/machine/Cargo.toml | 1 + ethcore/machine/src/machine.rs | 2 +- ethcore/machine/src/tx_filter.rs | 2 +- ethcore/node-filter/Cargo.toml | 1 + ethcore/node-filter/src/lib.rs | 4 +- ethcore/private-tx/Cargo.toml | 1 + ethcore/private-tx/tests/private_contract.rs | 2 +- ethcore/service/Cargo.toml | 1 + ethcore/service/src/lib.rs | 1 + ethcore/service/src/service.rs | 4 +- ethcore/spec/Cargo.toml | 41 ++++++++++ ethcore/{src/spec => spec/src}/chain.rs | 6 +- ethcore/{src/spec => spec/src}/genesis.rs | 4 +- ethcore/{src/spec/mod.rs => spec/src/lib.rs} | 2 +- ethcore/{src/spec => spec/src}/seal.rs | 0 ethcore/{src/spec => spec/src}/spec.rs | 74 +++++++++--------- ethcore/src/block.rs | 2 +- ethcore/src/client/test_client.rs | 2 +- ethcore/src/json_tests/executive.rs | 2 +- ethcore/src/lib.rs | 26 +++---- ethcore/src/miner/miner.rs | 2 +- ethcore/src/snapshot/service.rs | 2 +- ethcore/src/snapshot/tests/proof_of_work.rs | 2 +- ethcore/src/snapshot/tests/service.rs | 2 +- ethcore/src/tests/client.rs | 2 +- ethcore/src/tests/trace.rs | 2 +- ethcore/src/verification/mod.rs | 18 +++-- ethcore/src/verification/queue/mod.rs | 9 ++- ethcore/src/verification/verification.rs | 2 +- ethcore/sync/Cargo.toml | 1 + ethcore/sync/src/block_sync.rs | 2 +- ethcore/sync/src/lib.rs | 1 + ethcore/sync/src/light_sync/tests/test_net.rs | 2 +- ethcore/sync/src/tests/chain.rs | 2 +- ethcore/sync/src/tests/consensus.rs | 2 +- ethcore/sync/src/tests/helpers.rs | 2 +- ethcore/sync/src/tests/private.rs | 2 +- ethcore/types/src/engines/mod.rs | 15 ++++ evmbin/Cargo.toml | 1 + evmbin/src/info.rs | 6 +- evmbin/src/main.rs | 3 +- parity/export_hardcoded_sync.rs | 4 +- parity/lib.rs | 1 + parity/params.rs | 2 +- parity/run.rs | 3 +- rpc/Cargo.toml | 1 + rpc/src/lib.rs | 1 + rpc/src/v1/tests/eth.rs | 2 +- 80 files changed, 341 insertions(+), 204 deletions(-) create mode 100644 ethcore/spec/Cargo.toml rename ethcore/{src/spec => spec/src}/chain.rs (97%) rename ethcore/{src/spec => spec/src}/genesis.rs (97%) rename ethcore/{src/spec/mod.rs => spec/src/lib.rs} (92%) rename ethcore/{src/spec => spec/src}/seal.rs (100%) rename ethcore/{src/spec => spec/src}/spec.rs (96%) diff --git a/Cargo.lock b/Cargo.lock index 6feca9605..d4867ad33 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -187,6 +187,7 @@ dependencies = [ "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "spec 0.1.0", "state-db 0.1.0", "time-utils 0.1.0", "unexpected 0.1.0", @@ -258,6 +259,7 @@ dependencies = [ "machine 0.1.0", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "spec 0.1.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "validator-set 0.1.0", ] @@ -362,6 +364,7 @@ dependencies = [ "ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "machine 0.1.0", + "spec 0.1.0", "trace 0.1.0", ] @@ -521,6 +524,7 @@ dependencies = [ "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "spec 0.1.0", "state-db 0.1.0", "time-utils 0.1.0", "unexpected 0.1.0", @@ -955,6 +959,7 @@ dependencies = [ name = "ethash" version = "1.12.0" dependencies = [ + "common-types 0.1.0", "criterion 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -986,6 +991,7 @@ dependencies = [ "machine 0.1.0", "macros 0.1.0", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "spec 0.1.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "unexpected 0.1.0", ] @@ -1009,11 +1015,9 @@ dependencies = [ "account-db 0.1.0", "account-state 0.1.0", "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "authority-round 0.1.0", "basic-authority 0.1.0", "blooms-db 0.1.0", "client-traits 0.1.0", - "clique 0.1.0", "common-types 0.1.0", "criterion 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1023,7 +1027,6 @@ dependencies = [ "ethabi-contract 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "ethabi-derive 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethash 1.12.0", - "ethash-engine 0.1.0", "ethcore-accounts 0.1.0", "ethcore-blockchain 0.1.0", "ethcore-bloom-journal 0.1.0", @@ -1041,7 +1044,6 @@ dependencies = [ "fetch 0.1.0", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "instant-seal 0.1.0", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.2.0", "keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1074,6 +1076,7 @@ dependencies = [ "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "spec 0.1.0", "state-db 0.1.0", "stats 0.1.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1237,6 +1240,7 @@ dependencies = [ "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "spec 0.1.0", "stats 0.1.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1390,6 +1394,7 @@ dependencies = [ "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "spec 0.1.0", "state-db 0.1.0", "time-utils 0.1.0", "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1457,6 +1462,7 @@ dependencies = [ "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-rocksdb 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "spec 0.1.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "trace-time 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1512,6 +1518,7 @@ dependencies = [ "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "spec 0.1.0", "trace-time 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "triehash-ethereum 0.2.0", ] @@ -1653,6 +1660,7 @@ dependencies = [ "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "spec 0.1.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "trace 0.1.0", "vm 0.1.0", @@ -1680,6 +1688,7 @@ dependencies = [ "patricia-trie-ethereum 0.1.0", "pod 0.1.0", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "spec 0.1.0", "trace 0.1.0", "trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "trie-vm-factories 0.1.0", @@ -2102,6 +2111,7 @@ dependencies = [ "keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "machine 0.1.0", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "spec 0.1.0", "trace 0.1.0", ] @@ -2519,6 +2529,7 @@ dependencies = [ "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "spec 0.1.0", "state-db 0.1.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "trace 0.1.0", @@ -2750,6 +2761,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "spec 0.1.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3004,6 +3016,7 @@ dependencies = [ "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "spec 0.1.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3150,6 +3163,7 @@ dependencies = [ "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "spec 0.1.0", "stats 0.1.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4153,6 +4167,42 @@ dependencies = [ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "spec" +version = "0.1.0" +dependencies = [ + "account-state 0.1.0", + "authority-round 0.1.0", + "basic-authority 0.1.0", + "clique 0.1.0", + "common-types 0.1.0", + "engine 0.1.0", + "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", + "ethash 1.12.0", + "ethash-engine 0.1.0", + "ethcore 1.12.0", + "ethcore-builtin 0.1.0", + "ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethjson 0.1.0", + "evm 0.1.0", + "executive-state 0.1.0", + "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "instant-seal 0.1.0", + "journaldb 0.2.0", + "keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "machine 0.1.0", + "null-engine 0.1.0", + "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pod 0.1.0", + "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "trace 0.1.0", + "trie-vm-factories 0.1.0", + "vm 0.1.0", +] + [[package]] name = "spin" version = "0.5.0" @@ -4863,6 +4913,7 @@ dependencies = [ "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "spec 0.1.0", "triehash-ethereum 0.2.0", "unexpected 0.1.0", "vm 0.1.0", diff --git a/Cargo.toml b/Cargo.toml index c8841db28..d8eb21797 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,32 +7,16 @@ license = "GPL-3.0" authors = ["Parity Technologies "] [dependencies] -blooms-db = { path = "util/blooms-db" } -log = "0.4" -rustc-hex = "1.0" -docopt = "1.0" -clap = "2" -term_size = "0.3" -textwrap = "0.9" -num_cpus = "1.2" -number_prefix = "0.2" -rpassword = "1.0" -semver = "0.9" ansi_term = "0.11" -parking_lot = "0.8" -regex = "1.0" atty = "0.2.8" -toml = "0.4" -serde = "1.0" -serde_json = "1.0" -serde_derive = "1.0" -futures = "0.1" -fdlimit = "0.1" -ctrlc = { git = "https://github.com/paritytech/rust-ctrlc.git" } -jsonrpc-core = "12.0.0" -parity-bytes = "0.1" +blooms-db = { path = "util/blooms-db" } +clap = "2" +cli-signer= { path = "cli-signer" } client-traits = { path = "ethcore/client-traits" } common-types = { path = "ethcore/types" } +ctrlc = { git = "https://github.com/paritytech/rust-ctrlc.git" } +dir = { path = "util/dir" } +docopt = "1.0" engine = { path = "ethcore/engine" } ethcore = { path = "ethcore", features = ["parity"] } ethcore-accounts = { path = "accounts", optional = true } @@ -45,36 +29,50 @@ ethcore-logger = { path = "parity/logger" } ethcore-miner = { path = "miner" } ethcore-network = { path = "util/network" } ethcore-private-tx = { path = "ethcore/private-tx" } +ethcore-secretstore = { path = "secret-store", optional = true } ethcore-service = { path = "ethcore/service" } ethcore-sync = { path = "ethcore/sync" } ethereum-types = "0.6.0" ethkey = { path = "accounts/ethkey" } ethstore = { path = "accounts/ethstore" } +fdlimit = "0.1" +futures = "0.1" +journaldb = { path = "util/journaldb" } +jsonrpc-core = "12.0.0" +keccak-hash = "0.2.0" +kvdb = "0.1" +kvdb-rocksdb = "0.1.3" +log = "0.4" +migration-rocksdb = { path = "util/migration-rocksdb" } node-filter = { path = "ethcore/node-filter" } -rlp = "0.4.0" -cli-signer= { path = "cli-signer" } +num_cpus = "1.2" +number_prefix = "0.2" +panic_hook = { path = "util/panic-hook" } +parity-bytes = "0.1" parity-daemonize = "0.3" parity-hash-fetch = { path = "updater/hash-fetch" } parity-ipfs-api = { path = "ipfs" } parity-local-store = { path = "miner/local-store" } -parity-runtime = { path = "util/runtime" } -parity-rpc = { path = "rpc" } -parity-updater = { path = "updater" } -parity-version = { path = "util/version" } parity-path = "0.1" -dir = { path = "util/dir" } -panic_hook = { path = "util/panic-hook" } -keccak-hash = "0.2.0" -migration-rocksdb = { path = "util/migration-rocksdb" } -kvdb = "0.1" -kvdb-rocksdb = "0.1.3" -journaldb = { path = "util/journaldb" } - -ethcore-secretstore = { path = "secret-store", optional = true } - -registrar = { path = "util/registrar" } - +parity-rpc = { path = "rpc" } +parity-runtime = { path = "util/runtime" } +parity-updater = { path = "updater" } parity-util-mem = { version = "0.2.0", features = ["jemalloc-global"] } +parity-version = { path = "util/version" } +parking_lot = "0.8" +regex = "1.0" +registrar = { path = "util/registrar" } +rlp = "0.4.0" +rpassword = "1.0" +rustc-hex = "1.0" +semver = "0.9" +serde = "1.0" +serde_derive = "1.0" +serde_json = "1.0" +spec = { path = "ethcore/spec" } +term_size = "0.3" +textwrap = "0.9" +toml = "0.4" [build-dependencies] rustc_version = "0.2" diff --git a/ethash/Cargo.toml b/ethash/Cargo.toml index 7bd234300..59db4cd73 100644 --- a/ethash/Cargo.toml +++ b/ethash/Cargo.toml @@ -5,6 +5,7 @@ version = "1.12.0" authors = ["Parity Technologies "] [dependencies] +common-types = { path = "../ethcore/types" } crunchy = "0.1.0" either = "1.0.0" ethereum-types = "0.6.0" diff --git a/ethash/benches/basic.rs b/ethash/benches/basic.rs index 64c31cb21..f1b8fcbaa 100644 --- a/ethash/benches/basic.rs +++ b/ethash/benches/basic.rs @@ -17,9 +17,11 @@ #[macro_use] extern crate criterion; extern crate ethash; +extern crate common_types; use criterion::Criterion; -use ethash::{NodeCacheBuilder, OptimizeFor}; +use ethash::NodeCacheBuilder; +use common_types::engines::OptimizeFor; const HASH: [u8; 32] = [ 0xf5, 0x7e, 0x6f, 0x3a, 0xcf, 0xc0, 0xdd, 0x4b, diff --git a/ethash/benches/progpow.rs b/ethash/benches/progpow.rs index e086a14b4..fdf8415f1 100644 --- a/ethash/benches/progpow.rs +++ b/ethash/benches/progpow.rs @@ -3,14 +3,16 @@ extern crate criterion; extern crate ethash; extern crate rustc_hex; extern crate tempdir; +extern crate common_types; use criterion::Criterion; use ethash::progpow; use tempdir::TempDir; use rustc_hex::FromHex; -use ethash::{NodeCacheBuilder, OptimizeFor}; +use ethash::NodeCacheBuilder; use ethash::compute::light_compute; +use common_types::engines::OptimizeFor; fn bench_hashimoto_light(c: &mut Criterion) { let builder = NodeCacheBuilder::new(OptimizeFor::Memory, u64::max_value()); diff --git a/ethash/src/cache.rs b/ethash/src/cache.rs index b16d27314..e3dc6a515 100644 --- a/ethash/src/cache.rs +++ b/ethash/src/cache.rs @@ -30,20 +30,10 @@ use std::path::{Path, PathBuf}; use std::slice; use std::sync::Arc; +use common_types::engines::OptimizeFor; + type Cache = Either, MmapMut>; -#[derive(PartialEq, Eq, Debug, Clone, Copy)] -pub enum OptimizeFor { - Cpu, - Memory, -} - -impl Default for OptimizeFor { - fn default() -> Self { - OptimizeFor::Cpu - } -} - fn byte_size(cache: &Cache) -> usize { use self::Either::{Left, Right}; diff --git a/ethash/src/lib.rs b/ethash/src/lib.rs index 3225ceb9f..e181087cc 100644 --- a/ethash/src/lib.rs +++ b/ethash/src/lib.rs @@ -14,6 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Ethereum. If not, see . +extern crate common_types; extern crate either; extern crate ethereum_types; extern crate memmap; @@ -51,14 +52,17 @@ pub mod progpow; #[cfg(not(feature = "bench"))] mod progpow; -pub use cache::{NodeCacheBuilder, OptimizeFor}; +pub use cache::NodeCacheBuilder; pub use compute::{ProofOfWork, quick_get_difficulty, slow_hash_block_number}; +pub use seed_compute::SeedHashCompute; +pub use shared::ETHASH_EPOCH_LENGTH; + +use common_types::engines::OptimizeFor; use compute::Light; use ethereum_types::{BigEndianHash, U256, U512}; use keccak::H256; use parking_lot::Mutex; -pub use seed_compute::SeedHashCompute; -pub use shared::ETHASH_EPOCH_LENGTH; + use std::mem; use std::path::{Path, PathBuf}; use std::convert::TryFrom; diff --git a/ethash/src/progpow.rs b/ethash/src/progpow.rs index 7c7fb531a..0ade1c541 100644 --- a/ethash/src/progpow.rs +++ b/ethash/src/progpow.rs @@ -419,7 +419,8 @@ pub fn generate_cdag(cache: &[Node]) -> CDag { mod test { use tempdir::TempDir; - use cache::{NodeCacheBuilder, OptimizeFor}; + use common_types::engines::OptimizeFor; + use cache::NodeCacheBuilder; use keccak::H256; use rustc_hex::FromHex; use serde_json::{self, Value}; diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index eafeb8bea..d87133a50 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -9,12 +9,10 @@ authors = ["Parity Technologies "] [dependencies] account-db = { path = "account-db" } account-state = { path = "account-state" } -authority-round = { path = "./engines/authority-round" } ansi_term = "0.11" -basic-authority = { path = "./engines/basic-authority" } +basic-authority = { path = "./engines/basic-authority", optional = true} # used by test-helpers feature blooms-db = { path = "../util/blooms-db", optional = true } client-traits = { path = "./client-traits" } -clique = { path = "./engines/clique" } common-types = { path = "types" } crossbeam-utils = "0.6" engine = { path = "./engine" } @@ -22,25 +20,22 @@ env_logger = { version = "0.5", optional = true } ethabi = "8.0" ethabi-contract = "8.0" ethabi-derive = "8.0" -ethash = { path = "../ethash" } -ethash-engine = { path = "./engines/ethash" } +ethash = { path = "../ethash", optional = true } +ethjson = { path = "../json", optional = true } +ethkey = { path = "../accounts/ethkey", optional = true } ethcore-blockchain = { path = "./blockchain" } ethcore-bloom-journal = { path = "../util/bloom" } -ethcore-builtin = { path = "./builtin" } ethcore-call-contract = { path = "./call-contract" } ethcore-db = { path = "./db" } ethcore-io = { path = "../util/io" } ethcore-miner = { path = "../miner" } ethcore-stratum = { path = "../miner/stratum", optional = true } ethereum-types = "0.6.0" -ethjson = { path = "../json" } -ethkey = { path = "../accounts/ethkey" } evm = { path = "evm" } executive-state = { path = "executive-state" } futures = "0.1" hash-db = "0.15.0" parity-util-mem = "0.2.0" -instant-seal = { path = "./engines/instant-seal" } itertools = "0.5" journaldb = { path = "../util/journaldb" } keccak-hash = "0.2.0" @@ -54,14 +49,13 @@ log = "0.4" macros = { path = "../util/macros", optional = true } machine = { path = "./machine" } memory-cache = { path = "../util/memory-cache" } -null-engine = { path = "./engines/null-engine" } num_cpus = "1.2" parity-bytes = "0.1" parity-snappy = "0.1" parking_lot = "0.8" +pod = { path = "pod", optional = true } trie-db = "0.15.0" patricia-trie-ethereum = { path = "../util/patricia-trie-ethereum" } -pod = { path = "pod" } rand = "0.6" rand_xorshift = "0.1.1" rayon = "1.1" @@ -70,6 +64,7 @@ rlp_derive = { path = "../util/rlp-derive" } rustc-hex = "1.0" serde = "1.0" serde_derive = "1.0" +spec = { path = "spec" } state-db = { path = "state-db" } stats = { path = "../util/stats" } tempdir = { version = "0.3", optional = true } @@ -84,15 +79,21 @@ vm = { path = "vm" } [dev-dependencies] blooms-db = { path = "../util/blooms-db" } +ethcore-builtin = { path = "./builtin" } criterion = "0.2" engine = { path = "./engine", features = ["test-helpers"] } env_logger = "0.5" +ethash = { path = "../ethash" } ethcore-accounts = { path = "../accounts" } +ethjson = { path = "../json" } +ethkey = { path = "../accounts/ethkey" } fetch = { path = "../util/fetch" } kvdb-rocksdb = "0.1.3" machine = { path = "./machine", features = ["test-helpers"] } macros = { path = "../util/macros" } +null-engine = { path = "./engines/null-engine" } parity-runtime = { path = "../util/runtime" } +pod = { path = "pod" } rlp_compress = { path = "../util/rlp-compress" } serde_json = "1.0" tempdir = "0.3" @@ -126,7 +127,8 @@ ci-skip-tests = [] # Run memory/cpu heavy tests. test-heavy = [] # Compile test helpers -test-helpers = ["tempdir", "kvdb-rocksdb", "blooms-db", "macros", "basic-authority/test-helpers"] +# note[dvdplm]: "basic-authority/test-helpers" is needed so that `generate_dummy_client_with_spec` works +test-helpers = ["tempdir", "kvdb-rocksdb", "blooms-db", "ethash", "ethjson", "ethkey", "macros", "pod", "basic-authority/test-helpers"] [[bench]] name = "builtin" diff --git a/ethcore/block-reward/Cargo.toml b/ethcore/block-reward/Cargo.toml index 5c2022a9a..699c88535 100644 --- a/ethcore/block-reward/Cargo.toml +++ b/ethcore/block-reward/Cargo.toml @@ -19,3 +19,4 @@ trace = { path = "../trace" } [dev-dependencies] ethcore = { path = "..", features = ["test-helpers"] } +spec = { path = "../spec" } diff --git a/ethcore/block-reward/src/lib.rs b/ethcore/block-reward/src/lib.rs index 268e7931a..859a3f35a 100644 --- a/ethcore/block-reward/src/lib.rs +++ b/ethcore/block-reward/src/lib.rs @@ -164,11 +164,12 @@ mod test { use std::str::FromStr; use ethcore::{ client::PrepareOpenBlock, - spec, test_helpers::generate_dummy_client_with_spec, }; use ethereum_types::{U256, Address}; use engine::SystemOrCodeCallKind; + use spec; + use crate::{BlockRewardContract, RewardKind}; #[test] diff --git a/ethcore/engines/authority-round/Cargo.toml b/ethcore/engines/authority-round/Cargo.toml index e3b0f8b4a..bd4879ac6 100644 --- a/ethcore/engines/authority-round/Cargo.toml +++ b/ethcore/engines/authority-round/Cargo.toml @@ -34,6 +34,7 @@ accounts = { package = "ethcore-accounts", path = "../../../accounts" } engine = { path = "../../engine", features = ["test-helpers"] } env_logger = "0.6.2" ethcore = { path = "../..", features = ["test-helpers"] } +spec = { path = "../../spec" } state-db = { path = "../../state-db" } validator-set = { path = "../validator-set", features = ["test-helpers"] } serde_json = "1" diff --git a/ethcore/engines/authority-round/src/lib.rs b/ethcore/engines/authority-round/src/lib.rs index 8a41979f7..98aa8c22a 100644 --- a/ethcore/engines/authority-round/src/lib.rs +++ b/ethcore/engines/authority-round/src/lib.rs @@ -1683,12 +1683,12 @@ mod tests { generate_dummy_client_with_spec, get_temp_state_db, TestNotify }, - spec::{self, Spec}, }; use engine::Engine; use block_reward::BlockRewardContract; - use validator_set::{TestSet, SimpleList}; use machine::Machine; + use spec::{self, Spec}; + use validator_set::{TestSet, SimpleList}; use ethjson; use serde_json; diff --git a/ethcore/engines/basic-authority/Cargo.toml b/ethcore/engines/basic-authority/Cargo.toml index 2a5938c7e..92f2c79a8 100644 --- a/ethcore/engines/basic-authority/Cargo.toml +++ b/ethcore/engines/basic-authority/Cargo.toml @@ -25,6 +25,7 @@ engine = { path = "../../engine", features = ["test-helpers"] } ethcore = { path = "../..", features = ["test-helpers"] } keccak-hash = "0.2.0" tempdir = "0.3" +spec = { path = "../../spec" } [features] test-helpers = [] diff --git a/ethcore/engines/basic-authority/src/lib.rs b/ethcore/engines/basic-authority/src/lib.rs index d17b01580..b18283fb2 100644 --- a/ethcore/engines/basic-authority/src/lib.rs +++ b/ethcore/engines/basic-authority/src/lib.rs @@ -222,7 +222,6 @@ mod tests { use ethereum_types::H520; use ethcore::{ block::*, - spec, test_helpers::get_temp_state_db }; use accounts::AccountProvider; diff --git a/ethcore/engines/clique/Cargo.toml b/ethcore/engines/clique/Cargo.toml index 516303102..7b9894053 100644 --- a/ethcore/engines/clique/Cargo.toml +++ b/ethcore/engines/clique/Cargo.toml @@ -27,4 +27,5 @@ unexpected = { path = "../../../util/unexpected" } [dev-dependencies] ethcore = { path = "../..", features = ["test-helpers"] } +spec = { path = "../../spec" } state-db = { path = "../../state-db" } diff --git a/ethcore/engines/clique/src/lib.rs b/ethcore/engines/clique/src/lib.rs index 15b9bdea3..05cb5d262 100644 --- a/ethcore/engines/clique/src/lib.rs +++ b/ethcore/engines/clique/src/lib.rs @@ -240,8 +240,6 @@ impl Clique { /// Note we need to `mock` the miner and it is introduced to test block verification to trigger new blocks /// to mainly test consensus edge cases pub fn with_test(epoch_length: u64, period: u64) -> Self { - use ethcore::spec; - Self { epoch_length, period, diff --git a/ethcore/engines/ethash/Cargo.toml b/ethcore/engines/ethash/Cargo.toml index 648b3a15d..85129230c 100644 --- a/ethcore/engines/ethash/Cargo.toml +++ b/ethcore/engines/ethash/Cargo.toml @@ -23,4 +23,5 @@ unexpected = { path = "../../../util/unexpected" } ethcore = { path = "../..", features = ["test-helpers"] } keccak-hash = "0.2.0" rlp = "0.4.2" +spec = { path = "../../spec" } tempdir = "0.3" diff --git a/ethcore/engines/ethash/src/lib.rs b/ethcore/engines/ethash/src/lib.rs index 498978f2a..bd901ef88 100644 --- a/ethcore/engines/ethash/src/lib.rs +++ b/ethcore/engines/ethash/src/lib.rs @@ -25,6 +25,7 @@ use common_types::{ header::Header, engines::{ EthashSeal, + OptimizeFor, params::CommonParams, }, errors::{BlockError, EthcoreError as Error}, @@ -33,7 +34,7 @@ use common_types::{ use engine::Engine; use ethereum_types::{H256, U256}; use ethjson; -use ethash::{self, quick_get_difficulty, slow_hash_block_number, EthashManager, OptimizeFor}; +use ethash::{self, quick_get_difficulty, slow_hash_block_number, EthashManager}; use keccak_hash::{KECCAK_EMPTY_LIST_RLP}; use log::trace; use macros::map; @@ -493,9 +494,9 @@ mod tests { use ethcore::{ block::*, test_helpers::get_temp_state_db, - spec::{new_morden, new_mcip3_test, new_homestead_test_machine, Spec}, }; use rlp; + use spec::{new_morden, new_mcip3_test, new_homestead_test_machine, Spec}; use tempdir::TempDir; use super::{Ethash, EthashParams, ecip1017_eras_block_reward}; diff --git a/ethcore/engines/instant-seal/Cargo.toml b/ethcore/engines/instant-seal/Cargo.toml index c456ce906..42a74e999 100644 --- a/ethcore/engines/instant-seal/Cargo.toml +++ b/ethcore/engines/instant-seal/Cargo.toml @@ -17,4 +17,5 @@ trace = { path = "../../trace" } [dev-dependencies] ethcore = { path = "../..", features = ["test-helpers"] } +spec = { path = "../../spec" } rlp = "0.4.2" diff --git a/ethcore/engines/instant-seal/src/lib.rs b/ethcore/engines/instant-seal/src/lib.rs index 99d859d58..a103401a7 100644 --- a/ethcore/engines/instant-seal/src/lib.rs +++ b/ethcore/engines/instant-seal/src/lib.rs @@ -114,9 +114,9 @@ mod tests { use ethereum_types::{H520, Address}; use ethcore::{ test_helpers::get_temp_state_db, - spec, block::*, }; + use spec; #[test] fn instant_can_seal() { diff --git a/ethcore/engines/validator-set/Cargo.toml b/ethcore/engines/validator-set/Cargo.toml index aeeb2f081..c92ae13d6 100644 --- a/ethcore/engines/validator-set/Cargo.toml +++ b/ethcore/engines/validator-set/Cargo.toml @@ -11,8 +11,8 @@ client-traits = { path = "../../client-traits" } common-types = { path = "../../types" } engine = { path = "../../engine" } ethabi = "8.0.1" -ethabi-derive = "8.0.0" ethabi-contract = "8.0.1" +ethabi-derive = "8.0.0" ethereum-types = "0.6.0" ethjson = { path = "../../../json" } executive-state = { path = "../../executive-state" } @@ -32,13 +32,14 @@ vm = { path = "../../vm" } [dev-dependencies] accounts = { package = "ethcore-accounts", path = "../../../accounts" } -engine = { path = "../../engine", features = ["test-helpers"] } -ethcore = { path = "../..", features = ["test-helpers"] } -keccak-hash = "0.2.0" -ethkey = { path = "../../../accounts/ethkey" } -rustc-hex = "1.0" call-contract = { package = "ethcore-call-contract", path = "../../call-contract" } +engine = { path = "../../engine", features = ["test-helpers"] } env_logger = "0.6.2" +ethcore = { path = "../..", features = ["test-helpers"] } +ethkey = { path = "../../../accounts/ethkey" } +keccak-hash = "0.2.0" +rustc-hex = "1.0" +spec = { path = "../../spec" } [features] test-helpers = [] diff --git a/ethcore/engines/validator-set/src/contract.rs b/ethcore/engines/validator-set/src/contract.rs index 07b70f4a3..e05e6c452 100644 --- a/ethcore/engines/validator-set/src/contract.rs +++ b/ethcore/engines/validator-set/src/contract.rs @@ -146,10 +146,12 @@ impl ValidatorSet for ValidatorContract { mod tests { use std::sync::Arc; + use accounts::AccountProvider; + use call_contract::CallContract; use common_types::{header::Header, ids::BlockId}; + use client_traits::{BlockChainClient, ChainInfo, BlockInfo}; use ethcore::{ miner::{self, MinerService}, - spec, test_helpers::generate_dummy_client_with_spec, }; use ethereum_types::{H520, Address}; @@ -157,9 +159,7 @@ mod tests { use parity_bytes::ToPretty; use rlp::encode; use rustc_hex::FromHex; - use accounts::AccountProvider; - use call_contract::CallContract; - use client_traits::{BlockChainClient, ChainInfo, BlockInfo}; + use spec; use super::super::ValidatorSet; use super::ValidatorContract; diff --git a/ethcore/engines/validator-set/src/multi.rs b/ethcore/engines/validator-set/src/multi.rs index a9fa6e8dc..72b653041 100644 --- a/ethcore/engines/validator-set/src/multi.rs +++ b/ethcore/engines/validator-set/src/multi.rs @@ -156,22 +156,21 @@ mod tests { use std::collections::BTreeMap; use accounts::AccountProvider; - use client_traits::{BlockChainClient, BlockInfo, ChainInfo, ImportBlock, EngineClient}; use common_types::{ header::Header, ids::BlockId, verification::Unverified, }; + use client_traits::{BlockChainClient, BlockInfo, ChainInfo, ImportBlock, EngineClient}; use engine::EpochChange; - - use ethkey::Secret; use ethcore::{ miner::{self, MinerService}, test_helpers::{generate_dummy_client_with_spec, generate_dummy_client_with_spec_and_data}, - spec, }; use ethereum_types::Address; + use ethkey::Secret; use keccak_hash::keccak; + use spec; use crate::ValidatorSet; use super::Multi; diff --git a/ethcore/engines/validator-set/src/safe_contract.rs b/ethcore/engines/validator-set/src/safe_contract.rs index 8ae43a03d..d023802f0 100644 --- a/ethcore/engines/validator-set/src/safe_contract.rs +++ b/ethcore/engines/validator-set/src/safe_contract.rs @@ -251,7 +251,7 @@ impl ValidatorSafeContract { LogEntry { address: self.contract_address, - topics: topics, + topics, data: Vec::new(), // irrelevant for bloom. }.bloom() } @@ -467,7 +467,6 @@ mod tests { use client_traits::{BlockInfo, ChainInfo, ImportBlock, EngineClient}; use engine::{EpochChange, Proof}; use ethcore::{ - spec, miner::{self, MinerService}, test_helpers::{generate_dummy_client_with_spec, generate_dummy_client_with_spec_and_data} }; @@ -475,6 +474,7 @@ mod tests { use ethereum_types::Address; use keccak_hash::keccak; use rustc_hex::FromHex; + use spec; use super::super::ValidatorSet; use super::{ValidatorSafeContract, EVENT_NAME_HASH}; diff --git a/ethcore/executive-state/Cargo.toml b/ethcore/executive-state/Cargo.toml index a962a1e39..4ced7f90c 100644 --- a/ethcore/executive-state/Cargo.toml +++ b/ethcore/executive-state/Cargo.toml @@ -29,5 +29,6 @@ evm = { path = "../evm" } keccak-hash = "0.2.0" pod = { path = "../pod" } rustc-hex = "1.0" +spec = { path = "../spec" } trie-db = "0.15.0" ethtrie = { package = "patricia-trie-ethereum", path = "../../util/patricia-trie-ethereum" } diff --git a/ethcore/executive-state/src/lib.rs b/ethcore/executive-state/src/lib.rs index 2be7b0d6f..29b4cd783 100644 --- a/ethcore/executive-state/src/lib.rs +++ b/ethcore/executive-state/src/lib.rs @@ -273,7 +273,6 @@ mod tests { use ethkey::Secret; use ethereum_types::{H256, U256, Address, BigEndianHash}; use ethcore::{ - spec, test_helpers::{get_temp_state, get_temp_state_db} }; use ethtrie; @@ -281,6 +280,7 @@ mod tests { use machine::Machine; use pod::{self, PodAccount, PodState}; use rustc_hex::FromHex; + use spec; use ::trace::{FlatTrace, TraceError, trace}; use trie_db::{TrieFactory, TrieSpec}; use vm::EnvInfo; diff --git a/ethcore/light/Cargo.toml b/ethcore/light/Cargo.toml index 4e87e0fec..abc233744 100644 --- a/ethcore/light/Cargo.toml +++ b/ethcore/light/Cargo.toml @@ -39,6 +39,7 @@ itertools = "0.5" bincode = "1.1" serde = "1.0" serde_derive = "1.0" +spec = { path = "../spec" } parking_lot = "0.8" stats = { path = "../../util/stats" } keccak-hash = "0.2.0" diff --git a/ethcore/light/src/client/header_chain.rs b/ethcore/light/src/client/header_chain.rs index 92207139a..22b83c732 100644 --- a/ethcore/light/src/client/header_chain.rs +++ b/ethcore/light/src/client/header_chain.rs @@ -41,7 +41,7 @@ use common_types::{ header::Header, ids::BlockId, }; -use ethcore::spec::{Spec, SpecHardcodedSync}; +use spec::{Spec, SpecHardcodedSync}; use ethereum_types::{H256, H264, U256}; use parity_util_mem::{MallocSizeOf, MallocSizeOfOps}; use kvdb::{DBTransaction, KeyValueDB}; @@ -877,7 +877,7 @@ mod tests { use cache::Cache; use common_types::header::Header; use common_types::ids::BlockId; - use ethcore::spec; + use spec; use ethereum_types::U256; use kvdb::KeyValueDB; use kvdb_memorydb; diff --git a/ethcore/light/src/client/mod.rs b/ethcore/light/src/client/mod.rs index afc210997..98149ea2f 100644 --- a/ethcore/light/src/client/mod.rs +++ b/ethcore/light/src/client/mod.rs @@ -21,7 +21,7 @@ use std::sync::{Weak, Arc}; use engine::{Engine, EpochChange, Proof}; use ethcore::client::{ClientReport, ClientIoMessage}; use ethcore::verification::queue::{self, HeaderQueue}; -use ethcore::spec::{Spec, SpecHardcodedSync}; +use spec::{Spec, SpecHardcodedSync}; use io::IoChannel; use parking_lot::{Mutex, RwLock}; use ethereum_types::{H256, U256}; @@ -252,7 +252,7 @@ impl Client { } /// Get the header queue info. - pub fn queue_info(&self) -> queue::QueueInfo { + pub fn queue_info(&self) -> BlockQueueInfo { self.queue.queue_info() } @@ -546,7 +546,7 @@ impl LightChainClient for Client { fn chain_info(&self) -> BlockChainInfo { Client::chain_info(self) } - fn queue_info(&self) -> queue::QueueInfo { + fn queue_info(&self) -> BlockQueueInfo { self.queue.queue_info() } diff --git a/ethcore/light/src/client/service.rs b/ethcore/light/src/client/service.rs index ee002e02b..2a55322b4 100644 --- a/ethcore/light/src/client/service.rs +++ b/ethcore/light/src/client/service.rs @@ -24,7 +24,7 @@ use common_types::errors::EthcoreError as CoreError; use ethcore_db as db; use ethcore_blockchain::BlockChainDB; use ethcore::client::ClientIoMessage; -use ethcore::spec::Spec; +use spec::Spec; use io::{IoContext, IoError, IoHandler, IoService}; use cache::Cache; @@ -113,7 +113,7 @@ impl IoHandler for ImportBlocks { #[cfg(test)] mod tests { use super::Service; - use ethcore::spec; + use spec; use std::sync::Arc; use cache::Cache; diff --git a/ethcore/light/src/lib.rs b/ethcore/light/src/lib.rs index a51b213e7..3d2bd3752 100644 --- a/ethcore/light/src/lib.rs +++ b/ethcore/light/src/lib.rs @@ -85,6 +85,7 @@ extern crate parking_lot; #[macro_use] extern crate rlp_derive; extern crate serde; +extern crate spec; extern crate smallvec; extern crate stats; extern crate vm; diff --git a/ethcore/machine/Cargo.toml b/ethcore/machine/Cargo.toml index cd0cfd66b..e349b4d07 100644 --- a/ethcore/machine/Cargo.toml +++ b/ethcore/machine/Cargo.toml @@ -39,6 +39,7 @@ ethjson = { path = "../../json" } ethkey = { path = "../../accounts/ethkey" } macros = { path = "../../util/macros" } rustc-hex = "1.0" +spec = { path = "../spec" } tempdir = "0.3" trace = { path = "../trace" } diff --git a/ethcore/machine/src/machine.rs b/ethcore/machine/src/machine.rs index 2f096d3b8..5006ac26f 100644 --- a/ethcore/machine/src/machine.rs +++ b/ethcore/machine/src/machine.rs @@ -408,7 +408,7 @@ mod tests { use std::str::FromStr; use common_types::header::Header; use super::*; - use ethcore::spec; + use spec; fn get_default_ethash_extensions() -> EthashExtensions { EthashExtensions { diff --git a/ethcore/machine/src/tx_filter.rs b/ethcore/machine/src/tx_filter.rs index 76a5d571a..9d479fe24 100644 --- a/ethcore/machine/src/tx_filter.rs +++ b/ethcore/machine/src/tx_filter.rs @@ -160,12 +160,12 @@ mod test { }; use ethcore::{ client::{Client, ClientConfig}, - spec::Spec, miner::Miner, test_helpers, }; use ethkey::{Secret, KeyPair}; use ethcore_io::IoChannel; + use spec::Spec; use super::TransactionFilter; diff --git a/ethcore/node-filter/Cargo.toml b/ethcore/node-filter/Cargo.toml index 73a861252..45d8c4858 100644 --- a/ethcore/node-filter/Cargo.toml +++ b/ethcore/node-filter/Cargo.toml @@ -24,4 +24,5 @@ lru-cache = "0.1" ethcore = { path = "..", features = ["test-helpers"] } kvdb-memorydb = "0.1" ethcore-io = { path = "../../util/io" } +spec = { path = "../spec" } tempdir = "0.3" diff --git a/ethcore/node-filter/src/lib.rs b/ethcore/node-filter/src/lib.rs index 2c4313c37..f34b6571b 100644 --- a/ethcore/node-filter/src/lib.rs +++ b/ethcore/node-filter/src/lib.rs @@ -34,6 +34,8 @@ extern crate ethcore_io as io; extern crate kvdb_memorydb; #[cfg(test)] extern crate tempdir; +#[cfg(test)] +extern crate spec; #[macro_use] extern crate log; @@ -130,7 +132,7 @@ mod test { use std::sync::{Arc, Weak}; use client_traits::BlockChainClient; - use ethcore::spec::Spec; + use spec::Spec; use ethcore::client::{Client, ClientConfig}; use ethcore::miner::Miner; use ethcore::test_helpers; diff --git a/ethcore/private-tx/Cargo.toml b/ethcore/private-tx/Cargo.toml index 2c793b042..6dc912722 100644 --- a/ethcore/private-tx/Cargo.toml +++ b/ethcore/private-tx/Cargo.toml @@ -43,6 +43,7 @@ rustc-hex = "1.0" serde = "1.0" serde_derive = "1.0" serde_json = "1.0" +spec = { path = "../spec" } state-db = { path = "../state-db" } time-utils = { path = "../../util/time-utils" } tiny-keccak = "1.4" diff --git a/ethcore/private-tx/tests/private_contract.rs b/ethcore/private-tx/tests/private_contract.rs index 77a32c049..1f334912f 100644 --- a/ethcore/private-tx/tests/private_contract.rs +++ b/ethcore/private-tx/tests/private_contract.rs @@ -26,6 +26,7 @@ extern crate ethkey; extern crate keccak_hash as hash; extern crate rustc_hex; extern crate machine; +extern crate spec; #[macro_use] extern crate log; @@ -39,7 +40,6 @@ use ethcore::{ CreateContractAddress, test_helpers::{generate_dummy_client, push_block_with_transactions, new_db}, miner::Miner, - spec, }; use client_traits::BlockChainClient; use ethkey::{Secret, KeyPair, Signature}; diff --git a/ethcore/service/Cargo.toml b/ethcore/service/Cargo.toml index 7d68a7719..6ab4afecd 100644 --- a/ethcore/service/Cargo.toml +++ b/ethcore/service/Cargo.toml @@ -15,6 +15,7 @@ ethcore-sync = { path = "../sync" } ethereum-types = "0.6.0" kvdb = "0.1" log = "0.4" +spec = { path = "../spec" } trace-time = "0.1" [dev-dependencies] diff --git a/ethcore/service/src/lib.rs b/ethcore/service/src/lib.rs index fabb4a9b0..d49a3d30d 100644 --- a/ethcore/service/src/lib.rs +++ b/ethcore/service/src/lib.rs @@ -23,6 +23,7 @@ extern crate ethcore_private_tx; extern crate ethcore_sync as sync; extern crate ethereum_types; extern crate kvdb; +extern crate spec; #[macro_use] extern crate log; diff --git a/ethcore/service/src/service.rs b/ethcore/service/src/service.rs index 08cb88782..c1aebfe93 100644 --- a/ethcore/service/src/service.rs +++ b/ethcore/service/src/service.rs @@ -30,7 +30,7 @@ use ethcore::client::{Client, ClientConfig, ChainNotify, ClientIoMessage}; use ethcore::miner::Miner; use ethcore::snapshot::service::{Service as SnapshotService, ServiceParams as SnapServiceParams}; use ethcore::snapshot::{SnapshotService as _SnapshotService}; -use ethcore::spec::Spec; +use spec::Spec; use common_types::{ errors::{EthcoreError, SnapshotError}, snapshot::RestorationStatus, @@ -298,7 +298,7 @@ mod tests { use ethcore_db::NUM_COLUMNS; use ethcore::client::ClientConfig; use ethcore::miner::Miner; - use ethcore::spec; + use spec; use ethcore::test_helpers; use kvdb_rocksdb::{DatabaseConfig, CompactionProfile}; use super::*; diff --git a/ethcore/spec/Cargo.toml b/ethcore/spec/Cargo.toml new file mode 100644 index 000000000..03e16765b --- /dev/null +++ b/ethcore/spec/Cargo.toml @@ -0,0 +1,41 @@ +[package] +description = "Ethereum engine specification" +name = "spec" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2018" +license = "GPL-3.0" + +[dependencies] +account-state = { path = "../account-state" } +authority-round = { path = "../engines/authority-round" } +basic-authority = { path = "../engines/basic-authority" } +builtin = { package = "ethcore-builtin", path = "../builtin" } +bytes = { package = "parity-bytes", version = "0.1.0" } +clique = { path = "../engines/clique" } +common-types = { path = "../types" } +engine = { path = "../engine" } +ethash = { path = "../../ethash" } +ethash-engine = { path = "../engines/ethash" } +ethereum-types = "0.6.0" +ethjson = { path = "../../json" } +evm = { path = "../evm" } +executive-state = { path = "../executive-state" } +hash-db = "0.15.0" +instant-seal = { path = "../engines/instant-seal" } +journaldb = { path = "../../util/journaldb" } +keccak-hash = "0.2.0" +kvdb-memorydb = "0.1.0" +log = "0.4.8" +machine = { path = "../machine" } +null-engine = { path = "../engines/null-engine" } +pod = { path = "../pod" } +rlp = "0.4.2" +trace = { path = "../trace" } +trie-vm-factories = { path = "../trie-vm-factories" } +vm = { path = "../vm" } + +[dev-dependencies] +ethcore = { path = "..", features = ["test-helpers"] } +env_logger = "0.5" +tempdir = "0.3.7" diff --git a/ethcore/src/spec/chain.rs b/ethcore/spec/src/chain.rs similarity index 97% rename from ethcore/src/spec/chain.rs rename to ethcore/spec/src/chain.rs index 3774f892b..db4e20540 100644 --- a/ethcore/src/spec/chain.rs +++ b/ethcore/spec/src/chain.rs @@ -49,7 +49,7 @@ macro_rules! bundle_test_machine { ($($path: expr => $name: ident), *) => { $( /// Bundled test spec - pub fn $name() -> crate::machine::Machine { + pub fn $name() -> machine::Machine { crate::spec::Spec::load_machine( include_bytes!(concat!("../../res/", $path, ".json")) as &[u8] ).expect(concat!("Chain spec ", $path, " is invalid.")) @@ -119,10 +119,10 @@ bundle_test_machine! { #[cfg(test)] mod tests { use account_state::State; + use common_types::{view, views::BlockView}; use ethereum_types::U256; use tempdir::TempDir; - use test_helpers::get_temp_state_db; - use types::{view, views::BlockView}; + use ethcore::test_helpers::get_temp_state_db; use super::{new_morden, new_foundation}; diff --git a/ethcore/src/spec/genesis.rs b/ethcore/spec/src/genesis.rs similarity index 97% rename from ethcore/src/spec/genesis.rs rename to ethcore/spec/src/genesis.rs index 96a42178d..d96d8bb3f 100644 --- a/ethcore/src/spec/genesis.rs +++ b/ethcore/spec/src/genesis.rs @@ -16,8 +16,8 @@ use ethereum_types::{H256, U256, Address}; use ethjson; -use hash::KECCAK_NULL_RLP; -use spec::seal::Seal; +use keccak_hash::KECCAK_NULL_RLP; +use crate::seal::Seal; /// Genesis components. pub struct Genesis { diff --git a/ethcore/src/spec/mod.rs b/ethcore/spec/src/lib.rs similarity index 92% rename from ethcore/src/spec/mod.rs rename to ethcore/spec/src/lib.rs index 5ac0b8a9b..0748d6966 100644 --- a/ethcore/src/spec/mod.rs +++ b/ethcore/spec/src/lib.rs @@ -23,4 +23,4 @@ mod spec; pub use self::chain::*; pub use self::genesis::Genesis; -pub use self::spec::{Spec, SpecHardcodedSync, SpecParams, OptimizeFor}; +pub use self::spec::{Spec, SpecHardcodedSync, SpecParams}; diff --git a/ethcore/src/spec/seal.rs b/ethcore/spec/src/seal.rs similarity index 100% rename from ethcore/src/spec/seal.rs rename to ethcore/spec/src/seal.rs diff --git a/ethcore/src/spec/spec.rs b/ethcore/spec/src/spec.rs similarity index 96% rename from ethcore/src/spec/spec.rs rename to ethcore/spec/src/spec.rs index 046a9e028..87b59285e 100644 --- a/ethcore/src/spec/spec.rs +++ b/ethcore/spec/src/spec.rs @@ -24,41 +24,42 @@ use std::{ sync::Arc, }; -use bytes::Bytes; -use ethereum_types::{H256, Bloom, U256, Address}; -use ethjson; -use hash::{KECCAK_NULL_RLP, keccak}; -use rlp::{Rlp, RlpStream}; -use types::{ +use common_types::{ BlockNumber, header::Header, encoded, - engines::params::CommonParams, + engines::{OptimizeFor, params::CommonParams}, errors::EthcoreError as Error, + transaction::{Action, Transaction}, }; -use vm::{EnvInfo, CallType, ActionValue, ActionParams, ParamsType}; - -use builtin::Builtin; -use engine::Engine; -use clique::Clique; -use null_engine::NullEngine; -use instant_seal::{InstantSeal, InstantSealParams}; +use account_state::{Backend, State, backend::Basic as BasicBackend}; use authority_round::AuthorityRound; use basic_authority::BasicAuthority; +use bytes::Bytes; +use builtin::Builtin; +use clique::Clique; +use engine::Engine; use ethash_engine::Ethash; -use machine::{ - executive::Executive, - machine::Machine, - substate::Substate, -}; -use trie_vm_factories::Factories; +use ethereum_types::{H256, Bloom, U256, Address}; +use ethjson; +use instant_seal::{InstantSeal, InstantSealParams}; +use keccak_hash::{KECCAK_NULL_RLP, keccak}; +use log::{trace, warn}; +use machine::{executive::Executive, Machine, substate::Substate}; +use null_engine::NullEngine; use pod::PodState; -use spec::Genesis; -use spec::seal::Generic as GenericSeal; -use account_state::{Backend, State, backend::Basic as BasicBackend}; +use rlp::{Rlp, RlpStream}; use trace::{NoopTracer, NoopVMTracer}; +use trie_vm_factories::Factories; +use vm::{EnvInfo, CallType, ActionValue, ActionParams, ParamsType}; + +use crate::{ + Genesis, + seal::Generic as GenericSeal, +}; + + -pub use ethash::OptimizeFor; /// Runtime parameters for the spec that are related to how the software should run the chain, /// rather than integral properties of the chain itself. @@ -489,8 +490,6 @@ impl Spec { /// initialize genesis epoch data, using in-memory database for /// constructor. pub fn genesis_epoch_data(&self) -> Result, String> { - use types::transaction::{Action, Transaction}; - let genesis = self.genesis_header(); let factories = Default::default(); @@ -505,7 +504,7 @@ impl Spec { let call = |a, d| { let mut db = db.boxed_clone(); - let env_info = ::evm::EnvInfo { + let env_info = evm::EnvInfo { number: 0, author: *genesis.author(), timestamp: genesis.timestamp(), @@ -525,7 +524,7 @@ impl Spec { data: d, }.fake_sign(from); - let res = ::executive_state::prove_transaction_virtual( + let res = executive_state::prove_transaction_virtual( db.as_hash_db_mut(), *genesis.state_root(), &tx, @@ -545,14 +544,15 @@ impl Spec { #[cfg(test)] mod tests { - use super::*; - use account_state::State; - use test_helpers::get_temp_state_db; - use tempdir::TempDir; - use types::view; - use types::views::BlockView; use std::str::FromStr; - use crate::spec; + + use account_state::State; + use common_types::{view, views::BlockView}; + use ethereum_types::{Address, H256}; + use ethcore::test_helpers::get_temp_state_db; + use tempdir::TempDir; + + use super::Spec; #[test] fn test_load_empty() { @@ -562,7 +562,7 @@ mod tests { #[test] fn test_chain() { - let test_spec = spec::new_test(); + let test_spec = crate::new_test(); assert_eq!( test_spec.state_root, @@ -578,7 +578,7 @@ mod tests { #[test] fn genesis_constructor() { let _ = ::env_logger::try_init(); - let spec = spec::new_test_constructor(); + let spec = crate::new_test_constructor(); let db = spec.ensure_db_good(get_temp_state_db(), &Default::default()) .unwrap(); let state = State::from_existing( diff --git a/ethcore/src/block.rs b/ethcore/src/block.rs index 3a1633778..7102832a5 100644 --- a/ethcore/src/block.rs +++ b/ethcore/src/block.rs @@ -500,7 +500,7 @@ mod tests { verification::Unverified, }; use hash_db::EMPTY_PREFIX; - use crate::spec; + use spec; /// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header fn enact_bytes( diff --git a/ethcore/src/client/test_client.rs b/ethcore/src/client/test_client.rs index 422bebcd8..6f243cb4c 100644 --- a/ethcore/src/client/test_client.rs +++ b/ethcore/src/client/test_client.rs @@ -58,6 +58,7 @@ use types::{ client_types::Mode, blockchain_info::BlockChainInfo, block_status::BlockStatus, + verification::VerificationQueueInfo as BlockQueueInfo, }; use vm::{Schedule, LastHashes}; @@ -80,7 +81,6 @@ use spec::{Spec, self}; use account_state::state::StateInfo; use state_db::StateDB; use trace::LocalizedTrace; -use verification::queue::QueueInfo as BlockQueueInfo; /// Test client. pub struct TestBlockChainClient { diff --git a/ethcore/src/json_tests/executive.rs b/ethcore/src/json_tests/executive.rs index 234cd557d..514206fdd 100644 --- a/ethcore/src/json_tests/executive.rs +++ b/ethcore/src/json_tests/executive.rs @@ -39,7 +39,7 @@ use ethtrie; use rlp::RlpStream; use hash::keccak; use ethereum_types::BigEndianHash; -use crate::spec; +use spec; use super::HookType; diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index ab1190d8f..a34db6c65 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -55,32 +55,23 @@ extern crate account_db; extern crate account_state; -extern crate authority_round; extern crate ansi_term; -extern crate basic_authority; extern crate client_traits; extern crate common_types as types; -extern crate clique; extern crate crossbeam_utils; extern crate engine; extern crate ethabi; -extern crate ethash; -extern crate ethash_engine; extern crate ethcore_blockchain as blockchain; extern crate ethcore_bloom_journal as bloom_journal; -extern crate ethcore_builtin as builtin; extern crate ethcore_call_contract as call_contract; extern crate ethcore_db as db; extern crate ethcore_io as io; extern crate ethcore_miner; extern crate ethereum_types; -extern crate ethjson; -extern crate ethkey; extern crate executive_state; extern crate trie_vm_factories; extern crate futures; extern crate hash_db; -extern crate instant_seal; extern crate itertools; extern crate journaldb; extern crate keccak_hash as hash; @@ -92,12 +83,10 @@ extern crate kvdb_memorydb; extern crate len_caching_lock; extern crate machine; extern crate memory_cache; -extern crate null_engine; extern crate num_cpus; extern crate parity_bytes as bytes; extern crate parity_snappy as snappy; extern crate parking_lot; -extern crate pod; extern crate trie_db as trie; extern crate patricia_trie_ethereum as ethtrie; extern crate rand; @@ -108,6 +97,7 @@ extern crate parity_util_mem as malloc_size_of; #[cfg(any(test, feature = "test-helpers"))] extern crate rustc_hex; extern crate serde; +extern crate spec; extern crate state_db; extern crate time_utils; extern crate trace; @@ -122,6 +112,13 @@ extern crate rand_xorshift; extern crate ethcore_accounts as accounts; #[cfg(feature = "stratum")] extern crate ethcore_stratum; +#[cfg(any(test, feature = "stratum"))] +extern crate ethash; + +#[cfg(any(test, feature = "test-helpers"))] +extern crate ethkey; +#[cfg(any(test, feature = "test-helpers"))] +extern crate ethjson; #[cfg(any(test, feature = "tempdir"))] extern crate tempdir; #[cfg(any(test, feature = "kvdb-rocksdb"))] @@ -129,9 +126,13 @@ extern crate kvdb_rocksdb; #[cfg(any(test, feature = "json-tests"))] #[macro_use] extern crate lazy_static; -#[cfg(any(test, feature = "json-tests", feature = "test-helpers", feature = "parity"))] +#[cfg(any(test, feature = "test-helpers"))] #[macro_use] extern crate macros; +#[cfg(test)] +extern crate null_engine; +#[cfg(any(test, feature = "test-helpers"))] +extern crate pod; #[cfg(any(test, feature = "blooms-db"))] extern crate blooms_db; #[cfg(any(test, feature = "env_logger"))] @@ -161,7 +162,6 @@ pub mod block; pub mod client; pub mod miner; pub mod snapshot; -pub mod spec; pub mod verification; #[cfg(test)] diff --git a/ethcore/src/miner/miner.rs b/ethcore/src/miner/miner.rs index e7e066d45..bd12ede19 100644 --- a/ethcore/src/miner/miner.rs +++ b/ethcore/src/miner/miner.rs @@ -1498,7 +1498,7 @@ mod tests { BlockNumber, transaction::Transaction }; - use crate::spec; + use spec; #[test] fn should_prepare_block_to_seal() { diff --git a/ethcore/src/snapshot/service.rs b/ethcore/src/snapshot/service.rs index cbef5b5ff..cdc0d6a18 100644 --- a/ethcore/src/snapshot/service.rs +++ b/ethcore/src/snapshot/service.rs @@ -907,7 +907,7 @@ impl Drop for Service { mod tests { use client::ClientIoMessage; use io::{IoService}; - use crate::spec; + use spec; use journaldb::Algorithm; use snapshot::SnapshotService; use super::*; diff --git a/ethcore/src/snapshot/tests/proof_of_work.rs b/ethcore/src/snapshot/tests/proof_of_work.rs index a187be45c..85982a6df 100644 --- a/ethcore/src/snapshot/tests/proof_of_work.rs +++ b/ethcore/src/snapshot/tests/proof_of_work.rs @@ -33,7 +33,7 @@ use parking_lot::Mutex; use snappy; use kvdb::DBTransaction; use test_helpers; -use crate::spec; +use spec; const SNAPSHOT_MODE: ::snapshot::PowSnapshot = ::snapshot::PowSnapshot { blocks: 30000, max_restore_blocks: 30000 }; diff --git a/ethcore/src/snapshot/tests/service.rs b/ethcore/src/snapshot/tests/service.rs index acc28a8be..5702ddf97 100644 --- a/ethcore/src/snapshot/tests/service.rs +++ b/ethcore/src/snapshot/tests/service.rs @@ -32,7 +32,7 @@ use types::{ use snapshot::io::{PackedReader, PackedWriter, SnapshotReader, SnapshotWriter}; use snapshot::service::{Service, ServiceParams}; use snapshot::{chunk_state, chunk_secondary, SnapshotService}; -use crate::spec; +use spec; use test_helpers::{new_db, new_temp_db, generate_dummy_client_with_spec_and_data, restoration_db_handler}; use parking_lot::Mutex; diff --git a/ethcore/src/tests/client.rs b/ethcore/src/tests/client.rs index ea2aff7ae..b376b3c0f 100644 --- a/ethcore/src/tests/client.rs +++ b/ethcore/src/tests/client.rs @@ -33,7 +33,7 @@ use types::{ use client::{Client, ClientConfig, PrepareOpenBlock, ImportSealedBlock}; use client_traits::{BlockInfo, BlockChainClient, BlockChainReset, ChainInfo, ImportBlock}; -use crate::spec; +use spec; use machine::executive::{Executive, TransactOptions}; use miner::{Miner, PendingOrdering, MinerService}; use account_state::{State, CleanupMode, backend}; diff --git a/ethcore/src/tests/trace.rs b/ethcore/src/tests/trace.rs index dd6fb8464..26cb7e2be 100644 --- a/ethcore/src/tests/trace.rs +++ b/ethcore/src/tests/trace.rs @@ -21,7 +21,7 @@ use hash::keccak; use block::*; use ethereum_types::{U256, Address}; use io::*; -use crate::spec; +use spec; use test_helpers::get_temp_state_db; use client::{Client, ClientConfig}; use client_traits::{BlockChainClient, ImportBlock}; diff --git a/ethcore/src/verification/mod.rs b/ethcore/src/verification/mod.rs index 46cfd4b9e..16e0e52dd 100644 --- a/ethcore/src/verification/mod.rs +++ b/ethcore/src/verification/mod.rs @@ -16,20 +16,26 @@ //! Block verification utilities. +use call_contract::CallContract; +use client_traits::BlockInfo; + mod verification; mod verifier; pub mod queue; mod canon_verifier; mod noop_verifier; -pub use self::verification::*; +pub use self::verification::FullFamilyParams; pub use self::verifier::Verifier; -pub use self::canon_verifier::CanonVerifier; -pub use self::noop_verifier::NoopVerifier; -pub use self::queue::{BlockQueue, Config as QueueConfig, VerificationQueue, QueueInfo}; +pub use self::queue::{BlockQueue, Config as QueueConfig}; -use call_contract::CallContract; -use client_traits::BlockInfo; +use self::verification::{ + verify_block_basic, + verify_block_unordered, + verify_header_params, +}; +use self::canon_verifier::CanonVerifier; +use self::noop_verifier::NoopVerifier; /// Verifier type. #[derive(Debug, PartialEq, Clone)] diff --git a/ethcore/src/verification/queue/mod.rs b/ethcore/src/verification/queue/mod.rs index 5bd96442a..58754251d 100644 --- a/ethcore/src/verification/queue/mod.rs +++ b/ethcore/src/verification/queue/mod.rs @@ -29,12 +29,13 @@ use io::*; use engine::Engine; use client::ClientIoMessage; use len_caching_lock::LenCachingMutex; -use types::errors::{BlockError, EthcoreError as Error, ImportError}; +use types::{ + errors::{BlockError, EthcoreError as Error, ImportError}, + verification::VerificationQueueInfo as QueueInfo, +}; use self::kind::{BlockLike, Kind}; -pub use types::verification::VerificationQueueInfo as QueueInfo; - pub mod kind; const MIN_MEM_LIMIT: usize = 16384; @@ -743,7 +744,7 @@ mod tests { view, views::BlockView, }; - use crate::spec; + use spec; // create a test block queue. // auto_scaling enables verifier adjustment. diff --git a/ethcore/src/verification/verification.rs b/ethcore/src/verification/verification.rs index 12149dfa8..4e73a37d3 100644 --- a/ethcore/src/verification/verification.rs +++ b/ethcore/src/verification/verification.rs @@ -372,7 +372,7 @@ mod tests { use hash::keccak; use engine::Engine; use ethkey::{Random, Generator}; - use crate::spec; + use spec; use test_helpers::{create_test_block_with_data, create_test_block}; use types::{ encoded, diff --git a/ethcore/sync/Cargo.toml b/ethcore/sync/Cargo.toml index e0f1a3fe5..721614887 100644 --- a/ethcore/sync/Cargo.toml +++ b/ethcore/sync/Cargo.toml @@ -46,3 +46,4 @@ ethcore-io = { path = "../../util/io", features = ["mio"] } kvdb-memorydb = "0.1" rustc-hex = "1.0" rand_xorshift = "0.1.1" +spec = { path = "../spec" } diff --git a/ethcore/sync/src/block_sync.rs b/ethcore/sync/src/block_sync.rs index a2b5650ed..bdc9864c9 100644 --- a/ethcore/sync/src/block_sync.rs +++ b/ethcore/sync/src/block_sync.rs @@ -637,7 +637,7 @@ fn all_expected(values: &[A], expected_values: &[B], is_expected: F) -> mod tests { use super::*; use ethcore::client::TestBlockChainClient; - use ethcore::spec; + use spec; use ethkey::{Generator,Random}; use hash::keccak; use parking_lot::RwLock; diff --git a/ethcore/sync/src/lib.rs b/ethcore/sync/src/lib.rs index eb1cdb98a..32baddec0 100644 --- a/ethcore/sync/src/lib.rs +++ b/ethcore/sync/src/lib.rs @@ -49,6 +49,7 @@ extern crate ethcore_light as light; #[cfg(test)] extern crate rand_xorshift; #[cfg(test)] extern crate machine; #[cfg(test)] extern crate engine; +#[cfg(test)] extern crate spec; #[macro_use] extern crate enum_primitive; diff --git a/ethcore/sync/src/light_sync/tests/test_net.rs b/ethcore/sync/src/light_sync/tests/test_net.rs index f33ad2123..eb35b8905 100644 --- a/ethcore/sync/src/light_sync/tests/test_net.rs +++ b/ethcore/sync/src/light_sync/tests/test_net.rs @@ -23,7 +23,7 @@ use light_sync::*; use tests::helpers::{TestNet, Peer as PeerLike, TestPacket}; use ethcore::client::TestBlockChainClient; -use ethcore::spec; +use spec; use io::IoChannel; use kvdb_memorydb; use light::client::fetch::{self, Unavailable}; diff --git a/ethcore/sync/src/tests/chain.rs b/ethcore/sync/src/tests/chain.rs index 0f67321df..c01c96a03 100644 --- a/ethcore/sync/src/tests/chain.rs +++ b/ethcore/sync/src/tests/chain.rs @@ -22,7 +22,7 @@ use client_traits::BlockInfo; use chain::SyncState; use super::helpers::*; use {SyncConfig, WarpSync}; -use ethcore::spec; +use spec; #[test] fn two_peers() { diff --git a/ethcore/sync/src/tests/consensus.rs b/ethcore/sync/src/tests/consensus.rs index f991d4692..8879897f0 100644 --- a/ethcore/sync/src/tests/consensus.rs +++ b/ethcore/sync/src/tests/consensus.rs @@ -21,7 +21,7 @@ use io::{IoHandler, IoChannel}; use client_traits::ChainInfo; use engine::signer; use ethcore::client::{ClientIoMessage}; -use ethcore::spec; +use spec; use ethcore::miner::{self, MinerService}; use ethkey::{KeyPair, Secret}; use types::transaction::{Action, PendingTransaction, Transaction}; diff --git a/ethcore/sync/src/tests/helpers.rs b/ethcore/sync/src/tests/helpers.rs index c4b6c7c43..b99148078 100644 --- a/ethcore/sync/src/tests/helpers.rs +++ b/ethcore/sync/src/tests/helpers.rs @@ -26,7 +26,7 @@ use client_traits::BlockChainClient; use ethcore::client::{TestBlockChainClient, Client as EthcoreClient, ClientConfig, ChainNotify, NewBlocks, ChainMessageType, ClientIoMessage}; use ethcore::snapshot::SnapshotService; -use ethcore::spec::{self, Spec}; +use spec::{self, Spec}; use ethcore_private_tx::PrivateStateDB; use ethcore::miner::Miner; use ethcore::test_helpers; diff --git a/ethcore/sync/src/tests/private.rs b/ethcore/sync/src/tests/private.rs index 27fa6f013..aabcaa825 100644 --- a/ethcore/sync/src/tests/private.rs +++ b/ethcore/sync/src/tests/private.rs @@ -25,7 +25,6 @@ use ethcore::{ CreateContractAddress, client::ClientIoMessage, miner::{self, MinerService}, - spec::Spec, test_helpers::{push_block_with_transactions, new_db}, }; use ethcore_private_tx::{Provider, ProviderConfig, NoopEncryptor, Importer, SignedPrivateTransaction, StoringKeyProvider}; @@ -34,6 +33,7 @@ use machine::executive::contract_address; use tests::helpers::{TestNet, TestIoHandler}; use rustc_hex::FromHex; use rlp::Rlp; +use spec::Spec; use SyncConfig; fn seal_spec() -> Spec { diff --git a/ethcore/types/src/engines/mod.rs b/ethcore/types/src/engines/mod.rs index 89d4e9bf4..94aaa4453 100644 --- a/ethcore/types/src/engines/mod.rs +++ b/ethcore/types/src/engines/mod.rs @@ -28,6 +28,21 @@ pub mod epoch; pub mod params; pub mod machine; +/// Optimize cache for CPU or memory usage +#[derive(PartialEq, Eq, Debug, Clone, Copy)] +pub enum OptimizeFor { + /// Optimize cache for CPU + Cpu, + /// Optimize cache for memory + Memory, +} + +impl Default for OptimizeFor { + fn default() -> Self { + OptimizeFor::Cpu + } +} + /// Ethash/Clique specific seal #[derive(Debug, PartialEq)] pub struct EthashSeal { diff --git a/evmbin/Cargo.toml b/evmbin/Cargo.toml index 0a9a481e4..ecd7e42bc 100644 --- a/evmbin/Cargo.toml +++ b/evmbin/Cargo.toml @@ -24,6 +24,7 @@ pod = { path = "../ethcore/pod" } rustc-hex = "1.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" +spec = { path = "../ethcore/spec" } trace = { path = "../ethcore/trace" } vm = { path = "../ethcore/vm" } diff --git a/evmbin/src/info.rs b/evmbin/src/info.rs index 57ac12150..c69da622c 100644 --- a/evmbin/src/info.rs +++ b/evmbin/src/info.rs @@ -20,13 +20,13 @@ use std::time::{Instant, Duration}; use common_types::transaction; use ethcore::{ - client::{self, EvmTestClient, EvmTestError, TransactErr, TransactSuccess}, - spec, + client::{EvmTestClient, EvmTestError, TransactErr, TransactSuccess}, TrieSpec, }; use ethereum_types::{H256, U256}; use ethjson; use pod::PodState; +use spec; use trace; use vm::ActionParams; @@ -244,7 +244,7 @@ pub mod tests { use super::*; use tempdir::TempDir; use ethereum_types::Address; - use ethcore::spec::{self, Spec}; + use spec::{self, Spec}; pub fn run_test( informant: I, diff --git a/evmbin/src/main.rs b/evmbin/src/main.rs index 40d394180..78036c60f 100644 --- a/evmbin/src/main.rs +++ b/evmbin/src/main.rs @@ -42,7 +42,8 @@ use parity_bytes::Bytes; use docopt::Docopt; use rustc_hex::FromHex; use ethereum_types::{U256, Address}; -use ethcore::{spec, json_tests, TrieSpec}; +use ethcore::{json_tests, TrieSpec}; +use spec; use serde::Deserialize; use vm::{ActionParams, CallType}; diff --git a/parity/export_hardcoded_sync.rs b/parity/export_hardcoded_sync.rs index adcdf5035..ba01965c0 100644 --- a/parity/export_hardcoded_sync.rs +++ b/parity/export_hardcoded_sync.rs @@ -18,10 +18,10 @@ use std::sync::Arc; use std::time::Duration; use ethcore::client::DatabaseCompactionProfile; -use ethcore::spec::{SpecParams, OptimizeFor}; +use spec::SpecParams; use light::client::fetch::Unavailable as UnavailableDataFetcher; use light::Cache as LightDataCache; - +use types::engines::OptimizeFor; use params::{SpecType, Pruning}; use helpers::execute_upgrades; use dir::Directories; diff --git a/parity/lib.rs b/parity/lib.rs index 86abde9da..3d96c0700 100644 --- a/parity/lib.rs +++ b/parity/lib.rs @@ -73,6 +73,7 @@ extern crate parity_runtime; extern crate parity_updater as updater; extern crate parity_version; extern crate registrar; +extern crate spec; #[macro_use] extern crate log as rlog; diff --git a/parity/params.rs b/parity/params.rs index e4d1e7548..f82aa0749 100644 --- a/parity/params.rs +++ b/parity/params.rs @@ -18,7 +18,7 @@ use std::collections::HashSet; use std::time::Duration; use std::{str, fs, fmt}; -use ethcore::spec::{Spec, SpecParams, self}; +use spec::{Spec, SpecParams, self}; use ethereum_types::{U256, Address}; use parity_runtime::Executor; use hash_fetch::fetch::Client as FetchClient; diff --git a/parity/run.rs b/parity/run.rs index d13ef9d05..417f544f1 100644 --- a/parity/run.rs +++ b/parity/run.rs @@ -26,7 +26,7 @@ use client_traits::{BlockInfo, BlockChainClient}; use ethcore::client::{Client, DatabaseCompactionProfile, VMType}; use ethcore::miner::{self, stratum, Miner, MinerService, MinerOptions}; use ethcore::snapshot::{self, SnapshotConfiguration}; -use ethcore::spec::{SpecParams, OptimizeFor}; +use spec::SpecParams; use ethcore::verification::queue::VerifierSettings; use ethcore_logger::{Config as LogConfig, RotatingLogger}; use ethcore_service::ClientService; @@ -43,6 +43,7 @@ use parity_runtime::Runtime; use sync::{self, SyncConfig, PrivateTxHandler}; use types::{ client_types::Mode, + engines::OptimizeFor, ids::BlockId, snapshot::Snapshotting, }; diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 507b821ef..c5e7dd28b 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -64,6 +64,7 @@ parity-updater = { path = "../updater" } parity-version = { path = "../util/version" } rlp = "0.4.0" account-state = { path = "../ethcore/account-state" } +spec = { path = "../ethcore/spec" } stats = { path = "../util/stats" } trace = { path = "../ethcore/trace" } vm = { path = "../ethcore/vm" } diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index acf9f13dc..ed909484f 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -85,6 +85,7 @@ extern crate parity_version as version; extern crate eip_712; extern crate rlp; extern crate account_state; +extern crate spec; extern crate stats; extern crate tempdir; extern crate trace; diff --git a/rpc/src/v1/tests/eth.rs b/rpc/src/v1/tests/eth.rs index 23aedbe50..45887ae9a 100644 --- a/rpc/src/v1/tests/eth.rs +++ b/rpc/src/v1/tests/eth.rs @@ -22,7 +22,7 @@ use accounts::AccountProvider; use client_traits::{BlockChainClient, ChainInfo, ImportBlock}; use ethcore::client::{Client, ClientConfig}; use ethcore::miner::Miner; -use ethcore::spec::{Genesis, Spec, self}; +use spec::{Genesis, Spec, self}; use ethcore::test_helpers; use ethcore::verification::VerifierType; use ethereum_types::{Address, H256, U256};