From 2af3140a2677b5a7e08b9fb8a133320a2d4ba908 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 22 Aug 2019 18:25:49 +0200 Subject: [PATCH] Extract engines to own crates (#10966) 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 * 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 * remove double-semicolons --- Cargo.lock | 385 ++++++++++++++---- Cargo.toml | 5 - ethcore/Cargo.toml | 17 +- ethcore/block-reward/Cargo.toml | 21 + .../res}/block_reward.json | 0 .../src/lib.rs} | 30 +- ethcore/builtin/src/lib.rs | 4 +- ethcore/engine/src/engine.rs | 18 +- ethcore/engine/src/lib.rs | 1 - ethcore/engines/authority-round/Cargo.toml | 39 ++ .../authority-round/src}/finality.rs | 8 +- .../authority-round/src/lib.rs} | 51 ++- ethcore/engines/basic-authority/Cargo.toml | 30 ++ .../basic-authority}/res/basic_authority.json | 0 .../basic-authority/src/lib.rs} | 67 ++- ethcore/engines/clique/Cargo.toml | 30 ++ .../clique/src}/block_state.rs | 24 +- .../mod.rs => engines/clique/src/lib.rs} | 45 +- .../clique => engines/clique/src}/params.rs | 0 .../clique => engines/clique/src}/tests.rs | 15 +- .../clique => engines/clique/src}/util.rs | 15 +- ethcore/engines/ethash/Cargo.toml | 26 ++ .../ethash.rs => engines/ethash/src/lib.rs} | 91 ++--- ethcore/engines/instant-seal/Cargo.toml | 20 + .../instant-seal/src/lib.rs} | 35 +- ethcore/engines/null-engine/Cargo.toml | 15 + .../null-engine/src/lib.rs} | 31 +- ethcore/engines/validator-set/Cargo.toml | 44 ++ .../validator-set/res}/validator_report.json | 0 .../validator-set/res}/validator_set.json | 0 .../validator-set/src}/contract.rs | 40 +- .../validator-set/src/lib.rs} | 18 +- .../validator-set/src}/multi.rs | 35 +- .../validator-set/src}/safe_contract.rs | 64 +-- .../validator-set/src}/simple_list.rs | 14 +- .../validator-set/src}/test.rs | 14 +- ethcore/executive-state/Cargo.toml | 33 ++ .../src/lib.rs} | 64 +-- ethcore/light/Cargo.toml | 1 + ethcore/light/src/client/mod.rs | 3 +- ethcore/light/src/lib.rs | 1 + ethcore/light/src/on_demand/request.rs | 2 +- ethcore/service/src/service.rs | 9 +- ethcore/src/block.rs | 2 +- ethcore/src/client/client.rs | 18 +- ethcore/src/client/evm_test_client.rs | 8 +- ethcore/src/client/io_message.rs | 2 +- ethcore/src/client/mod.rs | 5 - ethcore/src/client/test_client.rs | 3 +- ethcore/src/engines/mod.rs | 34 -- ethcore/src/lib.rs | 20 +- ethcore/src/snapshot/consensus/authority.rs | 8 +- ethcore/src/snapshot/consensus/mod.rs | 13 + ethcore/src/snapshot/consensus/work.rs | 5 +- ethcore/src/snapshot/io.rs | 7 +- ethcore/src/snapshot/mod.rs | 10 +- ethcore/src/snapshot/service.rs | 28 +- ethcore/src/snapshot/tests/helpers.rs | 4 +- ethcore/src/snapshot/tests/proof_of_work.rs | 3 +- ethcore/src/snapshot/tests/service.rs | 3 +- ethcore/src/snapshot/traits.rs | 73 +++- ethcore/src/spec/spec.rs | 10 +- ethcore/src/verification/verification.rs | 2 +- ethcore/sync/src/chain/handler.rs | 2 +- ethcore/sync/src/chain/mod.rs | 4 +- ethcore/sync/src/snapshot.rs | 5 +- ethcore/sync/src/tests/snapshot.rs | 7 +- ethcore/types/src/engines/mod.rs | 34 +- ethcore/types/src/lib.rs | 1 - ethcore/types/src/restoration_status.rs | 48 --- ethcore/types/src/snapshot.rs | 47 +++ evmbin/src/info.rs | 2 +- parity/informant.rs | 3 +- parity/run.rs | 10 +- parity/snapshot.rs | 3 +- rpc/src/lib.rs | 4 +- rpc/src/v1/impls/eth.rs | 8 +- rpc/src/v1/impls/parity.rs | 3 +- rpc/src/v1/impls/traces.rs | 3 +- rpc/src/v1/tests/helpers/snapshot_service.rs | 5 +- rpc/src/v1/tests/mocked/eth.rs | 3 +- 81 files changed, 1205 insertions(+), 610 deletions(-) create mode 100644 ethcore/block-reward/Cargo.toml rename ethcore/{res/contracts => block-reward/res}/block_reward.json (100%) rename ethcore/{src/engines/block_reward.rs => block-reward/src/lib.rs} (95%) create mode 100644 ethcore/engines/authority-round/Cargo.toml rename ethcore/{src/engines/authority_round => engines/authority-round/src}/finality.rs (98%) rename ethcore/{src/engines/authority_round/mod.rs => engines/authority-round/src/lib.rs} (99%) create mode 100644 ethcore/engines/basic-authority/Cargo.toml rename ethcore/{ => engines/basic-authority}/res/basic_authority.json (100%) rename ethcore/{src/engines/basic_authority.rs => engines/basic-authority/src/lib.rs} (91%) create mode 100644 ethcore/engines/clique/Cargo.toml rename ethcore/{src/engines/clique => engines/clique/src}/block_state.rs (97%) rename ethcore/{src/engines/clique/mod.rs => engines/clique/src/lib.rs} (97%) rename ethcore/{src/engines/clique => engines/clique/src}/params.rs (100%) rename ethcore/{src/engines/clique => engines/clique/src}/tests.rs (99%) rename ethcore/{src/engines/clique => engines/clique/src}/util.rs (96%) create mode 100644 ethcore/engines/ethash/Cargo.toml rename ethcore/{src/engines/ethash.rs => engines/ethash/src/lib.rs} (95%) create mode 100644 ethcore/engines/instant-seal/Cargo.toml rename ethcore/{src/engines/instant_seal.rs => engines/instant-seal/src/lib.rs} (91%) create mode 100644 ethcore/engines/null-engine/Cargo.toml rename ethcore/{src/engines/null_engine.rs => engines/null-engine/src/lib.rs} (86%) create mode 100644 ethcore/engines/validator-set/Cargo.toml rename ethcore/{res/contracts => engines/validator-set/res}/validator_report.json (100%) rename ethcore/{res/contracts => engines/validator-set/res}/validator_set.json (100%) rename ethcore/{src/engines/validator_set => engines/validator-set/src}/contract.rs (93%) rename ethcore/{src/engines/validator_set/mod.rs => engines/validator-set/src/lib.rs} (96%) rename ethcore/{src/engines/validator_set => engines/validator-set/src}/multi.rs (96%) rename ethcore/{src/engines/validator_set => engines/validator-set/src}/safe_contract.rs (95%) rename ethcore/{src/engines/validator_set => engines/validator-set/src}/simple_list.rs (97%) rename ethcore/{src/engines/validator_set => engines/validator-set/src}/test.rs (95%) create mode 100644 ethcore/executive-state/Cargo.toml rename ethcore/{src/executive_state.rs => executive-state/src/lib.rs} (99%) delete mode 100644 ethcore/src/engines/mod.rs delete mode 100644 ethcore/types/src/restoration_status.rs diff --git a/Cargo.lock b/Cargo.lock index 152da9223..6feca9605 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -35,7 +35,7 @@ dependencies = [ "pod 0.1.0", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rlp_compress 0.1.0", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", "trace 0.1.0", "trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "trie-vm-factories 0.1.0", @@ -161,6 +161,38 @@ dependencies = [ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "authority-round" +version = "0.1.0" +dependencies = [ + "block-reward 0.1.0", + "client-traits 0.1.0", + "common-types 0.1.0", + "engine 0.1.0", + "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ethcore 1.12.0", + "ethcore-accounts 0.1.0", + "ethcore-io 1.12.0", + "ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethjson 0.1.0", + "ethkey 0.3.0", + "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", + "keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", + "machine 0.1.0", + "macros 0.1.0", + "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)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "state-db 0.1.0", + "time-utils 0.1.0", + "unexpected 0.1.0", + "validator-set 0.1.0", +] + [[package]] name = "autocfg" version = "0.1.4" @@ -209,6 +241,27 @@ dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "basic-authority" +version = "0.1.0" +dependencies = [ + "client-traits 0.1.0", + "common-types 0.1.0", + "engine 0.1.0", + "ethcore 1.12.0", + "ethcore-accounts 0.1.0", + "ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethjson 0.1.0", + "ethkey 0.3.0", + "keccak-hash 0.2.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", + "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)", + "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "validator-set 0.1.0", +] + [[package]] name = "bincode" version = "1.1.4" @@ -216,7 +269,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -296,6 +349,22 @@ dependencies = [ "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "block-reward" +version = "0.1.0" +dependencies = [ + "common-types 0.1.0", + "engine 0.1.0", + "ethabi 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", + "ethcore 1.12.0", + "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", + "trace 0.1.0", +] + [[package]] name = "blooms-db" version = "0.1.0" @@ -366,7 +435,7 @@ name = "chainspec" version = "0.1.0" dependencies = [ "ethjson 0.1.0", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -432,6 +501,31 @@ dependencies = [ "vm 0.1.0", ] +[[package]] +name = "clique" +version = "0.1.0" +dependencies = [ + "client-traits 0.1.0", + "common-types 0.1.0", + "engine 0.1.0", + "ethcore 1.12.0", + "ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethjson 0.1.0", + "ethkey 0.3.0", + "keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", + "machine 0.1.0", + "macros 0.1.0", + "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)", + "state-db 0.1.0", + "time-utils 0.1.0", + "unexpected 0.1.0", +] + [[package]] name = "cloudabi" version = "0.0.3" @@ -503,9 +597,9 @@ dependencies = [ "itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", "itertools-num 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "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.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "simplelog 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -603,7 +697,7 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "csv-core 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -713,7 +807,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -727,7 +821,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "eip-712" version = "0.1.0" dependencies = [ - "ethabi 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -737,9 +831,9 @@ dependencies = [ "lunarity-lexer 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "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.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "toolshed 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "validator 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "validator_derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -795,6 +889,18 @@ dependencies = [ "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "env_logger" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "error-chain" version = "0.12.0" @@ -816,15 +922,15 @@ dependencies = [ [[package]] name = "ethabi" -version = "8.0.0" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "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.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -838,7 +944,7 @@ name = "ethabi-derive" version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "ethabi 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -859,11 +965,31 @@ dependencies = [ "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "primal 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "static_assertions 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ethash-engine" +version = "0.1.0" +dependencies = [ + "block-reward 0.1.0", + "common-types 0.1.0", + "engine 0.1.0", + "ethash 1.12.0", + "ethcore 1.12.0", + "ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethjson 0.1.0", + "keccak-hash 0.2.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", + "macros 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)", + "unexpected 0.1.0", +] + [[package]] name = "ethbloom" version = "0.6.4" @@ -883,17 +1009,21 @@ 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)", "engine 0.1.0", "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", - "ethabi 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "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", @@ -907,9 +1037,11 @@ dependencies = [ "ethjson 0.1.0", "ethkey 0.3.0", "evm 0.1.0", + "executive-state 0.1.0", "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)", @@ -920,10 +1052,10 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "len-caching-lock 0.1.1", "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)", "machine 0.1.0", "macros 0.1.0", "memory-cache 0.1.0", + "null-engine 0.1.0", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-runtime 0.1.0", @@ -939,9 +1071,9 @@ dependencies = [ "rlp_compress 0.1.0", "rlp_derive 0.1.0", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "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.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "state-db 0.1.0", "stats 0.1.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -966,9 +1098,9 @@ dependencies = [ "ethstore 0.2.1", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "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.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1080,6 +1212,7 @@ dependencies = [ "ethcore-miner 1.12.0", "ethcore-network 1.12.0", "ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "executive-state 0.1.0", "failsafe 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "fastmap 0.1.0", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1101,7 +1234,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)", "rlp_derive 0.1.0", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", "stats 0.1.0", @@ -1134,7 +1267,7 @@ dependencies = [ "common-types 0.1.0", "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethabi 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "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", @@ -1153,9 +1286,9 @@ dependencies = [ "price-info 1.12.0", "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)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "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.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "trace-time 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "transaction-pool 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1177,7 +1310,7 @@ dependencies = [ "parity-snappy 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", ] @@ -1209,8 +1342,8 @@ 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)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (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)", "slab 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "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)", @@ -1225,7 +1358,7 @@ dependencies = [ "common-types 0.1.0", "derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", - "ethabi 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "ethcore 1.12.0", @@ -1254,9 +1387,9 @@ dependencies = [ "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rlp_derive 0.1.0", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "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.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "state-db 0.1.0", "time-utils 0.1.0", "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1275,7 +1408,7 @@ dependencies = [ "client-traits 0.1.0", "common-types 0.1.0", "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", - "ethabi 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "ethcore 1.12.0", @@ -1297,9 +1430,9 @@ dependencies = [ "parity-runtime 0.1.0", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "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.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "tokio 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1402,9 +1535,9 @@ version = "0.1.0" dependencies = [ "ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "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.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1421,7 +1554,7 @@ dependencies = [ "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "zeroize 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1437,7 +1570,7 @@ dependencies = [ "panic_hook 0.1.0", "parity-wordlist 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", "threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1458,9 +1591,9 @@ 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)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "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.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1479,7 +1612,7 @@ dependencies = [ "panic_hook 0.1.0", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1518,13 +1651,41 @@ dependencies = [ "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "pod 0.1.0", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (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)", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "trace 0.1.0", "vm 0.1.0", ] +[[package]] +name = "executive-state" +version = "0.1.0" +dependencies = [ + "account-db 0.1.0", + "account-state 0.1.0", + "common-types 0.1.0", + "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", + "ethcore 1.12.0", + "ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethkey 0.3.0", + "evm 0.1.0", + "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "keccak-hasher 0.1.1", + "kvdb 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", + "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "patricia-trie-ethereum 0.1.0", + "pod 0.1.0", + "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trace 0.1.0", + "trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-vm-factories 0.1.0", + "vm 0.1.0", +] + [[package]] name = "failsafe" version = "0.3.0" @@ -1748,8 +1909,8 @@ dependencies = [ "pest_derive 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (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)", ] [[package]] @@ -1921,7 +2082,7 @@ name = "impl-serde" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1929,6 +2090,21 @@ name = "indexmap" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "instant-seal" +version = "0.1.0" +dependencies = [ + "common-types 0.1.0", + "engine 0.1.0", + "ethcore 1.12.0", + "ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethjson 0.1.0", + "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)", + "trace 0.1.0", +] + [[package]] name = "integer-encoding" version = "1.0.5" @@ -2054,9 +2230,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "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.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2105,7 +2281,7 @@ dependencies = [ "jsonrpc-core 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2324,7 +2500,7 @@ dependencies = [ "client-traits 0.1.0", "common-types 0.1.0", "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "ethabi 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "ethcore 1.12.0", @@ -2562,7 +2738,7 @@ version = "1.12.0" dependencies = [ "client-traits 0.1.0", "common-types 0.1.0", - "ethabi 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "ethcore 1.12.0", @@ -2582,6 +2758,18 @@ name = "nodrop" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "null-engine" +version = "0.1.0" +dependencies = [ + "block-reward 0.1.0", + "common-types 0.1.0", + "engine 0.1.0", + "ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethjson 0.1.0", + "machine 0.1.0", +] + [[package]] name = "num" version = "0.1.42" @@ -2712,7 +2900,7 @@ version = "3.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2813,9 +3001,9 @@ dependencies = [ "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "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.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "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)", @@ -2827,7 +3015,7 @@ dependencies = [ name = "parity-hash-fetch" version = "1.12.0" dependencies = [ - "ethabi 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2874,9 +3062,9 @@ dependencies = [ "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)", "rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "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.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2959,9 +3147,9 @@ dependencies = [ "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)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "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.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "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)", @@ -2985,8 +3173,8 @@ dependencies = [ "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-rpc 1.12.0", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (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)", "url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3039,7 +3227,7 @@ version = "1.12.0" dependencies = [ "client-traits 0.1.0", "common-types 0.1.0", - "ethabi 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "ethcore 1.12.0", @@ -3272,7 +3460,7 @@ dependencies = [ "patricia-trie-ethereum 0.1.0", "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)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", "trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "triehash-ethereum 0.2.0", ] @@ -3294,7 +3482,7 @@ dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-runtime 0.1.0", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3384,9 +3572,9 @@ dependencies = [ "ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethjson 0.1.0", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "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.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "vm 0.1.0", "wasm 0.1.0", ] @@ -3640,7 +3828,7 @@ dependencies = [ name = "registrar" version = "0.0.1" dependencies = [ - "ethabi 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3764,7 +3952,7 @@ dependencies = [ [[package]] name = "ryu" -version = "0.2.6" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -3822,7 +4010,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3832,7 +4020,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.89" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3850,12 +4038,12 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.39" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 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)", ] [[package]] @@ -4408,7 +4596,7 @@ name = "toml" version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4416,7 +4604,7 @@ name = "toml" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4640,12 +4828,46 @@ dependencies = [ "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "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.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "validator-set" +version = "0.1.0" +dependencies = [ + "client-traits 0.1.0", + "common-types 0.1.0", + "engine 0.1.0", + "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ethabi 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", + "ethcore 1.12.0", + "ethcore-accounts 0.1.0", + "ethcore-call-contract 0.1.0", + "ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethjson 0.1.0", + "ethkey 0.3.0", + "executive-state 0.1.0", + "keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.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", + "memory-cache 0.1.0", + "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", + "triehash-ethereum 0.2.0", + "unexpected 0.1.0", + "vm 0.1.0", +] + [[package]] name = "validator_derive" version = "0.8.0" @@ -4948,9 +5170,10 @@ dependencies = [ "checksum elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "073be79b6538296faf81c631872676600616073817dd9a440c477ad09b408983" "checksum enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be4551092f4d519593039259a9ed8daedf0da12e5109c5280338073eaeb81180" "checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" +"checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" "checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02" "checksum eth-secp256k1 0.5.7 (git+https://github.com/paritytech/rust-secp256k1)" = "" -"checksum ethabi 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b312e5740d6e0369491ebe81a8752f7797b70e495530f28bbb7cc967ded3d77c" +"checksum ethabi 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ebdeeea85a6d217b9fcc862906d7e283c047e04114165c433756baf5dce00a6c" "checksum ethabi-contract 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e0d6314f57a5451692753696f40903bacf870adf65d452911ab6b15bf6be41f8" "checksum ethabi-derive 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "65cdef3199bf5d1821dc53b5ab992f853a13b2e28d7a63983095d9d61fae58d3" "checksum ethbloom 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3932e82d64d347a045208924002930dc105a138995ccdc1479d0f05f0359f17c" @@ -5146,7 +5369,7 @@ dependencies = [ "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum rustls 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)" = "38af00e78b66109e7184a0ee16940f41583161b7ec0518af258e4bcaed15db25" -"checksum ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7153dd96dade874ab973e098cb62fcdbb89a03682e46b144fd09550998d4a4a7" +"checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" "checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" "checksum same-file 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "10f7794e2fda7f594866840e95f5c5962e886e228e68b6505885811a94dd728c" "checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" @@ -5156,9 +5379,9 @@ dependencies = [ "checksum sct 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f5adf8fbd58e1b1b52699dc8bed2630faecb6d8c7bee77d009d6bbe4af569b9" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)" = "92514fb95f900c9b5126e32d020f5c6d40564c27a5ea6d1d7d9f157a96623560" +"checksum serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)" = "fec2851eb56d010dc9a21b89ca53ee75e6528bab60c11e89d38390904982da9f" "checksum serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)" = "bb6eabf4b5914e88e24eea240bb7c9f9a2cbc1bbbe8d961d381975ec3c6b806c" -"checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" +"checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" "checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68" "checksum sha1 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "171698ce4ec7cbb93babeb3190021b4d72e96ccb98e33d277ae4ea959d6f2d9e" "checksum sha2 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9eb6be24e4c23a84d7184280d2722f7f2731fcdd4a9d886efbfe4413e4847ea0" diff --git a/Cargo.toml b/Cargo.toml index 69fe1f02a..c8841db28 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -135,9 +135,4 @@ members = [ "ethcore/wasm/run", "evmbin", "parity-clib", - "util/triehash-ethereum", - "util/keccak-hasher", - "util/patricia-trie-ethereum", - "util/fastmap", - "util/time-utils", ] diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index f896042aa..eafeb8bea 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -9,9 +9,12 @@ 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" } 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" } @@ -20,6 +23,7 @@ ethabi = "8.0" ethabi-contract = "8.0" ethabi-derive = "8.0" ethash = { path = "../ethash" } +ethash-engine = { path = "./engines/ethash" } ethcore-blockchain = { path = "./blockchain" } ethcore-bloom-journal = { path = "../util/bloom" } ethcore-builtin = { path = "./builtin" } @@ -32,9 +36,11 @@ 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" @@ -42,13 +48,13 @@ keccak-hasher = { path = "../util/keccak-hasher" } kvdb = "0.1" kvdb-memorydb = "0.1" kvdb-rocksdb = { version = "0.1.3", optional = true } -lazy_static = "1.2.0" +lazy_static = "1.3.0" len-caching-lock = { path = "../util/len-caching-lock" } log = "0.4" -lru-cache = "0.1" +macros = { path = "../util/macros", optional = true } machine = { path = "./machine" } -macros = { path = "../util/macros" } memory-cache = { path = "../util/memory-cache" } +null-engine = { path = "./engines/null-engine" } num_cpus = "1.2" parity-bytes = "0.1" parity-snappy = "0.1" @@ -85,6 +91,7 @@ ethcore-accounts = { path = "../accounts" } fetch = { path = "../util/fetch" } kvdb-rocksdb = "0.1.3" machine = { path = "./machine", features = ["test-helpers"] } +macros = { path = "../util/macros" } parity-runtime = { path = "../util/runtime" } rlp_compress = { path = "../util/rlp-compress" } serde_json = "1.0" @@ -92,7 +99,7 @@ tempdir = "0.3" trie-standardmap = "0.15.0" [features] -parity = ["work-notify", "price-info", "stratum"] +parity = ["work-notify", "price-info", "stratum", "macros"] # Large optional features that are enabled by default for Parity, # but might be omitted for other dependent crates. work-notify = ["ethcore-miner/work-notify"] @@ -119,7 +126,7 @@ ci-skip-tests = [] # Run memory/cpu heavy tests. test-heavy = [] # Compile test helpers -test-helpers = ["tempdir", "kvdb-rocksdb", "blooms-db"] +test-helpers = ["tempdir", "kvdb-rocksdb", "blooms-db", "macros", "basic-authority/test-helpers"] [[bench]] name = "builtin" diff --git a/ethcore/block-reward/Cargo.toml b/ethcore/block-reward/Cargo.toml new file mode 100644 index 000000000..5c2022a9a --- /dev/null +++ b/ethcore/block-reward/Cargo.toml @@ -0,0 +1,21 @@ +[package] +description = "A crate to interact with the block rewards contract." +name = "block-reward" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2018" +license = "GPL-3.0" + +[dependencies] +common-types = { path = "../types" } +engine = { path = "../engine" } +ethabi = "8.0.1" +ethabi-derive = "8.0.0" +ethabi-contract = "8.0.1" +ethereum-types = "0.6.0" +keccak-hash = "0.2.0" +machine = { path = "../machine" } +trace = { path = "../trace" } + +[dev-dependencies] +ethcore = { path = "..", features = ["test-helpers"] } diff --git a/ethcore/res/contracts/block_reward.json b/ethcore/block-reward/res/block_reward.json similarity index 100% rename from ethcore/res/contracts/block_reward.json rename to ethcore/block-reward/res/block_reward.json diff --git a/ethcore/src/engines/block_reward.rs b/ethcore/block-reward/src/lib.rs similarity index 95% rename from ethcore/src/engines/block_reward.rs rename to ethcore/block-reward/src/lib.rs index c2f66c13e..268e7931a 100644 --- a/ethcore/src/engines/block_reward.rs +++ b/ethcore/block-reward/src/lib.rs @@ -14,24 +14,25 @@ // You should have received a copy of the GNU General Public License // along with Parity Ethereum. If not, see . -//! A module with types for declaring block rewards and a client interface for interacting with a +//! Types for declaring block rewards and a client interface for interacting with a //! block reward contract. -use ethabi::FunctionOutputDecoder; -use ethereum_types::{Address, U256}; - use std::sync::Arc; -use hash::keccak; -use machine::{Machine, ExecutedBlock}; -use trace; -use types::{ + +use ethabi::FunctionOutputDecoder; +use ethabi_contract::use_contract; +use ethereum_types::{Address, U256}; +use common_types::{ BlockNumber, errors::{EngineError, EthcoreError as Error}, }; +use keccak_hash::keccak; +use machine::{Machine, ExecutedBlock}; use engine::{SystemOrCodeCall, SystemOrCodeCallKind}; +use trace; use trace::{Tracer, ExecutiveTracer, Tracing}; -use_contract!(block_reward_contract, "res/contracts/block_reward.json"); +use_contract!(block_reward_contract, "res/block_reward.json"); /// The kind of block reward. /// Depending on the consensus engine the allocated block reward might have @@ -161,13 +162,14 @@ pub fn apply_block_rewards( #[cfg(test)] mod test { use std::str::FromStr; - use client::PrepareOpenBlock; + use ethcore::{ + client::PrepareOpenBlock, + spec, + test_helpers::generate_dummy_client_with_spec, + }; use ethereum_types::{U256, Address}; - use crate::spec; - use test_helpers::generate_dummy_client_with_spec; - use engine::SystemOrCodeCallKind; - use super::{BlockRewardContract, RewardKind}; + use crate::{BlockRewardContract, RewardKind}; #[test] fn block_reward_contract() { diff --git a/ethcore/builtin/src/lib.rs b/ethcore/builtin/src/lib.rs index d6f498441..c06d3330f 100644 --- a/ethcore/builtin/src/lib.rs +++ b/ethcore/builtin/src/lib.rs @@ -442,7 +442,7 @@ impl Implementation for Bn128Add { if let Some(sum) = AffineG1::from_jacobian(p1 + p2) { // point not at infinity sum.x().to_big_endian(&mut write_buf[0..32]).expect("Cannot fail since 0..32 is 32-byte length"); - sum.y().to_big_endian(&mut write_buf[32..64]).expect("Cannot fail since 32..64 is 32-byte length");; + sum.y().to_big_endian(&mut write_buf[32..64]).expect("Cannot fail since 32..64 is 32-byte length"); } output.write(0, &write_buf); @@ -463,7 +463,7 @@ impl Implementation for Bn128Mul { if let Some(sum) = AffineG1::from_jacobian(p * fr) { // point not at infinity sum.x().to_big_endian(&mut write_buf[0..32]).expect("Cannot fail since 0..32 is 32-byte length"); - sum.y().to_big_endian(&mut write_buf[32..64]).expect("Cannot fail since 32..64 is 32-byte length");; + sum.y().to_big_endian(&mut write_buf[32..64]).expect("Cannot fail since 32..64 is 32-byte length"); } output.write(0, &write_buf); Ok(()) diff --git a/ethcore/engine/src/engine.rs b/ethcore/engine/src/engine.rs index 33c253357..815c14b38 100644 --- a/ethcore/engine/src/engine.rs +++ b/ethcore/engine/src/engine.rs @@ -31,6 +31,7 @@ use common_types::{ machine::{AuxiliaryData, AuxiliaryRequest}, }, errors::{EthcoreError as Error, EngineError}, + snapshot::Snapshotting, transaction::{self, UnverifiedTransaction}, }; use client_traits::EngineClient; @@ -43,10 +44,7 @@ use machine::{ }; use vm::{EnvInfo, Schedule, CallType, ActionValue}; -use crate::{ - signer::EngineSigner, - snapshot::SnapshotComponents, -}; +use crate::signer::EngineSigner; /// A system-calling closure. Enacts calls on a block's state from the system address. pub type SystemCall<'a> = dyn FnMut(Address, Vec) -> Result, String> + 'a; @@ -306,16 +304,8 @@ pub trait Engine: Sync + Send { /// Trigger next step of the consensus engine. fn step(&self) {} - /// Create a factory for building snapshot chunks and restoring from them. - /// Returning `None` indicates that this engine doesn't support snapshot creation. - fn snapshot_components(&self) -> Option> { - None - } - - /// Whether this engine supports warp sync. - fn supports_warp(&self) -> bool { - self.snapshot_components().is_some() - } + /// Snapshot mode for the engine: Unsupported, PoW or PoA + fn snapshot_mode(&self) -> Snapshotting { Snapshotting::Unsupported } /// Return a new open block header timestamp based on the parent timestamp. fn open_block_header_timestamp(&self, parent_timestamp: u64) -> u64 { diff --git a/ethcore/engine/src/lib.rs b/ethcore/engine/src/lib.rs index 5b3c93bf6..0ee5e313d 100644 --- a/ethcore/engine/src/lib.rs +++ b/ethcore/engine/src/lib.rs @@ -18,7 +18,6 @@ mod engine; pub mod signer; -pub mod snapshot; pub use crate::engine::{ Engine, diff --git a/ethcore/engines/authority-round/Cargo.toml b/ethcore/engines/authority-round/Cargo.toml new file mode 100644 index 000000000..e3b0f8b4a --- /dev/null +++ b/ethcore/engines/authority-round/Cargo.toml @@ -0,0 +1,39 @@ +[package] +description = "Non-instant BFT proof-of-authority blockchain engine" +name = "authority-round" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2018" +license = "GPL-3.0" + +[dependencies] +block-reward = { path = "../../block-reward" } +client-traits = { path = "../../client-traits" } +common-types = { path = "../../types" } +ethereum-types = "0.6.0" +ethjson = { path = "../../../json" } +ethkey = { path = "../../../accounts/ethkey" } +engine = { path = "../../engine" } +io = { package = "ethcore-io", path = "../../../util/io" } +itertools = "0.5" +keccak-hash = "0.2.0" +lazy_static = "1.3.0" +log = "0.4" +lru-cache = "0.1" +machine = { path = "../../machine" } +macros = { path = "../../../util/macros" } +parking_lot = "0.8" +rand = "0.6" +rlp = "0.4.0" +time-utils = { path = "../../../util/time-utils" } +unexpected = { path = "../../../util/unexpected" } +validator-set = { path = "../validator-set" } + +[dev-dependencies] +accounts = { package = "ethcore-accounts", path = "../../../accounts" } +engine = { path = "../../engine", features = ["test-helpers"] } +env_logger = "0.6.2" +ethcore = { path = "../..", features = ["test-helpers"] } +state-db = { path = "../../state-db" } +validator-set = { path = "../validator-set", features = ["test-helpers"] } +serde_json = "1" diff --git a/ethcore/src/engines/authority_round/finality.rs b/ethcore/engines/authority-round/src/finality.rs similarity index 98% rename from ethcore/src/engines/authority_round/finality.rs rename to ethcore/engines/authority-round/src/finality.rs index 76b086efc..e0a896253 100644 --- a/ethcore/src/engines/authority_round/finality.rs +++ b/ethcore/engines/authority-round/src/finality.rs @@ -19,10 +19,10 @@ use std::collections::{VecDeque}; use std::collections::hash_map::{HashMap, Entry}; +use common_types::BlockNumber; use ethereum_types::{H256, Address}; -use types::BlockNumber; - -use engines::validator_set::SimpleList; +use log::{trace, warn}; +use validator_set::SimpleList; /// Error indicating unknown validator. #[derive(Debug, PartialEq, Eq, Clone, Copy)] @@ -179,8 +179,8 @@ impl RollingFinality { #[cfg(test)] mod tests { + use common_types::BlockNumber; use ethereum_types::{H256, Address}; - use types::BlockNumber; use super::RollingFinality; #[test] diff --git a/ethcore/src/engines/authority_round/mod.rs b/ethcore/engines/authority-round/src/lib.rs similarity index 99% rename from ethcore/src/engines/authority_round/mod.rs rename to ethcore/engines/authority-round/src/lib.rs index 49b912c5a..8a41979f7 100644 --- a/ethcore/src/engines/authority_round/mod.rs +++ b/ethcore/engines/authority-round/src/lib.rs @@ -29,19 +29,17 @@ use std::sync::{Weak, Arc}; use std::time::{UNIX_EPOCH, Duration}; use client_traits::EngineClient; -use engine::{Engine,ConstructedVerifier}; -use engines::block_reward; -use engines::block_reward::{BlockRewardContract, RewardKind}; -use engine::snapshot::SnapshotComponents; +use engine::{Engine, ConstructedVerifier}; +use block_reward::{self, BlockRewardContract, RewardKind}; use ethjson; use machine::{ ExecutedBlock, Machine, }; -use hash::keccak; +use macros::map; +use keccak_hash::keccak; +use log::{info, debug, error, trace, warn}; use engine::signer::EngineSigner; -use super::validator_set::{ValidatorSet, SimpleList, new_validator_set}; -use self::finality::RollingFinality; use ethkey::{self, Signature}; use io::{IoContext, IoHandler, TimerToken, IoService}; use itertools::{self, Itertools}; @@ -49,7 +47,7 @@ use rlp::{encode, Decodable, DecoderError, Encodable, RlpStream, Rlp}; use ethereum_types::{H256, H520, Address, U128, U256}; use parking_lot::{Mutex, RwLock}; use time_utils::CheckedSystemTime; -use types::{ +use common_types::{ ancestry_action::AncestryAction, BlockNumber, header::{Header, ExtendedHeader}, @@ -62,11 +60,16 @@ use types::{ machine::{Call, AuxiliaryData}, }, errors::{BlockError, EthcoreError as Error, EngineError}, + snapshot::Snapshotting, }; use unexpected::{Mismatch, OutOfBounds}; +use validator_set::{ValidatorSet, SimpleList, new_validator_set}; + mod finality; +use self::finality::RollingFinality; + /// `AuthorityRound` params. pub struct AuthorityRoundParams { /// Time to wait before next block or authority switching, @@ -1631,11 +1634,11 @@ impl Engine for AuthorityRound { ) } - fn snapshot_components(&self) -> Option> { + fn snapshot_mode(&self) -> Snapshotting { if self.immediate_transitions { - None + Snapshotting::Unsupported } else { - Some(Box::new(::snapshot::PoaSnapshot)) + Snapshotting::PoA } } @@ -1663,29 +1666,33 @@ mod tests { use std::str::FromStr; use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrdering}; - use hash::keccak; + use keccak_hash::keccak; use accounts::AccountProvider; use ethereum_types::{Address, H520, H256, U256}; use ethkey::Signature; - use types::{ + use common_types::{ header::Header, engines::{Seal, params::CommonParams}, errors::{EthcoreError as Error, EngineError}, transaction::{Action, Transaction}, }; use rlp::encode; - use block::*; - use test_helpers::{ - generate_dummy_client_with_spec, get_temp_state_db, - TestNotify + use ethcore::{ + block::*, + test_helpers::{ + generate_dummy_client_with_spec, get_temp_state_db, + TestNotify + }, + spec::{self, Spec}, }; - use crate::spec::{Spec, self}; use engine::Engine; - use engines::block_reward::BlockRewardContract; - use engines::validator_set::{TestSet, SimpleList}; - use super::{AuthorityRoundParams, AuthorityRound, EmptyStep, SealedEmptyStep, calculate_score}; + use block_reward::BlockRewardContract; + use validator_set::{TestSet, SimpleList}; use machine::Machine; use ethjson; + use serde_json; + + use super::{AuthorityRoundParams, AuthorityRound, EmptyStep, SealedEmptyStep, calculate_score}; fn build_aura(f: F) -> Arc where F: FnOnce(&mut AuthorityRoundParams), @@ -1719,7 +1726,7 @@ mod tests { #[test] fn has_valid_metadata() { let engine = spec::new_test_round().engine; - assert!(!engine.name().is_empty()); + assert_eq!(engine.name(), "AuthorityRound"); } #[test] diff --git a/ethcore/engines/basic-authority/Cargo.toml b/ethcore/engines/basic-authority/Cargo.toml new file mode 100644 index 000000000..2a5938c7e --- /dev/null +++ b/ethcore/engines/basic-authority/Cargo.toml @@ -0,0 +1,30 @@ +[package] +description = "Basic PoA blockchain engine." +name = "basic-authority" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2018" +license = "GPL-3.0" + +[dependencies] +client-traits = { path = "../../client-traits" } +common-types = { path = "../../types" } +engine = { path = "../../engine" } +ethereum-types = "0.6.0" +ethjson = { path = "../../../json" } +ethkey = { path = "../../../accounts/ethkey" } +log = "0.4.8" +machine = { path = "../../machine" } +parking_lot = "0.8" +rlp = "0.4.2" +validator-set = { path = "../validator-set" } + +[dev-dependencies] +accounts = { package = "ethcore-accounts", path = "../../../accounts" } +engine = { path = "../../engine", features = ["test-helpers"] } +ethcore = { path = "../..", features = ["test-helpers"] } +keccak-hash = "0.2.0" +tempdir = "0.3" + +[features] +test-helpers = [] diff --git a/ethcore/res/basic_authority.json b/ethcore/engines/basic-authority/res/basic_authority.json similarity index 100% rename from ethcore/res/basic_authority.json rename to ethcore/engines/basic-authority/res/basic_authority.json diff --git a/ethcore/src/engines/basic_authority.rs b/ethcore/engines/basic-authority/src/lib.rs similarity index 91% rename from ethcore/src/engines/basic_authority.rs rename to ethcore/engines/basic-authority/src/lib.rs index 55c8ab5e7..d17b01580 100644 --- a/ethcore/src/engines/basic_authority.rs +++ b/ethcore/engines/basic-authority/src/lib.rs @@ -17,22 +17,8 @@ //! A blockchain engine that supports a basic, non-BFT proof-of-authority. use std::sync::Weak; -use ethereum_types::{H256, H520}; -use parking_lot::RwLock; -use ethkey::{self, Signature}; -use engine::{ - Engine, - ConstructedVerifier, - snapshot::SnapshotComponents, - signer::EngineSigner, -}; -use ethjson; -use client_traits::EngineClient; -use machine::{ - Machine, - executed_block::ExecutedBlock, -}; -use types::{ + +use common_types::{ header::Header, engines::{ Headers, @@ -44,8 +30,16 @@ use types::{ }, errors::{EngineError, BlockError, EthcoreError as Error}, }; - -use super::validator_set::{ValidatorSet, SimpleList, new_validator_set}; +use client_traits::EngineClient; +use ethereum_types::{H256, H520}; +use parking_lot::RwLock; +use engine::{Engine, ConstructedVerifier, signer::EngineSigner}; +use ethkey::{self, Signature}; +use ethjson; +use log::trace; +use machine::{Machine, executed_block::ExecutedBlock}; +use rlp::Rlp; +use validator_set::{ValidatorSet, SimpleList, new_validator_set}; /// `BasicAuthority` params. #[derive(Debug, PartialEq)] @@ -73,8 +67,6 @@ impl engine::EpochVerifier for EpochVerifier { } fn verify_external(header: &Header, validators: &dyn ValidatorSet) -> Result<(), Error> { - use rlp::Rlp; - // Check if the signature belongs to a validator, can depend on parent state. let sig = Rlp::new(&header.seal()[0]).as_val::()?; let signer = ethkey::public_to_address(ðkey::recover(&sig.into(), &header.bare_hash())?); @@ -130,7 +122,7 @@ impl Engine for BasicAuthority { if self.validators.contains(header.parent_hash(), author) { // account should be pernamently unlocked, otherwise sealing will fail if let Ok(signature) = self.sign(header.bare_hash()) { - return Seal::Regular(vec![::rlp::encode(&(H520::from(signature).as_bytes()))]); + return Seal::Regular(vec![rlp::encode(&(H520::from(signature).as_bytes()))]); } else { trace!(target: "basicauthority", "generate_seal: FAIL: accounts secret key unavailable"); } @@ -150,13 +142,13 @@ impl Engine for BasicAuthority { self.validators.genesis_epoch_data(header, call) } - #[cfg(not(test))] + #[cfg(not(any(test, feature = "test-helpers")))] fn signals_epoch_end(&self, _header: &Header, _auxiliary: AuxiliaryData) -> engine::EpochChange { // don't bother signalling even though a contract might try. engine::EpochChange::No } - #[cfg(test)] + #[cfg(any(test, feature = "test-helpers"))] fn signals_epoch_end(&self, header: &Header, auxiliary: AuxiliaryData) -> engine::EpochChange { // in test mode, always signal even though they don't be finalized. let first = header.number() == 0; @@ -202,10 +194,6 @@ impl Engine for BasicAuthority { } } - fn register_client(&self, client: Weak) { - self.validators.register_client(client); - } - fn set_signer(&self, signer: Box) { *self.signer.write() = Some(signer); } @@ -218,8 +206,8 @@ impl Engine for BasicAuthority { ) } - fn snapshot_components(&self) -> Option> { - None + fn register_client(&self, client: Weak) { + self.validators.register_client(client); } fn params(&self) -> &CommonParams { @@ -230,19 +218,24 @@ impl Engine for BasicAuthority { #[cfg(test)] mod tests { use std::sync::Arc; - use hash::keccak; + use keccak_hash::keccak; use ethereum_types::H520; - use block::*; - use test_helpers::get_temp_state_db; + use ethcore::{ + block::*, + spec, + test_helpers::get_temp_state_db + }; use accounts::AccountProvider; - use types::header::Header; use spec::Spec; - use types::engines::{Seal, SealingState}; + use common_types::{ + header::Header, + engines::{Seal, SealingState} + }; use tempdir::TempDir; /// Create a new test chain spec with `BasicAuthority` consensus engine. fn new_test_authority() -> Spec { - let bytes: &[u8] = include_bytes!("../../res/basic_authority.json"); + let bytes: &[u8] = include_bytes!("../res/basic_authority.json"); let tempdir = TempDir::new("").unwrap(); Spec::load(&tempdir.path(), bytes).expect("invalid chain spec") } @@ -250,7 +243,7 @@ mod tests { #[test] fn has_valid_metadata() { let engine = new_test_authority().engine; - assert!(!engine.name().is_empty()); + assert_eq!(engine.name(), "BasicAuthority"); } #[test] @@ -264,7 +257,7 @@ mod tests { fn can_do_signature_verification_fail() { let engine = new_test_authority().engine; let mut header: Header = Header::default(); - header.set_seal(vec![::rlp::encode(&H520::default())]); + header.set_seal(vec![rlp::encode(&H520::default())]); let verify_result = engine.verify_block_external(&header); assert!(verify_result.is_err()); diff --git a/ethcore/engines/clique/Cargo.toml b/ethcore/engines/clique/Cargo.toml new file mode 100644 index 000000000..516303102 --- /dev/null +++ b/ethcore/engines/clique/Cargo.toml @@ -0,0 +1,30 @@ +[package] +description = "Clique consensus engine" +name = "clique" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2018" +license = "GPL-3.0" + +[dependencies] +client-traits = { path = "../../client-traits" } +common-types = { path = "../../types" } +ethereum-types = "0.6.0" +ethjson = { path = "../../../json" } +ethkey = { path = "../../../accounts/ethkey" } +engine = { path = "../../engine" } +keccak-hash = "0.2.0" +lazy_static = "1.3.0" +log = "0.4" +lru-cache = "0.1" +machine = { path = "../../machine" } +macros = { path = "../../../util/macros" } +parking_lot = "0.8" +rand = "0.6" +rlp = "0.4.0" +time-utils = { path = "../../../util/time-utils" } +unexpected = { path = "../../../util/unexpected" } + +[dev-dependencies] +ethcore = { path = "../..", features = ["test-helpers"] } +state-db = { path = "../../state-db" } diff --git a/ethcore/src/engines/clique/block_state.rs b/ethcore/engines/clique/src/block_state.rs similarity index 97% rename from ethcore/src/engines/clique/block_state.rs rename to ethcore/engines/clique/src/block_state.rs index 787dd53dc..b4c73b243 100644 --- a/ethcore/src/engines/clique/block_state.rs +++ b/ethcore/engines/clique/src/block_state.rs @@ -14,22 +14,28 @@ // You should have received a copy of the GNU General Public License // along with Parity Ethereum. If not, see . -use std::collections::{HashMap, BTreeSet, VecDeque}; -use std::fmt; -use std::time::{Duration, SystemTime, UNIX_EPOCH}; +use std::{ + collections::{HashMap, BTreeSet, VecDeque}, + fmt, + time::{Duration, SystemTime, UNIX_EPOCH}, +}; -use engines::clique::util::{extract_signers, recover_creator}; -use engines::clique::{VoteType, DIFF_INTURN, DIFF_NOTURN, NULL_AUTHOR, SIGNING_DELAY_NOTURN_MS}; -use ethereum_types::{Address, H64}; -use rand::Rng; -use time_utils::CheckedSystemTime; -use types::{ +use common_types::{ BlockNumber, header::Header, errors::{BlockError, EthcoreError as Error, EngineError}, }; +use ethereum_types::{Address, H64}; +use log::{debug, trace}; +use rand::Rng; +use time_utils::CheckedSystemTime; use unexpected::Mismatch; +use crate::{ + util::{extract_signers, recover_creator}, + {VoteType, DIFF_INTURN, DIFF_NOTURN, NULL_AUTHOR, SIGNING_DELAY_NOTURN_MS}, +}; + /// Type that keeps track of the state for a given vote // Votes that go against the proposal aren't counted since it's equivalent to not voting #[derive(Copy, Clone, Debug, PartialEq, PartialOrd)] diff --git a/ethcore/src/engines/clique/mod.rs b/ethcore/engines/clique/src/lib.rs similarity index 97% rename from ethcore/src/engines/clique/mod.rs rename to ethcore/engines/clique/src/lib.rs index 3f249f42a..15b9bdea3 100644 --- a/ethcore/src/engines/clique/mod.rs +++ b/ethcore/engines/clique/src/lib.rs @@ -58,40 +58,39 @@ /// 7. Finally, `Clique::verify_local_seal()` is called. After this, the syncing code path will be followed /// in order to import the new block. -use std::cmp; -use std::collections::{HashMap, VecDeque, BTreeMap}; -use std::sync::{Arc, Weak}; -use std::thread; -use std::time; -use std::time::{Instant, Duration, SystemTime, UNIX_EPOCH}; +use std::{ + cmp, + collections::{HashMap, VecDeque, BTreeMap}, + sync::{Arc, Weak}, + thread, + time::{self, Instant, Duration, SystemTime, UNIX_EPOCH}, +}; use client_traits::EngineClient; -use engines::{ - clique::util::{extract_signers, recover_creator}, - EthashSeal, -}; use engine::{ Engine, signer::EngineSigner, }; use ethereum_types::{Address, H64, H160, H256, U256}; use ethkey::Signature; -use hash::KECCAK_EMPTY_LIST_RLP; -use itertools::Itertools; +use keccak_hash::KECCAK_EMPTY_LIST_RLP; +use log::{trace, warn}; use lru_cache::LruCache; use machine::{ ExecutedBlock, Machine, }; +use macros::map; use parking_lot::RwLock; use rand::Rng; use unexpected::{Mismatch, OutOfBounds}; use time_utils::CheckedSystemTime; -use types::{ +use common_types::{ BlockNumber, ids::BlockId, header::Header, engines::{ + EthashSeal, Seal, SealingState, params::CommonParams, @@ -100,8 +99,12 @@ use types::{ errors::{BlockError, EthcoreError as Error, EngineError}, }; -use self::block_state::CliqueBlockState; -use self::params::CliqueParams; +use crate::{ + util::{extract_signers, recover_creator}, + block_state::CliqueBlockState, + params::CliqueParams, +}; + mod params; mod block_state; @@ -214,7 +217,7 @@ impl Clique { thread::Builder::new().name("StepService".into()) .spawn(move || { loop { - let next_step_at = Instant::now() + SEALING_FREQ; + let next_step_at = Instant::now() + SEALING_FREQ; trace!(target: "miner", "StepService: triggering sealing"); if let Some(eng) = weak_eng.upgrade() { eng.step() @@ -237,7 +240,7 @@ 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 crate::spec; + use ethcore::spec; Self { epoch_length, @@ -424,7 +427,7 @@ impl Engine for Clique { let votes = self.proposals.read().iter() .filter(|(address, vote_type)| state.is_valid_vote(*address, **vote_type)) .map(|(address, vote_type)| (*address, *vote_type)) - .collect_vec(); + .collect::>(); if !votes.is_empty() { // Pick a random vote. @@ -458,9 +461,9 @@ impl Engine for Clique { // If we are building an checkpoint block, add all signers now. if is_checkpoint { seal.reserve(state.signers().len() * 20); - state.signers().iter().foreach(|addr| { - seal.extend_from_slice(&addr[..]); - }); + for signer in state.signers() { + seal.extend_from_slice(&signer[..]); + } } header.set_extra_data(seal.clone()); diff --git a/ethcore/src/engines/clique/params.rs b/ethcore/engines/clique/src/params.rs similarity index 100% rename from ethcore/src/engines/clique/params.rs rename to ethcore/engines/clique/src/params.rs diff --git a/ethcore/src/engines/clique/tests.rs b/ethcore/engines/clique/src/tests.rs similarity index 99% rename from ethcore/src/engines/clique/tests.rs rename to ethcore/engines/clique/src/tests.rs index e1954a13f..90ed67fcf 100644 --- a/ethcore/src/engines/clique/tests.rs +++ b/ethcore/engines/clique/src/tests.rs @@ -16,17 +16,20 @@ //! Consensus tests for `PoA Clique Engine`, see http://eips.ethereum.org/EIPS/eip-225 for more information -use block::*; +use std::sync::Arc; +use std::collections::HashMap; + +use common_types::errors::{EthcoreError as Error, EngineError}; +use ethcore::{ + block::*, + test_helpers::get_temp_state_db, +}; use engine::Engine; use ethereum_types::{Address, H256}; use ethkey::{Secret, KeyPair}; use state_db::StateDB; -use super::*; -use test_helpers::get_temp_state_db; -use types::errors::{EthcoreError as Error, EngineError}; -use std::sync::Arc; -use std::collections::HashMap; +use super::*; /// Possible signers pub const SIGNER_TAGS: [char; 6] = ['A', 'B', 'C', 'D', 'E', 'F']; diff --git a/ethcore/src/engines/clique/util.rs b/ethcore/engines/clique/src/util.rs similarity index 96% rename from ethcore/src/engines/clique/util.rs rename to ethcore/engines/clique/src/util.rs index afa0a73bf..007f49a2c 100644 --- a/ethcore/src/engines/clique/util.rs +++ b/ethcore/engines/clique/src/util.rs @@ -16,16 +16,17 @@ use std::collections::BTreeSet; -use engines::clique::{ADDRESS_LENGTH, SIGNATURE_LENGTH, VANITY_LENGTH, NULL_NONCE, NULL_MIXHASH}; -use ethereum_types::{Address, H256}; -use ethkey::{public_to_address, recover as ec_recover, Signature}; -use lru_cache::LruCache; -use parking_lot::RwLock; -use rlp::encode; -use types::{ +use common_types::{ header::Header, errors::{EthcoreError as Error, EngineError}, }; +use ethereum_types::{Address, H256}; +use ethkey::{public_to_address, recover as ec_recover, Signature}; +use lazy_static::lazy_static; +use lru_cache::LruCache; +use parking_lot::RwLock; +use rlp::encode; +use crate::{ADDRESS_LENGTH, SIGNATURE_LENGTH, VANITY_LENGTH, NULL_NONCE, NULL_MIXHASH}; /// How many recovered signature to cache in the memory. pub const CREATOR_CACHE_NUM: usize = 4096; diff --git a/ethcore/engines/ethash/Cargo.toml b/ethcore/engines/ethash/Cargo.toml new file mode 100644 index 000000000..648b3a15d --- /dev/null +++ b/ethcore/engines/ethash/Cargo.toml @@ -0,0 +1,26 @@ +[package] +description = "Ethash PoW blockchain engine" +name = "ethash-engine" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2018" +license = "GPL-3.0" + +[dependencies] +block-reward = { path = "../../block-reward" } +common-types = { path = "../../types" } +engine = { path = "../../engine" } +ethash= { path = "../../../ethash" } +ethereum-types = "0.6.0" +ethjson = { path = "../../../json" } +keccak-hash = "0.2.0" +log = "0.4.8" +machine = { path = "../../machine" } +macros = { path = "../../../util/macros" } +unexpected = { path = "../../../util/unexpected" } + +[dev-dependencies] +ethcore = { path = "../..", features = ["test-helpers"] } +keccak-hash = "0.2.0" +rlp = "0.4.2" +tempdir = "0.3" diff --git a/ethcore/src/engines/ethash.rs b/ethcore/engines/ethash/src/lib.rs similarity index 95% rename from ethcore/src/engines/ethash.rs rename to ethcore/engines/ethash/src/lib.rs index df75ae816..498978f2a 100644 --- a/ethcore/src/engines/ethash.rs +++ b/ethcore/engines/ethash/src/lib.rs @@ -19,27 +19,29 @@ use std::collections::BTreeMap; use std::path::Path; use std::sync::Arc; -use engine::snapshot::SnapshotComponents; -use ethereum_types::{H256, H64, U256}; -use ethjson; -use hash::{KECCAK_EMPTY_LIST_RLP}; -use rlp::Rlp; -use types::{ +use block_reward::{self, BlockRewardContract, RewardKind}; +use common_types::{ BlockNumber, header::Header, - engines::params::CommonParams, + engines::{ + EthashSeal, + params::CommonParams, + }, errors::{BlockError, EthcoreError as Error}, + snapshot::Snapshotting, }; - -use unexpected::{OutOfBounds, Mismatch}; - -use engines::block_reward::{self, BlockRewardContract, RewardKind}; use engine::Engine; +use ethereum_types::{H256, U256}; +use ethjson; use ethash::{self, quick_get_difficulty, slow_hash_block_number, EthashManager, OptimizeFor}; +use keccak_hash::{KECCAK_EMPTY_LIST_RLP}; +use log::trace; +use macros::map; use machine::{ ExecutedBlock, Machine, }; +use unexpected::{OutOfBounds, Mismatch}; /// Number of blocks in an ethash snapshot. // make dependent on difficulty increment divisor? @@ -47,38 +49,6 @@ const SNAPSHOT_BLOCKS: u64 = 5000; /// Maximum number of blocks allowed in an ethash snapshot. const MAX_SNAPSHOT_BLOCKS: u64 = 30000; -/// Ethash specific seal -#[derive(Debug, PartialEq)] -pub struct Seal { - /// Ethash seal mix_hash - pub mix_hash: H256, - /// Ethash seal nonce - pub nonce: H64, -} - -impl Seal { - /// Tries to parse rlp as ethash seal. - pub fn parse_seal>(seal: &[T]) -> Result { - if seal.len() != 2 { - return Err(BlockError::InvalidSealArity( - Mismatch { - expected: 2, - found: seal.len() - } - ).into()); - } - - let mix_hash = Rlp::new(seal[0].as_ref()).as_val::()?; - let nonce = Rlp::new(seal[1].as_ref()).as_val::()?; - let seal = Seal { - mix_hash, - nonce, - }; - - Ok(seal) - } -} - /// Ethash params. #[derive(Debug, PartialEq)] pub struct EthashParams { @@ -207,7 +177,7 @@ impl Ethash { } fn verify_block_unordered(pow: &Arc, header: &Header) -> Result<(), Error> { - let seal = Seal::parse_seal(header.seal())?; + let seal = EthashSeal::parse_seal(header.seal())?; let result = pow.compute_light( header.number() as u64, @@ -253,6 +223,7 @@ impl engine::EpochVerifier for EpochVerifier { impl Engine for Ethash { fn name(&self) -> &str { "Ethash" } + fn machine(&self) -> &Machine { &self.machine } // Two fields - nonce and mix. @@ -260,7 +231,7 @@ impl Engine for Ethash { /// Additional engine-specific information for the user/developer concerning `header`. fn extra_info(&self, header: &Header) -> BTreeMap { - match Seal::parse_seal(header.seal()) { + match EthashSeal::parse_seal(header.seal()) { Ok(seal) => map![ "nonce".to_owned() => format!("0x{:x}", seal.nonce), "mixHash".to_owned() => format!("0x{:x}", seal.mix_hash) @@ -350,7 +321,7 @@ impl Engine for Ethash { fn verify_block_basic(&self, header: &Header) -> Result<(), Error> { // check the seal fields. - let seal = Seal::parse_seal(header.seal())?; + let seal = EthashSeal::parse_seal(header.seal())?; // TODO: consider removing these lines. let min_difficulty = self.ethash_params.minimum_difficulty; @@ -401,8 +372,11 @@ impl Engine for Ethash { header.set_difficulty(difficulty); } - fn snapshot_components(&self) -> Option> { - Some(Box::new(::snapshot::PowSnapshot::new(SNAPSHOT_BLOCKS, MAX_SNAPSHOT_BLOCKS))) + fn snapshot_mode(&self) -> Snapshotting { + Snapshotting::PoW { + blocks: SNAPSHOT_BLOCKS, + max_restore_blocks: MAX_SNAPSHOT_BLOCKS + } } fn params(&self) -> &CommonParams { self.machine.params() } @@ -509,20 +483,23 @@ mod tests { use std::str::FromStr; use std::sync::Arc; use std::collections::BTreeMap; - use ethereum_types::{H64, H256, U256, Address}; - use block::*; - use test_helpers::get_temp_state_db; - use types::{ + + use common_types::{ header::Header, - errors::{BlockError, EthcoreError as Error}, + errors::{BlockError, EthcoreError as Error} }; - use spec::Spec; use engine::Engine; - use crate::spec::{new_morden, new_mcip3_test, new_homestead_test_machine}; - use super::{Ethash, EthashParams, ecip1017_eras_block_reward}; + use ethereum_types::{H64, H256, U256, Address}; + use ethcore::{ + block::*, + test_helpers::get_temp_state_db, + spec::{new_morden, new_mcip3_test, new_homestead_test_machine, Spec}, + }; use rlp; use tempdir::TempDir; + use super::{Ethash, EthashParams, ecip1017_eras_block_reward}; + fn test_spec() -> Spec { let tempdir = TempDir::new("").unwrap(); new_morden(&tempdir.path()) @@ -644,7 +621,7 @@ mod tests { #[test] fn has_valid_metadata() { let engine = test_spec().engine; - assert!(!engine.name().is_empty()); + assert_eq!(engine.name(), "Ethash"); } #[test] diff --git a/ethcore/engines/instant-seal/Cargo.toml b/ethcore/engines/instant-seal/Cargo.toml new file mode 100644 index 000000000..c456ce906 --- /dev/null +++ b/ethcore/engines/instant-seal/Cargo.toml @@ -0,0 +1,20 @@ +[package] +description = "Engine that seals instantly" +name = "instant-seal" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2018" +license = "GPL-3.0" + +[dependencies] +common-types = { path = "../../types" } +engine = { path = "../../engine" } +ethjson = { path = "../../../json" } +ethereum-types = "0.6.0" +keccak-hash = "0.2.0" +machine = { path = "../../machine" } +trace = { path = "../../trace" } + +[dev-dependencies] +ethcore = { path = "../..", features = ["test-helpers"] } +rlp = "0.4.2" diff --git a/ethcore/src/engines/instant_seal.rs b/ethcore/engines/instant-seal/src/lib.rs similarity index 91% rename from ethcore/src/engines/instant_seal.rs rename to ethcore/engines/instant-seal/src/lib.rs index d786176bd..99d859d58 100644 --- a/ethcore/src/engines/instant_seal.rs +++ b/ethcore/engines/instant-seal/src/lib.rs @@ -14,12 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Ethereum. If not, see . -use engine::Engine; -use machine::{ - ExecutedBlock, - Machine -}; -use types::{ +use common_types::{ header::Header, engines::{ Seal, @@ -28,6 +23,12 @@ use types::{ }, errors::EthcoreError as Error, }; +use engine::Engine; +use ethjson; +use machine::{ + ExecutedBlock, + Machine +}; /// `InstantSeal` params. @@ -37,8 +38,8 @@ pub struct InstantSealParams { pub millisecond_timestamp: bool, } -impl From<::ethjson::spec::InstantSealParams> for InstantSealParams { - fn from(p: ::ethjson::spec::InstantSealParams) -> Self { +impl From for InstantSealParams { + fn from(p: ethjson::spec::InstantSealParams) -> Self { InstantSealParams { millisecond_timestamp: p.millisecond_timestamp, } @@ -63,9 +64,7 @@ impl InstantSeal { } impl Engine for InstantSeal { - fn name(&self) -> &str { - "InstantSeal" - } + fn name(&self) -> &str { "InstantSeal" } fn machine(&self) -> &Machine { &self.machine } @@ -108,14 +107,16 @@ impl Engine for InstantSeal { #[cfg(test)] mod tests { use std::sync::Arc; - use ethereum_types::{H520, Address}; - use test_helpers::get_temp_state_db; - use crate::spec; - use types::{ + use common_types::{ header::Header, engines::Seal, }; - use block::*; + use ethereum_types::{H520, Address}; + use ethcore::{ + test_helpers::get_temp_state_db, + spec, + block::*, + }; #[test] fn instant_can_seal() { @@ -138,7 +139,7 @@ mod tests { assert!(engine.verify_block_basic(&header).is_ok()); - header.set_seal(vec![::rlp::encode(&H520::default())]); + header.set_seal(vec![rlp::encode(&H520::default())]); assert!(engine.verify_block_unordered(&header).is_ok()); } diff --git a/ethcore/engines/null-engine/Cargo.toml b/ethcore/engines/null-engine/Cargo.toml new file mode 100644 index 000000000..b0822d3d7 --- /dev/null +++ b/ethcore/engines/null-engine/Cargo.toml @@ -0,0 +1,15 @@ +[package] +description = "An ethereum engine which does not provide any consensus mechanism and does not seal blocks." +name = "null-engine" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2018" +license = "GPL-3.0" + +[dependencies] +common-types = { path = "../../types" } +block-reward = { path = "../../block-reward" } +engine = { path = "../../engine" } +ethjson = { path = "../../../json" } +ethereum-types = "0.6.0" +machine = { path = "../../machine" } diff --git a/ethcore/src/engines/null_engine.rs b/ethcore/engines/null-engine/src/lib.rs similarity index 86% rename from ethcore/src/engines/null_engine.rs rename to ethcore/engines/null-engine/src/lib.rs index 37e4e2ce6..64b39cc97 100644 --- a/ethcore/src/engines/null_engine.rs +++ b/ethcore/engines/null-engine/src/lib.rs @@ -14,20 +14,20 @@ // You should have received a copy of the GNU General Public License // along with Parity Ethereum. If not, see . -use engine::snapshot::SnapshotComponents; -use engine::Engine; -use engines::block_reward::{self, RewardKind}; -use ethereum_types::U256; -use machine::{ - ExecutedBlock, - Machine, -}; -use types::{ +use common_types::{ BlockNumber, header::Header, engines::params::CommonParams, errors::EthcoreError as Error, }; +use engine::Engine; +use block_reward::{self, RewardKind}; +use ethereum_types::U256; +use machine::{ + ExecutedBlock, + Machine, +}; +use common_types::snapshot::Snapshotting; /// Params for a null engine. #[derive(Clone, Default)] @@ -36,8 +36,8 @@ pub struct NullEngineParams { pub block_reward: U256, } -impl From<::ethjson::spec::NullEngineParams> for NullEngineParams { - fn from(p: ::ethjson::spec::NullEngineParams) -> Self { +impl From for NullEngineParams { + fn from(p: ethjson::spec::NullEngineParams) -> Self { NullEngineParams { block_reward: p.block_reward.map_or_else(Default::default, Into::into), } @@ -59,11 +59,8 @@ impl NullEngine { } } } - impl Engine for NullEngine { - fn name(&self) -> &str { - "NullEngine" - } + fn name(&self) -> &str { "NullEngine" } fn machine(&self) -> &Machine { &self.machine } @@ -104,8 +101,8 @@ impl Engine for NullEngine { Ok(()) } - fn snapshot_components(&self) -> Option> { - Some(Box::new(::snapshot::PowSnapshot::new(10000, 10000))) + fn snapshot_mode(&self) -> Snapshotting { + Snapshotting::PoW { blocks: 10_000, max_restore_blocks: 10_000 } } fn params(&self) -> &CommonParams { diff --git a/ethcore/engines/validator-set/Cargo.toml b/ethcore/engines/validator-set/Cargo.toml new file mode 100644 index 000000000..aeeb2f081 --- /dev/null +++ b/ethcore/engines/validator-set/Cargo.toml @@ -0,0 +1,44 @@ +[package] +description = "Manage validators and sets of validators: creation, calling and validation of contracts, epoch management, proofs and proving" +name = "validator-set" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2018" +license = "GPL-3.0" + +[dependencies] +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" +ethereum-types = "0.6.0" +ethjson = { path = "../../../json" } +executive-state = { path = "../../executive-state" } +keccak-hash = "0.2.0" +kvdb = "0.1.0" +lazy_static = "1.3.0" +log = "0.4.8" +machine = { path = "../../machine" } +memory-cache = { path = "../../../util/memory-cache" } +parity-bytes = "0.1.0" +parity-util-mem = "0.2.0" +parking_lot = "0.8" +rlp = "0.4.2" +triehash = { package = "triehash-ethereum", version = "0.2", path = "../../../util/triehash-ethereum" } +unexpected = { path = "../../../util/unexpected" } +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" } +env_logger = "0.6.2" + +[features] +test-helpers = [] diff --git a/ethcore/res/contracts/validator_report.json b/ethcore/engines/validator-set/res/validator_report.json similarity index 100% rename from ethcore/res/contracts/validator_report.json rename to ethcore/engines/validator-set/res/validator_report.json diff --git a/ethcore/res/contracts/validator_set.json b/ethcore/engines/validator-set/res/validator_set.json similarity index 100% rename from ethcore/res/contracts/validator_set.json rename to ethcore/engines/validator-set/res/validator_set.json diff --git a/ethcore/src/engines/validator_set/contract.rs b/ethcore/engines/validator-set/src/contract.rs similarity index 93% rename from ethcore/src/engines/validator_set/contract.rs rename to ethcore/engines/validator-set/src/contract.rs index bf9769556..07b70f4a3 100644 --- a/ethcore/src/engines/validator_set/contract.rs +++ b/ethcore/engines/validator-set/src/contract.rs @@ -19,12 +19,15 @@ use std::sync::Weak; -use bytes::Bytes; +use parity_bytes::Bytes; +use ethabi_contract::use_contract; use ethereum_types::{H256, Address}; +use log::{warn, trace}; use machine::Machine; use parking_lot::RwLock; -use types::{ +use common_types::{ BlockNumber, + ids::BlockId, header::Header, errors::EthcoreError, engines::machine::{Call, AuxiliaryData}, @@ -33,10 +36,12 @@ use types::{ use client_traits::EngineClient; use engine::SystemCall; -use super::{ValidatorSet, SimpleList}; -use super::safe_contract::ValidatorSafeContract; +use crate::{ + ValidatorSet, SimpleList, + safe_contract::ValidatorSafeContract +}; -use_contract!(validator_report, "res/contracts/validator_report.json"); +use_contract!(validator_report, "res/validator_report.json"); /// A validator contract with reporting. pub struct ValidatorContract { @@ -73,7 +78,7 @@ impl ValidatorContract { } impl ValidatorSet for ValidatorContract { - fn default_caller(&self, id: ::types::ids::BlockId) -> Box { + fn default_caller(&self, id: BlockId) -> Box { self.validators.default_caller(id) } @@ -140,21 +145,22 @@ impl ValidatorSet for ValidatorContract { #[cfg(test)] mod tests { use std::sync::Arc; - use rustc_hex::FromHex; - use hash::keccak; - use ethereum_types::{H520, Address}; - use bytes::ToPretty; - use rlp::encode; - use crate::spec; - use types::{ - header::Header, - ids::BlockId, + + use common_types::{header::Header, ids::BlockId}; + use ethcore::{ + miner::{self, MinerService}, + spec, + test_helpers::generate_dummy_client_with_spec, }; + use ethereum_types::{H520, Address}; + use keccak_hash::keccak; + use parity_bytes::ToPretty; + use rlp::encode; + use rustc_hex::FromHex; use accounts::AccountProvider; - use miner::{self, MinerService}; - use test_helpers::generate_dummy_client_with_spec; use call_contract::CallContract; use client_traits::{BlockChainClient, ChainInfo, BlockInfo}; + use super::super::ValidatorSet; use super::ValidatorContract; diff --git a/ethcore/src/engines/validator_set/mod.rs b/ethcore/engines/validator-set/src/lib.rs similarity index 96% rename from ethcore/src/engines/validator_set/mod.rs rename to ethcore/engines/validator-set/src/lib.rs index 27f11f4e2..ca8d708f1 100644 --- a/ethcore/src/engines/validator_set/mod.rs +++ b/ethcore/engines/validator-set/src/lib.rs @@ -16,7 +16,7 @@ /// Validator lists. -#[cfg(test)] +#[cfg(any(test, feature = "test-helpers"))] mod test; mod simple_list; mod safe_contract; @@ -25,21 +25,23 @@ mod multi; use std::sync::Weak; -use bytes::Bytes; use client_traits::EngineClient; -use engine::SystemCall; -use ethereum_types::{H256, Address}; -use ethjson::spec::ValidatorSet as ValidatorSpec; -use machine::Machine; -use types::{ +use common_types::{ BlockNumber, header::Header, ids::BlockId, errors::EthcoreError, engines::machine::{Call, AuxiliaryData}, }; +use engine::SystemCall; +use ethereum_types::{H256, Address}; +use ethjson::spec::ValidatorSet as ValidatorSpec; +use machine::Machine; +// The MallocSizeOf derive looks for this in the root +use parity_util_mem as malloc_size_of; +use parity_bytes::Bytes; -#[cfg(test)] +#[cfg(any(test, feature = "test-helpers"))] pub use self::test::TestSet; pub use self::simple_list::SimpleList; diff --git a/ethcore/src/engines/validator_set/multi.rs b/ethcore/engines/validator-set/src/multi.rs similarity index 96% rename from ethcore/src/engines/validator_set/multi.rs rename to ethcore/engines/validator-set/src/multi.rs index 9e44430f4..a9fa6e8dc 100644 --- a/ethcore/src/engines/validator_set/multi.rs +++ b/ethcore/engines/validator-set/src/multi.rs @@ -19,19 +19,20 @@ use std::collections::BTreeMap; use std::sync::Weak; -use bytes::Bytes; -use ethereum_types::{H256, Address}; -use parking_lot::RwLock; -use types::{ +use common_types::{ BlockNumber, header::Header, ids::BlockId, errors::EthcoreError, engines::machine::{Call, AuxiliaryData}, }; - use client_traits::EngineClient; +use ethereum_types::{H256, Address}; +use log::{debug, trace}; +use parity_bytes::Bytes; +use parking_lot::RwLock; use machine::Machine; + use super::{SystemCall, ValidatorSet}; type BlockNumberLookup = Box Result + Send + Sync + 'static>; @@ -153,22 +154,26 @@ impl ValidatorSet for Multi { mod tests { use std::sync::Arc; use std::collections::BTreeMap; - use hash::keccak; + use accounts::AccountProvider; use client_traits::{BlockChainClient, BlockInfo, ChainInfo, ImportBlock, EngineClient}; - use engine::EpochChange; - use engines::validator_set::ValidatorSet; - use ethkey::Secret; - use types::header::Header; - use miner::{self, MinerService}; - use crate::spec; - use test_helpers::{generate_dummy_client_with_spec, generate_dummy_client_with_spec_and_data}; - use types::{ + use common_types::{ + header::Header, ids::BlockId, verification::Unverified, }; - use ethereum_types::Address; + 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 keccak_hash::keccak; + + use crate::ValidatorSet; use super::Multi; #[test] diff --git a/ethcore/src/engines/validator_set/safe_contract.rs b/ethcore/engines/validator-set/src/safe_contract.rs similarity index 95% rename from ethcore/src/engines/validator_set/safe_contract.rs rename to ethcore/engines/validator-set/src/safe_contract.rs index 08f03c7a4..8ae43a03d 100644 --- a/ethcore/src/engines/validator_set/safe_contract.rs +++ b/ethcore/engines/validator-set/src/safe_contract.rs @@ -18,15 +18,9 @@ use std::sync::{Weak, Arc}; -use bytes::Bytes; -use ethabi::FunctionOutputDecoder; -use ethereum_types::{H256, U256, Address, Bloom}; -use hash::keccak; -use kvdb::DBValue; -use memory_cache::MemoryLruCache; -use parking_lot::RwLock; -use rlp::{Rlp, RlpStream}; -use types::{ +use client_traits::EngineClient; +use common_types::{ + BlockNumber, header::Header, errors::{EngineError, EthcoreError, BlockError}, ids::BlockId, @@ -34,14 +28,24 @@ use types::{ engines::machine::{Call, AuxiliaryData, AuxiliaryRequest}, receipt::Receipt, }; +use ethabi::FunctionOutputDecoder; +use ethabi_contract::use_contract; +use ethereum_types::{H256, U256, Address, Bloom}; +use keccak_hash::keccak; +use kvdb::DBValue; +use lazy_static::lazy_static; +use log::{debug, info, trace}; +use machine::Machine; +use memory_cache::MemoryLruCache; +use parity_bytes::Bytes; +use parking_lot::RwLock; +use rlp::{Rlp, RlpStream}; use unexpected::Mismatch; -use client_traits::EngineClient; -use machine::Machine; use super::{SystemCall, ValidatorSet}; use super::simple_list::SimpleList; -use_contract!(validator_set, "res/contracts/validator_set.json"); +use_contract!(validator_set, "res/validator_set.json"); const MEMOIZE_CAPACITY: usize = 500; @@ -99,12 +103,12 @@ fn encode_first_proof(header: &Header, state_items: &[Vec]) -> Bytes { fn check_first_proof(machine: &Machine, contract_address: Address, old_header: Header, state_items: &[DBValue]) -> Result, String> { - use types::transaction::{Action, Transaction}; + use common_types::transaction::{Action, Transaction}; // TODO: match client contract_call_tx more cleanly without duplication. const PROVIDED_GAS: u64 = 50_000_000; - let env_info = ::vm::EnvInfo { + let env_info = vm::EnvInfo { number: old_header.number(), author: *old_header.author(), difficulty: *old_header.difficulty(), @@ -133,7 +137,7 @@ fn check_first_proof(machine: &Machine, contract_address: Address, old_header: H data, }.fake_sign(from); - let res = ::executive_state::check_proof( + let res = executive_state::check_proof( state_items, *old_header.state_root(), &tx, @@ -142,9 +146,9 @@ fn check_first_proof(machine: &Machine, contract_address: Address, old_header: H ); match res { - ::executive_state::ProvedExecution::BadProof => Err("Bad proof".into()), - ::executive_state::ProvedExecution::Failed(e) => Err(format!("Failed call: {}", e)), - ::executive_state::ProvedExecution::Complete(e) => decoder.decode(&e.output).map_err(|e| e.to_string()), + executive_state::ProvedExecution::BadProof => Err("Bad proof".into()), + executive_state::ProvedExecution::Failed(e) => Err(format!("Failed call: {}", e)), + executive_state::ProvedExecution::Complete(e) => decoder.decode(&e.output).map_err(|e| e.to_string()), } } @@ -351,7 +355,7 @@ impl ValidatorSet for ValidatorSafeContract { } } - fn epoch_set(&self, first: bool, machine: &Machine, _number: ::types::BlockNumber, proof: &[u8]) + fn epoch_set(&self, first: bool, machine: &Machine, _number: BlockNumber, proof: &[u8]) -> Result<(SimpleList, Option), EthcoreError> { let rlp = Rlp::new(proof); @@ -374,7 +378,7 @@ impl ValidatorSet for ValidatorSafeContract { // ensure receipts match header. // TODO: optimize? these were just decoded. - let found_root = ::triehash::ordered_trie_root( + let found_root = triehash::ordered_trie_root( receipts.iter().map(::rlp::encode) ); if found_root != *old_header.receipts_root() { @@ -450,13 +454,9 @@ impl ValidatorSet for ValidatorSafeContract { #[cfg(test)] mod tests { use std::sync::Arc; - use rustc_hex::FromHex; - use hash::keccak; - use engine::{EpochChange, Proof}; - use ethereum_types::Address; - use crate::spec; + use accounts::AccountProvider; - use types::{ + use common_types::{ ids::BlockId, engines::machine::AuxiliaryRequest, header::Header, @@ -465,9 +465,17 @@ mod tests { verification::Unverified, }; 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} + }; use ethkey::Secret; - use miner::{self, MinerService}; - use test_helpers::{generate_dummy_client_with_spec, generate_dummy_client_with_spec_and_data}; + use ethereum_types::Address; + use keccak_hash::keccak; + use rustc_hex::FromHex; + use super::super::ValidatorSet; use super::{ValidatorSafeContract, EVENT_NAME_HASH}; diff --git a/ethcore/src/engines/validator_set/simple_list.rs b/ethcore/engines/validator-set/src/simple_list.rs similarity index 97% rename from ethcore/src/engines/validator_set/simple_list.rs rename to ethcore/engines/validator-set/src/simple_list.rs index d3d14f009..77057f1cd 100644 --- a/ethcore/src/engines/validator_set/simple_list.rs +++ b/ethcore/engines/validator-set/src/simple_list.rs @@ -16,16 +16,18 @@ /// Preconfigured validator list. -use parity_util_mem::MallocSizeOf; -use ethereum_types::{H256, Address}; - -use machine::Machine; -use types::{ +use common_types::{ BlockNumber, + ids::BlockId, header::Header, errors::EthcoreError, engines::machine::{Call, AuxiliaryData}, }; +use ethereum_types::{H256, Address}; +use log::warn; +use machine::Machine; +use parity_util_mem::MallocSizeOf; + use super::ValidatorSet; /// Validator set containing a known set of addresses. @@ -65,7 +67,7 @@ impl From> for SimpleList { } impl ValidatorSet for SimpleList { - fn default_caller(&self, _block_id: ::types::ids::BlockId) -> Box { + fn default_caller(&self, _block_id: BlockId) -> Box { Box::new(|_, _| Err("Simple list doesn't require calls.".into())) } diff --git a/ethcore/src/engines/validator_set/test.rs b/ethcore/engines/validator-set/src/test.rs similarity index 95% rename from ethcore/src/engines/validator_set/test.rs rename to ethcore/engines/validator-set/src/test.rs index c4572a75c..0198c2d5b 100644 --- a/ethcore/src/engines/validator_set/test.rs +++ b/ethcore/engines/validator-set/src/test.rs @@ -19,18 +19,20 @@ use std::str::FromStr; use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrdering}; -use parity_util_mem::MallocSizeOf; -use bytes::Bytes; -use ethereum_types::{H256, Address}; -use types::{ +use log::trace; +use parity_util_mem::MallocSizeOf; +use common_types::{ BlockNumber, + ids::BlockId, header::Header, errors::EthcoreError, engines::machine::{Call, AuxiliaryData}, }; - +use ethereum_types::{H256, Address}; use machine::Machine; +use parity_bytes::Bytes; + use super::{ValidatorSet, SimpleList}; /// Set used for testing with a single validator. @@ -64,7 +66,7 @@ impl TestSet { } impl ValidatorSet for TestSet { - fn default_caller(&self, _block_id: ::types::ids::BlockId) -> Box { + fn default_caller(&self, _block_id: BlockId) -> Box { Box::new(|_, _| Err("Test set doesn't require calls.".into())) } diff --git a/ethcore/executive-state/Cargo.toml b/ethcore/executive-state/Cargo.toml new file mode 100644 index 000000000..a962a1e39 --- /dev/null +++ b/ethcore/executive-state/Cargo.toml @@ -0,0 +1,33 @@ +[package] +description = "Execute transactions producing a receipt and an optional trace." +name = "executive-state" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2018" +license = "GPL-3.0" + +[dependencies] +account-db = { path = "../account-db" } +account-state = { path = "../account-state" } +bytes = { package = "parity-bytes", version = "0.1.0" } +common-types = { path = "../types" } +ethereum-types = "0.6.0" +hash-db = "0.15.0" +keccak-hasher = { path = "../../util/keccak-hasher" } +kvdb = "0.1.0" +log = "0.4.8" +machine = { path = "../machine" } +trace = { path = "../trace" } +trie-vm-factories = { path = "../trie-vm-factories" } +vm = { path = "../vm" } + +[dev-dependencies] +env_logger = "0.5" +ethcore = { path = "..", features = ["test-helpers"] } +ethkey = { path = "../../accounts/ethkey" } +evm = { path = "../evm" } +keccak-hash = "0.2.0" +pod = { path = "../pod" } +rustc-hex = "1.0" +trie-db = "0.15.0" +ethtrie = { package = "patricia-trie-ethereum", path = "../../util/patricia-trie-ethereum" } diff --git a/ethcore/src/executive_state.rs b/ethcore/executive-state/src/lib.rs similarity index 99% rename from ethcore/src/executive_state.rs rename to ethcore/executive-state/src/lib.rs index 7d440e26a..2be7b0d6f 100644 --- a/ethcore/src/executive_state.rs +++ b/ethcore/executive-state/src/lib.rs @@ -18,29 +18,30 @@ //! `account-state` crates and contains everything that requires `Machine` or `Executive` (or types //! thereof). -use machine::{ - machine::Machine, - executive::{Executive, TransactOptions}, - executed::Executed, +use account_state::{ + backend::{self, Backend}, + state::State, }; -use vm::EnvInfo; -use types::{ +use bytes::Bytes; +use common_types::{ engines::machine::Executed as RawExecuted, errors::{ExecutionError, EthcoreError as Error}, transaction::SignedTransaction, receipt::{TransactionOutcome, Receipt}, }; -use trace::{FlatTrace, VMTrace}; -use account_state::{ - backend::{self, Backend}, - state::State, -}; use ethereum_types::H256; -use trie_vm_factories::Factories; -use bytes::Bytes; +use hash_db::AsHashDB; use keccak_hasher::KeccakHasher; use kvdb::DBValue; -use hash_db::AsHashDB; +use log::trace; +use machine::{ + machine::Machine, + executive::{Executive, TransactOptions}, + executed::Executed, +}; +use trace::{FlatTrace, VMTrace}; +use trie_vm_factories::Factories; +use vm::EnvInfo; /// Return type of proof validity check. #[derive(Debug, Clone)] @@ -80,7 +81,7 @@ pub fn check_proof( ) -> ProvedExecution { let backend = self::backend::ProofCheck::new(proof); let mut factories = Factories::default(); - factories.accountdb = ::account_db::Factory::Plain; + factories.accountdb = account_db::Factory::Plain; let res = State::from_existing( backend, @@ -263,22 +264,26 @@ mod tests { use std::sync::Arc; use std::str::FromStr; use std::collections::HashSet; - use rustc_hex::FromHex; - use hash::{keccak, KECCAK_NULL_RLP}; + use super::*; + + use account_state::{Account, CleanupMode}; + use common_types::transaction::*; + use keccak_hash::{keccak, KECCAK_NULL_RLP}; use ethkey::Secret; use ethereum_types::{H256, U256, Address, BigEndianHash}; - use test_helpers::{get_temp_state, get_temp_state_db}; - use machine::Machine; - use vm::EnvInfo; - use types::transaction::*; - use trace::{FlatTrace, TraceError, trace}; + use ethcore::{ + spec, + test_helpers::{get_temp_state, get_temp_state_db} + }; + use ethtrie; use evm::CallType; - use pod::{self, PodAccount}; - use pod::PodState; - use executive_state::ExecutiveState; - use account_state::{Account, CleanupMode}; - use crate::spec; + use machine::Machine; + use pod::{self, PodAccount, PodState}; + use rustc_hex::FromHex; + use ::trace::{FlatTrace, TraceError, trace}; + use trie_db::{TrieFactory, TrieSpec}; + use vm::EnvInfo; fn secret() -> Secret { keccak("").into() @@ -1537,7 +1542,7 @@ mod tests { fn should_not_panic_on_state_diff_with_storage() { let mut state = get_temp_state(); let a = Address::from_low_u64_be(0xa); - state.init_code(&a, b"abcdefg".to_vec()).unwrap();; + state.init_code(&a, b"abcdefg".to_vec()).unwrap(); state.add_balance(&a, &256.into(), CleanupMode::NoEmpty).unwrap(); state.set_storage(&a, H256::from_low_u64_be(0xb), H256::from_low_u64_be(0xc).into()).unwrap(); @@ -1658,9 +1663,6 @@ mod tests { #[test] fn should_get_full_pod_storage_values() { - use trie::{TrieFactory, TrieSpec}; - use ethtrie; - let a = Address::from_low_u64_be(10); let db = get_temp_state_db(); diff --git a/ethcore/light/Cargo.toml b/ethcore/light/Cargo.toml index 19911db39..4e87e0fec 100644 --- a/ethcore/light/Cargo.toml +++ b/ethcore/light/Cargo.toml @@ -17,6 +17,7 @@ ethcore = { path = ".."} ethcore-db = { path = "../db" } ethcore-blockchain = { path = "../blockchain" } ethereum-types = "0.6.0" +executive-state = { path = "../executive-state" } machine = { path = "../machine" } memory-db = "0.15.0" trie-db = "0.15.0" diff --git a/ethcore/light/src/client/mod.rs b/ethcore/light/src/client/mod.rs index 73e512b10..afc210997 100644 --- a/ethcore/light/src/client/mod.rs +++ b/ethcore/light/src/client/mod.rs @@ -19,7 +19,7 @@ use std::sync::{Weak, Arc}; use engine::{Engine, EpochChange, Proof}; -use ethcore::client::{ClientReport, EnvInfo, ClientIoMessage}; +use ethcore::client::{ClientReport, ClientIoMessage}; use ethcore::verification::queue::{self, HeaderQueue}; use ethcore::spec::{Spec, SpecHardcodedSync}; use io::IoChannel; @@ -39,6 +39,7 @@ use common_types::{ verification::VerificationQueueInfo as BlockQueueInfo, }; use kvdb::KeyValueDB; +use vm::EnvInfo; use self::fetch::ChainDataFetcher; use self::header_chain::{AncestryIter, HeaderChain, HardcodedSync}; diff --git a/ethcore/light/src/lib.rs b/ethcore/light/src/lib.rs index 9b9c40533..a51b213e7 100644 --- a/ethcore/light/src/lib.rs +++ b/ethcore/light/src/lib.rs @@ -61,6 +61,7 @@ extern crate ethcore_blockchain; extern crate ethcore_db; extern crate ethcore_io as io; extern crate ethcore_network as network; +extern crate executive_state; extern crate parity_bytes as bytes; extern crate ethereum_types; extern crate ethcore_miner as miner; diff --git a/ethcore/light/src/on_demand/request.rs b/ethcore/light/src/on_demand/request.rs index cff0b63fc..94af245eb 100644 --- a/ethcore/light/src/on_demand/request.rs +++ b/ethcore/light/src/on_demand/request.rs @@ -25,7 +25,7 @@ use common_types::encoded; use common_types::receipt::Receipt; use common_types::transaction::SignedTransaction; use engine::{Engine, StateDependentProof}; -use ethcore::executive_state::{ProvedExecution, self}; +use executive_state::{ProvedExecution, self}; use ethereum_types::{H256, U256, Address}; use ethtrie::{TrieError, TrieDB}; use hash::{KECCAK_NULL_RLP, KECCAK_EMPTY, KECCAK_EMPTY_LIST_RLP, keccak}; diff --git a/ethcore/service/src/service.rs b/ethcore/service/src/service.rs index 9d3c8703b..08cb88782 100644 --- a/ethcore/service/src/service.rs +++ b/ethcore/service/src/service.rs @@ -29,9 +29,12 @@ use blockchain::{BlockChainDB, BlockChainDBHandler}; 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, RestorationStatus}; +use ethcore::snapshot::{SnapshotService as _SnapshotService}; use ethcore::spec::Spec; -use common_types::errors::{EthcoreError, SnapshotError}; +use common_types::{ + errors::{EthcoreError, SnapshotError}, + snapshot::RestorationStatus, +}; use ethcore_private_tx::{self, Importer, Signer}; @@ -112,7 +115,7 @@ impl ClientService { { let io_service = IoService::::start()?; - info!("Configured for {} using {} engine", Colour::White.bold().paint(spec.name.clone()), Colour::Yellow.bold().paint(spec.engine.name())); + info!("Configured for {} using {} engine", Colour::White.bold().paint(spec.name.clone()), Colour::Yellow.bold().paint(spec.engine.name().to_string())); let pruning = config.pruning; let client = Client::new( diff --git a/ethcore/src/block.rs b/ethcore/src/block.rs index 2ed86bb66..3a1633778 100644 --- a/ethcore/src/block.rs +++ b/ethcore/src/block.rs @@ -265,7 +265,7 @@ impl<'x> OpenBlock<'x> { }) } - #[cfg(test)] + #[cfg(any(test, feature = "test-helpers"))] /// Return mutable block reference. To be used in tests only. pub fn block_mut(&mut self) -> &mut ExecutedBlock { &mut self.block } } diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index f2a03144d..60e4263ae 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -20,6 +20,7 @@ use std::sync::atomic::{AtomicUsize, AtomicBool, Ordering as AtomicOrdering}; use std::sync::{Arc, Weak}; use std::time::{Instant, Duration}; +use account_state::state::StateInfo; use blockchain::{BlockReceipts, BlockChain, BlockChainDB, BlockProvider, TreeRoute, ImportRoute, TransactionAddress, ExtrasInsert, BlockNumberKey}; use bytes::Bytes; use call_contract::{CallContract, RegistryInfo}; @@ -39,7 +40,7 @@ use hash_db::EMPTY_PREFIX; use block::{LockedBlock, Drain, ClosedBlock, OpenBlock, enact_verified, SealedBlock}; use client::ancient_import::AncientVerifier; use client::{ - ReopenBlock, PrepareOpenBlock, ImportSealedBlock, BroadcastProposalBlock, StateInfo, + ReopenBlock, PrepareOpenBlock, ImportSealedBlock, BroadcastProposalBlock, Call, BlockProducer, SealedBlockImporter, ChainNotify, EngineInfo, ClientConfig, NewBlocks, ChainRoute, ChainMessageType, bad_blocks, ClientIoMessage, }; @@ -85,7 +86,7 @@ use types::{ log_entry::LocalizedLogEntry, receipt::{Receipt, LocalizedReceipt}, header::Header, - snapshot::Progress, + snapshot::{Progress, Snapshotting}, trace_filter::Filter as TraceFilter, pruning_info::PruningInfo, call_analytics::CallAnalytics, @@ -1020,7 +1021,7 @@ impl Client { } /// Get shared miner reference. - #[cfg(test)] + #[cfg(any(test, feature = "test-helpers"))] pub fn miner(&self) -> Arc { self.importer.miner.clone() } @@ -1168,6 +1169,9 @@ impl Client { at: BlockId, p: &Progress, ) -> Result<(), EthcoreError> { + if let Snapshotting::Unsupported = self.engine.snapshot_mode() { + return Err(EthcoreError::Snapshot(SnapshotError::SnapshotsUnsupported)); + } let db = self.state_db.read().journal_db().boxed_clone(); let best_block_number = self.chain_info().best_block_number; let block_number = self.block_number(at).ok_or_else(|| SnapshotError::InvalidStartingBlock(at))?; @@ -1197,7 +1201,7 @@ impl Client { }; let processing_threads = self.config.snapshot.processing_threads; - let chunker = self.engine.snapshot_components().ok_or_else(|| SnapshotError::SnapshotsUnsupported)?; + let chunker = snapshot::chunker(self.engine.snapshot_mode()).ok_or_else(|| SnapshotError::SnapshotsUnsupported)?; snapshot::take_snapshot( chunker, &self.chain.read(), @@ -1227,10 +1231,8 @@ impl Client { fn transaction_address(&self, id: TransactionId) -> Option { match id { TransactionId::Hash(ref hash) => self.chain.read().transaction_address(hash), - TransactionId::Location(id, index) => Self::block_hash(&self.chain.read(), id).map(|hash| TransactionAddress { - block_hash: hash, - index: index, - }) + TransactionId::Location(id, index) => Self::block_hash(&self.chain.read(), id).map(|block_hash| + TransactionAddress { block_hash, index }) } } diff --git a/ethcore/src/client/evm_test_client.rs b/ethcore/src/client/evm_test_client.rs index f11a93363..867e44421 100644 --- a/ethcore/src/client/evm_test_client.rs +++ b/ethcore/src/client/evm_test_client.rs @@ -21,7 +21,7 @@ use std::sync::Arc; use ethereum_types::{H256, U256, H160}; use {trie_vm_factories, journaldb, trie, kvdb_memorydb}; use kvdb::{self, KeyValueDB}; -use {state_db, client, trace, db, spec}; +use {state_db, trace, db, spec}; use pod::PodState; use types::{ errors::EthcoreError, @@ -214,7 +214,7 @@ impl<'a> EvmTestClient<'a> { ) -> Result { let genesis = self.spec.genesis_header(); - let info = client::EnvInfo { + let info = vm::EnvInfo { number: genesis.number(), author: *genesis.author(), timestamp: genesis.timestamp(), @@ -233,7 +233,7 @@ impl<'a> EvmTestClient<'a> { params: ActionParams, tracer: &mut T, vm_tracer: &mut V, - info: client::EnvInfo, + info: vm::EnvInfo, ) -> Result { let mut substate = Substate::new(); @@ -252,7 +252,7 @@ impl<'a> EvmTestClient<'a> { /// Returns the state root, gas left and the output. pub fn transact( &mut self, - env_info: &client::EnvInfo, + env_info: &vm::EnvInfo, transaction: transaction::SignedTransaction, tracer: T, vm_tracer: V, diff --git a/ethcore/src/client/io_message.rs b/ethcore/src/client/io_message.rs index 5fcf8f9ff..1b4725da5 100644 --- a/ethcore/src/client/io_message.rs +++ b/ethcore/src/client/io_message.rs @@ -18,7 +18,7 @@ use std::fmt; use bytes::Bytes; use client::Client; use ethereum_types::H256; -use snapshot::ManifestData; +use types::snapshot::ManifestData; /// Message type for external and internal events #[derive(Debug)] diff --git a/ethcore/src/client/mod.rs b/ethcore/src/client/mod.rs index cd5dd4735..60e36d172 100644 --- a/ethcore/src/client/mod.rs +++ b/ethcore/src/client/mod.rs @@ -38,13 +38,8 @@ pub use self::traits::{ ReopenBlock, PrepareOpenBlock, ImportSealedBlock, BroadcastProposalBlock, Call, EngineInfo, BlockProducer, SealedBlockImporter, }; -pub use account_state::state::StateInfo; - - -pub use vm::{LastHashes, EnvInfo}; pub use verification::VerifierType; mod traits; - mod chain_notify; diff --git a/ethcore/src/client/test_client.rs b/ethcore/src/client/test_client.rs index 42d30bbc2..422bebcd8 100644 --- a/ethcore/src/client/test_client.rs +++ b/ethcore/src/client/test_client.rs @@ -59,14 +59,13 @@ use types::{ blockchain_info::BlockChainInfo, block_status::BlockStatus, }; -use vm::Schedule; +use vm::{Schedule, LastHashes}; use block::{OpenBlock, SealedBlock, ClosedBlock}; use call_contract::{CallContract, RegistryInfo}; use client::{ ReopenBlock, PrepareOpenBlock, ImportSealedBlock, BroadcastProposalBlock, Call, EngineInfo, BlockProducer, SealedBlockImporter, - LastHashes, }; use client_traits::{ BlockInfo, Nonce, Balance, ChainInfo, TransactionInfo, BlockChainClient, ImportBlock, diff --git a/ethcore/src/engines/mod.rs b/ethcore/src/engines/mod.rs deleted file mode 100644 index 780a6a063..000000000 --- a/ethcore/src/engines/mod.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015-2019 Parity Technologies (UK) Ltd. -// This file is part of Parity Ethereum. - -// Parity Ethereum is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Ethereum is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Ethereum. If not, see . - -//! Consensus engine specification and basic implementations. - -mod authority_round; -mod basic_authority; -mod clique; -mod ethash; -mod instant_seal; -mod null_engine; -mod validator_set; - -pub mod block_reward; - -pub use self::authority_round::AuthorityRound; -pub use self::basic_authority::BasicAuthority; -pub use self::instant_seal::{InstantSeal, InstantSealParams}; -pub use self::null_engine::NullEngine; -pub use self::clique::Clique; -pub use self::ethash::{Ethash, Seal as EthashSeal}; diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index d1936aa9d..ab1190d8f 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -55,13 +55,17 @@ 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; @@ -72,9 +76,11 @@ 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; @@ -84,9 +90,9 @@ extern crate kvdb; extern crate kvdb_memorydb; extern crate len_caching_lock; -extern crate lru_cache; 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; @@ -120,6 +126,12 @@ extern crate ethcore_stratum; extern crate tempdir; #[cfg(any(test, feature = "kvdb-rocksdb"))] 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"))] +#[macro_use] +extern crate macros; #[cfg(any(test, feature = "blooms-db"))] extern crate blooms_db; #[cfg(any(test, feature = "env_logger"))] @@ -132,10 +144,6 @@ extern crate ethabi_contract; #[macro_use] extern crate log; #[macro_use] -extern crate lazy_static; -#[macro_use] -extern crate macros; -#[macro_use] extern crate rlp_derive; #[macro_use] extern crate trace_time; @@ -151,8 +159,6 @@ extern crate parity_runtime; pub mod block; pub mod client; -pub mod engines; -pub mod executive_state; pub mod miner; pub mod snapshot; pub mod spec; diff --git a/ethcore/src/snapshot/consensus/authority.rs b/ethcore/src/snapshot/consensus/authority.rs index 19f46bb14..426ca1e54 100644 --- a/ethcore/src/snapshot/consensus/authority.rs +++ b/ethcore/src/snapshot/consensus/authority.rs @@ -22,11 +22,7 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; -use engine::{ - Engine, - EpochVerifier, - snapshot::{SnapshotComponents, Rebuilder} -}; +use engine::{Engine, EpochVerifier}; use blockchain::{BlockChain, BlockChainDB, BlockProvider}; use bytes::Bytes; use ethereum_types::{H256, U256}; @@ -43,6 +39,8 @@ use types::{ snapshot::{ChunkSink, Progress, ManifestData} }; +use snapshot::{SnapshotComponents, Rebuilder}; + /// Snapshot creation and restoration for PoA chains. /// Chunk format: /// diff --git a/ethcore/src/snapshot/consensus/mod.rs b/ethcore/src/snapshot/consensus/mod.rs index 3623d008d..aa323b6af 100644 --- a/ethcore/src/snapshot/consensus/mod.rs +++ b/ethcore/src/snapshot/consensus/mod.rs @@ -22,3 +22,16 @@ mod work; pub use self::authority::*; pub use self::work::*; + +use snapshot::SnapshotComponents; +use types::snapshot::Snapshotting::{self, *}; + +/// Create a factory for building snapshot chunks and restoring from them. +/// `None` indicates that the engine doesn't support snapshot creation. +pub fn chunker(snapshot_type: Snapshotting) -> Option> { + match snapshot_type { + PoA => Some(Box::new(PoaSnapshot)), + PoW { blocks, max_restore_blocks } => Some(Box::new(PowSnapshot::new(blocks, max_restore_blocks))), + Unsupported => None, + } +} diff --git a/ethcore/src/snapshot/consensus/work.rs b/ethcore/src/snapshot/consensus/work.rs index f9c4faec3..ee52f85ba 100644 --- a/ethcore/src/snapshot/consensus/work.rs +++ b/ethcore/src/snapshot/consensus/work.rs @@ -26,7 +26,6 @@ use std::sync::Arc; use blockchain::{BlockChain, BlockChainDB, BlockProvider}; use engine::Engine; -use engine::snapshot::{SnapshotComponents, Rebuilder}; use snapshot::block::AbridgedBlock; use ethereum_types::H256; use kvdb::KeyValueDB; @@ -40,6 +39,8 @@ use types::{ snapshot::{ChunkSink, ManifestData, Progress}, }; +use snapshot::{SnapshotComponents, Rebuilder}; + /// Snapshot creation and restoration for PoW chains. /// This includes blocks from the head of the chain as a /// loose assurance that the chain is valid. @@ -48,7 +49,7 @@ pub struct PowSnapshot { /// Number of blocks from the head of the chain /// to include in the snapshot. pub blocks: u64, - /// Number of to allow in the snapshot when restoring. + /// Number of blocks to allow in the snapshot when restoring. pub max_restore_blocks: u64, } diff --git a/ethcore/src/snapshot/io.rs b/ethcore/src/snapshot/io.rs index cf1316827..5a959932b 100644 --- a/ethcore/src/snapshot/io.rs +++ b/ethcore/src/snapshot/io.rs @@ -28,9 +28,10 @@ use std::path::{Path, PathBuf}; use bytes::Bytes; use ethereum_types::H256; use rlp::{RlpStream, Rlp}; -use types::errors::{SnapshotError, EthcoreError}; - -use super::ManifestData; +use types::{ + errors::{SnapshotError, EthcoreError}, + snapshot::ManifestData, +}; const SNAPSHOT_VERSION: u64 = 2; diff --git a/ethcore/src/snapshot/mod.rs b/ethcore/src/snapshot/mod.rs index 3dab15d4f..ff3faa2c5 100644 --- a/ethcore/src/snapshot/mod.rs +++ b/ethcore/src/snapshot/mod.rs @@ -46,25 +46,21 @@ use ethtrie::{TrieDB, TrieDBMut}; use rlp::{RlpStream, Rlp}; use bloom_journal::Bloom; use num_cpus; +use types::snapshot::ManifestData; use self::io::SnapshotWriter; use super::state_db::StateDB; use account_state::Account as StateAccount; -use engine::{ - Engine, - snapshot::SnapshotComponents -}; +use engine::Engine; use crossbeam_utils::thread; use rand::{Rng, rngs::OsRng}; pub use self::consensus::*; pub use self::service::{SnapshotClient, Service, DatabaseRestore}; -pub use self::traits::SnapshotService; +pub use self::traits::{SnapshotService, SnapshotComponents, Rebuilder}; pub use self::watcher::Watcher; -pub use types::snapshot::ManifestData; -pub use types::restoration_status::RestorationStatus; pub use types::basic_account::BasicAccount; pub mod io; diff --git a/ethcore/src/snapshot/service.rs b/ethcore/src/snapshot/service.rs index 3c1a3afea..cbef5b5ff 100644 --- a/ethcore/src/snapshot/service.rs +++ b/ethcore/src/snapshot/service.rs @@ -24,21 +24,24 @@ use std::sync::Arc; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::cmp; -use super::{StateRebuilder, RestorationStatus, SnapshotService, MAX_CHUNK_SIZE}; -use super::io::{SnapshotReader, LooseReader, SnapshotWriter, LooseWriter}; +use super::{ + StateRebuilder, + SnapshotService, + Rebuilder, + MAX_CHUNK_SIZE, + io::{SnapshotReader, LooseReader, SnapshotWriter, LooseWriter}, + chunker, +}; use blockchain::{BlockChain, BlockChainDB, BlockChainDBHandler}; use client::{Client, ClientIoMessage}; -use client_traits::{ - BlockInfo, BlockChainClient, ChainInfo -}; +use client_traits::{BlockInfo, BlockChainClient, ChainInfo}; use engine::Engine; -use engine::snapshot::Rebuilder; use hash::keccak; use types::{ errors::{EthcoreError as Error, SnapshotError, SnapshotError::UnlinkedAncientBlockChain}, ids::BlockId, - snapshot::{ManifestData, Progress}, + snapshot::{ManifestData, Progress, RestorationStatus}, }; use io::IoChannel; @@ -111,10 +114,10 @@ impl Restoration { let raw_db = params.db; let chain = BlockChain::new(Default::default(), params.genesis, raw_db.clone()); - let components = params.engine.snapshot_components() - .ok_or_else(|| ::snapshot::Error::SnapshotsUnsupported)?; + let chunker = chunker(params.engine.snapshot_mode()) + .ok_or_else(|| Error::Snapshot(SnapshotError::SnapshotsUnsupported))?; - let secondary = components.rebuilder(chain, raw_db.clone(), &manifest)?; + let secondary = chunker.rebuilder(chain, raw_db.clone(), &manifest)?; let final_state_root = manifest.state_root.clone(); @@ -801,7 +804,7 @@ impl SnapshotService for Service { } fn supported_versions(&self) -> Option<(u64, u64)> { - self.engine.snapshot_components() + chunker(self.engine.snapshot_mode()) .map(|c| (c.min_supported_version(), c.current_version())) } @@ -906,8 +909,9 @@ mod tests { use io::{IoService}; use crate::spec; use journaldb::Algorithm; - use snapshot::{ManifestData, RestorationStatus, SnapshotService}; + use snapshot::SnapshotService; use super::*; + use types::snapshot::{ManifestData, RestorationStatus}; use tempdir::TempDir; use test_helpers::{generate_dummy_client_with_spec_and_data, restoration_db_handler}; diff --git a/ethcore/src/snapshot/tests/helpers.rs b/ethcore/src/snapshot/tests/helpers.rs index d1931d911..c9420fcfc 100644 --- a/ethcore/src/snapshot/tests/helpers.rs +++ b/ethcore/src/snapshot/tests/helpers.rs @@ -161,13 +161,13 @@ pub fn restore( use std::sync::atomic::AtomicBool; let flag = AtomicBool::new(true); - let components = engine.snapshot_components().unwrap(); + let chunker = crate::snapshot::chunker(engine.snapshot_mode()).expect("the engine used here supports snapshots"); let manifest = reader.manifest(); let mut state = StateRebuilder::new(db.key_value().clone(), journaldb::Algorithm::Archive); let mut secondary = { let chain = BlockChain::new(Default::default(), genesis, db.clone()); - components.rebuilder(chain, db, manifest).unwrap() + chunker.rebuilder(chain, db, manifest).unwrap() }; let mut snappy_buffer = Vec::new(); diff --git a/ethcore/src/snapshot/tests/proof_of_work.rs b/ethcore/src/snapshot/tests/proof_of_work.rs index 6e7726a6a..a187be45c 100644 --- a/ethcore/src/snapshot/tests/proof_of_work.rs +++ b/ethcore/src/snapshot/tests/proof_of_work.rs @@ -21,11 +21,12 @@ use tempdir::TempDir; use types::{ errors::EthcoreError as Error, engines::ForkChoice, + snapshot::Progress, }; use blockchain::generator::{BlockGenerator, BlockBuilder}; use blockchain::{BlockChain, ExtrasInsert}; -use snapshot::{chunk_secondary, Error as SnapshotError, Progress, SnapshotComponents}; +use snapshot::{chunk_secondary, Error as SnapshotError, SnapshotComponents}; use snapshot::io::{PackedReader, PackedWriter, SnapshotReader, SnapshotWriter}; use parking_lot::Mutex; diff --git a/ethcore/src/snapshot/tests/service.rs b/ethcore/src/snapshot/tests/service.rs index e9bc3b92b..acc28a8be 100644 --- a/ethcore/src/snapshot/tests/service.rs +++ b/ethcore/src/snapshot/tests/service.rs @@ -27,10 +27,11 @@ use types::{ ids::BlockId, snapshot::Progress, verification::Unverified, + snapshot::{ManifestData, RestorationStatus}, }; use snapshot::io::{PackedReader, PackedWriter, SnapshotReader, SnapshotWriter}; use snapshot::service::{Service, ServiceParams}; -use snapshot::{chunk_state, chunk_secondary, ManifestData, SnapshotService, RestorationStatus}; +use snapshot::{chunk_state, chunk_secondary, SnapshotService}; use crate::spec; use test_helpers::{new_db, new_temp_db, generate_dummy_client_with_spec_and_data, restoration_db_handler}; diff --git a/ethcore/src/snapshot/traits.rs b/ethcore/src/snapshot/traits.rs index aa61b595b..3eb2542bc 100644 --- a/ethcore/src/snapshot/traits.rs +++ b/ethcore/src/snapshot/traits.rs @@ -14,9 +14,16 @@ // You should have received a copy of the GNU General Public License // along with Parity Ethereum. If not, see . -use super::{ManifestData, RestorationStatus}; -use ethereum_types::H256; +use std::sync::{Arc, atomic::AtomicBool}; + +use blockchain::{BlockChain, BlockChainDB}; use bytes::Bytes; +use ethereum_types::H256; +use types::{ + errors::{EthcoreError as Error, SnapshotError}, + snapshot::{ManifestData, ChunkSink, Progress, RestorationStatus}, +}; + /// The interface for a snapshot network service. /// This handles: @@ -61,3 +68,65 @@ pub trait SnapshotService : Sync + Send { /// Shutdown the Snapshot Service by aborting any ongoing restore fn shutdown(&self); } + +use crate::engine::Engine; + +/// Restore from secondary snapshot chunks. +pub trait Rebuilder: Send { + /// Feed a chunk, potentially out of order. + /// + /// Check `abort_flag` periodically while doing heavy work. If set to `false`, should bail with + /// `Error::RestorationAborted`. + fn feed( + &mut self, + chunk: &[u8], + engine: &dyn Engine, + abort_flag: &AtomicBool, + ) -> Result<(), Error>; + + /// Finalize the restoration. Will be done after all chunks have been + /// fed successfully. + /// + /// This should apply the necessary "glue" between chunks, + /// and verify against the restored state. + fn finalize(&mut self) -> Result<(), Error>; +} + +/// Components necessary for snapshot creation and restoration. +pub trait SnapshotComponents: Send { + /// Create secondary snapshot chunks; these corroborate the state data + /// in the state chunks. + /// + /// Chunks shouldn't exceed the given preferred size, and should be fed + /// uncompressed into the sink. + /// + /// This will vary by consensus engine, so it's exposed as a trait. + fn chunk_all( + &mut self, + chain: &BlockChain, + block_at: H256, + chunk_sink: &mut ChunkSink, + progress: &Progress, + preferred_size: usize, + ) -> Result<(), SnapshotError>; + + /// Create a rebuilder, which will have chunks fed into it in arbitrary + /// order and then be finalized. + /// + /// The manifest, a database, and fresh `BlockChain` are supplied. + /// + /// The engine passed to the `Rebuilder` methods will be the same instance + /// that created the `SnapshotComponents`. + fn rebuilder( + &self, + chain: BlockChain, + db: Arc, + manifest: &ManifestData, + ) -> Result, Error>; + + /// Minimum supported snapshot version number. + fn min_supported_version(&self) -> u64; + + /// Current version number + fn current_version(&self) -> u64; +} diff --git a/ethcore/src/spec/spec.rs b/ethcore/src/spec/spec.rs index f5ffd543e..046a9e028 100644 --- a/ethcore/src/spec/spec.rs +++ b/ethcore/src/spec/spec.rs @@ -40,10 +40,12 @@ use vm::{EnvInfo, CallType, ActionValue, ActionParams, ParamsType}; use builtin::Builtin; use engine::Engine; -use engines::{ - NullEngine, InstantSeal, InstantSealParams, BasicAuthority, Clique, - AuthorityRound, Ethash, -}; +use clique::Clique; +use null_engine::NullEngine; +use instant_seal::{InstantSeal, InstantSealParams}; +use authority_round::AuthorityRound; +use basic_authority::BasicAuthority; +use ethash_engine::Ethash; use machine::{ executive::Executive, machine::Machine, diff --git a/ethcore/src/verification/verification.rs b/ethcore/src/verification/verification.rs index 28cc87e5e..12149dfa8 100644 --- a/ethcore/src/verification/verification.rs +++ b/ethcore/src/verification/verification.rs @@ -782,7 +782,7 @@ mod tests { use ethkey::{Generator, Random}; use types::transaction::{Transaction, Action}; use machine::Machine; - use engines::NullEngine; + use null_engine::NullEngine; let mut params = CommonParams::default(); params.dust_protection_transition = 0; diff --git a/ethcore/sync/src/chain/handler.rs b/ethcore/sync/src/chain/handler.rs index 27da6931f..89c740951 100644 --- a/ethcore/sync/src/chain/handler.rs +++ b/ethcore/sync/src/chain/handler.rs @@ -18,7 +18,6 @@ use api::WARP_SYNC_PROTOCOL_ID; use block_sync::{BlockDownloaderImportError as DownloaderImportError, DownloadAction}; use bytes::Bytes; use enum_primitive::FromPrimitive; -use ethcore::snapshot::{ManifestData, RestorationStatus}; use ethereum_types::{H256, U256}; use hash::keccak; use network::PeerId; @@ -34,6 +33,7 @@ use types::{ ids::BlockId, errors::{EthcoreError, ImportError, BlockError}, verification::Unverified, + snapshot::{ManifestData, RestorationStatus}, }; use super::sync_packet::{PacketInfo, SyncPacket}; diff --git a/ethcore/sync/src/chain/mod.rs b/ethcore/sync/src/chain/mod.rs index d71cd9f84..233a41b5f 100644 --- a/ethcore/sync/src/chain/mod.rs +++ b/ethcore/sync/src/chain/mod.rs @@ -109,7 +109,6 @@ use rlp::{RlpStream, DecoderError}; use network::{self, PeerId, PacketId}; use network::client_version::ClientVersion; use client_traits::BlockChainClient; -use ethcore::snapshot::RestorationStatus; use sync_io::SyncIo; use super::{WarpSync, SyncConfig}; use block_sync::{BlockDownloader, DownloadAction}; @@ -125,6 +124,7 @@ use types::{ verification::VerificationQueueInfo as BlockQueueInfo, blockchain_info::BlockChainInfo, block_status::BlockStatus, + snapshot::RestorationStatus, }; use self::handler::SyncHandler; @@ -1616,7 +1616,7 @@ pub mod tests { // Add some balance to clients and reset nonces for h in &[good_blocks[0], retracted_blocks[0]] { let block = client.block(BlockId::Hash(*h)).unwrap(); - let sender = sender(&block.transactions()[0]);; + let sender = sender(&block.transactions()[0]); client.set_balance(sender, U256::from(10_000_000_000_000_000_000u64)); client.set_nonce(sender, U256::from(0)); } diff --git a/ethcore/sync/src/snapshot.rs b/ethcore/sync/src/snapshot.rs index 07df99877..882ee1880 100644 --- a/ethcore/sync/src/snapshot.rs +++ b/ethcore/sync/src/snapshot.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Parity Ethereum. If not, see . -use ethcore::snapshot::{ManifestData, SnapshotService}; +use ethcore::snapshot::SnapshotService; use ethereum_types::H256; use hash::keccak; +use types::snapshot::ManifestData; use std::collections::HashSet; use std::iter::FromIterator; @@ -178,7 +179,7 @@ mod test { use hash::keccak; use bytes::Bytes; use super::*; - use ethcore::snapshot::ManifestData; + use types::snapshot::ManifestData; fn is_empty(snapshot: &Snapshot) -> bool { snapshot.pending_block_chunks.is_empty() && diff --git a/ethcore/sync/src/tests/snapshot.rs b/ethcore/sync/src/tests/snapshot.rs index f7a947329..8136dc50c 100644 --- a/ethcore/sync/src/tests/snapshot.rs +++ b/ethcore/sync/src/tests/snapshot.rs @@ -20,9 +20,12 @@ use hash::keccak; use ethereum_types::H256; use parking_lot::Mutex; use bytes::Bytes; -use ethcore::snapshot::{SnapshotService, ManifestData, RestorationStatus}; +use ethcore::snapshot::SnapshotService; use ethcore::client::EachBlockWith; -use types::BlockNumber; +use types::{ + BlockNumber, + snapshot::{ManifestData, RestorationStatus}, +}; use super::helpers::*; use {SyncConfig, WarpSync}; diff --git a/ethcore/types/src/engines/mod.rs b/ethcore/types/src/engines/mod.rs index 3a1564b9a..89d4e9bf4 100644 --- a/ethcore/types/src/engines/mod.rs +++ b/ethcore/types/src/engines/mod.rs @@ -16,16 +16,46 @@ //! Engine-specific types. -use ethereum_types::{Address, H256}; +use ethereum_types::{Address, H256, H64}; use bytes::Bytes; use ethjson; +use rlp::Rlp; +use unexpected::Mismatch; -use crate::BlockNumber; +use crate::{BlockNumber, errors::{BlockError, EthcoreError}}; pub mod epoch; pub mod params; pub mod machine; +/// Ethash/Clique specific seal +#[derive(Debug, PartialEq)] +pub struct EthashSeal { + /// Ethash seal mix_hash + pub mix_hash: H256, + /// Ethash seal nonce + pub nonce: H64, +} + +impl EthashSeal { + /// Tries to parse rlp encoded bytes as an Ethash/Clique seal. + pub fn parse_seal>(seal: &[T]) -> Result { + if seal.len() != 2 { + return Err(BlockError::InvalidSealArity( + Mismatch { + expected: 2, + found: seal.len() + } + ).into()); + } + + let mix_hash = Rlp::new(seal[0].as_ref()).as_val::()?; + let nonce = Rlp::new(seal[1].as_ref()).as_val::()?; + Ok(EthashSeal { mix_hash, nonce }) + } +} + + /// Seal type. #[derive(Debug, PartialEq, Eq)] pub enum Seal { diff --git a/ethcore/types/src/lib.rs b/ethcore/types/src/lib.rs index 99153a205..42a3c6f81 100644 --- a/ethcore/types/src/lib.rs +++ b/ethcore/types/src/lib.rs @@ -74,7 +74,6 @@ pub mod ids; pub mod log_entry; pub mod pruning_info; pub mod receipt; -pub mod restoration_status; pub mod security_level; pub mod snapshot; pub mod state_diff; diff --git a/ethcore/types/src/restoration_status.rs b/ethcore/types/src/restoration_status.rs deleted file mode 100644 index 8fc548d05..000000000 --- a/ethcore/types/src/restoration_status.rs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2015-2019 Parity Technologies (UK) Ltd. -// This file is part of Parity Ethereum. - -// Parity Ethereum is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity Ethereum is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity Ethereum. If not, see . - -//! Restoration status type definition - -/// Statuses for restorations. -#[derive(PartialEq, Eq, Clone, Copy, Debug)] -pub enum RestorationStatus { - /// No restoration. - Inactive, - /// Restoration is initializing - Initializing { - /// Total number of state chunks. - state_chunks: u32, - /// Total number of block chunks. - block_chunks: u32, - /// Number of chunks done/imported - chunks_done: u32, - }, - /// Ongoing restoration. - Ongoing { - /// Total number of state chunks. - state_chunks: u32, - /// Total number of block chunks. - block_chunks: u32, - /// Number of state chunks completed. - state_chunks_done: u32, - /// Number of block chunks completed. - block_chunks_done: u32, - }, - /// Finalizing restoration - Finalizing, - /// Failed restoration. - Failed, -} diff --git a/ethcore/types/src/snapshot.rs b/ethcore/types/src/snapshot.rs index dd58279e2..ed305d689 100644 --- a/ethcore/types/src/snapshot.rs +++ b/ethcore/types/src/snapshot.rs @@ -22,6 +22,22 @@ use ethereum_types::H256; use rlp::{Rlp, RlpStream, DecoderError}; use bytes::Bytes; +/// Modes of snapshotting +pub enum Snapshotting { + /// Snapshotting and warp sync is not supported + Unsupported, + /// Snapshots for proof-of-work chains + PoW { + /// Number of blocks from the head of the chain + /// to include in the snapshot. + blocks: u64, + /// Number of blocks to allow in the snapshot when restoring. + max_restore_blocks: u64 + }, + /// Snapshots for proof-of-authority chains + PoA, +} + /// A progress indicator for snapshots. #[derive(Debug, Default)] pub struct Progress { @@ -122,3 +138,34 @@ impl ManifestData { /// A sink for produced chunks. pub type ChunkSink<'a> = dyn FnMut(&[u8]) -> std::io::Result<()> + 'a; + +/// Statuses for snapshot restoration. +#[derive(PartialEq, Eq, Clone, Copy, Debug)] +pub enum RestorationStatus { + /// No restoration. + Inactive, + /// Restoration is initializing + Initializing { + /// Total number of state chunks. + state_chunks: u32, + /// Total number of block chunks. + block_chunks: u32, + /// Number of chunks done/imported + chunks_done: u32, + }, + /// Ongoing restoration. + Ongoing { + /// Total number of state chunks. + state_chunks: u32, + /// Total number of block chunks. + block_chunks: u32, + /// Number of state chunks completed. + state_chunks_done: u32, + /// Number of block chunks completed. + block_chunks_done: u32, + }, + /// Finalizing restoration + Finalizing, + /// Failed restoration. + Failed, +} diff --git a/evmbin/src/info.rs b/evmbin/src/info.rs index c42454a01..57ac12150 100644 --- a/evmbin/src/info.rs +++ b/evmbin/src/info.rs @@ -122,7 +122,7 @@ pub struct TxInput<'a, T> { /// State root hash associated with the transaction. pub post_root: H256, /// Client environment information associated with the transaction's chain specification. - pub env_info: &'a client::EnvInfo, + pub env_info: &'a vm::EnvInfo, /// Signed transaction accompanied by a signature that may be unverified and a successfully recovered /// sender address. The unverified transaction contains a recoverable ECDSA signature that has been encoded /// as RSV components and includes replay protection for the specified chain. Verification of the signed transaction diff --git a/parity/informant.rs b/parity/informant.rs index 683c67c4b..0249e60bb 100644 --- a/parity/informant.rs +++ b/parity/informant.rs @@ -32,8 +32,9 @@ use types::{ ids::BlockId, blockchain_info::BlockChainInfo, verification::VerificationQueueInfo as BlockQueueInfo, + snapshot::RestorationStatus, }; -use ethcore::snapshot::{RestorationStatus, SnapshotService as SS}; +use ethcore::snapshot::SnapshotService as SS; use ethcore::snapshot::service::Service as SnapshotService; use sync::{LightSyncProvider, LightSync, SyncProvider, ManageNetwork}; use io::{TimerToken, IoContext, IoHandler}; diff --git a/parity/run.rs b/parity/run.rs index efd0781f3..d13ef9d05 100644 --- a/parity/run.rs +++ b/parity/run.rs @@ -44,6 +44,7 @@ use sync::{self, SyncConfig, PrivateTxHandler}; use types::{ client_types::Mode, ids::BlockId, + snapshot::Snapshotting, }; use parity_rpc::{ Origin, Metadata, NetworkSettings, informant, PubSubSession, FutureResult, FutureResponse, FutureOutput @@ -445,7 +446,14 @@ fn execute_impl(cmd: RunCmd, logger: Arc, on_client_rq: } sync_config.fork_block = spec.fork_block(); - let mut warp_sync = spec.engine.supports_warp() && cmd.warp_sync; + let snapshot_supported = + if let Snapshotting::Unsupported = spec.engine.snapshot_mode() { + false + } else { + true + }; + + let mut warp_sync = snapshot_supported && cmd.warp_sync; if warp_sync { // Logging is not initialized yet, so we print directly to stderr if fat_db { diff --git a/parity/snapshot.rs b/parity/snapshot.rs index 19cfb4897..4a4c9d718 100644 --- a/parity/snapshot.rs +++ b/parity/snapshot.rs @@ -21,7 +21,7 @@ use std::path::{Path, PathBuf}; use std::sync::Arc; use hash::keccak; -use ethcore::snapshot::{RestorationStatus, SnapshotConfiguration, SnapshotService as SS}; +use ethcore::snapshot::{SnapshotConfiguration, SnapshotService as SS}; use ethcore::snapshot::io::{SnapshotReader, PackedReader, PackedWriter}; use ethcore::snapshot::service::Service as SnapshotService; use ethcore::client::{DatabaseCompactionProfile, VMType}; @@ -31,6 +31,7 @@ use types::{ ids::BlockId, snapshot::Progress, client_types::Mode, + snapshot::RestorationStatus, }; use cache::CacheConfig; diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 897df8d96..acf9f13dc 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -63,7 +63,6 @@ extern crate jsonrpc_pubsub; extern crate client_traits; extern crate common_types as types; -extern crate engine; extern crate ethash; extern crate ethcore; extern crate fastmap; @@ -105,6 +104,9 @@ extern crate serde_derive; #[cfg(test)] extern crate rand_xorshift; +#[cfg(test)] +extern crate engine; + #[cfg(test)] extern crate ethjson; #[cfg(test)] diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index f50d79b5a..50237326a 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -24,9 +24,10 @@ use rlp::Rlp; use ethereum_types::{Address, H64, H160, H256, U64, U256, BigEndianHash}; use parking_lot::Mutex; +use account_state::state::StateInfo; use client_traits::{BlockChainClient, StateClient, ProvingBlockChainClient, StateOrBlock}; use ethash::{self, SeedHashCompute}; -use ethcore::client::{StateInfo, Call, EngineInfo}; +use ethcore::client::{Call, EngineInfo}; use ethcore::miner::{self, MinerService}; use ethcore::snapshot::SnapshotService; use hash::keccak; @@ -37,7 +38,8 @@ use types::{ encoded, ids::{BlockId, TransactionId, UncleId}, filter::Filter as EthcoreFilter, - transaction::{SignedTransaction, LocalizedTransaction} + transaction::{SignedTransaction, LocalizedTransaction}, + snapshot::RestorationStatus, }; use jsonrpc_core::{BoxFuture, Result}; @@ -518,8 +520,6 @@ impl Eth for EthClient< } fn syncing(&self) -> Result { - use ethcore::snapshot::RestorationStatus; - let status = self.sync.status(); let client = &self.client; let snapshot_status = self.snapshot.status(); diff --git a/rpc/src/v1/impls/parity.rs b/rpc/src/v1/impls/parity.rs index 75e69dcbf..0dd657213 100644 --- a/rpc/src/v1/impls/parity.rs +++ b/rpc/src/v1/impls/parity.rs @@ -23,7 +23,7 @@ use ethereum_types::{H64, H160, H256, H512, U64, U256}; use ethcore::client::Call; use client_traits::{BlockChainClient, StateClient}; use ethcore::miner::{self, MinerService, FilterOptions}; -use ethcore::snapshot::{SnapshotService, RestorationStatus}; +use ethcore::snapshot::SnapshotService; use account_state::state::StateInfo; use ethcore_logger::RotatingLogger; use ethkey::{crypto::ecies, Brain, Generator}; @@ -34,6 +34,7 @@ use sync::{SyncProvider, ManageNetwork}; use types::{ ids::BlockId, verification::Unverified, + snapshot::RestorationStatus, }; use updater::{Service as UpdateService}; use version::version_data; diff --git a/rpc/src/v1/impls/traces.rs b/rpc/src/v1/impls/traces.rs index 4d0ccc1a9..112e8eab7 100644 --- a/rpc/src/v1/impls/traces.rs +++ b/rpc/src/v1/impls/traces.rs @@ -18,7 +18,8 @@ use std::sync::Arc; -use ethcore::client::{StateInfo, Call}; +use account_state::state::StateInfo; +use ethcore::client::Call; use client_traits::{BlockChainClient, StateClient}; use ethereum_types::H256; use rlp::Rlp; diff --git a/rpc/src/v1/tests/helpers/snapshot_service.rs b/rpc/src/v1/tests/helpers/snapshot_service.rs index 881c434e1..aee9a6681 100644 --- a/rpc/src/v1/tests/helpers/snapshot_service.rs +++ b/rpc/src/v1/tests/helpers/snapshot_service.rs @@ -14,11 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Parity Ethereum. If not, see . -use ethcore::snapshot::{ManifestData, RestorationStatus, SnapshotService}; +use ethcore::snapshot::SnapshotService; use bytes::Bytes; use ethereum_types::H256; use parking_lot::Mutex; +use types::snapshot::{ManifestData, RestorationStatus}; /// Mocked snapshot service (used for sync info extensions). pub struct TestSnapshotService { @@ -48,8 +49,8 @@ impl SnapshotService for TestSnapshotService { fn status(&self) -> RestorationStatus { self.status.lock().clone() } fn begin_restore(&self, _manifest: ManifestData) { } fn abort_restore(&self) { } - fn abort_snapshot(&self) {} fn restore_state_chunk(&self, _hash: H256, _chunk: Bytes) { } fn restore_block_chunk(&self, _hash: H256, _chunk: Bytes) { } + fn abort_snapshot(&self) {} fn shutdown(&self) { } } diff --git a/rpc/src/v1/tests/mocked/eth.rs b/rpc/src/v1/tests/mocked/eth.rs index 7477eec69..9a40d2700 100644 --- a/rpc/src/v1/tests/mocked/eth.rs +++ b/rpc/src/v1/tests/mocked/eth.rs @@ -36,6 +36,7 @@ use types::{ transaction::{Transaction, Action}, log_entry::{LocalizedLogEntry, LogEntry}, receipt::{LocalizedReceipt, TransactionOutcome}, + snapshot::RestorationStatus, }; use jsonrpc_core::IoHandler; @@ -131,8 +132,6 @@ fn rpc_eth_protocol_version() { #[test] fn rpc_eth_syncing() { - use ethcore::snapshot::RestorationStatus; - let request = r#"{"jsonrpc": "2.0", "method": "eth_syncing", "params": [], "id": 1}"#; let tester = EthTester::default();