Move more types out of ethcore (#10880)
* WIP move errors, pod_account and state account to own crates * Sort out dependencies, fix broken code and tests Remove botched ethcore-error crate * remove template line * fix review feedback * Remove test-only AccountDBMut::new * Extract AccountDB to account-db * Move Substate to state-account – wip * Add lib.rs * cleanup * test failure * test failure 2 * third time's the charm * Add factories crate * Use new factories crate * Use factories crate * Extract trace * Fix tests * Sort out parity-util-mem and parking_lot * cleanup * WIP port over the rest of state from ethcore * Collect all impls for Machine * some notes * Rename pod-account to pod * Move PodState to pod crate * Use PodState from pod crate * Fix use clause for json tests * Sort out evmbin * Add missing code and use PodState * Move code that depends on Machine and Executive to own module * Sort out cloning errors, fix ethcore to use new state crate * Do without funky From impls * Fix ethcore tests * Fixes around the project to use new state crate * Add back the more specific impls of StateOrBlock From conversions * Move execute to freestanding function and remove it from trait Sort out the error handling in executive_state by moving the result types from state to ethcore Undo the verbose code added to work around the StateOrBlock From conversions * cleanup * Fix "error: enum variants on type aliases are experimental" * Bring back the state tests Fix whitespace * remove ethcore/state/mod.rs * cleanup * cleanup * Cleanup state-account errors * Fix more todos Add module docs * Add error.rs * Fixup Cargo.lock * Smaller ethcore API is fine * Add `to-pod-full` feature to state-account Fix evmbin * Fix a few more test failures * Fix RPC test build * Baptize the new trait * Remove resolved TODOs * Rename state-account to account-state * Do not re-export the trace crate * Don't export state_db from ethcore * Let private-tx use StateDB. :( * Remove ethcore/src/pod_state.rs * Inner type does not need to be pub/pub(crate) * optimise imports * Revert "Inner type does not need to be pub/pub(crate)" This reverts commit 2f839f8a0f72f71334da64620f57e6dd6039f06b. * Move DatabaseExtras to ethcore-blockchain * Add database_extra module to ethcore-blockchain * Remove to-pod-full feature * cosmetics * New crate: state-db * Add new crate * Move PreverifiedBlock and BlockError to types * Sort out the merge * Add missing `license` meta data keys * wip * wip client-traits * merge conflict * verification crate type checks * Move impls for CommonParams to common_types Fix misc stuff in ethcore * Fix tests * Implement VerifyingEngine for all engines except Ethash Temporarily sort out error handling Move more types to common_types * Split Engine in two and move code around * cleanup * verification: don't rexport common_types * Use error from common_types * Consolidate error types * VerifyingEngine use Errors from common_types * verification: Use error type from common_types * SnapshotError moved to common_types * Move more code from Engne to VerifyingEngine Add a VerifyingClient trait: BlockInfo + CallContract Whitespace * Add MAX_UNCLE_AGE const * Port over remaining code from ethcore/verification * Use errors from common_types * Fix the confusing "io" naming * Move more types into common_types * Add todos * Experiment with Engine trait outside ethcore * Hook up types from common_types in ethcore Don't use verification crate Don't use client-traits crate * Revert to impl Engine for Arc<Ethash> and add note to explain why Revert moving ClientIoMessage to common_types Fix build * Remove ClientIoMessage from common_types * Cleanup * More cleanup * Sort error handling changes in the rest of parity * Remove unused code * Remove WIP types * Cleanup todos not tackled here * remove cruft * Fix some whitespace and a merge error * ethcore tests * test failures * Restore Engine impls to master to make review a bit easier * cleanup * whitespace * applied review suggestions * types does not depend on rustc-hex * ethash engine moved to engine module * applied review suggestion
This commit is contained in:
parent
7f707fa524
commit
1ef9d5b52f
37
Cargo.lock
generated
37
Cargo.lock
generated
@ -454,16 +454,22 @@ dependencies = [
|
|||||||
name = "common-types"
|
name = "common-types"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"ethbloom 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"ethcore-io 1.12.0",
|
||||||
"ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ethjson 0.1.0",
|
"ethjson 0.1.0",
|
||||||
"ethkey 0.3.0",
|
"ethkey 0.3.0",
|
||||||
"keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"parity-snappy 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"patricia-trie-ethereum 0.1.0",
|
||||||
"rlp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rlp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rlp_derive 0.1.0",
|
"rlp_derive 0.1.0",
|
||||||
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"unexpected 0.1.0",
|
"unexpected 0.1.0",
|
||||||
|
"vm 0.1.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -513,7 +519,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"thread-scoped 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"thread-scoped 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
@ -854,7 +860,6 @@ dependencies = [
|
|||||||
"common-types 0.1.0",
|
"common-types 0.1.0",
|
||||||
"criterion 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"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)",
|
"crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"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)",
|
"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.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ethabi-contract 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ethabi-contract 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -889,7 +894,7 @@ dependencies = [
|
|||||||
"lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"macros 0.1.0",
|
"macros 0.1.0",
|
||||||
"memory-cache 0.1.0",
|
"memory-cache 0.1.0",
|
||||||
"num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"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-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"parity-runtime 0.1.0",
|
"parity-runtime 0.1.0",
|
||||||
"parity-snappy 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parity-snappy 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -1020,7 +1025,7 @@ dependencies = [
|
|||||||
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
"mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"slab 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"slab 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -1032,7 +1037,6 @@ dependencies = [
|
|||||||
name = "ethcore-light"
|
name = "ethcore-light"
|
||||||
version = "1.12.0"
|
version = "1.12.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"account-state 0.1.0",
|
|
||||||
"bincode 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bincode 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"common-types 0.1.0",
|
"common-types 0.1.0",
|
||||||
"derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"derive_more 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -1268,6 +1272,7 @@ name = "ethcore-service"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"common-types 0.1.0",
|
||||||
"ethcore 1.12.0",
|
"ethcore 1.12.0",
|
||||||
"ethcore-blockchain 0.1.0",
|
"ethcore-blockchain 0.1.0",
|
||||||
"ethcore-db 0.1.0",
|
"ethcore-db 0.1.0",
|
||||||
@ -1426,7 +1431,7 @@ dependencies = [
|
|||||||
"docopt 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"docopt 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ethstore 0.2.1",
|
"ethstore 0.2.1",
|
||||||
"num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"panic_hook 0.1.0",
|
"panic_hook 0.1.0",
|
||||||
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"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)",
|
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -1621,7 +1626,7 @@ version = "0.1.8"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -2071,7 +2076,7 @@ dependencies = [
|
|||||||
"jsonrpc-core 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"jsonrpc-core 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.3.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.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"tokio 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"tokio 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"unicase 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"unicase 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -2168,7 +2173,7 @@ dependencies = [
|
|||||||
"interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"parity-rocksdb 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parity-rocksdb 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -2551,7 +2556,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num_cpus"
|
name = "num_cpus"
|
||||||
version = "1.10.0"
|
version = "1.10.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -2703,7 +2708,7 @@ dependencies = [
|
|||||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"migration-rocksdb 0.1.0",
|
"migration-rocksdb 0.1.0",
|
||||||
"node-filter 1.12.0",
|
"node-filter 1.12.0",
|
||||||
"num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"number_prefix 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"number_prefix 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"panic_hook 0.1.0",
|
"panic_hook 0.1.0",
|
||||||
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -3469,7 +3474,7 @@ dependencies = [
|
|||||||
"crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -4086,7 +4091,7 @@ name = "threadpool"
|
|||||||
version = "1.7.1"
|
version = "1.7.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -4209,7 +4214,7 @@ dependencies = [
|
|||||||
"lazy_static 1.3.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.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
"mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"slab 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"slab 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"tokio-executor 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"tokio-executor 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -4257,7 +4262,7 @@ dependencies = [
|
|||||||
"crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"tokio-executor 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"tokio-executor 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
@ -4973,7 +4978,7 @@ dependencies = [
|
|||||||
"checksum num-iter 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "af3fdbbc3291a5464dc57b03860ec37ca6bf915ed6ee385e7c6c052c422b2124"
|
"checksum num-iter 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "af3fdbbc3291a5464dc57b03860ec37ca6bf915ed6ee385e7c6c052c422b2124"
|
||||||
"checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31"
|
"checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31"
|
||||||
"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"
|
"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"
|
||||||
"checksum num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a23f0ed30a54abaa0c7e83b1d2d87ada7c3c23078d1d87815af3e3b6385fbba"
|
"checksum num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273"
|
||||||
"checksum number_prefix 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dbf9993e59c894e3c08aa1c2712914e9e6bf1fcbfc6bef283e2183df345a4fee"
|
"checksum number_prefix 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dbf9993e59c894e3c08aa1c2712914e9e6bf1fcbfc6bef283e2183df345a4fee"
|
||||||
"checksum ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2c49021782e5233cd243168edfa8037574afed4eba4bbaf538b3d8d1789d8c"
|
"checksum ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2c49021782e5233cd243168edfa8037574afed4eba4bbaf538b3d8d1789d8c"
|
||||||
"checksum opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "93f5bb2e8e8dec81642920ccff6b61f1eb94fa3020c5a325c9851ff604152409"
|
"checksum opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "93f5bb2e8e8dec81642920ccff6b61f1eb94fa3020c5a325c9851ff604152409"
|
||||||
|
@ -12,7 +12,6 @@ ansi_term = "0.11"
|
|||||||
blooms-db = { path = "../util/blooms-db", optional = true }
|
blooms-db = { path = "../util/blooms-db", optional = true }
|
||||||
common-types = { path = "types" }
|
common-types = { path = "types" }
|
||||||
crossbeam-utils = "0.6"
|
crossbeam-utils = "0.6"
|
||||||
derive_more = "0.14.0"
|
|
||||||
env_logger = { version = "0.5", optional = true }
|
env_logger = { version = "0.5", optional = true }
|
||||||
ethabi = "8.0"
|
ethabi = "8.0"
|
||||||
ethabi-contract = "8.0"
|
ethabi-contract = "8.0"
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
description = "DB backend wrapper for Account trie"
|
|
||||||
name = "account-db"
|
name = "account-db"
|
||||||
version = "0.1.0"
|
description = "DB backend wrapper for Account trie"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
|
license = "GPL-3.0"
|
||||||
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
description = "Ethereum accounts, keeps track of changes to the code and storage"
|
|
||||||
name = "account-state"
|
name = "account-state"
|
||||||
version = "0.1.0"
|
description = "Ethereum accounts, keeps track of changes to the code and storage"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
|
license = "GPL-3.0"
|
||||||
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -29,7 +29,6 @@ use lru_cache::LruCache;
|
|||||||
use parity_bytes::{Bytes, ToPretty};
|
use parity_bytes::{Bytes, ToPretty};
|
||||||
use rlp::{DecoderError, encode};
|
use rlp::{DecoderError, encode};
|
||||||
use trie_db::{Recorder, Trie};
|
use trie_db::{Recorder, Trie};
|
||||||
|
|
||||||
use common_types::basic_account::BasicAccount;
|
use common_types::basic_account::BasicAccount;
|
||||||
use ethtrie::{Result as TrieResult, SecTrieDB, TrieDB, TrieFactory};
|
use ethtrie::{Result as TrieResult, SecTrieDB, TrieDB, TrieFactory};
|
||||||
use keccak_hasher::KeccakHasher;
|
use keccak_hasher::KeccakHasher;
|
||||||
|
@ -29,7 +29,6 @@ use hash_db::{AsHashDB, EMPTY_PREFIX, HashDB, Prefix};
|
|||||||
use kvdb::DBValue;
|
use kvdb::DBValue;
|
||||||
use memory_db::{HashKey, MemoryDB};
|
use memory_db::{HashKey, MemoryDB};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
|
|
||||||
use journaldb::AsKeyedHashDB;
|
use journaldb::AsKeyedHashDB;
|
||||||
use keccak_hasher::KeccakHasher;
|
use keccak_hasher::KeccakHasher;
|
||||||
|
|
||||||
@ -222,7 +221,7 @@ impl<H: AsHashDB<KeccakHasher, DBValue>> Proving<H> {
|
|||||||
/// This will store all values ever fetched from that base.
|
/// This will store all values ever fetched from that base.
|
||||||
pub fn new(base: H) -> Self {
|
pub fn new(base: H) -> Self {
|
||||||
Proving {
|
Proving {
|
||||||
base: base,
|
base,
|
||||||
changed: journaldb::new_memory_db(),
|
changed: journaldb::new_memory_db(),
|
||||||
proof: Mutex::new(HashSet::new()),
|
proof: Mutex::new(HashSet::new()),
|
||||||
}
|
}
|
||||||
|
@ -25,11 +25,9 @@
|
|||||||
pub mod account;
|
pub mod account;
|
||||||
pub mod backend;
|
pub mod backend;
|
||||||
pub mod state;
|
pub mod state;
|
||||||
pub mod error;
|
|
||||||
|
|
||||||
pub use {
|
pub use {
|
||||||
account::Account,
|
account::Account,
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
error::Error,
|
|
||||||
state::{State, CleanupMode},
|
state::{State, CleanupMode},
|
||||||
};
|
};
|
||||||
|
@ -32,6 +32,7 @@ use std::{
|
|||||||
use common_types::{
|
use common_types::{
|
||||||
state_diff::StateDiff,
|
state_diff::StateDiff,
|
||||||
basic_account::BasicAccount,
|
basic_account::BasicAccount,
|
||||||
|
errors::EthcoreError as Error,
|
||||||
};
|
};
|
||||||
use ethereum_types::{Address, H256, U256};
|
use ethereum_types::{Address, H256, U256};
|
||||||
use ethtrie::{TrieDB, Result as TrieResult};
|
use ethtrie::{TrieDB, Result as TrieResult};
|
||||||
@ -46,7 +47,6 @@ use pod::{self, PodAccount, PodState};
|
|||||||
use trie_db::{Trie, TrieError, Recorder};
|
use trie_db::{Trie, TrieError, Recorder};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Error,
|
|
||||||
account::Account,
|
account::Account,
|
||||||
backend::Backend,
|
backend::Backend,
|
||||||
};
|
};
|
||||||
|
@ -35,7 +35,6 @@ itertools = "0.5"
|
|||||||
bincode = "1.1"
|
bincode = "1.1"
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
serde_derive = "1.0"
|
serde_derive = "1.0"
|
||||||
account-state = { path = "../account-state" }
|
|
||||||
parking_lot = "0.8"
|
parking_lot = "0.8"
|
||||||
stats = { path = "../../util/stats" }
|
stats = { path = "../../util/stats" }
|
||||||
keccak-hash = "0.2.0"
|
keccak-hash = "0.2.0"
|
||||||
|
@ -30,12 +30,14 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use cache::Cache;
|
use cache::Cache;
|
||||||
use cht;
|
use cht;
|
||||||
use common_types::block_status::BlockStatus;
|
use common_types::{
|
||||||
use common_types::encoded;
|
block_status::BlockStatus,
|
||||||
use common_types::header::Header;
|
encoded,
|
||||||
use common_types::ids::BlockId;
|
errors::{EthcoreError as Error, BlockError, EthcoreResult},
|
||||||
|
header::Header,
|
||||||
|
ids::BlockId,
|
||||||
|
};
|
||||||
use ethcore::engines::epoch::{Transition as EpochTransition, PendingTransition as PendingEpochTransition};
|
use ethcore::engines::epoch::{Transition as EpochTransition, PendingTransition as PendingEpochTransition};
|
||||||
use ethcore::error::{Error, EthcoreResult, BlockError};
|
|
||||||
use ethcore::spec::{Spec, SpecHardcodedSync};
|
use ethcore::spec::{Spec, SpecHardcodedSync};
|
||||||
use ethereum_types::{H256, H264, U256};
|
use ethereum_types::{H256, H264, U256};
|
||||||
use parity_util_mem::{MallocSizeOf, MallocSizeOfOps};
|
use parity_util_mem::{MallocSizeOf, MallocSizeOfOps};
|
||||||
|
@ -20,21 +20,23 @@ use std::sync::{Weak, Arc};
|
|||||||
|
|
||||||
use ethcore::client::{ClientReport, EnvInfo, ClientIoMessage};
|
use ethcore::client::{ClientReport, EnvInfo, ClientIoMessage};
|
||||||
use ethcore::engines::{epoch, Engine, EpochChange, EpochTransition, Proof};
|
use ethcore::engines::{epoch, Engine, EpochChange, EpochTransition, Proof};
|
||||||
use ethcore::error::{Error, EthcoreResult};
|
|
||||||
use ethcore::verification::queue::{self, HeaderQueue};
|
use ethcore::verification::queue::{self, HeaderQueue};
|
||||||
use ethcore::spec::{Spec, SpecHardcodedSync};
|
use ethcore::spec::{Spec, SpecHardcodedSync};
|
||||||
use io::IoChannel;
|
use io::IoChannel;
|
||||||
use parking_lot::{Mutex, RwLock};
|
use parking_lot::{Mutex, RwLock};
|
||||||
use ethereum_types::{H256, U256};
|
use ethereum_types::{H256, U256};
|
||||||
use futures::{IntoFuture, Future};
|
use futures::{IntoFuture, Future};
|
||||||
use common_types::BlockNumber;
|
use common_types::{
|
||||||
use common_types::block_status::BlockStatus;
|
BlockNumber,
|
||||||
use common_types::blockchain_info::BlockChainInfo;
|
block_status::BlockStatus,
|
||||||
use common_types::encoded;
|
blockchain_info::BlockChainInfo,
|
||||||
use common_types::header::Header;
|
encoded,
|
||||||
use common_types::ids::BlockId;
|
errors::EthcoreError as Error,
|
||||||
use common_types::verification_queue_info::VerificationQueueInfo as BlockQueueInfo;
|
errors::EthcoreResult,
|
||||||
|
header::Header,
|
||||||
|
ids::BlockId,
|
||||||
|
verification_queue_info::VerificationQueueInfo as BlockQueueInfo,
|
||||||
|
};
|
||||||
use kvdb::KeyValueDB;
|
use kvdb::KeyValueDB;
|
||||||
|
|
||||||
use self::fetch::ChainDataFetcher;
|
use self::fetch::ChainDataFetcher;
|
||||||
@ -468,7 +470,7 @@ impl<T: ChainDataFetcher> Client<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn check_epoch_signal(&self, verified_header: &Header) -> Result<Option<Proof>, T::Error> {
|
fn check_epoch_signal(&self, verified_header: &Header) -> Result<Option<Proof>, T::Error> {
|
||||||
use ethcore::machine::{AuxiliaryRequest, AuxiliaryData};
|
use common_types::engines::machine::{AuxiliaryRequest, AuxiliaryData};
|
||||||
|
|
||||||
let mut block: Option<Vec<u8>> = None;
|
let mut block: Option<Vec<u8>> = None;
|
||||||
let mut receipts: Option<Vec<_>> = None;
|
let mut receipts: Option<Vec<_>> = None;
|
||||||
|
@ -20,10 +20,10 @@
|
|||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use common_types::errors::EthcoreError as CoreError;
|
||||||
use ethcore_db as db;
|
use ethcore_db as db;
|
||||||
use ethcore_blockchain::BlockChainDB;
|
use ethcore_blockchain::BlockChainDB;
|
||||||
use ethcore::client::ClientIoMessage;
|
use ethcore::client::ClientIoMessage;
|
||||||
use ethcore::error::Error as CoreError;
|
|
||||||
use ethcore::spec::Spec;
|
use ethcore::spec::Spec;
|
||||||
use io::{IoContext, IoError, IoHandler, IoService};
|
use io::{IoContext, IoError, IoHandler, IoService};
|
||||||
|
|
||||||
|
@ -89,7 +89,6 @@ extern crate triehash_ethereum as triehash;
|
|||||||
extern crate kvdb;
|
extern crate kvdb;
|
||||||
extern crate memory_cache;
|
extern crate memory_cache;
|
||||||
extern crate derive_more;
|
extern crate derive_more;
|
||||||
extern crate account_state;
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
extern crate kvdb_memorydb;
|
extern crate kvdb_memorydb;
|
||||||
|
@ -26,7 +26,6 @@ use common_types::receipt::Receipt;
|
|||||||
use common_types::transaction::SignedTransaction;
|
use common_types::transaction::SignedTransaction;
|
||||||
use ethcore::engines::{Engine, StateDependentProof};
|
use ethcore::engines::{Engine, StateDependentProof};
|
||||||
use ethcore::executive_state::{ProvedExecution, self};
|
use ethcore::executive_state::{ProvedExecution, self};
|
||||||
use account_state;
|
|
||||||
use ethereum_types::{H256, U256, Address};
|
use ethereum_types::{H256, U256, Address};
|
||||||
use ethtrie::{TrieError, TrieDB};
|
use ethtrie::{TrieError, TrieDB};
|
||||||
use hash::{KECCAK_NULL_RLP, KECCAK_EMPTY, KECCAK_EMPTY_LIST_RLP, keccak};
|
use hash::{KECCAK_NULL_RLP, KECCAK_EMPTY, KECCAK_EMPTY_LIST_RLP, keccak};
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
description = "State/Account system expressed in Plain Old Data."
|
|
||||||
name = "pod"
|
name = "pod"
|
||||||
version = "0.1.0"
|
description = "State/Account system expressed in Plain Old Data."
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
|
license = "GPL-3.0"
|
||||||
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -19,8 +19,10 @@ use derive_more::Display;
|
|||||||
use ethereum_types::Address;
|
use ethereum_types::Address;
|
||||||
use rlp::DecoderError;
|
use rlp::DecoderError;
|
||||||
use ethtrie::TrieError;
|
use ethtrie::TrieError;
|
||||||
use ethcore::error::{Error as EthcoreError, ExecutionError};
|
use types::{
|
||||||
use types::transaction::Error as TransactionError;
|
errors::{EthcoreError, ExecutionError},
|
||||||
|
transaction::Error as TransactionError,
|
||||||
|
};
|
||||||
use ethkey::Error as KeyError;
|
use ethkey::Error as KeyError;
|
||||||
use ethkey::crypto::Error as CryptoError;
|
use ethkey::crypto::Error as CryptoError;
|
||||||
use txpool::VerifiedTransaction;
|
use txpool::VerifiedTransaction;
|
||||||
|
@ -6,6 +6,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
ansi_term = "0.11"
|
ansi_term = "0.11"
|
||||||
|
common-types = { path = "../types" }
|
||||||
ethcore = { path = ".." }
|
ethcore = { path = ".." }
|
||||||
ethcore-blockchain = { path = "../blockchain" }
|
ethcore-blockchain = { path = "../blockchain" }
|
||||||
ethcore-io = { path = "../../util/io" }
|
ethcore-io = { path = "../../util/io" }
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
extern crate ansi_term;
|
extern crate ansi_term;
|
||||||
|
extern crate common_types;
|
||||||
extern crate ethcore;
|
extern crate ethcore;
|
||||||
extern crate ethcore_blockchain as blockchain;
|
extern crate ethcore_blockchain as blockchain;
|
||||||
extern crate ethcore_io as io;
|
extern crate ethcore_io as io;
|
||||||
|
@ -29,9 +29,9 @@ use blockchain::{BlockChainDB, BlockChainDBHandler};
|
|||||||
use ethcore::client::{Client, ClientConfig, ChainNotify, ClientIoMessage};
|
use ethcore::client::{Client, ClientConfig, ChainNotify, ClientIoMessage};
|
||||||
use ethcore::miner::Miner;
|
use ethcore::miner::Miner;
|
||||||
use ethcore::snapshot::service::{Service as SnapshotService, ServiceParams as SnapServiceParams};
|
use ethcore::snapshot::service::{Service as SnapshotService, ServiceParams as SnapServiceParams};
|
||||||
use ethcore::snapshot::{SnapshotService as _SnapshotService, RestorationStatus, Error as SnapshotError};
|
use ethcore::snapshot::{SnapshotService as _SnapshotService, RestorationStatus};
|
||||||
use ethcore::spec::Spec;
|
use ethcore::spec::Spec;
|
||||||
use ethcore::error::Error as EthcoreError;
|
use common_types::errors::{EthcoreError, SnapshotError};
|
||||||
|
|
||||||
|
|
||||||
use ethcore_private_tx::{self, Importer, Signer};
|
use ethcore_private_tx::{self, Importer, Signer};
|
||||||
|
@ -39,21 +39,23 @@ use bytes::Bytes;
|
|||||||
use ethereum_types::{H256, U256, Address, Bloom};
|
use ethereum_types::{H256, U256, Address, Bloom};
|
||||||
|
|
||||||
use engines::Engine;
|
use engines::Engine;
|
||||||
use error::{Error, BlockError};
|
|
||||||
use trie_vm_factories::Factories;
|
use trie_vm_factories::Factories;
|
||||||
use state_db::StateDB;
|
use state_db::StateDB;
|
||||||
use account_state::State;
|
use account_state::State;
|
||||||
use trace::Tracing;
|
use trace::Tracing;
|
||||||
use triehash::ordered_trie_root;
|
use triehash::ordered_trie_root;
|
||||||
use unexpected::{Mismatch, OutOfBounds};
|
use unexpected::{Mismatch, OutOfBounds};
|
||||||
use verification::PreverifiedBlock;
|
|
||||||
use vm::{EnvInfo, LastHashes};
|
use vm::{EnvInfo, LastHashes};
|
||||||
|
|
||||||
use hash::keccak;
|
use hash::keccak;
|
||||||
use rlp::{RlpStream, Encodable, encode_list};
|
use rlp::{RlpStream, Encodable, encode_list};
|
||||||
use types::transaction::{SignedTransaction, Error as TransactionError};
|
use types::{
|
||||||
use types::header::Header;
|
block::PreverifiedBlock,
|
||||||
use types::receipt::{Receipt, TransactionOutcome};
|
errors::{EthcoreError as Error, BlockError},
|
||||||
|
transaction::{SignedTransaction, Error as TransactionError},
|
||||||
|
header::Header,
|
||||||
|
receipt::{Receipt, TransactionOutcome},
|
||||||
|
};
|
||||||
use executive_state::ExecutiveState;
|
use executive_state::ExecutiveState;
|
||||||
|
|
||||||
/// Block that is ready for transactions to be added.
|
/// Block that is ready for transactions to be added.
|
||||||
@ -550,16 +552,16 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use engines::Engine;
|
use engines::Engine;
|
||||||
use vm::LastHashes;
|
use vm::LastHashes;
|
||||||
use error::Error;
|
|
||||||
use trie_vm_factories::Factories;
|
use trie_vm_factories::Factories;
|
||||||
use state_db::StateDB;
|
use state_db::StateDB;
|
||||||
use ethereum_types::Address;
|
use ethereum_types::Address;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use verification::queue::kind::blocks::Unverified;
|
use verification::queue::kind::blocks::Unverified;
|
||||||
use types::transaction::SignedTransaction;
|
use types::transaction::SignedTransaction;
|
||||||
use types::header::Header;
|
use types::{
|
||||||
use types::view;
|
header::Header, view, views::BlockView,
|
||||||
use types::views::BlockView;
|
errors::EthcoreError as Error,
|
||||||
|
};
|
||||||
use hash_db::EMPTY_PREFIX;
|
use hash_db::EMPTY_PREFIX;
|
||||||
|
|
||||||
/// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header
|
/// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header
|
||||||
|
@ -23,7 +23,10 @@ use engines::{Engine, EpochVerifier};
|
|||||||
use blockchain::BlockChain;
|
use blockchain::BlockChain;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use types::header::Header;
|
use types::{
|
||||||
|
header::Header,
|
||||||
|
errors::EthcoreError,
|
||||||
|
};
|
||||||
|
|
||||||
// do "heavy" verification on ~1/50 blocks, randomly sampled.
|
// do "heavy" verification on ~1/50 blocks, randomly sampled.
|
||||||
const HEAVY_VERIFY_RATE: f32 = 0.02;
|
const HEAVY_VERIFY_RATE: f32 = 0.02;
|
||||||
@ -51,7 +54,7 @@ impl AncientVerifier {
|
|||||||
rng: &mut R,
|
rng: &mut R,
|
||||||
header: &Header,
|
header: &Header,
|
||||||
chain: &BlockChain,
|
chain: &BlockChain,
|
||||||
) -> Result<(), ::error::Error> {
|
) -> Result<(), EthcoreError> {
|
||||||
// perform verification
|
// perform verification
|
||||||
let verified = if let Some(ref cur_verifier) = *self.cur_verifier.read() {
|
let verified = if let Some(ref cur_verifier) = *self.cur_verifier.read() {
|
||||||
match rng.gen::<f32>() <= HEAVY_VERIFY_RATE {
|
match rng.gen::<f32>() <= HEAVY_VERIFY_RATE {
|
||||||
@ -86,7 +89,7 @@ impl AncientVerifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn initial_verifier(&self, header: &Header, chain: &BlockChain)
|
fn initial_verifier(&self, header: &Header, chain: &BlockChain)
|
||||||
-> Result<Box<dyn EpochVerifier>, ::error::Error>
|
-> Result<Box<dyn EpochVerifier>, EthcoreError>
|
||||||
{
|
{
|
||||||
trace!(target: "client", "Initializing ancient block restoration.");
|
trace!(target: "client", "Initializing ancient block restoration.");
|
||||||
let current_epoch_data = chain.epoch_transitions()
|
let current_epoch_data = chain.epoch_transitions()
|
||||||
|
@ -33,38 +33,25 @@ use journaldb;
|
|||||||
use kvdb::{DBValue, KeyValueDB, DBTransaction};
|
use kvdb::{DBValue, KeyValueDB, DBTransaction};
|
||||||
use parking_lot::{Mutex, RwLock};
|
use parking_lot::{Mutex, RwLock};
|
||||||
use rand::rngs::OsRng;
|
use rand::rngs::OsRng;
|
||||||
use types::transaction::{self, LocalizedTransaction, UnverifiedTransaction, SignedTransaction, Action};
|
|
||||||
use trie::{TrieSpec, TrieFactory, Trie};
|
use trie::{TrieSpec, TrieFactory, Trie};
|
||||||
use types::ancestry_action::AncestryAction;
|
|
||||||
use types::encoded;
|
|
||||||
use types::filter::Filter;
|
|
||||||
use types::log_entry::LocalizedLogEntry;
|
|
||||||
use types::receipt::{Receipt, LocalizedReceipt};
|
|
||||||
use types::{BlockNumber, header::Header};
|
|
||||||
use vm::{EnvInfo, LastHashes, CreateContractAddress};
|
use vm::{EnvInfo, LastHashes, CreateContractAddress};
|
||||||
use hash_db::EMPTY_PREFIX;
|
use hash_db::EMPTY_PREFIX;
|
||||||
use block::{LockedBlock, Drain, ClosedBlock, OpenBlock, enact_verified, SealedBlock};
|
use block::{LockedBlock, Drain, ClosedBlock, OpenBlock, enact_verified, SealedBlock};
|
||||||
use client::ancient_import::AncientVerifier;
|
use client::ancient_import::AncientVerifier;
|
||||||
use client::{
|
use client::{
|
||||||
Nonce, Balance, ChainInfo, BlockInfo, TransactionInfo,
|
Nonce, Balance, ChainInfo, TransactionInfo,
|
||||||
ReopenBlock, PrepareOpenBlock, ScheduleInfo, ImportSealedBlock,
|
ReopenBlock, PrepareOpenBlock, ScheduleInfo, ImportSealedBlock,
|
||||||
BroadcastProposalBlock, ImportBlock, StateOrBlock, StateInfo, StateClient, Call,
|
BroadcastProposalBlock, ImportBlock, StateOrBlock, StateInfo, StateClient, Call,
|
||||||
AccountData, BlockChain as BlockChainTrait, BlockProducer, SealedBlockImporter,
|
AccountData, BlockChain as BlockChainTrait, BlockProducer, SealedBlockImporter,
|
||||||
ClientIoMessage, BlockChainReset
|
BlockChainReset
|
||||||
};
|
};
|
||||||
use client::{
|
use client::{
|
||||||
BlockId, TransactionId, UncleId, TraceId, ClientConfig, BlockChainClient,
|
BlockId, TransactionId, UncleId, TraceId, ClientConfig, BlockChainClient,
|
||||||
TraceFilter, CallAnalytics, Mode,
|
TraceFilter, CallAnalytics, Mode,
|
||||||
ChainNotify, NewBlocks, ChainRoute, PruningInfo, ProvingBlockChainClient, EngineInfo, ChainMessageType,
|
ChainNotify, NewBlocks, ChainRoute, PruningInfo, ProvingBlockChainClient, EngineInfo, ChainMessageType,
|
||||||
IoClient, BadBlocks,
|
IoClient, BadBlocks, bad_blocks, BlockInfo, ClientIoMessage,
|
||||||
};
|
|
||||||
use client::bad_blocks;
|
|
||||||
use engines::{MAX_UNCLE_AGE, Engine, EpochTransition, ForkChoice, EngineError, SealingState};
|
|
||||||
use engines::epoch::PendingTransition;
|
|
||||||
use error::{
|
|
||||||
ImportError, ExecutionError, CallError, BlockError,
|
|
||||||
Error as EthcoreError, EthcoreResult,
|
|
||||||
};
|
};
|
||||||
|
use engines::{Engine, EpochTransition, ForkChoice};
|
||||||
use executive::{Executive, Executed, TransactOptions, contract_address};
|
use executive::{Executive, Executed, TransactOptions, contract_address};
|
||||||
use trie_vm_factories::{Factories, VmFactory};
|
use trie_vm_factories::{Factories, VmFactory};
|
||||||
use miner::{Miner, MinerService};
|
use miner::{Miner, MinerService};
|
||||||
@ -75,18 +62,37 @@ use executive_state;
|
|||||||
use state_db::StateDB;
|
use state_db::StateDB;
|
||||||
use trace::{self, TraceDB, ImportRequest as TraceImportRequest, LocalizedTrace, Database as TraceDatabase};
|
use trace::{self, TraceDB, ImportRequest as TraceImportRequest, LocalizedTrace, Database as TraceDatabase};
|
||||||
use transaction_ext::Transaction;
|
use transaction_ext::Transaction;
|
||||||
|
use types::{
|
||||||
|
ancestry_action::AncestryAction,
|
||||||
|
BlockNumber,
|
||||||
|
block::PreverifiedBlock,
|
||||||
|
encoded,
|
||||||
|
engines::{
|
||||||
|
SealingState,
|
||||||
|
MAX_UNCLE_AGE,
|
||||||
|
epoch::PendingTransition,
|
||||||
|
machine::{AuxiliaryData, Call as MachineCall},
|
||||||
|
},
|
||||||
|
errors::{EngineError, ExecutionError, BlockError, EthcoreError, SnapshotError, ImportError, EthcoreResult},
|
||||||
|
transaction::{self, LocalizedTransaction, UnverifiedTransaction, SignedTransaction, Action, CallError},
|
||||||
|
filter::Filter,
|
||||||
|
log_entry::LocalizedLogEntry,
|
||||||
|
receipt::{Receipt, LocalizedReceipt},
|
||||||
|
header::Header,
|
||||||
|
};
|
||||||
|
|
||||||
use verification::queue::kind::BlockLike;
|
use verification::queue::kind::BlockLike;
|
||||||
use verification::queue::kind::blocks::Unverified;
|
use verification::queue::kind::blocks::Unverified;
|
||||||
use verification::{PreverifiedBlock, Verifier, BlockQueue};
|
use verification::{Verifier, BlockQueue};
|
||||||
use verification;
|
use verification;
|
||||||
use ansi_term::Colour;
|
use ansi_term::Colour;
|
||||||
|
|
||||||
// re-export
|
// re-export
|
||||||
|
pub use blockchain::CacheSize as BlockChainCacheSize;
|
||||||
|
use db::{Writable, Readable, keys::BlockDetails};
|
||||||
pub use types::blockchain_info::BlockChainInfo;
|
pub use types::blockchain_info::BlockChainInfo;
|
||||||
pub use types::block_status::BlockStatus;
|
pub use types::block_status::BlockStatus;
|
||||||
pub use blockchain::CacheSize as BlockChainCacheSize;
|
pub use types::verification_queue_info::VerificationQueueInfo as BlockQueueInfo;
|
||||||
pub use verification::QueueInfo as BlockQueueInfo;
|
|
||||||
use db::{Writable, Readable, keys::BlockDetails};
|
|
||||||
|
|
||||||
use_contract!(registry, "res/contracts/registrar.json");
|
use_contract!(registry, "res/contracts/registrar.json");
|
||||||
|
|
||||||
@ -249,7 +255,12 @@ impl Importer {
|
|||||||
message_channel: IoChannel<ClientIoMessage>,
|
message_channel: IoChannel<ClientIoMessage>,
|
||||||
miner: Arc<Miner>,
|
miner: Arc<Miner>,
|
||||||
) -> Result<Importer, EthcoreError> {
|
) -> Result<Importer, EthcoreError> {
|
||||||
let block_queue = BlockQueue::new(config.queue.clone(), engine.clone(), message_channel.clone(), config.verifier_type.verifying_seal());
|
let block_queue = BlockQueue::new(
|
||||||
|
config.queue.clone(),
|
||||||
|
engine.clone(),
|
||||||
|
message_channel.clone(),
|
||||||
|
config.verifier_type.verifying_seal()
|
||||||
|
);
|
||||||
|
|
||||||
Ok(Importer {
|
Ok(Importer {
|
||||||
import_lock: Mutex::new(()),
|
import_lock: Mutex::new(()),
|
||||||
@ -384,7 +395,7 @@ impl Importer {
|
|||||||
|
|
||||||
if let Err(e) = verify_family_result {
|
if let Err(e) = verify_family_result {
|
||||||
warn!(target: "client", "Stage 3 block verification failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e);
|
warn!(target: "client", "Stage 3 block verification failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e);
|
||||||
return Err(e.into());
|
return Err(e);
|
||||||
};
|
};
|
||||||
|
|
||||||
let verify_external_result = self.verifier.verify_block_external(&header, engine);
|
let verify_external_result = self.verifier.verify_block_external(&header, engine);
|
||||||
@ -591,7 +602,7 @@ impl Importer {
|
|||||||
use engines::EpochChange;
|
use engines::EpochChange;
|
||||||
|
|
||||||
let hash = header.hash();
|
let hash = header.hash();
|
||||||
let auxiliary = ::machine::AuxiliaryData {
|
let auxiliary = AuxiliaryData {
|
||||||
bytes: Some(block_bytes),
|
bytes: Some(block_bytes),
|
||||||
receipts: Some(&receipts),
|
receipts: Some(&receipts),
|
||||||
};
|
};
|
||||||
@ -935,7 +946,7 @@ impl Client {
|
|||||||
|
|
||||||
// use a state-proving closure for the given block.
|
// use a state-proving closure for the given block.
|
||||||
fn with_proving_caller<F, T>(&self, id: BlockId, with_call: F) -> T
|
fn with_proving_caller<F, T>(&self, id: BlockId, with_call: F) -> T
|
||||||
where F: FnOnce(&::machine::Call) -> T
|
where F: FnOnce(&MachineCall) -> T
|
||||||
{
|
{
|
||||||
let call = |a, d| {
|
let call = |a, d| {
|
||||||
let tx = self.contract_call_tx(id, a, d);
|
let tx = self.contract_call_tx(id, a, d);
|
||||||
@ -1151,10 +1162,10 @@ impl Client {
|
|||||||
) -> Result<(), EthcoreError> {
|
) -> Result<(), EthcoreError> {
|
||||||
let db = self.state_db.read().journal_db().boxed_clone();
|
let db = self.state_db.read().journal_db().boxed_clone();
|
||||||
let best_block_number = self.chain_info().best_block_number;
|
let best_block_number = self.chain_info().best_block_number;
|
||||||
let block_number = self.block_number(at).ok_or_else(|| snapshot::Error::InvalidStartingBlock(at))?;
|
let block_number = self.block_number(at).ok_or_else(|| SnapshotError::InvalidStartingBlock(at))?;
|
||||||
|
|
||||||
if db.is_prunable() && self.pruning_info().earliest_state > block_number {
|
if db.is_prunable() && self.pruning_info().earliest_state > block_number {
|
||||||
return Err(snapshot::Error::OldBlockPrunedDB.into());
|
return Err(SnapshotError::OldBlockPrunedDB.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
let history = cmp::min(self.history, 1000);
|
let history = cmp::min(self.history, 1000);
|
||||||
@ -1168,17 +1179,17 @@ impl Client {
|
|||||||
|
|
||||||
match self.block_hash(BlockId::Number(start_num)) {
|
match self.block_hash(BlockId::Number(start_num)) {
|
||||||
Some(h) => h,
|
Some(h) => h,
|
||||||
None => return Err(snapshot::Error::InvalidStartingBlock(at).into()),
|
None => return Err(SnapshotError::InvalidStartingBlock(at).into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => match self.block_hash(at) {
|
_ => match self.block_hash(at) {
|
||||||
Some(hash) => hash,
|
Some(hash) => hash,
|
||||||
None => return Err(snapshot::Error::InvalidStartingBlock(at).into()),
|
None => return Err(SnapshotError::InvalidStartingBlock(at).into()),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let processing_threads = self.config.snapshot.processing_threads;
|
let processing_threads = self.config.snapshot.processing_threads;
|
||||||
let chunker = self.engine.snapshot_components().ok_or_else(|| snapshot::Error::SnapshotsUnsupported)?;
|
let chunker = self.engine.snapshot_components().ok_or_else(|| SnapshotError::SnapshotsUnsupported)?;
|
||||||
snapshot::take_snapshot(
|
snapshot::take_snapshot(
|
||||||
chunker,
|
chunker,
|
||||||
&self.chain.read(),
|
&self.chain.read(),
|
||||||
|
@ -23,7 +23,12 @@ use {trie_vm_factories, journaldb, trie, kvdb_memorydb};
|
|||||||
use kvdb::{self, KeyValueDB};
|
use kvdb::{self, KeyValueDB};
|
||||||
use {state_db, client, executive, trace, db, spec};
|
use {state_db, client, executive, trace, db, spec};
|
||||||
use pod::PodState;
|
use pod::PodState;
|
||||||
use types::{log_entry, receipt, transaction};
|
use types::{
|
||||||
|
errors::EthcoreError,
|
||||||
|
log_entry,
|
||||||
|
receipt,
|
||||||
|
transaction
|
||||||
|
};
|
||||||
use trie_vm_factories::Factories;
|
use trie_vm_factories::Factories;
|
||||||
use evm::{VMType, FinalizationResult};
|
use evm::{VMType, FinalizationResult};
|
||||||
use vm::{self, ActionParams, CreateContractAddress};
|
use vm::{self, ActionParams, CreateContractAddress};
|
||||||
@ -41,12 +46,12 @@ pub enum EvmTestError {
|
|||||||
/// EVM error.
|
/// EVM error.
|
||||||
Evm(vm::Error),
|
Evm(vm::Error),
|
||||||
/// Initialization error.
|
/// Initialization error.
|
||||||
ClientError(::error::Error),
|
ClientError(EthcoreError),
|
||||||
/// Post-condition failure,
|
/// Post-condition failure,
|
||||||
PostCondition(String),
|
PostCondition(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E: Into<::error::Error>> From<E> for EvmTestError {
|
impl<E: Into<EthcoreError>> From<E> for EvmTestError {
|
||||||
fn from(err: E) -> Self {
|
fn from(err: E) -> Self {
|
||||||
EvmTestError::ClientError(err.into())
|
EvmTestError::ClientError(err.into())
|
||||||
}
|
}
|
||||||
@ -345,7 +350,7 @@ pub struct TransactErr {
|
|||||||
/// State root
|
/// State root
|
||||||
pub state_root: H256,
|
pub state_root: H256,
|
||||||
/// Execution error
|
/// Execution error
|
||||||
pub error: ::error::Error,
|
pub error: EthcoreError,
|
||||||
/// end state if needed
|
/// end state if needed
|
||||||
pub end_state: Option<PodState>,
|
pub end_state: Option<PodState>,
|
||||||
}
|
}
|
||||||
|
@ -36,10 +36,11 @@ use kvdb_memorydb;
|
|||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use rlp::{Rlp, RlpStream};
|
use rlp::{Rlp, RlpStream};
|
||||||
use rustc_hex::FromHex;
|
use rustc_hex::FromHex;
|
||||||
use types::transaction::{self, Transaction, LocalizedTransaction, SignedTransaction, Action};
|
use types::transaction::{self, Transaction, LocalizedTransaction, SignedTransaction, Action, CallError};
|
||||||
use types::BlockNumber;
|
use types::BlockNumber;
|
||||||
use types::basic_account::BasicAccount;
|
use types::basic_account::BasicAccount;
|
||||||
use types::encoded;
|
use types::encoded;
|
||||||
|
use types::errors::{EthcoreError as Error, EthcoreResult};
|
||||||
use types::filter::Filter;
|
use types::filter::Filter;
|
||||||
use types::header::Header;
|
use types::header::Header;
|
||||||
use types::log_entry::LocalizedLogEntry;
|
use types::log_entry::LocalizedLogEntry;
|
||||||
@ -52,16 +53,15 @@ use vm::Schedule;
|
|||||||
use block::{OpenBlock, SealedBlock, ClosedBlock};
|
use block::{OpenBlock, SealedBlock, ClosedBlock};
|
||||||
use call_contract::{CallContract, RegistryInfo};
|
use call_contract::{CallContract, RegistryInfo};
|
||||||
use client::{
|
use client::{
|
||||||
Nonce, Balance, ChainInfo, BlockInfo, ReopenBlock, TransactionInfo,
|
Nonce, Balance, ChainInfo, ReopenBlock, TransactionInfo,
|
||||||
PrepareOpenBlock, BlockChainClient, BlockChainInfo, BlockStatus, BlockId, Mode,
|
PrepareOpenBlock, BlockChainClient, BlockChainInfo, BlockStatus, BlockId, Mode,
|
||||||
TransactionId, UncleId, TraceId, TraceFilter, LastHashes, CallAnalytics,
|
TransactionId, UncleId, TraceId, TraceFilter, LastHashes, CallAnalytics,
|
||||||
ProvingBlockChainClient, ScheduleInfo, ImportSealedBlock, BroadcastProposalBlock, ImportBlock, StateOrBlock,
|
ProvingBlockChainClient, ScheduleInfo, ImportSealedBlock, BroadcastProposalBlock, ImportBlock, StateOrBlock,
|
||||||
Call, StateClient, EngineInfo, AccountData, BlockChain, BlockProducer, SealedBlockImporter, IoClient,
|
Call, StateClient, EngineInfo, AccountData, BlockChain, BlockProducer, SealedBlockImporter, IoClient,
|
||||||
BadBlocks
|
BadBlocks
|
||||||
};
|
};
|
||||||
|
use client::BlockInfo;
|
||||||
use engines::Engine;
|
use engines::Engine;
|
||||||
use error::{Error, EthcoreResult};
|
|
||||||
use executed::CallError;
|
|
||||||
use executive::Executed;
|
use executive::Executed;
|
||||||
use journaldb;
|
use journaldb;
|
||||||
use miner::{self, Miner, MinerService};
|
use miner::{self, Miner, MinerService};
|
||||||
|
@ -25,32 +25,34 @@ use ethereum_types::{H256, U256, Address};
|
|||||||
use evm::Schedule;
|
use evm::Schedule;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use kvdb::DBValue;
|
use kvdb::DBValue;
|
||||||
use types::transaction::{self, LocalizedTransaction, SignedTransaction};
|
use types::{
|
||||||
use types::BlockNumber;
|
transaction::{self, LocalizedTransaction, SignedTransaction, CallError},
|
||||||
use types::basic_account::BasicAccount;
|
BlockNumber,
|
||||||
use types::block_status::BlockStatus;
|
basic_account::BasicAccount,
|
||||||
use types::blockchain_info::BlockChainInfo;
|
block_status::BlockStatus,
|
||||||
use types::call_analytics::CallAnalytics;
|
blockchain_info::BlockChainInfo,
|
||||||
use types::encoded;
|
call_analytics::CallAnalytics,
|
||||||
use types::filter::Filter;
|
encoded,
|
||||||
use types::header::Header;
|
errors::EthcoreError as Error,
|
||||||
use types::ids::*;
|
errors::EthcoreResult,
|
||||||
use types::log_entry::LocalizedLogEntry;
|
filter::Filter,
|
||||||
use types::pruning_info::PruningInfo;
|
header::Header,
|
||||||
use types::receipt::LocalizedReceipt;
|
ids::*,
|
||||||
use types::trace_filter::Filter as TraceFilter;
|
log_entry::LocalizedLogEntry,
|
||||||
|
pruning_info::PruningInfo,
|
||||||
|
receipt::LocalizedReceipt,
|
||||||
|
trace_filter::Filter as TraceFilter,
|
||||||
|
verification_queue_info::VerificationQueueInfo as BlockQueueInfo,
|
||||||
|
};
|
||||||
use vm::LastHashes;
|
use vm::LastHashes;
|
||||||
|
|
||||||
use block::{OpenBlock, SealedBlock, ClosedBlock};
|
use block::{OpenBlock, SealedBlock, ClosedBlock};
|
||||||
use client::Mode;
|
use client::Mode;
|
||||||
use engines::Engine;
|
use engines::Engine;
|
||||||
use error::{Error, EthcoreResult};
|
|
||||||
use executed::CallError;
|
|
||||||
use executive::Executed;
|
use executive::Executed;
|
||||||
use account_state::state::StateInfo;
|
use account_state::state::StateInfo;
|
||||||
use trace::LocalizedTrace;
|
use trace::LocalizedTrace;
|
||||||
use verification::queue::QueueInfo as BlockQueueInfo;
|
use verification::queue::kind::blocks::Unverified; // todo this is reexported from common_types
|
||||||
use verification::queue::kind::blocks::Unverified;
|
|
||||||
|
|
||||||
/// State information to be used during client query
|
/// State information to be used during client query
|
||||||
pub enum StateOrBlock {
|
pub enum StateOrBlock {
|
||||||
|
@ -26,12 +26,11 @@ use std::time::{UNIX_EPOCH, Duration};
|
|||||||
|
|
||||||
use block::*;
|
use block::*;
|
||||||
use client::EngineClient;
|
use client::EngineClient;
|
||||||
use engines::{Engine, Seal, SealingState, EngineError, ConstructedVerifier};
|
use engines::{Engine, Seal, ConstructedVerifier};
|
||||||
use engines::block_reward;
|
use engines::block_reward;
|
||||||
use engines::block_reward::{BlockRewardContract, RewardKind};
|
use engines::block_reward::{BlockRewardContract, RewardKind};
|
||||||
use error::{Error, BlockError};
|
|
||||||
use ethjson;
|
use ethjson;
|
||||||
use machine::{AuxiliaryData, Call, Machine};
|
use machine::Machine;
|
||||||
use hash::keccak;
|
use hash::keccak;
|
||||||
use super::signer::EngineSigner;
|
use super::signer::EngineSigner;
|
||||||
use super::validator_set::{ValidatorSet, SimpleList, new_validator_set};
|
use super::validator_set::{ValidatorSet, SimpleList, new_validator_set};
|
||||||
@ -43,9 +42,17 @@ use rlp::{encode, Decodable, DecoderError, Encodable, RlpStream, Rlp};
|
|||||||
use ethereum_types::{H256, H520, Address, U128, U256};
|
use ethereum_types::{H256, H520, Address, U128, U256};
|
||||||
use parking_lot::{Mutex, RwLock};
|
use parking_lot::{Mutex, RwLock};
|
||||||
use time_utils::CheckedSystemTime;
|
use time_utils::CheckedSystemTime;
|
||||||
use types::BlockNumber;
|
use types::{
|
||||||
use types::header::{Header, ExtendedHeader};
|
ancestry_action::AncestryAction,
|
||||||
use types::ancestry_action::AncestryAction;
|
BlockNumber,
|
||||||
|
header::{Header, ExtendedHeader},
|
||||||
|
engines::{
|
||||||
|
params::CommonParams,
|
||||||
|
SealingState,
|
||||||
|
machine::{Call, AuxiliaryData},
|
||||||
|
},
|
||||||
|
errors::{BlockError, EthcoreError as Error, EngineError},
|
||||||
|
};
|
||||||
use unexpected::{Mismatch, OutOfBounds};
|
use unexpected::{Mismatch, OutOfBounds};
|
||||||
|
|
||||||
mod finality;
|
mod finality;
|
||||||
@ -1420,9 +1427,7 @@ impl Engine for AuthorityRound {
|
|||||||
.map(|set_proof| combine_proofs(0, &set_proof, &[]))
|
.map(|set_proof| combine_proofs(0, &set_proof, &[]))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn signals_epoch_end(&self, header: &Header, aux: AuxiliaryData)
|
fn signals_epoch_end(&self, header: &Header, aux: AuxiliaryData) -> super::EpochChange {
|
||||||
-> super::EpochChange
|
|
||||||
{
|
|
||||||
if self.immediate_transitions { return super::EpochChange::No }
|
if self.immediate_transitions { return super::EpochChange::No }
|
||||||
|
|
||||||
let first = header.number() == 0;
|
let first = header.number() == 0;
|
||||||
@ -1604,6 +1609,10 @@ impl Engine for AuthorityRound {
|
|||||||
|
|
||||||
finalized.into_iter().map(AncestryAction::MarkFinalized).collect()
|
finalized.into_iter().map(AncestryAction::MarkFinalized).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn params(&self) -> &CommonParams {
|
||||||
|
self.machine.params()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@ -1615,7 +1624,12 @@ mod tests {
|
|||||||
use accounts::AccountProvider;
|
use accounts::AccountProvider;
|
||||||
use ethereum_types::{Address, H520, H256, U256};
|
use ethereum_types::{Address, H520, H256, U256};
|
||||||
use ethkey::Signature;
|
use ethkey::Signature;
|
||||||
use types::header::Header;
|
use types::{
|
||||||
|
header::Header,
|
||||||
|
engines::params::CommonParams,
|
||||||
|
errors::{EthcoreError as Error, EngineError},
|
||||||
|
transaction::{Action, Transaction},
|
||||||
|
};
|
||||||
use rlp::encode;
|
use rlp::encode;
|
||||||
use block::*;
|
use block::*;
|
||||||
use test_helpers::{
|
use test_helpers::{
|
||||||
@ -1623,10 +1637,8 @@ mod tests {
|
|||||||
TestNotify
|
TestNotify
|
||||||
};
|
};
|
||||||
use spec::Spec;
|
use spec::Spec;
|
||||||
use types::transaction::{Action, Transaction};
|
use engines::{Seal, Engine};
|
||||||
use engines::{Seal, Engine, EngineError};
|
|
||||||
use engines::validator_set::{TestSet, SimpleList};
|
use engines::validator_set::{TestSet, SimpleList};
|
||||||
use error::Error;
|
|
||||||
use super::{AuthorityRoundParams, AuthorityRound, EmptyStep, SealedEmptyStep, calculate_score};
|
use super::{AuthorityRoundParams, AuthorityRound, EmptyStep, SealedEmptyStep, calculate_score};
|
||||||
use machine::Machine;
|
use machine::Machine;
|
||||||
|
|
||||||
@ -1653,7 +1665,7 @@ mod tests {
|
|||||||
// mutate aura params
|
// mutate aura params
|
||||||
f(&mut params);
|
f(&mut params);
|
||||||
// create engine
|
// create engine
|
||||||
let mut c_params = ::spec::CommonParams::default();
|
let mut c_params = CommonParams::default();
|
||||||
c_params.gas_limit_bound_divisor = 5.into();
|
c_params.gas_limit_bound_divisor = 5.into();
|
||||||
let machine = Machine::regular(c_params, Default::default());
|
let machine = Machine::regular(c_params, Default::default());
|
||||||
AuthorityRound::new(params, machine).unwrap()
|
AuthorityRound::new(params, machine).unwrap()
|
||||||
|
@ -21,13 +21,21 @@ use ethereum_types::{H256, H520};
|
|||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use ethkey::{self, Signature};
|
use ethkey::{self, Signature};
|
||||||
use block::*;
|
use block::*;
|
||||||
use engines::{Engine, Seal, SealingState, ConstructedVerifier, EngineError};
|
use engines::{Engine, Seal, ConstructedVerifier};
|
||||||
use engines::signer::EngineSigner;
|
use engines::signer::EngineSigner;
|
||||||
use error::{BlockError, Error};
|
|
||||||
use ethjson;
|
use ethjson;
|
||||||
use client::EngineClient;
|
use client::EngineClient;
|
||||||
use machine::{AuxiliaryData, Call, Machine};
|
use machine::Machine;
|
||||||
use types::header::Header;
|
use types::{
|
||||||
|
header::Header,
|
||||||
|
engines::{
|
||||||
|
SealingState,
|
||||||
|
params::CommonParams,
|
||||||
|
machine::{AuxiliaryData, Call},
|
||||||
|
},
|
||||||
|
errors::{EngineError, BlockError, EthcoreError as Error},
|
||||||
|
};
|
||||||
|
|
||||||
use super::validator_set::{ValidatorSet, SimpleList, new_validator_set};
|
use super::validator_set::{ValidatorSet, SimpleList, new_validator_set};
|
||||||
|
|
||||||
/// `BasicAuthority` params.
|
/// `BasicAuthority` params.
|
||||||
@ -134,17 +142,13 @@ impl Engine for BasicAuthority {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
fn signals_epoch_end(&self, _header: &Header, _auxiliary: AuxiliaryData)
|
fn signals_epoch_end(&self, _header: &Header, _auxiliary: AuxiliaryData) -> super::EpochChange {
|
||||||
-> super::EpochChange
|
|
||||||
{
|
|
||||||
// don't bother signalling even though a contract might try.
|
// don't bother signalling even though a contract might try.
|
||||||
super::EpochChange::No
|
super::EpochChange::No
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
fn signals_epoch_end(&self, header: &Header, auxiliary: AuxiliaryData)
|
fn signals_epoch_end(&self, header: &Header, auxiliary: AuxiliaryData) -> super::EpochChange {
|
||||||
-> super::EpochChange
|
|
||||||
{
|
|
||||||
// in test mode, always signal even though they don't be finalized.
|
// in test mode, always signal even though they don't be finalized.
|
||||||
let first = header.number() == 0;
|
let first = header.number() == 0;
|
||||||
self.validators.signals_epoch_end(first, header, auxiliary)
|
self.validators.signals_epoch_end(first, header, auxiliary)
|
||||||
@ -208,6 +212,10 @@ impl Engine for BasicAuthority {
|
|||||||
fn snapshot_components(&self) -> Option<Box<dyn (::snapshot::SnapshotComponents)>> {
|
fn snapshot_components(&self) -> Option<Box<dyn (::snapshot::SnapshotComponents)>> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn params(&self) -> &CommonParams {
|
||||||
|
self.machine.params()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -23,10 +23,12 @@ use ethereum_types::{H160, Address, U256};
|
|||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use hash::keccak;
|
use hash::keccak;
|
||||||
use error::Error;
|
|
||||||
use machine::Machine;
|
use machine::Machine;
|
||||||
use trace;
|
use trace;
|
||||||
use types::BlockNumber;
|
use types::{
|
||||||
|
BlockNumber,
|
||||||
|
errors::{EngineError, EthcoreError as Error},
|
||||||
|
};
|
||||||
use super::{SystemOrCodeCall, SystemOrCodeCallKind};
|
use super::{SystemOrCodeCall, SystemOrCodeCallKind};
|
||||||
use trace::{Tracer, ExecutiveTracer, Tracing};
|
use trace::{Tracer, ExecutiveTracer, Tracing};
|
||||||
use block::ExecutedBlock;
|
use block::ExecutedBlock;
|
||||||
@ -120,7 +122,7 @@ impl BlockRewardContract {
|
|||||||
|
|
||||||
let output = caller(self.kind.clone(), input)
|
let output = caller(self.kind.clone(), input)
|
||||||
.map_err(Into::into)
|
.map_err(Into::into)
|
||||||
.map_err(::engines::EngineError::FailedSystemCall)?;
|
.map_err(EngineError::FailedSystemCall)?;
|
||||||
|
|
||||||
// since this is a non-constant call we can't use ethabi's function output
|
// since this is a non-constant call we can't use ethabi's function output
|
||||||
// deserialization, sadness ensues.
|
// deserialization, sadness ensues.
|
||||||
@ -131,7 +133,7 @@ impl BlockRewardContract {
|
|||||||
|
|
||||||
let tokens = ethabi::decode(types, &output)
|
let tokens = ethabi::decode(types, &output)
|
||||||
.map_err(|err| err.to_string())
|
.map_err(|err| err.to_string())
|
||||||
.map_err(::engines::EngineError::FailedSystemCall)?;
|
.map_err(EngineError::FailedSystemCall)?;
|
||||||
|
|
||||||
assert!(tokens.len() == 2);
|
assert!(tokens.len() == 2);
|
||||||
|
|
||||||
@ -139,7 +141,7 @@ impl BlockRewardContract {
|
|||||||
let rewards = tokens[1].clone().to_array().expect("type checked by ethabi::decode; qed");
|
let rewards = tokens[1].clone().to_array().expect("type checked by ethabi::decode; qed");
|
||||||
|
|
||||||
if addresses.len() != rewards.len() {
|
if addresses.len() != rewards.len() {
|
||||||
return Err(::engines::EngineError::FailedSystemCall(
|
return Err(EngineError::FailedSystemCall(
|
||||||
"invalid data returned by reward contract: both arrays must have the same size".into()
|
"invalid data returned by reward contract: both arrays must have the same size".into()
|
||||||
).into());
|
).into());
|
||||||
}
|
}
|
||||||
|
@ -18,15 +18,16 @@ use std::collections::{HashMap, BTreeSet, VecDeque};
|
|||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
use engines::EngineError;
|
|
||||||
use engines::clique::util::{extract_signers, recover_creator};
|
use engines::clique::util::{extract_signers, recover_creator};
|
||||||
use engines::clique::{VoteType, DIFF_INTURN, DIFF_NOTURN, NULL_AUTHOR, SIGNING_DELAY_NOTURN_MS};
|
use engines::clique::{VoteType, DIFF_INTURN, DIFF_NOTURN, NULL_AUTHOR, SIGNING_DELAY_NOTURN_MS};
|
||||||
use error::{Error, BlockError};
|
|
||||||
use ethereum_types::{Address, H64};
|
use ethereum_types::{Address, H64};
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use time_utils::CheckedSystemTime;
|
use time_utils::CheckedSystemTime;
|
||||||
use types::BlockNumber;
|
use types::{
|
||||||
use types::header::Header;
|
BlockNumber,
|
||||||
|
header::Header,
|
||||||
|
errors::{BlockError, EthcoreError as Error, EngineError},
|
||||||
|
};
|
||||||
use unexpected::Mismatch;
|
use unexpected::Mismatch;
|
||||||
|
|
||||||
/// Type that keeps track of the state for a given vote
|
/// Type that keeps track of the state for a given vote
|
||||||
|
@ -68,22 +68,27 @@ use std::time::{Instant, Duration, SystemTime, UNIX_EPOCH};
|
|||||||
use block::ExecutedBlock;
|
use block::ExecutedBlock;
|
||||||
use client::{BlockId, EngineClient};
|
use client::{BlockId, EngineClient};
|
||||||
use engines::clique::util::{extract_signers, recover_creator};
|
use engines::clique::util::{extract_signers, recover_creator};
|
||||||
use engines::{Engine, EngineError, Seal, SealingState};
|
use engines::{Engine, Seal, SealingState, EthashSeal};
|
||||||
use error::{BlockError, Error};
|
|
||||||
use ethereum_types::{Address, H64, H160, H256, U256};
|
use ethereum_types::{Address, H64, H160, H256, U256};
|
||||||
use ethkey::Signature;
|
use ethkey::Signature;
|
||||||
use hash::KECCAK_EMPTY_LIST_RLP;
|
use hash::KECCAK_EMPTY_LIST_RLP;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use lru_cache::LruCache;
|
use lru_cache::LruCache;
|
||||||
use machine::{Call, Machine};
|
use machine::Machine;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use super::signer::EngineSigner;
|
use super::signer::EngineSigner;
|
||||||
use unexpected::{Mismatch, OutOfBounds};
|
use unexpected::{Mismatch, OutOfBounds};
|
||||||
use time_utils::CheckedSystemTime;
|
use time_utils::CheckedSystemTime;
|
||||||
use types::BlockNumber;
|
use types::{
|
||||||
use types::header::Header;
|
BlockNumber,
|
||||||
use ethereum::ethash;
|
header::Header,
|
||||||
|
engines::{
|
||||||
|
params::CommonParams,
|
||||||
|
machine::Call,
|
||||||
|
},
|
||||||
|
errors::{BlockError, EthcoreError as Error, EngineError},
|
||||||
|
};
|
||||||
|
|
||||||
use self::block_state::CliqueBlockState;
|
use self::block_state::CliqueBlockState;
|
||||||
use self::params::CliqueParams;
|
use self::params::CliqueParams;
|
||||||
@ -255,8 +260,7 @@ impl Clique {
|
|||||||
fn new_checkpoint_state(&self, header: &Header) -> Result<CliqueBlockState, Error> {
|
fn new_checkpoint_state(&self, header: &Header) -> Result<CliqueBlockState, Error> {
|
||||||
debug_assert_eq!(header.number() % self.epoch_length, 0);
|
debug_assert_eq!(header.number() % self.epoch_length, 0);
|
||||||
|
|
||||||
let mut state = CliqueBlockState::new(
|
let mut state = CliqueBlockState::new(extract_signers(header)?);
|
||||||
extract_signers(header)?);
|
|
||||||
|
|
||||||
// TODO(niklasad1): refactor to perform this check in the `CliqueBlockState` constructor instead
|
// TODO(niklasad1): refactor to perform this check in the `CliqueBlockState` constructor instead
|
||||||
state.calc_next_timestamp(header.timestamp(), self.period)?;
|
state.calc_next_timestamp(header.timestamp(), self.period)?;
|
||||||
@ -364,7 +368,7 @@ impl Engine for Clique {
|
|||||||
|
|
||||||
fn extra_info(&self, header: &Header) -> BTreeMap<String, String> {
|
fn extra_info(&self, header: &Header) -> BTreeMap<String, String> {
|
||||||
// clique engine seal fields are the same as ethash seal fields
|
// clique engine seal fields are the same as ethash seal fields
|
||||||
match ethash::Seal::parse_seal(header.seal()) {
|
match EthashSeal::parse_seal(header.seal()) {
|
||||||
Ok(seal) => map![
|
Ok(seal) => map![
|
||||||
"nonce".to_owned() => format!("{:#x}", seal.nonce),
|
"nonce".to_owned() => format!("{:#x}", seal.nonce),
|
||||||
"mixHash".to_owned() => format!("{:#x}", seal.mix_hash)
|
"mixHash".to_owned() => format!("{:#x}", seal.mix_hash)
|
||||||
@ -522,8 +526,7 @@ impl Engine for Clique {
|
|||||||
|
|
||||||
// Wait for the right moment.
|
// Wait for the right moment.
|
||||||
if now < limit {
|
if now < limit {
|
||||||
trace!(target: "engine",
|
trace!(target: "engine", "generate_seal: sleeping to sign: inturn: {}, now: {:?}, to: {:?}.",
|
||||||
"generate_seal: sleeping to sign: inturn: {}, now: {:?}, to: {:?}.",
|
|
||||||
inturn, now, limit);
|
inturn, now, limit);
|
||||||
match limit.duration_since(SystemTime::now()) {
|
match limit.duration_since(SystemTime::now()) {
|
||||||
Ok(duration) => {
|
Ok(duration) => {
|
||||||
@ -560,7 +563,7 @@ impl Engine for Clique {
|
|||||||
let limit = CheckedSystemTime::checked_add(SystemTime::now(), Duration::from_secs(self.period))
|
let limit = CheckedSystemTime::checked_add(SystemTime::now(), Duration::from_secs(self.period))
|
||||||
.ok_or(BlockError::TimestampOverflow)?;
|
.ok_or(BlockError::TimestampOverflow)?;
|
||||||
|
|
||||||
// This should succeed under the contraints that the system clock works
|
// This should succeed under the constraints that the system clock works
|
||||||
let limit_as_dur = limit.duration_since(UNIX_EPOCH).map_err(|e| {
|
let limit_as_dur = limit.duration_since(UNIX_EPOCH).map_err(|e| {
|
||||||
Box::new(format!("Converting SystemTime to Duration failed: {}", e))
|
Box::new(format!("Converting SystemTime to Duration failed: {}", e))
|
||||||
})?;
|
})?;
|
||||||
@ -782,4 +785,8 @@ impl Engine for Clique {
|
|||||||
fn executive_author(&self, header: &Header) -> Result<Address, Error> {
|
fn executive_author(&self, header: &Header) -> Result<Address, Error> {
|
||||||
recover_creator(header)
|
recover_creator(header)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn params(&self) -> &CommonParams {
|
||||||
|
self.machine.params()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,12 +18,12 @@
|
|||||||
|
|
||||||
use block::*;
|
use block::*;
|
||||||
use engines::Engine;
|
use engines::Engine;
|
||||||
use error::Error;
|
|
||||||
use ethereum_types::{Address, H256};
|
use ethereum_types::{Address, H256};
|
||||||
use ethkey::{Secret, KeyPair};
|
use ethkey::{Secret, KeyPair};
|
||||||
use state_db::StateDB;
|
use state_db::StateDB;
|
||||||
use super::*;
|
use super::*;
|
||||||
use test_helpers::get_temp_state_db;
|
use test_helpers::get_temp_state_db;
|
||||||
|
use types::errors::{EthcoreError as Error, EngineError};
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
@ -16,15 +16,16 @@
|
|||||||
|
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
|
|
||||||
use engines::EngineError;
|
|
||||||
use engines::clique::{ADDRESS_LENGTH, SIGNATURE_LENGTH, VANITY_LENGTH, NULL_NONCE, NULL_MIXHASH};
|
use engines::clique::{ADDRESS_LENGTH, SIGNATURE_LENGTH, VANITY_LENGTH, NULL_NONCE, NULL_MIXHASH};
|
||||||
use error::Error;
|
|
||||||
use ethereum_types::{Address, H256};
|
use ethereum_types::{Address, H256};
|
||||||
use ethkey::{public_to_address, recover as ec_recover, Signature};
|
use ethkey::{public_to_address, recover as ec_recover, Signature};
|
||||||
use lru_cache::LruCache;
|
use lru_cache::LruCache;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use rlp::encode;
|
use rlp::encode;
|
||||||
use types::header::Header;
|
use types::{
|
||||||
|
header::Header,
|
||||||
|
errors::{EthcoreError as Error, EngineError},
|
||||||
|
};
|
||||||
|
|
||||||
/// How many recovered signature to cache in the memory.
|
/// How many recovered signature to cache in the memory.
|
||||||
pub const CREATOR_CACHE_NUM: usize = 4096;
|
pub const CREATOR_CACHE_NUM: usize = 4096;
|
||||||
|
@ -23,19 +23,23 @@ use ethereum_types::{H256, H64, U256};
|
|||||||
use ethjson;
|
use ethjson;
|
||||||
use hash::{KECCAK_EMPTY_LIST_RLP};
|
use hash::{KECCAK_EMPTY_LIST_RLP};
|
||||||
use rlp::Rlp;
|
use rlp::Rlp;
|
||||||
use types::header::Header;
|
use types::{
|
||||||
use types::BlockNumber;
|
BlockNumber,
|
||||||
|
header::Header,
|
||||||
|
engines::params::CommonParams,
|
||||||
|
errors::{BlockError, EthcoreError as Error},
|
||||||
|
};
|
||||||
|
|
||||||
use unexpected::{OutOfBounds, Mismatch};
|
use unexpected::{OutOfBounds, Mismatch};
|
||||||
|
|
||||||
use block::ExecutedBlock;
|
use block::ExecutedBlock;
|
||||||
use engines::block_reward::{self, BlockRewardContract, RewardKind};
|
use engines::block_reward::{self, BlockRewardContract, RewardKind};
|
||||||
use engines::{self, Engine};
|
use engines::{self, Engine};
|
||||||
use error::{BlockError, Error};
|
|
||||||
use ethash::{self, quick_get_difficulty, slow_hash_block_number, EthashManager, OptimizeFor};
|
use ethash::{self, quick_get_difficulty, slow_hash_block_number, EthashManager, OptimizeFor};
|
||||||
use machine::Machine;
|
use machine::Machine;
|
||||||
|
|
||||||
/// Number of blocks in an ethash snapshot.
|
/// Number of blocks in an ethash snapshot.
|
||||||
// make dependent on difficulty incrment divisor?
|
// make dependent on difficulty increment divisor?
|
||||||
const SNAPSHOT_BLOCKS: u64 = 5000;
|
const SNAPSHOT_BLOCKS: u64 = 5000;
|
||||||
/// Maximum number of blocks allowed in an ethash snapshot.
|
/// Maximum number of blocks allowed in an ethash snapshot.
|
||||||
const MAX_SNAPSHOT_BLOCKS: u64 = 30000;
|
const MAX_SNAPSHOT_BLOCKS: u64 = 30000;
|
||||||
@ -203,10 +207,13 @@ impl Ethash {
|
|||||||
// for any block in the chain.
|
// for any block in the chain.
|
||||||
// in the future, we might move the Ethash epoch
|
// in the future, we might move the Ethash epoch
|
||||||
// caching onto this mechanism as well.
|
// caching onto this mechanism as well.
|
||||||
|
// NOTE[dvdplm]: the reason we impl this for Arc<Ethash> and not plain Ethash is the
|
||||||
|
// way `epoch_verifier()` works. This means `new()` returns an `Arc<Ethash>` which is
|
||||||
|
// then re-wrapped in an Arc in `spec::engine()`.
|
||||||
impl engines::EpochVerifier for Arc<Ethash> {
|
impl engines::EpochVerifier for Arc<Ethash> {
|
||||||
fn verify_light(&self, _header: &Header) -> Result<(), Error> { Ok(()) }
|
fn verify_light(&self, _header: &Header) -> Result<(), Error> { Ok(()) }
|
||||||
fn verify_heavy(&self, header: &Header) -> Result<(), Error> {
|
fn verify_heavy(&self, header: &Header) -> Result<(), Error> {
|
||||||
self.verify_block_unordered(header)
|
self.verify_block_unordered(header).into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,6 +387,8 @@ impl Engine for Arc<Ethash> {
|
|||||||
fn snapshot_components(&self) -> Option<Box<dyn (::snapshot::SnapshotComponents)>> {
|
fn snapshot_components(&self) -> Option<Box<dyn (::snapshot::SnapshotComponents)>> {
|
||||||
Some(Box::new(::snapshot::PowSnapshot::new(SNAPSHOT_BLOCKS, MAX_SNAPSHOT_BLOCKS)))
|
Some(Box::new(::snapshot::PowSnapshot::new(SNAPSHOT_BLOCKS, MAX_SNAPSHOT_BLOCKS)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn params(&self) -> &CommonParams { self.machine.params() }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Ethash {
|
impl Ethash {
|
||||||
@ -486,11 +495,13 @@ mod tests {
|
|||||||
use ethereum_types::{H64, H256, U256, Address};
|
use ethereum_types::{H64, H256, U256, Address};
|
||||||
use block::*;
|
use block::*;
|
||||||
use test_helpers::get_temp_state_db;
|
use test_helpers::get_temp_state_db;
|
||||||
use error::{BlockError, Error};
|
use types::{
|
||||||
use types::header::Header;
|
header::Header,
|
||||||
|
errors::{BlockError, EthcoreError as Error},
|
||||||
|
};
|
||||||
use spec::Spec;
|
use spec::Spec;
|
||||||
use engines::Engine;
|
use engines::Engine;
|
||||||
use super::super::{new_morden, new_mcip3_test, new_homestead_test_machine};
|
use ethereum::{new_morden, new_mcip3_test, new_homestead_test_machine};
|
||||||
use super::{Ethash, EthashParams, ecip1017_eras_block_reward};
|
use super::{Ethash, EthashParams, ecip1017_eras_block_reward};
|
||||||
use rlp;
|
use rlp;
|
||||||
use tempdir::TempDir;
|
use tempdir::TempDir;
|
@ -14,11 +14,18 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use engines::{Engine, Seal, SealingState};
|
use engines::{Engine, Seal};
|
||||||
use machine::Machine;
|
use machine::Machine;
|
||||||
use types::header::Header;
|
use types::{
|
||||||
|
header::Header,
|
||||||
|
engines::{
|
||||||
|
SealingState,
|
||||||
|
params::CommonParams,
|
||||||
|
},
|
||||||
|
errors::EthcoreError as Error,
|
||||||
|
};
|
||||||
|
|
||||||
use block::ExecutedBlock;
|
use block::ExecutedBlock;
|
||||||
use error::Error;
|
|
||||||
|
|
||||||
/// `InstantSeal` params.
|
/// `InstantSeal` params.
|
||||||
#[derive(Default, Debug, PartialEq)]
|
#[derive(Default, Debug, PartialEq)]
|
||||||
@ -87,8 +94,14 @@ impl Engine for InstantSeal {
|
|||||||
fn is_timestamp_valid(&self, header_timestamp: u64, parent_timestamp: u64) -> bool {
|
fn is_timestamp_valid(&self, header_timestamp: u64, parent_timestamp: u64) -> bool {
|
||||||
header_timestamp >= parent_timestamp
|
header_timestamp >= parent_timestamp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn params(&self) -> &CommonParams {
|
||||||
|
self.machine.params()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
mod authority_round;
|
mod authority_round;
|
||||||
mod basic_authority;
|
mod basic_authority;
|
||||||
mod clique;
|
mod clique;
|
||||||
|
mod ethash;
|
||||||
mod instant_seal;
|
mod instant_seal;
|
||||||
mod null_engine;
|
mod null_engine;
|
||||||
mod validator_set;
|
mod validator_set;
|
||||||
@ -32,6 +33,7 @@ pub use self::instant_seal::{InstantSeal, InstantSealParams};
|
|||||||
pub use self::null_engine::NullEngine;
|
pub use self::null_engine::NullEngine;
|
||||||
pub use self::signer::EngineSigner;
|
pub use self::signer::EngineSigner;
|
||||||
pub use self::clique::Clique;
|
pub use self::clique::Clique;
|
||||||
|
pub use self::ethash::{Ethash, Seal as EthashSeal};
|
||||||
|
|
||||||
// TODO [ToDr] Remove re-export (#10130)
|
// TODO [ToDr] Remove re-export (#10130)
|
||||||
pub use types::engines::ForkChoice;
|
pub use types::engines::ForkChoice;
|
||||||
@ -39,120 +41,31 @@ pub use types::engines::epoch::{self, Transition as EpochTransition};
|
|||||||
|
|
||||||
use std::sync::{Weak, Arc};
|
use std::sync::{Weak, Arc};
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::{fmt, error};
|
|
||||||
|
|
||||||
use builtin::Builtin;
|
use builtin::Builtin;
|
||||||
use vm::{EnvInfo, Schedule, CallType, ActionValue};
|
use vm::{EnvInfo, Schedule, CallType, ActionValue};
|
||||||
use error::Error;
|
use types::{
|
||||||
use types::BlockNumber;
|
BlockNumber,
|
||||||
use types::header::{Header, ExtendedHeader};
|
ancestry_action::AncestryAction,
|
||||||
|
header::{Header, ExtendedHeader},
|
||||||
|
engines::{
|
||||||
|
SealingState, Headers, PendingTransitionStore,
|
||||||
|
params::CommonParams,
|
||||||
|
machine as machine_types,
|
||||||
|
machine::{AuxiliaryData, AuxiliaryRequest},
|
||||||
|
},
|
||||||
|
errors::{EthcoreError as Error, EngineError},
|
||||||
|
transaction::{self, UnverifiedTransaction, SignedTransaction},
|
||||||
|
};
|
||||||
use snapshot::SnapshotComponents;
|
use snapshot::SnapshotComponents;
|
||||||
use spec::CommonParams;
|
|
||||||
use types::transaction::{self, UnverifiedTransaction, SignedTransaction};
|
|
||||||
use client::EngineClient;
|
use client::EngineClient;
|
||||||
|
|
||||||
use ethkey::{Signature};
|
use ethkey::{Signature};
|
||||||
use machine::{self, Machine, AuxiliaryRequest, AuxiliaryData};
|
use machine::Machine;
|
||||||
use ethereum_types::{H64, H256, U256, Address};
|
use ethereum_types::{H256, U256, Address};
|
||||||
use unexpected::{Mismatch, OutOfBounds};
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use types::ancestry_action::AncestryAction;
|
|
||||||
use block::ExecutedBlock;
|
use block::ExecutedBlock;
|
||||||
|
|
||||||
/// Default EIP-210 contract code.
|
|
||||||
/// As defined in https://github.com/ethereum/EIPs/pull/210
|
|
||||||
pub const DEFAULT_BLOCKHASH_CONTRACT: &'static str = "73fffffffffffffffffffffffffffffffffffffffe33141561006a5760014303600035610100820755610100810715156100455760003561010061010083050761010001555b6201000081071515610064576000356101006201000083050761020001555b5061013e565b4360003512151561008457600060405260206040f361013d565b61010060003543031315156100a857610100600035075460605260206060f361013c565b6101006000350715156100c55762010000600035430313156100c8565b60005b156100ea576101006101006000350507610100015460805260206080f361013b565b620100006000350715156101095763010000006000354303131561010c565b60005b1561012f57610100620100006000350507610200015460a052602060a0f361013a565b600060c052602060c0f35b5b5b5b5b";
|
|
||||||
/// The number of generations back that uncles can be.
|
|
||||||
pub const MAX_UNCLE_AGE: usize = 6;
|
|
||||||
|
|
||||||
/// Voting errors.
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum EngineError {
|
|
||||||
/// Signature or author field does not belong to an authority.
|
|
||||||
NotAuthorized(Address),
|
|
||||||
/// The same author issued different votes at the same step.
|
|
||||||
DoubleVote(Address),
|
|
||||||
/// The received block is from an incorrect proposer.
|
|
||||||
NotProposer(Mismatch<Address>),
|
|
||||||
/// Message was not expected.
|
|
||||||
UnexpectedMessage,
|
|
||||||
/// Seal field has an unexpected size.
|
|
||||||
BadSealFieldSize(OutOfBounds<usize>),
|
|
||||||
/// Validation proof insufficient.
|
|
||||||
InsufficientProof(String),
|
|
||||||
/// Failed system call.
|
|
||||||
FailedSystemCall(String),
|
|
||||||
/// Malformed consensus message.
|
|
||||||
MalformedMessage(String),
|
|
||||||
/// Requires client ref, but none registered.
|
|
||||||
RequiresClient,
|
|
||||||
/// Invalid engine specification or implementation.
|
|
||||||
InvalidEngine,
|
|
||||||
/// Requires signer ref, but none registered.
|
|
||||||
RequiresSigner,
|
|
||||||
/// Missing Parent Epoch
|
|
||||||
MissingParent(H256),
|
|
||||||
/// Checkpoint is missing
|
|
||||||
CliqueMissingCheckpoint(H256),
|
|
||||||
/// Missing vanity data
|
|
||||||
CliqueMissingVanity,
|
|
||||||
/// Missing signature
|
|
||||||
CliqueMissingSignature,
|
|
||||||
/// Missing signers
|
|
||||||
CliqueCheckpointNoSigner,
|
|
||||||
/// List of signers is invalid
|
|
||||||
CliqueCheckpointInvalidSigners(usize),
|
|
||||||
/// Wrong author on a checkpoint
|
|
||||||
CliqueWrongAuthorCheckpoint(Mismatch<Address>),
|
|
||||||
/// Wrong checkpoint authors recovered
|
|
||||||
CliqueFaultyRecoveredSigners(Vec<String>),
|
|
||||||
/// Invalid nonce (should contain vote)
|
|
||||||
CliqueInvalidNonce(H64),
|
|
||||||
/// The signer signed a block to recently
|
|
||||||
CliqueTooRecentlySigned(Address),
|
|
||||||
/// Custom
|
|
||||||
Custom(String),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Display for EngineError {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
use self::EngineError::*;
|
|
||||||
let msg = match *self {
|
|
||||||
CliqueMissingCheckpoint(ref hash) => format!("Missing checkpoint block: {}", hash),
|
|
||||||
CliqueMissingVanity => format!("Extra data is missing vanity data"),
|
|
||||||
CliqueMissingSignature => format!("Extra data is missing signature"),
|
|
||||||
CliqueCheckpointInvalidSigners(len) => format!("Checkpoint block list was of length: {} of checkpoint but
|
|
||||||
it needs to be bigger than zero and a divisible by 20", len),
|
|
||||||
CliqueCheckpointNoSigner => format!("Checkpoint block list of signers was empty"),
|
|
||||||
CliqueInvalidNonce(ref mis) => format!("Unexpected nonce {} expected {} or {}", mis, 0_u64, u64::max_value()),
|
|
||||||
CliqueWrongAuthorCheckpoint(ref oob) => format!("Unexpected checkpoint author: {}", oob),
|
|
||||||
CliqueFaultyRecoveredSigners(ref mis) => format!("Faulty recovered signers {:?}", mis),
|
|
||||||
CliqueTooRecentlySigned(ref address) => format!("The signer: {} has signed a block too recently", address),
|
|
||||||
Custom(ref s) => s.clone(),
|
|
||||||
DoubleVote(ref address) => format!("Author {} issued too many blocks.", address),
|
|
||||||
NotProposer(ref mis) => format!("Author is not a current proposer: {}", mis),
|
|
||||||
NotAuthorized(ref address) => format!("Signer {} is not authorized.", address),
|
|
||||||
UnexpectedMessage => "This Engine should not be fed messages.".into(),
|
|
||||||
BadSealFieldSize(ref oob) => format!("Seal field has an unexpected length: {}", oob),
|
|
||||||
InsufficientProof(ref msg) => format!("Insufficient validation proof: {}", msg),
|
|
||||||
FailedSystemCall(ref msg) => format!("Failed to make system call: {}", msg),
|
|
||||||
MalformedMessage(ref msg) => format!("Received malformed consensus message: {}", msg),
|
|
||||||
RequiresClient => format!("Call requires client but none registered"),
|
|
||||||
RequiresSigner => format!("Call requires signer but none registered"),
|
|
||||||
InvalidEngine => format!("Invalid engine specification or implementation"),
|
|
||||||
MissingParent(ref hash) => format!("Parent Epoch is missing from database: {}", hash),
|
|
||||||
};
|
|
||||||
|
|
||||||
f.write_fmt(format_args!("Engine error ({})", msg))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl error::Error for EngineError {
|
|
||||||
fn description(&self) -> &str {
|
|
||||||
"Engine error"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Seal type.
|
/// Seal type.
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub enum Seal {
|
pub enum Seal {
|
||||||
@ -162,17 +75,6 @@ pub enum Seal {
|
|||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The type of sealing the engine is currently able to perform.
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
|
||||||
pub enum SealingState {
|
|
||||||
/// The engine is ready to seal a block.
|
|
||||||
Ready,
|
|
||||||
/// The engine can't seal at the moment, and no block should be prepared and queued.
|
|
||||||
NotReady,
|
|
||||||
/// The engine does not seal internally.
|
|
||||||
External,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A system-calling closure. Enacts calls on a block's state from the system address.
|
/// A system-calling closure. Enacts calls on a block's state from the system address.
|
||||||
pub type SystemCall<'a> = dyn FnMut(Address, Vec<u8>) -> Result<Vec<u8>, String> + 'a;
|
pub type SystemCall<'a> = dyn FnMut(Address, Vec<u8>) -> Result<Vec<u8>, String> + 'a;
|
||||||
|
|
||||||
@ -189,7 +91,7 @@ pub enum SystemOrCodeCallKind {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Default SystemOrCodeCall implementation.
|
/// Default SystemOrCodeCall implementation.
|
||||||
pub fn default_system_or_code_call<'a>(machine: &'a ::machine::Machine, block: &'a mut ::block::ExecutedBlock) -> impl FnMut(SystemOrCodeCallKind, Vec<u8>) -> Result<Vec<u8>, String> + 'a {
|
pub fn default_system_or_code_call<'a>(machine: &'a Machine, block: &'a mut ::block::ExecutedBlock) -> impl FnMut(SystemOrCodeCallKind, Vec<u8>) -> Result<Vec<u8>, String> + 'a {
|
||||||
move |to, data| {
|
move |to, data| {
|
||||||
let result = match to {
|
let result = match to {
|
||||||
SystemOrCodeCallKind::Address(address) => {
|
SystemOrCodeCallKind::Address(address) => {
|
||||||
@ -218,16 +120,10 @@ pub fn default_system_or_code_call<'a>(machine: &'a ::machine::Machine, block: &
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Type alias for a function we can get headers by hash through.
|
|
||||||
pub type Headers<'a, H> = dyn Fn(H256) -> Option<H> + 'a;
|
|
||||||
|
|
||||||
/// Type alias for a function we can query pending transitions by block hash through.
|
|
||||||
pub type PendingTransitionStore<'a> = dyn Fn(H256) -> Option<epoch::PendingTransition> + 'a;
|
|
||||||
|
|
||||||
/// Proof dependent on state.
|
/// Proof dependent on state.
|
||||||
pub trait StateDependentProof: Send + Sync {
|
pub trait StateDependentProof: Send + Sync {
|
||||||
/// Generate a proof, given the state.
|
/// Generate a proof, given the state.
|
||||||
fn generate_proof<'a>(&self, state: &machine::Call) -> Result<Vec<u8>, String>;
|
fn generate_proof<'a>(&self, state: &machine_types::Call) -> Result<Vec<u8>, String>;
|
||||||
/// Check a proof generated elsewhere (potentially by a peer).
|
/// Check a proof generated elsewhere (potentially by a peer).
|
||||||
// `engine` needed to check state proofs, while really this should
|
// `engine` needed to check state proofs, while really this should
|
||||||
// just be state machine params.
|
// just be state machine params.
|
||||||
@ -360,7 +256,7 @@ pub trait Engine: Sync + Send {
|
|||||||
fn verify_block_external(&self, _header: &Header) -> Result<(), Error> { Ok(()) }
|
fn verify_block_external(&self, _header: &Header) -> Result<(), Error> { Ok(()) }
|
||||||
|
|
||||||
/// Genesis epoch data.
|
/// Genesis epoch data.
|
||||||
fn genesis_epoch_data<'a>(&self, _header: &Header, _state: &machine::Call) -> Result<Vec<u8>, String> { Ok(Vec::new()) }
|
fn genesis_epoch_data<'a>(&self, _header: &Header, _state: &machine_types::Call) -> Result<Vec<u8>, String> { Ok(Vec::new()) }
|
||||||
|
|
||||||
/// Whether an epoch change is signalled at the given header but will require finality.
|
/// Whether an epoch change is signalled at the given header but will require finality.
|
||||||
/// If a change can be enacted immediately then return `No` from this function but
|
/// If a change can be enacted immediately then return `No` from this function but
|
||||||
@ -371,9 +267,7 @@ pub trait Engine: Sync + Send {
|
|||||||
/// Return `Yes` or `No` when the answer is definitively known.
|
/// Return `Yes` or `No` when the answer is definitively known.
|
||||||
///
|
///
|
||||||
/// Should not interact with state.
|
/// Should not interact with state.
|
||||||
fn signals_epoch_end<'a>(&self, _header: &Header, _aux: AuxiliaryData<'a>)
|
fn signals_epoch_end<'a>(&self, _header: &Header, _aux: AuxiliaryData<'a>) -> EpochChange {
|
||||||
-> EpochChange
|
|
||||||
{
|
|
||||||
EpochChange::No
|
EpochChange::No
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -475,9 +369,7 @@ pub trait Engine: Sync + Send {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get the general parameters of the chain.
|
/// Get the general parameters of the chain.
|
||||||
fn params(&self) -> &CommonParams {
|
fn params(&self) -> &CommonParams;
|
||||||
self.machine().params()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the EVM schedule for the given block number.
|
/// Get the EVM schedule for the given block number.
|
||||||
fn schedule(&self, block_number: BlockNumber) -> Schedule {
|
fn schedule(&self, block_number: BlockNumber) -> Schedule {
|
||||||
@ -496,9 +388,7 @@ pub trait Engine: Sync + Send {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Some intrinsic operation parameters; by default they take their value from the `spec()`'s `engine_params`.
|
/// Some intrinsic operation parameters; by default they take their value from the `spec()`'s `engine_params`.
|
||||||
fn maximum_extra_data_size(&self) -> usize {
|
fn maximum_extra_data_size(&self) -> usize { self.params().maximum_extra_data_size }
|
||||||
self.machine().maximum_extra_data_size()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The nonce with which accounts begin at given block.
|
/// The nonce with which accounts begin at given block.
|
||||||
fn account_start_nonce(&self, block: BlockNumber) -> U256 {
|
fn account_start_nonce(&self, block: BlockNumber) -> U256 {
|
||||||
|
@ -18,10 +18,13 @@ use engines::Engine;
|
|||||||
use engines::block_reward::{self, RewardKind};
|
use engines::block_reward::{self, RewardKind};
|
||||||
use ethereum_types::U256;
|
use ethereum_types::U256;
|
||||||
use machine::Machine;
|
use machine::Machine;
|
||||||
use types::BlockNumber;
|
use types::{
|
||||||
use types::header::Header;
|
BlockNumber,
|
||||||
|
header::Header,
|
||||||
|
engines::params::CommonParams,
|
||||||
|
errors::EthcoreError as Error,
|
||||||
|
};
|
||||||
use block::ExecutedBlock;
|
use block::ExecutedBlock;
|
||||||
use error::Error;
|
|
||||||
|
|
||||||
/// Params for a null engine.
|
/// Params for a null engine.
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
@ -61,6 +64,8 @@ impl Engine for NullEngine {
|
|||||||
|
|
||||||
fn machine(&self) -> &Machine { &self.machine }
|
fn machine(&self) -> &Machine { &self.machine }
|
||||||
|
|
||||||
|
fn maximum_uncle_count(&self, _block: BlockNumber) -> usize { 2 }
|
||||||
|
|
||||||
fn on_close_block(
|
fn on_close_block(
|
||||||
&self,
|
&self,
|
||||||
block: &mut ExecutedBlock,
|
block: &mut ExecutedBlock,
|
||||||
@ -92,8 +97,6 @@ impl Engine for NullEngine {
|
|||||||
block_reward::apply_block_rewards(&rewards, block, &self.machine)
|
block_reward::apply_block_rewards(&rewards, block, &self.machine)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn maximum_uncle_count(&self, _block: BlockNumber) -> usize { 2 }
|
|
||||||
|
|
||||||
fn verify_local_seal(&self, _header: &Header) -> Result<(), Error> {
|
fn verify_local_seal(&self, _header: &Header) -> Result<(), Error> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -101,4 +104,8 @@ impl Engine for NullEngine {
|
|||||||
fn snapshot_components(&self) -> Option<Box<dyn (::snapshot::SnapshotComponents)>> {
|
fn snapshot_components(&self) -> Option<Box<dyn (::snapshot::SnapshotComponents)>> {
|
||||||
Some(Box::new(::snapshot::PowSnapshot::new(10000, 10000)))
|
Some(Box::new(::snapshot::PowSnapshot::new(10000, 10000)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn params(&self) -> &CommonParams {
|
||||||
|
self.machine.params()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,14 @@ use std::sync::Weak;
|
|||||||
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use ethereum_types::{H256, Address};
|
use ethereum_types::{H256, Address};
|
||||||
use machine::{AuxiliaryData, Call, Machine};
|
use machine::Machine;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use types::BlockNumber;
|
use types::{
|
||||||
use types::header::Header;
|
BlockNumber,
|
||||||
|
header::Header,
|
||||||
|
errors::EthcoreError,
|
||||||
|
engines::machine::{Call, AuxiliaryData},
|
||||||
|
};
|
||||||
|
|
||||||
use client::EngineClient;
|
use client::EngineClient;
|
||||||
|
|
||||||
@ -72,7 +76,7 @@ impl ValidatorSet for ValidatorContract {
|
|||||||
self.validators.default_caller(id)
|
self.validators.default_caller(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_epoch_begin(&self, first: bool, header: &Header, call: &mut SystemCall) -> Result<(), ::error::Error> {
|
fn on_epoch_begin(&self, first: bool, header: &Header, call: &mut SystemCall) -> Result<(), EthcoreError> {
|
||||||
self.validators.on_epoch_begin(first, header, call)
|
self.validators.on_epoch_begin(first, header, call)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +97,7 @@ impl ValidatorSet for ValidatorContract {
|
|||||||
self.validators.signals_epoch_end(first, header, aux)
|
self.validators.signals_epoch_end(first, header, aux)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn epoch_set(&self, first: bool, machine: &Machine, number: BlockNumber, proof: &[u8]) -> Result<(SimpleList, Option<H256>), ::error::Error> {
|
fn epoch_set(&self, first: bool, machine: &Machine, number: BlockNumber, proof: &[u8]) -> Result<(SimpleList, Option<H256>), EthcoreError> {
|
||||||
self.validators.epoch_set(first, machine, number, proof)
|
self.validators.epoch_set(first, machine, number, proof)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +151,8 @@ mod tests {
|
|||||||
use types::ids::BlockId;
|
use types::ids::BlockId;
|
||||||
use test_helpers::generate_dummy_client_with_spec;
|
use test_helpers::generate_dummy_client_with_spec;
|
||||||
use call_contract::CallContract;
|
use call_contract::CallContract;
|
||||||
use client::{BlockChainClient, ChainInfo, BlockInfo};
|
use client::{BlockChainClient, ChainInfo};
|
||||||
|
use client::BlockInfo;
|
||||||
use super::super::ValidatorSet;
|
use super::super::ValidatorSet;
|
||||||
use super::ValidatorContract;
|
use super::ValidatorContract;
|
||||||
|
|
||||||
|
@ -28,10 +28,14 @@ use std::sync::Weak;
|
|||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use ethereum_types::{H256, Address};
|
use ethereum_types::{H256, Address};
|
||||||
use ethjson::spec::ValidatorSet as ValidatorSpec;
|
use ethjson::spec::ValidatorSet as ValidatorSpec;
|
||||||
use machine::{AuxiliaryData, Call, Machine};
|
use machine::Machine;
|
||||||
use types::BlockNumber;
|
use types::{
|
||||||
use types::header::Header;
|
BlockNumber,
|
||||||
use types::ids::BlockId;
|
header::Header,
|
||||||
|
ids::BlockId,
|
||||||
|
errors::EthcoreError,
|
||||||
|
engines::machine::{Call, AuxiliaryData},
|
||||||
|
};
|
||||||
|
|
||||||
use client::EngineClient;
|
use client::EngineClient;
|
||||||
|
|
||||||
@ -88,7 +92,7 @@ pub trait ValidatorSet: Send + Sync + 'static {
|
|||||||
/// The caller provided here may not generate proofs.
|
/// The caller provided here may not generate proofs.
|
||||||
///
|
///
|
||||||
/// `first` is true if this is the first block in the set.
|
/// `first` is true if this is the first block in the set.
|
||||||
fn on_epoch_begin(&self, _first: bool, _header: &Header, _call: &mut SystemCall) -> Result<(), ::error::Error> {
|
fn on_epoch_begin(&self, _first: bool, _header: &Header, _call: &mut SystemCall) -> Result<(), EthcoreError> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +128,7 @@ pub trait ValidatorSet: Send + Sync + 'static {
|
|||||||
/// Returns the set, along with a flag indicating whether finality of a specific
|
/// Returns the set, along with a flag indicating whether finality of a specific
|
||||||
/// hash should be proven.
|
/// hash should be proven.
|
||||||
fn epoch_set(&self, first: bool, machine: &Machine, number: BlockNumber, proof: &[u8])
|
fn epoch_set(&self, first: bool, machine: &Machine, number: BlockNumber, proof: &[u8])
|
||||||
-> Result<(SimpleList, Option<H256>), ::error::Error>;
|
-> Result<(SimpleList, Option<H256>), EthcoreError>;
|
||||||
|
|
||||||
/// Checks if a given address is a validator, with the given function
|
/// Checks if a given address is a validator, with the given function
|
||||||
/// for executing synchronous calls to contracts.
|
/// for executing synchronous calls to contracts.
|
||||||
|
@ -22,12 +22,16 @@ use std::sync::Weak;
|
|||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use ethereum_types::{H256, Address};
|
use ethereum_types::{H256, Address};
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use types::BlockNumber;
|
use types::{
|
||||||
use types::header::Header;
|
BlockNumber,
|
||||||
use types::ids::BlockId;
|
header::Header,
|
||||||
|
ids::BlockId,
|
||||||
|
errors::EthcoreError,
|
||||||
|
engines::machine::{Call, AuxiliaryData},
|
||||||
|
};
|
||||||
|
|
||||||
use client::EngineClient;
|
use client::EngineClient;
|
||||||
use machine::{AuxiliaryData, Call, Machine};
|
use machine::Machine;
|
||||||
use super::{SystemCall, ValidatorSet};
|
use super::{SystemCall, ValidatorSet};
|
||||||
|
|
||||||
type BlockNumberLookup = Box<dyn Fn(BlockId) -> Result<BlockNumber, String> + Send + Sync + 'static>;
|
type BlockNumberLookup = Box<dyn Fn(BlockId) -> Result<BlockNumber, String> + Send + Sync + 'static>;
|
||||||
@ -77,7 +81,7 @@ impl ValidatorSet for Multi {
|
|||||||
.unwrap_or_else(|| Box::new(|_, _| Err("No validator set for given ID.".into())))
|
.unwrap_or_else(|| Box::new(|_, _| Err("No validator set for given ID.".into())))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_epoch_begin(&self, _first: bool, header: &Header, call: &mut SystemCall) -> Result<(), ::error::Error> {
|
fn on_epoch_begin(&self, _first: bool, header: &Header, call: &mut SystemCall) -> Result<(), EthcoreError> {
|
||||||
let (set_block, set) = self.correct_set_by_number(header.number());
|
let (set_block, set) = self.correct_set_by_number(header.number());
|
||||||
let first = set_block == header.number();
|
let first = set_block == header.number();
|
||||||
|
|
||||||
@ -104,7 +108,7 @@ impl ValidatorSet for Multi {
|
|||||||
set.signals_epoch_end(first, header, aux)
|
set.signals_epoch_end(first, header, aux)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn epoch_set(&self, _first: bool, machine: &Machine, number: BlockNumber, proof: &[u8]) -> Result<(super::SimpleList, Option<H256>), ::error::Error> {
|
fn epoch_set(&self, _first: bool, machine: &Machine, number: BlockNumber, proof: &[u8]) -> Result<(super::SimpleList, Option<H256>), EthcoreError> {
|
||||||
let (set_block, set) = self.correct_set_by_number(number);
|
let (set_block, set) = self.correct_set_by_number(number);
|
||||||
let first = set_block == number;
|
let first = set_block == number;
|
||||||
|
|
||||||
@ -151,7 +155,8 @@ mod tests {
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use hash::keccak;
|
use hash::keccak;
|
||||||
use accounts::AccountProvider;
|
use accounts::AccountProvider;
|
||||||
use client::{BlockChainClient, ChainInfo, BlockInfo, ImportBlock};
|
use client::{BlockChainClient, ChainInfo, ImportBlock};
|
||||||
|
use client::BlockInfo;
|
||||||
use engines::EpochChange;
|
use engines::EpochChange;
|
||||||
use engines::validator_set::ValidatorSet;
|
use engines::validator_set::ValidatorSet;
|
||||||
use ethkey::Secret;
|
use ethkey::Secret;
|
||||||
|
@ -26,14 +26,18 @@ use kvdb::DBValue;
|
|||||||
use memory_cache::MemoryLruCache;
|
use memory_cache::MemoryLruCache;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use rlp::{Rlp, RlpStream};
|
use rlp::{Rlp, RlpStream};
|
||||||
use types::header::Header;
|
use types::{
|
||||||
use types::ids::BlockId;
|
header::Header,
|
||||||
use types::log_entry::LogEntry;
|
errors::{EngineError, EthcoreError, BlockError},
|
||||||
use types::receipt::Receipt;
|
ids::BlockId,
|
||||||
|
log_entry::LogEntry,
|
||||||
|
engines::machine::{Call, AuxiliaryData, AuxiliaryRequest},
|
||||||
|
receipt::Receipt,
|
||||||
|
};
|
||||||
use unexpected::Mismatch;
|
use unexpected::Mismatch;
|
||||||
|
|
||||||
use client::EngineClient;
|
use client::EngineClient;
|
||||||
use machine::{AuxiliaryData, Call, Machine, AuxiliaryRequest};
|
use machine::Machine;
|
||||||
use super::{SystemCall, ValidatorSet};
|
use super::{SystemCall, ValidatorSet};
|
||||||
use super::simple_list::SimpleList;
|
use super::simple_list::SimpleList;
|
||||||
|
|
||||||
@ -144,13 +148,13 @@ fn check_first_proof(machine: &Machine, contract_address: Address, old_header: H
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decode_first_proof(rlp: &Rlp) -> Result<(Header, Vec<DBValue>), ::error::Error> {
|
fn decode_first_proof(rlp: &Rlp) -> Result<(Header, Vec<DBValue>), EthcoreError> {
|
||||||
let header = rlp.val_at(0)?;
|
let header = rlp.val_at(0)?;
|
||||||
let state_items = rlp.at(1)?.iter().map(|x| {
|
let state_items = rlp.at(1)?.iter().map(|x| {
|
||||||
let mut val = DBValue::new();
|
let mut val = DBValue::new();
|
||||||
val.append_slice(x.data()?);
|
val.append_slice(x.data()?);
|
||||||
Ok(val)
|
Ok(val)
|
||||||
}).collect::<Result<_, ::error::Error>>()?;
|
}).collect::<Result<_, EthcoreError>>()?;
|
||||||
|
|
||||||
Ok((header, state_items))
|
Ok((header, state_items))
|
||||||
}
|
}
|
||||||
@ -164,7 +168,7 @@ fn encode_proof(header: &Header, receipts: &[Receipt]) -> Bytes {
|
|||||||
stream.drain()
|
stream.drain()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decode_proof(rlp: &Rlp) -> Result<(Header, Vec<Receipt>), ::error::Error> {
|
fn decode_proof(rlp: &Rlp) -> Result<(Header, Vec<Receipt>), EthcoreError> {
|
||||||
Ok((rlp.val_at(0)?, rlp.list_at(1)?))
|
Ok((rlp.val_at(0)?, rlp.list_at(1)?))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,11 +297,11 @@ impl ValidatorSet for ValidatorSafeContract {
|
|||||||
.map(|out| (out, Vec::new()))) // generate no proofs in general
|
.map(|out| (out, Vec::new()))) // generate no proofs in general
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_epoch_begin(&self, _first: bool, _header: &Header, caller: &mut SystemCall) -> Result<(), ::error::Error> {
|
fn on_epoch_begin(&self, _first: bool, _header: &Header, caller: &mut SystemCall) -> Result<(), EthcoreError> {
|
||||||
let data = validator_set::functions::finalize_change::encode_input();
|
let data = validator_set::functions::finalize_change::encode_input();
|
||||||
caller(self.contract_address, data)
|
caller(self.contract_address, data)
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
.map_err(::engines::EngineError::FailedSystemCall)
|
.map_err(EngineError::FailedSystemCall)
|
||||||
.map_err(Into::into)
|
.map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,7 +352,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: ::types::BlockNumber, proof: &[u8])
|
||||||
-> Result<(SimpleList, Option<H256>), ::error::Error>
|
-> Result<(SimpleList, Option<H256>), EthcoreError>
|
||||||
{
|
{
|
||||||
let rlp = Rlp::new(proof);
|
let rlp = Rlp::new(proof);
|
||||||
|
|
||||||
@ -359,7 +363,7 @@ impl ValidatorSet for ValidatorSafeContract {
|
|||||||
let number = old_header.number();
|
let number = old_header.number();
|
||||||
let old_hash = old_header.hash();
|
let old_hash = old_header.hash();
|
||||||
let addresses = check_first_proof(machine, self.contract_address, old_header, &state_items)
|
let addresses = check_first_proof(machine, self.contract_address, old_header, &state_items)
|
||||||
.map_err(::engines::EngineError::InsufficientProof)?;
|
.map_err(EngineError::InsufficientProof)?;
|
||||||
|
|
||||||
trace!(target: "engine", "Extracted epoch validator set at block #{}: {} addresses",
|
trace!(target: "engine", "Extracted epoch validator set at block #{}: {} addresses",
|
||||||
number, addresses.len());
|
number, addresses.len());
|
||||||
@ -374,7 +378,7 @@ impl ValidatorSet for ValidatorSafeContract {
|
|||||||
receipts.iter().map(::rlp::encode)
|
receipts.iter().map(::rlp::encode)
|
||||||
);
|
);
|
||||||
if found_root != *old_header.receipts_root() {
|
if found_root != *old_header.receipts_root() {
|
||||||
return Err(::error::BlockError::InvalidReceiptsRoot(
|
return Err(BlockError::InvalidReceiptsRoot(
|
||||||
Mismatch { expected: *old_header.receipts_root(), found: found_root }
|
Mismatch { expected: *old_header.receipts_root(), found: found_root }
|
||||||
).into());
|
).into());
|
||||||
}
|
}
|
||||||
@ -387,7 +391,7 @@ impl ValidatorSet for ValidatorSafeContract {
|
|||||||
|
|
||||||
Ok((list, Some(old_header.hash())))
|
Ok((list, Some(old_header.hash())))
|
||||||
},
|
},
|
||||||
None => Err(::engines::EngineError::InsufficientProof("No log event in proof.".into()).into()),
|
None => Err(EngineError::InsufficientProof("No log event in proof.".into()).into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -453,7 +457,8 @@ mod tests {
|
|||||||
use spec::Spec;
|
use spec::Spec;
|
||||||
use accounts::AccountProvider;
|
use accounts::AccountProvider;
|
||||||
use types::transaction::{Transaction, Action};
|
use types::transaction::{Transaction, Action};
|
||||||
use client::{ChainInfo, BlockInfo, ImportBlock};
|
use client::{ChainInfo, ImportBlock};
|
||||||
|
use client::BlockInfo;
|
||||||
use ethkey::Secret;
|
use ethkey::Secret;
|
||||||
use miner::{self, MinerService};
|
use miner::{self, MinerService};
|
||||||
use test_helpers::{generate_dummy_client_with_spec, generate_dummy_client_with_spec_and_data};
|
use test_helpers::{generate_dummy_client_with_spec, generate_dummy_client_with_spec_and_data};
|
||||||
@ -545,9 +550,11 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn detects_bloom() {
|
fn detects_bloom() {
|
||||||
use engines::EpochChange;
|
use engines::EpochChange;
|
||||||
use machine::AuxiliaryRequest;
|
use types::{
|
||||||
use types::header::Header;
|
header::Header,
|
||||||
use types::log_entry::LogEntry;
|
log_entry::LogEntry,
|
||||||
|
engines::machine::AuxiliaryRequest,
|
||||||
|
};
|
||||||
|
|
||||||
let client = generate_dummy_client_with_spec(Spec::new_validator_safe_contract);
|
let client = generate_dummy_client_with_spec(Spec::new_validator_safe_contract);
|
||||||
let engine = client.engine().clone();
|
let engine = client.engine().clone();
|
||||||
|
@ -19,9 +19,13 @@
|
|||||||
use parity_util_mem::MallocSizeOf;
|
use parity_util_mem::MallocSizeOf;
|
||||||
use ethereum_types::{H256, Address};
|
use ethereum_types::{H256, Address};
|
||||||
|
|
||||||
use machine::{AuxiliaryData, Call, Machine};
|
use machine::Machine;
|
||||||
use types::BlockNumber;
|
use types::{
|
||||||
use types::header::Header;
|
BlockNumber,
|
||||||
|
header::Header,
|
||||||
|
errors::EthcoreError,
|
||||||
|
engines::machine::{Call, AuxiliaryData},
|
||||||
|
};
|
||||||
use super::ValidatorSet;
|
use super::ValidatorSet;
|
||||||
|
|
||||||
/// Validator set containing a known set of addresses.
|
/// Validator set containing a known set of addresses.
|
||||||
@ -78,7 +82,7 @@ impl ValidatorSet for SimpleList {
|
|||||||
::engines::EpochChange::No
|
::engines::EpochChange::No
|
||||||
}
|
}
|
||||||
|
|
||||||
fn epoch_set(&self, _first: bool, _: &Machine, _: BlockNumber, _: &[u8]) -> Result<(SimpleList, Option<H256>), ::error::Error> {
|
fn epoch_set(&self, _first: bool, _: &Machine, _: BlockNumber, _: &[u8]) -> Result<(SimpleList, Option<H256>), EthcoreError> {
|
||||||
Ok((self.clone(), None))
|
Ok((self.clone(), None))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,10 +23,14 @@ use parity_util_mem::MallocSizeOf;
|
|||||||
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use ethereum_types::{H256, Address};
|
use ethereum_types::{H256, Address};
|
||||||
use types::BlockNumber;
|
use types::{
|
||||||
use types::header::Header;
|
BlockNumber,
|
||||||
|
header::Header,
|
||||||
|
errors::EthcoreError,
|
||||||
|
engines::machine::{Call, AuxiliaryData},
|
||||||
|
};
|
||||||
|
|
||||||
use machine::{AuxiliaryData, Call, Machine};
|
use machine::Machine;
|
||||||
use super::{ValidatorSet, SimpleList};
|
use super::{ValidatorSet, SimpleList};
|
||||||
|
|
||||||
/// Set used for testing with a single validator.
|
/// Set used for testing with a single validator.
|
||||||
@ -72,7 +76,7 @@ impl ValidatorSet for TestSet {
|
|||||||
::engines::EpochChange::No
|
::engines::EpochChange::No
|
||||||
}
|
}
|
||||||
|
|
||||||
fn epoch_set(&self, _: bool, _: &Machine, _: BlockNumber, _: &[u8]) -> Result<(SimpleList, Option<H256>), ::error::Error> {
|
fn epoch_set(&self, _: bool, _: &Machine, _: BlockNumber, _: &[u8]) -> Result<(SimpleList, Option<H256>), EthcoreError> {
|
||||||
Ok((self.validator.clone(), None))
|
Ok((self.validator.clone(), None))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,37 +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 <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
use ethereum_types::U256;
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
/// 1 Ether in Wei
|
|
||||||
pub fn ether() -> U256 { U256::exp10(18) }
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
/// 1 Finney in Wei
|
|
||||||
pub fn finney() -> U256 { U256::exp10(15) }
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
/// 1 Szabo in Wei
|
|
||||||
pub fn szabo() -> U256 { U256::exp10(12) }
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
/// 1 Shannon in Wei
|
|
||||||
pub fn shannon() -> U256 { U256::exp10(9) }
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
/// 1 Wei in Wei
|
|
||||||
pub fn wei() -> U256 { U256::exp10(0) }
|
|
@ -19,14 +19,6 @@
|
|||||||
//! Contains all Ethereum network specific stuff, such as denominations and
|
//! Contains all Ethereum network specific stuff, such as denominations and
|
||||||
//! consensus specifications.
|
//! consensus specifications.
|
||||||
|
|
||||||
/// Export the ethash module.
|
|
||||||
pub mod ethash;
|
|
||||||
/// Export the denominations module.
|
|
||||||
pub mod denominations;
|
|
||||||
|
|
||||||
pub use self::ethash::{Ethash};
|
|
||||||
pub use self::denominations::*;
|
|
||||||
|
|
||||||
use machine::Machine;
|
use machine::Machine;
|
||||||
use super::spec::*;
|
use super::spec::*;
|
||||||
|
|
||||||
|
@ -16,15 +16,15 @@
|
|||||||
|
|
||||||
//! Transaction execution format module.
|
//! Transaction execution format module.
|
||||||
|
|
||||||
use ethereum_types::{U256, U512, Address};
|
use ethereum_types::{U256, Address};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use ethtrie;
|
|
||||||
use vm;
|
use vm;
|
||||||
use trace::{VMTrace, FlatTrace};
|
use trace::{VMTrace, FlatTrace};
|
||||||
use types::state_diff::StateDiff;
|
use types::{
|
||||||
use types::log_entry::LogEntry;
|
state_diff::StateDiff,
|
||||||
|
log_entry::LogEntry,
|
||||||
use std::{fmt, error};
|
errors::ExecutionError,
|
||||||
|
};
|
||||||
|
|
||||||
/// Transaction execution receipt.
|
/// Transaction execution receipt.
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
@ -69,132 +69,5 @@ pub struct Executed<T = FlatTrace, V = VMTrace> {
|
|||||||
pub state_diff: Option<StateDiff>,
|
pub state_diff: Option<StateDiff>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Result of executing the transaction.
|
|
||||||
#[derive(PartialEq, Debug, Clone)]
|
|
||||||
pub enum ExecutionError {
|
|
||||||
/// Returned when there gas paid for transaction execution is
|
|
||||||
/// lower than base gas required.
|
|
||||||
NotEnoughBaseGas {
|
|
||||||
/// Absolute minimum gas required.
|
|
||||||
required: U256,
|
|
||||||
/// Gas provided.
|
|
||||||
got: U256
|
|
||||||
},
|
|
||||||
/// Returned when block (gas_used + gas) > gas_limit.
|
|
||||||
///
|
|
||||||
/// If gas =< gas_limit, upstream may try to execute the transaction
|
|
||||||
/// in next block.
|
|
||||||
BlockGasLimitReached {
|
|
||||||
/// Gas limit of block for transaction.
|
|
||||||
gas_limit: U256,
|
|
||||||
/// Gas used in block prior to transaction.
|
|
||||||
gas_used: U256,
|
|
||||||
/// Amount of gas in block.
|
|
||||||
gas: U256
|
|
||||||
},
|
|
||||||
/// Returned when transaction nonce does not match state nonce.
|
|
||||||
InvalidNonce {
|
|
||||||
/// Nonce expected.
|
|
||||||
expected: U256,
|
|
||||||
/// Nonce found.
|
|
||||||
got: U256
|
|
||||||
},
|
|
||||||
/// Returned when cost of transaction (value + gas_price * gas) exceeds
|
|
||||||
/// current sender balance.
|
|
||||||
NotEnoughCash {
|
|
||||||
/// Minimum required balance.
|
|
||||||
required: U512,
|
|
||||||
/// Actual balance.
|
|
||||||
got: U512
|
|
||||||
},
|
|
||||||
/// When execution tries to modify the state in static context
|
|
||||||
MutableCallInStaticContext,
|
|
||||||
/// Returned when transacting from a non-existing account with dust protection enabled.
|
|
||||||
SenderMustExist,
|
|
||||||
/// Returned when internal evm error occurs.
|
|
||||||
Internal(String),
|
|
||||||
/// Returned when generic transaction occurs
|
|
||||||
TransactionMalformed(String),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Box<ethtrie::TrieError>> for ExecutionError {
|
|
||||||
fn from(err: Box<ethtrie::TrieError>) -> Self {
|
|
||||||
ExecutionError::Internal(format!("{:?}", err))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl From<ethtrie::TrieError> for ExecutionError {
|
|
||||||
fn from(err: ethtrie::TrieError) -> Self {
|
|
||||||
ExecutionError::Internal(format!("{:?}", err))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Display for ExecutionError {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
use self::ExecutionError::*;
|
|
||||||
|
|
||||||
let msg = match *self {
|
|
||||||
NotEnoughBaseGas { ref required, ref got } =>
|
|
||||||
format!("Not enough base gas. {} is required, but only {} paid", required, got),
|
|
||||||
BlockGasLimitReached { ref gas_limit, ref gas_used, ref gas } =>
|
|
||||||
format!("Block gas limit reached. The limit is {}, {} has \
|
|
||||||
already been used, and {} more is required", gas_limit, gas_used, gas),
|
|
||||||
InvalidNonce { ref expected, ref got } =>
|
|
||||||
format!("Invalid transaction nonce: expected {}, found {}", expected, got),
|
|
||||||
NotEnoughCash { ref required, ref got } =>
|
|
||||||
format!("Cost of transaction exceeds sender balance. {} is required \
|
|
||||||
but the sender only has {}", required, got),
|
|
||||||
MutableCallInStaticContext => "Mutable Call in static context".to_owned(),
|
|
||||||
SenderMustExist => "Transacting from an empty account".to_owned(),
|
|
||||||
Internal(ref msg) => msg.clone(),
|
|
||||||
TransactionMalformed(ref err) => format!("Malformed transaction: {}", err),
|
|
||||||
};
|
|
||||||
|
|
||||||
f.write_fmt(format_args!("Transaction execution error ({}).", msg))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl error::Error for ExecutionError {
|
|
||||||
fn description(&self) -> &str {
|
|
||||||
"Transaction execution error"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Result of executing the transaction.
|
|
||||||
#[derive(PartialEq, Debug, Clone)]
|
|
||||||
pub enum CallError {
|
|
||||||
/// Couldn't find the transaction in the chain.
|
|
||||||
TransactionNotFound,
|
|
||||||
/// Couldn't find requested block's state in the chain.
|
|
||||||
StatePruned,
|
|
||||||
/// Couldn't find an amount of gas that didn't result in an exception.
|
|
||||||
Exceptional(vm::Error),
|
|
||||||
/// Corrupt state.
|
|
||||||
StateCorrupt,
|
|
||||||
/// Error executing.
|
|
||||||
Execution(ExecutionError),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<ExecutionError> for CallError {
|
|
||||||
fn from(error: ExecutionError) -> Self {
|
|
||||||
CallError::Execution(error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Display for CallError {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
use self::CallError::*;
|
|
||||||
|
|
||||||
let msg = match *self {
|
|
||||||
TransactionNotFound => "Transaction couldn't be found in the chain".into(),
|
|
||||||
StatePruned => "Couldn't find the transaction block's state in the chain".into(),
|
|
||||||
Exceptional(ref e) => format!("An exception ({}) happened in the execution", e),
|
|
||||||
StateCorrupt => "Stored state found to be corrupted.".into(),
|
|
||||||
Execution(ref e) => format!("{}", e),
|
|
||||||
};
|
|
||||||
|
|
||||||
f.write_fmt(format_args!("Transaction execution error ({}).", msg))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Transaction execution result.
|
/// Transaction execution result.
|
||||||
pub type ExecutionResult = Result<Box<Executed>, ExecutionError>;
|
pub type ExecutionResult = Result<Box<Executed>, ExecutionError>;
|
||||||
|
@ -23,7 +23,6 @@ use ethereum_types::{H256, U256, U512, Address};
|
|||||||
use bytes::{Bytes, BytesRef};
|
use bytes::{Bytes, BytesRef};
|
||||||
use account_state::{Backend as StateBackend, State, CleanupMode};
|
use account_state::{Backend as StateBackend, State, CleanupMode};
|
||||||
use substate::Substate;
|
use substate::Substate;
|
||||||
use executed::ExecutionError;
|
|
||||||
use machine::Machine;
|
use machine::Machine;
|
||||||
use evm::{CallType, Finalize, FinalizationResult};
|
use evm::{CallType, Finalize, FinalizationResult};
|
||||||
use vm::{
|
use vm::{
|
||||||
@ -33,7 +32,10 @@ use vm::{
|
|||||||
use trie_vm_factories::VmFactory;
|
use trie_vm_factories::VmFactory;
|
||||||
use externalities::*;
|
use externalities::*;
|
||||||
use trace::{self, Tracer, VMTracer};
|
use trace::{self, Tracer, VMTracer};
|
||||||
use types::transaction::{Action, SignedTransaction};
|
use types::{
|
||||||
|
errors::ExecutionError,
|
||||||
|
transaction::{Action, SignedTransaction},
|
||||||
|
};
|
||||||
use transaction_ext::Transaction;
|
use transaction_ext::Transaction;
|
||||||
use crossbeam_utils::thread;
|
use crossbeam_utils::thread;
|
||||||
pub use executed::{Executed, ExecutionResult};
|
pub use executed::{Executed, ExecutionResult};
|
||||||
@ -1215,7 +1217,6 @@ mod tests {
|
|||||||
use ethereum_types::{H256, U256, U512, Address, BigEndianHash};
|
use ethereum_types::{H256, U256, U512, Address, BigEndianHash};
|
||||||
use vm::{ActionParams, ActionValue, CallType, EnvInfo, CreateContractAddress};
|
use vm::{ActionParams, ActionValue, CallType, EnvInfo, CreateContractAddress};
|
||||||
use evm::{Factory, VMType};
|
use evm::{Factory, VMType};
|
||||||
use error::ExecutionError;
|
|
||||||
use machine::Machine;
|
use machine::Machine;
|
||||||
use account_state::CleanupMode;
|
use account_state::CleanupMode;
|
||||||
use substate::Substate;
|
use substate::Substate;
|
||||||
@ -1223,7 +1224,10 @@ mod tests {
|
|||||||
use trace::trace;
|
use trace::trace;
|
||||||
use trace::{FlatTrace, Tracer, NoopTracer, ExecutiveTracer};
|
use trace::{FlatTrace, Tracer, NoopTracer, ExecutiveTracer};
|
||||||
use trace::{VMTrace, VMOperation, VMExecutedOperation, MemoryDiff, StorageDiff, VMTracer, NoopVMTracer, ExecutiveVMTracer};
|
use trace::{VMTrace, VMOperation, VMExecutedOperation, MemoryDiff, StorageDiff, VMTracer, NoopVMTracer, ExecutiveVMTracer};
|
||||||
use types::transaction::{Action, Transaction};
|
use types::{
|
||||||
|
errors::ExecutionError,
|
||||||
|
transaction::{Action, Transaction},
|
||||||
|
};
|
||||||
|
|
||||||
fn make_frontier_machine(max_depth: usize) -> Machine {
|
fn make_frontier_machine(max_depth: usize) -> Machine {
|
||||||
let mut machine = ::ethereum::new_frontier_test_machine();
|
let mut machine = ::ethereum::new_frontier_test_machine();
|
||||||
|
@ -21,8 +21,9 @@
|
|||||||
use machine::Machine;
|
use machine::Machine;
|
||||||
use vm::EnvInfo;
|
use vm::EnvInfo;
|
||||||
use executive::{Executive, TransactOptions};
|
use executive::{Executive, TransactOptions};
|
||||||
use executed::{Executed, ExecutionError};
|
use executed::Executed;
|
||||||
use types::{
|
use types::{
|
||||||
|
errors::{ExecutionError, EthcoreError as Error},
|
||||||
transaction::SignedTransaction,
|
transaction::SignedTransaction,
|
||||||
receipt::{TransactionOutcome, Receipt},
|
receipt::{TransactionOutcome, Receipt},
|
||||||
};
|
};
|
||||||
@ -38,8 +39,6 @@ use keccak_hasher::KeccakHasher;
|
|||||||
use kvdb::DBValue;
|
use kvdb::DBValue;
|
||||||
use hash_db::AsHashDB;
|
use hash_db::AsHashDB;
|
||||||
|
|
||||||
use error::Error;
|
|
||||||
|
|
||||||
/// Return type of proof validity check.
|
/// Return type of proof validity check.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum ProvedExecution {
|
pub enum ProvedExecution {
|
||||||
|
@ -19,8 +19,11 @@ use super::test_common::*;
|
|||||||
use client::EvmTestClient;
|
use client::EvmTestClient;
|
||||||
use ethjson;
|
use ethjson;
|
||||||
use rlp::Rlp;
|
use rlp::Rlp;
|
||||||
use types::header::Header;
|
use types::{
|
||||||
use types::transaction::UnverifiedTransaction;
|
header::Header,
|
||||||
|
errors::EthcoreError as Error,
|
||||||
|
transaction::UnverifiedTransaction
|
||||||
|
};
|
||||||
use transaction_ext::Transaction;
|
use transaction_ext::Transaction;
|
||||||
|
|
||||||
/// Run transaction jsontests on a given folder.
|
/// Run transaction jsontests on a given folder.
|
||||||
@ -60,7 +63,7 @@ fn do_json_test<H: FnMut(&str, HookType)>(json_data: &[u8], start_stop_hook: &mu
|
|||||||
let rlp: Vec<u8> = test.rlp.clone().into();
|
let rlp: Vec<u8> = test.rlp.clone().into();
|
||||||
let res = Rlp::new(&rlp)
|
let res = Rlp::new(&rlp)
|
||||||
.as_val()
|
.as_val()
|
||||||
.map_err(::error::Error::from)
|
.map_err(Error::from)
|
||||||
.and_then(|t: UnverifiedTransaction| {
|
.and_then(|t: UnverifiedTransaction| {
|
||||||
let mut header: Header = Default::default();
|
let mut header: Header = Default::default();
|
||||||
// Use high enough number to activate all required features.
|
// Use high enough number to activate all required features.
|
||||||
|
@ -128,7 +128,6 @@ extern crate serde_json;
|
|||||||
extern crate ethabi_derive;
|
extern crate ethabi_derive;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate ethabi_contract;
|
extern crate ethabi_contract;
|
||||||
extern crate derive_more;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
@ -152,7 +151,6 @@ extern crate parity_runtime;
|
|||||||
pub mod block;
|
pub mod block;
|
||||||
pub mod client;
|
pub mod client;
|
||||||
pub mod engines;
|
pub mod engines;
|
||||||
pub mod error;
|
|
||||||
pub mod ethereum;
|
pub mod ethereum;
|
||||||
pub mod executed;
|
pub mod executed;
|
||||||
pub mod executive;
|
pub mod executive;
|
||||||
|
@ -22,17 +22,24 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use ethereum_types::{U256, H256, Address};
|
use ethereum_types::{U256, H256, Address};
|
||||||
use rlp::Rlp;
|
use rlp::Rlp;
|
||||||
use types::transaction::{self, SYSTEM_ADDRESS, UNSIGNED_SENDER, UnverifiedTransaction, SignedTransaction};
|
use types::{
|
||||||
use types::BlockNumber;
|
BlockNumber,
|
||||||
use types::header::Header;
|
header::Header,
|
||||||
use vm::{CallType, ActionParams, ActionValue, ParamsType, EnvInfo, Schedule};
|
engines::{
|
||||||
|
EthashExtensions,
|
||||||
|
params::CommonParams,
|
||||||
|
},
|
||||||
|
errors::{EngineError, EthcoreError as Error},
|
||||||
|
transaction::{self, SYSTEM_ADDRESS, UNSIGNED_SENDER, UnverifiedTransaction, SignedTransaction},
|
||||||
|
};
|
||||||
|
use vm::{CallType, ActionParams, ActionValue, ParamsType};
|
||||||
|
use vm::{EnvInfo, Schedule};
|
||||||
|
|
||||||
use block::ExecutedBlock;
|
use block::ExecutedBlock;
|
||||||
use builtin::Builtin;
|
use builtin::Builtin;
|
||||||
use call_contract::CallContract;
|
use call_contract::CallContract;
|
||||||
use client::BlockInfo;
|
use client::BlockInfo;
|
||||||
use error::Error;
|
|
||||||
use executive::Executive;
|
use executive::Executive;
|
||||||
use spec::CommonParams;
|
|
||||||
use account_state::CleanupMode;
|
use account_state::CleanupMode;
|
||||||
use substate::Substate;
|
use substate::Substate;
|
||||||
use trace::{NoopTracer, NoopVMTracer};
|
use trace::{NoopTracer, NoopVMTracer};
|
||||||
@ -41,30 +48,6 @@ use tx_filter::TransactionFilter;
|
|||||||
/// Parity tries to round block.gas_limit to multiple of this constant
|
/// Parity tries to round block.gas_limit to multiple of this constant
|
||||||
pub const PARITY_GAS_LIMIT_DETERMINANT: U256 = U256([37, 0, 0, 0]);
|
pub const PARITY_GAS_LIMIT_DETERMINANT: U256 = U256([37, 0, 0, 0]);
|
||||||
|
|
||||||
/// Ethash-specific extensions.
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
pub struct EthashExtensions {
|
|
||||||
/// Homestead transition block number.
|
|
||||||
pub homestead_transition: BlockNumber,
|
|
||||||
/// DAO hard-fork transition block (X).
|
|
||||||
pub dao_hardfork_transition: u64,
|
|
||||||
/// DAO hard-fork refund contract address (C).
|
|
||||||
pub dao_hardfork_beneficiary: Address,
|
|
||||||
/// DAO hard-fork DAO accounts list (L)
|
|
||||||
pub dao_hardfork_accounts: Vec<Address>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<::ethjson::spec::EthashParams> for EthashExtensions {
|
|
||||||
fn from(p: ::ethjson::spec::EthashParams) -> Self {
|
|
||||||
EthashExtensions {
|
|
||||||
homestead_transition: p.homestead_transition.map_or(0, Into::into),
|
|
||||||
dao_hardfork_transition: p.dao_hardfork_transition.map_or(u64::max_value(), Into::into),
|
|
||||||
dao_hardfork_beneficiary: p.dao_hardfork_beneficiary.map_or_else(Address::zero, Into::into),
|
|
||||||
dao_hardfork_accounts: p.dao_hardfork_accounts.unwrap_or_else(Vec::new).into_iter().map(Into::into).collect(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Special rules to be applied to the schedule.
|
/// Special rules to be applied to the schedule.
|
||||||
pub type ScheduleCreationRules = dyn Fn(&mut Schedule, BlockNumber) + Sync + Send;
|
pub type ScheduleCreationRules = dyn Fn(&mut Schedule, BlockNumber) + Sync + Send;
|
||||||
|
|
||||||
@ -182,7 +165,7 @@ impl Machine {
|
|||||||
let mut ex = Executive::new(&mut state, &env_info, self, &schedule);
|
let mut ex = Executive::new(&mut state, &env_info, self, &schedule);
|
||||||
let mut substate = Substate::new();
|
let mut substate = Substate::new();
|
||||||
|
|
||||||
let res = ex.call(params, &mut substate, &mut NoopTracer, &mut NoopVMTracer).map_err(|e| ::engines::EngineError::FailedSystemCall(format!("{}", e)))?;
|
let res = ex.call(params, &mut substate, &mut NoopTracer, &mut NoopVMTracer).map_err(|e| EngineError::FailedSystemCall(format!("{}", e)))?;
|
||||||
let output = res.return_data.to_vec();
|
let output = res.return_data.to_vec();
|
||||||
|
|
||||||
Ok(output)
|
Ok(output)
|
||||||
@ -366,9 +349,12 @@ impl Machine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Does verification of the transaction against the parent state.
|
/// Does verification of the transaction against the parent state.
|
||||||
pub fn verify_transaction<C: BlockInfo + CallContract>(&self, t: &SignedTransaction, parent: &Header, client: &C)
|
pub fn verify_transaction<C: BlockInfo + CallContract>(
|
||||||
-> Result<(), transaction::Error>
|
&self,
|
||||||
{
|
t: &SignedTransaction,
|
||||||
|
parent: &Header,
|
||||||
|
client: &C
|
||||||
|
) -> Result<(), transaction::Error> {
|
||||||
if let Some(ref filter) = self.tx_filter.as_ref() {
|
if let Some(ref filter) = self.tx_filter.as_ref() {
|
||||||
if !filter.transaction_allowed(&parent.hash(), parent.number() + 1, t, client) {
|
if !filter.transaction_allowed(&parent.hash(), parent.number() + 1, t, client) {
|
||||||
return Err(transaction::Error::NotAllowed.into())
|
return Err(transaction::Error::NotAllowed.into())
|
||||||
@ -399,30 +385,6 @@ impl Machine {
|
|||||||
live.state_mut().add_balance(address, amount, CleanupMode::NoEmpty).map_err(Into::into)
|
live.state_mut().add_balance(address, amount, CleanupMode::NoEmpty).map_err(Into::into)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// Auxiliary data fetcher for an Ethereum machine. In Ethereum-like machines
|
|
||||||
/// there are two kinds of auxiliary data: bodies and receipts.
|
|
||||||
#[derive(Default, Clone)]
|
|
||||||
pub struct AuxiliaryData<'a> {
|
|
||||||
/// The full block bytes, including the header.
|
|
||||||
pub bytes: Option<&'a [u8]>,
|
|
||||||
/// The block receipts.
|
|
||||||
pub receipts: Option<&'a [::types::receipt::Receipt]>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Type alias for a function we can make calls through synchronously.
|
|
||||||
/// Returns the call result and state proof for each call.
|
|
||||||
pub type Call<'a> = dyn Fn(Address, Vec<u8>) -> Result<(Vec<u8>, Vec<Vec<u8>>), String> + 'a;
|
|
||||||
|
|
||||||
/// Request for auxiliary data of a block.
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
|
||||||
pub enum AuxiliaryRequest {
|
|
||||||
/// Needs the body.
|
|
||||||
Body,
|
|
||||||
/// Needs the receipts.
|
|
||||||
Receipts,
|
|
||||||
/// Needs both body and receipts.
|
|
||||||
Both,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try to round gas_limit a bit so that:
|
// Try to round gas_limit a bit so that:
|
||||||
// 1) it will still be in desired range
|
// 1) it will still be in desired range
|
||||||
|
@ -43,20 +43,22 @@ use types::transaction::{
|
|||||||
SignedTransaction,
|
SignedTransaction,
|
||||||
PendingTransaction,
|
PendingTransaction,
|
||||||
};
|
};
|
||||||
use types::BlockNumber;
|
use types::{
|
||||||
use types::block::Block;
|
BlockNumber,
|
||||||
use types::header::Header;
|
block::Block,
|
||||||
use types::receipt::RichReceipt;
|
header::Header,
|
||||||
|
engines::{SealingState},
|
||||||
|
errors::{EthcoreError as Error, ExecutionError},
|
||||||
|
receipt::RichReceipt,
|
||||||
|
};
|
||||||
use using_queue::{UsingQueue, GetAction};
|
use using_queue::{UsingQueue, GetAction};
|
||||||
|
|
||||||
use block::{ClosedBlock, SealedBlock};
|
use block::{ClosedBlock, SealedBlock};
|
||||||
use client::{
|
use client::{
|
||||||
BlockChain, ChainInfo, BlockProducer, SealedBlockImporter, Nonce, TransactionInfo, TransactionId
|
BlockChain, ChainInfo, BlockProducer, SealedBlockImporter, Nonce, TransactionInfo, TransactionId, ClientIoMessage,
|
||||||
};
|
};
|
||||||
use client::{BlockId, ClientIoMessage};
|
use client::BlockId;
|
||||||
use engines::{Engine, Seal, SealingState, EngineSigner};
|
use engines::{Engine, Seal, EngineSigner};
|
||||||
use error::Error;
|
|
||||||
use executed::ExecutionError;
|
|
||||||
use executive::contract_address;
|
use executive::contract_address;
|
||||||
use spec::Spec;
|
use spec::Spec;
|
||||||
use account_state::State;
|
use account_state::State;
|
||||||
@ -245,7 +247,7 @@ pub struct Miner {
|
|||||||
sealing: Mutex<SealingWork>,
|
sealing: Mutex<SealingWork>,
|
||||||
params: RwLock<AuthoringParams>,
|
params: RwLock<AuthoringParams>,
|
||||||
#[cfg(feature = "work-notify")]
|
#[cfg(feature = "work-notify")]
|
||||||
listeners: RwLock<Vec<Box<NotifyWork>>>,
|
listeners: RwLock<Vec<Box<dyn NotifyWork>>>,
|
||||||
nonce_cache: NonceCache,
|
nonce_cache: NonceCache,
|
||||||
gas_pricer: Mutex<GasPricer>,
|
gas_pricer: Mutex<GasPricer>,
|
||||||
options: MinerOptions,
|
options: MinerOptions,
|
||||||
@ -260,7 +262,7 @@ pub struct Miner {
|
|||||||
impl Miner {
|
impl Miner {
|
||||||
/// Push listener that will handle new jobs
|
/// Push listener that will handle new jobs
|
||||||
#[cfg(feature = "work-notify")]
|
#[cfg(feature = "work-notify")]
|
||||||
pub fn add_work_listener(&self, notifier: Box<NotifyWork>) {
|
pub fn add_work_listener(&self, notifier: Box<dyn NotifyWork>) {
|
||||||
self.listeners.write().push(notifier);
|
self.listeners.write().push(notifier);
|
||||||
self.sealing.lock().enabled = true;
|
self.sealing.lock().enabled = true;
|
||||||
}
|
}
|
||||||
|
@ -37,10 +37,13 @@ use bytes::Bytes;
|
|||||||
use ethcore_miner::pool::{VerifiedTransaction, QueueStatus, local_transactions};
|
use ethcore_miner::pool::{VerifiedTransaction, QueueStatus, local_transactions};
|
||||||
use ethereum_types::{H256, U256, Address};
|
use ethereum_types::{H256, U256, Address};
|
||||||
use types::transaction::{self, UnverifiedTransaction, SignedTransaction, PendingTransaction};
|
use types::transaction::{self, UnverifiedTransaction, SignedTransaction, PendingTransaction};
|
||||||
use types::BlockNumber;
|
use types::{
|
||||||
use types::block::Block;
|
BlockNumber,
|
||||||
use types::header::Header;
|
errors::EthcoreError as Error,
|
||||||
use types::receipt::RichReceipt;
|
block::Block,
|
||||||
|
header::Header,
|
||||||
|
receipt::RichReceipt,
|
||||||
|
};
|
||||||
|
|
||||||
use block::SealedBlock;
|
use block::SealedBlock;
|
||||||
use call_contract::{CallContract, RegistryInfo};
|
use call_contract::{CallContract, RegistryInfo};
|
||||||
@ -49,7 +52,6 @@ use client::{
|
|||||||
BlockChain, BlockProducer, SealedBlockImporter, ChainInfo,
|
BlockChain, BlockProducer, SealedBlockImporter, ChainInfo,
|
||||||
AccountData, Nonce,
|
AccountData, Nonce,
|
||||||
};
|
};
|
||||||
use error::Error;
|
|
||||||
use account_state::state::StateInfo;
|
use account_state::state::StateInfo;
|
||||||
|
|
||||||
/// Provides methods to verify incoming external transactions
|
/// Provides methods to verify incoming external transactions
|
||||||
|
@ -36,7 +36,8 @@ use types::header::Header;
|
|||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
|
|
||||||
use call_contract::CallContract;
|
use call_contract::CallContract;
|
||||||
use client::{TransactionId, BlockInfo, Nonce};
|
use client::{TransactionId, Nonce};
|
||||||
|
use client::BlockInfo;
|
||||||
use engines::Engine;
|
use engines::Engine;
|
||||||
use miner;
|
use miner;
|
||||||
use transaction_ext::Transaction;
|
use transaction_ext::Transaction;
|
||||||
|
@ -255,7 +255,7 @@ impl Stratum {
|
|||||||
#[cfg(feature = "work-notify")]
|
#[cfg(feature = "work-notify")]
|
||||||
pub fn register(cfg: &Options, miner: Arc<Miner>, client: Weak<Client>) -> Result<(), Error> {
|
pub fn register(cfg: &Options, miner: Arc<Miner>, client: Weak<Client>) -> Result<(), Error> {
|
||||||
let stratum = Stratum::start(cfg, Arc::downgrade(&miner.clone()), client)?;
|
let stratum = Stratum::start(cfg, Arc::downgrade(&miner.clone()), client)?;
|
||||||
miner.add_work_listener(Box::new(stratum) as Box<NotifyWork>);
|
miner.add_work_listener(Box::new(stratum) as Box<dyn NotifyWork>);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use engines::{Engine, EpochVerifier, EpochTransition};
|
use engines::{Engine, EpochVerifier, EpochTransition};
|
||||||
use snapshot::{Error, ManifestData, Progress};
|
use snapshot::{ManifestData, Progress};
|
||||||
|
|
||||||
use blockchain::{BlockChain, BlockChainDB, BlockProvider};
|
use blockchain::{BlockChain, BlockChainDB, BlockProvider};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
@ -33,10 +33,13 @@ use ethereum_types::{H256, U256};
|
|||||||
use itertools::{Position, Itertools};
|
use itertools::{Position, Itertools};
|
||||||
use kvdb::KeyValueDB;
|
use kvdb::KeyValueDB;
|
||||||
use rlp::{RlpStream, Rlp};
|
use rlp::{RlpStream, Rlp};
|
||||||
use types::encoded;
|
use types::{
|
||||||
use types::header::Header;
|
encoded,
|
||||||
use types::ids::BlockId;
|
header::Header,
|
||||||
use types::receipt::Receipt;
|
ids::BlockId,
|
||||||
|
errors::{SnapshotError, EthcoreError},
|
||||||
|
receipt::Receipt,
|
||||||
|
};
|
||||||
|
|
||||||
/// Snapshot creation and restoration for PoA chains.
|
/// Snapshot creation and restoration for PoA chains.
|
||||||
/// Chunk format:
|
/// Chunk format:
|
||||||
@ -59,9 +62,9 @@ impl SnapshotComponents for PoaSnapshot {
|
|||||||
sink: &mut ChunkSink,
|
sink: &mut ChunkSink,
|
||||||
_progress: &Progress,
|
_progress: &Progress,
|
||||||
preferred_size: usize,
|
preferred_size: usize,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), SnapshotError> {
|
||||||
let number = chain.block_number(&block_at)
|
let number = chain.block_number(&block_at)
|
||||||
.ok_or_else(|| Error::InvalidStartingBlock(BlockId::Hash(block_at)))?;
|
.ok_or_else(||SnapshotError::InvalidStartingBlock(BlockId::Hash(block_at)))?;
|
||||||
|
|
||||||
let mut pending_size = 0;
|
let mut pending_size = 0;
|
||||||
let mut rlps = Vec::new();
|
let mut rlps = Vec::new();
|
||||||
@ -75,7 +78,7 @@ impl SnapshotComponents for PoaSnapshot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let header = chain.block_header_data(&transition.block_hash)
|
let header = chain.block_header_data(&transition.block_hash)
|
||||||
.ok_or_else(|| Error::BlockNotFound(transition.block_hash))?;
|
.ok_or_else(||SnapshotError::BlockNotFound(transition.block_hash))?;
|
||||||
|
|
||||||
let entry = {
|
let entry = {
|
||||||
let mut entry_stream = RlpStream::new_list(2);
|
let mut entry_stream = RlpStream::new_list(2);
|
||||||
@ -100,12 +103,12 @@ impl SnapshotComponents for PoaSnapshot {
|
|||||||
|
|
||||||
let (block, receipts) = chain.block(&block_at)
|
let (block, receipts) = chain.block(&block_at)
|
||||||
.and_then(|b| chain.block_receipts(&block_at).map(|r| (b, r)))
|
.and_then(|b| chain.block_receipts(&block_at).map(|r| (b, r)))
|
||||||
.ok_or_else(|| Error::BlockNotFound(block_at))?;
|
.ok_or_else(||SnapshotError::BlockNotFound(block_at))?;
|
||||||
let block = block.decode()?;
|
let block = block.decode()?;
|
||||||
|
|
||||||
let parent_td = chain.block_details(block.header.parent_hash())
|
let parent_td = chain.block_details(block.header.parent_hash())
|
||||||
.map(|d| d.total_difficulty)
|
.map(|d| d.total_difficulty)
|
||||||
.ok_or_else(|| Error::BlockNotFound(block_at))?;
|
.ok_or_else(||SnapshotError::BlockNotFound(block_at))?;
|
||||||
|
|
||||||
rlps.push({
|
rlps.push({
|
||||||
let mut stream = RlpStream::new_list(5);
|
let mut stream = RlpStream::new_list(5);
|
||||||
@ -128,11 +131,11 @@ impl SnapshotComponents for PoaSnapshot {
|
|||||||
chain: BlockChain,
|
chain: BlockChain,
|
||||||
db: Arc<dyn BlockChainDB>,
|
db: Arc<dyn BlockChainDB>,
|
||||||
manifest: &ManifestData,
|
manifest: &ManifestData,
|
||||||
) -> Result<Box<dyn Rebuilder>, ::error::Error> {
|
) -> Result<Box<dyn Rebuilder>, EthcoreError> {
|
||||||
Ok(Box::new(ChunkRebuilder {
|
Ok(Box::new(ChunkRebuilder {
|
||||||
manifest: manifest.clone(),
|
manifest: manifest.clone(),
|
||||||
warp_target: None,
|
warp_target: None,
|
||||||
chain: chain,
|
chain,
|
||||||
db: db.key_value().clone(),
|
db: db.key_value().clone(),
|
||||||
had_genesis: false,
|
had_genesis: false,
|
||||||
unverified_firsts: Vec::new(),
|
unverified_firsts: Vec::new(),
|
||||||
@ -146,7 +149,7 @@ impl SnapshotComponents for PoaSnapshot {
|
|||||||
|
|
||||||
// writes a chunk composed of the inner RLPs here.
|
// writes a chunk composed of the inner RLPs here.
|
||||||
// flag indicates whether the chunk is the last chunk.
|
// flag indicates whether the chunk is the last chunk.
|
||||||
fn write_chunk(last: bool, chunk_data: &mut Vec<Bytes>, sink: &mut ChunkSink) -> Result<(), Error> {
|
fn write_chunk(last: bool, chunk_data: &mut Vec<Bytes>, sink: &mut ChunkSink) -> Result<(), SnapshotError> {
|
||||||
let mut stream = RlpStream::new_list(1 + chunk_data.len());
|
let mut stream = RlpStream::new_list(1 + chunk_data.len());
|
||||||
|
|
||||||
stream.append(&last);
|
stream.append(&last);
|
||||||
@ -185,7 +188,7 @@ impl ChunkRebuilder {
|
|||||||
last_verifier: &mut Option<Box<dyn EpochVerifier>>,
|
last_verifier: &mut Option<Box<dyn EpochVerifier>>,
|
||||||
transition_rlp: Rlp,
|
transition_rlp: Rlp,
|
||||||
engine: &dyn Engine,
|
engine: &dyn Engine,
|
||||||
) -> Result<Verified, ::error::Error> {
|
) -> Result<Verified, EthcoreError> {
|
||||||
use engines::ConstructedVerifier;
|
use engines::ConstructedVerifier;
|
||||||
|
|
||||||
// decode.
|
// decode.
|
||||||
@ -202,7 +205,7 @@ impl ChunkRebuilder {
|
|||||||
Some(ref last) =>
|
Some(ref last) =>
|
||||||
if last.check_finality_proof(finality_proof).map_or(true, |hashes| !hashes.contains(&hash))
|
if last.check_finality_proof(finality_proof).map_or(true, |hashes| !hashes.contains(&hash))
|
||||||
{
|
{
|
||||||
return Err(Error::BadEpochProof(header.number()).into());
|
return Err(SnapshotError::BadEpochProof(header.number()).into());
|
||||||
},
|
},
|
||||||
None if header.number() != 0 => {
|
None if header.number() != 0 => {
|
||||||
// genesis never requires additional validation.
|
// genesis never requires additional validation.
|
||||||
@ -231,7 +234,7 @@ impl ChunkRebuilder {
|
|||||||
block_number: header.number(),
|
block_number: header.number(),
|
||||||
proof: epoch_data,
|
proof: epoch_data,
|
||||||
},
|
},
|
||||||
header: header,
|
header,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -242,7 +245,7 @@ impl Rebuilder for ChunkRebuilder {
|
|||||||
chunk: &[u8],
|
chunk: &[u8],
|
||||||
engine: &dyn Engine,
|
engine: &dyn Engine,
|
||||||
abort_flag: &AtomicBool,
|
abort_flag: &AtomicBool,
|
||||||
) -> Result<(), ::error::Error> {
|
) -> Result<(), EthcoreError> {
|
||||||
let rlp = Rlp::new(chunk);
|
let rlp = Rlp::new(chunk);
|
||||||
let is_last_chunk: bool = rlp.val_at(0)?;
|
let is_last_chunk: bool = rlp.val_at(0)?;
|
||||||
let num_items = rlp.item_count()?;
|
let num_items = rlp.item_count()?;
|
||||||
@ -255,13 +258,13 @@ impl Rebuilder for ChunkRebuilder {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if num_transitions == 0 && !is_last_chunk {
|
if num_transitions == 0 && !is_last_chunk {
|
||||||
return Err(Error::WrongChunkFormat("Found non-last chunk without any data.".into()).into());
|
return Err(SnapshotError::WrongChunkFormat("Found non-last chunk without any data.".into()).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut last_verifier = None;
|
let mut last_verifier = None;
|
||||||
let mut last_number = None;
|
let mut last_number = None;
|
||||||
for transition_rlp in rlp.iter().skip(1).take(num_transitions).with_position() {
|
for transition_rlp in rlp.iter().skip(1).take(num_transitions).with_position() {
|
||||||
if !abort_flag.load(Ordering::SeqCst) { return Err(Error::RestorationAborted.into()) }
|
if !abort_flag.load(Ordering::SeqCst) { return Err(SnapshotError::RestorationAborted.into()) }
|
||||||
|
|
||||||
let (is_first, is_last) = match transition_rlp {
|
let (is_first, is_last) = match transition_rlp {
|
||||||
Position::First(_) => (true, false),
|
Position::First(_) => (true, false),
|
||||||
@ -278,7 +281,7 @@ impl Rebuilder for ChunkRebuilder {
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
if last_number.map_or(false, |num| verified.header.number() <= num) {
|
if last_number.map_or(false, |num| verified.header.number() <= num) {
|
||||||
return Err(Error::WrongChunkFormat("Later epoch transition in earlier or same block.".into()).into());
|
return Err(SnapshotError::WrongChunkFormat("Later epoch transition in earlier or same block.".into()).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
last_number = Some(verified.header.number());
|
last_number = Some(verified.header.number());
|
||||||
@ -289,7 +292,7 @@ impl Rebuilder for ChunkRebuilder {
|
|||||||
// but it doesn't need verification later.
|
// but it doesn't need verification later.
|
||||||
if verified.header.number() == 0 {
|
if verified.header.number() == 0 {
|
||||||
if verified.header.hash() != self.chain.genesis_hash() {
|
if verified.header.hash() != self.chain.genesis_hash() {
|
||||||
return Err(Error::WrongBlockHash(0, verified.header.hash(), self.chain.genesis_hash()).into());
|
return Err(SnapshotError::WrongBlockHash(0, verified.header.hash(), self.chain.genesis_hash()).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
self.had_genesis = true;
|
self.had_genesis = true;
|
||||||
@ -332,7 +335,7 @@ impl Rebuilder for ChunkRebuilder {
|
|||||||
let hash = block.header.hash();
|
let hash = block.header.hash();
|
||||||
let best_hash = self.manifest.block_hash;
|
let best_hash = self.manifest.block_hash;
|
||||||
if hash != best_hash {
|
if hash != best_hash {
|
||||||
return Err(Error::WrongBlockHash(block.header.number(), best_hash, hash).into())
|
return Err(SnapshotError::WrongBlockHash(block.header.number(), best_hash, hash).into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,14 +351,14 @@ impl Rebuilder for ChunkRebuilder {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn finalize(&mut self) -> Result<(), ::error::Error> {
|
fn finalize(&mut self) -> Result<(), EthcoreError> {
|
||||||
if !self.had_genesis {
|
if !self.had_genesis {
|
||||||
return Err(Error::WrongChunkFormat("No genesis transition included.".into()).into());
|
return Err(SnapshotError::WrongChunkFormat("No genesis transition included.".into()).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
let target_header = match self.warp_target.take() {
|
let target_header = match self.warp_target.take() {
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
None => return Err(Error::WrongChunkFormat("Warp target block not included.".into()).into()),
|
None => return Err(SnapshotError::WrongChunkFormat("Warp target block not included.".into()).into()),
|
||||||
};
|
};
|
||||||
|
|
||||||
trace!(target: "snapshot", "rebuilder, finalize: verifying {} unverified first blocks", self.unverified_firsts.len());
|
trace!(target: "snapshot", "rebuilder, finalize: verifying {} unverified first blocks", self.unverified_firsts.len());
|
||||||
@ -368,7 +371,7 @@ impl Rebuilder for ChunkRebuilder {
|
|||||||
while let Some(&(ref last_header, ref last_verifier)) = lasts_reversed.next() {
|
while let Some(&(ref last_header, ref last_verifier)) = lasts_reversed.next() {
|
||||||
if last_header.number() < header.number() {
|
if last_header.number() < header.number() {
|
||||||
if last_verifier.check_finality_proof(&finality_proof).map_or(true, |hashes| !hashes.contains(&hash)) {
|
if last_verifier.check_finality_proof(&finality_proof).map_or(true, |hashes| !hashes.contains(&hash)) {
|
||||||
return Err(Error::BadEpochProof(header.number()).into());
|
return Err(SnapshotError::BadEpochProof(header.number()).into());
|
||||||
}
|
}
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
@ -376,7 +379,7 @@ impl Rebuilder for ChunkRebuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !found {
|
if !found {
|
||||||
return Err(Error::WrongChunkFormat("Inconsistent chunk ordering.".into()).into());
|
return Err(SnapshotError::WrongChunkFormat("Inconsistent chunk ordering.".into()).into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,8 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use blockchain::{BlockChain, BlockChainDB};
|
use blockchain::{BlockChain, BlockChainDB};
|
||||||
use engines::Engine;
|
use engines::Engine;
|
||||||
use snapshot::{Error, ManifestData, Progress};
|
use snapshot::{ManifestData, Progress};
|
||||||
|
use types::errors::{SnapshotError, EthcoreError};
|
||||||
|
|
||||||
use ethereum_types::H256;
|
use ethereum_types::H256;
|
||||||
|
|
||||||
@ -51,7 +52,7 @@ pub trait SnapshotComponents: Send {
|
|||||||
chunk_sink: &mut ChunkSink,
|
chunk_sink: &mut ChunkSink,
|
||||||
progress: &Progress,
|
progress: &Progress,
|
||||||
preferred_size: usize,
|
preferred_size: usize,
|
||||||
) -> Result<(), Error>;
|
) -> Result<(), SnapshotError>;
|
||||||
|
|
||||||
/// Create a rebuilder, which will have chunks fed into it in aribtrary
|
/// Create a rebuilder, which will have chunks fed into it in aribtrary
|
||||||
/// order and then be finalized.
|
/// order and then be finalized.
|
||||||
@ -65,7 +66,7 @@ pub trait SnapshotComponents: Send {
|
|||||||
chain: BlockChain,
|
chain: BlockChain,
|
||||||
db: Arc<dyn BlockChainDB>,
|
db: Arc<dyn BlockChainDB>,
|
||||||
manifest: &ManifestData,
|
manifest: &ManifestData,
|
||||||
) -> Result<Box<dyn Rebuilder>, ::error::Error>;
|
) -> Result<Box<dyn Rebuilder>, EthcoreError>;
|
||||||
|
|
||||||
/// Minimum supported snapshot version number.
|
/// Minimum supported snapshot version number.
|
||||||
fn min_supported_version(&self) -> u64;
|
fn min_supported_version(&self) -> u64;
|
||||||
@ -85,12 +86,12 @@ pub trait Rebuilder: Send {
|
|||||||
chunk: &[u8],
|
chunk: &[u8],
|
||||||
engine: &dyn Engine,
|
engine: &dyn Engine,
|
||||||
abort_flag: &AtomicBool,
|
abort_flag: &AtomicBool,
|
||||||
) -> Result<(), ::error::Error>;
|
) -> Result<(), EthcoreError>;
|
||||||
|
|
||||||
/// Finalize the restoration. Will be done after all chunks have been
|
/// Finalize the restoration. Will be done after all chunks have been
|
||||||
/// fed successfully.
|
/// fed successfully.
|
||||||
///
|
///
|
||||||
/// This should apply the necessary "glue" between chunks,
|
/// This should apply the necessary "glue" between chunks,
|
||||||
/// and verify against the restored state.
|
/// and verify against the restored state.
|
||||||
fn finalize(&mut self) -> Result<(), ::error::Error>;
|
fn finalize(&mut self) -> Result<(), EthcoreError>;
|
||||||
}
|
}
|
||||||
|
@ -28,14 +28,17 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use blockchain::{BlockChain, BlockChainDB, BlockProvider};
|
use blockchain::{BlockChain, BlockChainDB, BlockProvider};
|
||||||
use engines::Engine;
|
use engines::Engine;
|
||||||
use snapshot::{Error, ManifestData, Progress};
|
use snapshot::{ManifestData, Progress};
|
||||||
use snapshot::block::AbridgedBlock;
|
use snapshot::block::AbridgedBlock;
|
||||||
use ethereum_types::H256;
|
use ethereum_types::H256;
|
||||||
use kvdb::KeyValueDB;
|
use kvdb::KeyValueDB;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use rlp::{RlpStream, Rlp};
|
use rlp::{RlpStream, Rlp};
|
||||||
use rand::rngs::OsRng;
|
use rand::rngs::OsRng;
|
||||||
use types::encoded;
|
use types::{
|
||||||
|
encoded,
|
||||||
|
errors::{SnapshotError, EthcoreError},
|
||||||
|
};
|
||||||
|
|
||||||
/// Snapshot creation and restoration for PoW chains.
|
/// Snapshot creation and restoration for PoW chains.
|
||||||
/// This includes blocks from the head of the chain as a
|
/// This includes blocks from the head of the chain as a
|
||||||
@ -52,10 +55,7 @@ pub struct PowSnapshot {
|
|||||||
impl PowSnapshot {
|
impl PowSnapshot {
|
||||||
/// Create a new instance.
|
/// Create a new instance.
|
||||||
pub fn new(blocks: u64, max_restore_blocks: u64) -> PowSnapshot {
|
pub fn new(blocks: u64, max_restore_blocks: u64) -> PowSnapshot {
|
||||||
PowSnapshot {
|
PowSnapshot { blocks, max_restore_blocks }
|
||||||
blocks: blocks,
|
|
||||||
max_restore_blocks: max_restore_blocks,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,14 +67,14 @@ impl SnapshotComponents for PowSnapshot {
|
|||||||
chunk_sink: &mut ChunkSink,
|
chunk_sink: &mut ChunkSink,
|
||||||
progress: &Progress,
|
progress: &Progress,
|
||||||
preferred_size: usize,
|
preferred_size: usize,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), SnapshotError> {
|
||||||
PowWorker {
|
PowWorker {
|
||||||
chain: chain,
|
chain,
|
||||||
rlps: VecDeque::new(),
|
rlps: VecDeque::new(),
|
||||||
current_hash: block_at,
|
current_hash: block_at,
|
||||||
writer: chunk_sink,
|
writer: chunk_sink,
|
||||||
progress: progress,
|
progress,
|
||||||
preferred_size: preferred_size,
|
preferred_size,
|
||||||
}.chunk_all(self.blocks)
|
}.chunk_all(self.blocks)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ impl SnapshotComponents for PowSnapshot {
|
|||||||
chain: BlockChain,
|
chain: BlockChain,
|
||||||
db: Arc<dyn BlockChainDB>,
|
db: Arc<dyn BlockChainDB>,
|
||||||
manifest: &ManifestData,
|
manifest: &ManifestData,
|
||||||
) -> Result<Box<dyn Rebuilder>, ::error::Error> {
|
) -> Result<Box<dyn Rebuilder>, EthcoreError> {
|
||||||
PowRebuilder::new(chain, db.key_value().clone(), manifest, self.max_restore_blocks).map(|r| Box::new(r) as Box<_>)
|
PowRebuilder::new(chain, db.key_value().clone(), manifest, self.max_restore_blocks).map(|r| Box::new(r) as Box<_>)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ struct PowWorker<'a> {
|
|||||||
impl<'a> PowWorker<'a> {
|
impl<'a> PowWorker<'a> {
|
||||||
// Repeatedly fill the buffers and writes out chunks, moving backwards from starting block hash.
|
// Repeatedly fill the buffers and writes out chunks, moving backwards from starting block hash.
|
||||||
// Loops until we reach the first desired block, and writes out the remainder.
|
// Loops until we reach the first desired block, and writes out the remainder.
|
||||||
fn chunk_all(&mut self, snapshot_blocks: u64) -> Result<(), Error> {
|
fn chunk_all(&mut self, snapshot_blocks: u64) -> Result<(), SnapshotError> {
|
||||||
let mut loaded_size = 0;
|
let mut loaded_size = 0;
|
||||||
let mut last = self.current_hash;
|
let mut last = self.current_hash;
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ impl<'a> PowWorker<'a> {
|
|||||||
|
|
||||||
let (block, receipts) = self.chain.block(&self.current_hash)
|
let (block, receipts) = self.chain.block(&self.current_hash)
|
||||||
.and_then(|b| self.chain.block_receipts(&self.current_hash).map(|r| (b, r)))
|
.and_then(|b| self.chain.block_receipts(&self.current_hash).map(|r| (b, r)))
|
||||||
.ok_or_else(|| Error::BlockNotFound(self.current_hash))?;
|
.ok_or_else(||SnapshotError::BlockNotFound(self.current_hash))?;
|
||||||
|
|
||||||
let abridged_rlp = AbridgedBlock::from_block_view(&block.view()).into_inner();
|
let abridged_rlp = AbridgedBlock::from_block_view(&block.view()).into_inner();
|
||||||
|
|
||||||
@ -155,12 +155,12 @@ impl<'a> PowWorker<'a> {
|
|||||||
//
|
//
|
||||||
// we preface each chunk with the parent of the first block's details,
|
// we preface each chunk with the parent of the first block's details,
|
||||||
// obtained from the details of the last block written.
|
// obtained from the details of the last block written.
|
||||||
fn write_chunk(&mut self, last: H256) -> Result<(), Error> {
|
fn write_chunk(&mut self, last: H256) -> Result<(), SnapshotError> {
|
||||||
trace!(target: "snapshot", "prepared block chunk with {} blocks", self.rlps.len());
|
trace!(target: "snapshot", "prepared block chunk with {} blocks", self.rlps.len());
|
||||||
|
|
||||||
let (last_header, last_details) = self.chain.block_header_data(&last)
|
let (last_header, last_details) = self.chain.block_header_data(&last)
|
||||||
.and_then(|n| self.chain.block_details(&last).map(|d| (n, d)))
|
.and_then(|n| self.chain.block_details(&last).map(|d| (n, d)))
|
||||||
.ok_or_else(|| Error::BlockNotFound(last))?;
|
.ok_or_else(||SnapshotError::BlockNotFound(last))?;
|
||||||
|
|
||||||
let parent_number = last_header.number() - 1;
|
let parent_number = last_header.number() - 1;
|
||||||
let parent_hash = last_header.parent_hash();
|
let parent_hash = last_header.parent_hash();
|
||||||
@ -206,7 +206,7 @@ pub struct PowRebuilder {
|
|||||||
|
|
||||||
impl PowRebuilder {
|
impl PowRebuilder {
|
||||||
/// Create a new PowRebuilder.
|
/// Create a new PowRebuilder.
|
||||||
fn new(chain: BlockChain, db: Arc<dyn KeyValueDB>, manifest: &ManifestData, snapshot_blocks: u64) -> Result<Self, ::error::Error> {
|
fn new(chain: BlockChain, db: Arc<dyn KeyValueDB>, manifest: &ManifestData, snapshot_blocks: u64) -> Result<Self, EthcoreError> {
|
||||||
Ok(PowRebuilder {
|
Ok(PowRebuilder {
|
||||||
chain,
|
chain,
|
||||||
db,
|
db,
|
||||||
@ -224,7 +224,7 @@ impl PowRebuilder {
|
|||||||
impl Rebuilder for PowRebuilder {
|
impl Rebuilder for PowRebuilder {
|
||||||
/// Feed the rebuilder an uncompressed block chunk.
|
/// Feed the rebuilder an uncompressed block chunk.
|
||||||
/// Returns the number of blocks fed or any errors.
|
/// Returns the number of blocks fed or any errors.
|
||||||
fn feed(&mut self, chunk: &[u8], engine: &dyn Engine, abort_flag: &AtomicBool) -> Result<(), ::error::Error> {
|
fn feed(&mut self, chunk: &[u8], engine: &dyn Engine, abort_flag: &AtomicBool) -> Result<(), EthcoreError> {
|
||||||
use snapshot::verify_old_block;
|
use snapshot::verify_old_block;
|
||||||
use ethereum_types::U256;
|
use ethereum_types::U256;
|
||||||
use triehash::ordered_trie_root;
|
use triehash::ordered_trie_root;
|
||||||
@ -236,7 +236,7 @@ impl Rebuilder for PowRebuilder {
|
|||||||
trace!(target: "snapshot", "restoring block chunk with {} blocks.", num_blocks);
|
trace!(target: "snapshot", "restoring block chunk with {} blocks.", num_blocks);
|
||||||
|
|
||||||
if self.fed_blocks + num_blocks > self.snapshot_blocks {
|
if self.fed_blocks + num_blocks > self.snapshot_blocks {
|
||||||
return Err(Error::TooManyBlocks(self.snapshot_blocks, self.fed_blocks + num_blocks).into())
|
return Err(SnapshotError::TooManyBlocks(self.snapshot_blocks, self.fed_blocks + num_blocks).into())
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: assert here that these values are consistent with chunks being in order.
|
// todo: assert here that these values are consistent with chunks being in order.
|
||||||
@ -245,7 +245,7 @@ impl Rebuilder for PowRebuilder {
|
|||||||
let parent_total_difficulty = rlp.val_at::<U256>(2)?;
|
let parent_total_difficulty = rlp.val_at::<U256>(2)?;
|
||||||
|
|
||||||
for idx in 3..item_count {
|
for idx in 3..item_count {
|
||||||
if !abort_flag.load(Ordering::SeqCst) { return Err(Error::RestorationAborted.into()) }
|
if !abort_flag.load(Ordering::SeqCst) { return Err(SnapshotError::RestorationAborted.into()) }
|
||||||
|
|
||||||
let pair = rlp.at(idx)?;
|
let pair = rlp.at(idx)?;
|
||||||
let abridged_rlp = pair.at(0)?.as_raw().to_owned();
|
let abridged_rlp = pair.at(0)?.as_raw().to_owned();
|
||||||
@ -259,11 +259,11 @@ impl Rebuilder for PowRebuilder {
|
|||||||
|
|
||||||
if is_best {
|
if is_best {
|
||||||
if block.header.hash() != self.best_hash {
|
if block.header.hash() != self.best_hash {
|
||||||
return Err(Error::WrongBlockHash(cur_number, self.best_hash, block.header.hash()).into())
|
return Err(SnapshotError::WrongBlockHash(cur_number, self.best_hash, block.header.hash()).into())
|
||||||
}
|
}
|
||||||
|
|
||||||
if block.header.state_root() != &self.best_root {
|
if block.header.state_root() != &self.best_root {
|
||||||
return Err(Error::WrongStateRoot(self.best_root, *block.header.state_root()).into())
|
return Err(SnapshotError::WrongStateRoot(self.best_root, *block.header.state_root()).into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,7 +298,7 @@ impl Rebuilder for PowRebuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Glue together any disconnected chunks and check that the chain is complete.
|
/// Glue together any disconnected chunks and check that the chain is complete.
|
||||||
fn finalize(&mut self) -> Result<(), ::error::Error> {
|
fn finalize(&mut self) -> Result<(), EthcoreError> {
|
||||||
let mut batch = self.db.transaction();
|
let mut batch = self.db.transaction();
|
||||||
trace!(target: "snapshot", "rebuilder, finalize: inserting {} disconnected chunks", self.disconnected.len());
|
trace!(target: "snapshot", "rebuilder, finalize: inserting {} disconnected chunks", self.disconnected.len());
|
||||||
for (first_num, first_hash) in self.disconnected.drain(..) {
|
for (first_num, first_hash) in self.disconnected.drain(..) {
|
||||||
|
@ -28,6 +28,7 @@ use std::path::{Path, PathBuf};
|
|||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use ethereum_types::H256;
|
use ethereum_types::H256;
|
||||||
use rlp::{RlpStream, Rlp};
|
use rlp::{RlpStream, Rlp};
|
||||||
|
use types::errors::{SnapshotError, EthcoreError};
|
||||||
|
|
||||||
use super::ManifestData;
|
use super::ManifestData;
|
||||||
|
|
||||||
@ -206,7 +207,7 @@ impl PackedReader {
|
|||||||
/// Create a new `PackedReader` for the file at the given path.
|
/// Create a new `PackedReader` for the file at the given path.
|
||||||
/// This will fail if any io errors are encountered or the file
|
/// This will fail if any io errors are encountered or the file
|
||||||
/// is not a valid packed snapshot.
|
/// is not a valid packed snapshot.
|
||||||
pub fn new(path: &Path) -> Result<Option<Self>, ::snapshot::error::Error> {
|
pub fn new(path: &Path) -> Result<Option<Self>, SnapshotError> {
|
||||||
let mut file = File::open(path)?;
|
let mut file = File::open(path)?;
|
||||||
let file_len = file.metadata()?.len();
|
let file_len = file.metadata()?.len();
|
||||||
if file_len < 8 {
|
if file_len < 8 {
|
||||||
@ -246,7 +247,7 @@ impl PackedReader {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if version > SNAPSHOT_VERSION {
|
if version > SNAPSHOT_VERSION {
|
||||||
return Err(::snapshot::error::Error::VersionNotSupported(version));
|
return Err(SnapshotError::VersionNotSupported(version));
|
||||||
}
|
}
|
||||||
|
|
||||||
let state: Vec<ChunkInfo> = rlp.list_at(0 + start)?;
|
let state: Vec<ChunkInfo> = rlp.list_at(0 + start)?;
|
||||||
@ -299,7 +300,7 @@ pub struct LooseReader {
|
|||||||
impl LooseReader {
|
impl LooseReader {
|
||||||
/// Create a new `LooseReader` which will read the manifest and chunk data from
|
/// Create a new `LooseReader` which will read the manifest and chunk data from
|
||||||
/// the given directory.
|
/// the given directory.
|
||||||
pub fn new(mut dir: PathBuf) -> Result<Self, ::error::Error> {
|
pub fn new(mut dir: PathBuf) -> Result<Self, EthcoreError> {
|
||||||
let mut manifest_buf = Vec::new();
|
let mut manifest_buf = Vec::new();
|
||||||
|
|
||||||
dir.push("MANIFEST");
|
dir.push("MANIFEST");
|
||||||
|
@ -28,9 +28,11 @@ use hash::{keccak, KECCAK_NULL_RLP, KECCAK_EMPTY};
|
|||||||
use account_db::{AccountDB, AccountDBMut};
|
use account_db::{AccountDB, AccountDBMut};
|
||||||
use blockchain::{BlockChain, BlockProvider};
|
use blockchain::{BlockChain, BlockProvider};
|
||||||
use engines::Engine;
|
use engines::Engine;
|
||||||
use types::header::Header;
|
use types::{
|
||||||
use types::ids::BlockId;
|
ids::BlockId,
|
||||||
|
header::Header,
|
||||||
|
errors::{SnapshotError as Error, EthcoreError},
|
||||||
|
};
|
||||||
use ethereum_types::{H256, U256};
|
use ethereum_types::{H256, U256};
|
||||||
use hash_db::HashDB;
|
use hash_db::HashDB;
|
||||||
use keccak_hasher::KeccakHasher;
|
use keccak_hasher::KeccakHasher;
|
||||||
@ -53,8 +55,6 @@ use account_state::Account as StateAccount;
|
|||||||
use crossbeam_utils::thread;
|
use crossbeam_utils::thread;
|
||||||
use rand::{Rng, rngs::OsRng};
|
use rand::{Rng, rngs::OsRng};
|
||||||
|
|
||||||
pub use self::error::Error;
|
|
||||||
|
|
||||||
pub use self::consensus::*;
|
pub use self::consensus::*;
|
||||||
pub use self::service::{SnapshotClient, Service, DatabaseRestore};
|
pub use self::service::{SnapshotClient, Service, DatabaseRestore};
|
||||||
pub use self::traits::SnapshotService;
|
pub use self::traits::SnapshotService;
|
||||||
@ -69,7 +69,6 @@ pub mod service;
|
|||||||
mod account;
|
mod account;
|
||||||
mod block;
|
mod block;
|
||||||
mod consensus;
|
mod consensus;
|
||||||
mod error;
|
|
||||||
mod watcher;
|
mod watcher;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@ -423,7 +422,7 @@ impl StateRebuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Feed an uncompressed state chunk into the rebuilder.
|
/// Feed an uncompressed state chunk into the rebuilder.
|
||||||
pub fn feed(&mut self, chunk: &[u8], flag: &AtomicBool) -> Result<(), ::error::Error> {
|
pub fn feed(&mut self, chunk: &[u8], flag: &AtomicBool) -> Result<(), EthcoreError> {
|
||||||
let rlp = Rlp::new(chunk);
|
let rlp = Rlp::new(chunk);
|
||||||
let empty_rlp = StateAccount::new_basic(U256::zero(), U256::zero()).rlp();
|
let empty_rlp = StateAccount::new_basic(U256::zero(), U256::zero()).rlp();
|
||||||
let mut pairs = Vec::with_capacity(rlp.item_count()?);
|
let mut pairs = Vec::with_capacity(rlp.item_count()?);
|
||||||
@ -486,7 +485,7 @@ impl StateRebuilder {
|
|||||||
/// Finalize the restoration. Check for accounts missing code and make a dummy
|
/// Finalize the restoration. Check for accounts missing code and make a dummy
|
||||||
/// journal entry.
|
/// journal entry.
|
||||||
/// Once all chunks have been fed, there should be nothing missing.
|
/// Once all chunks have been fed, there should be nothing missing.
|
||||||
pub fn finalize(mut self, era: u64, id: H256) -> Result<Box<dyn JournalDB>, ::error::Error> {
|
pub fn finalize(mut self, era: u64, id: H256) -> Result<Box<dyn JournalDB>, EthcoreError> {
|
||||||
let missing = self.missing_code.keys().cloned().collect::<Vec<_>>();
|
let missing = self.missing_code.keys().cloned().collect::<Vec<_>>();
|
||||||
if !missing.is_empty() { return Err(Error::MissingCode(missing).into()) }
|
if !missing.is_empty() { return Err(Error::MissingCode(missing).into()) }
|
||||||
|
|
||||||
@ -517,7 +516,7 @@ fn rebuild_accounts(
|
|||||||
known_code: &HashMap<H256, H256>,
|
known_code: &HashMap<H256, H256>,
|
||||||
known_storage_roots: &mut HashMap<H256, H256>,
|
known_storage_roots: &mut HashMap<H256, H256>,
|
||||||
abort_flag: &AtomicBool,
|
abort_flag: &AtomicBool,
|
||||||
) -> Result<RebuiltStatus, ::error::Error> {
|
) -> Result<RebuiltStatus, EthcoreError> {
|
||||||
let mut status = RebuiltStatus::default();
|
let mut status = RebuiltStatus::default();
|
||||||
for (account_rlp, out) in account_fat_rlps.into_iter().zip(out_chunk.iter_mut()) {
|
for (account_rlp, out) in account_fat_rlps.into_iter().zip(out_chunk.iter_mut()) {
|
||||||
if !abort_flag.load(Ordering::SeqCst) { return Err(Error::RestorationAborted.into()) }
|
if !abort_flag.load(Ordering::SeqCst) { return Err(Error::RestorationAborted.into()) }
|
||||||
@ -578,13 +577,13 @@ const POW_VERIFY_RATE: f32 = 0.02;
|
|||||||
/// Verify an old block with the given header, engine, blockchain, body. If `always` is set, it will perform
|
/// Verify an old block with the given header, engine, blockchain, body. If `always` is set, it will perform
|
||||||
/// the fullest verification possible. If not, it will take a random sample to determine whether it will
|
/// the fullest verification possible. If not, it will take a random sample to determine whether it will
|
||||||
/// do heavy or light verification.
|
/// do heavy or light verification.
|
||||||
pub fn verify_old_block(rng: &mut OsRng, header: &Header, engine: &dyn Engine, chain: &BlockChain, always: bool) -> Result<(), ::error::Error> {
|
pub fn verify_old_block(rng: &mut OsRng, header: &Header, engine: &dyn Engine, chain: &BlockChain, always: bool) -> Result<(), EthcoreError> {
|
||||||
engine.verify_block_basic(header)?;
|
engine.verify_block_basic(header)?;
|
||||||
|
|
||||||
if always || rng.gen::<f32>() <= POW_VERIFY_RATE {
|
if always || rng.gen::<f32>() <= POW_VERIFY_RATE {
|
||||||
engine.verify_block_unordered(header)?;
|
engine.verify_block_unordered(header)?;
|
||||||
match chain.block_header_data(header.parent_hash()) {
|
match chain.block_header_data(header.parent_hash()) {
|
||||||
Some(parent) => engine.verify_block_family(header, &parent.decode()?),
|
Some(parent) => engine.verify_block_family(header, &parent.decode()?).map_err(Into::into),
|
||||||
None => Ok(()),
|
None => Ok(()),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -28,12 +28,13 @@ use super::{ManifestData, StateRebuilder, Rebuilder, RestorationStatus, Snapshot
|
|||||||
use super::io::{SnapshotReader, LooseReader, SnapshotWriter, LooseWriter};
|
use super::io::{SnapshotReader, LooseReader, SnapshotWriter, LooseWriter};
|
||||||
|
|
||||||
use blockchain::{BlockChain, BlockChainDB, BlockChainDBHandler};
|
use blockchain::{BlockChain, BlockChainDB, BlockChainDBHandler};
|
||||||
use client::{BlockInfo, BlockChainClient, Client, ChainInfo, ClientIoMessage};
|
use client::{BlockChainClient, Client, ChainInfo, BlockInfo, ClientIoMessage};
|
||||||
use engines::Engine;
|
use engines::Engine;
|
||||||
use error::Error;
|
|
||||||
use snapshot::{Error as SnapshotError};
|
|
||||||
use hash::keccak;
|
use hash::keccak;
|
||||||
use types::ids::BlockId;
|
use types::{
|
||||||
|
errors::{EthcoreError as Error, SnapshotError, SnapshotError::UnlinkedAncientBlockChain},
|
||||||
|
ids::BlockId,
|
||||||
|
};
|
||||||
|
|
||||||
use io::IoChannel;
|
use io::IoChannel;
|
||||||
|
|
||||||
@ -43,7 +44,6 @@ use bytes::Bytes;
|
|||||||
use journaldb::Algorithm;
|
use journaldb::Algorithm;
|
||||||
use kvdb::DBTransaction;
|
use kvdb::DBTransaction;
|
||||||
use snappy;
|
use snappy;
|
||||||
use snapshot::error::Error::UnlinkedAncientBlockChain;
|
|
||||||
|
|
||||||
/// Helper for removing directories in case of error.
|
/// Helper for removing directories in case of error.
|
||||||
struct Guard(bool, PathBuf);
|
struct Guard(bool, PathBuf);
|
||||||
|
@ -41,6 +41,7 @@ use journaldb;
|
|||||||
use trie::{TrieMut, Trie};
|
use trie::{TrieMut, Trie};
|
||||||
use ethtrie::{SecTrieDBMut, TrieDB, TrieDBMut};
|
use ethtrie::{SecTrieDBMut, TrieDB, TrieDBMut};
|
||||||
use self::trie_standardmap::{Alphabet, StandardMap, ValueMode};
|
use self::trie_standardmap::{Alphabet, StandardMap, ValueMode};
|
||||||
|
use types::errors::EthcoreError;
|
||||||
|
|
||||||
// the proportion of accounts we will alter each tick.
|
// the proportion of accounts we will alter each tick.
|
||||||
const ACCOUNT_CHURN: f32 = 0.01;
|
const ACCOUNT_CHURN: f32 = 0.01;
|
||||||
@ -155,7 +156,7 @@ pub fn restore(
|
|||||||
engine: &dyn Engine,
|
engine: &dyn Engine,
|
||||||
reader: &dyn SnapshotReader,
|
reader: &dyn SnapshotReader,
|
||||||
genesis: &[u8],
|
genesis: &[u8],
|
||||||
) -> Result<(), ::error::Error> {
|
) -> Result<(), EthcoreError> {
|
||||||
use std::sync::atomic::AtomicBool;
|
use std::sync::atomic::AtomicBool;
|
||||||
|
|
||||||
let flag = AtomicBool::new(true);
|
let flag = AtomicBool::new(true);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
use std::sync::atomic::AtomicBool;
|
use std::sync::atomic::AtomicBool;
|
||||||
use tempdir::TempDir;
|
use tempdir::TempDir;
|
||||||
use error::Error;
|
use types::errors::EthcoreError as Error;
|
||||||
|
|
||||||
use blockchain::generator::{BlockGenerator, BlockBuilder};
|
use blockchain::generator::{BlockGenerator, BlockBuilder};
|
||||||
use blockchain::{BlockChain, ExtrasInsert};
|
use blockchain::{BlockChain, ExtrasInsert};
|
||||||
|
@ -21,7 +21,8 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use tempdir::TempDir;
|
use tempdir::TempDir;
|
||||||
use blockchain::BlockProvider;
|
use blockchain::BlockProvider;
|
||||||
use client::{Client, ClientConfig, ImportBlock, BlockInfo};
|
use client::{Client, ClientConfig, ImportBlock};
|
||||||
|
use client::BlockInfo;
|
||||||
use types::ids::BlockId;
|
use types::ids::BlockId;
|
||||||
use snapshot::io::{PackedReader, PackedWriter, SnapshotReader, SnapshotWriter};
|
use snapshot::io::{PackedReader, PackedWriter, SnapshotReader, SnapshotWriter};
|
||||||
use snapshot::service::{Service, ServiceParams};
|
use snapshot::service::{Service, ServiceParams};
|
||||||
|
@ -20,14 +20,14 @@ use std::sync::Arc;
|
|||||||
use std::sync::atomic::AtomicBool;
|
use std::sync::atomic::AtomicBool;
|
||||||
use hash::{KECCAK_NULL_RLP, keccak};
|
use hash::{KECCAK_NULL_RLP, keccak};
|
||||||
|
|
||||||
use types::basic_account::BasicAccount;
|
use types::{
|
||||||
|
basic_account::BasicAccount,
|
||||||
|
errors::EthcoreError as Error,
|
||||||
|
};
|
||||||
use snapshot::account;
|
use snapshot::account;
|
||||||
use snapshot::{chunk_state, Error as SnapshotError, Progress, StateRebuilder, SNAPSHOT_SUBPARTS};
|
use snapshot::{chunk_state, Error as SnapshotError, Progress, StateRebuilder, SNAPSHOT_SUBPARTS};
|
||||||
use snapshot::io::{PackedReader, PackedWriter, SnapshotReader, SnapshotWriter};
|
use snapshot::io::{PackedReader, PackedWriter, SnapshotReader, SnapshotWriter};
|
||||||
use super::helpers::StateProducer;
|
use super::helpers::StateProducer;
|
||||||
|
|
||||||
use error::Error;
|
|
||||||
|
|
||||||
use rand::SeedableRng;
|
use rand::SeedableRng;
|
||||||
use rand_xorshift::XorShiftRng;
|
use rand_xorshift::XorShiftRng;
|
||||||
use ethereum_types::H256;
|
use ethereum_types::H256;
|
||||||
|
@ -21,4 +21,4 @@ mod seal;
|
|||||||
mod spec;
|
mod spec;
|
||||||
|
|
||||||
pub use self::genesis::Genesis;
|
pub use self::genesis::Genesis;
|
||||||
pub use self::spec::{Spec, SpecHardcodedSync, SpecParams, CommonParams, OptimizeFor};
|
pub use self::spec::{Spec, SpecHardcodedSync, SpecParams, OptimizeFor};
|
||||||
|
@ -28,17 +28,20 @@ use hash::{KECCAK_NULL_RLP, keccak};
|
|||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use rlp::{Rlp, RlpStream};
|
use rlp::{Rlp, RlpStream};
|
||||||
use rustc_hex::{FromHex, ToHex};
|
use rustc_hex::{FromHex, ToHex};
|
||||||
use types::BlockNumber;
|
use types::{
|
||||||
use types::encoded;
|
BlockNumber,
|
||||||
use types::header::Header;
|
header::Header,
|
||||||
use vm::{EnvInfo, CallType, ActionValue, ActionParams, ParamsType, VersionedSchedule};
|
encoded,
|
||||||
|
engines::params::CommonParams,
|
||||||
|
errors::EthcoreError as Error,
|
||||||
|
};
|
||||||
|
use vm::{EnvInfo, CallType, ActionValue, ActionParams, ParamsType};
|
||||||
|
|
||||||
use builtin::Builtin;
|
use builtin::Builtin;
|
||||||
use engines::{
|
use engines::{
|
||||||
Engine, NullEngine, InstantSeal, InstantSealParams, BasicAuthority, Clique,
|
Engine, NullEngine, InstantSeal, InstantSealParams, BasicAuthority, Clique,
|
||||||
AuthorityRound, DEFAULT_BLOCKHASH_CONTRACT
|
AuthorityRound, Ethash,
|
||||||
};
|
};
|
||||||
use error::Error;
|
|
||||||
use executive::Executive;
|
use executive::Executive;
|
||||||
use trie_vm_factories::Factories;
|
use trie_vm_factories::Factories;
|
||||||
use machine::Machine;
|
use machine::Machine;
|
||||||
@ -51,301 +54,11 @@ use trace::{NoopTracer, NoopVMTracer};
|
|||||||
|
|
||||||
pub use ethash::OptimizeFor;
|
pub use ethash::OptimizeFor;
|
||||||
|
|
||||||
const MAX_TRANSACTION_SIZE: usize = 300 * 1024;
|
|
||||||
|
|
||||||
// helper for formatting errors.
|
// helper for formatting errors.
|
||||||
fn fmt_err<F: ::std::fmt::Display>(f: F) -> String {
|
fn fmt_err<F: ::std::fmt::Display>(f: F) -> String {
|
||||||
format!("Spec json is invalid: {}", f)
|
format!("Spec json is invalid: {}", f)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parameters common to ethereum-like blockchains.
|
|
||||||
/// NOTE: when adding bugfix hard-fork parameters,
|
|
||||||
/// add to `nonzero_bugfix_hard_fork`
|
|
||||||
///
|
|
||||||
/// we define a "bugfix" hard fork as any hard fork which
|
|
||||||
/// you would put on-by-default in a new chain.
|
|
||||||
#[derive(Debug, PartialEq, Default)]
|
|
||||||
#[cfg_attr(test, derive(Clone))]
|
|
||||||
pub struct CommonParams {
|
|
||||||
/// Account start nonce.
|
|
||||||
pub account_start_nonce: U256,
|
|
||||||
/// Maximum size of extra data.
|
|
||||||
pub maximum_extra_data_size: usize,
|
|
||||||
/// Network id.
|
|
||||||
pub network_id: u64,
|
|
||||||
/// Chain id.
|
|
||||||
pub chain_id: u64,
|
|
||||||
/// Main subprotocol name.
|
|
||||||
pub subprotocol_name: String,
|
|
||||||
/// Minimum gas limit.
|
|
||||||
pub min_gas_limit: U256,
|
|
||||||
/// Fork block to check.
|
|
||||||
pub fork_block: Option<(BlockNumber, H256)>,
|
|
||||||
/// EIP150 transition block number.
|
|
||||||
pub eip150_transition: BlockNumber,
|
|
||||||
/// Number of first block where EIP-160 rules begin.
|
|
||||||
pub eip160_transition: BlockNumber,
|
|
||||||
/// Number of first block where EIP-161.abc begin.
|
|
||||||
pub eip161abc_transition: BlockNumber,
|
|
||||||
/// Number of first block where EIP-161.d begins.
|
|
||||||
pub eip161d_transition: BlockNumber,
|
|
||||||
/// Number of first block where EIP-98 rules begin.
|
|
||||||
pub eip98_transition: BlockNumber,
|
|
||||||
/// Number of first block where EIP-658 rules begin.
|
|
||||||
pub eip658_transition: BlockNumber,
|
|
||||||
/// Number of first block where EIP-155 rules begin.
|
|
||||||
pub eip155_transition: BlockNumber,
|
|
||||||
/// Validate block receipts root.
|
|
||||||
pub validate_receipts_transition: BlockNumber,
|
|
||||||
/// Validate transaction chain id.
|
|
||||||
pub validate_chain_id_transition: BlockNumber,
|
|
||||||
/// Number of first block where EIP-140 rules begin.
|
|
||||||
pub eip140_transition: BlockNumber,
|
|
||||||
/// Number of first block where EIP-210 rules begin.
|
|
||||||
pub eip210_transition: BlockNumber,
|
|
||||||
/// EIP-210 Blockhash contract address.
|
|
||||||
pub eip210_contract_address: Address,
|
|
||||||
/// EIP-210 Blockhash contract code.
|
|
||||||
pub eip210_contract_code: Bytes,
|
|
||||||
/// Gas allocated for EIP-210 blockhash update.
|
|
||||||
pub eip210_contract_gas: U256,
|
|
||||||
/// Number of first block where EIP-211 rules begin.
|
|
||||||
pub eip211_transition: BlockNumber,
|
|
||||||
/// Number of first block where EIP-214 rules begin.
|
|
||||||
pub eip214_transition: BlockNumber,
|
|
||||||
/// Number of first block where EIP-145 rules begin.
|
|
||||||
pub eip145_transition: BlockNumber,
|
|
||||||
/// Number of first block where EIP-1052 rules begin.
|
|
||||||
pub eip1052_transition: BlockNumber,
|
|
||||||
/// Number of first block where EIP-1283 rules begin.
|
|
||||||
pub eip1283_transition: BlockNumber,
|
|
||||||
/// Number of first block where EIP-1283 rules end.
|
|
||||||
pub eip1283_disable_transition: BlockNumber,
|
|
||||||
/// Number of first block where EIP-1014 rules begin.
|
|
||||||
pub eip1014_transition: BlockNumber,
|
|
||||||
/// Number of first block where dust cleanup rules (EIP-168 and EIP169) begin.
|
|
||||||
pub dust_protection_transition: BlockNumber,
|
|
||||||
/// Nonce cap increase per block. Nonce cap is only checked if dust protection is enabled.
|
|
||||||
pub nonce_cap_increment: u64,
|
|
||||||
/// Enable dust cleanup for contracts.
|
|
||||||
pub remove_dust_contracts: bool,
|
|
||||||
/// Wasm activation blocknumber, if any disabled initially.
|
|
||||||
pub wasm_activation_transition: BlockNumber,
|
|
||||||
/// Wasm account version, activated after `wasm_activation_transition`. If this field is defined, do not use code
|
|
||||||
/// prefix to determine VM to execute.
|
|
||||||
pub wasm_version: Option<U256>,
|
|
||||||
/// Number of first block where KIP-4 rules begin. Only has effect if Wasm is activated.
|
|
||||||
pub kip4_transition: BlockNumber,
|
|
||||||
/// Number of first block where KIP-6 rules begin. Only has effect if Wasm is activated.
|
|
||||||
pub kip6_transition: BlockNumber,
|
|
||||||
/// Gas limit bound divisor (how much gas limit can change per block)
|
|
||||||
pub gas_limit_bound_divisor: U256,
|
|
||||||
/// Registrar contract address.
|
|
||||||
pub registrar: Option<Address>,
|
|
||||||
/// Node permission managing contract address.
|
|
||||||
pub node_permission_contract: Option<Address>,
|
|
||||||
/// Maximum contract code size that can be deployed.
|
|
||||||
pub max_code_size: u64,
|
|
||||||
/// Number of first block where max code size limit is active.
|
|
||||||
pub max_code_size_transition: BlockNumber,
|
|
||||||
/// Transaction permission managing contract address.
|
|
||||||
pub transaction_permission_contract: Option<Address>,
|
|
||||||
/// Block at which the transaction permission contract should start being used.
|
|
||||||
pub transaction_permission_contract_transition: BlockNumber,
|
|
||||||
/// Maximum size of transaction's RLP payload
|
|
||||||
pub max_transaction_size: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CommonParams {
|
|
||||||
/// Schedule for an EVM in the post-EIP-150-era of the Ethereum main net.
|
|
||||||
pub fn schedule(&self, block_number: u64) -> ::vm::Schedule {
|
|
||||||
if block_number < self.eip150_transition {
|
|
||||||
::vm::Schedule::new_homestead()
|
|
||||||
} else {
|
|
||||||
let max_code_size = self.max_code_size(block_number);
|
|
||||||
let mut schedule = ::vm::Schedule::new_post_eip150(
|
|
||||||
max_code_size as _,
|
|
||||||
block_number >= self.eip160_transition,
|
|
||||||
block_number >= self.eip161abc_transition,
|
|
||||||
block_number >= self.eip161d_transition
|
|
||||||
);
|
|
||||||
|
|
||||||
self.update_schedule(block_number, &mut schedule);
|
|
||||||
schedule
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns max code size at given block.
|
|
||||||
pub fn max_code_size(&self, block_number: u64) -> u64 {
|
|
||||||
if block_number >= self.max_code_size_transition {
|
|
||||||
self.max_code_size
|
|
||||||
} else {
|
|
||||||
u64::max_value()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Apply common spec config parameters to the schedule.
|
|
||||||
pub fn update_schedule(&self, block_number: u64, schedule: &mut ::vm::Schedule) {
|
|
||||||
schedule.have_create2 = block_number >= self.eip1014_transition;
|
|
||||||
schedule.have_revert = block_number >= self.eip140_transition;
|
|
||||||
schedule.have_static_call = block_number >= self.eip214_transition;
|
|
||||||
schedule.have_return_data = block_number >= self.eip211_transition;
|
|
||||||
schedule.have_bitwise_shifting = block_number >= self.eip145_transition;
|
|
||||||
schedule.have_extcodehash = block_number >= self.eip1052_transition;
|
|
||||||
schedule.eip1283 = block_number >= self.eip1283_transition && !(block_number >= self.eip1283_disable_transition);
|
|
||||||
if block_number >= self.eip210_transition {
|
|
||||||
schedule.blockhash_gas = 800;
|
|
||||||
}
|
|
||||||
if block_number >= self.dust_protection_transition {
|
|
||||||
schedule.kill_dust = match self.remove_dust_contracts {
|
|
||||||
true => ::vm::CleanDustMode::WithCodeAndStorage,
|
|
||||||
false => ::vm::CleanDustMode::BasicOnly,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if block_number >= self.wasm_activation_transition {
|
|
||||||
let mut wasm = ::vm::WasmCosts::default();
|
|
||||||
if block_number >= self.kip4_transition {
|
|
||||||
wasm.have_create2 = true;
|
|
||||||
}
|
|
||||||
if block_number >= self.kip6_transition {
|
|
||||||
wasm.have_gasleft = true;
|
|
||||||
}
|
|
||||||
schedule.wasm = Some(wasm);
|
|
||||||
if let Some(version) = self.wasm_version {
|
|
||||||
schedule.versions.insert(version, VersionedSchedule::PWasm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return Some if the current parameters contain a bugfix hard fork not on block 0.
|
|
||||||
pub fn nonzero_bugfix_hard_fork(&self) -> Option<&str> {
|
|
||||||
if self.eip155_transition != 0 {
|
|
||||||
return Some("eip155Transition");
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.validate_receipts_transition != 0 {
|
|
||||||
return Some("validateReceiptsTransition");
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.validate_chain_id_transition != 0 {
|
|
||||||
return Some("validateChainIdTransition");
|
|
||||||
}
|
|
||||||
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<ethjson::spec::Params> for CommonParams {
|
|
||||||
fn from(p: ethjson::spec::Params) -> Self {
|
|
||||||
CommonParams {
|
|
||||||
account_start_nonce: p.account_start_nonce.map_or_else(U256::zero, Into::into),
|
|
||||||
maximum_extra_data_size: p.maximum_extra_data_size.into(),
|
|
||||||
network_id: p.network_id.into(),
|
|
||||||
chain_id: if let Some(n) = p.chain_id {
|
|
||||||
n.into()
|
|
||||||
} else {
|
|
||||||
p.network_id.into()
|
|
||||||
},
|
|
||||||
subprotocol_name: p.subprotocol_name.unwrap_or_else(|| "eth".to_owned()),
|
|
||||||
min_gas_limit: p.min_gas_limit.into(),
|
|
||||||
fork_block: if let (Some(n), Some(h)) = (p.fork_block, p.fork_hash) {
|
|
||||||
Some((n.into(), h.into()))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
},
|
|
||||||
eip150_transition: p.eip150_transition.map_or(0, Into::into),
|
|
||||||
eip160_transition: p.eip160_transition.map_or(0, Into::into),
|
|
||||||
eip161abc_transition: p.eip161abc_transition.map_or(0, Into::into),
|
|
||||||
eip161d_transition: p.eip161d_transition.map_or(0, Into::into),
|
|
||||||
eip98_transition: p.eip98_transition.map_or_else(
|
|
||||||
BlockNumber::max_value,
|
|
||||||
Into::into,
|
|
||||||
),
|
|
||||||
eip155_transition: p.eip155_transition.map_or(0, Into::into),
|
|
||||||
validate_receipts_transition: p.validate_receipts_transition.map_or(0, Into::into),
|
|
||||||
validate_chain_id_transition: p.validate_chain_id_transition.map_or(0, Into::into),
|
|
||||||
eip140_transition: p.eip140_transition.map_or_else(
|
|
||||||
BlockNumber::max_value,
|
|
||||||
Into::into,
|
|
||||||
),
|
|
||||||
eip210_transition: p.eip210_transition.map_or_else(
|
|
||||||
BlockNumber::max_value,
|
|
||||||
Into::into,
|
|
||||||
),
|
|
||||||
eip210_contract_address: p.eip210_contract_address.map_or(Address::from_low_u64_be(0xf0), Into::into),
|
|
||||||
eip210_contract_code: p.eip210_contract_code.map_or_else(
|
|
||||||
|| {
|
|
||||||
DEFAULT_BLOCKHASH_CONTRACT.from_hex().expect(
|
|
||||||
"Default BLOCKHASH contract is valid",
|
|
||||||
)
|
|
||||||
},
|
|
||||||
Into::into,
|
|
||||||
),
|
|
||||||
eip210_contract_gas: p.eip210_contract_gas.map_or(1000000.into(), Into::into),
|
|
||||||
eip211_transition: p.eip211_transition.map_or_else(
|
|
||||||
BlockNumber::max_value,
|
|
||||||
Into::into,
|
|
||||||
),
|
|
||||||
eip145_transition: p.eip145_transition.map_or_else(
|
|
||||||
BlockNumber::max_value,
|
|
||||||
Into::into,
|
|
||||||
),
|
|
||||||
eip214_transition: p.eip214_transition.map_or_else(
|
|
||||||
BlockNumber::max_value,
|
|
||||||
Into::into,
|
|
||||||
),
|
|
||||||
eip658_transition: p.eip658_transition.map_or_else(
|
|
||||||
BlockNumber::max_value,
|
|
||||||
Into::into,
|
|
||||||
),
|
|
||||||
eip1052_transition: p.eip1052_transition.map_or_else(
|
|
||||||
BlockNumber::max_value,
|
|
||||||
Into::into,
|
|
||||||
),
|
|
||||||
eip1283_transition: p.eip1283_transition.map_or_else(
|
|
||||||
BlockNumber::max_value,
|
|
||||||
Into::into,
|
|
||||||
),
|
|
||||||
eip1283_disable_transition: p.eip1283_disable_transition.map_or_else(
|
|
||||||
BlockNumber::max_value,
|
|
||||||
Into::into,
|
|
||||||
),
|
|
||||||
eip1014_transition: p.eip1014_transition.map_or_else(
|
|
||||||
BlockNumber::max_value,
|
|
||||||
Into::into,
|
|
||||||
),
|
|
||||||
dust_protection_transition: p.dust_protection_transition.map_or_else(
|
|
||||||
BlockNumber::max_value,
|
|
||||||
Into::into,
|
|
||||||
),
|
|
||||||
nonce_cap_increment: p.nonce_cap_increment.map_or(64, Into::into),
|
|
||||||
remove_dust_contracts: p.remove_dust_contracts.unwrap_or(false),
|
|
||||||
gas_limit_bound_divisor: p.gas_limit_bound_divisor.into(),
|
|
||||||
registrar: p.registrar.map(Into::into),
|
|
||||||
node_permission_contract: p.node_permission_contract.map(Into::into),
|
|
||||||
max_code_size: p.max_code_size.map_or(u64::max_value(), Into::into),
|
|
||||||
max_transaction_size: p.max_transaction_size.map_or(MAX_TRANSACTION_SIZE, Into::into),
|
|
||||||
max_code_size_transition: p.max_code_size_transition.map_or(0, Into::into),
|
|
||||||
transaction_permission_contract: p.transaction_permission_contract.map(Into::into),
|
|
||||||
transaction_permission_contract_transition:
|
|
||||||
p.transaction_permission_contract_transition.map_or(0, Into::into),
|
|
||||||
wasm_activation_transition: p.wasm_activation_transition.map_or_else(
|
|
||||||
BlockNumber::max_value,
|
|
||||||
Into::into
|
|
||||||
),
|
|
||||||
wasm_version: p.wasm_version.map(Into::into),
|
|
||||||
kip4_transition: p.kip4_transition.map_or_else(
|
|
||||||
BlockNumber::max_value,
|
|
||||||
Into::into
|
|
||||||
),
|
|
||||||
kip6_transition: p.kip6_transition.map_or_else(
|
|
||||||
BlockNumber::max_value,
|
|
||||||
Into::into
|
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Runtime parameters for the spec that are related to how the software should run the chain,
|
/// Runtime parameters for the spec that are related to how the software should run the chain,
|
||||||
/// rather than integral properties of the chain itself.
|
/// rather than integral properties of the chain itself.
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
@ -613,7 +326,7 @@ impl Spec {
|
|||||||
|
|
||||||
match engine_spec {
|
match engine_spec {
|
||||||
ethjson::spec::Engine::Null(null) => Arc::new(NullEngine::new(null.params.into(), machine)),
|
ethjson::spec::Engine::Null(null) => Arc::new(NullEngine::new(null.params.into(), machine)),
|
||||||
ethjson::spec::Engine::Ethash(ethash) => Arc::new(::ethereum::Ethash::new(spec_params.cache_dir, ethash.params.into(), machine, spec_params.optimization_setting)),
|
ethjson::spec::Engine::Ethash(ethash) => Arc::new(Ethash::new(spec_params.cache_dir, ethash.params.into(), machine, spec_params.optimization_setting)),
|
||||||
ethjson::spec::Engine::InstantSeal(Some(instant_seal)) => Arc::new(InstantSeal::new(instant_seal.params.into(), machine)),
|
ethjson::spec::Engine::InstantSeal(Some(instant_seal)) => Arc::new(InstantSeal::new(instant_seal.params.into(), machine)),
|
||||||
ethjson::spec::Engine::InstantSeal(None) => Arc::new(InstantSeal::new(InstantSealParams::default(), machine)),
|
ethjson::spec::Engine::InstantSeal(None) => Arc::new(InstantSeal::new(InstantSealParams::default(), machine)),
|
||||||
ethjson::spec::Engine::BasicAuthority(basic_authority) => Arc::new(BasicAuthority::new(basic_authority.params.into(), machine)),
|
ethjson::spec::Engine::BasicAuthority(basic_authority) => Arc::new(BasicAuthority::new(basic_authority.params.into(), machine)),
|
||||||
|
@ -27,7 +27,8 @@ use types::filter::Filter;
|
|||||||
use types::view;
|
use types::view;
|
||||||
use types::views::BlockView;
|
use types::views::BlockView;
|
||||||
|
|
||||||
use client::{BlockChainClient, BlockChainReset, Client, ClientConfig, BlockId, ChainInfo, BlockInfo, PrepareOpenBlock, ImportSealedBlock, ImportBlock};
|
use client::{BlockChainClient, BlockChainReset, Client, ClientConfig, BlockId, ChainInfo, PrepareOpenBlock, ImportSealedBlock, ImportBlock};
|
||||||
|
use client::BlockInfo;
|
||||||
use ethereum;
|
use ethereum;
|
||||||
use executive::{Executive, TransactOptions};
|
use executive::{Executive, TransactOptions};
|
||||||
use miner::{Miner, PendingOrdering, MinerService};
|
use miner::{Miner, PendingOrdering, MinerService};
|
||||||
|
@ -21,11 +21,13 @@ use lru_cache::LruCache;
|
|||||||
use ethabi::FunctionOutputDecoder;
|
use ethabi::FunctionOutputDecoder;
|
||||||
|
|
||||||
use call_contract::CallContract;
|
use call_contract::CallContract;
|
||||||
use client::{BlockInfo, BlockId};
|
use client::{BlockId, BlockInfo};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use spec::CommonParams;
|
use types::{
|
||||||
use types::transaction::{Action, SignedTransaction};
|
BlockNumber,
|
||||||
use types::BlockNumber;
|
engines::params::CommonParams,
|
||||||
|
transaction::{Action, SignedTransaction}
|
||||||
|
};
|
||||||
use hash::KECCAK_EMPTY;
|
use hash::KECCAK_EMPTY;
|
||||||
|
|
||||||
use_contract!(transact_acl_deprecated, "res/contracts/tx_acl_deprecated.json");
|
use_contract!(transact_acl_deprecated, "res/contracts/tx_acl_deprecated.json");
|
||||||
|
@ -19,12 +19,14 @@
|
|||||||
use call_contract::CallContract;
|
use call_contract::CallContract;
|
||||||
use client::BlockInfo;
|
use client::BlockInfo;
|
||||||
use engines::Engine;
|
use engines::Engine;
|
||||||
use error::Error;
|
use types::{
|
||||||
use types::header::Header;
|
header::Header,
|
||||||
|
errors::EthcoreError as Error,
|
||||||
|
};
|
||||||
use super::Verifier;
|
use super::Verifier;
|
||||||
use super::verification;
|
use super::verification;
|
||||||
|
|
||||||
/// A canonial verifier -- this does full verification.
|
/// A canonical verifier -- this does full verification.
|
||||||
pub struct CanonVerifier;
|
pub struct CanonVerifier;
|
||||||
|
|
||||||
impl<C: BlockInfo + CallContract> Verifier<C> for CanonVerifier {
|
impl<C: BlockInfo + CallContract> Verifier<C> for CanonVerifier {
|
||||||
|
@ -36,7 +36,7 @@ use client::BlockInfo;
|
|||||||
pub enum VerifierType {
|
pub enum VerifierType {
|
||||||
/// Verifies block normally.
|
/// Verifies block normally.
|
||||||
Canon,
|
Canon,
|
||||||
/// Verifies block normallly, but skips seal verification.
|
/// Verifies block normally, but skips seal verification.
|
||||||
CanonNoSeal,
|
CanonNoSeal,
|
||||||
/// Does not verify block at all.
|
/// Does not verify block at all.
|
||||||
/// Used in tests.
|
/// Used in tests.
|
||||||
|
@ -19,8 +19,10 @@
|
|||||||
use call_contract::CallContract;
|
use call_contract::CallContract;
|
||||||
use client::BlockInfo;
|
use client::BlockInfo;
|
||||||
use engines::Engine;
|
use engines::Engine;
|
||||||
use error::Error;
|
use types::{
|
||||||
use types::header::Header;
|
header::Header,
|
||||||
|
errors::EthcoreError as Error
|
||||||
|
};
|
||||||
use super::{verification, Verifier};
|
use super::{verification, Verifier};
|
||||||
|
|
||||||
/// A no-op verifier -- this will verify everything it's given immediately.
|
/// A no-op verifier -- this will verify everything it's given immediately.
|
||||||
|
@ -17,11 +17,14 @@
|
|||||||
//! Definition of valid items for the verification queue.
|
//! Definition of valid items for the verification queue.
|
||||||
|
|
||||||
use engines::Engine;
|
use engines::Engine;
|
||||||
use error::Error;
|
|
||||||
|
|
||||||
use parity_util_mem::MallocSizeOf;
|
use parity_util_mem::MallocSizeOf;
|
||||||
use ethereum_types::{H256, U256};
|
use ethereum_types::{H256, U256};
|
||||||
|
|
||||||
|
use types::{
|
||||||
|
errors::EthcoreError as Error,
|
||||||
|
};
|
||||||
|
|
||||||
pub use self::blocks::Blocks;
|
pub use self::blocks::Blocks;
|
||||||
pub use self::headers::Headers;
|
pub use self::headers::Headers;
|
||||||
|
|
||||||
@ -69,10 +72,13 @@ pub mod blocks {
|
|||||||
use super::{Kind, BlockLike};
|
use super::{Kind, BlockLike};
|
||||||
|
|
||||||
use engines::Engine;
|
use engines::Engine;
|
||||||
use error::{Error, BlockError};
|
use types::{
|
||||||
use types::header::Header;
|
block::PreverifiedBlock,
|
||||||
use verification::{PreverifiedBlock, verify_block_basic, verify_block_unordered};
|
header::Header,
|
||||||
use types::transaction::UnverifiedTransaction;
|
errors::{EthcoreError as Error, BlockError},
|
||||||
|
transaction::UnverifiedTransaction
|
||||||
|
};
|
||||||
|
use verification::{verify_block_basic, verify_block_unordered};
|
||||||
|
|
||||||
use parity_util_mem::MallocSizeOf;
|
use parity_util_mem::MallocSizeOf;
|
||||||
use ethereum_types::{H256, U256};
|
use ethereum_types::{H256, U256};
|
||||||
@ -180,8 +186,10 @@ pub mod headers {
|
|||||||
use super::{Kind, BlockLike};
|
use super::{Kind, BlockLike};
|
||||||
|
|
||||||
use engines::Engine;
|
use engines::Engine;
|
||||||
use error::Error;
|
use types::{
|
||||||
use types::header::Header;
|
header::Header,
|
||||||
|
errors::EthcoreError as Error,
|
||||||
|
};
|
||||||
use verification::verify_header_params;
|
use verification::verify_header_params;
|
||||||
|
|
||||||
use ethereum_types::{H256, U256};
|
use ethereum_types::{H256, U256};
|
||||||
|
@ -26,10 +26,10 @@ use parity_util_mem::{MallocSizeOf, MallocSizeOfExt};
|
|||||||
use ethereum_types::{H256, U256};
|
use ethereum_types::{H256, U256};
|
||||||
use parking_lot::{Condvar, Mutex, RwLock};
|
use parking_lot::{Condvar, Mutex, RwLock};
|
||||||
use io::*;
|
use io::*;
|
||||||
use error::{BlockError, ImportError, Error};
|
|
||||||
use engines::Engine;
|
use engines::Engine;
|
||||||
use client::ClientIoMessage;
|
use client::ClientIoMessage;
|
||||||
use len_caching_lock::LenCachingMutex;
|
use len_caching_lock::LenCachingMutex;
|
||||||
|
use types::errors::{BlockError, EthcoreError as Error, ImportError};
|
||||||
|
|
||||||
use self::kind::{BlockLike, Kind};
|
use self::kind::{BlockLike, Kind};
|
||||||
|
|
||||||
@ -738,10 +738,12 @@ mod tests {
|
|||||||
use super::{BlockQueue, Config, State};
|
use super::{BlockQueue, Config, State};
|
||||||
use super::kind::blocks::Unverified;
|
use super::kind::blocks::Unverified;
|
||||||
use test_helpers::{get_good_dummy_block_seq, get_good_dummy_block};
|
use test_helpers::{get_good_dummy_block_seq, get_good_dummy_block};
|
||||||
use error::*;
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use types::view;
|
use types::{
|
||||||
use types::views::BlockView;
|
view,
|
||||||
|
views::BlockView,
|
||||||
|
errors::{EthcoreError, ImportError},
|
||||||
|
};
|
||||||
|
|
||||||
// create a test block queue.
|
// create a test block queue.
|
||||||
// auto_scaling enables verifier adjustment.
|
// auto_scaling enables verifier adjustment.
|
||||||
@ -792,7 +794,7 @@ mod tests {
|
|||||||
match duplicate_import {
|
match duplicate_import {
|
||||||
Err((_, e)) => {
|
Err((_, e)) => {
|
||||||
match e {
|
match e {
|
||||||
Error::Import(ImportError::AlreadyQueued) => {},
|
EthcoreError::Import(ImportError::AlreadyQueued) => {},
|
||||||
_ => { panic!("must return AlreadyQueued error"); }
|
_ => { panic!("must return AlreadyQueued error"); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,7 @@
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
use bytes::Bytes;
|
|
||||||
use hash::keccak;
|
use hash::keccak;
|
||||||
use parity_util_mem::MallocSizeOf;
|
|
||||||
use rlp::Rlp;
|
use rlp::Rlp;
|
||||||
use triehash::ordered_trie_root;
|
use triehash::ordered_trie_root;
|
||||||
use unexpected::{Mismatch, OutOfBounds};
|
use unexpected::{Mismatch, OutOfBounds};
|
||||||
@ -34,27 +32,18 @@ use unexpected::{Mismatch, OutOfBounds};
|
|||||||
use blockchain::*;
|
use blockchain::*;
|
||||||
use call_contract::CallContract;
|
use call_contract::CallContract;
|
||||||
use client::BlockInfo;
|
use client::BlockInfo;
|
||||||
use engines::{Engine, MAX_UNCLE_AGE};
|
use engines::Engine;
|
||||||
use error::{BlockError, Error};
|
use types::{
|
||||||
use types::{BlockNumber, header::Header};
|
BlockNumber,
|
||||||
use types::transaction::SignedTransaction;
|
header::Header,
|
||||||
|
errors::{EthcoreError as Error, BlockError},
|
||||||
|
engines::MAX_UNCLE_AGE,
|
||||||
|
block::PreverifiedBlock,
|
||||||
|
};
|
||||||
use verification::queue::kind::blocks::Unverified;
|
use verification::queue::kind::blocks::Unverified;
|
||||||
|
|
||||||
use time_utils::CheckedSystemTime;
|
use time_utils::CheckedSystemTime;
|
||||||
|
|
||||||
/// Preprocessed block data gathered in `verify_block_unordered` call
|
|
||||||
#[derive(MallocSizeOf)]
|
|
||||||
pub struct PreverifiedBlock {
|
|
||||||
/// Populated block header
|
|
||||||
pub header: Header,
|
|
||||||
/// Populated block transactions
|
|
||||||
pub transactions: Vec<SignedTransaction>,
|
|
||||||
/// Populated block uncles
|
|
||||||
pub uncles: Vec<Header>,
|
|
||||||
/// Block bytes
|
|
||||||
pub bytes: Bytes,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Phase 1 quick block verification. Only does checks that are cheap. Operates on a single block
|
/// Phase 1 quick block verification. Only does checks that are cheap. Operates on a single block
|
||||||
pub fn verify_block_basic(block: &Unverified, engine: &dyn Engine, check_seal: bool) -> Result<(), Error> {
|
pub fn verify_block_basic(block: &Unverified, engine: &dyn Engine, check_seal: bool) -> Result<(), Error> {
|
||||||
verify_header_params(&block.header, engine, true, check_seal)?;
|
verify_header_params(&block.header, engine, true, check_seal)?;
|
||||||
@ -281,7 +270,7 @@ pub fn verify_header_params(header: &Header, engine: &dyn Engine, is_full: bool,
|
|||||||
}
|
}
|
||||||
if let Some(limit) = engine.maximum_gas_limit() {
|
if let Some(limit) = engine.maximum_gas_limit() {
|
||||||
if header.gas_limit() > &limit {
|
if header.gas_limit() > &limit {
|
||||||
return Err(From::from(::error::BlockError::InvalidGasLimit(OutOfBounds { min: None, max: Some(limit), found: *header.gas_limit() })));
|
return Err(From::from(BlockError::InvalidGasLimit(OutOfBounds { min: None, max: Some(limit), found: *header.gas_limit() })));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let maximum_extra_data_size = engine.maximum_extra_data_size();
|
let maximum_extra_data_size = engine.maximum_extra_data_size();
|
||||||
@ -379,15 +368,19 @@ mod tests {
|
|||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
use ethereum_types::{H256, BloomRef, U256, Address};
|
use ethereum_types::{H256, BloomRef, U256, Address};
|
||||||
use blockchain::{BlockDetails, TransactionAddress, BlockReceipts};
|
use blockchain::{BlockDetails, TransactionAddress, BlockReceipts};
|
||||||
use types::encoded;
|
use bytes::Bytes;
|
||||||
use hash::keccak;
|
use hash::keccak;
|
||||||
use engines::Engine;
|
use engines::Engine;
|
||||||
use error::BlockError::*;
|
|
||||||
use ethkey::{Random, Generator};
|
use ethkey::{Random, Generator};
|
||||||
use spec::{CommonParams, Spec};
|
use spec::Spec;
|
||||||
use test_helpers::{create_test_block_with_data, create_test_block};
|
use test_helpers::{create_test_block_with_data, create_test_block};
|
||||||
use types::transaction::{SignedTransaction, Transaction, UnverifiedTransaction, Action};
|
use types::{
|
||||||
use types::log_entry::{LogEntry, LocalizedLogEntry};
|
encoded,
|
||||||
|
engines::params::CommonParams,
|
||||||
|
errors::BlockError::*,
|
||||||
|
transaction::{SignedTransaction, Transaction, UnverifiedTransaction, Action},
|
||||||
|
log_entry::{LogEntry, LocalizedLogEntry},
|
||||||
|
};
|
||||||
use rlp;
|
use rlp;
|
||||||
use triehash::ordered_trie_root;
|
use triehash::ordered_trie_root;
|
||||||
|
|
||||||
|
@ -19,8 +19,10 @@
|
|||||||
use call_contract::CallContract;
|
use call_contract::CallContract;
|
||||||
use client::BlockInfo;
|
use client::BlockInfo;
|
||||||
use engines::Engine;
|
use engines::Engine;
|
||||||
use error::Error;
|
use types::{
|
||||||
use types::header::Header;
|
header::Header,
|
||||||
|
errors::EthcoreError as Error,
|
||||||
|
};
|
||||||
use super::verification;
|
use super::verification;
|
||||||
|
|
||||||
/// Should be used to verify blocks.
|
/// Should be used to verify blocks.
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
description = "State database"
|
|
||||||
name = "state-db"
|
name = "state-db"
|
||||||
version = "0.1.0"
|
description = "State database"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -23,9 +23,11 @@ use std::cmp;
|
|||||||
use parity_util_mem::MallocSizeOf;
|
use parity_util_mem::MallocSizeOf;
|
||||||
use ethereum_types::H256;
|
use ethereum_types::H256;
|
||||||
use rlp::{self, Rlp};
|
use rlp::{self, Rlp};
|
||||||
use types::BlockNumber;
|
use types::{
|
||||||
|
BlockNumber,
|
||||||
|
errors::{EthcoreError, BlockError, ImportError},
|
||||||
|
};
|
||||||
use ethcore::client::{BlockStatus, BlockId};
|
use ethcore::client::{BlockStatus, BlockId};
|
||||||
use ethcore::error::{ImportError, BlockError, Error as EthcoreError};
|
|
||||||
use sync_io::SyncIo;
|
use sync_io::SyncIo;
|
||||||
use blocks::{BlockCollection, SyncBody, SyncHeader};
|
use blocks::{BlockCollection, SyncBody, SyncHeader};
|
||||||
use chain::BlockSet;
|
use chain::BlockSet;
|
||||||
|
@ -18,7 +18,6 @@ use api::WARP_SYNC_PROTOCOL_ID;
|
|||||||
use block_sync::{BlockDownloaderImportError as DownloaderImportError, DownloadAction};
|
use block_sync::{BlockDownloaderImportError as DownloaderImportError, DownloadAction};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use enum_primitive::FromPrimitive;
|
use enum_primitive::FromPrimitive;
|
||||||
use ethcore::error::{Error as EthcoreError, ImportError, BlockError};
|
|
||||||
use ethcore::snapshot::{ManifestData, RestorationStatus};
|
use ethcore::snapshot::{ManifestData, RestorationStatus};
|
||||||
use ethcore::verification::queue::kind::blocks::Unverified;
|
use ethcore::verification::queue::kind::blocks::Unverified;
|
||||||
use ethereum_types::{H256, U256};
|
use ethereum_types::{H256, U256};
|
||||||
@ -30,9 +29,12 @@ use snapshot::ChunkType;
|
|||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use std::{mem, cmp};
|
use std::{mem, cmp};
|
||||||
use sync_io::SyncIo;
|
use sync_io::SyncIo;
|
||||||
use types::BlockNumber;
|
use types::{
|
||||||
use types::block_status::BlockStatus;
|
BlockNumber,
|
||||||
use types::ids::BlockId;
|
block_status::BlockStatus,
|
||||||
|
ids::BlockId,
|
||||||
|
errors::{EthcoreError, ImportError, BlockError},
|
||||||
|
};
|
||||||
|
|
||||||
use super::sync_packet::{PacketInfo, SyncPacket};
|
use super::sync_packet::{PacketInfo, SyncPacket};
|
||||||
use super::sync_packet::SyncPacket::{
|
use super::sync_packet::SyncPacket::{
|
||||||
|
@ -493,7 +493,7 @@ impl<L: AsLightClient> LightSync<L> {
|
|||||||
|
|
||||||
// handles request dispatch, block import, state machine transitions, and timeouts.
|
// handles request dispatch, block import, state machine transitions, and timeouts.
|
||||||
fn maintain_sync(&self, ctx: &dyn BasicContext) {
|
fn maintain_sync(&self, ctx: &dyn BasicContext) {
|
||||||
use ethcore::error::{Error as EthcoreError, ImportError};
|
use types::errors::{EthcoreError, ImportError};
|
||||||
|
|
||||||
const DRAIN_AMOUNT: usize = 128;
|
const DRAIN_AMOUNT: usize = 128;
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
description = "Transaction tracing"
|
|
||||||
name = "trace"
|
name = "trace"
|
||||||
|
description = "Transaction tracing"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
|
license = "GPL-3.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -5,15 +5,21 @@ version = "0.1.0"
|
|||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
derive_more = "0.15.0"
|
||||||
|
ethbloom = "0.6"
|
||||||
|
ethcore-io = { path = "../../util/io" }
|
||||||
ethereum-types = "0.6.0"
|
ethereum-types = "0.6.0"
|
||||||
ethjson = { path = "../../json" }
|
ethjson = { path = "../../json" }
|
||||||
parity-util-mem = "0.1"
|
|
||||||
ethkey = { path = "../../accounts/ethkey" }
|
ethkey = { path = "../../accounts/ethkey" }
|
||||||
keccak-hash = "0.2.0"
|
keccak-hash = "0.2.0"
|
||||||
parity-bytes = "0.1"
|
parity-bytes = "0.1"
|
||||||
|
parity-util-mem = "0.1"
|
||||||
|
parity-snappy = "0.1"
|
||||||
|
patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" }
|
||||||
rlp = "0.4.0"
|
rlp = "0.4.0"
|
||||||
rlp_derive = { path = "../../util/rlp-derive" }
|
rlp_derive = { path = "../../util/rlp-derive" }
|
||||||
unexpected = { path = "../../util/unexpected" }
|
unexpected = { path = "../../util/unexpected" }
|
||||||
|
vm = { path = "../vm"}
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
rustc-hex= "1.0"
|
rustc-hex= "1.0" # todo: only needed for CommonParams to do from_hex on a const. Remove?
|
||||||
|
@ -18,24 +18,14 @@
|
|||||||
//!
|
//!
|
||||||
//! Blocks can be produced by a local node or they may be received from the network.
|
//! Blocks can be produced by a local node or they may be received from the network.
|
||||||
//!
|
//!
|
||||||
//! To create a block locally, we start with an `OpenBlock`. This block is mutable
|
//! Other block types are found in `ethcore`
|
||||||
//! and can be appended to with transactions and uncles.
|
|
||||||
//!
|
|
||||||
//! When ready, `OpenBlock` can be closed and turned into a `ClosedBlock`. A `ClosedBlock` can
|
|
||||||
//! be reopend again by a miner under certain circumstances. On block close, state commit is
|
|
||||||
//! performed.
|
|
||||||
//!
|
|
||||||
//! `LockedBlock` is a version of a `ClosedBlock` that cannot be reopened. It can be sealed
|
|
||||||
//! using an engine.
|
|
||||||
//!
|
|
||||||
//! `ExecutedBlock` is an underlaying data structure used by all structs above to store block
|
|
||||||
//! related info.
|
|
||||||
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
|
use parity_util_mem::MallocSizeOf;
|
||||||
|
|
||||||
use header::Header;
|
use header::Header;
|
||||||
use rlp::{Rlp, RlpStream, Decodable, DecoderError};
|
use rlp::{Rlp, RlpStream, Decodable, DecoderError};
|
||||||
use transaction::UnverifiedTransaction;
|
use transaction::{UnverifiedTransaction, SignedTransaction};
|
||||||
|
|
||||||
/// A block, encoded as it is on the block chain.
|
/// A block, encoded as it is on the block chain.
|
||||||
#[derive(Default, Debug, Clone, PartialEq)]
|
#[derive(Default, Debug, Clone, PartialEq)]
|
||||||
@ -74,3 +64,16 @@ impl Decodable for Block {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Preprocessed block data gathered in `verify_block_unordered` call
|
||||||
|
#[derive(MallocSizeOf)]
|
||||||
|
pub struct PreverifiedBlock {
|
||||||
|
/// Populated block header
|
||||||
|
pub header: Header,
|
||||||
|
/// Populated block transactions
|
||||||
|
pub transactions: Vec<SignedTransaction>,
|
||||||
|
/// Populated block uncles
|
||||||
|
pub uncles: Vec<Header>,
|
||||||
|
/// Block bytes
|
||||||
|
pub bytes: Bytes,
|
||||||
|
}
|
||||||
|
@ -20,7 +20,7 @@ use std::fmt;
|
|||||||
|
|
||||||
use ethereum_types::{U256, H256};
|
use ethereum_types::{U256, H256};
|
||||||
use security_level::SecurityLevel;
|
use security_level::SecurityLevel;
|
||||||
use {BlockNumber};
|
use BlockNumber;
|
||||||
|
|
||||||
/// Information about the blockchain gathered together.
|
/// Information about the blockchain gathered together.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
//! Epoch verifiers and transitions.
|
//! Epoch verifiers and transitions.
|
||||||
|
|
||||||
use ethereum_types::H256;
|
use ethereum_types::H256;
|
||||||
|
|
||||||
use rlp::{Encodable, Decodable, DecoderError, RlpStream, Rlp};
|
use rlp::{Encodable, Decodable, DecoderError, RlpStream, Rlp};
|
||||||
|
|
||||||
/// A full epoch transition.
|
/// A full epoch transition.
|
||||||
@ -70,4 +69,3 @@ impl Decodable for PendingTransition {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
46
ethcore/types/src/engines/machine.rs
Normal file
46
ethcore/types/src/engines/machine.rs
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
// 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! State machine types
|
||||||
|
|
||||||
|
use ethereum_types::Address;
|
||||||
|
|
||||||
|
use crate::receipt;
|
||||||
|
|
||||||
|
/// Type alias for a function we can make calls through synchronously.
|
||||||
|
/// Returns the call result and state proof for each call.
|
||||||
|
pub type Call<'a> = dyn Fn(Address, Vec<u8>) -> Result<(Vec<u8>, Vec<Vec<u8>>), String> + 'a;
|
||||||
|
|
||||||
|
/// Request for auxiliary data of a block.
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
|
pub enum AuxiliaryRequest {
|
||||||
|
/// Needs the body.
|
||||||
|
Body,
|
||||||
|
/// Needs the receipts.
|
||||||
|
Receipts,
|
||||||
|
/// Needs both body and receipts.
|
||||||
|
Both,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Auxiliary data fetcher for an Ethereum machine. In Ethereum-like machines
|
||||||
|
/// there are two kinds of auxiliary data: bodies and receipts.
|
||||||
|
#[derive(Default, Clone)]
|
||||||
|
pub struct AuxiliaryData<'a> {
|
||||||
|
/// The full block bytes, including the header.
|
||||||
|
pub bytes: Option<&'a [u8]>,
|
||||||
|
/// The block receipts.
|
||||||
|
pub receipts: Option<&'a [receipt::Receipt]>,
|
||||||
|
}
|
@ -16,7 +16,52 @@
|
|||||||
|
|
||||||
//! Engine-specific types.
|
//! Engine-specific types.
|
||||||
|
|
||||||
|
use ethereum_types::{Address, H256};
|
||||||
|
use ethjson;
|
||||||
|
|
||||||
|
use crate::BlockNumber;
|
||||||
|
|
||||||
pub mod epoch;
|
pub mod epoch;
|
||||||
|
pub mod params;
|
||||||
|
pub mod machine;
|
||||||
|
|
||||||
|
/// The type of sealing the engine is currently able to perform.
|
||||||
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
|
pub enum SealingState {
|
||||||
|
/// The engine is ready to seal a block.
|
||||||
|
Ready,
|
||||||
|
/// The engine can't seal at the moment, and no block should be prepared and queued.
|
||||||
|
NotReady,
|
||||||
|
/// The engine does not seal internally.
|
||||||
|
External,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The number of generations back that uncles can be.
|
||||||
|
pub const MAX_UNCLE_AGE: usize = 6;
|
||||||
|
|
||||||
|
/// Default EIP-210 contract code.
|
||||||
|
/// As defined in https://github.com/ethereum/EIPs/pull/210
|
||||||
|
pub const DEFAULT_BLOCKHASH_CONTRACT: &'static [u8] = &[
|
||||||
|
0x73, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
|
0xff, 0xff, 0xff, 0xff, 0xfe, 0x33, 0x14, 0x15, 0x61, 0x00, 0x6a, 0x57, 0x60, 0x01, 0x43, 0x03,
|
||||||
|
0x60, 0x00, 0x35, 0x61, 0x01, 0x00, 0x82, 0x07, 0x55, 0x61, 0x01, 0x00, 0x81, 0x07, 0x15, 0x15,
|
||||||
|
0x61, 0x00, 0x45, 0x57, 0x60, 0x00, 0x35, 0x61, 0x01, 0x00, 0x61, 0x01, 0x00, 0x83, 0x05, 0x07,
|
||||||
|
0x61, 0x01, 0x00, 0x01, 0x55, 0x5b, 0x62, 0x01, 0x00, 0x00, 0x81, 0x07, 0x15, 0x15, 0x61, 0x00,
|
||||||
|
0x64, 0x57, 0x60, 0x00, 0x35, 0x61, 0x01, 0x00, 0x62, 0x01, 0x00, 0x00, 0x83, 0x05, 0x07, 0x61,
|
||||||
|
0x02, 0x00, 0x01, 0x55, 0x5b, 0x50, 0x61, 0x01, 0x3e, 0x56, 0x5b, 0x43, 0x60, 0x00, 0x35, 0x12,
|
||||||
|
0x15, 0x15, 0x61, 0x00, 0x84, 0x57, 0x60, 0x00, 0x60, 0x40, 0x52, 0x60, 0x20, 0x60, 0x40, 0xf3,
|
||||||
|
0x61, 0x01, 0x3d, 0x56, 0x5b, 0x61, 0x01, 0x00, 0x60, 0x00, 0x35, 0x43, 0x03, 0x13, 0x15, 0x15,
|
||||||
|
0x61, 0x00, 0xa8, 0x57, 0x61, 0x01, 0x00, 0x60, 0x00, 0x35, 0x07, 0x54, 0x60, 0x60, 0x52, 0x60,
|
||||||
|
0x20, 0x60, 0x60, 0xf3, 0x61, 0x01, 0x3c, 0x56, 0x5b, 0x61, 0x01, 0x00, 0x60, 0x00, 0x35, 0x07,
|
||||||
|
0x15, 0x15, 0x61, 0x00, 0xc5, 0x57, 0x62, 0x01, 0x00, 0x00, 0x60, 0x00, 0x35, 0x43, 0x03, 0x13,
|
||||||
|
0x15, 0x61, 0x00, 0xc8, 0x56, 0x5b, 0x60, 0x00, 0x5b, 0x15, 0x61, 0x00, 0xea, 0x57, 0x61, 0x01,
|
||||||
|
0x00, 0x61, 0x01, 0x00, 0x60, 0x00, 0x35, 0x05, 0x07, 0x61, 0x01, 0x00, 0x01, 0x54, 0x60, 0x80,
|
||||||
|
0x52, 0x60, 0x20, 0x60, 0x80, 0xf3, 0x61, 0x01, 0x3b, 0x56, 0x5b, 0x62, 0x01, 0x00, 0x00, 0x60,
|
||||||
|
0x00, 0x35, 0x07, 0x15, 0x15, 0x61, 0x01, 0x09, 0x57, 0x63, 0x01, 0x00, 0x00, 0x00, 0x60, 0x00,
|
||||||
|
0x35, 0x43, 0x03, 0x13, 0x15, 0x61, 0x01, 0x0c, 0x56, 0x5b, 0x60, 0x00, 0x5b, 0x15, 0x61, 0x01,
|
||||||
|
0x2f, 0x57, 0x61, 0x01, 0x00, 0x62, 0x01, 0x00, 0x00, 0x60, 0x00, 0x35, 0x05, 0x07, 0x61, 0x02,
|
||||||
|
0x00, 0x01, 0x54, 0x60, 0xa0, 0x52, 0x60, 0x20, 0x60, 0xa0, 0xf3, 0x61, 0x01, 0x3a, 0x56, 0x5b,
|
||||||
|
0x60, 0x00, 0x60, 0xc0, 0x52, 0x60, 0x20, 0x60, 0xc0, 0xf3, 0x5b, 0x5b, 0x5b, 0x5b, 0x5b];
|
||||||
|
|
||||||
/// Fork choice.
|
/// Fork choice.
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
@ -26,3 +71,33 @@ pub enum ForkChoice {
|
|||||||
/// Choose the current best block.
|
/// Choose the current best block.
|
||||||
Old,
|
Old,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Ethash-specific extensions.
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct EthashExtensions {
|
||||||
|
/// Homestead transition block number.
|
||||||
|
pub homestead_transition: BlockNumber,
|
||||||
|
/// DAO hard-fork transition block (X).
|
||||||
|
pub dao_hardfork_transition: u64,
|
||||||
|
/// DAO hard-fork refund contract address (C).
|
||||||
|
pub dao_hardfork_beneficiary: Address,
|
||||||
|
/// DAO hard-fork DAO accounts list (L)
|
||||||
|
pub dao_hardfork_accounts: Vec<Address>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<ethjson::spec::EthashParams> for EthashExtensions {
|
||||||
|
fn from(p: ::ethjson::spec::EthashParams) -> Self {
|
||||||
|
EthashExtensions {
|
||||||
|
homestead_transition: p.homestead_transition.map_or(0, Into::into),
|
||||||
|
dao_hardfork_transition: p.dao_hardfork_transition.map_or(u64::max_value(), Into::into),
|
||||||
|
dao_hardfork_beneficiary: p.dao_hardfork_beneficiary.map_or_else(Address::zero, Into::into),
|
||||||
|
dao_hardfork_accounts: p.dao_hardfork_accounts.unwrap_or_else(Vec::new).into_iter().map(Into::into).collect(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Type alias for a function we can get headers by hash through.
|
||||||
|
pub type Headers<'a, H> = dyn Fn(H256) -> Option<H> + 'a;
|
||||||
|
|
||||||
|
/// Type alias for a function we can query pending transitions by block hash through.
|
||||||
|
pub type PendingTransitionStore<'a> = dyn Fn(H256) -> Option<epoch::PendingTransition> + 'a;
|
||||||
|
310
ethcore/types/src/engines/params.rs
Normal file
310
ethcore/types/src/engines/params.rs
Normal file
@ -0,0 +1,310 @@
|
|||||||
|
// 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! Engine-specific parameter types.
|
||||||
|
|
||||||
|
use ethereum_types::{Address, U256, H256};
|
||||||
|
use bytes::Bytes;
|
||||||
|
use ethjson;
|
||||||
|
|
||||||
|
use BlockNumber;
|
||||||
|
use engines::DEFAULT_BLOCKHASH_CONTRACT;
|
||||||
|
|
||||||
|
const MAX_TRANSACTION_SIZE: usize = 300 * 1024;
|
||||||
|
|
||||||
|
/// Parameters common to ethereum-like blockchains.
|
||||||
|
/// NOTE: when adding bugfix hard-fork parameters,
|
||||||
|
/// add to `nonzero_bugfix_hard_fork`
|
||||||
|
///
|
||||||
|
/// we define a "bugfix" hard fork as any hard fork which
|
||||||
|
/// you would put on-by-default in a new chain.
|
||||||
|
// NOTE [dvdplm]: `Clone` is needed only for tests.
|
||||||
|
#[derive(Debug, PartialEq, Default, Clone)]
|
||||||
|
pub struct CommonParams {
|
||||||
|
/// Account start nonce.
|
||||||
|
pub account_start_nonce: U256,
|
||||||
|
/// Maximum size of extra data.
|
||||||
|
pub maximum_extra_data_size: usize,
|
||||||
|
/// Network id.
|
||||||
|
pub network_id: u64,
|
||||||
|
/// Chain id.
|
||||||
|
pub chain_id: u64,
|
||||||
|
/// Main subprotocol name.
|
||||||
|
pub subprotocol_name: String,
|
||||||
|
/// Minimum gas limit.
|
||||||
|
pub min_gas_limit: U256,
|
||||||
|
/// Fork block to check.
|
||||||
|
pub fork_block: Option<(BlockNumber, H256)>,
|
||||||
|
/// EIP150 transition block number.
|
||||||
|
pub eip150_transition: BlockNumber,
|
||||||
|
/// Number of first block where EIP-160 rules begin.
|
||||||
|
pub eip160_transition: BlockNumber,
|
||||||
|
/// Number of first block where EIP-161.abc begin.
|
||||||
|
pub eip161abc_transition: BlockNumber,
|
||||||
|
/// Number of first block where EIP-161.d begins.
|
||||||
|
pub eip161d_transition: BlockNumber,
|
||||||
|
/// Number of first block where EIP-98 rules begin.
|
||||||
|
pub eip98_transition: BlockNumber,
|
||||||
|
/// Number of first block where EIP-658 rules begin.
|
||||||
|
pub eip658_transition: BlockNumber,
|
||||||
|
/// Number of first block where EIP-155 rules begin.
|
||||||
|
pub eip155_transition: BlockNumber,
|
||||||
|
/// Validate block receipts root.
|
||||||
|
pub validate_receipts_transition: BlockNumber,
|
||||||
|
/// Validate transaction chain id.
|
||||||
|
pub validate_chain_id_transition: BlockNumber,
|
||||||
|
/// Number of first block where EIP-140 rules begin.
|
||||||
|
pub eip140_transition: BlockNumber,
|
||||||
|
/// Number of first block where EIP-210 rules begin.
|
||||||
|
pub eip210_transition: BlockNumber,
|
||||||
|
/// EIP-210 Blockhash contract address.
|
||||||
|
pub eip210_contract_address: Address,
|
||||||
|
/// EIP-210 Blockhash contract code.
|
||||||
|
pub eip210_contract_code: Bytes,
|
||||||
|
/// Gas allocated for EIP-210 blockhash update.
|
||||||
|
pub eip210_contract_gas: U256,
|
||||||
|
/// Number of first block where EIP-211 rules begin.
|
||||||
|
pub eip211_transition: BlockNumber,
|
||||||
|
/// Number of first block where EIP-214 rules begin.
|
||||||
|
pub eip214_transition: BlockNumber,
|
||||||
|
/// Number of first block where EIP-145 rules begin.
|
||||||
|
pub eip145_transition: BlockNumber,
|
||||||
|
/// Number of first block where EIP-1052 rules begin.
|
||||||
|
pub eip1052_transition: BlockNumber,
|
||||||
|
/// Number of first block where EIP-1283 rules begin.
|
||||||
|
pub eip1283_transition: BlockNumber,
|
||||||
|
/// Number of first block where EIP-1283 rules end.
|
||||||
|
pub eip1283_disable_transition: BlockNumber,
|
||||||
|
/// Number of first block where EIP-1014 rules begin.
|
||||||
|
pub eip1014_transition: BlockNumber,
|
||||||
|
/// Number of first block where dust cleanup rules (EIP-168 and EIP169) begin.
|
||||||
|
pub dust_protection_transition: BlockNumber,
|
||||||
|
/// Nonce cap increase per block. Nonce cap is only checked if dust protection is enabled.
|
||||||
|
pub nonce_cap_increment: u64,
|
||||||
|
/// Enable dust cleanup for contracts.
|
||||||
|
pub remove_dust_contracts: bool,
|
||||||
|
/// Wasm activation blocknumber, if any disabled initially.
|
||||||
|
pub wasm_activation_transition: BlockNumber,
|
||||||
|
/// Wasm account version, activated after `wasm_activation_transition`. If this field is defined, do not use code
|
||||||
|
/// prefix to determine VM to execute.
|
||||||
|
pub wasm_version: Option<U256>,
|
||||||
|
/// Number of first block where KIP-4 rules begin. Only has effect if Wasm is activated.
|
||||||
|
pub kip4_transition: BlockNumber,
|
||||||
|
/// Number of first block where KIP-6 rules begin. Only has effect if Wasm is activated.
|
||||||
|
pub kip6_transition: BlockNumber,
|
||||||
|
/// Gas limit bound divisor (how much gas limit can change per block)
|
||||||
|
pub gas_limit_bound_divisor: U256,
|
||||||
|
/// Registrar contract address.
|
||||||
|
pub registrar: Option<Address>,
|
||||||
|
/// Node permission managing contract address.
|
||||||
|
pub node_permission_contract: Option<Address>,
|
||||||
|
/// Maximum contract code size that can be deployed.
|
||||||
|
pub max_code_size: u64,
|
||||||
|
/// Number of first block where max code size limit is active.
|
||||||
|
pub max_code_size_transition: BlockNumber,
|
||||||
|
/// Transaction permission managing contract address.
|
||||||
|
pub transaction_permission_contract: Option<Address>,
|
||||||
|
/// Block at which the transaction permission contract should start being used.
|
||||||
|
pub transaction_permission_contract_transition: BlockNumber,
|
||||||
|
/// Maximum size of transaction's RLP payload
|
||||||
|
pub max_transaction_size: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CommonParams {
|
||||||
|
/// Schedule for an EVM in the post-EIP-150-era of the Ethereum main net.
|
||||||
|
pub fn schedule(&self, block_number: u64) -> vm::Schedule {
|
||||||
|
if block_number < self.eip150_transition {
|
||||||
|
vm::Schedule::new_homestead()
|
||||||
|
} else {
|
||||||
|
let max_code_size = self.max_code_size(block_number);
|
||||||
|
let mut schedule = vm::Schedule::new_post_eip150(
|
||||||
|
max_code_size as _,
|
||||||
|
block_number >= self.eip160_transition,
|
||||||
|
block_number >= self.eip161abc_transition,
|
||||||
|
block_number >= self.eip161d_transition
|
||||||
|
);
|
||||||
|
|
||||||
|
self.update_schedule(block_number, &mut schedule);
|
||||||
|
schedule
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns max code size at given block.
|
||||||
|
pub fn max_code_size(&self, block_number: u64) -> u64 {
|
||||||
|
if block_number >= self.max_code_size_transition {
|
||||||
|
self.max_code_size
|
||||||
|
} else {
|
||||||
|
u64::max_value()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Apply common spec config parameters to the schedule.
|
||||||
|
pub fn update_schedule(&self, block_number: u64, schedule: &mut vm::Schedule) {
|
||||||
|
schedule.have_create2 = block_number >= self.eip1014_transition;
|
||||||
|
schedule.have_revert = block_number >= self.eip140_transition;
|
||||||
|
schedule.have_static_call = block_number >= self.eip214_transition;
|
||||||
|
schedule.have_return_data = block_number >= self.eip211_transition;
|
||||||
|
schedule.have_bitwise_shifting = block_number >= self.eip145_transition;
|
||||||
|
schedule.have_extcodehash = block_number >= self.eip1052_transition;
|
||||||
|
schedule.eip1283 = block_number >= self.eip1283_transition && !(block_number >= self.eip1283_disable_transition);
|
||||||
|
if block_number >= self.eip210_transition {
|
||||||
|
schedule.blockhash_gas = 800;
|
||||||
|
}
|
||||||
|
if block_number >= self.dust_protection_transition {
|
||||||
|
schedule.kill_dust = match self.remove_dust_contracts {
|
||||||
|
true => vm::CleanDustMode::WithCodeAndStorage,
|
||||||
|
false => vm::CleanDustMode::BasicOnly,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if block_number >= self.wasm_activation_transition {
|
||||||
|
let mut wasm = vm::WasmCosts::default();
|
||||||
|
if block_number >= self.kip4_transition {
|
||||||
|
wasm.have_create2 = true;
|
||||||
|
}
|
||||||
|
if block_number >= self.kip6_transition {
|
||||||
|
wasm.have_gasleft = true;
|
||||||
|
}
|
||||||
|
schedule.wasm = Some(wasm);
|
||||||
|
if let Some(version) = self.wasm_version {
|
||||||
|
schedule.versions.insert(version, vm::VersionedSchedule::PWasm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return Some if the current parameters contain a bugfix hard fork not on block 0.
|
||||||
|
pub fn nonzero_bugfix_hard_fork(&self) -> Option<&str> {
|
||||||
|
if self.eip155_transition != 0 {
|
||||||
|
return Some("eip155Transition");
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.validate_receipts_transition != 0 {
|
||||||
|
return Some("validateReceiptsTransition");
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.validate_chain_id_transition != 0 {
|
||||||
|
return Some("validateChainIdTransition");
|
||||||
|
}
|
||||||
|
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<ethjson::spec::Params> for CommonParams {
|
||||||
|
fn from(p: ethjson::spec::Params) -> Self {
|
||||||
|
CommonParams {
|
||||||
|
account_start_nonce: p.account_start_nonce.map_or_else(U256::zero, Into::into),
|
||||||
|
maximum_extra_data_size: p.maximum_extra_data_size.into(),
|
||||||
|
network_id: p.network_id.into(),
|
||||||
|
chain_id: if let Some(n) = p.chain_id {
|
||||||
|
n.into()
|
||||||
|
} else {
|
||||||
|
p.network_id.into()
|
||||||
|
},
|
||||||
|
subprotocol_name: p.subprotocol_name.unwrap_or_else(|| "eth".to_owned()),
|
||||||
|
min_gas_limit: p.min_gas_limit.into(),
|
||||||
|
fork_block: if let (Some(n), Some(h)) = (p.fork_block, p.fork_hash) {
|
||||||
|
Some((n.into(), h.into()))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
},
|
||||||
|
eip150_transition: p.eip150_transition.map_or(0, Into::into),
|
||||||
|
eip160_transition: p.eip160_transition.map_or(0, Into::into),
|
||||||
|
eip161abc_transition: p.eip161abc_transition.map_or(0, Into::into),
|
||||||
|
eip161d_transition: p.eip161d_transition.map_or(0, Into::into),
|
||||||
|
eip98_transition: p.eip98_transition.map_or_else(
|
||||||
|
BlockNumber::max_value,
|
||||||
|
Into::into,
|
||||||
|
),
|
||||||
|
eip155_transition: p.eip155_transition.map_or(0, Into::into),
|
||||||
|
validate_receipts_transition: p.validate_receipts_transition.map_or(0, Into::into),
|
||||||
|
validate_chain_id_transition: p.validate_chain_id_transition.map_or(0, Into::into),
|
||||||
|
eip140_transition: p.eip140_transition.map_or_else(
|
||||||
|
BlockNumber::max_value,
|
||||||
|
Into::into,
|
||||||
|
),
|
||||||
|
eip210_transition: p.eip210_transition.map_or_else(
|
||||||
|
BlockNumber::max_value,
|
||||||
|
Into::into,
|
||||||
|
),
|
||||||
|
eip210_contract_address: p.eip210_contract_address.map_or(Address::from_low_u64_be(0xf0), Into::into),
|
||||||
|
eip210_contract_code: p.eip210_contract_code.map_or_else(
|
||||||
|
|| DEFAULT_BLOCKHASH_CONTRACT.to_vec(),
|
||||||
|
Into::into,
|
||||||
|
),
|
||||||
|
eip210_contract_gas: p.eip210_contract_gas.map_or(1000000.into(), Into::into),
|
||||||
|
eip211_transition: p.eip211_transition.map_or_else(
|
||||||
|
BlockNumber::max_value,
|
||||||
|
Into::into,
|
||||||
|
),
|
||||||
|
eip145_transition: p.eip145_transition.map_or_else(
|
||||||
|
BlockNumber::max_value,
|
||||||
|
Into::into,
|
||||||
|
),
|
||||||
|
eip214_transition: p.eip214_transition.map_or_else(
|
||||||
|
BlockNumber::max_value,
|
||||||
|
Into::into,
|
||||||
|
),
|
||||||
|
eip658_transition: p.eip658_transition.map_or_else(
|
||||||
|
BlockNumber::max_value,
|
||||||
|
Into::into,
|
||||||
|
),
|
||||||
|
eip1052_transition: p.eip1052_transition.map_or_else(
|
||||||
|
BlockNumber::max_value,
|
||||||
|
Into::into,
|
||||||
|
),
|
||||||
|
eip1283_transition: p.eip1283_transition.map_or_else(
|
||||||
|
BlockNumber::max_value,
|
||||||
|
Into::into,
|
||||||
|
),
|
||||||
|
eip1283_disable_transition: p.eip1283_disable_transition.map_or_else(
|
||||||
|
BlockNumber::max_value,
|
||||||
|
Into::into,
|
||||||
|
),
|
||||||
|
eip1014_transition: p.eip1014_transition.map_or_else(
|
||||||
|
BlockNumber::max_value,
|
||||||
|
Into::into,
|
||||||
|
),
|
||||||
|
dust_protection_transition: p.dust_protection_transition.map_or_else(
|
||||||
|
BlockNumber::max_value,
|
||||||
|
Into::into,
|
||||||
|
),
|
||||||
|
nonce_cap_increment: p.nonce_cap_increment.map_or(64, Into::into),
|
||||||
|
remove_dust_contracts: p.remove_dust_contracts.unwrap_or(false),
|
||||||
|
gas_limit_bound_divisor: p.gas_limit_bound_divisor.into(),
|
||||||
|
registrar: p.registrar.map(Into::into),
|
||||||
|
node_permission_contract: p.node_permission_contract.map(Into::into),
|
||||||
|
max_code_size: p.max_code_size.map_or(u64::max_value(), Into::into),
|
||||||
|
max_transaction_size: p.max_transaction_size.map_or(MAX_TRANSACTION_SIZE, Into::into),
|
||||||
|
max_code_size_transition: p.max_code_size_transition.map_or(0, Into::into),
|
||||||
|
transaction_permission_contract: p.transaction_permission_contract.map(Into::into),
|
||||||
|
transaction_permission_contract_transition:
|
||||||
|
p.transaction_permission_contract_transition.map_or(0, Into::into),
|
||||||
|
wasm_activation_transition: p.wasm_activation_transition.map_or_else(
|
||||||
|
BlockNumber::max_value,
|
||||||
|
Into::into
|
||||||
|
),
|
||||||
|
wasm_version: p.wasm_version.map(Into::into),
|
||||||
|
kip4_transition: p.kip4_transition.map_or_else(
|
||||||
|
BlockNumber::max_value,
|
||||||
|
Into::into
|
||||||
|
),
|
||||||
|
kip6_transition: p.kip6_transition.map_or_else(
|
||||||
|
BlockNumber::max_value,
|
||||||
|
Into::into
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,38 +1,30 @@
|
|||||||
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
|
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
|
||||||
// This file is part of Parity Ethereum.
|
// This file is part of Parity.
|
||||||
|
|
||||||
// Parity Ethereum is free software: you can redistribute it and/or modify
|
// Parity is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
// (at your option) any later version.
|
// (at your option) any later version.
|
||||||
|
|
||||||
// Parity Ethereum is distributed in the hope that it will be useful,
|
// Parity is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
//! General error types for use in ethcore.
|
use std::{
|
||||||
|
fmt,
|
||||||
|
error,
|
||||||
|
time::SystemTime
|
||||||
|
};
|
||||||
|
|
||||||
use std::{fmt, error};
|
use ethbloom::Bloom;
|
||||||
use std::time::SystemTime;
|
use ethereum_types::{H256, U256, Address};
|
||||||
|
|
||||||
use derive_more::{Display, From};
|
|
||||||
use ethereum_types::{H256, U256, Address, Bloom};
|
|
||||||
use ethkey::Error as EthkeyError;
|
|
||||||
use ethtrie::TrieError;
|
|
||||||
use rlp;
|
|
||||||
use snappy::InvalidInput;
|
|
||||||
use snapshot::Error as SnapshotError;
|
|
||||||
use types::BlockNumber;
|
|
||||||
use types::transaction::Error as TransactionError;
|
|
||||||
use unexpected::{Mismatch, OutOfBounds};
|
use unexpected::{Mismatch, OutOfBounds};
|
||||||
|
|
||||||
use engines::EngineError;
|
use BlockNumber;
|
||||||
|
|
||||||
pub use executed::{ExecutionError, CallError};
|
|
||||||
|
|
||||||
/// Errors concerning block processing.
|
/// Errors concerning block processing.
|
||||||
#[derive(Debug, Display, PartialEq, Clone, Eq)]
|
#[derive(Debug, Display, PartialEq, Clone, Eq)]
|
||||||
@ -165,94 +157,3 @@ pub enum ImportError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl error::Error for ImportError {}
|
impl error::Error for ImportError {}
|
||||||
|
|
||||||
/// Ethcore Result
|
|
||||||
pub type EthcoreResult<T> = Result<T, Error>;
|
|
||||||
|
|
||||||
/// Ethcore Error
|
|
||||||
#[derive(Debug, Display, From)]
|
|
||||||
pub enum Error {
|
|
||||||
/// Error concerning block import.
|
|
||||||
#[display(fmt = "Import error: {}", _0)]
|
|
||||||
Import(ImportError),
|
|
||||||
/// Io channel queue error
|
|
||||||
#[display(fmt = "Queue is full: {}", _0)]
|
|
||||||
FullQueue(usize),
|
|
||||||
/// Io create error
|
|
||||||
#[display(fmt = "Io error: {}", _0)]
|
|
||||||
Io(::io::IoError),
|
|
||||||
/// Error concerning the Rust standard library's IO subsystem.
|
|
||||||
#[display(fmt = "Std Io error: {}", _0)]
|
|
||||||
StdIo(::std::io::Error),
|
|
||||||
/// Error concerning TrieDBs.
|
|
||||||
#[display(fmt = "Trie error: {}", _0)]
|
|
||||||
Trie(TrieError),
|
|
||||||
/// Error concerning EVM code execution.
|
|
||||||
#[display(fmt = "Execution error: {}", _0)]
|
|
||||||
Execution(ExecutionError),
|
|
||||||
/// Error concerning block processing.
|
|
||||||
#[display(fmt = "Block error: {}", _0)]
|
|
||||||
Block(BlockError),
|
|
||||||
/// Error concerning transaction processing.
|
|
||||||
#[display(fmt = "Transaction error: {}", _0)]
|
|
||||||
Transaction(TransactionError),
|
|
||||||
/// Snappy error
|
|
||||||
#[display(fmt = "Snappy error: {}", _0)]
|
|
||||||
Snappy(InvalidInput),
|
|
||||||
/// Consensus vote error.
|
|
||||||
#[display(fmt = "Engine error: {}", _0)]
|
|
||||||
Engine(EngineError),
|
|
||||||
/// Ethkey error."
|
|
||||||
#[display(fmt = "Ethkey error: {}", _0)]
|
|
||||||
Ethkey(EthkeyError),
|
|
||||||
/// RLP decoding errors
|
|
||||||
#[display(fmt = "Decoder error: {}", _0)]
|
|
||||||
Decoder(rlp::DecoderError),
|
|
||||||
/// Snapshot error.
|
|
||||||
#[display(fmt = "Snapshot error {}", _0)]
|
|
||||||
Snapshot(SnapshotError),
|
|
||||||
/// PoW hash is invalid or out of date.
|
|
||||||
#[display(fmt = "PoW hash is invalid or out of date.")]
|
|
||||||
PowHashInvalid,
|
|
||||||
/// The value of the nonce or mishash is invalid.
|
|
||||||
#[display(fmt = "The value of the nonce or mishash is invalid.")]
|
|
||||||
PowInvalid,
|
|
||||||
/// A convenient variant for String.
|
|
||||||
#[display(fmt = "{}", _0)]
|
|
||||||
Msg(String),
|
|
||||||
/// State errors
|
|
||||||
#[display(fmt = "State error ({})", _0)]
|
|
||||||
State(account_state::Error),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl error::Error for Error {
|
|
||||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
|
||||||
match self {
|
|
||||||
Error::Io(e) => Some(e),
|
|
||||||
Error::StdIo(e) => Some(e),
|
|
||||||
Error::Trie(e) => Some(e),
|
|
||||||
Error::Execution(e) => Some(e),
|
|
||||||
Error::Block(e) => Some(e),
|
|
||||||
Error::Transaction(e) => Some(e),
|
|
||||||
Error::Snappy(e) => Some(e),
|
|
||||||
Error::Engine(e) => Some(e),
|
|
||||||
Error::Ethkey(e) => Some(e),
|
|
||||||
Error::Decoder(e) => Some(e),
|
|
||||||
Error::Snapshot(e) => Some(e),
|
|
||||||
Error::State(e) => Some(e),
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<&str> for Error {
|
|
||||||
fn from(s: &str) -> Self {
|
|
||||||
Error::Msg(s.into())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<E> From<Box<E>> for Error where Error: From<E> {
|
|
||||||
fn from(err: Box<E>) -> Error {
|
|
||||||
Error::from(*err)
|
|
||||||
}
|
|
||||||
}
|
|
109
ethcore/types/src/errors/engine_error.rs
Normal file
109
ethcore/types/src/errors/engine_error.rs
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
|
||||||
|
// This file is part of Parity.
|
||||||
|
|
||||||
|
// Parity is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// Parity is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
use std::fmt;
|
||||||
|
|
||||||
|
use derive_more::From;
|
||||||
|
use ethereum_types::{Address, H64, H256};
|
||||||
|
use unexpected::{Mismatch, OutOfBounds};
|
||||||
|
|
||||||
|
/// Voting errors.
|
||||||
|
#[derive(Debug, From)]
|
||||||
|
pub enum EngineError {
|
||||||
|
/// Signature or author field does not belong to an authority.
|
||||||
|
NotAuthorized(Address),
|
||||||
|
/// The same author issued different votes at the same step.
|
||||||
|
DoubleVote(Address),
|
||||||
|
/// The received block is from an incorrect proposer.
|
||||||
|
NotProposer(Mismatch<Address>),
|
||||||
|
/// Message was not expected.
|
||||||
|
UnexpectedMessage,
|
||||||
|
/// Seal field has an unexpected size.
|
||||||
|
BadSealFieldSize(OutOfBounds<usize>),
|
||||||
|
/// Validation proof insufficient.
|
||||||
|
InsufficientProof(String),
|
||||||
|
/// Failed system call.
|
||||||
|
FailedSystemCall(String),
|
||||||
|
/// Malformed consensus message.
|
||||||
|
MalformedMessage(String),
|
||||||
|
/// Requires client ref, but none registered.
|
||||||
|
RequiresClient,
|
||||||
|
/// Invalid engine specification or implementation.
|
||||||
|
InvalidEngine,
|
||||||
|
/// Requires signer ref, but none registered.
|
||||||
|
RequiresSigner,
|
||||||
|
/// Missing Parent Epoch
|
||||||
|
MissingParent(H256),
|
||||||
|
/// Checkpoint is missing
|
||||||
|
CliqueMissingCheckpoint(H256),
|
||||||
|
/// Missing vanity data
|
||||||
|
CliqueMissingVanity,
|
||||||
|
/// Missing signature
|
||||||
|
CliqueMissingSignature,
|
||||||
|
/// Missing signers
|
||||||
|
CliqueCheckpointNoSigner,
|
||||||
|
/// List of signers is invalid
|
||||||
|
CliqueCheckpointInvalidSigners(usize),
|
||||||
|
/// Wrong author on a checkpoint
|
||||||
|
CliqueWrongAuthorCheckpoint(Mismatch<Address>),
|
||||||
|
/// Wrong checkpoint authors recovered
|
||||||
|
CliqueFaultyRecoveredSigners(Vec<String>),
|
||||||
|
/// Invalid nonce (should contain vote)
|
||||||
|
CliqueInvalidNonce(H64),
|
||||||
|
/// The signer signed a block to recently
|
||||||
|
CliqueTooRecentlySigned(Address),
|
||||||
|
/// Custom
|
||||||
|
Custom(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for EngineError {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
use self::EngineError::*;
|
||||||
|
let msg = match *self {
|
||||||
|
CliqueMissingCheckpoint(ref hash) => format!("Missing checkpoint block: {}", hash),
|
||||||
|
CliqueMissingVanity => format!("Extra data is missing vanity data"),
|
||||||
|
CliqueMissingSignature => format!("Extra data is missing signature"),
|
||||||
|
CliqueCheckpointInvalidSigners(len) => format!("Checkpoint block list was of length: {} of checkpoint but
|
||||||
|
it needs to be bigger than zero and a divisible by 20", len),
|
||||||
|
CliqueCheckpointNoSigner => format!("Checkpoint block list of signers was empty"),
|
||||||
|
CliqueInvalidNonce(ref mis) => format!("Unexpected nonce {} expected {} or {}", mis, 0_u64, u64::max_value()),
|
||||||
|
CliqueWrongAuthorCheckpoint(ref oob) => format!("Unexpected checkpoint author: {}", oob),
|
||||||
|
CliqueFaultyRecoveredSigners(ref mis) => format!("Faulty recovered signers {:?}", mis),
|
||||||
|
CliqueTooRecentlySigned(ref address) => format!("The signer: {} has signed a block too recently", address),
|
||||||
|
Custom(ref s) => s.clone(),
|
||||||
|
DoubleVote(ref address) => format!("Author {} issued too many blocks.", address),
|
||||||
|
NotProposer(ref mis) => format!("Author is not a current proposer: {}", mis),
|
||||||
|
NotAuthorized(ref address) => format!("Signer {} is not authorized.", address),
|
||||||
|
UnexpectedMessage => "This Engine should not be fed messages.".into(),
|
||||||
|
BadSealFieldSize(ref oob) => format!("Seal field has an unexpected length: {}", oob),
|
||||||
|
InsufficientProof(ref msg) => format!("Insufficient validation proof: {}", msg),
|
||||||
|
FailedSystemCall(ref msg) => format!("Failed to make system call: {}", msg),
|
||||||
|
MalformedMessage(ref msg) => format!("Received malformed consensus message: {}", msg),
|
||||||
|
RequiresClient => format!("Call requires client but none registered"),
|
||||||
|
RequiresSigner => format!("Call requires signer but none registered"),
|
||||||
|
InvalidEngine => format!("Invalid engine specification or implementation"),
|
||||||
|
MissingParent(ref hash) => format!("Parent Epoch is missing from database: {}", hash),
|
||||||
|
};
|
||||||
|
|
||||||
|
f.write_fmt(format_args!("Engine error ({})", msg))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::error::Error for EngineError {
|
||||||
|
fn description(&self) -> &str {
|
||||||
|
"Engine error"
|
||||||
|
}
|
||||||
|
}
|
205
ethcore/types/src/errors/ethcore_error.rs
Normal file
205
ethcore/types/src/errors/ethcore_error.rs
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
// 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! General error types for use in ethcore.
|
||||||
|
|
||||||
|
use std::{error, fmt};
|
||||||
|
use derive_more::{Display, From};
|
||||||
|
use ethereum_types::{U256, U512};
|
||||||
|
use ethtrie::TrieError;
|
||||||
|
use parity_snappy::InvalidInput;
|
||||||
|
use ethkey::Error as EthkeyError;
|
||||||
|
|
||||||
|
use errors::{BlockError, EngineError, ImportError, SnapshotError};
|
||||||
|
use transaction::Error as TransactionError;
|
||||||
|
|
||||||
|
/// Ethcore Result
|
||||||
|
pub type EthcoreResult<T> = Result<T, EthcoreError>;
|
||||||
|
|
||||||
|
/// Ethcore Error
|
||||||
|
#[derive(Debug, Display, From)]
|
||||||
|
pub enum EthcoreError {
|
||||||
|
/// Error concerning block import.
|
||||||
|
#[display(fmt = "Import error: {}", _0)]
|
||||||
|
Import(ImportError),
|
||||||
|
/// Io channel queue error
|
||||||
|
#[display(fmt = "Queue is full: {}", _0)]
|
||||||
|
FullQueue(usize),
|
||||||
|
/// Io create error
|
||||||
|
#[display(fmt = "Io error: {}", _0)]
|
||||||
|
Io(ethcore_io::IoError),
|
||||||
|
/// Error concerning the Rust standard library's IO subsystem.
|
||||||
|
#[display(fmt = "Std Io error: {}", _0)]
|
||||||
|
StdIo(::std::io::Error),
|
||||||
|
/// Error concerning TrieDBs.
|
||||||
|
#[display(fmt = "Trie error: {}", _0)]
|
||||||
|
Trie(TrieError),
|
||||||
|
/// Error concerning EVM code execution.
|
||||||
|
#[display(fmt = "Execution error: {}", _0)]
|
||||||
|
Execution(ExecutionError),
|
||||||
|
/// Error concerning block processing.
|
||||||
|
#[display(fmt = "Block error: {}", _0)]
|
||||||
|
Block(BlockError),
|
||||||
|
/// Error concerning transaction processing.
|
||||||
|
#[display(fmt = "Transaction error: {}", _0)]
|
||||||
|
Transaction(TransactionError),
|
||||||
|
/// Snappy error
|
||||||
|
#[display(fmt = "Snappy error: {}", _0)]
|
||||||
|
Snappy(InvalidInput),
|
||||||
|
/// Consensus vote error.
|
||||||
|
#[display(fmt = "Engine error: {}", _0)]
|
||||||
|
Engine(EngineError),
|
||||||
|
/// Ethkey error."
|
||||||
|
#[display(fmt = "Ethkey error: {}", _0)]
|
||||||
|
Ethkey(EthkeyError),
|
||||||
|
/// RLP decoding errors
|
||||||
|
#[display(fmt = "Decoder error: {}", _0)]
|
||||||
|
Decoder(rlp::DecoderError),
|
||||||
|
/// Snapshot error.
|
||||||
|
#[display(fmt = "Snapshot error {}", _0)]
|
||||||
|
Snapshot(SnapshotError),
|
||||||
|
/// PoW hash is invalid or out of date.
|
||||||
|
#[display(fmt = "PoW hash is invalid or out of date.")]
|
||||||
|
PowHashInvalid,
|
||||||
|
/// The value of the nonce or mishash is invalid.
|
||||||
|
#[display(fmt = "The value of the nonce or mishash is invalid.")]
|
||||||
|
PowInvalid,
|
||||||
|
/// A convenient variant for String.
|
||||||
|
#[display(fmt = "{}", _0)]
|
||||||
|
Msg(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl error::Error for EthcoreError {
|
||||||
|
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||||
|
use self::EthcoreError::*;
|
||||||
|
match self {
|
||||||
|
Io(e) => Some(e),
|
||||||
|
StdIo(e) => Some(e),
|
||||||
|
Trie(e) => Some(e),
|
||||||
|
Execution(e) => Some(e),
|
||||||
|
Block(e) => Some(e),
|
||||||
|
Transaction(e) => Some(e),
|
||||||
|
Snappy(e) => Some(e),
|
||||||
|
Engine(e) => Some(e),
|
||||||
|
Ethkey(e) => Some(e),
|
||||||
|
Decoder(e) => Some(e),
|
||||||
|
Snapshot(e) => Some(e),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<&str> for EthcoreError {
|
||||||
|
fn from(s: &str) -> Self {
|
||||||
|
EthcoreError::Msg(s.into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<E> From<Box<E>> for EthcoreError where EthcoreError: From<E> {
|
||||||
|
fn from(err: Box<E>) -> EthcoreError {
|
||||||
|
EthcoreError::from(*err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Error type for executing a transaction.
|
||||||
|
#[derive(PartialEq, Debug, Clone)]
|
||||||
|
pub enum ExecutionError {
|
||||||
|
/// Returned when there gas paid for transaction execution is
|
||||||
|
/// lower than base gas required.
|
||||||
|
NotEnoughBaseGas {
|
||||||
|
/// Absolute minimum gas required.
|
||||||
|
required: U256,
|
||||||
|
/// Gas provided.
|
||||||
|
got: U256
|
||||||
|
},
|
||||||
|
/// Returned when block (gas_used + gas) > gas_limit.
|
||||||
|
///
|
||||||
|
/// If gas =< gas_limit, upstream may try to execute the transaction
|
||||||
|
/// in next block.
|
||||||
|
BlockGasLimitReached {
|
||||||
|
/// Gas limit of block for transaction.
|
||||||
|
gas_limit: U256,
|
||||||
|
/// Gas used in block prior to transaction.
|
||||||
|
gas_used: U256,
|
||||||
|
/// Amount of gas in block.
|
||||||
|
gas: U256
|
||||||
|
},
|
||||||
|
/// Returned when transaction nonce does not match state nonce.
|
||||||
|
InvalidNonce {
|
||||||
|
/// Nonce expected.
|
||||||
|
expected: U256,
|
||||||
|
/// Nonce found.
|
||||||
|
got: U256
|
||||||
|
},
|
||||||
|
/// Returned when cost of transaction (value + gas_price * gas) exceeds
|
||||||
|
/// current sender balance.
|
||||||
|
NotEnoughCash {
|
||||||
|
/// Minimum required balance.
|
||||||
|
required: U512,
|
||||||
|
/// Actual balance.
|
||||||
|
got: U512
|
||||||
|
},
|
||||||
|
/// When execution tries to modify the state in static context
|
||||||
|
MutableCallInStaticContext,
|
||||||
|
/// Returned when transacting from a non-existing account with dust protection enabled.
|
||||||
|
SenderMustExist,
|
||||||
|
/// Returned when internal evm error occurs.
|
||||||
|
Internal(String),
|
||||||
|
/// Returned when generic transaction occurs
|
||||||
|
TransactionMalformed(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl error::Error for ExecutionError {
|
||||||
|
fn description(&self) -> &str {
|
||||||
|
"Transaction execution error"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Box<TrieError>> for ExecutionError {
|
||||||
|
fn from(err: Box<TrieError>) -> Self {
|
||||||
|
ExecutionError::Internal(format!("{:?}", err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl From<TrieError> for ExecutionError {
|
||||||
|
fn from(err: TrieError) -> Self {
|
||||||
|
ExecutionError::Internal(format!("{:?}", err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for ExecutionError {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
use self::ExecutionError::*;
|
||||||
|
|
||||||
|
let msg = match *self {
|
||||||
|
NotEnoughBaseGas { ref required, ref got } =>
|
||||||
|
format!("Not enough base gas. {} is required, but only {} paid", required, got),
|
||||||
|
BlockGasLimitReached { ref gas_limit, ref gas_used, ref gas } =>
|
||||||
|
format!("Block gas limit reached. The limit is {}, {} has \
|
||||||
|
already been used, and {} more is required", gas_limit, gas_used, gas),
|
||||||
|
InvalidNonce { ref expected, ref got } =>
|
||||||
|
format!("Invalid transaction nonce: expected {}, found {}", expected, got),
|
||||||
|
NotEnoughCash { ref required, ref got } =>
|
||||||
|
format!("Cost of transaction exceeds sender balance. {} is required \
|
||||||
|
but the sender only has {}", required, got),
|
||||||
|
MutableCallInStaticContext => "Mutable Call in static context".to_owned(),
|
||||||
|
SenderMustExist => "Transacting from an empty account".to_owned(),
|
||||||
|
Internal(ref msg) => msg.clone(),
|
||||||
|
TransactionMalformed(ref err) => format!("Malformed transaction: {}", err),
|
||||||
|
};
|
||||||
|
|
||||||
|
f.write_fmt(format_args!("Transaction execution error ({}).", msg))
|
||||||
|
}
|
||||||
|
}
|
@ -14,22 +14,16 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
//! State related errors
|
//! General error types for use in parity-ethereum.
|
||||||
|
|
||||||
use derive_more::{Display, From};
|
mod block_error;
|
||||||
|
mod engine_error;
|
||||||
|
mod ethcore_error;
|
||||||
|
mod snapshot_error;
|
||||||
|
|
||||||
#[derive(Debug, Display, From)]
|
pub use self::{
|
||||||
pub enum Error {
|
block_error::{BlockError, ImportError},
|
||||||
/// Trie error.
|
engine_error::EngineError,
|
||||||
Trie(ethtrie::TrieError),
|
ethcore_error::{EthcoreError, ExecutionError, EthcoreResult},
|
||||||
/// Decoder error.
|
snapshot_error::SnapshotError,
|
||||||
Decoder(rlp::DecoderError),
|
};
|
||||||
}
|
|
||||||
|
|
||||||
impl std::error::Error for Error {}
|
|
||||||
|
|
||||||
impl<E> From<Box<E>> for Error where Error: From<E> {
|
|
||||||
fn from(err: Box<E>) -> Self {
|
|
||||||
Error::from(*err)
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,15 +19,15 @@
|
|||||||
use std::error;
|
use std::error;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use types::ids::BlockId;
|
|
||||||
|
|
||||||
use ethereum_types::H256;
|
use ethereum_types::H256;
|
||||||
use ethtrie::TrieError;
|
use ethtrie::TrieError;
|
||||||
use rlp::DecoderError;
|
use rlp::DecoderError;
|
||||||
|
|
||||||
|
use ids::BlockId;
|
||||||
|
|
||||||
/// Snapshot-related errors.
|
/// Snapshot-related errors.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum SnapshotError {
|
||||||
/// Invalid starting block for snapshot.
|
/// Invalid starting block for snapshot.
|
||||||
InvalidStartingBlock(BlockId),
|
InvalidStartingBlock(BlockId),
|
||||||
/// Block not found.
|
/// Block not found.
|
||||||
@ -72,67 +72,69 @@ pub enum Error {
|
|||||||
UnlinkedAncientBlockChain(H256),
|
UnlinkedAncientBlockChain(H256),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl error::Error for Error {
|
impl error::Error for SnapshotError {
|
||||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||||
|
use self::SnapshotError::*;
|
||||||
match self {
|
match self {
|
||||||
Error::Trie(e) => Some(e),
|
Trie(e) => Some(e),
|
||||||
Error::Decoder(e) => Some(e),
|
Decoder(e) => Some(e),
|
||||||
Error::Io(e) => Some(e),
|
Io(e) => Some(e),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Error {
|
impl fmt::Display for SnapshotError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
use self::SnapshotError::*;
|
||||||
match *self {
|
match *self {
|
||||||
Error::InvalidStartingBlock(ref id) => write!(f, "Invalid starting block: {:?}", id),
|
InvalidStartingBlock(ref id) => write!(f, "Invalid starting block: {:?}", id),
|
||||||
Error::BlockNotFound(ref hash) => write!(f, "Block not found in chain: {}", hash),
|
BlockNotFound(ref hash) => write!(f, "Block not found in chain: {}", hash),
|
||||||
Error::IncompleteChain => write!(f, "Incomplete blockchain."),
|
IncompleteChain => write!(f, "Incomplete blockchain."),
|
||||||
Error::WrongStateRoot(ref expected, ref found) => write!(f, "Final block has wrong state root. Expected {:?}, got {:?}", expected, found),
|
WrongStateRoot(ref expected, ref found) => write!(f, "Final block has wrong state root. Expected {:?}, got {:?}", expected, found),
|
||||||
Error::WrongBlockHash(ref num, ref expected, ref found) =>
|
WrongBlockHash(ref num, ref expected, ref found) =>
|
||||||
write!(f, "Block {} had wrong hash. expected {:?}, got {:?}", num, expected, found),
|
write!(f, "Block {} had wrong hash. expected {:?}, got {:?}", num, expected, found),
|
||||||
Error::TooManyBlocks(ref expected, ref found) => write!(f, "Snapshot contained too many blocks. Expected {}, got {}", expected, found),
|
TooManyBlocks(ref expected, ref found) => write!(f, "Snapshot contained too many blocks. Expected {}, got {}", expected, found),
|
||||||
Error::OldBlockPrunedDB => write!(f, "Attempted to create a snapshot at an old block while using \
|
OldBlockPrunedDB => write!(f, "Attempted to create a snapshot at an old block while using \
|
||||||
a pruned database. Please re-run with the --pruning archive flag."),
|
a pruned database. Please re-run with the --pruning archive flag."),
|
||||||
Error::MissingCode(ref missing) => write!(f, "Incomplete snapshot: {} contract codes not found.", missing.len()),
|
MissingCode(ref missing) => write!(f, "Incomplete snapshot: {} contract codes not found.", missing.len()),
|
||||||
Error::UnrecognizedCodeState(state) => write!(f, "Unrecognized code encoding ({})", state),
|
UnrecognizedCodeState(state) => write!(f, "Unrecognized code encoding ({})", state),
|
||||||
Error::RestorationAborted => write!(f, "Snapshot restoration aborted."),
|
RestorationAborted => write!(f, "Snapshot restoration aborted."),
|
||||||
Error::Io(ref err) => err.fmt(f),
|
Io(ref err) => err.fmt(f),
|
||||||
Error::Decoder(ref err) => err.fmt(f),
|
Decoder(ref err) => err.fmt(f),
|
||||||
Error::Trie(ref err) => err.fmt(f),
|
Trie(ref err) => err.fmt(f),
|
||||||
Error::VersionNotSupported(ref ver) => write!(f, "Snapshot version {} is not supprted.", ver),
|
VersionNotSupported(ref ver) => write!(f, "Snapshot version {} is not supprted.", ver),
|
||||||
Error::ChunkTooSmall => write!(f, "Chunk size is too small."),
|
ChunkTooSmall => write!(f, "Chunk size is too small."),
|
||||||
Error::ChunkTooLarge => write!(f, "Chunk size is too large."),
|
ChunkTooLarge => write!(f, "Chunk size is too large."),
|
||||||
Error::SnapshotsUnsupported => write!(f, "Snapshots unsupported by consensus engine."),
|
SnapshotsUnsupported => write!(f, "Snapshots unsupported by consensus engine."),
|
||||||
Error::SnapshotAborted => write!(f, "Snapshot was aborted."),
|
SnapshotAborted => write!(f, "Snapshot was aborted."),
|
||||||
Error::BadEpochProof(i) => write!(f, "Bad epoch proof for transition to epoch {}", i),
|
BadEpochProof(i) => write!(f, "Bad epoch proof for transition to epoch {}", i),
|
||||||
Error::WrongChunkFormat(ref msg) => write!(f, "Wrong chunk format: {}", msg),
|
WrongChunkFormat(ref msg) => write!(f, "Wrong chunk format: {}", msg),
|
||||||
Error::UnlinkedAncientBlockChain(parent_hash) => write!(f, "Unlinked ancient blocks chain at parent_hash={:#x}", parent_hash),
|
UnlinkedAncientBlockChain(parent_hash) => write!(f, "Unlinked ancient blocks chain at parent_hash={:#x}", parent_hash),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<::std::io::Error> for Error {
|
impl From<::std::io::Error> for SnapshotError {
|
||||||
fn from(err: ::std::io::Error) -> Self {
|
fn from(err: ::std::io::Error) -> Self {
|
||||||
Error::Io(err)
|
SnapshotError::Io(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<TrieError> for Error {
|
impl From<TrieError> for SnapshotError {
|
||||||
fn from(err: TrieError) -> Self {
|
fn from(err: TrieError) -> Self {
|
||||||
Error::Trie(err)
|
SnapshotError::Trie(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<DecoderError> for Error {
|
impl From<DecoderError> for SnapshotError {
|
||||||
fn from(err: DecoderError) -> Self {
|
fn from(err: DecoderError) -> Self {
|
||||||
Error::Decoder(err)
|
SnapshotError::Decoder(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E> From<Box<E>> for Error where Error: From<E> {
|
impl<E> From<Box<E>> for SnapshotError where SnapshotError: From<E> {
|
||||||
fn from(err: Box<E>) -> Self {
|
fn from(err: Box<E>) -> Self {
|
||||||
Error::from(*err)
|
SnapshotError::from(*err)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -33,26 +33,30 @@
|
|||||||
|
|
||||||
#![warn(missing_docs, unused_extern_crates)]
|
#![warn(missing_docs, unused_extern_crates)]
|
||||||
|
|
||||||
|
extern crate ethbloom;
|
||||||
extern crate ethereum_types;
|
extern crate ethereum_types;
|
||||||
extern crate ethjson;
|
extern crate ethjson;
|
||||||
extern crate ethkey;
|
extern crate ethkey;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate derive_more;
|
||||||
extern crate keccak_hash as hash;
|
extern crate keccak_hash as hash;
|
||||||
extern crate parity_bytes as bytes;
|
extern crate parity_bytes as bytes;
|
||||||
|
extern crate patricia_trie_ethereum as ethtrie;
|
||||||
extern crate rlp;
|
extern crate rlp;
|
||||||
|
extern crate parity_snappy;
|
||||||
extern crate unexpected;
|
extern crate unexpected;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate rlp_derive;
|
extern crate rlp_derive;
|
||||||
extern crate parity_util_mem;
|
extern crate parity_util_mem;
|
||||||
|
|
||||||
extern crate parity_util_mem as malloc_size_of;
|
extern crate parity_util_mem as malloc_size_of;
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
extern crate rustc_hex;
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod views;
|
pub mod views;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
extern crate rustc_hex;
|
||||||
|
|
||||||
pub mod account_diff;
|
pub mod account_diff;
|
||||||
pub mod ancestry_action;
|
pub mod ancestry_action;
|
||||||
pub mod basic_account;
|
pub mod basic_account;
|
||||||
@ -62,6 +66,7 @@ pub mod blockchain_info;
|
|||||||
pub mod call_analytics;
|
pub mod call_analytics;
|
||||||
pub mod encoded;
|
pub mod encoded;
|
||||||
pub mod engines;
|
pub mod engines;
|
||||||
|
pub mod errors;
|
||||||
pub mod filter;
|
pub mod filter;
|
||||||
pub mod header;
|
pub mod header;
|
||||||
pub mod ids;
|
pub mod ids;
|
||||||
|
@ -21,6 +21,8 @@ use ethkey;
|
|||||||
use rlp;
|
use rlp;
|
||||||
use unexpected::OutOfBounds;
|
use unexpected::OutOfBounds;
|
||||||
|
|
||||||
|
use errors::ExecutionError;
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
/// Errors concerning transaction processing.
|
/// Errors concerning transaction processing.
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
@ -130,3 +132,40 @@ impl error::Error for Error {
|
|||||||
"Transaction error"
|
"Transaction error"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Result of executing the transaction.
|
||||||
|
#[derive(PartialEq, Debug, Clone)]
|
||||||
|
pub enum CallError {
|
||||||
|
/// Couldn't find the transaction in the chain.
|
||||||
|
TransactionNotFound,
|
||||||
|
/// Couldn't find requested block's state in the chain.
|
||||||
|
StatePruned,
|
||||||
|
/// Couldn't find an amount of gas that didn't result in an exception.
|
||||||
|
Exceptional(vm::Error),
|
||||||
|
/// Corrupt state.
|
||||||
|
StateCorrupt,
|
||||||
|
/// Error executing.
|
||||||
|
Execution(ExecutionError),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<ExecutionError> for CallError {
|
||||||
|
fn from(error: ExecutionError) -> Self {
|
||||||
|
CallError::Execution(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for CallError {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
use self::CallError::*;
|
||||||
|
let msg = match *self {
|
||||||
|
TransactionNotFound => "Transaction couldn't be found in the chain".into(),
|
||||||
|
StatePruned => "Couldn't find the transaction block's state in the chain".into(),
|
||||||
|
Exceptional(ref e) => format!("An exception ({}) happened in the execution", e),
|
||||||
|
StateCorrupt => "Stored state found to be corrupted.".into(),
|
||||||
|
Execution(ref e) => format!("{}", e),
|
||||||
|
};
|
||||||
|
|
||||||
|
f.write_fmt(format_args!("Transaction execution error ({}).", msg))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -19,5 +19,5 @@
|
|||||||
mod error;
|
mod error;
|
||||||
mod transaction;
|
mod transaction;
|
||||||
|
|
||||||
pub use self::error::Error;
|
pub use self::error::{Error, CallError};
|
||||||
pub use self::transaction::*;
|
pub use self::transaction::*;
|
||||||
|
@ -20,6 +20,7 @@ use std::io::{BufReader, BufRead};
|
|||||||
use std::time::{Instant, Duration};
|
use std::time::{Instant, Duration};
|
||||||
use std::thread::sleep;
|
use std::thread::sleep;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use rustc_hex::FromHex;
|
use rustc_hex::FromHex;
|
||||||
use hash::{keccak, KECCAK_NULL_RLP};
|
use hash::{keccak, KECCAK_NULL_RLP};
|
||||||
use ethereum_types::{U256, H256, Address};
|
use ethereum_types::{U256, H256, Address};
|
||||||
@ -28,7 +29,6 @@ use rlp::PayloadInfo;
|
|||||||
use ethcore::client::{
|
use ethcore::client::{
|
||||||
Mode, DatabaseCompactionProfile, VMType, Nonce, Balance, BlockChainClient, BlockId, BlockInfo, ImportBlock, BlockChainReset
|
Mode, DatabaseCompactionProfile, VMType, Nonce, Balance, BlockChainClient, BlockId, BlockInfo, ImportBlock, BlockChainReset
|
||||||
};
|
};
|
||||||
use ethcore::error::{ImportError, Error as EthcoreError};
|
|
||||||
use ethcore::miner::Miner;
|
use ethcore::miner::Miner;
|
||||||
use ethcore::verification::queue::VerifierSettings;
|
use ethcore::verification::queue::VerifierSettings;
|
||||||
use ethcore::verification::queue::kind::blocks::Unverified;
|
use ethcore::verification::queue::kind::blocks::Unverified;
|
||||||
@ -42,6 +42,7 @@ use user_defaults::UserDefaults;
|
|||||||
use ethcore_private_tx;
|
use ethcore_private_tx;
|
||||||
use db;
|
use db;
|
||||||
use ansi_term::Colour;
|
use ansi_term::Colour;
|
||||||
|
use types::errors::{ImportError, EthcoreError};
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum DataFormat {
|
pub enum DataFormat {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use ethereum_types::Bloom;
|
use ethereum_types::Bloom;
|
||||||
use ethcore::error::Error;
|
use types::errors::EthcoreError as Error;
|
||||||
use rlp;
|
use rlp;
|
||||||
use super::kvdb_rocksdb::DatabaseConfig;
|
use super::kvdb_rocksdb::DatabaseConfig;
|
||||||
use super::open_database;
|
use super::open_database;
|
||||||
|
@ -21,7 +21,7 @@ use std::fmt::{Display, Formatter, Error as FmtError};
|
|||||||
use super::migration_rocksdb::{Manager as MigrationManager, Config as MigrationConfig, ChangeColumns};
|
use super::migration_rocksdb::{Manager as MigrationManager, Config as MigrationConfig, ChangeColumns};
|
||||||
use super::kvdb_rocksdb::{CompactionProfile, DatabaseConfig};
|
use super::kvdb_rocksdb::{CompactionProfile, DatabaseConfig};
|
||||||
use ethcore::client::DatabaseCompactionProfile;
|
use ethcore::client::DatabaseCompactionProfile;
|
||||||
use ethcore;
|
use types::errors::EthcoreError;
|
||||||
|
|
||||||
use super::helpers;
|
use super::helpers;
|
||||||
use super::blooms::migrate_blooms;
|
use super::blooms::migrate_blooms;
|
||||||
@ -63,7 +63,7 @@ pub enum Error {
|
|||||||
/// Migration is not possible.
|
/// Migration is not possible.
|
||||||
MigrationImpossible,
|
MigrationImpossible,
|
||||||
/// Blooms-db migration error.
|
/// Blooms-db migration error.
|
||||||
BloomsDB(ethcore::error::Error),
|
BloomsDB(EthcoreError),
|
||||||
/// Migration was completed succesfully,
|
/// Migration was completed succesfully,
|
||||||
/// but there was a problem with io.
|
/// but there was a problem with io.
|
||||||
Io(IoError),
|
Io(IoError),
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use ethcore::error::{Error as EthcoreError, CallError};
|
|
||||||
use ethcore::client::BlockId;
|
use ethcore::client::BlockId;
|
||||||
use jsonrpc_core::{futures, Result as RpcResult, Error, ErrorCode, Value};
|
use jsonrpc_core::{futures, Result as RpcResult, Error, ErrorCode, Value};
|
||||||
use rlp::DecoderError;
|
use rlp::DecoderError;
|
||||||
@ -27,7 +26,11 @@ use ethcore_private_tx::Error as PrivateTransactionError;
|
|||||||
use vm::Error as VMError;
|
use vm::Error as VMError;
|
||||||
use light::on_demand::error::{Error as OnDemandError};
|
use light::on_demand::error::{Error as OnDemandError};
|
||||||
use ethcore::client::BlockChainClient;
|
use ethcore::client::BlockChainClient;
|
||||||
use types::blockchain_info::BlockChainInfo;
|
use types::{
|
||||||
|
blockchain_info::BlockChainInfo,
|
||||||
|
errors::{EthcoreError},
|
||||||
|
transaction::CallError,
|
||||||
|
};
|
||||||
use v1::types::BlockNumber;
|
use v1::types::BlockNumber;
|
||||||
use v1::impls::EthClientOptions;
|
use v1::impls::EthClientOptions;
|
||||||
|
|
||||||
|
@ -21,12 +21,14 @@ use std::cmp;
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use types::basic_account::BasicAccount;
|
use types::{
|
||||||
use types::encoded;
|
basic_account::BasicAccount,
|
||||||
use types::filter::Filter as EthcoreFilter;
|
encoded,
|
||||||
use types::ids::BlockId;
|
errors::ExecutionError,
|
||||||
use types::receipt::Receipt;
|
filter::Filter as EthcoreFilter,
|
||||||
use ethcore::executed::ExecutionError;
|
ids::BlockId,
|
||||||
|
receipt::Receipt,
|
||||||
|
};
|
||||||
|
|
||||||
use jsonrpc_core::{Result, Error};
|
use jsonrpc_core::{Result, Error};
|
||||||
use jsonrpc_core::futures::{future, Future};
|
use jsonrpc_core::futures::{future, Future};
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user