Update to latest trie version. (#10972)

* Switch to 'trie' crates, there is an unpublished deps to staging
parity-common triehash still.

* Use crates.io dependency.

* indentation

* Update util/journaldb/src/traits.rs

indentation

Co-Authored-By: cheme <emericchevalier.pro@gmail.com>

* Rem import braces

* switch deps to simple-codec branch (code broken)

* painfull update of trie and memdb, plus rework codec to be compatible
with simple_codec changes

* Removed useless implementation from trait.

* Remove some malloc size until update and patch triehash, seems ok
otherwhise.

* Update parity-util-mem.

* Switch to published triehash 0.8.

* Avoid redundancy in encode_partial functions.
Use better namings.

* Update util/patricia-trie-ethereum/src/rlp_node_codec.rs

Co-Authored-By: Andronik Ordian <write@reusable.software>

* Update util/patricia-trie-ethereum/src/rlp_node_codec.rs

Co-Authored-By: Andronik Ordian <write@reusable.software>

* Restore previous child rlp header length check.
Better comments and formatting.

* Update util/patricia-trie-ethereum/src/rlp_node_codec.rs

Co-Authored-By: David <dvdplm@gmail.com>

* Update util/patricia-trie-ethereum/src/rlp_node_codec.rs

Co-Authored-By: David <dvdplm@gmail.com>
This commit is contained in:
cheme 2019-08-15 15:36:48 +02:00 committed by David
parent e50eafe6e1
commit 5807402a0b
31 changed files with 229 additions and 158 deletions

132
Cargo.lock generated
View File

@ -5,7 +5,7 @@ name = "account-db"
version = "0.1.0"
dependencies = [
"ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"keccak-hasher 0.1.1",
"kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -20,16 +20,16 @@ dependencies = [
"common-types 0.1.0",
"derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"journaldb 0.2.0",
"keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"keccak-hasher 0.1.1",
"kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"memory-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"memory-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"patricia-trie-ethereum 0.1.0",
"pod 0.1.0",
@ -37,7 +37,7 @@ dependencies = [
"rlp_compress 0.1.0",
"serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
"trace 0.1.0",
"trie-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"trie-vm-factories 0.1.0",
]
@ -403,14 +403,6 @@ dependencies = [
"vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "clear_on_drop"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "cli-signer"
version = "1.4.0"
@ -471,7 +463,7 @@ dependencies = [
"keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-snappy 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"patricia-trie-ethereum 0.1.0",
"rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp_derive 0.1.0",
@ -889,7 +881,7 @@ dependencies = [
"evm 0.1.0",
"fetch 0.1.0",
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
"journaldb 0.2.0",
"keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -908,7 +900,7 @@ dependencies = [
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-runtime 0.1.0",
"parity-snappy 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"patricia-trie-ethereum 0.1.0",
"pod 0.1.0",
@ -928,8 +920,8 @@ dependencies = [
"time-utils 0.1.0",
"trace 0.1.0",
"trace-time 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"trie-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"trie-standardmap 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"trie-standardmap 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"trie-vm-factories 0.1.0",
"triehash-ethereum 0.2.0",
"unexpected 0.1.0",
@ -969,7 +961,7 @@ dependencies = [
"kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1020,7 +1012,7 @@ dependencies = [
"common-types 0.1.0",
"ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp_derive 0.1.0",
@ -1062,7 +1054,7 @@ dependencies = [
"failsafe 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fastmap 0.1.0",
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
"journaldb 0.2.0",
"keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1072,9 +1064,9 @@ dependencies = [
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"machine 0.1.0",
"memory-cache 0.1.0",
"memory-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"memory-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"patricia-trie-ethereum 0.1.0",
"rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1085,7 +1077,7 @@ dependencies = [
"smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
"stats 0.1.0",
"tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"trie-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"triehash-ethereum 0.2.0",
"vm 0.1.0",
]
@ -1127,7 +1119,7 @@ dependencies = [
"linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-runtime 0.1.0",
"parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"price-info 1.12.0",
"rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1221,7 +1213,7 @@ dependencies = [
"machine 0.1.0",
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-crypto 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"patricia-trie-ethereum 0.1.0",
"rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1236,7 +1228,7 @@ dependencies = [
"tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"trace 0.1.0",
"transaction-pool 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"trie-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"vm 0.1.0",
]
@ -1335,7 +1327,7 @@ dependencies = [
"ethstore 0.2.1",
"fastmap 0.1.0",
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"keccak-hasher 0.1.1",
"kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1345,7 +1337,7 @@ dependencies = [
"macros 0.1.0",
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-runtime 0.1.0",
"parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1468,7 +1460,7 @@ dependencies = [
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"memory-cache 0.1.0",
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"vm 0.1.0",
@ -1728,12 +1720,12 @@ dependencies = [
[[package]]
name = "hash-db"
version = "0.12.4"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "hash256-std-hasher"
version = "0.12.4"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2008,15 +2000,15 @@ dependencies = [
"env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)",
"ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fastmap 0.1.0",
"hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"keccak-hasher 0.1.1",
"kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"memory-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"memory-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -2137,18 +2129,18 @@ name = "keccak-hasher"
version = "0.1.1"
dependencies = [
"ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"plain_hasher 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "keccak-hasher"
version = "0.12.4"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"hash256-std-hasher 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"hash256-std-hasher 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -2375,17 +2367,17 @@ name = "memory-cache"
version = "0.1.0"
dependencies = [
"lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "memory-db"
version = "0.12.4"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -2774,7 +2766,7 @@ dependencies = [
"parity-rpc 1.12.0",
"parity-runtime 0.1.0",
"parity-updater 1.12.0",
"parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-version 2.7.0",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3031,11 +3023,10 @@ dependencies = [
[[package]]
name = "parity-util-mem"
version = "0.1.0"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3128,14 +3119,14 @@ version = "0.1.0"
dependencies = [
"elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"journaldb 0.2.0",
"keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"keccak-hasher 0.1.1",
"memory-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"memory-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"trie-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -3231,7 +3222,7 @@ dependencies = [
"common-types 0.1.0",
"ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethjson 0.1.0",
"hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"keccak-hasher 0.1.1",
@ -3243,7 +3234,7 @@ dependencies = [
"rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
"trie-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"triehash-ethereum 0.2.0",
]
@ -3956,7 +3947,7 @@ dependencies = [
"ethcore-bloom-journal 0.1.0",
"ethcore-db 0.1.0",
"ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"journaldb 0.2.0",
"keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"keccak-hasher 0.1.1",
@ -4409,7 +4400,7 @@ dependencies = [
"kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp_derive 0.1.0",
@ -4441,11 +4432,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "trie-db"
version = "0.12.4"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -4453,11 +4444,11 @@ dependencies = [
[[package]]
name = "trie-standardmap"
version = "0.12.4"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"keccak-hasher 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"keccak-hasher 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -4468,17 +4459,17 @@ dependencies = [
"evm 0.1.0",
"keccak-hasher 0.1.1",
"patricia-trie-ethereum 0.1.0",
"trie-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"vm 0.1.0",
"wasm 0.1.0",
]
[[package]]
name = "triehash"
version = "0.6.0"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -4488,7 +4479,7 @@ version = "0.2.0"
dependencies = [
"ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"keccak-hasher 0.1.1",
"triehash 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"triehash 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -4886,7 +4877,6 @@ dependencies = [
"checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878"
"checksum cid 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0e37fba0087d9f3f4e269827a55dc511abf3e440cc097a0c154ff4e6584f988"
"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e"
"checksum clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17"
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
"checksum cmake 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "6ec65ee4f9c9d16f335091d23693457ed4928657ba4982289d7fafee03bc614a"
"checksum combine 3.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fc1d011beeed29187b8db2ac3925c8dd4d3e87db463dc9d2d2833985388fc5bc"
@ -4949,8 +4939,8 @@ dependencies = [
"checksum h2 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "a27e7ed946e8335bdf9a191bc1b9b14a03ba822d013d2f58437f4fabcbd7fc2c"
"checksum hamming 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65043da274378d68241eb9a8f8f8aa54e349136f7b8e12f63e3ef44043cc30e1"
"checksum handlebars 0.32.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d89ec99d1594f285d4590fc32bac5f75cdab383f1123d504d27862c644a807dd"
"checksum hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3c95a428c86ed4633d83e07ef9e0a147a906da01e931f07e74a85bedce5a43"
"checksum hash256-std-hasher 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "663ce20dae36902c16d12c6aaae400ca40d922407a8cf2b4caf8cae9b39b4f03"
"checksum hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "32c87fec93c4a2d264483ef843ac1930ae7c7999d97d73721305a5188b4c23a4"
"checksum hash256-std-hasher 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "16293646125e09e5bc216d9f73fa81ab31c4f97007d56c036bbf15a58e970540"
"checksum hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "8e04cb7a5051270ef3fa79f8c7604d581ecfa73d520e74f554e45541c4b5881a"
"checksum heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461"
"checksum heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea04fa3ead4e05e51a7c806fc07271fdbde4e246a6c6d1efd52e72230b771b82"
@ -4990,7 +4980,7 @@ dependencies = [
"checksum jsonrpc-tcp-server 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ede8a327b567123038ca3dac22311923dc03602487de19c70b45d82760d31205"
"checksum jsonrpc-ws-server 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "977ea40f077c027553e4112d750114b9e5cc7bcf5642512838abc2a9b322bd23"
"checksum keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "69e8ee697b9aa6dcc34d7657565fa5052763a1627a5b59e4c3c0ae3ed0d70a65"
"checksum keccak-hasher 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6c936c737d79690593c34275faf583151a0e8c0abf34eaecad10399eed0beb7d"
"checksum keccak-hasher 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bf18164fd7ce989041f8fc4a1ae72a8bd1bec3575f2aeaf1d4968fc053aabef"
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
"checksum kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "72ae89206cea31c32014b39d5a454b96135894221610dbfd19cf4d2d044fa546"
"checksum kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "45bcdf5eb083602cff61a6f8438dce2a7900d714e893fc48781c39fb119d37aa"
@ -5012,7 +5002,7 @@ dependencies = [
"checksum memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b3629fe9fdbff6daa6c33b90f7c08355c1aca05a3d01fa8063b822fcf185f3b"
"checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff"
"checksum memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ce6075db033bbbb7ee5a0bbd3a3186bbae616f57fb001c485c7ff77955f8177f"
"checksum memory-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1eeeeab44c01c7da4409e68ec5b5db74c92305386efab3615e495b1dacaec196"
"checksum memory-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a688133a81c915553c1dd9c3e859949f43a854cb8f8773e690e849b53b1f89f0"
"checksum memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882"
"checksum memzero 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "93c0d11ac30a033511ae414355d80f70d9f29a44a49140face477117a1ee90db"
"checksum mime 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)" = "0a907b83e7b9e987032439a387e187119cddafc92d5c2aaeb1d92580a793f630"
@ -5051,7 +5041,7 @@ dependencies = [
"checksum parity-snappy 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2c5f9d149b13134b8b354d93a92830efcbee6fe5b73a2e6e540fe70d4dd8a63"
"checksum parity-snappy-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1a413d51e5e1927320c9de992998e4a279dffb8c8a7363570198bd8383e66f1b"
"checksum parity-tokio-ipc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eb002c2d3539ccd3b82bd915ec060028d4ab350ad203dbffa20028c1e483af5b"
"checksum parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "89e80f22052161e0cb55cb5a8a75890420c525031f95c9d262dbb0434aa85dc1"
"checksum parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2005637ccf93dbb60c85081ccaaf3f945f573da48dcc79f27f9646caa3ec1dc"
"checksum parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)" = "511379a8194230c2395d2f5fa627a5a7e108a9f976656ce723ae68fca4097bfc"
"checksum parity-wordlist 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "573d08f0d3bc8a6ffcdac1de2725b5daeed8db26345a9c12d91648e2d6457f3e"
"checksum parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5"
@ -5194,9 +5184,9 @@ dependencies = [
"checksum trace-time 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe82f2f0bf1991e163e757baf044282823155dd326e70f44ce2186c3c320cc9"
"checksum transaction-pool 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8d8bd3123931aa6e49dd03bc8a2400490e14701d779458d1f1fff1f04c6f666"
"checksum transient-hashmap 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aeb4b191d033a35edfce392a38cdcf9790b6cebcb30fa690c312c29da4dc433e"
"checksum trie-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ae063390324bfcf36c7e8e4fb1f85f6f0fb5dd04e1cd282581eb7b8b34b32de7"
"checksum trie-standardmap 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "40787fb1a63a97ed56d12bc303937ea274e09d1afa2e20e4f074eff2074b24d3"
"checksum triehash 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b645ad3fc9871596897fb64a57c9c29adc9f5ece87c2d78766e3fc5a5da56b56"
"checksum trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b65d609ae631d808c6c1cc23a622733d5a0b66a7d67e9f5cd5171562a1f4cb5"
"checksum trie-standardmap 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "64fda153c00484d640bc91334624be22ead0e5baca917d9fd53ff29bdebcf9b2"
"checksum triehash 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "61d0a66fa2412c7eb7816640e8ea14cf6bd63b6c824e72315b6ca76d33851134"
"checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382"
"checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169"
"checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d"

View File

@ -73,7 +73,7 @@ ethcore-secretstore = { path = "secret-store", optional = true }
registrar = { path = "util/registrar" }
parity-util-mem = { version = "0.1", features = ["jemalloc-global"] }
parity-util-mem = { version = "0.2.0", features = ["jemalloc-global"] }
[build-dependencies]
rustc_version = "0.2"

View File

@ -32,8 +32,8 @@ ethkey = { path = "../accounts/ethkey" }
evm = { path = "evm" }
trie-vm-factories = { path = "trie-vm-factories" }
futures = "0.1"
hash-db = "0.12.4"
parity-util-mem = "0.1"
hash-db = "0.15.0"
parity-util-mem = "0.2.0"
itertools = "0.5"
journaldb = { path = "../util/journaldb" }
keccak-hash = "0.2.0"
@ -53,7 +53,7 @@ parity-bytes = "0.1"
parity-snappy = "0.1"
parking_lot = "0.8"
pod = { path = "pod" }
trie-db = "0.12.4"
trie-db = "0.15.0"
patricia-trie-ethereum = { path = "../util/patricia-trie-ethereum" }
rand = "0.6"
rayon = "1.1"
@ -86,7 +86,7 @@ parity-runtime = { path = "../util/runtime" }
rlp_compress = { path = "../util/rlp-compress" }
serde_json = "1.0"
tempdir = "0.3"
trie-standardmap = "0.12.4"
trie-standardmap = "0.15.0"
machine = { path = "./machine", features = ["test-helpers"] }
[features]

View File

@ -8,7 +8,7 @@ edition = "2018"
[dependencies]
ethereum-types = "0.6"
hash-db = "0.12.4"
hash-db = "0.15.0"
keccak-hash = "0.2.0"
keccak-hasher = { path = "../../util/keccak-hasher" }
kvdb = "0.1"

View File

@ -12,22 +12,22 @@ derive_more = "0.15.0"
ethereum-types = "0.6.0"
ethtrie = { package = "patricia-trie-ethereum", path = "../../util/patricia-trie-ethereum" }
trie-vm-factories = { path = "../trie-vm-factories" }
hash-db = "0.12.4"
hash-db = "0.15.0"
journaldb = { path = "../../util/journaldb" }
keccak-hash = "0.2.0"
keccak-hasher = { path = "../../util/keccak-hasher" }
kvdb = "0.1.0"
log = "0.4"
lru-cache = "0.1.2"
memory-db = "0.12.4"
memory-db = "0.15.0"
parity-bytes = "0.1.0"
parity-util-mem = "0.1.0"
parity-util-mem = "0.2.0"
parking_lot = "0.8.0"
pod = { path = "../pod" }
rlp = "0.4.0"
serde = { version = "1.0", features = ["derive"] }
trace = { path = "../trace" }
trie-db = "0.12.4"
trie-db = "0.15.0"
[dev-dependencies]
account-db = { path = "../account-db" }

View File

@ -14,7 +14,7 @@ common-types = { path = "../types" }
ethcore-db = { path = "../db" }
ethereum-types = "0.6.0"
keccak-hash = "0.2.0"
parity-util-mem = "0.1"
parity-util-mem = "0.2.0"
itertools = "0.5"
kvdb = "0.1"
log = "0.4"

View File

@ -11,7 +11,7 @@ edition = "2018"
common-types = { path = "../types" }
ethereum-types = "0.6.0"
kvdb = "0.1"
parity-util-mem = "0.1"
parity-util-mem = "0.2.0"
parking_lot = "0.8"
rlp = "0.4.0"
rlp_derive = { path = "../../util/rlp-derive" }

View File

@ -8,7 +8,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
bit-set = "0.4"
parity-bytes = "0.1"
ethereum-types = "0.6.0"
parity-util-mem = "0.1"
parity-util-mem = "0.2.0"
lazy_static = "1.0"
log = "0.4"
vm = { path = "../vm" }

View File

@ -17,14 +17,14 @@ ethcore-db = { path = "../db" }
ethcore-blockchain = { path = "../blockchain" }
ethereum-types = "0.6.0"
machine = { path = "../machine" }
memory-db = "0.12.4"
trie-db = "0.12.4"
memory-db = "0.15.0"
trie-db = "0.15.0"
patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" }
ethcore-network = { path = "../../util/network" }
ethcore-miner = { path = "../../miner" }
ethcore-io = { path = "../../util/io" }
hash-db = "0.12.4"
parity-util-mem = "0.1"
hash-db = "0.15.0"
parity-util-mem = "0.2.0"
vm = { path = "../vm" }
fastmap = { path = "../../util/fastmap" }
failsafe = { version = "0.3.0", default-features = false, features = ["parking_lot_mutex"] }

View File

@ -11,7 +11,7 @@ common-types = { path = "../types" }
ethereum-types = "0.6"
ethjson = { path = "../../json" }
ethtrie = { package = "patricia-trie-ethereum", path = "../../util/patricia-trie-ethereum" }
hash-db = "0.12"
hash-db = "0.15.0"
itertools = "0.8"
keccak-hash = "0.2.0"
keccak-hasher = { path = "../../util/keccak-hasher" }
@ -21,7 +21,7 @@ parity-bytes = "0.1.0"
rlp = "0.4"
rustc-hex = "1"
serde = { version = "1.0", features = ["derive"] }
trie-db = "0.12.4"
trie-db = "0.15.0"
triehash = { package = "triehash-ethereum", version = "0.2", path = "../../util/triehash-ethereum" }
[dev-dependencies]

View File

@ -26,7 +26,7 @@ use keccak_hasher::KeccakHasher;
use triehash::sec_trie_root;
use parity_bytes::Bytes;
use trie_db::TrieFactory;
use ethtrie::RlpCodec;
use ethtrie::Layout;
use ethjson;
use common_types::account_diff::*;
use rlp::{self, RlpStream};
@ -70,7 +70,7 @@ impl PodAccount {
}
/// Place additional data into given hash DB.
pub fn insert_additional(&self, db: &mut dyn HashDB<KeccakHasher, DBValue>, factory: &TrieFactory<KeccakHasher, RlpCodec>) {
pub fn insert_additional(&self, db: &mut dyn HashDB<KeccakHasher, DBValue>, factory: &TrieFactory<Layout>) {
match self.code {
Some(ref c) if !c.is_empty() => { db.insert(hash_db::EMPTY_PREFIX, c); }
_ => {}

View File

@ -22,14 +22,14 @@ ethjson = { path = "../../json" }
ethkey = { path = "../../accounts/ethkey" }
fetch = { path = "../../util/fetch" }
futures = "0.1"
parity-util-mem = "0.1"
parity-util-mem = "0.2.0"
keccak-hash = "0.2.0"
log = "0.4"
machine = { path = "../machine" }
parity-bytes = "0.1"
parity-crypto = "0.4.0"
parking_lot = "0.8"
trie-db = "0.12.4"
trie-db = "0.15.0"
patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" }
rand = "0.3"
rlp = "0.4.0"

View File

@ -91,7 +91,7 @@ use verification::queue::kind::blocks::Unverified;
use verification::{Verifier, BlockQueue};
use verification;
use ansi_term::Colour;
use ethtrie::Layout;
// re-export
pub use blockchain::CacheSize as BlockChainCacheSize;
use db::{Writable, Readable, keys::BlockDetails};
@ -726,7 +726,7 @@ impl Client {
false => TrieSpec::Secure,
};
let trie_factory = TrieFactory::new(trie_spec);
let trie_factory = TrieFactory::new(trie_spec, Layout);
let factories = Factories {
vm: VmFactory::new(config.vm_type.clone(), config.jump_table_size),
trie: trie_factory,

View File

@ -158,7 +158,7 @@ impl<'a> EvmTestClient<'a> {
fn factories(trie_spec: trie::TrieSpec) -> Factories {
Factories {
vm: trie_vm_factories::VmFactory::new(VMType::Interpreter, 5 * 1024),
trie: trie::TrieFactory::new(trie_spec),
trie: trie::TrieFactory::new(trie_spec, ethtrie::Layout),
accountdb: Default::default(),
}
}

View File

@ -1658,13 +1658,14 @@ mod tests {
#[test]
fn should_get_full_pod_storage_values() {
use trie::{TrieFactory, TrieSpec};
use ethtrie;
let a = Address::from_low_u64_be(10);
let db = get_temp_state_db();
let factories = Factories {
vm: Default::default(),
trie: TrieFactory::new(TrieSpec::Fat),
trie: TrieFactory::new(TrieSpec::Fat, ethtrie::Layout),
accountdb: Default::default(),
};

View File

@ -16,7 +16,6 @@
use ethjson;
use trie::{TrieFactory, TrieSpec};
use ethtrie::RlpCodec;
use ethereum_types::H256;
use super::HookType;
@ -28,7 +27,7 @@ pub use self::secure::run_test_file as run_secure_test_file;
fn test_trie<H: FnMut(&str, HookType)>(json: &[u8], trie: TrieSpec, start_stop_hook: &mut H) -> Vec<String> {
let tests = ethjson::trie::Test::load(json).unwrap();
let factory = TrieFactory::<_, RlpCodec>::new(trie);
let factory = TrieFactory::new(trie, ethtrie::Layout);
let mut result = vec![];
for (name, test) in tests.into_iter() {

View File

@ -12,7 +12,7 @@ bloom_journal = { package = "ethcore-bloom-journal", path = "../../util/bloom" }
common-types = { path = "../types"}
ethcore-db = { path = "../db" }
ethereum-types = "0.6.0"
hash-db = "0.12.4"
hash-db = "0.15.0"
keccak-hash = "0.2.0"
keccak-hasher = { path = "../../util/keccak-hasher" }
journaldb = { path = "../../util/journaldb" }

View File

@ -20,7 +20,7 @@ ethereum-types = "0.6.0"
ethkey = { path = "../../accounts/ethkey" }
ethstore = { path = "../../accounts/ethstore" }
fastmap = { path = "../../util/fastmap" }
hash-db = "0.12.4"
hash-db = "0.15.0"
keccak-hash = "0.2.0"
keccak-hasher = { path = "../../util/keccak-hasher" }
kvdb = "0.1"
@ -29,7 +29,7 @@ machine = { path = "../machine" }
macros = { path = "../../util/macros" }
parity-bytes = "0.1"
parking_lot = "0.8"
parity-util-mem = "0.1"
parity-util-mem = "0.2.0"
rand = "0.6"
rlp = "0.4.0"
trace-time = "0.1"

View File

@ -14,7 +14,7 @@ evm = { path = "../evm" }
kvdb = "0.1.0"
log = "0.4"
parity-bytes = "0.1.0"
parity-util-mem = "0.1"
parity-util-mem = "0.2.0"
parking_lot = "0.8.0"
rlp = "0.4.0"
rlp_derive = { path = "../../util/rlp-derive" }

View File

@ -6,7 +6,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
trie-db = "0.12.4"
trie-db = "0.15.0"
ethtrie = { package = "patricia-trie-ethereum", path = "../../util/patricia-trie-ethereum" }
account-db = { path = "../account-db" }
evm = { path = "../evm" }

View File

@ -15,12 +15,11 @@
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
use trie_db::TrieFactory;
use ethtrie::RlpCodec;
use ethtrie::Layout;
use account_db::Factory as AccountFactory;
use evm::{Factory as EvmFactory, VMType};
use vm::{Exec, ActionParams, VersionedSchedule, Schedule};
use wasm::WasmInterpreter;
use keccak_hasher::KeccakHasher;
const WASM_MAGIC_NUMBER: &'static [u8; 4] = b"\0asm";
@ -67,7 +66,7 @@ pub struct Factories {
/// factory for evm.
pub vm: VmFactory,
/// factory for tries.
pub trie: TrieFactory<KeccakHasher, RlpCodec>,
pub trie: TrieFactory<Layout>,
/// factory for account databases.
pub accountdb: AccountFactory,
}

View File

@ -13,7 +13,7 @@ ethjson = { path = "../../json" }
ethkey = { path = "../../accounts/ethkey" }
keccak-hash = "0.2.0"
parity-bytes = "0.1"
parity-util-mem = "0.1"
parity-util-mem = "0.2.0"
parity-snappy = "0.1"
patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" }
rlp = "0.4.0"

View File

@ -23,7 +23,7 @@ ethabi-contract = "8.0"
ethcore-call-contract = { path = "../ethcore/call-contract" }
ethereum-types = "0.6.0"
futures = "0.1"
parity-util-mem = "0.1"
parity-util-mem = "0.2.0"
keccak-hash = "0.2.0"
linked-hash-map = "0.5"
log = "0.4"

View File

@ -9,12 +9,12 @@ edition = "2018"
[dependencies]
parity-bytes = "0.1"
ethereum-types = "0.6.0"
hash-db = "0.12.4"
malloc_size_of = { version = "0.1", package = "parity-util-mem" }
hash-db = "0.15.0"
malloc_size_of = { version = "0.2", package = "parity-util-mem" }
keccak-hasher = { path = "../keccak-hasher" }
kvdb = "0.1"
log = "0.4"
memory-db = "0.12.4"
memory-db = "0.15.0"
parking_lot = "0.8"
fastmap = { path = "../../util/fastmap" }
rlp = "0.4.0"

View File

@ -343,7 +343,7 @@ impl JournalDB for EarlyMergeDB {
Some(ref c) => c.read().size_of(&mut ops),
None => 0
}
}
}
fn state(&self, id: &H256) -> Option<Bytes> {
self.backing.get_by_prefix(self.column, &id[0..DB_PREFIX_LEN]).map(|b| b.into_vec())

View File

@ -8,5 +8,5 @@ license = "GPL-3.0"
[dependencies]
ethereum-types = "0.6.0"
tiny-keccak = "1.4.2"
hash-db = "0.12.4"
hash-db = "0.15.0"
plain_hasher = "0.2"

View File

@ -6,5 +6,5 @@ description = "An LRU-cache which operates on memory used"
license = "GPL3"
[dependencies]
parity-util-mem = "0.1"
parity-util-mem = "0.2.0"
lru-cache = "0.1"

View File

@ -6,15 +6,15 @@ description = "Merkle-Patricia Trie (Ethereum Style)"
license = "GPL-3.0"
[dependencies]
trie-db = "0.12.4"
trie-db = "0.15.0"
keccak-hasher = { version = "0.1.1", path = "../keccak-hasher" }
hash-db = "0.12.4"
hash-db = "0.15.0"
rlp = "0.4.0"
parity-bytes = "0.1"
ethereum-types = "0.6.0"
elastic-array = "0.10"
[dev-dependencies]
memory-db = "0.12.4"
memory-db = "0.15.0"
keccak-hash = "0.2.0"
journaldb = { path = "../journaldb" }

View File

@ -35,6 +35,17 @@ use rlp::DecoderError;
/// Convenience type alias to instantiate a Keccak-flavoured `RlpNodeCodec`
pub type RlpCodec = RlpNodeCodec<KeccakHasher>;
#[derive(Clone, Default)]
/// Defines the working of a particular flavour of trie:
/// how keys are hashed, how values are encoded, does it use extension nodes or not.
pub struct Layout;
impl trie_db::TrieLayout for Layout {
const USE_EXTENSION: bool = true;
type Hash = keccak_hasher::KeccakHasher;
type Codec = RlpNodeCodec<KeccakHasher>;
}
/// Convenience type alias to instantiate a Keccak/Rlp-flavoured `TrieDB`
///
/// Use it as a `Trie` trait object. You can use `db()` to get the backing database object.
@ -70,13 +81,13 @@ pub type RlpCodec = RlpNodeCodec<KeccakHasher>;
/// assert_eq!(t.get(b"foo").unwrap().unwrap(), DBValue::from_slice(b"bar"));
/// }
/// ```
pub type TrieDB<'db> = trie::TrieDB<'db, KeccakHasher, RlpCodec>;
pub type TrieDB<'db> = trie::TrieDB<'db, Layout>;
/// Convenience type alias to instantiate a Keccak/Rlp-flavoured `SecTrieDB`
pub type SecTrieDB<'db> = trie::SecTrieDB<'db, KeccakHasher, RlpCodec>;
pub type SecTrieDB<'db> = trie::SecTrieDB<'db, Layout>;
/// Convenience type alias to instantiate a Keccak/Rlp-flavoured `FatDB`
pub type FatDB<'db> = trie::FatDB<'db, KeccakHasher, RlpCodec>;
pub type FatDB<'db> = trie::FatDB<'db, Layout>;
/// Convenience type alias to instantiate a Keccak/Rlp-flavoured `TrieDBMut`
///
@ -102,6 +113,7 @@ pub type FatDB<'db> = trie::FatDB<'db, KeccakHasher, RlpCodec>;
/// use memory_db::*;
/// use ethereum_types::H256;
/// use elastic_array::ElasticArray128;
/// use trie::Trie;
///
/// type DBValue = ElasticArray128<u8>;
///
@ -118,16 +130,16 @@ pub type FatDB<'db> = trie::FatDB<'db, KeccakHasher, RlpCodec>;
/// assert!(!t.contains(b"foo").unwrap());
/// }
/// ```
pub type TrieDBMut<'db> = trie::TrieDBMut<'db, KeccakHasher, RlpCodec>;
pub type TrieDBMut<'db> = trie::TrieDBMut<'db, Layout>;
/// Convenience type alias to instantiate a Keccak/Rlp-flavoured `SecTrieDBMut`
pub type SecTrieDBMut<'db> = trie::SecTrieDBMut<'db, KeccakHasher, RlpCodec>;
pub type SecTrieDBMut<'db> = trie::SecTrieDBMut<'db, Layout>;
/// Convenience type alias to instantiate a Keccak/Rlp-flavoured `FatDBMut`
pub type FatDBMut<'db> = trie::FatDBMut<'db, KeccakHasher, RlpCodec>;
pub type FatDBMut<'db> = trie::FatDBMut<'db, Layout>;
/// Convenience type alias to instantiate a Keccak/Rlp-flavoured `TrieFactory`
pub type TrieFactory = trie::TrieFactory<KeccakHasher, RlpCodec>;
pub type TrieFactory = trie::TrieFactory<Layout>;
/// Convenience type alias for Keccak/Rlp flavoured trie errors
pub type TrieError = trie::TrieError<H256, DecoderError>;

View File

@ -16,13 +16,15 @@
//! `NodeCodec` implementation for Rlp
use elastic_array::ElasticArray128;
use ethereum_types::H256;
use hash_db::Hasher;
use keccak_hasher::KeccakHasher;
use rlp::{DecoderError, RlpStream, Rlp, Prototype};
use std::marker::PhantomData;
use trie::{NibbleSlice, NodeCodec, node::Node, ChildReference};
use std::borrow::Borrow;
use trie::{NibbleSlice, NodeCodec, node::Node, ChildReference, Partial};
/// Concrete implementation of a `NodeCodec` with Rlp encoding, generic over the `Hasher`
#[derive(Default, Clone)]
@ -30,15 +32,50 @@ pub struct RlpNodeCodec<H: Hasher> {mark: PhantomData<H>}
const HASHED_NULL_NODE_BYTES : [u8;32] = [0x56, 0xe8, 0x1f, 0x17, 0x1b, 0xcc, 0x55, 0xa6, 0xff, 0x83, 0x45, 0xe6, 0x92, 0xc0, 0xf8, 0x6e, 0x5b, 0x48, 0xe0, 0x1b, 0x99, 0x6c, 0xad, 0xc0, 0x01, 0x62, 0x2f, 0xb5, 0xe3, 0x63, 0xb4, 0x21];
const HASHED_NULL_NODE : H256 = H256( HASHED_NULL_NODE_BYTES );
/// Encode a partial value with a partial tuple as input.
fn encode_partial_iter<'a>(partial: Partial<'a>, is_leaf: bool) -> impl Iterator<Item = u8> + 'a {
encode_partial_inner_iter((partial.0).1, partial.1.iter().map(|v| *v), (partial.0).0 > 0, is_leaf)
}
/// Encode a partial value with an iterator as input.
fn encode_partial_from_iterator_iter<'a>(
mut partial: impl Iterator<Item = u8> + 'a,
odd: bool,
is_leaf: bool,
) -> impl Iterator<Item = u8> + 'a {
let first = if odd { partial.next().unwrap_or(0) } else { 0 };
encode_partial_inner_iter(first, partial, odd, is_leaf)
}
/// Encode a partial value with an iterator as input.
fn encode_partial_inner_iter<'a>(
first_byte: u8,
partial_remaining: impl Iterator<Item = u8> + 'a,
odd: bool,
is_leaf: bool,
) -> impl Iterator<Item = u8> + 'a {
let encoded_type = if is_leaf {0x20} else {0};
let first = if odd {
0x10 + encoded_type + first_byte
} else {
encoded_type
};
std::iter::once(first).chain(partial_remaining)
}
// NOTE: what we'd really like here is:
// `impl<H: Hasher> NodeCodec<H> for RlpNodeCodec<H> where H::Out: Decodable`
// but due to the current limitations of Rust const evaluation we can't
// do `const HASHED_NULL_NODE: H::Out = H::Out( … … )`. Perhaps one day soon?
impl NodeCodec<KeccakHasher> for RlpNodeCodec<KeccakHasher> {
type Error = DecoderError;
fn hashed_null_node() -> <KeccakHasher as Hasher>::Out {
HASHED_NULL_NODE
}
fn decode(data: &[u8]) -> ::std::result::Result<Node, Self::Error> {
let r = Rlp::new(data);
match r.prototype()? {
@ -47,19 +84,36 @@ impl NodeCodec<KeccakHasher> for RlpNodeCodec<KeccakHasher> {
// if leaf, second item is a value (is_data())
// if extension, second item is a node (either SHA3 to be looked up and
// fed back into this function or inline RLP which can be fed back into this function).
Prototype::List(2) => match NibbleSlice::from_encoded(r.at(0)?.data()?) {
(slice, true) => Ok(Node::Leaf(slice, r.at(1)?.data()?)),
(slice, false) => Ok(Node::Extension(slice, r.at(1)?.as_raw())),
Prototype::List(2) => {
let enc_nibble = r.at(0)?.data()?;
let from_encoded = if enc_nibble.is_empty() {
(NibbleSlice::new(&[]), false)
} else {
// check leaf bit from header.
let is_leaf = enc_nibble[0] & 32 == 32;
// Check the header bit to see if we're dealing with an odd partial (only a nibble of header info)
// or an even partial (skip a full byte).
let (start, byte_offset) = if enc_nibble[0] & 16 == 16 { (0, 1) } else { (1, 0) };
(NibbleSlice::new_offset(&enc_nibble[start..], byte_offset), is_leaf)
};
match from_encoded {
(slice, true) => Ok(Node::Leaf(slice, r.at(1)?.data()?)),
(slice, false) => Ok(Node::Extension(slice, r.at(1)?.data()?)),
}
},
// branch - first 16 are nodes, 17th is a value (or empty).
Prototype::List(17) => {
let mut nodes = [None as Option<&[u8]>; 16];
for i in 0..16 {
let v = r.at(i)?;
if v.is_empty() {
let value = r.at(i)?;
if value.is_empty() {
nodes[i] = None;
} else {
nodes[i] = Some(v.as_raw());
if value.is_data() && value.size() == KeccakHasher::LENGTH {
nodes[i] = Some(value.data()?);
} else {
return Err(DecoderError::Custom("Rlp is not valid."));
}
}
}
Ok(Node::Branch(nodes, if r.at(16)?.is_empty() { None } else { Some(r.at(16)?.data()?) }))
@ -70,65 +124,81 @@ impl NodeCodec<KeccakHasher> for RlpNodeCodec<KeccakHasher> {
_ => Err(DecoderError::Custom("Rlp is not valid."))
}
}
fn try_decode_hash(data: &[u8]) -> Option<<KeccakHasher as Hasher>::Out> {
let r = Rlp::new(data);
if r.is_data() && r.size() == KeccakHasher::LENGTH {
Some(r.as_val().expect("Hash is the correct size; qed"))
if data.len() == KeccakHasher::LENGTH {
let mut r = <KeccakHasher as Hasher>::Out::default();
r.as_mut().copy_from_slice(data);
Some(r)
} else {
None
}
}
fn is_empty_node(data: &[u8]) -> bool {
Rlp::new(data).is_empty()
}
fn empty_node() -> Vec<u8> {
let mut stream = RlpStream::new();
stream.append_empty_data();
stream.drain()
fn empty_node() -> &'static[u8] {
&[0x80]
}
fn leaf_node(partial: &[u8], value: &[u8]) -> Vec<u8> {
fn leaf_node(partial: Partial, value: &[u8]) -> Vec<u8> {
let mut stream = RlpStream::new_list(2);
stream.append(&partial);
stream.append_iter(encode_partial_iter(partial, true));
stream.append(&value);
stream.drain()
}
fn ext_node(partial: &[u8], child_ref: ChildReference<<KeccakHasher as Hasher>::Out>) -> Vec<u8> {
fn extension_node(
partial: impl Iterator<Item = u8>,
number_nibble: usize,
child_ref: ChildReference<<KeccakHasher as Hasher>::Out>,
) -> Vec<u8> {
let mut stream = RlpStream::new_list(2);
stream.append(&partial);
stream.append_iter(encode_partial_from_iterator_iter(partial, number_nibble % 2 > 0, false));
match child_ref {
ChildReference::Hash(h) => stream.append(&h),
ChildReference::Inline(inline_data, len) => {
let bytes = &AsRef::<[u8]>::as_ref(&inline_data)[..len];
ChildReference::Hash(hash) => stream.append(&hash),
ChildReference::Inline(inline_data, length) => {
let bytes = &AsRef::<[u8]>::as_ref(&inline_data)[..length];
stream.append_raw(bytes, 1)
},
};
stream.drain()
}
// fn branch_node<I>(children: I, value: Option<Vec<u8>>) -> Vec<u8>
fn branch_node<I>(children: I, value: Option<ElasticArray128<u8>>) -> Vec<u8>
where I: IntoIterator<Item=Option<ChildReference<<KeccakHasher as Hasher>::Out>>>
{
fn branch_node(
children: impl Iterator<Item = impl Borrow<Option<ChildReference<<KeccakHasher as Hasher>::Out>>>>,
maybe_value: Option<&[u8]>,
) -> Vec<u8> {
let mut stream = RlpStream::new_list(17);
for child_ref in children {
match child_ref {
match child_ref.borrow() {
Some(c) => match c {
ChildReference::Hash(h) => stream.append(&h),
ChildReference::Inline(inline_data, len) => {
let bytes = &AsRef::<[u8]>::as_ref(&inline_data)[..len];
ChildReference::Hash(h) => stream.append(h),
ChildReference::Inline(inline_data, length) => {
let bytes = &AsRef::<[u8]>::as_ref(inline_data)[..*length];
stream.append_raw(bytes, 1)
},
},
None => stream.append_empty_data()
};
}
if let Some(value) = value {
if let Some(value) = maybe_value {
stream.append(&&*value);
} else {
stream.append_empty_data();
}
stream.drain()
}
fn branch_node_nibbled(
_partial: impl Iterator<Item = u8>,
_number_nibble: usize,
_children: impl Iterator<Item = impl Borrow<Option<ChildReference<<KeccakHasher as Hasher>::Out>>>>,
_maybe_value: Option<&[u8]>) -> Vec<u8> {
unreachable!("This codec is only used with a trie Layout that uses extension node.")
}
}

View File

@ -6,6 +6,6 @@ description = "Trie-root helpers, ethereum style"
license = "GPL-3.0"
[dependencies]
triehash = "0.6.0"
triehash = "0.8.0"
ethereum-types = "0.6.0"
keccak-hasher = { path = "../keccak-hasher" }