Extract blockchain from ethcore (#10114)

* Split blockchain & db from ethcore.

* Clean up blockchain deps.

* Missing docs.

* Fix blockchain tests.

* Make other crates compile.

* Remove some re-exports.

* Remove types re-export from ethcore.

* Remove EVM dependency from transaction.

* Merge ethcore-transaction with common-types.

* Clean-up ethcore deps a bit.

* remove ethcore from cargo.toml

* Update ethcore/blockchain/src/lib.rs

Co-Authored-By: tomusdrw <tomusdrw@users.noreply.github.com>

* Address review comments.

* Update DB comment.

* Add tracking issue to the TODO and fix typo.

* Common naming for common types.

* Update ethcore/db/src/keys.rs

Co-Authored-By: tomusdrw <tomusdrw@users.noreply.github.com>

* Update ethcore/blockchain/src/generator.rs

Co-Authored-By: tomusdrw <tomusdrw@users.noreply.github.com>

* Try to fix beta tests.
This commit is contained in:
Tomasz Drwięga 2019-01-04 14:05:46 +01:00 committed by Afri Schoedon
parent 3090324366
commit 3650f2d51c
223 changed files with 1428 additions and 1058 deletions

101
Cargo.lock generated
View File

@ -291,12 +291,15 @@ version = "0.1.0"
dependencies = [
"ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethjson 0.1.0",
"ethkey 0.3.0",
"heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-machine 0.1.0",
"rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp_derive 0.1.0",
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unexpected 0.1.0",
]
[[package]]
@ -583,15 +586,6 @@ dependencies = [
"heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "env_logger"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "env_logger"
version = "0.5.13"
@ -693,18 +687,19 @@ dependencies = [
"common-types 0.1.0",
"criterion 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)",
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethabi 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethabi-contract 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethabi-derive 6.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ethash 1.12.0",
"ethcore-blockchain 0.1.0",
"ethcore-bloom-journal 0.1.0",
"ethcore-db 0.1.0",
"ethcore-io 1.12.0",
"ethcore-logger 1.12.0",
"ethcore-miner 1.12.0",
"ethcore-stratum 1.12.0",
"ethcore-transaction 0.1.0",
"ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethjson 0.1.0",
"ethkey 0.3.0",
@ -756,6 +751,33 @@ dependencies = [
"wasm 0.1.0",
]
[[package]]
name = "ethcore-blockchain"
version = "0.1.0"
dependencies = [
"ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"blooms-db 0.1.0",
"common-types 0.1.0",
"env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore-db 0.1.0",
"ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethkey 0.3.0",
"heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
"keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp_compress 0.1.0",
"rlp_derive 0.1.0",
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ethcore-bloom-journal"
version = "0.1.0"
@ -763,6 +785,19 @@ dependencies = [
"siphasher 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ethcore-db"
version = "0.1.0"
dependencies = [
"common-types 0.1.0",
"ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp_derive 0.1.0",
]
[[package]]
name = "ethcore-io"
version = "1.12.0"
@ -785,11 +820,13 @@ name = "ethcore-light"
version = "1.12.0"
dependencies = [
"bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"common-types 0.1.0",
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore 1.12.0",
"ethcore-blockchain 0.1.0",
"ethcore-db 0.1.0",
"ethcore-io 1.12.0",
"ethcore-network 1.12.0",
"ethcore-transaction 0.1.0",
"ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"failsafe 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fastmap 0.1.0",
@ -840,10 +877,10 @@ name = "ethcore-miner"
version = "1.12.0"
dependencies = [
"ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"common-types 0.1.0",
"env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)",
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethash 1.12.0",
"ethcore-transaction 0.1.0",
"ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethkey 0.3.0",
"fetch 0.1.0",
@ -919,6 +956,7 @@ dependencies = [
name = "ethcore-private-tx"
version = "1.0.0"
dependencies = [
"common-types 0.1.0",
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethabi 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethabi-contract 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -927,7 +965,6 @@ dependencies = [
"ethcore-io 1.12.0",
"ethcore-logger 1.12.0",
"ethcore-miner 1.12.0",
"ethcore-transaction 0.1.0",
"ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethjson 0.1.0",
"ethkey 0.3.0",
@ -958,13 +995,13 @@ name = "ethcore-secretstore"
version = "1.0.0"
dependencies = [
"byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"common-types 0.1.0",
"ethabi 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethabi-contract 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethabi-derive 6.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore 1.12.0",
"ethcore-logger 1.12.0",
"ethcore-sync 1.12.0",
"ethcore-transaction 0.1.0",
"ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethkey 0.3.0",
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
@ -997,6 +1034,8 @@ dependencies = [
"ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore 1.12.0",
"ethcore-blockchain 0.1.0",
"ethcore-db 0.1.0",
"ethcore-io 1.12.0",
"ethcore-private-tx 1.0.0",
"ethcore-sync 1.12.0",
@ -1037,9 +1076,9 @@ dependencies = [
"ethcore-network 1.12.0",
"ethcore-network-devp2p 1.12.0",
"ethcore-private-tx 1.0.0",
"ethcore-transaction 0.1.0",
"ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethkey 0.3.0",
"ethstore 0.2.0",
"fastmap 0.1.0",
"hashdb 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1058,21 +1097,6 @@ dependencies = [
"triehash-ethereum 0.2.0",
]
[[package]]
name = "ethcore-transaction"
version = "0.1.0"
dependencies = [
"ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethjson 0.1.0",
"ethkey 0.3.0",
"evm 0.1.0",
"heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unexpected 0.1.0",
]
[[package]]
name = "ethereum-types"
version = "0.4.0"
@ -1205,10 +1229,10 @@ dependencies = [
name = "evmbin"
version = "0.1.0"
dependencies = [
"common-types 0.1.0",
"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)",
"ethcore 1.12.0",
"ethcore-transaction 0.1.0",
"ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethjson 0.1.0",
"evm 0.1.0",
@ -2357,12 +2381,15 @@ dependencies = [
"blooms-db 0.1.0",
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cli-signer 1.4.0",
"common-types 0.1.0",
"ctrlc 1.1.1 (git+https://github.com/paritytech/rust-ctrlc.git)",
"daemonize 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dir 0.1.2",
"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)",
"ethcore 1.12.0",
"ethcore-blockchain 0.1.0",
"ethcore-db 0.1.0",
"ethcore-io 1.12.0",
"ethcore-light 1.12.0",
"ethcore-logger 1.12.0",
@ -2372,9 +2399,9 @@ dependencies = [
"ethcore-secretstore 1.0.0",
"ethcore-service 0.1.0",
"ethcore-sync 1.12.0",
"ethcore-transaction 0.1.0",
"ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethkey 0.3.0",
"ethstore 0.2.0",
"fake-fetch 0.0.1",
"fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2461,9 +2488,8 @@ dependencies = [
name = "parity-local-store"
version = "0.1.0"
dependencies = [
"ethcore 1.12.0",
"common-types 0.1.0",
"ethcore-io 1.12.0",
"ethcore-transaction 0.1.0",
"ethkey 0.3.0",
"kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2513,6 +2539,7 @@ version = "1.12.0"
dependencies = [
"ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"cid 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"common-types 0.1.0",
"eip-712 0.1.0",
"ethash 1.12.0",
"ethcore 1.12.0",
@ -2523,7 +2550,6 @@ dependencies = [
"ethcore-network 1.12.0",
"ethcore-private-tx 1.0.0",
"ethcore-sync 1.12.0",
"ethcore-transaction 0.1.0",
"ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethjson 0.1.0",
"ethkey 0.3.0",
@ -2635,6 +2661,7 @@ dependencies = [
name = "parity-updater"
version = "1.12.0"
dependencies = [
"common-types 0.1.0",
"ethabi 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethabi-contract 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethabi-derive 6.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -4131,7 +4158,6 @@ name = "vm"
version = "0.1.0"
dependencies = [
"byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"common-types 0.1.0",
"ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethjson 0.1.0",
"keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -4393,7 +4419,6 @@ dependencies = [
"checksum edit-distance 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3bd26878c3d921f89797a4e1a1711919f999a9f6946bb6f5a4ffda126d297b7e"
"checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0"
"checksum elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "88d4851b005ef16de812ea9acdb7bece2f0a40dd86c07b85631d7dafa54537bb"
"checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b"
"checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38"
"checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02"
"checksum eth-secp256k1 0.5.7 (git+https://github.com/paritytech/rust-secp256k1)" = "<none>"

View File

@ -33,6 +33,9 @@ ctrlc = { git = "https://github.com/paritytech/rust-ctrlc.git" }
jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-2.2" }
ethcore = { path = "ethcore", features = ["parity"] }
parity-bytes = "0.1"
common-types = { path = "ethcore/types" }
ethcore-blockchain = { path = "ethcore/blockchain" }
ethcore-db = { path = "ethcore/db" }
ethcore-io = { path = "util/io" }
ethcore-light = { path = "ethcore/light" }
ethcore-logger = { path = "logger" }
@ -41,7 +44,7 @@ ethcore-network = { path = "util/network" }
ethcore-private-tx = { path = "ethcore/private-tx" }
ethcore-service = { path = "ethcore/service" }
ethcore-sync = { path = "ethcore/sync" }
ethcore-transaction = { path = "ethcore/transaction" }
ethstore = { path = "accounts/ethstore" }
ethereum-types = "0.4"
node-filter = { path = "ethcore/node-filter" }
ethkey = { path = "accounts/ethkey" }

View File

@ -8,68 +8,68 @@ authors = ["Parity Technologies <admin@parity.io>"]
[dependencies]
ansi_term = "0.10"
blooms-db = { path = "../util/blooms-db" }
blooms-db = { path = "../util/blooms-db", optional = true }
bn = { git = "https://github.com/paritytech/bn", default-features = false }
byteorder = "1.0"
common-types = { path = "types" }
crossbeam = "0.4"
ethash = { path = "../ethash" }
ethcore-bloom-journal = { path = "../util/bloom" }
parity-bytes = "0.1"
hashdb = "0.3.0"
memorydb = "0.3.0"
patricia-trie = "0.3.0"
patricia-trie-ethereum = { path = "../util/patricia-trie-ethereum" }
parity-crypto = "0.2"
error-chain = { version = "0.12", default-features = false }
ethabi = "6.0"
ethabi-contract = "6.0"
ethabi-derive = "6.0"
ethash = { path = "../ethash" }
ethcore-blockchain = { path = "./blockchain" }
ethcore-bloom-journal = { path = "../util/bloom" }
ethcore-db = { path = "./db" }
ethcore-io = { path = "../util/io" }
ethcore-logger = { path = "../logger" }
ethcore-logger = { path = "../logger", optional = true }
ethcore-miner = { path = "../miner" }
ethcore-stratum = { path = "../miner/stratum", optional = true }
ethcore-transaction = { path = "./transaction" }
ethereum-types = "0.4"
memory-cache = { path = "../util/memory-cache" }
ethabi = "6.0"
ethabi-derive = "6.0"
ethabi-contract = "6.0"
ethjson = { path = "../json" }
ethkey = { path = "../accounts/ethkey" }
ethstore = { path = "../accounts/ethstore" }
evm = { path = "evm" }
hashdb = "0.3.0"
heapsize = "0.4"
itertools = "0.5"
lazy_static = "1.0"
log = "0.4"
lru-cache = "0.1"
num = { version = "0.1", default-features = false, features = ["bigint"] }
num_cpus = "1.2"
parity-machine = { path = "../machine" }
parking_lot = "0.7"
rayon = "1.0"
rand = "0.4"
rlp = { version = "0.3.0", features = ["ethereum"] }
rlp_compress = { path = "../util/rlp-compress" }
rlp_derive = { path = "../util/rlp-derive" }
journaldb = { path = "../util/journaldb" }
keccak-hash = "0.1"
keccak-hasher = { path = "../util/keccak-hasher" }
kvdb = "0.1"
kvdb-memorydb = "0.1"
parity-snappy = "0.1"
kvdb-rocksdb = { version = "0.1.3", optional = true }
lazy_static = "1.0"
len-caching-lock = { path = "../util/len-caching-lock" }
log = "0.4"
lru-cache = "0.1"
macros = { path = "../util/macros" }
memory-cache = { path = "../util/memory-cache" }
memorydb = "0.3.0"
num = { version = "0.1", default-features = false, features = ["bigint"] }
num_cpus = "1.2"
parity-bytes = "0.1"
parity-crypto = "0.2"
parity-machine = { path = "../machine" }
parity-snappy = "0.1"
parking_lot = "0.7"
patricia-trie = "0.3.0"
patricia-trie-ethereum = { path = "../util/patricia-trie-ethereum" }
rand = "0.4"
rayon = "1.0"
rlp = { version = "0.3.0", features = ["ethereum"] }
rlp_derive = { path = "../util/rlp-derive" }
rustc-hex = "1.0"
serde = "1.0"
serde_derive = "1.0"
stats = { path = "../util/stats" }
tempdir = {version="0.3", optional = true}
trace-time = "0.1"
triehash-ethereum = { version = "0.2", path = "../util/triehash-ethereum" }
unexpected = { path = "../util/unexpected" }
using_queue = { path = "../miner/using-queue" }
vm = { path = "vm" }
wasm = { path = "wasm" }
keccak-hash = "0.1"
triehash-ethereum = { version = "0.2", path = "../util/triehash-ethereum" }
unexpected = { path = "../util/unexpected" }
journaldb = { path = "../util/journaldb" }
keccak-hasher = { path = "../util/keccak-hasher" }
kvdb-rocksdb = "0.1.3"
serde = "1.0"
serde_derive = "1.0"
tempdir = {version="0.3", optional = true}
len-caching-lock = { path = "../util/len-caching-lock" }
[target.'cfg(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "android"))'.dependencies]
hardware-wallet = { path = "../accounts/hw" }
@ -78,10 +78,14 @@ hardware-wallet = { path = "../accounts/hw" }
fake-hardware-wallet = { path = "../accounts/fake-hardware-wallet" }
[dev-dependencies]
env_logger = "0.4"
blooms-db = { path = "../util/blooms-db" }
criterion = "0.2"
env_logger = "0.5"
ethcore-logger = { path = "../logger" }
kvdb-rocksdb = "0.1.3"
rlp_compress = { path = "../util/rlp-compress" }
tempdir = "0.3"
trie-standardmap = "0.1"
criterion = "0.2"
[features]
parity = ["work-notify", "price-info", "stratum"]
@ -105,13 +109,13 @@ evm-debug-tests = ["evm-debug", "evm/evm-debug-tests"]
# EVM debug traces are printed.
slow-blocks = []
# Run JSON consensus tests.
json-tests = ["ethcore-transaction/json-tests", "test-helpers", "tempdir", "to-pod-full"]
json-tests = ["ethcore-logger", "test-helpers", "tempdir", "to-pod-full"]
# Skip JSON consensus tests with pending issues.
ci-skip-issue = []
# Run memory/cpu heavy tests.
test-heavy = []
# Compile test helpers
test-helpers = ["tempdir"]
test-helpers = ["tempdir", "kvdb-rocksdb", "blooms-db"]
# Enables slow 'to-pod-full' method for use in tests and evmbin.
to-pod-full = []

View File

@ -0,0 +1,33 @@
[package]
description = "Ethcore blockchain database"
homepage = "http://parity.io"
license = "GPL-3.0"
name = "ethcore-blockchain"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
ansi_term = "0.10"
blooms-db = { path = "../../util/blooms-db" }
common-types = { path = "../types" }
ethcore-db = { path = "../db" }
ethereum-types = "0.4"
heapsize = "0.4"
itertools = "0.5"
kvdb = "0.1"
log = "0.4"
parity-bytes = "0.1"
parking_lot = "0.7"
rayon = "1.0"
rlp = { version = "0.3.0", features = ["ethereum"] }
rlp_compress = { path = "../../util/rlp-compress" }
rlp_derive = { path = "../../util/rlp-derive" }
[dev-dependencies]
env_logger = "0.5"
ethkey = { path = "../../accounts/ethkey" }
keccak-hash = "0.1"
rustc-hex = "1.0"
tempdir = "0.3"
kvdb-memorydb = "0.1"

View File

@ -16,8 +16,8 @@
use ethereum_types::{H256, U256};
use encoded;
use header::{Header, BlockNumber};
use common_types::{encoded, BlockNumber};
use common_types::header::Header;
/// Contains information on a best block that is specific to the consensus engine.
///

View File

@ -15,7 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use ethereum_types::{H256, U256};
use header::BlockNumber;
use common_types::BlockNumber;
/// Brief info about inserted block.
#[derive(Clone)]

View File

@ -22,34 +22,37 @@ use std::path::Path;
use std::sync::Arc;
use ansi_term::Colour;
use blockchain::{CacheSize, ImportRoute, Config};
use blockchain::best_block::{BestBlock, BestAncientBlock};
use blockchain::block_info::{BlockInfo, BlockLocation, BranchBecomingCanonChainData};
use blockchain::extras::{BlockReceipts, BlockDetails, TransactionAddress, EPOCH_KEY_PREFIX, EpochTransitions};
use blockchain::update::{ExtrasUpdate, ExtrasInsert};
use blooms_db;
use bytes::Bytes;
use cache_manager::CacheManager;
use db::{self, Writable, Readable, CacheUpdatePolicy};
use encoded;
use engines::epoch::{Transition as EpochTransition, PendingTransition as PendingEpochTransition};
use engines::ForkChoice;
use common_types::BlockNumber;
use common_types::blockchain_info::BlockChainInfo;
use common_types::encoded;
use common_types::engines::ForkChoice;
use common_types::engines::epoch::{Transition as EpochTransition, PendingTransition as PendingEpochTransition};
use common_types::header::{Header, ExtendedHeader};
use common_types::log_entry::{LogEntry, LocalizedLogEntry};
use common_types::receipt::Receipt;
use common_types::transaction::LocalizedTransaction;
use common_types::tree_route::TreeRoute;
use common_types::view;
use common_types::views::{BlockView, HeaderView};
use ethcore_db::cache_manager::CacheManager;
use ethcore_db::keys::{BlockReceipts, BlockDetails, TransactionAddress, EPOCH_KEY_PREFIX, EpochTransitions};
use ethcore_db::{self as db, Writable, Readable, CacheUpdatePolicy};
use ethereum_types::{H256, Bloom, BloomRef, U256};
use error::Error as EthcoreError;
use header::*;
use heapsize::HeapSizeOf;
use itertools::Itertools;
use kvdb::{DBTransaction, KeyValueDB};
use log_entry::{LogEntry, LocalizedLogEntry};
use log::{trace, warn, info};
use parity_bytes::Bytes;
use parking_lot::{Mutex, RwLock};
use rayon::prelude::*;
use receipt::Receipt;
use rlp_compress::{compress, decompress, blocks_swapper};
use rlp::RlpStream;
use transaction::*;
use types::blockchain_info::BlockChainInfo;
use types::tree_route::TreeRoute;
use views::{BlockView, HeaderView};
use rlp_compress::{compress, decompress, blocks_swapper};
use crate::best_block::{BestBlock, BestAncientBlock};
use crate::block_info::{BlockInfo, BlockLocation, BranchBecomingCanonChainData};
use crate::update::{ExtrasUpdate, ExtrasInsert};
use crate::{CacheSize, ImportRoute, Config};
/// Database backing `BlockChain`.
pub trait BlockChainDB: Send + Sync {
@ -63,7 +66,7 @@ pub trait BlockChainDB: Send + Sync {
fn trace_blooms(&self) -> &blooms_db::Database;
/// Restore the DB from the given path
fn restore(&self, new_db: &str) -> Result<(), EthcoreError> {
fn restore(&self, new_db: &str) -> Result<(), io::Error> {
// First, close the Blooms databases
self.blooms().close()?;
self.trace_blooms().close()?;
@ -1549,25 +1552,55 @@ impl BlockChain {
#[cfg(test)]
mod tests {
use super::*;
use std::iter;
use std::sync::Arc;
use rustc_hex::FromHex;
use hash::keccak;
use kvdb::DBTransaction;
use ethereum_types::*;
use receipt::{Receipt, TransactionOutcome};
use blockchain::{BlockProvider, BlockChain, BlockChainDB, Config, ImportRoute};
use test_helpers::{
generate_dummy_blockchain, generate_dummy_blockchain_with_extra,
generate_dummy_empty_blockchain
};
use blockchain::generator::{BlockGenerator, BlockBuilder, BlockOptions};
use blockchain::extras::TransactionAddress;
use transaction::{Transaction, Action};
use log_entry::{LogEntry, LocalizedLogEntry};
use common_types::receipt::{Receipt, TransactionOutcome};
use common_types::transaction::{Transaction, Action};
use crate::generator::{BlockGenerator, BlockBuilder, BlockOptions};
use ethkey::Secret;
use test_helpers::new_db;
use encoded;
use keccak_hash::keccak;
use rustc_hex::FromHex;
use tempdir::TempDir;
struct TestBlockChainDB {
_blooms_dir: TempDir,
_trace_blooms_dir: TempDir,
blooms: blooms_db::Database,
trace_blooms: blooms_db::Database,
key_value: Arc<KeyValueDB>,
}
impl BlockChainDB for TestBlockChainDB {
fn key_value(&self) -> &Arc<KeyValueDB> {
&self.key_value
}
fn blooms(&self) -> &blooms_db::Database {
&self.blooms
}
fn trace_blooms(&self) -> &blooms_db::Database {
&self.trace_blooms
}
}
/// Creates new test instance of `BlockChainDB`
pub fn new_db() -> Arc<BlockChainDB> {
let blooms_dir = TempDir::new("").unwrap();
let trace_blooms_dir = TempDir::new("").unwrap();
let db = TestBlockChainDB {
blooms: blooms_db::Database::open(blooms_dir.path()).unwrap(),
trace_blooms: blooms_db::Database::open(trace_blooms_dir.path()).unwrap(),
_blooms_dir: blooms_dir,
_trace_blooms_dir: trace_blooms_dir,
key_value: Arc::new(kvdb_memorydb::create(ethcore_db::NUM_COLUMNS.unwrap()))
};
Arc::new(db)
}
fn new_chain(genesis: encoded::Block, db: Arc<BlockChainDB>) -> BlockChain {
BlockChain::new(Config::default(), genesis.raw(), db)
@ -1588,7 +1621,7 @@ mod tests {
}
fn insert_block_batch(batch: &mut DBTransaction, bc: &BlockChain, block: encoded::Block, receipts: Vec<Receipt>) -> ImportRoute {
use blockchain::ExtrasInsert;
use crate::ExtrasInsert;
let fork_choice = {
let header = block.header_view();
@ -1596,9 +1629,9 @@ mod tests {
let parent_details = bc.block_details(&parent_hash).unwrap_or_else(|| panic!("Invalid parent hash: {:?}", parent_hash));
let block_total_difficulty = parent_details.total_difficulty + header.difficulty();
if block_total_difficulty > bc.best_block_total_difficulty() {
::engines::ForkChoice::New
common_types::engines::ForkChoice::New
} else {
::engines::ForkChoice::Old
common_types::engines::ForkChoice::Old
}
};
@ -2012,43 +2045,6 @@ mod tests {
}
}
#[test]
fn can_contain_arbitrary_block_sequence() {
let bc = generate_dummy_blockchain(50);
assert_eq!(bc.best_block_number(), 49);
}
#[test]
fn can_collect_garbage() {
let bc = generate_dummy_blockchain(3000);
assert_eq!(bc.best_block_number(), 2999);
let best_hash = bc.best_block_hash();
let mut block_header = bc.block_header_data(&best_hash);
while !block_header.is_none() {
block_header = bc.block_header_data(&block_header.unwrap().parent_hash());
}
assert!(bc.cache_size().blocks > 1024 * 1024);
for _ in 0..2 {
bc.collect_garbage();
}
assert!(bc.cache_size().blocks < 1024 * 1024);
}
#[test]
fn can_contain_arbitrary_block_sequence_with_extra() {
let bc = generate_dummy_blockchain_with_extra(25);
assert_eq!(bc.best_block_number(), 24);
}
#[test]
fn can_contain_only_genesis_block() {
let bc = generate_dummy_empty_blockchain();
assert_eq!(bc.best_block_number(), 0);
}
#[test]
fn find_transaction_by_hash() {
let genesis = "f901fcf901f7a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0af81e09f8c46ca322193edfda764fa7e88e81923f802f1d325ec0b0308ac2cd0a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830200008083023e38808454c98c8142a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421880102030405060708c0c0".from_hex().unwrap();
@ -2369,7 +2365,7 @@ mod tests {
#[test]
fn epoch_transitions_iter() {
use ::engines::EpochTransition;
use common_types::engines::epoch::Transition as EpochTransition;
let genesis = BlockBuilder::genesis();
let next_5 = genesis.add_blocks(5);
@ -2418,7 +2414,7 @@ mod tests {
#[test]
fn epoch_transition_for() {
use ::engines::EpochTransition;
use common_types::engines::epoch::Transition as EpochTransition;
let genesis = BlockBuilder::genesis();
let fork_7 = genesis.add_blocks_with(7, || BlockOptions {

View File

@ -19,51 +19,65 @@
use std::collections::VecDeque;
use ethereum_types::{U256, H256, Bloom};
use header::Header;
use common_types::encoded;
use common_types::header::Header;
use common_types::transaction::SignedTransaction;
use common_types::view;
use common_types::views::BlockView;
use rlp::encode;
use transaction::SignedTransaction;
use views::BlockView;
use encoded;
use rlp_derive::RlpEncodable;
/// Helper structure, used for encoding blocks.
#[derive(Default, Clone, RlpEncodable)]
pub struct Block {
/// Block header
pub header: Header,
/// Block transactions
pub transactions: Vec<SignedTransaction>,
/// Block uncles
pub uncles: Vec<Header>
}
impl Block {
/// Get a copy of the header
#[inline]
pub fn header(&self) -> Header {
self.header.clone()
}
/// Get block hash
#[inline]
pub fn hash(&self) -> H256 {
view!(BlockView, &self.encoded().raw()).header_view().hash()
}
/// Get block number
#[inline]
pub fn number(&self) -> u64 {
self.header.number()
}
/// Get RLP encoding of this block
#[inline]
pub fn encoded(&self) -> encoded::Block {
encoded::Block::new(encode(self))
}
/// Get block difficulty
#[inline]
pub fn difficulty(&self) -> U256 {
*self.header.difficulty()
}
}
/// Specify block options for generator
#[derive(Debug)]
pub struct BlockOptions {
/// Difficulty
pub difficulty: U256,
/// Set bloom filter
pub bloom: Bloom,
/// Transactions included in blocks
pub transactions: Vec<SignedTransaction>,
}
@ -77,12 +91,14 @@ impl Default for BlockOptions {
}
}
/// Utility to create blocks
#[derive(Clone)]
pub struct BlockBuilder {
blocks: VecDeque<Block>,
}
impl BlockBuilder {
/// Create new BlockBuilder starting at genesis.
pub fn genesis() -> Self {
let mut blocks = VecDeque::with_capacity(1);
blocks.push_back(Block::default());
@ -92,21 +108,25 @@ impl BlockBuilder {
}
}
/// Add new block with default options.
#[inline]
pub fn add_block(&self) -> Self {
self.add_block_with(|| BlockOptions::default())
}
/// Add `count` number of blocks with default options.
#[inline]
pub fn add_blocks(&self, count: usize) -> Self {
self.add_blocks_with(count, || BlockOptions::default())
}
/// Add block with specified options.
#[inline]
pub fn add_block_with<T>(&self, get_metadata: T) -> Self where T: Fn() -> BlockOptions {
self.add_blocks_with(1, get_metadata)
}
/// Add a block with given difficulty
#[inline]
pub fn add_block_with_difficulty<T>(&self, difficulty: T) -> Self where T: Into<U256> {
let difficulty = difficulty.into();
@ -116,6 +136,7 @@ impl BlockBuilder {
})
}
/// Add a block with given transactions.
#[inline]
pub fn add_block_with_transactions<T>(&self, transactions: T) -> Self
where T: IntoIterator<Item = SignedTransaction> {
@ -126,6 +147,7 @@ impl BlockBuilder {
})
}
/// Add a block with given bloom filter.
#[inline]
pub fn add_block_with_bloom(&self, bloom: Bloom) -> Self {
self.add_blocks_with(1, move || BlockOptions {
@ -134,6 +156,7 @@ impl BlockBuilder {
})
}
/// Add a bunch of blocks with given metadata.
pub fn add_blocks_with<T>(&self, count: usize, get_metadata: T) -> Self where T: Fn() -> BlockOptions {
assert!(count > 0, "There must be at least 1 block");
let mut parent_hash = self.last().hash();
@ -160,18 +183,21 @@ impl BlockBuilder {
}
}
/// Get a reference to the last generated block.
#[inline]
pub fn last(&self) -> &Block {
self.blocks.back().expect("There is always at least 1 block")
}
}
/// Generates a blockchain from given block builders (blocks will be concatenated).
#[derive(Clone)]
pub struct BlockGenerator {
builders: VecDeque<BlockBuilder>,
}
impl BlockGenerator {
/// Create new block generator.
pub fn new<T>(builders: T) -> Self where T: IntoIterator<Item = BlockBuilder> {
BlockGenerator {
builders: builders.into_iter().collect(),

View File

@ -17,7 +17,7 @@
//! Import route.
use ethereum_types::H256;
use blockchain::block_info::{BlockInfo, BlockLocation};
use crate::block_info::{BlockInfo, BlockLocation};
/// Import route for newly inserted block.
#[derive(Debug, PartialEq, Clone)]
@ -31,6 +31,7 @@ pub struct ImportRoute {
}
impl ImportRoute {
/// Empty import route.
pub fn none() -> Self {
ImportRoute {
retracted: vec![],
@ -68,8 +69,8 @@ impl From<BlockInfo> for ImportRoute {
#[cfg(test)]
mod tests {
use ethereum_types::{H256, U256};
use blockchain::block_info::{BlockInfo, BlockLocation, BranchBecomingCanonChainData};
use blockchain::ImportRoute;
use crate::block_info::{BlockInfo, BlockLocation, BranchBecomingCanonChainData};
use super::ImportRoute;
#[test]
fn import_route_none() {

View File

@ -16,22 +16,22 @@
//! Blockchain database.
#![warn(missing_docs)]
mod best_block;
mod block_info;
mod blockchain;
mod cache;
mod config;
mod extras;
mod import_route;
mod update;
#[cfg(test)]
pub mod generator;
pub use self::blockchain::{BlockProvider, BlockChain, BlockChainDB, BlockChainDBHandler};
pub use self::cache::CacheSize;
pub use self::config::Config;
pub use self::extras::{BlockReceipts, BlockDetails, TransactionAddress};
pub use self::import_route::ImportRoute;
pub use self::update::ExtrasInsert;
pub use types::tree_route::TreeRoute;
pub use ethcore_db::keys::{BlockReceipts, BlockDetails, TransactionAddress};
pub use common_types::tree_route::TreeRoute;

View File

@ -15,11 +15,14 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use std::collections::HashMap;
use common_types::BlockNumber;
use common_types::encoded::Block;
use common_types::engines::ForkChoice;
use ethcore_db::keys::{BlockDetails, BlockReceipts, TransactionAddress};
use ethereum_types::{H256, Bloom};
use header::BlockNumber;
use blockchain::block_info::BlockInfo;
use blockchain::extras::{BlockDetails, BlockReceipts, TransactionAddress};
use encoded::Block;
use crate::block_info::BlockInfo;
/// Block extras update info.
pub struct ExtrasUpdate {
@ -42,7 +45,7 @@ pub struct ExtrasUpdate {
/// Extra information in block insertion.
pub struct ExtrasInsert {
/// The primitive fork choice before applying finalization rules.
pub fork_choice: ::engines::ForkChoice,
pub fork_choice: ForkChoice,
/// Is the inserted block considered finalized.
pub is_finalized: bool,
}

17
ethcore/db/Cargo.toml Normal file
View File

@ -0,0 +1,17 @@
[package]
description = "Ethcore DB access utilities"
homepage = "http://parity.io"
license = "GPL-3.0"
name = "ethcore-db"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
common-types = { path = "../types" }
ethereum-types = "0.4"
heapsize = "0.4"
kvdb = "0.1"
parking_lot = "0.7"
rlp = { version = "0.3.0", features = ["ethereum"] }
rlp_derive = { path = "../../util/rlp-derive" }

View File

@ -14,11 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
//! Database cache manager
use std::collections::{VecDeque, HashSet};
use std::hash::Hash;
const COLLECTION_QUEUE_SIZE: usize = 8;
/// DB cache manager
pub struct CacheManager<T> {
pref_cache_size: usize,
max_cache_size: usize,
@ -27,6 +30,7 @@ pub struct CacheManager<T> {
}
impl<T> CacheManager<T> where T: Eq + Hash {
/// Create new cache manager with preferred (heap) sizes.
pub fn new(pref_cache_size: usize, max_cache_size: usize, bytes_per_cache_entry: usize) -> Self {
CacheManager {
pref_cache_size: pref_cache_size,
@ -36,6 +40,7 @@ impl<T> CacheManager<T> where T: Eq + Hash {
}
}
/// Mark element as used.
pub fn note_used(&mut self, id: T) {
if !self.cache_usage[0].contains(&id) {
if let Some(c) = self.cache_usage.iter_mut().skip(1).find(|e| e.contains(&id)) {

View File

@ -19,14 +19,16 @@
use std::io::Write;
use std::ops;
use db::Key;
use engines::epoch::{Transition as EpochTransition};
use common_types::BlockNumber;
use common_types::engines::epoch::Transition as EpochTransition;
use common_types::receipt::Receipt;
use ethereum_types::{H256, H264, U256};
use header::BlockNumber;
use heapsize::HeapSizeOf;
use kvdb::PREFIX_LEN as DB_PREFIX_LEN;
use receipt::Receipt;
use rlp;
use rlp_derive::{RlpEncodableWrapper, RlpDecodableWrapper, RlpEncodable, RlpDecodable};
use crate::db::Key;
/// Represents index of extra data in database
#[derive(Copy, Debug, Hash, Eq, PartialEq, Clone)]
@ -52,6 +54,7 @@ fn with_index(hash: &H256, i: ExtrasIndex) -> H264 {
result
}
/// Wrapper for block number used as a DB key.
pub struct BlockNumberKey([u8; 5]);
impl ops::Deref for BlockNumberKey {
@ -100,7 +103,7 @@ impl Key<BlockReceipts> for H256 {
}
}
impl Key<::engines::epoch::PendingTransition> for H256 {
impl Key<common_types::engines::epoch::PendingTransition> for H256 {
type Target = H264;
fn key(&self) -> H264 {
@ -117,6 +120,7 @@ pub const EPOCH_KEY_PREFIX: &'static [u8; DB_PREFIX_LEN] = &[
ExtrasIndex::EpochTransitions as u8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
];
/// Epoch transitions key
pub struct EpochTransitionsKey([u8; EPOCH_KEY_LEN]);
impl ops::Deref for EpochTransitionsKey {
@ -217,10 +221,12 @@ impl HeapSizeOf for TransactionAddress {
/// Contains all block receipts.
#[derive(Clone, RlpEncodableWrapper, RlpDecodableWrapper)]
pub struct BlockReceipts {
/// Block receipts
pub receipts: Vec<Receipt>,
}
impl BlockReceipts {
/// Create new block receipts wrapper.
pub fn new(receipts: Vec<Receipt>) -> Self {
BlockReceipts {
receipts: receipts
@ -237,7 +243,9 @@ impl HeapSizeOf for BlockReceipts {
/// Candidate transitions to an epoch with specific number.
#[derive(Clone, RlpEncodable, RlpDecodable)]
pub struct EpochTransitions {
/// Epoch number
pub number: u64,
/// List of candidate transitions
pub candidates: Vec<EpochTransition>,
}

26
ethcore/db/src/lib.rs Normal file
View File

@ -0,0 +1,26 @@
// Copyright 2015-2018 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/>.
//! Parity Ethereum database access utilities.
#![warn(missing_docs)]
mod db;
pub mod keys;
pub mod cache_manager;
pub use self::db::*;

View File

@ -8,9 +8,11 @@ authors = ["Parity Technologies <admin@parity.io>"]
[dependencies]
log = "0.4"
ethcore = { path = ".."}
parity-bytes = "0.1"
ethcore-transaction = { path = "../transaction" }
common-types = { path = "../types" }
ethcore = { path = ".."}
ethcore-db = { path = "../db" }
ethcore-blockchain = { path = "../blockchain" }
ethereum-types = "0.4"
memorydb = "0.3.0"
patricia-trie = "0.3.0"

View File

@ -20,15 +20,15 @@
//! Furthermore, stores a "gas price corpus" of relative recency, which is a sorted
//! vector of all gas prices from a recent range of blocks.
use ethcore::encoded;
use ethcore::header::BlockNumber;
use ethcore::receipt::Receipt;
use stats::Corpus;
use std::time::{Instant, Duration};
use heapsize::HeapSizeOf;
use common_types::encoded;
use common_types::BlockNumber;
use common_types::receipt::Receipt;
use ethereum_types::{H256, U256};
use heapsize::HeapSizeOf;
use memory_cache::MemoryLruCache;
use stats::Corpus;
/// Configuration for how much data to cache.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]

View File

@ -23,7 +23,7 @@
//! root has. A correct proof implies that the claimed block is identical to the one
//! we discarded.
use ethcore::ids::BlockId;
use common_types::ids::BlockId;
use ethereum_types::{H256, U256};
use hashdb::HashDB;
use keccak_hasher::KeccakHasher;

View File

@ -18,13 +18,13 @@
use std::sync::Arc;
use ethcore::encoded;
use common_types::encoded;
use common_types::header::Header;
use common_types::receipt::Receipt;
use ethcore::engines::{EthEngine, StateDependentProof};
use ethcore::machine::EthereumMachine;
use ethcore::header::Header;
use ethcore::receipt::Receipt;
use futures::future::IntoFuture;
use ethereum_types::H256;
use futures::future::IntoFuture;
/// Provides full chain data.
pub trait ChainDataFetcher: Send + Sync + 'static {

View File

@ -30,12 +30,12 @@ use std::sync::Arc;
use cache::Cache;
use cht;
use ethcore::block_status::BlockStatus;
use ethcore::encoded;
use common_types::block_status::BlockStatus;
use common_types::encoded;
use common_types::header::Header;
use common_types::ids::BlockId;
use ethcore::engines::epoch::{Transition as EpochTransition, PendingTransition as PendingEpochTransition};
use ethcore::error::{Error, EthcoreResult, ErrorKind as EthcoreErrorKind, BlockError};
use ethcore::header::Header;
use ethcore::ids::BlockId;
use ethcore::spec::{Spec, SpecHardcodedSync};
use ethereum_types::{H256, H264, U256};
use heapsize::HeapSizeOf;
@ -862,11 +862,11 @@ mod tests {
use super::{HeaderChain, HardcodedSync};
use std::sync::Arc;
use ethereum_types::U256;
use ethcore::ids::BlockId;
use ethcore::header::Header;
use ethcore::spec::Spec;
use cache::Cache;
use common_types::header::Header;
use common_types::ids::BlockId;
use ethcore::spec::Spec;
use ethereum_types::U256;
use kvdb::KeyValueDB;
use kvdb_memorydb;

View File

@ -18,21 +18,22 @@
use std::sync::{Weak, Arc};
use ethcore::block_status::BlockStatus;
use ethcore::client::{ClientReport, EnvInfo, ClientIoMessage};
use ethcore::engines::{epoch, EthEngine, EpochChange, EpochTransition, Proof};
use ethcore::machine::EthereumMachine;
use ethcore::error::{Error, EthcoreResult};
use ethcore::ids::BlockId;
use ethcore::header::{BlockNumber, Header};
use ethcore::verification::queue::{self, HeaderQueue};
use ethcore::blockchain_info::BlockChainInfo;
use ethcore::spec::{Spec, SpecHardcodedSync};
use ethcore::encoded;
use io::IoChannel;
use parking_lot::{Mutex, RwLock};
use ethereum_types::{H256, U256};
use futures::{IntoFuture, Future};
use common_types::BlockNumber;
use common_types::block_status::BlockStatus;
use common_types::blockchain_info::BlockChainInfo;
use common_types::encoded;
use common_types::header::Header;
use common_types::ids::BlockId;
use kvdb::KeyValueDB;

View File

@ -20,8 +20,9 @@
use std::fmt;
use std::sync::Arc;
use ethcore_db as db;
use ethcore_blockchain::BlockChainDB;
use ethcore::client::ClientIoMessage;
use ethcore::{db, BlockChainDB};
use ethcore::error::Error as CoreError;
use ethcore::spec::Spec;
use io::{IoContext, IoError, IoHandler, IoService};

View File

@ -54,10 +54,12 @@ extern crate serde_derive;
extern crate log;
extern crate bincode;
extern crate common_types;
extern crate ethcore_blockchain;
extern crate ethcore_db;
extern crate ethcore_io as io;
extern crate ethcore_network as network;
extern crate parity_bytes as bytes;
extern crate ethcore_transaction as transaction;
extern crate ethereum_types;
extern crate ethcore;
extern crate hashdb;

View File

@ -18,8 +18,7 @@
//!
//! This uses a "Provider" to answer requests.
use transaction::UnverifiedTransaction;
use common_types::transaction::UnverifiedTransaction;
use ethereum_types::{H256, U256};
use io::TimerToken;
use kvdb::DBValue;

View File

@ -17,21 +17,21 @@
//! Tests for the `LightProtocol` implementation.
//! These don't test of the higher level logic on top of
use ethcore::blockchain_info::BlockChainInfo;
use common_types::blockchain_info::BlockChainInfo;
use common_types::encoded;
use common_types::ids::BlockId;
use common_types::transaction::{Action, PendingTransaction};
use ethcore::client::{EachBlockWith, TestBlockChainClient};
use ethcore::encoded;
use ethcore::ids::BlockId;
use ethereum_types::{H256, U256, Address};
use net::{LightProtocol, Params, packet, Peer, Statistics};
use net::context::IoContext;
use net::status::{Capabilities, Status};
use net::load_timer::MOVING_SAMPLE_SIZE;
use net::status::{Capabilities, Status};
use net::{LightProtocol, Params, packet, Peer, Statistics};
use network::{PeerId, NodeId};
use provider::Provider;
use request;
use request::*;
use request;
use rlp::{Rlp, RlpStream};
use transaction::{Action, PendingTransaction};
use std::sync::Arc;
use std::time::Instant;

View File

@ -20,11 +20,12 @@ use std::cmp;
use std::sync::Arc;
use bytes::Bytes;
use ethcore::basic_account::BasicAccount;
use ethcore::encoded;
use common_types::basic_account::BasicAccount;
use common_types::encoded;
use common_types::receipt::Receipt;
use common_types::transaction::SignedTransaction;
use ethcore::engines::{EthEngine, StateDependentProof};
use ethcore::machine::EthereumMachine;
use ethcore::receipt::Receipt;
use ethcore::state::{self, ProvedExecution};
use ethereum_types::{H256, U256, Address};
use ethtrie::{TrieError, TrieDB};
@ -35,7 +36,6 @@ use memorydb::MemoryDB;
use parking_lot::Mutex;
use request::{self as net_request, IncompleteRequest, CompleteRequest, Output, OutputKind, Field};
use rlp::{RlpStream, Rlp};
use transaction::SignedTransaction;
use trie::Trie;
use vm::EnvInfo;
@ -1108,10 +1108,10 @@ mod tests {
use trie::Recorder;
use hash::keccak;
use ::ethcore::client::{BlockChainClient, BlockInfo, TestBlockChainClient, EachBlockWith};
use ethcore::header::Header;
use ethcore::encoded;
use ethcore::receipt::{Receipt, TransactionOutcome};
use ethcore::client::{BlockChainClient, BlockInfo, TestBlockChainClient, EachBlockWith};
use common_types::header::Header;
use common_types::encoded;
use common_types::receipt::{Receipt, TransactionOutcome};
fn make_cache() -> ::cache::Cache {
::cache::Cache::new(Default::default(), Duration::from_secs(1))

View File

@ -17,13 +17,13 @@
//! Tests for the on-demand service.
use cache::Cache;
use ethcore::header::Header;
use futures::Future;
use network::{PeerId, NodeId};
use net::*;
use common_types::header::Header;
use ethereum_types::H256;
use parking_lot::Mutex;
use ::request::{self as basic_request, Response};
use request::{self as basic_request, Response};
use std::sync::Arc;
use std::time::{Duration, Instant};

View File

@ -19,13 +19,13 @@
use std::sync::Arc;
use ethcore::blockchain_info::BlockChainInfo;
use common_types::blockchain_info::BlockChainInfo;
use common_types::encoded;
use common_types::ids::BlockId;
use common_types::transaction::PendingTransaction;
use ethcore::client::{BlockChainClient, ProvingBlockChainClient, ChainInfo, BlockInfo as ClientBlockInfo};
use ethcore::ids::BlockId;
use ethcore::encoded;
use ethereum_types::H256;
use parking_lot::RwLock;
use transaction::PendingTransaction;
use cht::{self, BlockInfo};
use client::{LightChainClient, AsLightClient};
@ -161,7 +161,7 @@ impl<T: ProvingBlockChainClient + ?Sized> Provider for T {
fn transaction_index(&self, req: request::CompleteTransactionIndexRequest)
-> Option<request::TransactionIndexResponse>
{
use ethcore::ids::TransactionId;
use common_types::ids::TransactionId;
self.transaction_receipt(TransactionId::Hash(req.hash)).map(|receipt| request::TransactionIndexResponse {
num: receipt.block_number,
@ -265,7 +265,7 @@ impl<T: ProvingBlockChainClient + ?Sized> Provider for T {
}
fn transaction_proof(&self, req: request::CompleteExecutionRequest) -> Option<request::ExecutionResponse> {
use transaction::Transaction;
use common_types::transaction::Transaction;
let id = BlockId::Hash(req.block_hash);
let nonce = match self.nonce(&req.from, id) {

View File

@ -27,7 +27,7 @@ use std::fmt;
use std::collections::{BTreeMap, HashMap};
use std::collections::hash_map::Entry;
use transaction::{self, Condition, PendingTransaction, SignedTransaction};
use common_types::transaction::{self, Condition, PendingTransaction, SignedTransaction};
use ethereum_types::{H256, U256, Address};
use fastmap::H256FastMap;
@ -370,7 +370,7 @@ impl TransactionQueue {
mod tests {
use super::TransactionQueue;
use ethereum_types::Address;
use transaction::{Transaction, PendingTransaction, Condition};
use common_types::transaction::{Transaction, PendingTransaction, Condition};
#[test]
fn queued_senders() {

View File

@ -670,7 +670,7 @@ pub trait ResponseLike {
/// Header request.
pub mod header {
use super::{Field, HashOrNumber, NoSuchOutput, OutputKind, Output};
use ethcore::encoded;
use common_types::encoded;
use rlp::{Encodable, Decodable, DecoderError, RlpStream, Rlp};
/// Potentially incomplete headers request.
@ -753,7 +753,7 @@ pub mod header {
impl Decodable for Response {
fn decode(rlp: &Rlp) -> Result<Self, DecoderError> {
use ethcore::header::Header as FullHeader;
use common_types::header::Header as FullHeader;
let mut headers = Vec::new();
@ -954,7 +954,7 @@ pub mod transaction_index {
/// Request and response for block receipts
pub mod block_receipts {
use super::{Field, NoSuchOutput, OutputKind, Output};
use ethcore::receipt::Receipt;
use common_types::receipt::Receipt;
use ethereum_types::H256;
/// Potentially incomplete block receipts request.
@ -1022,7 +1022,7 @@ pub mod block_receipts {
/// Request and response for a block body
pub mod block_body {
use super::{Field, NoSuchOutput, OutputKind, Output};
use ethcore::encoded;
use common_types::encoded;
use rlp::{Encodable, Decodable, DecoderError, RlpStream, Rlp};
use ethereum_types::H256;
@ -1089,8 +1089,8 @@ pub mod block_body {
impl Decodable for Response {
fn decode(rlp: &Rlp) -> Result<Self, DecoderError> {
use ethcore::header::Header as FullHeader;
use transaction::UnverifiedTransaction;
use common_types::header::Header as FullHeader;
use common_types::transaction::UnverifiedTransaction;
// check body validity.
let _: Vec<UnverifiedTransaction> = rlp.list_at(0)?;
@ -1406,7 +1406,7 @@ pub mod contract_code {
/// A request for proof of execution.
pub mod execution {
use super::{Field, NoSuchOutput, OutputKind, Output};
use transaction::Action;
use common_types::transaction::Action;
use rlp::{Encodable, Decodable, DecoderError, RlpStream, Rlp};
use ethereum_types::{H256, U256, Address};
use kvdb::DBValue;
@ -1629,7 +1629,7 @@ pub mod epoch_signal {
#[cfg(test)]
mod tests {
use super::*;
use ethcore::header::Header;
use common_types::header::Header;
fn check_roundtrip<T>(val: T)
where T: ::rlp::Encodable + ::rlp::Decodable + PartialEq + ::std::fmt::Debug
@ -1676,7 +1676,7 @@ mod tests {
let full_req = Request::Headers(req.clone());
let res = HeadersResponse {
headers: vec![
::ethcore::encoded::Header::new(::rlp::encode(&Header::default()))
::common_types::encoded::Header::new(::rlp::encode(&Header::default()))
]
};
let full_res = Response::Headers(res.clone());
@ -1729,7 +1729,7 @@ mod tests {
#[test]
fn receipts_roundtrip() {
use ethcore::receipt::{Receipt, TransactionOutcome};
use common_types::receipt::{Receipt, TransactionOutcome};
let req = IncompleteReceiptsRequest {
hash: Field::Scalar(Default::default()),
};
@ -1749,7 +1749,7 @@ mod tests {
#[test]
fn body_roundtrip() {
use transaction::{Transaction, UnverifiedTransaction};
use common_types::transaction::{Transaction, UnverifiedTransaction};
let req = IncompleteBodyRequest {
hash: Field::Scalar(Default::default()),
};
@ -1757,13 +1757,13 @@ mod tests {
let full_req = Request::Body(req.clone());
let res = BodyResponse {
body: {
let header = ::ethcore::header::Header::default();
let header = ::common_types::header::Header::default();
let tx = UnverifiedTransaction::from(Transaction::default().fake_sign(Default::default()));
let mut stream = RlpStream::new_list(2);
stream.begin_list(2).append(&tx).append(&tx)
.begin_list(1).append(&header);
::ethcore::encoded::Body::new(stream.out())
::common_types::encoded::Body::new(stream.out())
},
};
let full_res = Response::Body(res.clone());
@ -1844,7 +1844,7 @@ mod tests {
let req = IncompleteExecutionRequest {
block_hash: Field::Scalar(Default::default()),
from: Default::default(),
action: ::transaction::Action::Create,
action: ::common_types::transaction::Action::Create,
gas: 100_000.into(),
gas_price: 0.into(),
value: 100_000_001.into(),
@ -1874,7 +1874,7 @@ mod tests {
let reqs: Vec<_> = (0..10).map(|_| IncompleteExecutionRequest {
block_hash: Field::Scalar(Default::default()),
from: Default::default(),
action: ::transaction::Action::Create,
action: ::common_types::transaction::Action::Create,
gas: 100_000.into(),
gas_price: 0.into(),
value: 100_000_001.into(),
@ -1892,11 +1892,11 @@ mod tests {
#[test]
fn responses_vec() {
use ethcore::receipt::{Receipt, TransactionOutcome};
use common_types::receipt::{Receipt, TransactionOutcome};
let mut stream = RlpStream::new_list(2);
stream.begin_list(0).begin_list(0);
let body = ::ethcore::encoded::Body::new(stream.out());
let body = ::common_types::encoded::Body::new(stream.out());
let reqs = vec![
Response::Headers(HeadersResponse { headers: vec![] }),
Response::HeaderProof(HeaderProofResponse { proof: vec![], hash: Default::default(), td: 100.into()}),

View File

@ -6,17 +6,15 @@ license = "GPL-3.0"
authors = ["Parity Technologies <admin@parity.io>"]
[dependencies]
common-types = { path = "../types" }
error-chain = { version = "0.12", default-features = false }
ethabi = "6.0"
ethabi-derive = "6.0"
ethabi-contract = "6.0"
ethabi-derive = "6.0"
ethcore = { path = ".." }
parity-bytes = "0.1"
parity-crypto = "0.2"
ethcore-io = { path = "../../util/io" }
ethcore-logger = { path = "../../logger" }
ethcore-miner = { path = "../../miner" }
ethcore-transaction = { path = "../transaction" }
ethereum-types = "0.4"
ethjson = { path = "../../json" }
ethkey = { path = "../../accounts/ethkey" }
@ -25,6 +23,8 @@ futures = "0.1"
heapsize = "0.4"
keccak-hash = "0.1.2"
log = "0.4"
parity-bytes = "0.1"
parity-crypto = "0.2"
parking_lot = "0.7"
patricia-trie = "0.3.0"
patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" }

View File

@ -19,7 +19,7 @@ use rlp::DecoderError;
use ethtrie::TrieError;
use ethcore::account_provider::SignError;
use ethcore::error::{Error as EthcoreError, ExecutionError};
use transaction::Error as TransactionError;
use types::transaction::Error as TransactionError;
use ethkey::Error as KeyError;
use txpool::Error as TxPoolError;

View File

@ -25,27 +25,27 @@ mod private_transactions;
mod messages;
mod error;
extern crate common_types as types;
extern crate ethabi;
extern crate ethcore;
extern crate parity_bytes as bytes;
extern crate parity_crypto as crypto;
extern crate ethcore_io as io;
extern crate ethcore_miner;
extern crate ethcore_transaction as transaction;
extern crate ethabi;
extern crate ethereum_types;
extern crate ethkey;
extern crate ethjson;
extern crate ethkey;
extern crate fetch;
extern crate futures;
extern crate heapsize;
extern crate keccak_hash as hash;
extern crate parity_bytes as bytes;
extern crate parity_crypto as crypto;
extern crate parking_lot;
extern crate patricia_trie as trie;
extern crate transaction_pool as txpool;
extern crate patricia_trie_ethereum as ethtrie;
extern crate rlp;
extern crate url;
extern crate rustc_hex;
extern crate transaction_pool as txpool;
extern crate url;
#[macro_use]
extern crate log;
#[macro_use]
@ -78,7 +78,7 @@ use ethkey::{Signature, recover, public_to_address};
use io::IoChannel;
use ethcore::executive::{Executive, TransactOptions};
use ethcore::executed::{Executed};
use transaction::{SignedTransaction, Transaction, Action, UnverifiedTransaction};
use types::transaction::{SignedTransaction, Transaction, Action, UnverifiedTransaction};
use ethcore::{contract_address as ethcore_contract_address};
use ethcore::client::{
Client, ChainNotify, NewBlocks, ChainMessageType, ClientIoMessage, BlockId,

View File

@ -19,7 +19,7 @@ use bytes::Bytes;
use hash::keccak;
use rlp::Encodable;
use ethkey::Signature;
use transaction::signature::{add_chain_replay_protection, check_replay_protection};
use types::transaction::signature::{add_chain_replay_protection, check_replay_protection};
/// Message with private transaction encrypted
#[derive(Default, Debug, Clone, PartialEq, RlpEncodable, RlpDecodable, Eq)]

View File

@ -25,7 +25,7 @@ use heapsize::HeapSizeOf;
use ethkey::Signature;
use messages::PrivateTransaction;
use parking_lot::RwLock;
use transaction::{UnverifiedTransaction, SignedTransaction};
use types::transaction::{UnverifiedTransaction, SignedTransaction};
use txpool;
use txpool::{VerifiedTransaction, Verifier};
use error::{Error, ErrorKind};

View File

@ -16,14 +16,14 @@
//! Contract for private transactions tests.
extern crate rustc_hex;
extern crate common_types as types;
extern crate ethcore;
extern crate ethkey;
extern crate keccak_hash as hash;
extern crate ethcore_io;
extern crate ethcore_logger;
extern crate ethcore_private_tx;
extern crate ethcore_transaction;
extern crate ethkey;
extern crate keccak_hash as hash;
extern crate rustc_hex;
#[macro_use]
extern crate log;
@ -31,14 +31,14 @@ extern crate log;
use std::sync::Arc;
use rustc_hex::FromHex;
use types::ids::BlockId;
use types::transaction::{Transaction, Action};
use ethcore::CreateContractAddress;
use ethcore::account_provider::AccountProvider;
use ethcore::client::BlockChainClient;
use ethcore::client::BlockId;
use ethcore::executive::{contract_address};
use ethcore::miner::Miner;
use ethcore::test_helpers::{generate_dummy_client, push_block_with_transactions};
use ethcore_transaction::{Transaction, Action};
use ethkey::{Secret, KeyPair, Signature};
use hash::keccak;

View File

@ -7,6 +7,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
ansi_term = "0.10"
error-chain = { version = "0.12", default-features = false }
ethcore = { path = ".." }
ethcore-blockchain = { path = "../blockchain" }
ethcore-io = { path = "../../util/io" }
ethcore-private-tx = { path = "../private-tx" }
ethcore-sync = { path = "../sync" }
@ -16,6 +17,7 @@ log = "0.4"
trace-time = "0.1"
[dev-dependencies]
ethcore-db = { path = "../db" }
ethcore = { path = "..", features = ["test-helpers"] }
tempdir = "0.3"
kvdb-rocksdb = "0.1.3"

View File

@ -16,6 +16,7 @@
extern crate ansi_term;
extern crate ethcore;
extern crate ethcore_blockchain as blockchain;
extern crate ethcore_io as io;
extern crate ethcore_private_tx;
extern crate ethcore_sync as sync;
@ -24,16 +25,17 @@ extern crate kvdb;
#[macro_use]
extern crate error_chain;
#[macro_use]
extern crate log;
#[macro_use]
extern crate trace_time;
#[cfg(test)]
extern crate ethcore_db;
#[cfg(test)]
extern crate tempdir;
mod error;
mod service;
mod stop_guard;

View File

@ -26,7 +26,7 @@ use io::{IoContext, TimerToken, IoHandler, IoService, IoError};
use stop_guard::StopGuard;
use sync::PrivateTxHandler;
use ethcore::{BlockChainDB, BlockChainDBHandler};
use blockchain::{BlockChainDB, BlockChainDBHandler};
use ethcore::client::{Client, ClientConfig, ChainNotify, ClientIoMessage};
use ethcore::miner::Miner;
use ethcore::snapshot::service::{Service as SnapshotService, ServiceParams as SnapServiceParams};
@ -275,11 +275,11 @@ mod tests {
use tempdir::TempDir;
use ethcore_db::NUM_COLUMNS;
use ethcore::account_provider::AccountProvider;
use ethcore::client::ClientConfig;
use ethcore::miner::Miner;
use ethcore::spec::Spec;
use ethcore::db::NUM_COLUMNS;
use ethcore::test_helpers;
use kvdb_rocksdb::{DatabaseConfig, CompactionProfile};
use super::*;

View File

@ -32,11 +32,11 @@ use ethstore::{
random_string, SecretVaultRef, StoreAccountRef, OpaqueSecret,
};
use parking_lot::RwLock;
use types::transaction::{Action, Transaction};
pub use ethstore::ethkey::Signature;
pub use ethstore::{Derivation, IndexDerivation, KeyFile};
pub use hardware_wallet::{Error as HardwareError, HardwareWalletManager, KeyPath, TransactionInfo};
pub use super::transaction::{Action, Transaction};
/// Type of unlock.
#[derive(Clone, PartialEq)]

View File

@ -36,59 +36,58 @@ use std::collections::HashSet;
use std::sync::Arc;
use bytes::Bytes;
use ethereum_types::{H256, U256, Address, Bloom};
use engines::EthEngine;
use error::{Error, BlockError};
use ethereum_types::{H256, U256, Address, Bloom};
use factory::Factories;
use hash::keccak;
use header::{Header, ExtendedHeader};
use receipt::{Receipt, TransactionOutcome};
use rlp::{Rlp, RlpStream, Encodable, Decodable, DecoderError, encode_list};
use state_db::StateDB;
use state::State;
use trace::Tracing;
use transaction::{UnverifiedTransaction, SignedTransaction, Error as TransactionError};
use triehash::ordered_trie_root;
use unexpected::{Mismatch, OutOfBounds};
use verification::PreverifiedBlock;
use vm::{EnvInfo, LastHashes};
/// A block, encoded as it is on the block chain.
#[derive(Default, Debug, Clone, PartialEq)]
pub struct Block {
/// The header of this block.
pub header: Header,
/// The transactions in this block.
pub transactions: Vec<UnverifiedTransaction>,
/// The uncles of this block.
pub uncles: Vec<Header>,
use hash::keccak;
use rlp::{RlpStream, Encodable, encode_list};
use types::transaction::{SignedTransaction, Error as TransactionError};
use types::block::Block;
use types::header::{Header, ExtendedHeader};
use types::receipt::{Receipt, TransactionOutcome};
/// Block that is ready for transactions to be added.
///
/// It's a bit like a Vec<Transaction>, except that whenever a transaction is pushed, we execute it and
/// maintain the system `state()`. We also archive execution receipts in preparation for later block creation.
pub struct OpenBlock<'x> {
block: ExecutedBlock,
engine: &'x EthEngine,
}
impl Block {
/// Get the RLP-encoding of the block with the seal.
pub fn rlp_bytes(&self) -> Bytes {
let mut block_rlp = RlpStream::new_list(3);
block_rlp.append(&self.header);
block_rlp.append_list(&self.transactions);
block_rlp.append_list(&self.uncles);
block_rlp.out()
}
/// Just like `OpenBlock`, except that we've applied `Engine::on_close_block`, finished up the non-seal header fields,
/// and collected the uncles.
///
/// There is no function available to push a transaction.
#[derive(Clone)]
pub struct ClosedBlock {
block: ExecutedBlock,
unclosed_state: State<StateDB>,
}
impl Decodable for Block {
fn decode(rlp: &Rlp) -> Result<Self, DecoderError> {
if rlp.as_raw().len() != rlp.payload_info()?.total() {
return Err(DecoderError::RlpIsTooBig);
}
if rlp.item_count()? != 3 {
return Err(DecoderError::RlpIncorrectListLen);
}
Ok(Block {
header: rlp.val_at(0)?,
transactions: rlp.list_at(1)?,
uncles: rlp.list_at(2)?,
})
}
/// Just like `ClosedBlock` except that we can't reopen it and it's faster.
///
/// We actually store the post-`Engine::on_close_block` state, unlike in `ClosedBlock` where it's the pre.
#[derive(Clone)]
pub struct LockedBlock {
block: ExecutedBlock,
}
/// A block that has a valid seal.
///
/// The block's header has valid seal arguments. The block cannot be reversed into a `ClosedBlock` or `OpenBlock`.
pub struct SealedBlock {
block: ExecutedBlock,
}
/// An internal type for a block's common elements.
@ -216,40 +215,6 @@ impl ::parity_machine::Transactions for ExecutedBlock {
}
}
/// Block that is ready for transactions to be added.
///
/// It's a bit like a Vec<Transaction>, except that whenever a transaction is pushed, we execute it and
/// maintain the system `state()`. We also archive execution receipts in preparation for later block creation.
pub struct OpenBlock<'x> {
block: ExecutedBlock,
engine: &'x EthEngine,
}
/// Just like `OpenBlock`, except that we've applied `Engine::on_close_block`, finished up the non-seal header fields,
/// and collected the uncles.
///
/// There is no function available to push a transaction.
#[derive(Clone)]
pub struct ClosedBlock {
block: ExecutedBlock,
unclosed_state: State<StateDB>,
}
/// Just like `ClosedBlock` except that we can't reopen it and it's faster.
///
/// We actually store the post-`Engine::on_close_block` state, unlike in `ClosedBlock` where it's the pre.
#[derive(Clone)]
pub struct LockedBlock {
block: ExecutedBlock,
}
/// A block that has a valid seal.
///
/// The block's header has valid seal arguments. The block cannot be reversed into a `ClosedBlock` or `OpenBlock`.
pub struct SealedBlock {
block: ExecutedBlock,
}
impl<'x> OpenBlock<'x> {
/// Create a new `OpenBlock` ready for transaction pushing.
pub fn new<'a>(
@ -630,14 +595,15 @@ mod tests {
use engines::EthEngine;
use vm::LastHashes;
use error::Error;
use header::Header;
use factory::Factories;
use state_db::StateDB;
use views::BlockView;
use ethereum_types::Address;
use std::sync::Arc;
use transaction::SignedTransaction;
use verification::queue::kind::blocks::Unverified;
use types::transaction::SignedTransaction;
use types::header::Header;
use types::view;
use types::views::BlockView;
/// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header
fn enact_bytes(

View File

@ -18,13 +18,13 @@
use std::sync::Arc;
use blockchain::BlockChain;
use engines::{EthEngine, EpochVerifier};
use header::Header;
use machine::EthereumMachine;
use rand::Rng;
use blockchain::BlockChain;
use parking_lot::RwLock;
use rand::Rng;
use types::header::Header;
// do "heavy" verification on ~1/50 blocks, randomly sampled.
const HEAVY_VERIFY_RATE: f32 = 0.02;

View File

@ -16,7 +16,7 @@
use bytes::Bytes;
use ethereum_types::{H256, U256};
use transaction::UnverifiedTransaction;
use types::transaction::UnverifiedTransaction;
use blockchain::ImportRoute;
use std::time::Duration;
use std::collections::HashMap;

View File

@ -14,25 +14,36 @@
// 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::collections::{HashSet, BTreeMap, VecDeque};
use std::cmp;
use std::collections::{HashSet, BTreeMap, VecDeque};
use std::str::FromStr;
use std::sync::atomic::{AtomicUsize, AtomicBool, Ordering as AtomicOrdering};
use std::sync::{Arc, Weak};
use std::time::{Instant, Duration};
// util
use hash::keccak;
use blockchain::{BlockReceipts, BlockChain, BlockChainDB, BlockProvider, TreeRoute, ImportRoute, TransactionAddress, ExtrasInsert};
use bytes::Bytes;
use ethcore_miner::pool::VerifiedTransaction;
use ethereum_types::{H256, Address, U256};
use evm::Schedule;
use hash::keccak;
use io::IoChannel;
use itertools::Itertools;
use journaldb;
use trie::{TrieSpec, TrieFactory, Trie};
use kvdb::{DBValue, KeyValueDB, DBTransaction};
use parking_lot::{Mutex, RwLock};
use rand::OsRng;
use types::transaction::{self, LocalizedTransaction, UnverifiedTransaction, SignedTransaction, Action};
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, ExtendedHeader}};
use vm::{EnvInfo, LastHashes};
// other
use ethereum_types::{H256, Address, U256};
use block::{IsBlock, LockedBlock, Drain, ClosedBlock, OpenBlock, enact_verified, SealedBlock};
use blockchain::{BlockReceipts, BlockChain, BlockChainDB, BlockProvider, TreeRoute, ImportRoute, TransactionAddress, ExtrasInsert};
use client::ancient_import::AncientVerifier;
use client::{
Nonce, Balance, ChainInfo, BlockInfo, CallContract, TransactionInfo,
@ -48,37 +59,24 @@ use client::{
IoClient, BadBlocks,
};
use client::bad_blocks;
use encoded;
use engines::{EthEngine, EpochTransition, ForkChoice};
use error::{
ImportErrorKind, ExecutionError, CallError, BlockError,
QueueError, QueueErrorKind, Error as EthcoreError, EthcoreResult, ErrorKind as EthcoreErrorKind
};
use vm::{EnvInfo, LastHashes};
use evm::Schedule;
use executive::{Executive, Executed, TransactOptions, contract_address};
use factory::{Factories, VmFactory};
use header::{BlockNumber, Header, ExtendedHeader};
use io::IoChannel;
use log_entry::LocalizedLogEntry;
use miner::{Miner, MinerService};
use ethcore_miner::pool::VerifiedTransaction;
use parking_lot::{Mutex, RwLock};
use rand::OsRng;
use receipt::{Receipt, LocalizedReceipt};
use snapshot::{self, io as snapshot_io, SnapshotClient};
use spec::Spec;
use state_db::StateDB;
use state::{self, State};
use trace;
use trace::{TraceDB, ImportRequest as TraceImportRequest, LocalizedTrace, Database as TraceDatabase};
use transaction::{self, LocalizedTransaction, UnverifiedTransaction, SignedTransaction, Transaction, Action};
use types::filter::Filter;
use types::ancestry_action::AncestryAction;
use verification;
use verification::{PreverifiedBlock, Verifier, BlockQueue};
use verification::queue::kind::blocks::Unverified;
use state_db::StateDB;
use trace::{self, TraceDB, ImportRequest as TraceImportRequest, LocalizedTrace, Database as TraceDatabase};
use transaction_ext::Transaction;
use verification::queue::kind::BlockLike;
use verification::queue::kind::blocks::Unverified;
use verification::{PreverifiedBlock, Verifier, BlockQueue};
use verification;
// re-export
pub use types::blockchain_info::BlockChainInfo;
@ -1231,7 +1229,7 @@ impl Client {
// from the null sender, with 50M gas.
fn contract_call_tx(&self, block_id: BlockId, address: Address, data: Bytes) -> SignedTransaction {
let from = Address::default();
Transaction {
transaction::Transaction {
nonce: self.nonce(&from, block_id).unwrap_or_else(|| self.engine.account_start_nonce(0)),
action: Action::Call(address),
gas: U256::from(50_000_000),
@ -2112,7 +2110,7 @@ impl BlockChainClient for Client {
fn transact_contract(&self, address: Address, data: Bytes) -> Result<(), transaction::Error> {
let authoring_params = self.importer.miner.authoring_params();
let transaction = Transaction {
let transaction = transaction::Transaction {
nonce: self.latest_nonce(&authoring_params.author),
action: Action::Call(address),
gas: self.importer.miner.sensible_gas_limit(),
@ -2411,7 +2409,7 @@ impl super::traits::EngineClient for Client {
BlockChainClient::block_number(self, id)
}
fn block_header(&self, id: BlockId) -> Option<::encoded::Header> {
fn block_header(&self, id: BlockId) -> Option<encoded::Header> {
BlockChainClient::block_header(self, id)
}
}
@ -2520,7 +2518,7 @@ mod tests {
use std::sync::atomic::{AtomicBool, Ordering};
use kvdb::DBTransaction;
use blockchain::ExtrasInsert;
use encoded;
use types::encoded;
let client = generate_dummy_client(0);
let genesis = client.chain_info().best_block_hash;
@ -2579,9 +2577,9 @@ mod tests {
use hash::keccak;
use super::transaction_receipt;
use ethkey::KeyPair;
use log_entry::{LogEntry, LocalizedLogEntry};
use receipt::{Receipt, LocalizedReceipt, TransactionOutcome};
use transaction::{Transaction, LocalizedTransaction, Action};
use types::log_entry::{LogEntry, LocalizedLogEntry};
use types::receipt::{Receipt, LocalizedReceipt, TransactionOutcome};
use types::transaction::{Transaction, LocalizedTransaction, Action};
// given
let key = KeyPair::from_secret_slice(&keccak("test")).unwrap();

View File

@ -21,7 +21,8 @@ use std::sync::Arc;
use ethereum_types::{H256, U256, H160};
use {factory, journaldb, trie, kvdb_memorydb};
use kvdb::{self, KeyValueDB};
use {state, state_db, client, executive, trace, transaction, db, spec, pod_state, log_entry, receipt};
use {state, state_db, client, executive, trace, db, spec, pod_state};
use types::{log_entry, receipt, transaction};
use factory::Factories;
use evm::{VMType, FinalizationResult};
use vm::{self, ActionParams};

View File

@ -20,20 +20,35 @@ use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering as AtomicOrder};
use std::sync::Arc;
use std::collections::{HashMap, BTreeMap};
use std::mem;
use itertools::Itertools;
use rustc_hex::FromHex;
use hash::keccak;
use blockchain::{TreeRoute, BlockReceipts};
use bytes::Bytes;
use db::{NUM_COLUMNS, COL_STATE};
use ethcore_miner::pool::VerifiedTransaction;
use ethereum_types::{H256, U256, Address};
use parking_lot::RwLock;
use journaldb;
use ethkey::{Generator, Random};
use ethtrie;
use hash::keccak;
use itertools::Itertools;
use kvdb::DBValue;
use kvdb_memorydb;
use bytes::Bytes;
use parking_lot::RwLock;
use rlp::{Rlp, RlpStream};
use ethkey::{Generator, Random};
use ethcore_miner::pool::VerifiedTransaction;
use transaction::{self, Transaction, LocalizedTransaction, SignedTransaction, Action};
use blockchain::{TreeRoute, BlockReceipts};
use rustc_hex::FromHex;
use types::transaction::{self, Transaction, LocalizedTransaction, SignedTransaction, Action};
use types::BlockNumber;
use types::basic_account::BasicAccount;
use types::encoded;
use types::filter::Filter;
use types::header::Header;
use types::log_entry::LocalizedLogEntry;
use types::pruning_info::PruningInfo;
use types::receipt::{Receipt, LocalizedReceipt, TransactionOutcome};
use types::view;
use types::views::BlockView;
use vm::Schedule;
use block::{OpenBlock, SealedBlock, ClosedBlock};
use client::{
Nonce, Balance, ChainInfo, BlockInfo, ReopenBlock, CallContract, TransactionInfo, RegistryInfo,
PrepareOpenBlock, BlockChainClient, BlockChainInfo, BlockStatus, BlockId, Mode,
@ -42,30 +57,18 @@ use client::{
Call, StateClient, EngineInfo, AccountData, BlockChain, BlockProducer, SealedBlockImporter, IoClient,
BadBlocks,
};
use db::{NUM_COLUMNS, COL_STATE};
use header::{Header as BlockHeader, BlockNumber};
use filter::Filter;
use log_entry::LocalizedLogEntry;
use receipt::{Receipt, LocalizedReceipt, TransactionOutcome};
use engines::EthEngine;
use error::{Error, EthcoreResult};
use vm::Schedule;
use executed::CallError;
use executive::Executed;
use journaldb;
use miner::{self, Miner, MinerService};
use spec::Spec;
use types::basic_account::BasicAccount;
use types::pruning_info::PruningInfo;
use state::StateInfo;
use state_db::StateDB;
use trace::LocalizedTrace;
use verification::queue::QueueInfo;
use verification::queue::kind::blocks::Unverified;
use block::{OpenBlock, SealedBlock, ClosedBlock};
use executive::Executed;
use error::CallError;
use trace::LocalizedTrace;
use state_db::StateDB;
use header::Header;
use encoded;
use engines::EthEngine;
use ethtrie;
use state::StateInfo;
use views::BlockView;
/// Test client.
pub struct TestBlockChainClient {
@ -244,11 +247,11 @@ impl TestBlockChainClient {
/// Add a block to test client.
pub fn add_block<F>(&self, with: EachBlockWith, hook: F)
where F: Fn(BlockHeader) -> BlockHeader
where F: Fn(Header) -> Header
{
let n = self.numbers.read().len();
let mut header = BlockHeader::new();
let mut header = Header::new();
header.set_difficulty(From::from(n));
header.set_parent_hash(self.last_hash.read().clone());
header.set_number(n as BlockNumber);
@ -260,7 +263,7 @@ impl TestBlockChainClient {
let uncles = match with {
EachBlockWith::Uncle | EachBlockWith::UncleAndTransaction => {
let mut uncles = RlpStream::new_list(1);
let mut uncle_header = BlockHeader::new();
let mut uncle_header = Header::new();
uncle_header.set_difficulty(From::from(n));
uncle_header.set_parent_hash(self.last_hash.read().clone());
uncle_header.set_number(n as BlockNumber);
@ -309,7 +312,7 @@ impl TestBlockChainClient {
/// Make a bad block by setting invalid parent hash.
pub fn corrupt_block_parent(&self, n: BlockNumber) {
let hash = self.block_hash(BlockId::Number(n)).unwrap();
let mut header: BlockHeader = self.block_header(BlockId::Number(n)).unwrap().decode().expect("decoding failed");
let mut header: Header = self.block_header(BlockId::Number(n)).unwrap().decode().expect("decoding failed");
header.set_parent_hash(H256::from(42));
let mut rlp = RlpStream::new_list(3);
rlp.append(&header);
@ -935,7 +938,7 @@ impl super::traits::EngineClient for TestBlockChainClient {
BlockChainClient::block_number(self, id)
}
fn block_header(&self, id: BlockId) -> Option<::encoded::Header> {
fn block_header(&self, id: BlockId) -> Option<encoded::Header> {
BlockChainClient::block_header(self, id)
}
}

View File

@ -16,11 +16,10 @@
//! Bridge between Tracedb and Blockchain.
use ethereum_types::H256;
use header::BlockNumber;
use trace::DatabaseExtras as TraceDatabaseExtras;
use blockchain::{BlockChain, BlockProvider, TransactionAddress};
pub use types::trace_filter::Filter;
use ethereum_types::H256;
use trace::DatabaseExtras as TraceDatabaseExtras;
use types::BlockNumber;
impl TraceDatabaseExtras for BlockChain {
fn block_hash(&self, block_number: BlockNumber) -> Option<H256> {

View File

@ -17,40 +17,39 @@
use std::collections::BTreeMap;
use std::sync::Arc;
use blockchain::{BlockReceipts, TreeRoute};
use bytes::Bytes;
use ethcore_miner::pool::VerifiedTransaction;
use ethereum_types::{H256, U256, Address};
use evm::Schedule;
use itertools::Itertools;
use kvdb::DBValue;
use types::transaction::{self, LocalizedTransaction, SignedTransaction};
use types::BlockNumber;
use types::basic_account::BasicAccount;
use types::block_status::BlockStatus;
use types::blockchain_info::BlockChainInfo;
use types::call_analytics::CallAnalytics;
use types::encoded;
use types::filter::Filter;
use types::header::Header;
use types::ids::*;
use types::log_entry::LocalizedLogEntry;
use types::pruning_info::PruningInfo;
use types::receipt::LocalizedReceipt;
use types::trace_filter::Filter as TraceFilter;
use vm::LastHashes;
use block::{OpenBlock, SealedBlock, ClosedBlock};
use blockchain::{BlockReceipts, TreeRoute};
use client::Mode;
use encoded;
use vm::LastHashes;
use error::{Error, CallError, EthcoreResult};
use evm::Schedule;
use engines::EthEngine;
use error::{Error, EthcoreResult};
use executed::CallError;
use executive::Executed;
use filter::Filter;
use header::{BlockNumber};
use log_entry::LocalizedLogEntry;
use receipt::LocalizedReceipt;
use state::StateInfo;
use trace::LocalizedTrace;
use transaction::{self, LocalizedTransaction, SignedTransaction};
use verification::queue::QueueInfo as BlockQueueInfo;
use verification::queue::kind::blocks::Unverified;
use state::StateInfo;
use header::Header;
use engines::EthEngine;
use ethereum_types::{H256, U256, Address};
use ethcore_miner::pool::VerifiedTransaction;
use bytes::Bytes;
use kvdb::DBValue;
use types::ids::*;
use types::basic_account::BasicAccount;
use types::trace_filter::Filter as TraceFilter;
use types::call_analytics::CallAnalytics;
use types::blockchain_info::BlockChainInfo;
use types::block_status::BlockStatus;
use types::pruning_info::PruningInfo;
/// State information to be used during client query
pub enum StateOrBlock {

View File

@ -34,7 +34,6 @@ use error::{Error, ErrorKind, BlockError};
use ethjson;
use machine::{AuxiliaryData, Call, EthereumMachine};
use hash::keccak;
use header::{Header, BlockNumber, ExtendedHeader};
use super::signer::EngineSigner;
use super::validator_set::{ValidatorSet, SimpleList, new_validator_set};
use self::finality::RollingFinality;
@ -44,6 +43,8 @@ use itertools::{self, Itertools};
use rlp::{encode, Decodable, DecoderError, Encodable, RlpStream, Rlp};
use ethereum_types::{H256, H520, Address, U128, U256};
use parking_lot::{Mutex, RwLock};
use types::BlockNumber;
use types::header::{Header, ExtendedHeader};
use types::ancestry_action::AncestryAction;
use unexpected::{Mismatch, OutOfBounds};
@ -1528,7 +1529,7 @@ mod tests {
use hash::keccak;
use ethereum_types::{Address, H520, H256, U256};
use ethkey::Signature;
use header::Header;
use types::header::Header;
use rlp::encode;
use block::*;
use test_helpers::{
@ -1537,7 +1538,7 @@ mod tests {
};
use account_provider::AccountProvider;
use spec::Spec;
use transaction::{Action, Transaction};
use types::transaction::{Action, Transaction};
use engines::{Seal, Engine, EngineError, EthEngine};
use engines::validator_set::{TestSet, SimpleList};
use error::{Error, ErrorKind};

View File

@ -25,9 +25,9 @@ use block::*;
use engines::{Engine, Seal, ConstructedVerifier, EngineError};
use error::{BlockError, Error};
use ethjson;
use header::{Header, ExtendedHeader};
use client::EngineClient;
use machine::{AuxiliaryData, Call, EthereumMachine};
use types::header::{Header, ExtendedHeader};
use super::signer::EngineSigner;
use super::validator_set::{ValidatorSet, SimpleList, new_validator_set};
@ -215,7 +215,7 @@ mod tests {
use block::*;
use test_helpers::get_temp_state_db;
use account_provider::AccountProvider;
use header::Header;
use types::header::Header;
use spec::Spec;
use engines::Seal;
use tempdir::TempDir;

View File

@ -95,7 +95,7 @@ mod tests {
use ethereum_types::{H520, Address};
use test_helpers::get_temp_state_db;
use spec::Spec;
use header::Header;
use types::header::Header;
use block::*;
use engines::Seal;

View File

@ -24,7 +24,6 @@ mod signer;
mod validator_set;
pub mod block_reward;
pub mod epoch;
pub use self::authority_round::AuthorityRound;
pub use self::basic_authority::BasicAuthority;
@ -32,20 +31,23 @@ pub use self::epoch::{EpochVerifier, Transition as EpochTransition};
pub use self::instant_seal::{InstantSeal, InstantSealParams};
pub use self::null_engine::NullEngine;
// TODO [ToDr] Remove re-export (#10130)
pub use types::engines::ForkChoice;
pub use types::engines::epoch;
use std::sync::{Weak, Arc};
use std::collections::{BTreeMap, HashMap};
use std::{fmt, error};
use self::epoch::PendingTransition;
use account_provider::AccountProvider;
use builtin::Builtin;
use vm::{EnvInfo, Schedule, CreateContractAddress, CallType, ActionValue};
use error::Error;
use header::{Header, BlockNumber};
use types::BlockNumber;
use types::header::Header;
use snapshot::SnapshotComponents;
use spec::CommonParams;
use transaction::{self, UnverifiedTransaction, SignedTransaction};
use types::transaction::{self, UnverifiedTransaction, SignedTransaction};
use ethkey::{Password, Signature};
use parity_machine::{Machine, LocalizedMachine as Localized, TotalScoredHeader};
@ -58,15 +60,6 @@ use types::ancestry_action::AncestryAction;
/// As defined in https://github.com/ethereum/EIPs/pull/210
pub const DEFAULT_BLOCKHASH_CONTRACT: &'static str = "73fffffffffffffffffffffffffffffffffffffffe33141561006a5760014303600035610100820755610100810715156100455760003561010061010083050761010001555b6201000081071515610064576000356101006201000083050761020001555b5061013e565b4360003512151561008457600060405260206040f361013d565b61010060003543031315156100a857610100600035075460605260206060f361013c565b6101006000350715156100c55762010000600035430313156100c8565b60005b156100ea576101006101006000350507610100015460805260206080f361013b565b620100006000350715156101095763010000006000354303131561010c565b60005b1561012f57610100620100006000350507610200015460a052602060a0f361013a565b600060c052602060c0f35b5b5b5b5b";
/// Fork choice.
#[derive(Debug, PartialEq, Eq)]
pub enum ForkChoice {
/// Choose the new block.
New,
/// Choose the current best block.
Old,
}
/// Voting errors.
#[derive(Debug)]
pub enum EngineError {
@ -175,7 +168,7 @@ pub fn default_system_or_code_call<'a>(machine: &'a ::machine::EthereumMachine,
pub type Headers<'a, H> = Fn(H256) -> Option<H> + 'a;
/// Type alias for a function we can query pending transitions by block hash through.
pub type PendingTransitionStore<'a> = Fn(H256) -> Option<PendingTransition> + 'a;
pub type PendingTransitionStore<'a> = Fn(H256) -> Option<epoch::PendingTransition> + 'a;
/// Proof dependent on state.
pub trait StateDependentProof<M: Machine>: Send + Sync {

View File

@ -14,12 +14,12 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use ethereum_types::U256;
use engines::Engine;
use engines::block_reward::{self, RewardKind};
use header::BlockNumber;
use ethereum_types::U256;
use machine::WithRewards;
use parity_machine::{Header, LiveBlock, WithBalances, TotalScoredHeader};
use types::BlockNumber;
/// Params for a null engine.
#[derive(Clone, Default)]

View File

@ -21,11 +21,12 @@ use std::sync::Weak;
use bytes::Bytes;
use ethereum_types::{H256, Address};
use machine::{AuxiliaryData, Call, EthereumMachine};
use parking_lot::RwLock;
use types::BlockNumber;
use types::header::Header;
use client::EngineClient;
use header::{Header, BlockNumber};
use machine::{AuxiliaryData, Call, EthereumMachine};
use super::{ValidatorSet, SimpleList, SystemCall};
use super::safe_contract::ValidatorSafeContract;
@ -67,7 +68,7 @@ impl ValidatorContract {
}
impl ValidatorSet for ValidatorContract {
fn default_caller(&self, id: ::ids::BlockId) -> Box<Call> {
fn default_caller(&self, id: ::types::ids::BlockId) -> Box<Call> {
self.validators.default_caller(id)
}
@ -139,7 +140,7 @@ mod tests {
use bytes::ToPretty;
use rlp::encode;
use spec::Spec;
use header::Header;
use types::header::Header;
use account_provider::AccountProvider;
use miner::MinerService;
use types::ids::BlockId;

View File

@ -24,13 +24,16 @@ mod contract;
mod multi;
use std::sync::Weak;
use ids::BlockId;
use ethereum_types::{H256, Address};
use bytes::Bytes;
use ethereum_types::{H256, Address};
use ethjson::spec::ValidatorSet as ValidatorSpec;
use client::EngineClient;
use header::{Header, BlockNumber};
use machine::{AuxiliaryData, Call, EthereumMachine};
use types::BlockNumber;
use types::header::Header;
use types::ids::BlockId;
use client::EngineClient;
#[cfg(test)]
pub use self::test::TestSet;

View File

@ -18,11 +18,14 @@
use std::collections::BTreeMap;
use std::sync::Weak;
use bytes::Bytes;
use ethereum_types::{H256, Address};
use parking_lot::RwLock;
use bytes::Bytes;
use ids::BlockId;
use header::{BlockNumber, Header};
use types::BlockNumber;
use types::header::Header;
use types::ids::BlockId;
use client::EngineClient;
use machine::{AuxiliaryData, Call, EthereumMachine};
use super::{SystemCall, ValidatorSet};
@ -152,7 +155,7 @@ mod tests {
use engines::EpochChange;
use engines::validator_set::ValidatorSet;
use ethkey::Secret;
use header::Header;
use types::header::Header;
use miner::MinerService;
use spec::Spec;
use test_helpers::{generate_dummy_client_with_spec_and_accounts, generate_dummy_client_with_spec_and_data};

View File

@ -16,24 +16,26 @@
/// Validator set maintained in a contract, updated using `getValidators` method.
use std::sync::{Weak, Arc};
use bytes::Bytes;
use client::EngineClient;
use ethabi::FunctionOutputDecoder;
use ethereum_types::{H256, U256, Address, Bloom};
use hash::keccak;
use header::Header;
use ids::BlockId;
use kvdb::DBValue;
use log_entry::LogEntry;
use machine::{AuxiliaryData, Call, EthereumMachine, AuxiliaryRequest};
use memory_cache::MemoryLruCache;
use parking_lot::RwLock;
use receipt::Receipt;
use rlp::{Rlp, RlpStream};
use std::sync::{Weak, Arc};
use types::header::Header;
use types::ids::BlockId;
use types::log_entry::LogEntry;
use types::receipt::Receipt;
use unexpected::Mismatch;
use client::EngineClient;
use machine::{AuxiliaryData, Call, EthereumMachine, AuxiliaryRequest};
use super::{SystemCall, ValidatorSet};
use super::simple_list::SimpleList;
use unexpected::Mismatch;
use ethabi::FunctionOutputDecoder;
use_contract!(validator_set, "res/contracts/validator_set.json");
@ -91,7 +93,7 @@ fn encode_first_proof(header: &Header, state_items: &[Vec<u8>]) -> Bytes {
fn check_first_proof(machine: &EthereumMachine, contract_address: Address, old_header: Header, state_items: &[DBValue])
-> Result<Vec<Address>, String>
{
use transaction::{Action, Transaction};
use types::transaction::{Action, Transaction};
// TODO: match client contract_call_tx more cleanly without duplication.
const PROVIDED_GAS: u64 = 50_000_000;
@ -343,7 +345,7 @@ impl ValidatorSet for ValidatorSafeContract {
}
}
fn epoch_set(&self, first: bool, machine: &EthereumMachine, _number: ::header::BlockNumber, proof: &[u8])
fn epoch_set(&self, first: bool, machine: &EthereumMachine, _number: ::types::BlockNumber, proof: &[u8])
-> Result<(SimpleList, Option<H256>), ::error::Error>
{
let rlp = Rlp::new(proof);
@ -444,7 +446,7 @@ mod tests {
use types::ids::BlockId;
use spec::Spec;
use account_provider::AccountProvider;
use transaction::{Transaction, Action};
use types::transaction::{Transaction, Action};
use client::{ChainInfo, BlockInfo, ImportBlock};
use ethkey::Secret;
use miner::MinerService;
@ -532,10 +534,10 @@ mod tests {
#[test]
fn detects_bloom() {
use header::Header;
use engines::EpochChange;
use machine::AuxiliaryRequest;
use log_entry::LogEntry;
use types::header::Header;
use types::log_entry::LogEntry;
let client = generate_dummy_client_with_spec_and_accounts(Spec::new_validator_safe_contract, None);
let engine = client.engine().clone();
@ -571,7 +573,7 @@ mod tests {
#[test]
fn initial_contract_is_signal() {
use header::Header;
use types::header::Header;
use engines::{EpochChange, Proof};
let client = generate_dummy_client_with_spec_and_accounts(Spec::new_validator_safe_contract, None);

View File

@ -20,7 +20,8 @@ use heapsize::HeapSizeOf;
use ethereum_types::{H256, Address};
use machine::{AuxiliaryData, Call, EthereumMachine};
use header::{BlockNumber, Header};
use types::BlockNumber;
use types::header::Header;
use super::ValidatorSet;
/// Validator set containing a known set of addresses.
@ -64,7 +65,7 @@ impl HeapSizeOf for SimpleList {
}
impl ValidatorSet for SimpleList {
fn default_caller(&self, _block_id: ::ids::BlockId) -> Box<Call> {
fn default_caller(&self, _block_id: ::types::ids::BlockId) -> Box<Call> {
Box::new(|_, _| Err("Simple list doesn't require calls.".into()))
}

View File

@ -19,12 +19,14 @@
use std::str::FromStr;
use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrdering};
use heapsize::HeapSizeOf;
use ethereum_types::{H256, Address};
use bytes::Bytes;
use ethereum_types::{H256, Address};
use heapsize::HeapSizeOf;
use types::BlockNumber;
use types::header::Header;
use machine::{AuxiliaryData, Call, EthereumMachine};
use header::{Header, BlockNumber};
use super::{ValidatorSet, SimpleList};
/// Set used for testing with a single validator.
@ -57,7 +59,7 @@ impl HeapSizeOf for TestSet {
}
impl ValidatorSet for TestSet {
fn default_caller(&self, _block_id: ::ids::BlockId) -> Box<Call> {
fn default_caller(&self, _block_id: ::types::ids::BlockId) -> Box<Call> {
Box::new(|_, _| Err("Test set doesn't require calls.".into()))
}

View File

@ -18,18 +18,19 @@
use std::{fmt, error};
use std::time::SystemTime;
use ethereum_types::{H256, U256, Address, Bloom};
use snappy::InvalidInput;
use unexpected::{Mismatch, OutOfBounds};
use ethtrie::TrieError;
use io::*;
use header::BlockNumber;
use snapshot::Error as SnapshotError;
use engines::EngineError;
use ethkey::Error as EthkeyError;
use account_provider::SignError as AccountsError;
use transaction::Error as TransactionError;
use ethtrie::TrieError;
use rlp;
use snappy::InvalidInput;
use snapshot::Error as SnapshotError;
use types::transaction::Error as TransactionError;
use types::BlockNumber;
use unexpected::{Mismatch, OutOfBounds};
use account_provider::SignError as AccountsError;
use engines::EngineError;
pub use executed::{ExecutionError, CallError};
@ -165,7 +166,7 @@ error_chain! {
}
foreign_links {
Channel(IoError) #[doc = "Io channel error"];
Channel(::io::IoError) #[doc = "Io channel error"];
}
}
@ -224,7 +225,7 @@ error_chain! {
}
foreign_links {
Io(IoError) #[doc = "Io create error"];
Io(::io::IoError) #[doc = "Io create error"];
StdIo(::std::io::Error) #[doc = "Error concerning the Rust standard library's IO subsystem."];
Trie(TrieError) #[doc = "Error concerning TrieDBs."];
Execution(ExecutionError) #[doc = "Error concerning EVM code execution."];

View File

@ -14,21 +14,24 @@
// 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::path::Path;
use std::cmp;
use std::collections::BTreeMap;
use std::path::Path;
use std::sync::Arc;
use hash::{KECCAK_EMPTY_LIST_RLP};
use engines::block_reward::{self, BlockRewardContract, RewardKind};
use ethash::{self, quick_get_difficulty, slow_hash_block_number, EthashManager, OptimizeFor};
use ethereum_types::{H256, H64, U256};
use unexpected::{OutOfBounds, Mismatch};
use block::*;
use error::{BlockError, Error};
use header::{Header, BlockNumber, ExtendedHeader};
use engines::{self, Engine};
use ethjson;
use hash::{KECCAK_EMPTY_LIST_RLP};
use rlp::Rlp;
use types::header::{Header, ExtendedHeader};
use types::BlockNumber;
use unexpected::{OutOfBounds, Mismatch};
use block::ExecutedBlock;
use engines::block_reward::{self, BlockRewardContract, RewardKind};
use engines::{self, Engine};
use error::{BlockError, Error};
use ethash::{self, quick_get_difficulty, slow_hash_block_number, EthashManager, OptimizeFor};
use machine::EthereumMachine;
/// Number of blocks in an ethash snapshot.
@ -482,7 +485,7 @@ mod tests {
use block::*;
use test_helpers::get_temp_state_db;
use error::{BlockError, Error, ErrorKind};
use header::Header;
use types::header::Header;
use spec::Spec;
use engines::Engine;
use super::super::{new_morden, new_mcip3_test, new_homestead_test_machine};

View File

@ -180,7 +180,8 @@ mod tests {
use state::*;
use super::*;
use test_helpers::get_temp_state_db;
use views::BlockView;
use types::view;
use types::views::BlockView;
#[test]
fn ensure_db_good() {

View File

@ -21,8 +21,8 @@ use bytes::Bytes;
use ethtrie;
use vm;
use trace::{VMTrace, FlatTrace};
use log_entry::LogEntry;
use state_diff::StateDiff;
use types::state_diff::StateDiff;
use types::log_entry::LogEntry;
use std::{fmt, error};

View File

@ -21,7 +21,7 @@ use hash::keccak;
use ethereum_types::{H256, U256, U512, Address};
use bytes::{Bytes, BytesRef};
use state::{Backend as StateBackend, State, Substate, CleanupMode};
use error::ExecutionError;
use executed::ExecutionError;
use machine::EthereumMachine as Machine;
use evm::{CallType, Finalize, FinalizationResult};
use vm::{
@ -31,7 +31,8 @@ use vm::{
use factory::VmFactory;
use externalities::*;
use trace::{self, Tracer, VMTracer};
use transaction::{Action, SignedTransaction};
use types::transaction::{Action, SignedTransaction};
use transaction_ext::Transaction;
use crossbeam;
pub use executed::{Executed, ExecutionResult};
@ -1179,7 +1180,7 @@ mod tests {
use trace::trace;
use trace::{FlatTrace, Tracer, NoopTracer, ExecutiveTracer};
use trace::{VMTrace, VMOperation, VMExecutedOperation, MemoryDiff, StorageDiff, VMTracer, NoopVMTracer, ExecutiveVMTracer};
use transaction::{Action, Transaction};
use types::transaction::{Action, Transaction};
fn make_frontier_machine(max_depth: usize) -> EthereumMachine {
let mut machine = ::ethereum::new_frontier_test_machine();

View File

@ -27,7 +27,7 @@ use vm::{
Ext, ContractCreateResult, MessageCallResult, CreateContractAddress,
ReturnData, TrapKind
};
use transaction::UNSIGNED_SENDER;
use types::transaction::UNSIGNED_SENDER;
use trace::{Tracer, VMTracer};
/// Policy for handling output data on `RETURN` opcode.
@ -340,7 +340,7 @@ impl<'a, T: 'a, V: 'a, B: 'a> Ext for Externalities<'a, T, V, B>
}
fn log(&mut self, topics: Vec<H256>, data: &[u8]) -> vm::Result<()> {
use log_entry::LogEntry;
use types::log_entry::LogEntry;
if self.static_flag {
return Err(vm::Error::MutableCallInStaticContext);

View File

@ -15,7 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use ethjson;
use header::Header;
use types::header::Header;
use ethereum_types::U256;
use spec::Spec;

View File

@ -20,7 +20,7 @@ use pod_state::PodState;
use trace;
use client::{EvmTestClient, EvmTestError, TransactResult};
use ethjson;
use transaction::SignedTransaction;
use types::transaction::SignedTransaction;
use vm::EnvInfo;
use super::SKIP_TEST_STATE;
use super::HookType;

View File

@ -17,10 +17,11 @@
use std::path::Path;
use super::test_common::*;
use client::EvmTestClient;
use header::Header;
use ethjson;
use rlp::Rlp;
use transaction::UnverifiedTransaction;
use types::header::Header;
use types::transaction::UnverifiedTransaction;
use transaction_ext::Transaction;
/// Run transaction jsontests on a given folder.
pub fn run_test_path<H: FnMut(&str, HookType)>(p: &Path, skip: &[&'static str], h: &mut H) {
@ -67,7 +68,7 @@ fn do_json_test<H: FnMut(&str, HookType)>(json_data: &[u8], start_stop_hook: &mu
let minimal = t.gas_required(&spec.engine.schedule(header.number())).into();
if t.gas < minimal {
return Err(::transaction::Error::InsufficientGas {
return Err(::types::transaction::Error::InsufficientGas {
minimal, got: t.gas,
}.into());
}

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
#![warn(missing_docs)]
#![warn(missing_docs, unused_extern_crates)]
//! Ethcore library
//!
@ -57,61 +57,65 @@
// error_chain foreign_links.
#![recursion_limit="128"]
extern crate blooms_db;
extern crate ansi_term;
extern crate bn;
extern crate byteorder;
extern crate crossbeam;
extern crate common_types as types;
extern crate crossbeam;
extern crate ethabi;
extern crate ethash;
extern crate ethcore_blockchain as blockchain;
extern crate ethcore_bloom_journal as bloom_journal;
extern crate parity_crypto;
extern crate ethcore_db as db;
extern crate ethcore_io as io;
extern crate parity_bytes as bytes;
extern crate ethcore_logger;
extern crate ethcore_miner;
#[cfg(feature = "stratum")]
extern crate ethcore_stratum;
extern crate ethcore_transaction as transaction;
extern crate ethereum_types;
extern crate ethjson;
extern crate ethkey;
extern crate ethstore;
extern crate hashdb;
extern crate heapsize;
extern crate itertools;
extern crate journaldb;
extern crate keccak_hash as hash;
extern crate keccak_hasher;
extern crate kvdb;
extern crate kvdb_memorydb;
extern crate kvdb_rocksdb;
extern crate len_caching_lock;
extern crate lru_cache;
extern crate num_cpus;
extern crate memory_cache;
extern crate memorydb;
extern crate num;
extern crate num_cpus;
extern crate parity_bytes as bytes;
extern crate parity_crypto;
extern crate parity_machine;
extern crate parity_snappy as snappy;
extern crate parking_lot;
extern crate patricia_trie as trie;
extern crate patricia_trie_ethereum as ethtrie;
extern crate rand;
extern crate rayon;
extern crate rlp;
extern crate rlp_compress;
extern crate keccak_hash as hash;
extern crate keccak_hasher;
extern crate heapsize;
extern crate memorydb;
extern crate patricia_trie as trie;
extern crate patricia_trie_ethereum as ethtrie;
extern crate triehash_ethereum as triehash;
extern crate ansi_term;
extern crate unexpected;
extern crate parity_snappy as snappy;
extern crate ethabi;
extern crate rustc_hex;
extern crate serde;
extern crate stats;
extern crate triehash_ethereum as triehash;
extern crate unexpected;
extern crate using_queue;
extern crate vm;
extern crate wasm;
extern crate memory_cache;
extern crate journaldb;
extern crate serde;
#[cfg(feature = "stratum")]
extern crate ethcore_stratum;
#[cfg(any(test, feature = "json-tests", feature = "test-helpers"))]
extern crate tempdir;
extern crate len_caching_lock;
#[cfg(any(test, feature = "json-tests"))]
extern crate ethcore_logger;
#[cfg(any(test, feature = "test-helpers"))]
extern crate kvdb_rocksdb;
#[cfg(any(test, feature = "test-helpers"))]
extern crate blooms_db;
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "android"))]
extern crate hardware_wallet;
@ -143,24 +147,18 @@ extern crate evm;
#[cfg(test)]
extern crate env_logger;
pub extern crate ethstore;
#[macro_use]
pub mod views;
#[cfg(test)]
extern crate rlp_compress;
pub mod account_provider;
pub mod block;
pub mod builtin;
pub mod client;
pub mod db;
pub mod encoded;
pub mod engines;
pub mod error;
pub mod ethereum;
pub mod executed;
pub mod executive;
pub mod header;
pub mod machine;
pub mod miner;
pub mod pod_state;
@ -170,12 +168,11 @@ pub mod spec;
pub mod state;
pub mod state_db;
pub mod trace;
pub mod transaction_ext;
pub mod verification;
mod cache_manager;
mod account_db;
mod externalities;
mod blockchain;
mod factory;
mod tx_filter;
@ -186,8 +183,6 @@ pub mod json_tests;
#[cfg(any(test, feature = "test-helpers"))]
pub mod test_helpers;
pub use types::*;
pub use executive::contract_address;
pub use evm::CreateContractAddress;
pub use blockchain::{BlockChainDB, BlockChainDBHandler};
pub use trie::TrieSpec;

View File

@ -20,23 +20,24 @@ use std::collections::{BTreeMap, HashMap};
use std::cmp;
use std::sync::Arc;
use ethereum_types::{U256, H256, Address};
use rlp::Rlp;
use types::transaction::{self, SYSTEM_ADDRESS, UNSIGNED_SENDER, UnverifiedTransaction, SignedTransaction};
use types::BlockNumber;
use types::header::{Header, ExtendedHeader};
use vm::{CallType, ActionParams, ActionValue, ParamsType};
use vm::{EnvInfo, Schedule, CreateContractAddress};
use block::{ExecutedBlock, IsBlock};
use builtin::Builtin;
use client::{BlockInfo, CallContract};
use error::Error;
use executive::Executive;
use header::{BlockNumber, Header, ExtendedHeader};
use spec::CommonParams;
use state::{CleanupMode, Substate};
use trace::{NoopTracer, NoopVMTracer, Tracer, ExecutiveTracer, RewardType, Tracing};
use transaction::{self, SYSTEM_ADDRESS, UNSIGNED_SENDER, UnverifiedTransaction, SignedTransaction};
use tx_filter::TransactionFilter;
use ethereum_types::{U256, H256, Address};
use rlp::Rlp;
use vm::{CallType, ActionParams, ActionValue, ParamsType};
use vm::{EnvInfo, Schedule, CreateContractAddress};
/// Parity tries to round block.gas_limit to multiple of this constant
pub const PARITY_GAS_LIMIT_DETERMINANT: U256 = U256([37, 0, 0, 0]);
@ -408,7 +409,7 @@ 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]>,
pub receipts: Option<&'a [::types::receipt::Receipt]>,
}
/// Type alias for a function we can make calls through synchronously.
@ -526,7 +527,7 @@ mod tests {
Default::default(),
ethparams,
);
let mut header = ::header::Header::new();
let mut header = ::types::header::Header::new();
header.set_number(15);
let res = machine.verify_transaction_basic(&transaction, &header);
@ -546,8 +547,8 @@ mod tests {
ethparams,
);
let mut parent = ::header::Header::new();
let mut header = ::header::Header::new();
let mut parent = ::types::header::Header::new();
let mut header = ::types::header::Header::new();
header.set_number(1);
// this test will work for this constant only

View File

@ -21,39 +21,42 @@ use std::sync::Arc;
use ansi_term::Colour;
use bytes::Bytes;
use engines::{EthEngine, Seal};
use error::{Error, ErrorKind, ExecutionError};
use ethcore_miner::gas_pricer::GasPricer;
use ethcore_miner::pool::{self, TransactionQueue, VerifiedTransaction, QueueStatus, PrioritizationStrategy};
#[cfg(feature = "work-notify")]
use ethcore_miner::work_notify::NotifyWork;
use ethereum_types::{H256, U256, Address};
use ethkey::Password;
use io::IoChannel;
use miner::pool_client::{PoolClient, CachedNonceClient, NonceCache};
use miner;
use parking_lot::{Mutex, RwLock};
use rayon::prelude::*;
use transaction::{
use types::transaction::{
self,
Action,
UnverifiedTransaction,
SignedTransaction,
PendingTransaction,
};
use types::BlockNumber;
use types::block::Block;
use types::header::Header;
use types::receipt::RichReceipt;
use using_queue::{UsingQueue, GetAction};
use account_provider::{AccountProvider, SignError as AccountError};
use block::{ClosedBlock, IsBlock, Block, SealedBlock};
use block::{ClosedBlock, IsBlock, SealedBlock};
use client::{
BlockChain, ChainInfo, CallContract, BlockProducer, SealedBlockImporter, Nonce, TransactionInfo, TransactionId
};
use client::{BlockId, ClientIoMessage};
use engines::{EthEngine, Seal};
use error::{Error, ErrorKind};
use executed::ExecutionError;
use executive::contract_address;
use header::{Header, BlockNumber};
use miner;
use miner::pool_client::{PoolClient, CachedNonceClient, NonceCache};
use receipt::RichReceipt;
use spec::Spec;
use state::State;
use ethkey::Password;
/// Different possible definitions for pending transaction set.
#[derive(Debug, PartialEq)]
@ -1284,13 +1287,13 @@ mod tests {
use super::*;
use ethkey::{Generator, Random};
use hash::keccak;
use header::BlockNumber;
use rustc_hex::FromHex;
use types::BlockNumber;
use client::{TestBlockChainClient, EachBlockWith, ChainInfo, ImportSealedBlock};
use miner::{MinerService, PendingOrdering};
use test_helpers::{generate_dummy_client, generate_dummy_client_with_spec_and_accounts};
use transaction::{Transaction};
use types::transaction::{Transaction};
#[test]
fn should_prepare_block_to_seal() {

View File

@ -33,21 +33,23 @@ use std::sync::Arc;
use std::collections::{BTreeSet, BTreeMap};
use bytes::Bytes;
use ethereum_types::{H256, U256, Address};
use ethcore_miner::pool::{VerifiedTransaction, QueueStatus, local_transactions};
use ethereum_types::{H256, U256, Address};
use ethkey::Password;
use types::transaction::{self, UnverifiedTransaction, SignedTransaction, PendingTransaction};
use types::BlockNumber;
use types::block::Block;
use types::header::Header;
use types::receipt::RichReceipt;
use block::{Block, SealedBlock};
use block::SealedBlock;
use client::{
CallContract, RegistryInfo, ScheduleInfo,
BlockChain, BlockProducer, SealedBlockImporter, ChainInfo,
AccountData, Nonce,
};
use error::Error;
use header::{BlockNumber, Header};
use receipt::RichReceipt;
use transaction::{self, UnverifiedTransaction, SignedTransaction, PendingTransaction};
use state::StateInfo;
use ethkey::Password;
/// Provides methods to verify incoming external transactions
pub trait TransactionVerifierClient: Send + Sync

View File

@ -25,19 +25,20 @@ use std::{
use ethereum_types::{H256, U256, Address};
use ethcore_miner::pool;
use ethcore_miner::pool::client::NonceClient;
use transaction::{
use types::transaction::{
self,
UnverifiedTransaction,
SignedTransaction,
};
use types::header::Header;
use parking_lot::RwLock;
use account_provider::AccountProvider;
use client::{TransactionId, BlockInfo, CallContract, Nonce};
use engines::EthEngine;
use header::Header;
use miner;
use miner::service_transaction_checker::ServiceTransactionChecker;
use transaction_ext::Transaction;
/// Cache for state nonces.
#[derive(Debug, Clone)]

View File

@ -17,7 +17,7 @@
//! A service transactions contract checker.
use client::{RegistryInfo, CallContract, BlockId};
use transaction::SignedTransaction;
use types::transaction::SignedTransaction;
use ethabi::FunctionOutputDecoder;
use_contract!(service_transaction, "res/contracts/service_transaction.json");

View File

@ -17,7 +17,7 @@
//! Account state encoding and decoding
use account_db::{AccountDB, AccountDBMut};
use basic_account::BasicAccount;
use types::basic_account::BasicAccount;
use bytes::Bytes;
use ethereum_types::{H256, U256};
use ethtrie::{TrieDB, TrieDBMut};
@ -207,7 +207,7 @@ pub fn from_fat_rlp(
#[cfg(test)]
mod tests {
use account_db::{AccountDB, AccountDBMut};
use basic_account::BasicAccount;
use types::basic_account::BasicAccount;
use test_helpers::get_temp_state_db;
use snapshot::tests::helpers::fill_storage;

View File

@ -16,14 +16,14 @@
//! Block RLP compression.
use block::Block;
use header::Header;
use hash::keccak;
use views::BlockView;
use rlp::{DecoderError, RlpStream, Rlp};
use ethereum_types::H256;
use bytes::Bytes;
use ethereum_types::H256;
use hash::keccak;
use rlp::{DecoderError, RlpStream, Rlp};
use triehash::ordered_trie_root;
use types::block::Block;
use types::header::Header;
use types::views::BlockView;
const HEADER_FIELDS: usize = 8;
const BLOCK_FIELDS: usize = 2;
@ -132,13 +132,14 @@ impl AbridgedBlock {
#[cfg(test)]
mod tests {
use views::BlockView;
use block::Block;
use super::AbridgedBlock;
use transaction::{Action, Transaction};
use ethereum_types::{H256, U256, Address};
use bytes::Bytes;
use ethereum_types::{H256, U256, Address};
use types::transaction::{Action, Transaction};
use types::block::Block;
use types::view;
use types::views::BlockView;
fn encode_block(b: &Block) -> Bytes {
b.rlp_bytes()

View File

@ -24,21 +24,20 @@ use super::{SnapshotComponents, Rebuilder, ChunkSink};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use blockchain::{BlockChain, BlockChainDB, BlockProvider};
use engines::{EthEngine, EpochVerifier, EpochTransition};
use machine::EthereumMachine;
use ids::BlockId;
use header::Header;
use receipt::Receipt;
use snapshot::{Error, ManifestData, Progress};
use itertools::{Position, Itertools};
use rlp::{RlpStream, Rlp};
use ethereum_types::{H256, U256};
use kvdb::KeyValueDB;
use blockchain::{BlockChain, BlockChainDB, BlockProvider};
use bytes::Bytes;
use encoded;
use ethereum_types::{H256, U256};
use itertools::{Position, Itertools};
use kvdb::KeyValueDB;
use rlp::{RlpStream, Rlp};
use types::encoded;
use types::header::Header;
use types::ids::BlockId;
use types::receipt::Receipt;
/// Snapshot creation and restoration for PoA chains.
/// Chunk format:
@ -319,7 +318,7 @@ impl Rebuilder for ChunkRebuilder {
}
if is_last_chunk {
use block::Block;
use types::block::Block;
let last_rlp = rlp.at(num_items - 1)?;
let block = Block {

View File

@ -35,7 +35,7 @@ use kvdb::KeyValueDB;
use bytes::Bytes;
use rlp::{RlpStream, Rlp};
use rand::OsRng;
use encoded;
use types::encoded;
/// Snapshot creation and restoration for PoW chains.
/// This includes blocks from the head of the chain as a
@ -250,7 +250,7 @@ impl Rebuilder for PowRebuilder {
let pair = rlp.at(idx)?;
let abridged_rlp = pair.at(0)?.as_raw().to_owned();
let abridged_block = AbridgedBlock::from_raw(abridged_rlp);
let receipts: Vec<::receipt::Receipt> = pair.list_at(1)?;
let receipts: Vec<::types::receipt::Receipt> = pair.list_at(1)?;
let receipts_root = ordered_trie_root(pair.at(1)?.iter().map(|r| r.as_raw()));
let block = abridged_block.to_block(parent_hash, cur_number, receipts_root)?;

View File

@ -18,7 +18,7 @@
use std::fmt;
use ids::BlockId;
use types::ids::BlockId;
use ethereum_types::H256;
use ethtrie::TrieError;

View File

@ -28,8 +28,8 @@ use hash::{keccak, KECCAK_NULL_RLP, KECCAK_EMPTY};
use account_db::{AccountDB, AccountDBMut};
use blockchain::{BlockChain, BlockProvider};
use engines::EthEngine;
use header::Header;
use ids::BlockId;
use types::header::Header;
use types::ids::BlockId;
use ethereum_types::{H256, U256};
use hashdb::HashDB;

View File

@ -33,7 +33,7 @@ use engines::EthEngine;
use error::{Error, ErrorKind as SnapshotErrorKind};
use snapshot::{Error as SnapshotError};
use hash::keccak;
use ids::BlockId;
use types::ids::BlockId;
use io::IoChannel;

View File

@ -23,7 +23,7 @@ use std::sync::Arc;
use hash::{KECCAK_NULL_RLP};
use account_db::AccountDBMut;
use basic_account::BasicAccount;
use types::basic_account::BasicAccount;
use blockchain::{BlockChain, BlockChainDB};
use client::{Client, ChainInfo};
use engines::EthEngine;
@ -142,7 +142,7 @@ pub fn compare_dbs(one: &HashDB<KeccakHasher, DBValue>, two: &HashDB<KeccakHashe
/// Take a snapshot from the given client into a temporary file.
/// Return a snapshot reader for it.
pub fn snap(client: &Client) -> (Box<SnapshotReader>, TempDir) {
use ids::BlockId;
use types::ids::BlockId;
let tempdir = TempDir::new("").unwrap();
let path = tempdir.path().join("file");

View File

@ -26,7 +26,7 @@ use ethkey::Secret;
use snapshot::tests::helpers as snapshot_helpers;
use spec::Spec;
use test_helpers::generate_dummy_client_with_spec_and_accounts;
use transaction::{Transaction, Action, SignedTransaction};
use types::transaction::{Transaction, Action, SignedTransaction};
use tempdir::TempDir;
use ethereum_types::Address;

View File

@ -22,7 +22,7 @@ use std::sync::Arc;
use tempdir::TempDir;
use blockchain::BlockProvider;
use client::{Client, ClientConfig, ImportBlock, BlockInfo};
use ids::BlockId;
use types::ids::BlockId;
use snapshot::io::{PackedReader, PackedWriter, SnapshotReader, SnapshotWriter};
use snapshot::service::{Service, ServiceParams};
use snapshot::{chunk_state, chunk_secondary, ManifestData, Progress, SnapshotService, RestorationStatus};
@ -153,7 +153,7 @@ fn guards_delete_folders() {
#[test]
fn keep_ancient_blocks() {
::env_logger::init().ok();
::env_logger::try_init().ok();
// Test variables
const NUM_BLOCKS: u64 = 500;
@ -272,7 +272,7 @@ fn keep_ancient_blocks() {
#[test]
fn recover_aborted_recovery() {
::env_logger::init().ok();
::env_logger::try_init().ok();
const NUM_BLOCKS: u32 = 400;
let gas_prices = vec![1.into(), 2.into(), 3.into(), 999.into()];

View File

@ -20,7 +20,7 @@ use std::sync::Arc;
use std::sync::atomic::AtomicBool;
use hash::{KECCAK_NULL_RLP, keccak};
use basic_account::BasicAccount;
use types::basic_account::BasicAccount;
use snapshot::account;
use snapshot::{chunk_state, Error as SnapshotError, Progress, StateRebuilder, SNAPSHOT_SUBPARTS};
use snapshot::io::{PackedReader, PackedWriter, SnapshotReader, SnapshotWriter};

View File

@ -18,7 +18,7 @@
use parking_lot::Mutex;
use client::{BlockInfo, Client, ChainNotify, NewBlocks, ClientIoMessage};
use ids::BlockId;
use types::ids::BlockId;
use io::IoChannel;
use ethereum_types::H256;

View File

@ -29,10 +29,12 @@ use memorydb::MemoryDB;
use parking_lot::RwLock;
use rlp::{Rlp, RlpStream};
use rustc_hex::{FromHex, ToHex};
use types::BlockNumber;
use types::encoded;
use types::header::Header;
use vm::{EnvInfo, CallType, ActionValue, ActionParams, ParamsType};
use builtin::Builtin;
use encoded;
use engines::{
EthEngine, NullEngine, InstantSeal, InstantSealParams, BasicAuthority,
AuthorityRound, DEFAULT_BLOCKHASH_CONTRACT
@ -40,7 +42,6 @@ use engines::{
use error::Error;
use executive::Executive;
use factory::Factories;
use header::{BlockNumber, Header};
use machine::EthereumMachine;
use pod_state::PodState;
use spec::Genesis;
@ -840,7 +841,7 @@ impl Spec {
/// initialize genesis epoch data, using in-memory database for
/// constructor.
pub fn genesis_epoch_data(&self) -> Result<Vec<u8>, String> {
use transaction::{Action, Transaction};
use types::transaction::{Action, Transaction};
use journaldb;
use kvdb_memorydb;
@ -989,8 +990,9 @@ mod tests {
use super::*;
use state::State;
use test_helpers::get_temp_state_db;
use views::BlockView;
use tempdir::TempDir;
use types::view;
use types::views::BlockView;
// https://github.com/paritytech/parity-ethereum/issues/1840
#[test]

View File

@ -31,7 +31,7 @@ use ethtrie::{TrieFactory, TrieDB, SecTrieDB, Result as TrieResult};
use pod_account::*;
use rlp::{RlpStream, encode};
use lru_cache::LruCache;
use basic_account::BasicAccount;
use types::basic_account::BasicAccount;
use std::cell::{RefCell, Cell};

View File

@ -26,7 +26,7 @@ use std::fmt;
use std::sync::Arc;
use hash::{KECCAK_NULL_RLP, KECCAK_EMPTY};
use receipt::{Receipt, TransactionOutcome};
use types::receipt::{Receipt, TransactionOutcome};
use machine::EthereumMachine as Machine;
use vm::EnvInfo;
use error::Error;
@ -38,7 +38,7 @@ use pod_state::{self, PodState};
use types::basic_account::BasicAccount;
use executed::{Executed, ExecutionError};
use types::state_diff::StateDiff;
use transaction::SignedTransaction;
use types::transaction::SignedTransaction;
use state_db::StateDB;
use factory::VmFactory;
@ -1316,7 +1316,7 @@ mod tests {
use machine::EthereumMachine;
use vm::EnvInfo;
use spec::*;
use transaction::*;
use types::transaction::*;
use ethcore_logger::init_log;
use trace::{FlatTrace, TraceError, trace};
use evm::CallType;

View File

@ -17,7 +17,7 @@
//! Execution environment substate.
use std::collections::HashSet;
use ethereum_types::Address;
use log_entry::LogEntry;
use types::log_entry::LogEntry;
use evm::{Schedule, CleanDustMode};
use super::CleanupMode;
@ -69,7 +69,7 @@ impl Substate {
#[cfg(test)]
mod tests {
use super::Substate;
use log_entry::LogEntry;
use types::log_entry::LogEntry;
#[test]
fn created() {

View File

@ -26,13 +26,14 @@ use db::COL_ACCOUNT_BLOOM;
use ethereum_types::{H256, Address};
use hash::keccak;
use hashdb::HashDB;
use keccak_hasher::KeccakHasher;
use header::BlockNumber;
use journaldb::JournalDB;
use keccak_hasher::KeccakHasher;
use kvdb::{KeyValueDB, DBTransaction, DBValue};
use lru_cache::LruCache;
use memory_cache::MemoryLruCache;
use parking_lot::Mutex;
use types::BlockNumber;
use state::{self, Account};
/// Value used to initialize bloom bitmap size.

View File

@ -19,32 +19,35 @@
use std::path::Path;
use std::sync::Arc;
use std::{fs, io};
use account_provider::AccountProvider;
use ethereum_types::{H256, U256, Address};
use block::{OpenBlock, Drain};
use blockchain::{BlockChain, BlockChainDB, BlockChainDBHandler, Config as BlockChainConfig, ExtrasInsert};
use blooms_db;
use bytes::Bytes;
use client::{Client, ClientConfig, ChainInfo, ImportBlock, ChainNotify, ChainMessageType, PrepareOpenBlock};
use ethereum_types::{H256, U256, Address};
use ethkey::KeyPair;
use evm::Factory as EvmFactory;
use factory::Factories;
use hash::keccak;
use header::Header;
use io::*;
use miner::Miner;
use parking_lot::RwLock;
use rlp::{self, RlpStream};
use spec::Spec;
use state_db::StateDB;
use state::*;
use transaction::{Action, Transaction, SignedTransaction};
use views::BlockView;
use blooms_db;
use io::IoChannel;
use kvdb::KeyValueDB;
use kvdb_rocksdb::{self, Database, DatabaseConfig};
use parking_lot::RwLock;
use rlp::{self, RlpStream};
use tempdir::TempDir;
use types::transaction::{Action, Transaction, SignedTransaction};
use types::encoded;
use types::header::Header;
use types::view;
use types::views::BlockView;
use account_provider::AccountProvider;
use block::{OpenBlock, Drain};
use client::{Client, ClientConfig, ChainInfo, ImportBlock, ChainNotify, ChainMessageType, PrepareOpenBlock};
use factory::Factories;
use miner::Miner;
use spec::Spec;
use state::*;
use state_db::StateDB;
use verification::queue::kind::blocks::Unverified;
use encoded;
/// Creates test block with corresponding header
pub fn create_test_block(header: &Header) -> Bytes {

View File

@ -0,0 +1,61 @@
// Copyright 2015-2018 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 blockchain::BlockProvider;
use test_helpers::{
generate_dummy_blockchain,
generate_dummy_blockchain_with_extra,
generate_dummy_empty_blockchain,
};
#[test]
fn can_contain_arbitrary_block_sequence() {
let bc = generate_dummy_blockchain(50);
assert_eq!(bc.best_block_number(), 49);
}
#[test]
fn can_collect_garbage() {
let bc = generate_dummy_blockchain(3000);
assert_eq!(bc.best_block_number(), 2999);
let best_hash = bc.best_block_hash();
let mut block_header = bc.block_header_data(&best_hash);
while !block_header.is_none() {
block_header = bc.block_header_data(&block_header.unwrap().parent_hash());
}
assert!(bc.cache_size().blocks > 1024 * 1024);
for _ in 0..2 {
bc.collect_garbage();
}
assert!(bc.cache_size().blocks < 1024 * 1024);
}
#[test]
fn can_contain_arbitrary_block_sequence_with_extra() {
let bc = generate_dummy_blockchain_with_extra(25);
assert_eq!(bc.best_block_number(), 24);
}
#[test]
fn can_contain_only_genesis_block() {
let bc = generate_dummy_empty_blockchain();
assert_eq!(bc.best_block_number(), 0);
}

View File

@ -16,27 +16,29 @@
use std::str::FromStr;
use std::sync::Arc;
use ethereum_types::{U256, Address};
use ethkey::KeyPair;
use hash::keccak;
use io::IoChannel;
use client::{BlockChainClient, Client, ClientConfig, BlockId, ChainInfo, BlockInfo, PrepareOpenBlock, ImportSealedBlock, ImportBlock};
use state::{self, State, CleanupMode};
use executive::{Executive, TransactOptions};
use ethereum;
use tempdir::TempDir;
use types::transaction::{PendingTransaction, Transaction, Action, Condition};
use types::filter::Filter;
use types::view;
use types::views::BlockView;
use block::IsBlock;
use client::{BlockChainClient, Client, ClientConfig, BlockId, ChainInfo, BlockInfo, PrepareOpenBlock, ImportSealedBlock, ImportBlock};
use ethereum;
use executive::{Executive, TransactOptions};
use miner::{Miner, PendingOrdering, MinerService};
use spec::Spec;
use state::{self, State, CleanupMode};
use test_helpers::{
self,
generate_dummy_client, push_blocks_to_client, get_test_client_with_blocks, get_good_dummy_block_seq,
generate_dummy_client_with_data, get_good_dummy_block, get_bad_state_dummy_block
};
use types::filter::Filter;
use ethereum_types::{U256, Address};
use miner::{Miner, PendingOrdering};
use spec::Spec;
use views::BlockView;
use ethkey::KeyPair;
use transaction::{PendingTransaction, Transaction, Action, Condition};
use miner::MinerService;
use tempdir::TempDir;
use test_helpers;
use verification::queue::kind::blocks::Unverified;
#[test]

View File

@ -24,7 +24,7 @@ use executive::Executive;
use state::Substate;
use test_helpers::get_temp_state_with_factory;
use trace::{NoopVMTracer, NoopTracer};
use transaction::SYSTEM_ADDRESS;
use types::transaction::SYSTEM_ADDRESS;
use rustc_hex::FromHex;

View File

@ -15,5 +15,6 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
mod client;
mod blockchain;
mod evm;
mod trace;

View File

@ -26,14 +26,15 @@ use client::*;
use test_helpers::get_temp_state_db;
use client::{BlockChainClient, Client, ClientConfig};
use std::sync::Arc;
use header::Header;
use miner::Miner;
use transaction::{Action, Transaction};
use views::BlockView;
use types::transaction::{Action, Transaction};
use trace::{RewardType, LocalizedTrace};
use trace::trace::Action::Reward;
use test_helpers;
use verification::queue::kind::blocks::Unverified;
use types::header::Header;
use types::view;
use types::views::BlockView;
#[test]
fn can_trace_block_and_uncle_reward() {

Some files were not shown because too many files have changed in this diff Show More