From 79b671f6c78de4b2f814daf34c8558117a7f7800 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 23 Aug 2019 14:13:02 +0200 Subject: [PATCH 1/2] EIP 2028: transaction gas lowered from 68 to 16 (#10987) --- ethcore/evm/src/tests.rs | 1 - ethcore/types/src/engines/params.rs | 9 +++++++++ ethcore/vm/src/schedule.rs | 9 ++++++++- ethcore/vm/src/tests.rs | 7 +++++++ json/src/spec/params.rs | 2 ++ 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ethcore/evm/src/tests.rs b/ethcore/evm/src/tests.rs index 8d68fc1d3c4..15749b9266f 100644 --- a/ethcore/evm/src/tests.rs +++ b/ethcore/evm/src/tests.rs @@ -262,7 +262,6 @@ fn test_calldataload(factory: super::Factory) { assert_eq!(gas_left, U256::from(79_991)); assert_store(&ext, 0, "23ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff23"); - } evm_test!{test_author: test_author_int} diff --git a/ethcore/types/src/engines/params.rs b/ethcore/types/src/engines/params.rs index f3995adaa49..4b6fba31dbc 100644 --- a/ethcore/types/src/engines/params.rs +++ b/ethcore/types/src/engines/params.rs @@ -90,6 +90,8 @@ pub struct CommonParams { pub eip1283_disable_transition: BlockNumber, /// Number of first block where EIP-1014 rules begin. pub eip1014_transition: BlockNumber, + /// Number of first block where EIP-2028 rules begin. + pub eip2028_transition: BlockNumber, /// Number of first block where dust cleanup rules (EIP-168 and EIP169) begin. pub dust_protection_transition: BlockNumber, /// Nonce cap increase per block. Nonce cap is only checked if dust protection is enabled. @@ -160,6 +162,9 @@ impl CommonParams { schedule.have_bitwise_shifting = block_number >= self.eip145_transition; schedule.have_extcodehash = block_number >= self.eip1052_transition; schedule.eip1283 = block_number >= self.eip1283_transition && !(block_number >= self.eip1283_disable_transition); + if block_number >= self.eip2028_transition { + schedule.tx_data_non_zero_gas = 16; + } if block_number >= self.eip210_transition { schedule.blockhash_gas = 800; } @@ -277,6 +282,10 @@ impl From for CommonParams { BlockNumber::max_value, Into::into, ), + eip2028_transition: p.eip2028_transition.map_or_else( + BlockNumber::max_value, + Into::into, + ), dust_protection_transition: p.dust_protection_transition.map_or_else( BlockNumber::max_value, Into::into, diff --git a/ethcore/vm/src/schedule.rs b/ethcore/vm/src/schedule.rs index dec689ca23f..66c2391ac5b 100644 --- a/ethcore/vm/src/schedule.rs +++ b/ethcore/vm/src/schedule.rs @@ -91,7 +91,7 @@ pub struct Schedule { pub tx_create_gas: usize, /// Additional cost for empty data transaction pub tx_data_zero_gas: usize, - /// Aditional cost for non-empty data transaction + /// Additional cost for non-empty data transaction pub tx_data_non_zero_gas: usize, /// Gas price for copying memory pub copy_gas: usize, @@ -288,6 +288,13 @@ impl Schedule { schedule } + /// Schedule for the Istanbul fork of the Ethereum main net. + pub fn new_istanbul() -> Schedule { + let mut schedule = Self::new_constantinople(); + schedule.tx_data_non_zero_gas = 16; + schedule + } + fn new(efcd: bool, hdc: bool, tcg: usize) -> Schedule { Schedule { exceptional_failed_code_deposit: efcd, diff --git a/ethcore/vm/src/tests.rs b/ethcore/vm/src/tests.rs index 367be253302..b6709d6efff 100644 --- a/ethcore/vm/src/tests.rs +++ b/ethcore/vm/src/tests.rs @@ -98,6 +98,13 @@ impl FakeExt { ext } + /// New fake externalities with constantinople schedule rules + pub fn new_istanbul() -> Self { + let mut ext = FakeExt::default(); + ext.schedule = Schedule::new_istanbul(); + ext + } + /// Alter fake externalities to allow wasm pub fn with_wasm(mut self) -> Self { self.schedule.wasm = Some(Default::default()); diff --git a/json/src/spec/params.rs b/json/src/spec/params.rs index dc3e3fec183..68093db20c6 100644 --- a/json/src/spec/params.rs +++ b/json/src/spec/params.rs @@ -94,6 +94,8 @@ pub struct Params { /// See `CommonParams` docs. pub eip1014_transition: Option, /// See `CommonParams` docs. + pub eip2028_transition: Option, + /// See `CommonParams` docs. pub dust_protection_transition: Option, /// See `CommonParams` docs. pub nonce_cap_increment: Option, From fbf425c4e21639c76b53e9f489750da1d1ae0e55 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 23 Aug 2019 15:32:58 +0200 Subject: [PATCH 2/2] 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 | 74 +++++++++---------- 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 | 9 ++- 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 | 72 +++++++++--------- 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, 336 insertions(+), 199 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 6feca96058d..d4867ad3362 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 c8841db2828..d8eb2179793 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-path = "0.1" 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" } -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 } - +parking_lot = "0.8" +regex = "1.0" registrar = { path = "util/registrar" } - -parity-util-mem = { version = "0.2.0", features = ["jemalloc-global"] } +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 7bd2343004f..59db4cd73e2 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 64c31cb219b..f1b8fcbaa40 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 e086a14b42f..fdf8415f1ed 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 b16d2731457..e3dc6a515d0 100644 --- a/ethash/src/cache.rs +++ b/ethash/src/cache.rs @@ -30,19 +30,9 @@ use std::path::{Path, PathBuf}; use std::slice; use std::sync::Arc; -type Cache = Either, MmapMut>; - -#[derive(PartialEq, Eq, Debug, Clone, Copy)] -pub enum OptimizeFor { - Cpu, - Memory, -} +use common_types::engines::OptimizeFor; -impl Default for OptimizeFor { - fn default() -> Self { - OptimizeFor::Cpu - } -} +type Cache = Either, MmapMut>; fn byte_size(cache: &Cache) -> usize { use self::Either::{Left, Right}; diff --git a/ethash/src/lib.rs b/ethash/src/lib.rs index 3225ceb9f58..e181087cc35 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 7c7fb531aa7..0ade1c5412b 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 eafeb8beae7..d87133a502b 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 5c2022a9a77..699c88535d4 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 268e7931a1b..859a3f35a9f 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 e3b0f8b4aaa..bd4879ac67e 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 8a41979f7c7..98aa8c22add 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 2a5938c7e3a..92f2c79a8a9 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 d17b015804a..b18283fb214 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 5163031028b..7b98940531d 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 15b9bdea31b..05cb5d2621c 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 648b3a15d16..85129230c0f 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 498978f2af5..bd901ef888a 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 c456ce9065e..42a74e999d5 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 99d859d588f..a103401a7e7 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 aeeb2f08182..c92ae13d65d 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" } +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"] } -keccak-hash = "0.2.0" ethkey = { path = "../../../accounts/ethkey" } +keccak-hash = "0.2.0" rustc-hex = "1.0" -call-contract = { package = "ethcore-call-contract", path = "../../call-contract" } -env_logger = "0.6.2" +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 07b70f4a3b1..e05e6c4521c 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 a9fa6e8dce3..72b653041c6 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 8ae43a03d2a..d023802f0bf 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 a962a1e3937..4ced7f90c06 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 2be7b0d6f99..29b4cd78395 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 4e87e0fec6c..abc233744d1 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 92207139a0e..22b83c7325a 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 afc210997d2..98149ea2f8b 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 ee002e02b89..2a55322b464 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 a51b213e7d3..3d2bd3752d7 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 cd0cfd66bb6..e349b4d077a 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 2f096d3b837..5006ac26f1f 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 76a5d571a1b..9d479fe24b4 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 73a8612523d..45d8c4858e6 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 2c4313c37f0..f34b6571b58 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 2c793b04271..6dc91272201 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 77a32c049fb..1f334912fec 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 7d68a771975..6ab4afecd7a 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 fabb4a9b0eb..d49a3d30d39 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 08cb8878280..c1aebfe93f5 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 00000000000..03e16765b3c --- /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 3774f892b35..db4e2054040 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 96a42178dd4..d96d8bb3faa 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 5ac0b8a9b48..0748d6966ab 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 046a9e02807..87b59285eb7 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 std::str::FromStr; + use account_state::State; - use test_helpers::get_temp_state_db; + use common_types::{view, views::BlockView}; + use ethereum_types::{Address, H256}; + use ethcore::test_helpers::get_temp_state_db; use tempdir::TempDir; - use types::view; - use types::views::BlockView; - use std::str::FromStr; - use crate::spec; + + 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 3a16337780f..7102832a522 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 422bebcd8ff..6f243cb4c45 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 234cd557d54..514206fdd5c 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 ab1190d8f14..a34db6c6522 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 e7e066d452d..bd12ede1965 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 cbef5b5ff5d..cdc0d6a1888 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 a187be45cf1..85982a6df3c 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 acc28a8be98..5702ddf9703 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 ea2aff7ae64..b376b3c0f62 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 dd6fb8464d5..26cb7e2bece 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 46cfd4b9e2e..16e0e52dd1d 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 5bd96442aed..58754251dd2 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 12149dfa8b3..4e73a37d337 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 e0f1a3fe5f1..7216148876e 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 a2b5650ed7b..bdc9864c9c1 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 eb1cdb98ab3..32baddec0d7 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 f33ad212375..eb35b890517 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 0f67321df68..c01c96a036a 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 f991d4692e4..8879897f0ea 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 c4b6c7c4388..b991480788f 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 27fa6f01339..aabcaa82566 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 89d4e9bf4af..94aaa445319 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 0a9a481e40f..ecd7e42bcac 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 57ac12150b1..c69da622c28 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 40d394180be..78036c60f36 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 adcdf5035e3..ba01965c062 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 86abde9da24..3d96c070048 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 e4d1e7548f6..f82aa0749dd 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 d13ef9d0535..417f544f1e4 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 507b821ef24..c5e7dd28baf 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 acf9f13dc99..ed909484f2b 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 23aedbe50ec..45887ae9a73 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};