Merge master
This commit is contained in:
commit
6d8b511d25
110
Cargo.lock
generated
110
Cargo.lock
generated
@ -3,6 +3,7 @@ name = "wasm"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethcore-bigint 0.1.3",
|
||||
"ethcore-logger 1.8.0",
|
||||
"ethcore-util 1.8.0",
|
||||
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -196,7 +197,7 @@ name = "bloomable"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"ethcore-bigint 0.1.3",
|
||||
"tiny-keccak 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hash 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -299,8 +300,10 @@ name = "common-types"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bloomable 0.1.0",
|
||||
"ethcore-bigint 0.1.3",
|
||||
"ethcore-util 1.8.0",
|
||||
"ethjson 0.1.0",
|
||||
"hash 0.1.0",
|
||||
"heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rlp 0.2.0",
|
||||
"rlp_derive 0.1.0",
|
||||
@ -452,6 +455,14 @@ dependencies = [
|
||||
"backtrace 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "error-chain"
|
||||
version = "0.11.0-rc.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"backtrace 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "eth-secp256k1"
|
||||
version = "0.5.6"
|
||||
@ -481,16 +492,17 @@ name = "ethash"
|
||||
version = "1.8.0"
|
||||
dependencies = [
|
||||
"crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hash 0.1.0",
|
||||
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"primal 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sha3 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ethcore"
|
||||
version = "1.8.0"
|
||||
dependencies = [
|
||||
"ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bloomable 0.1.0",
|
||||
"bloomchain 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -502,6 +514,7 @@ dependencies = [
|
||||
"env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethabi 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethash 1.8.0",
|
||||
"ethcore-bigint 0.1.3",
|
||||
"ethcore-bloom-journal 0.1.0",
|
||||
"ethcore-devtools 1.8.0",
|
||||
"ethcore-io 1.8.0",
|
||||
@ -517,6 +530,7 @@ dependencies = [
|
||||
"evm 0.1.0",
|
||||
"futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hardware-wallet 1.8.0",
|
||||
"hash 0.1.0",
|
||||
"heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hyper 0.10.0-a.0 (git+https://github.com/paritytech/hyper)",
|
||||
"itertools 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -527,17 +541,21 @@ dependencies = [
|
||||
"native-contracts 0.1.0",
|
||||
"num 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num_cpus 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"price-info 1.7.0",
|
||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rlp 0.2.0",
|
||||
"rlp_derive 0.1.0",
|
||||
"rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"semantic_version 0.1.0",
|
||||
"semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"stats 0.1.0",
|
||||
"table 0.1.0",
|
||||
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"transient-hashmap 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"triehash 0.1.0",
|
||||
"unexpected 0.1.0",
|
||||
"using_queue 0.1.0",
|
||||
"vm 0.1.0",
|
||||
"wasm 0.1.0",
|
||||
@ -584,6 +602,7 @@ dependencies = [
|
||||
name = "ethcore-ipc"
|
||||
version = "1.8.0"
|
||||
dependencies = [
|
||||
"ethcore-bigint 0.1.3",
|
||||
"ethcore-devtools 1.8.0",
|
||||
"ethcore-util 1.8.0",
|
||||
"nanomsg 0.5.1 (git+https://github.com/paritytech/nanomsg.rs.git?branch=parity-1.7)",
|
||||
@ -646,6 +665,7 @@ version = "1.8.0"
|
||||
dependencies = [
|
||||
"bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethcore 1.8.0",
|
||||
"ethcore-bigint 0.1.3",
|
||||
"ethcore-devtools 1.8.0",
|
||||
"ethcore-io 1.8.0",
|
||||
"ethcore-ipc 1.8.0",
|
||||
@ -654,9 +674,11 @@ dependencies = [
|
||||
"ethcore-util 1.8.0",
|
||||
"evm 0.1.0",
|
||||
"futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hash 0.1.0",
|
||||
"heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"itertools 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rlp 0.2.0",
|
||||
"rlp_derive 0.1.0",
|
||||
@ -665,6 +687,7 @@ dependencies = [
|
||||
"smallvec 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"stats 0.1.0",
|
||||
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"triehash 0.1.0",
|
||||
"vm 0.1.0",
|
||||
]
|
||||
|
||||
@ -690,12 +713,14 @@ dependencies = [
|
||||
"ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bytes 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethcore-bigint 0.1.3",
|
||||
"ethcore-devtools 1.8.0",
|
||||
"ethcore-io 1.8.0",
|
||||
"ethcore-logger 1.8.0",
|
||||
"ethcore-util 1.8.0",
|
||||
"ethcrypto 0.1.0",
|
||||
"ethkey 0.2.0",
|
||||
"hash 0.1.0",
|
||||
"igd 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ipnetwork 0.12.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -720,6 +745,7 @@ dependencies = [
|
||||
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethabi 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethcore 1.8.0",
|
||||
"ethcore-bigint 0.1.3",
|
||||
"ethcore-devtools 1.8.0",
|
||||
"ethcore-ipc 1.8.0",
|
||||
"ethcore-ipc-codegen 1.8.0",
|
||||
@ -730,6 +756,7 @@ dependencies = [
|
||||
"ethkey 0.2.0",
|
||||
"futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures-cpupool 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hash 0.1.0",
|
||||
"hyper 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -751,6 +778,7 @@ name = "ethcore-stratum"
|
||||
version = "1.8.0"
|
||||
dependencies = [
|
||||
"env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethcore-bigint 0.1.3",
|
||||
"ethcore-devtools 1.8.0",
|
||||
"ethcore-ipc 1.8.0",
|
||||
"ethcore-ipc-codegen 1.8.0",
|
||||
@ -758,11 +786,13 @@ dependencies = [
|
||||
"ethcore-logger 1.8.0",
|
||||
"ethcore-util 1.8.0",
|
||||
"futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hash 0.1.0",
|
||||
"jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
||||
"jsonrpc-macros 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
||||
"jsonrpc-tcp-server 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
||||
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tokio-core 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
@ -771,31 +801,29 @@ dependencies = [
|
||||
name = "ethcore-util"
|
||||
version = "1.8.0"
|
||||
dependencies = [
|
||||
"ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"error-chain 0.11.0-rc.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"eth-secp256k1 0.5.6 (git+https://github.com/paritytech/rust-secp256k1)",
|
||||
"ethcore-bigint 0.1.3",
|
||||
"ethcore-bloom-journal 0.1.0",
|
||||
"ethcore-devtools 1.8.0",
|
||||
"ethcore-logger 1.8.0",
|
||||
"hash 0.1.0",
|
||||
"heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lru-cache 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rlp 0.2.0",
|
||||
"rocksdb 0.4.5 (git+https://github.com/paritytech/rust-rocksdb)",
|
||||
"rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sha3 0.1.0",
|
||||
"target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tiny-keccak 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"triehash 0.1.0",
|
||||
"vergen 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
@ -892,6 +920,7 @@ dependencies = [
|
||||
"clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethcore 1.8.0",
|
||||
"ethcore-bigint 0.1.3",
|
||||
"ethcore-devtools 1.8.0",
|
||||
"ethcore-io 1.8.0",
|
||||
"ethcore-ipc 1.8.0",
|
||||
@ -901,6 +930,7 @@ dependencies = [
|
||||
"ethcore-network 1.8.0",
|
||||
"ethcore-util 1.8.0",
|
||||
"ethkey 0.2.0",
|
||||
"hash 0.1.0",
|
||||
"heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ipnetwork 0.12.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -910,6 +940,7 @@ dependencies = [
|
||||
"semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"triehash 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -919,14 +950,17 @@ dependencies = [
|
||||
"bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"common-types 0.1.0",
|
||||
"ethcore-bigint 0.1.3",
|
||||
"ethcore-logger 1.8.0",
|
||||
"ethcore-util 1.8.0",
|
||||
"ethjson 0.1.0",
|
||||
"evmjit 1.8.0",
|
||||
"hash 0.1.0",
|
||||
"heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-wasm 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rlp 0.2.0",
|
||||
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"vm 0.1.0",
|
||||
@ -939,6 +973,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"docopt 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethcore 1.8.0",
|
||||
"ethcore-bigint 0.1.3",
|
||||
"ethcore-util 1.8.0",
|
||||
"ethjson 0.1.0",
|
||||
"evm 0.1.0",
|
||||
@ -1066,6 +1101,16 @@ dependencies = [
|
||||
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hash"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"ethcore-bigint 0.1.3",
|
||||
"gcc 0.3.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tiny-keccak 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heapsize"
|
||||
version = "0.4.0"
|
||||
@ -1189,6 +1234,7 @@ dependencies = [
|
||||
name = "ipc-common-types"
|
||||
version = "1.8.0"
|
||||
dependencies = [
|
||||
"ethcore-bigint 0.1.3",
|
||||
"ethcore-ipc 1.8.0",
|
||||
"ethcore-ipc-codegen 1.8.0",
|
||||
"ethcore-util 1.8.0",
|
||||
@ -1624,12 +1670,14 @@ name = "node-filter"
|
||||
version = "1.8.0"
|
||||
dependencies = [
|
||||
"ethcore 1.8.0",
|
||||
"ethcore-bigint 0.1.3",
|
||||
"ethcore-io 1.8.0",
|
||||
"ethcore-network 1.8.0",
|
||||
"ethcore-util 1.8.0",
|
||||
"futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"native-contracts 0.1.0",
|
||||
"parking_lot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1828,12 +1876,14 @@ version = "1.8.0"
|
||||
dependencies = [
|
||||
"ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"app_dirs 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clap 2.24.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ctrlc 1.1.1 (git+https://github.com/paritytech/rust-ctrlc.git)",
|
||||
"daemonize 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"docopt 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethcore 1.8.0",
|
||||
"ethcore-bigint 0.1.3",
|
||||
"ethcore-devtools 1.8.0",
|
||||
"ethcore-io 1.8.0",
|
||||
"ethcore-ipc 1.8.0",
|
||||
@ -1851,6 +1901,7 @@ dependencies = [
|
||||
"fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures-cpupool 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hash 0.1.0",
|
||||
"ipnetwork 0.12.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"isatty 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
||||
@ -1869,6 +1920,7 @@ dependencies = [
|
||||
"parity-rpc-client 1.4.0",
|
||||
"parity-updater 1.8.0",
|
||||
"parity-whisper 0.1.0",
|
||||
"parking_lot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"path 0.1.0",
|
||||
"pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -1894,10 +1946,12 @@ dependencies = [
|
||||
"base32 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethcore-bigint 0.1.3",
|
||||
"ethcore-devtools 1.8.0",
|
||||
"ethcore-util 1.8.0",
|
||||
"fetch 0.1.0",
|
||||
"futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hash 0.1.0",
|
||||
"itertools 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
||||
"jsonrpc-http-server 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
||||
@ -1910,6 +1964,7 @@ dependencies = [
|
||||
"parity-hash-fetch 1.8.0",
|
||||
"parity-reactor 0.1.0",
|
||||
"parity-ui 1.8.0",
|
||||
"parking_lot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.3.14 (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.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -1940,14 +1995,17 @@ name = "parity-hash-fetch"
|
||||
version = "1.8.0"
|
||||
dependencies = [
|
||||
"ethabi 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethcore-bigint 0.1.3",
|
||||
"ethcore-util 1.8.0",
|
||||
"fetch 0.1.0",
|
||||
"futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hash 0.1.0",
|
||||
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mime 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mime_guess 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"native-contracts 0.1.0",
|
||||
"parity-reactor 0.1.0",
|
||||
"parking_lot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
@ -1958,6 +2016,7 @@ version = "1.8.0"
|
||||
dependencies = [
|
||||
"cid 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethcore 1.8.0",
|
||||
"ethcore-bigint 0.1.3",
|
||||
"ethcore-util 1.8.0",
|
||||
"jsonrpc-http-server 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
||||
"mime 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -1992,10 +2051,12 @@ dependencies = [
|
||||
name = "parity-rpc"
|
||||
version = "1.8.0"
|
||||
dependencies = [
|
||||
"ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cid 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethash 1.8.0",
|
||||
"ethcore 1.8.0",
|
||||
"ethcore-bigint 0.1.3",
|
||||
"ethcore-devtools 1.8.0",
|
||||
"ethcore-io 1.8.0",
|
||||
"ethcore-ipc 1.8.0",
|
||||
@ -2010,6 +2071,7 @@ dependencies = [
|
||||
"fetch 0.1.0",
|
||||
"futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures-cpupool 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hash 0.1.0",
|
||||
"itertools 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
||||
"jsonrpc-http-server 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
||||
@ -2024,6 +2086,7 @@ dependencies = [
|
||||
"order-stat 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-reactor 0.1.0",
|
||||
"parity-updater 1.8.0",
|
||||
"parking_lot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rlp 0.2.0",
|
||||
@ -2046,11 +2109,13 @@ version = "1.4.0"
|
||||
dependencies = [
|
||||
"ethcore-util 1.8.0",
|
||||
"futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hash 0.1.0",
|
||||
"jsonrpc-core 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
||||
"jsonrpc-ws-server 7.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.7)",
|
||||
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-rpc 1.8.0",
|
||||
"parking_lot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -2094,7 +2159,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "parity-ui-precompiled"
|
||||
version = "1.4.0"
|
||||
source = "git+https://github.com/paritytech/js-precompiled.git#d809723e58bcb36c0f8d2eca5ca94abbb3690544"
|
||||
source = "git+https://github.com/paritytech/js-precompiled.git#75e4afa0b77396aa8feefb49276672c3fe885a88"
|
||||
dependencies = [
|
||||
"parity-dapps-glue 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
@ -2105,6 +2170,7 @@ version = "1.8.0"
|
||||
dependencies = [
|
||||
"ethabi 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethcore 1.8.0",
|
||||
"ethcore-bigint 0.1.3",
|
||||
"ethcore-ipc 1.8.0",
|
||||
"ethcore-ipc-codegen 1.8.0",
|
||||
"ethcore-util 1.8.0",
|
||||
@ -2114,6 +2180,7 @@ dependencies = [
|
||||
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-hash-fetch 1.8.0",
|
||||
"parity-reactor 0.1.0",
|
||||
"parking_lot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"path 0.1.0",
|
||||
"target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
@ -2609,6 +2676,10 @@ dependencies = [
|
||||
"libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semantic_version"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "0.1.20"
|
||||
@ -2694,13 +2765,6 @@ name = "sha1"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "sha3"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"gcc 0.3.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shell32-sys"
|
||||
version = "0.1.1"
|
||||
@ -3072,11 +3136,24 @@ dependencies = [
|
||||
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "triehash"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"ethcore-bigint 0.1.3",
|
||||
"hash 0.1.0",
|
||||
"rlp 0.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typeable"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "unexpected"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "unicase"
|
||||
version = "1.4.0"
|
||||
@ -3182,9 +3259,11 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"common-types 0.1.0",
|
||||
"ethcore-bigint 0.1.3",
|
||||
"ethcore-util 1.8.0",
|
||||
"ethjson 0.1.0",
|
||||
"evmjit 1.8.0",
|
||||
"hash 0.1.0",
|
||||
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rlp 0.2.0",
|
||||
@ -3326,6 +3405,7 @@ dependencies = [
|
||||
"checksum either 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3d2b503c86dad62aaf414ecf2b8c527439abedb3f8d812537f0b12bfd6f32a91"
|
||||
"checksum elastic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "258ff6a9a94f648d0379dbd79110e057edbb53eb85cc237e33eadf8e5a30df85"
|
||||
"checksum env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e3856f1697098606fc6cb97a93de88ca3f3bc35bb878c725920e6e82ecf05e83"
|
||||
"checksum error-chain 0.11.0-rc.2 (registry+https://github.com/rust-lang/crates.io-index)" = "38d3a55d9a7a456748f2a3912c0941a5d9a68006eb15b3c3c9836b8420dc102d"
|
||||
"checksum error-chain 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bd5c82c815138e278b8dcdeffc49f27ea6ffb528403e9dea4194f2e3dd40b143"
|
||||
"checksum eth-secp256k1 0.5.6 (git+https://github.com/paritytech/rust-secp256k1)" = "<none>"
|
||||
"checksum ethabi 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0c3d62319ee0f35abf20afe8859dd2668195912614346447bb2dee9fb8da7c62"
|
||||
|
@ -11,12 +11,14 @@ log = "0.3"
|
||||
env_logger = "0.4"
|
||||
rustc-hex = "1.0"
|
||||
docopt = "0.8"
|
||||
clap = "2"
|
||||
time = "0.1"
|
||||
num_cpus = "1.2"
|
||||
number_prefix = "0.2"
|
||||
rpassword = "0.2.1"
|
||||
semver = "0.6"
|
||||
ansi_term = "0.9"
|
||||
parking_lot = "0.4"
|
||||
regex = "0.2"
|
||||
isatty = "0.1"
|
||||
toml = "0.4"
|
||||
@ -33,6 +35,7 @@ jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "pa
|
||||
ethsync = { path = "sync" }
|
||||
ethcore = { path = "ethcore" }
|
||||
ethcore-util = { path = "util" }
|
||||
ethcore-bigint = { path = "util/bigint" }
|
||||
ethcore-io = { path = "util/io" }
|
||||
ethcore-devtools = { path = "devtools" }
|
||||
ethcore-ipc = { path = "ipc/rpc" }
|
||||
@ -57,6 +60,7 @@ parity-updater = { path = "updater" }
|
||||
parity-whisper = { path = "whisper" }
|
||||
path = { path = "util/path" }
|
||||
panic_hook = { path = "panic_hook" }
|
||||
hash = { path = "util/hash" }
|
||||
|
||||
parity-dapps = { path = "dapps", optional = true }
|
||||
clippy = { version = "0.0.103", optional = true}
|
||||
|
@ -13,6 +13,7 @@ futures = "0.1"
|
||||
linked-hash-map = "0.3"
|
||||
log = "0.3"
|
||||
parity-dapps-glue = "1.7"
|
||||
parking_lot = "0.4"
|
||||
mime = "0.2"
|
||||
mime_guess = "1.6.1"
|
||||
rand = "0.3"
|
||||
@ -30,11 +31,13 @@ jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "pa
|
||||
jsonrpc-http-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.7" }
|
||||
|
||||
ethcore-util = { path = "../util" }
|
||||
ethcore-bigint = { path = "../util/bigint" }
|
||||
fetch = { path = "../util/fetch" }
|
||||
node-health = { path = "./node-health" }
|
||||
parity-hash-fetch = { path = "../hash-fetch" }
|
||||
parity-reactor = { path = "../util/reactor" }
|
||||
parity-ui = { path = "./ui" }
|
||||
hash = { path = "../util/hash" }
|
||||
|
||||
clippy = { version = "0.0.103", optional = true}
|
||||
|
||||
|
@ -19,9 +19,9 @@ use std::{fs, fmt};
|
||||
use std::io::{self, Read, Write};
|
||||
use std::path::PathBuf;
|
||||
use fetch::{self, Mime};
|
||||
use util::H256;
|
||||
use hash::keccak_buffer;
|
||||
use bigint::hash::H256;
|
||||
|
||||
use util::sha3::sha3;
|
||||
use page::{LocalPageEndpoint, PageCache};
|
||||
use handlers::{ContentValidator, ValidatorResponse};
|
||||
use apps::manifest::{MANIFEST_FILENAME, deserialize_manifest, serialize_manifest, Manifest};
|
||||
@ -57,9 +57,9 @@ fn write_response_and_check_hash(
|
||||
file.flush()?;
|
||||
|
||||
// Validate hash
|
||||
// TODO [ToDr] calculate sha3 in-flight while reading the response
|
||||
// TODO [ToDr] calculate keccak in-flight while reading the response
|
||||
let mut file = io::BufReader::new(fs::File::open(&content_path)?);
|
||||
let hash = sha3(&mut file)?;
|
||||
let hash = keccak_buffer(&mut file)?;
|
||||
if id == hash {
|
||||
Ok((file.into_inner(), content_path))
|
||||
} else {
|
||||
|
@ -32,7 +32,7 @@ use hyper;
|
||||
use hyper::status::StatusCode;
|
||||
|
||||
use {Embeddable, SyncStatus, random_filename};
|
||||
use util::Mutex;
|
||||
use parking_lot::Mutex;
|
||||
use page::LocalPageEndpoint;
|
||||
use handlers::{ContentHandler, ContentFetcherHandler};
|
||||
use endpoint::{Endpoint, EndpointPath, Handler};
|
||||
|
@ -23,7 +23,7 @@ use std::time::{Instant, Duration};
|
||||
use fetch::{self, Fetch};
|
||||
use futures::Future;
|
||||
use parity_reactor::Remote;
|
||||
use util::Mutex;
|
||||
use parking_lot::Mutex;
|
||||
|
||||
use hyper::{server, Decoder, Encoder, Next, Method, Control};
|
||||
use hyper::net::HttpStream;
|
||||
|
@ -24,6 +24,7 @@ extern crate futures;
|
||||
extern crate itertools;
|
||||
extern crate linked_hash_map;
|
||||
extern crate mime_guess;
|
||||
extern crate parking_lot;
|
||||
extern crate rand;
|
||||
extern crate rustc_hex;
|
||||
extern crate serde;
|
||||
@ -37,12 +38,14 @@ extern crate jsonrpc_core;
|
||||
extern crate jsonrpc_http_server;
|
||||
|
||||
extern crate ethcore_util as util;
|
||||
extern crate ethcore_bigint as bigint;
|
||||
extern crate fetch;
|
||||
extern crate node_health;
|
||||
extern crate parity_dapps_glue as parity_dapps;
|
||||
extern crate parity_hash_fetch as hash_fetch;
|
||||
extern crate parity_reactor;
|
||||
extern crate parity_ui;
|
||||
extern crate hash;
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
@ -72,7 +75,7 @@ use std::collections::HashMap;
|
||||
use std::mem;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use util::RwLock;
|
||||
use parking_lot::RwLock;
|
||||
|
||||
use jsonrpc_http_server::{self as http, hyper, Origin};
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
use std::{io, thread, time};
|
||||
use std::sync::{atomic, mpsc, Arc};
|
||||
use util::Mutex;
|
||||
use parking_lot::Mutex;
|
||||
|
||||
use futures::{self, Future};
|
||||
use fetch::{self, Fetch};
|
||||
|
@ -20,7 +20,9 @@ use std::collections::HashMap;
|
||||
use rustc_hex::FromHex;
|
||||
|
||||
use hash_fetch::urlhint::ContractClient;
|
||||
use util::{Bytes, Address, Mutex, H256, ToPretty};
|
||||
use bigint::hash::H256;
|
||||
use util::{Bytes, Address, ToPretty};
|
||||
use parking_lot::Mutex;
|
||||
|
||||
const REGISTRAR: &'static str = "8e4e9b13d4b45cb0befc93c3061b1408f67316b2";
|
||||
const URLHINT: &'static str = "deadbeefcafe0000000000000000000000000000";
|
||||
|
@ -7,10 +7,10 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
|
||||
[dependencies]
|
||||
log = "0.3"
|
||||
sha3 = { path = "../util/sha3" }
|
||||
hash = { path = "../util/hash" }
|
||||
primal = "0.2.3"
|
||||
parking_lot = "0.4"
|
||||
crunchy = "0.1.0"
|
||||
|
||||
[features]
|
||||
benches = []
|
||||
benches = []
|
||||
|
@ -23,7 +23,7 @@ use primal::is_prime;
|
||||
use std::cell::Cell;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
use sha3;
|
||||
use hash;
|
||||
use std::slice;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::io::{self, Read, Write};
|
||||
@ -200,7 +200,7 @@ impl SeedHashCompute {
|
||||
#[inline]
|
||||
pub fn resume_compute_seedhash(mut hash: H256, start_epoch: u64, end_epoch: u64) -> H256 {
|
||||
for _ in start_epoch..end_epoch {
|
||||
unsafe { sha3::sha3_256(hash[..].as_mut_ptr(), 32, hash[..].as_ptr(), 32) };
|
||||
unsafe { hash::keccak_256(hash[..].as_mut_ptr(), 32, hash[..].as_ptr(), 32) };
|
||||
}
|
||||
hash
|
||||
}
|
||||
@ -214,14 +214,14 @@ fn fnv_hash(x: u32, y: u32) -> u32 {
|
||||
return x.wrapping_mul(FNV_PRIME) ^ y;
|
||||
}
|
||||
|
||||
fn sha3_512(input: &[u8], output: &mut [u8]) {
|
||||
unsafe { sha3::sha3_512(output.as_mut_ptr(), output.len(), input.as_ptr(), input.len()) };
|
||||
fn keccak_512(input: &[u8], output: &mut [u8]) {
|
||||
unsafe { hash::keccak_512(output.as_mut_ptr(), output.len(), input.as_ptr(), input.len()) };
|
||||
}
|
||||
|
||||
fn sha3_512_inplace(input: &mut [u8]) {
|
||||
// This is safe since `sha3_*` uses an internal buffer and copies the result to the output. This
|
||||
fn keccak_512_inplace(input: &mut [u8]) {
|
||||
// This is safe since `keccak_*` uses an internal buffer and copies the result to the output. This
|
||||
// means that we can reuse the input buffer for both input and output.
|
||||
unsafe { sha3::sha3_512(input.as_mut_ptr(), input.len(), input.as_ptr(), input.len()) };
|
||||
unsafe { hash::keccak_512(input.as_mut_ptr(), input.len(), input.as_ptr(), input.len()) };
|
||||
}
|
||||
|
||||
fn get_cache_size(block_number: u64) -> usize {
|
||||
@ -250,23 +250,23 @@ fn get_data_size(block_number: u64) -> usize {
|
||||
/// Boundary recovered from mix hash
|
||||
pub fn quick_get_difficulty(header_hash: &H256, nonce: u64, mix_hash: &H256) -> H256 {
|
||||
unsafe {
|
||||
// This is safe - the `sha3_512` call below reads the first 40 bytes (which we explicitly set
|
||||
// This is safe - the `keccak_512` call below reads the first 40 bytes (which we explicitly set
|
||||
// with two `copy_nonoverlapping` calls) but writes the first 64, and then we explicitly write
|
||||
// the next 32 bytes before we read the whole thing with `sha3_256`.
|
||||
// the next 32 bytes before we read the whole thing with `keccak_256`.
|
||||
//
|
||||
// This cannot be elided by the compiler as it doesn't know the implementation of
|
||||
// `sha3_512`.
|
||||
// `keccak_512`.
|
||||
let mut buf: [u8; 64 + 32] = mem::uninitialized();
|
||||
|
||||
ptr::copy_nonoverlapping(header_hash.as_ptr(), buf.as_mut_ptr(), 32);
|
||||
ptr::copy_nonoverlapping(mem::transmute(&nonce), buf[32..].as_mut_ptr(), 8);
|
||||
|
||||
sha3::sha3_512(buf.as_mut_ptr(), 64, buf.as_ptr(), 40);
|
||||
hash::keccak_512(buf.as_mut_ptr(), 64, buf.as_ptr(), 40);
|
||||
ptr::copy_nonoverlapping(mix_hash.as_ptr(), buf[64..].as_mut_ptr(), 32);
|
||||
|
||||
// This is initialized in `sha3_256`
|
||||
// This is initialized in `keccak_256`
|
||||
let mut hash: [u8; 32] = mem::uninitialized();
|
||||
sha3::sha3_256(hash.as_mut_ptr(), hash.len(), buf.as_ptr(), buf.len());
|
||||
hash::keccak_256(hash.as_mut_ptr(), hash.len(), buf.as_ptr(), buf.len());
|
||||
|
||||
hash
|
||||
}
|
||||
@ -320,7 +320,7 @@ fn hash_compute(light: &Light, full_size: usize, header_hash: &H256, nonce: u64)
|
||||
half_mix: unsafe {
|
||||
// Pack `header_hash` and `nonce` together
|
||||
// We explicitly write the first 40 bytes, leaving the last 24 as uninitialized. Then
|
||||
// `sha3_512` reads the first 40 bytes (4th parameter) and overwrites the entire array,
|
||||
// `keccak_512` reads the first 40 bytes (4th parameter) and overwrites the entire array,
|
||||
// leaving it fully initialized.
|
||||
let mut out: [u8; NODE_BYTES] = mem::uninitialized();
|
||||
|
||||
@ -335,8 +335,8 @@ fn hash_compute(light: &Light, full_size: usize, header_hash: &H256, nonce: u64)
|
||||
mem::size_of::<u64>(),
|
||||
);
|
||||
|
||||
// compute sha3-512 hash and replicate across mix
|
||||
sha3::sha3_512(
|
||||
// compute keccak-512 hash and replicate across mix
|
||||
hash::keccak_512(
|
||||
out.as_mut_ptr(),
|
||||
NODE_BYTES,
|
||||
out.as_ptr(),
|
||||
@ -427,10 +427,10 @@ fn hash_compute(light: &Light, full_size: usize, header_hash: &H256, nonce: u64)
|
||||
let value: H256 = unsafe {
|
||||
// We can interpret the buffer as an array of `u8`s, since it's `repr(C)`.
|
||||
let read_ptr: *const u8 = mem::transmute(&buf);
|
||||
// We overwrite the second half since `sha3_256` has an internal buffer and so allows
|
||||
// We overwrite the second half since `keccak_256` has an internal buffer and so allows
|
||||
// overlapping arrays as input.
|
||||
let write_ptr: *mut u8 = mem::transmute(&mut buf.compress_bytes);
|
||||
sha3::sha3_256(
|
||||
hash::keccak_256(
|
||||
write_ptr,
|
||||
buf.compress_bytes.len(),
|
||||
read_ptr,
|
||||
@ -450,7 +450,7 @@ fn calculate_dag_item(node_index: u32, cache: &[Node]) -> Node {
|
||||
let mut ret = cache[node_index as usize % num_parent_nodes].clone();
|
||||
ret.as_words_mut()[0] ^= node_index;
|
||||
|
||||
sha3_512_inplace(&mut ret.bytes);
|
||||
keccak_512_inplace(&mut ret.bytes);
|
||||
|
||||
debug_assert_eq!(NODE_WORDS, 16);
|
||||
for i in 0..ETHASH_DATASET_PARENTS as u32 {
|
||||
@ -467,7 +467,7 @@ fn calculate_dag_item(node_index: u32, cache: &[Node]) -> Node {
|
||||
}
|
||||
}
|
||||
|
||||
sha3_512_inplace(&mut ret.bytes);
|
||||
keccak_512_inplace(&mut ret.bytes);
|
||||
|
||||
ret
|
||||
}
|
||||
@ -485,9 +485,9 @@ fn light_new<T: AsRef<Path>>(cache_dir: T, block_number: u64) -> Light {
|
||||
// Use uninit instead of unnecessarily writing `size_of::<Node>() * num_nodes` 0s
|
||||
nodes.set_len(num_nodes);
|
||||
|
||||
sha3_512(&seedhash[0..32], &mut nodes.get_unchecked_mut(0).bytes);
|
||||
keccak_512(&seedhash[0..32], &mut nodes.get_unchecked_mut(0).bytes);
|
||||
for i in 1..num_nodes {
|
||||
sha3::sha3_512(nodes.get_unchecked_mut(i).bytes.as_mut_ptr(), NODE_BYTES, nodes.get_unchecked(i - 1).bytes.as_ptr(), NODE_BYTES);
|
||||
hash::keccak_512(nodes.get_unchecked_mut(i).bytes.as_mut_ptr(), NODE_BYTES, nodes.get_unchecked(i - 1).bytes.as_ptr(), NODE_BYTES);
|
||||
}
|
||||
|
||||
debug_assert_eq!(NODE_WORDS, 16);
|
||||
@ -504,7 +504,7 @@ fn light_new<T: AsRef<Path>>(cache_dir: T, block_number: u64) -> Light {
|
||||
}
|
||||
}
|
||||
|
||||
sha3_512(&data.bytes, &mut nodes.get_unchecked_mut(i).bytes);
|
||||
keccak_512(&data.bytes, &mut nodes.get_unchecked_mut(i).bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
#![cfg_attr(feature = "benches", feature(test))]
|
||||
|
||||
extern crate primal;
|
||||
extern crate sha3;
|
||||
extern crate hash;
|
||||
extern crate parking_lot;
|
||||
|
||||
#[macro_use]
|
||||
|
@ -11,6 +11,7 @@ build = "build.rs"
|
||||
"ethcore-ipc-codegen" = { path = "../ipc/codegen" }
|
||||
|
||||
[dependencies]
|
||||
ansi_term = "0.9"
|
||||
bit-set = "0.4"
|
||||
bloomchain = "0.1"
|
||||
bn = { git = "https://github.com/paritytech/bn" }
|
||||
@ -29,6 +30,7 @@ ethcore-ipc-nano = { path = "../ipc/nano" }
|
||||
ethcore-logger = { path = "../logger" }
|
||||
ethcore-stratum = { path = "../stratum" }
|
||||
ethcore-util = { path = "../util" }
|
||||
ethcore-bigint = { path = "../util/bigint" }
|
||||
ethjson = { path = "../json" }
|
||||
ethkey = { path = "../ethkey" }
|
||||
ethstore = { path = "../ethstore" }
|
||||
@ -45,6 +47,7 @@ lru-cache = "0.1.0"
|
||||
native-contracts = { path = "native_contracts" }
|
||||
num = "0.1"
|
||||
num_cpus = "1.2"
|
||||
parking_lot = "0.4"
|
||||
price-info = { path = "../price-info" }
|
||||
rand = "0.3"
|
||||
rlp = { path = "../util/rlp" }
|
||||
@ -60,6 +63,10 @@ table = { path = "../util/table" }
|
||||
bloomable = { path = "../util/bloomable" }
|
||||
vm = { path = "vm" }
|
||||
wasm = { path = "wasm" }
|
||||
hash = { path = "../util/hash" }
|
||||
triehash = { path = "../util/triehash" }
|
||||
semantic_version = { path = "../util/semantic_version" }
|
||||
unexpected = { path = "../util/unexpected" }
|
||||
|
||||
[dev-dependencies]
|
||||
native-contracts = { path = "native_contracts", features = ["test_contracts"] }
|
||||
|
@ -8,6 +8,7 @@ bit-set = "0.4"
|
||||
byteorder = "1.0"
|
||||
common-types = { path = "../types" }
|
||||
ethcore-util = { path = "../../util" }
|
||||
ethcore-bigint = { path = "../../util/bigint" }
|
||||
evmjit = { path = "../../evmjit", optional = true }
|
||||
ethjson = { path = "../../json" }
|
||||
heapsize = "0.4"
|
||||
@ -16,8 +17,10 @@ log = "0.3"
|
||||
rlp = { path = "../../util/rlp" }
|
||||
vm = { path = "../vm" }
|
||||
parity-wasm = "0.12"
|
||||
parking_lot = "0.4"
|
||||
ethcore-logger = { path = "../../logger" }
|
||||
wasm-utils = { git = "https://github.com/paritytech/wasm-utils" }
|
||||
hash = { path = "../../util/hash" }
|
||||
|
||||
[dev-dependencies]
|
||||
rustc-hex = "1.0"
|
||||
|
@ -24,6 +24,8 @@ extern crate test;
|
||||
|
||||
use self::test::{Bencher, black_box};
|
||||
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::H256;
|
||||
use util::*;
|
||||
use vm::ActionParams;
|
||||
use evm::{self, Factory, VMType};
|
||||
|
@ -17,7 +17,8 @@
|
||||
//! Evm interface.
|
||||
|
||||
use std::{ops, cmp, fmt};
|
||||
use util::{U128, U256, U512};
|
||||
|
||||
use bigint::prelude::{U128, U256, U512};
|
||||
use vm::{Ext, Result, ReturnData, GasLeft, Error};
|
||||
|
||||
/// Finalization result. Gas Left: either it is a known value, or it needs to be computed by processing
|
||||
@ -149,7 +150,7 @@ impl CostType for usize {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use util::U256;
|
||||
use bigint::prelude::U256;
|
||||
use super::CostType;
|
||||
|
||||
#[test]
|
||||
|
@ -18,7 +18,7 @@
|
||||
//!
|
||||
use std::sync::Arc;
|
||||
use vm::Vm;
|
||||
use util::U256;
|
||||
use bigint::prelude::U256;
|
||||
use super::interpreter::SharedCache;
|
||||
use super::vmtype::VMType;
|
||||
|
||||
|
@ -15,7 +15,8 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use std::cmp;
|
||||
use util::*;
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::H256;
|
||||
use super::u256_to_address;
|
||||
|
||||
use {evm, vm};
|
||||
|
@ -43,7 +43,7 @@ mod inner {
|
||||
use evm::instructions::{Instruction, InstructionInfo, INSTRUCTIONS};
|
||||
use evm::{CostType};
|
||||
|
||||
use util::U256;
|
||||
use bigint::prelude::U256;
|
||||
|
||||
macro_rules! evm_debug {
|
||||
($x: expr) => {
|
||||
|
@ -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/>.
|
||||
|
||||
use util::U256;
|
||||
use bigint::prelude::U256;
|
||||
use vm::ReturnData;
|
||||
|
||||
const MAX_RETURN_WASTE_BYTES: usize = 16384;
|
||||
@ -134,7 +134,7 @@ impl Memory for Vec<u8> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use util::U256;
|
||||
use bigint::prelude::U256;
|
||||
use super::Memory;
|
||||
|
||||
#[test]
|
||||
|
@ -26,6 +26,9 @@ mod shared_cache;
|
||||
use std::marker::PhantomData;
|
||||
use std::{cmp, mem};
|
||||
use std::sync::Arc;
|
||||
use hash::keccak;
|
||||
use bigint::prelude::{U256, U512};
|
||||
use bigint::hash::H256;
|
||||
|
||||
use vm::{
|
||||
self, ActionParams, ActionValue, CallType, MessageCallResult,
|
||||
@ -180,7 +183,7 @@ impl<Cost: CostType> vm::Vm for Interpreter<Cost> {
|
||||
match result {
|
||||
InstructionResult::JumpToPosition(position) => {
|
||||
if valid_jump_destinations.is_none() {
|
||||
let code_hash = params.code_hash.clone().unwrap_or_else(|| code.sha3());
|
||||
let code_hash = params.code_hash.clone().unwrap_or_else(|| keccak(code.as_ref()));
|
||||
valid_jump_destinations = Some(self.cache.jump_destinations(&code_hash, code));
|
||||
}
|
||||
let jump_destinations = valid_jump_destinations.as_ref().expect("jump_destinations are initialized on first jump; qed");
|
||||
@ -464,8 +467,8 @@ impl<Cost: CostType> Interpreter<Cost> {
|
||||
instructions::SHA3 => {
|
||||
let offset = stack.pop_back();
|
||||
let size = stack.pop_back();
|
||||
let sha3 = self.mem.read_slice(offset, size).sha3();
|
||||
stack.push(U256::from(&*sha3));
|
||||
let k = keccak(self.mem.read_slice(offset, size));
|
||||
stack.push(U256::from(&*k));
|
||||
},
|
||||
instructions::SLOAD => {
|
||||
let key = H256::from(&stack.pop_back());
|
||||
@ -880,7 +883,7 @@ mod tests {
|
||||
use rustc_hex::FromHex;
|
||||
use vmtype::VMType;
|
||||
use factory::Factory;
|
||||
use vm::{self, ActionParams, ActionValue};
|
||||
use vm::{ActionParams, ActionValue};
|
||||
use vm::tests::{FakeExt, test_finalize};
|
||||
|
||||
#[test]
|
||||
|
@ -15,9 +15,10 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use std::sync::Arc;
|
||||
use hash::KECCAK_EMPTY;
|
||||
use heapsize::HeapSizeOf;
|
||||
use util::{H256, Mutex};
|
||||
use util::sha3::*;
|
||||
use bigint::hash::H256;
|
||||
use parking_lot::Mutex;
|
||||
use util::cache::MemoryLruCache;
|
||||
use bit_set::BitSet;
|
||||
use super::super::instructions;
|
||||
@ -50,7 +51,7 @@ impl SharedCache {
|
||||
|
||||
/// Get jump destinations bitmap for a contract.
|
||||
pub fn jump_destinations(&self, code_hash: &H256, code: &[u8]) -> Arc<BitSet> {
|
||||
if code_hash == &SHA3_EMPTY {
|
||||
if code_hash == &KECCAK_EMPTY {
|
||||
return Self::find_jump_destinations(code);
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,8 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Just in time compiler execution environment.
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::H256;
|
||||
use util::*;
|
||||
use evmjit;
|
||||
use evm::{self, GasLeft};
|
||||
|
@ -20,13 +20,16 @@ extern crate byteorder;
|
||||
extern crate bit_set;
|
||||
extern crate common_types as types;
|
||||
extern crate ethcore_util as util;
|
||||
extern crate ethcore_bigint as bigint;
|
||||
extern crate ethjson;
|
||||
extern crate rlp;
|
||||
extern crate parity_wasm;
|
||||
extern crate parking_lot;
|
||||
extern crate wasm_utils;
|
||||
extern crate ethcore_logger;
|
||||
extern crate heapsize;
|
||||
extern crate vm;
|
||||
extern crate hash;
|
||||
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
|
@ -20,6 +20,8 @@ use std::hash::Hash;
|
||||
use std::sync::Arc;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use rustc_hex::FromHex;
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::H256;
|
||||
use util::*;
|
||||
use vm::{self, ActionParams, ActionValue};
|
||||
use vm::tests::{FakeExt, FakeCall, FakeCallType, test_finalize};
|
||||
|
@ -14,6 +14,7 @@ build = "build.rs"
|
||||
log = "0.3"
|
||||
ethcore = { path = ".."}
|
||||
ethcore-util = { path = "../../util" }
|
||||
ethcore-bigint = { path = "../../util/bigint" }
|
||||
ethcore-network = { path = "../../util/network" }
|
||||
ethcore-io = { path = "../../util/io" }
|
||||
ethcore-ipc = { path = "../../ipc/rpc", optional = true }
|
||||
@ -31,7 +32,10 @@ itertools = "0.5"
|
||||
bincode = "0.8.0"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
parking_lot = "0.4"
|
||||
stats = { path = "../../util/stats" }
|
||||
hash = { path = "../../util/hash" }
|
||||
triehash = { path = "../../util/triehash" }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
@ -27,7 +27,8 @@ use ethcore::receipt::Receipt;
|
||||
use stats::Corpus;
|
||||
use time::{SteadyTime, Duration};
|
||||
use heapsize::HeapSizeOf;
|
||||
use util::{U256, H256};
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::H256;
|
||||
use util::cache::MemoryLruCache;
|
||||
|
||||
/// Configuration for how much data to cache.
|
||||
|
@ -21,7 +21,9 @@
|
||||
//! we discarded.
|
||||
|
||||
use ethcore::ids::BlockId;
|
||||
use util::{Bytes, H256, U256, HashDB, MemoryDB};
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::H256;
|
||||
use util::{Bytes, HashDB, MemoryDB};
|
||||
use util::trie::{self, TrieMut, TrieDBMut, Trie, TrieDB, Recorder};
|
||||
use rlp::{RlpStream, UntrustedRlp};
|
||||
|
||||
@ -130,7 +132,7 @@ pub fn compute_root<I>(cht_num: u64, iterable: I) -> Option<H256>
|
||||
}
|
||||
|
||||
if v.len() == SIZE as usize {
|
||||
Some(::util::triehash::trie_root(v))
|
||||
Some(::triehash::trie_root(v))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -37,11 +37,12 @@ use ethcore::ids::BlockId;
|
||||
|
||||
use rlp::{Encodable, Decodable, DecoderError, RlpStream, Rlp, UntrustedRlp};
|
||||
use heapsize::HeapSizeOf;
|
||||
use util::{H256, U256, RwLock};
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::H256;
|
||||
use util::kvdb::{DBTransaction, KeyValueDB};
|
||||
|
||||
use cache::Cache;
|
||||
use util::Mutex;
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
|
||||
use smallvec::SmallVec;
|
||||
|
||||
@ -487,7 +488,7 @@ impl HeaderChain {
|
||||
|
||||
/// Get the genesis hash.
|
||||
pub fn genesis_hash(&self) -> H256 {
|
||||
::util::Hashable::sha3(&self.genesis_header)
|
||||
self.genesis_header.hash()
|
||||
}
|
||||
|
||||
/// Get the best block's data.
|
||||
@ -555,7 +556,7 @@ mod tests {
|
||||
use cache::Cache;
|
||||
|
||||
use time::Duration;
|
||||
use util::Mutex;
|
||||
use parking_lot::Mutex;
|
||||
|
||||
fn make_db() -> Arc<::util::KeyValueDB> {
|
||||
Arc::new(::util::kvdb::in_memory(0))
|
||||
|
@ -30,8 +30,10 @@ use ethcore::spec::Spec;
|
||||
use ethcore::service::ClientIoMessage;
|
||||
use ethcore::encoded;
|
||||
use io::IoChannel;
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::H256;
|
||||
|
||||
use util::{H256, U256, Mutex, RwLock};
|
||||
use util::kvdb::{KeyValueDB, CompactionProfile};
|
||||
|
||||
use self::header_chain::{AncestryIter, HeaderChain};
|
||||
|
@ -28,7 +28,7 @@ use io::{IoContext, IoError, IoHandler, IoService};
|
||||
use util::kvdb::{Database, DatabaseConfig};
|
||||
|
||||
use cache::Cache;
|
||||
use util::Mutex;
|
||||
use parking_lot::Mutex;
|
||||
|
||||
use super::{Client, Config as ClientConfig};
|
||||
|
||||
@ -117,11 +117,11 @@ mod tests {
|
||||
use super::Service;
|
||||
use devtools::RandomTempPath;
|
||||
use ethcore::spec::Spec;
|
||||
|
||||
|
||||
use std::sync::Arc;
|
||||
use cache::Cache;
|
||||
use time::Duration;
|
||||
use util::Mutex;
|
||||
use parking_lot::Mutex;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
|
@ -70,6 +70,7 @@ extern crate bincode;
|
||||
extern crate ethcore_io as io;
|
||||
extern crate ethcore_network as network;
|
||||
extern crate ethcore_util as util;
|
||||
extern crate ethcore_bigint as bigint;
|
||||
extern crate ethcore;
|
||||
extern crate evm;
|
||||
extern crate heapsize;
|
||||
@ -77,6 +78,7 @@ extern crate futures;
|
||||
extern crate itertools;
|
||||
extern crate rand;
|
||||
extern crate rlp;
|
||||
extern crate parking_lot;
|
||||
#[macro_use]
|
||||
extern crate rlp_derive;
|
||||
extern crate serde;
|
||||
@ -84,6 +86,8 @@ extern crate smallvec;
|
||||
extern crate stats;
|
||||
extern crate time;
|
||||
extern crate vm;
|
||||
extern crate hash;
|
||||
extern crate triehash;
|
||||
|
||||
#[cfg(feature = "ipc")]
|
||||
extern crate ethcore_ipc as ipc;
|
||||
|
@ -32,7 +32,7 @@ use request::{CompleteRequest, Kind};
|
||||
|
||||
use bincode;
|
||||
use time;
|
||||
use util::{RwLock, Mutex};
|
||||
use parking_lot::{RwLock, Mutex};
|
||||
|
||||
/// Number of time periods samples should be kept for.
|
||||
pub const MOVING_SAMPLE_SIZE: usize = 256;
|
||||
|
@ -23,8 +23,10 @@ use ethcore::transaction::UnverifiedTransaction;
|
||||
use io::TimerToken;
|
||||
use network::{HostInfo, NetworkProtocolHandler, NetworkContext, PeerId};
|
||||
use rlp::{RlpStream, UntrustedRlp};
|
||||
use util::hash::H256;
|
||||
use util::{DBValue, Mutex, RwLock, U256};
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::H256;
|
||||
use util::DBValue;
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use time::{Duration, SteadyTime};
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
@ -287,7 +289,7 @@ pub type PeerMap = HashMap<PeerId, Mutex<Peer>>;
|
||||
mod id_guard {
|
||||
|
||||
use network::PeerId;
|
||||
use util::RwLockReadGuard;
|
||||
use parking_lot::RwLockReadGuard;
|
||||
|
||||
use super::{PeerMap, ReqId};
|
||||
|
||||
|
@ -30,7 +30,7 @@ use request::{self, Request};
|
||||
use super::error::Error;
|
||||
|
||||
use rlp::*;
|
||||
use util::U256;
|
||||
use bigint::prelude::U256;
|
||||
use time::{Duration, SteadyTime};
|
||||
|
||||
/// Credits value.
|
||||
|
@ -27,7 +27,7 @@ use std::iter::FromIterator;
|
||||
use request::Request;
|
||||
use request::NetworkRequests as Requests;
|
||||
use net::{timeout, ReqId};
|
||||
use util::U256;
|
||||
use bigint::prelude::U256;
|
||||
|
||||
use time::{Duration, SteadyTime};
|
||||
|
||||
|
@ -17,7 +17,8 @@
|
||||
//! Peer status and capabilities.
|
||||
|
||||
use rlp::{DecoderError, Encodable, Decodable, RlpStream, UntrustedRlp};
|
||||
use util::{H256, U256};
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::H256;
|
||||
|
||||
use super::request_credits::FlowParams;
|
||||
|
||||
@ -373,7 +374,8 @@ pub fn write_announcement(announcement: &Announcement) -> Vec<u8> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use super::super::request_credits::FlowParams;
|
||||
use util::{U256, H256};
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::H256;
|
||||
use rlp::{RlpStream, UntrustedRlp};
|
||||
|
||||
#[test]
|
||||
|
@ -32,7 +32,9 @@ use request;
|
||||
use request::*;
|
||||
|
||||
use rlp::*;
|
||||
use util::{Address, H256, U256};
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::H256;
|
||||
use util::Address;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
@ -606,7 +608,7 @@ fn id_guard() {
|
||||
pending_requests.insert(req_id_1, req.clone(), 0.into(), ::time::SteadyTime::now());
|
||||
pending_requests.insert(req_id_2, req, 1.into(), ::time::SteadyTime::now());
|
||||
|
||||
proto.peers.write().insert(peer_id, ::util::Mutex::new(Peer {
|
||||
proto.peers.write().insert(peer_id, ::parking_lot::Mutex::new(Peer {
|
||||
local_credits: flow_params.create_credits(),
|
||||
status: status(provider.client.chain_info()),
|
||||
capabilities: capabilities.clone(),
|
||||
|
@ -27,7 +27,7 @@ use ethcore::executed::{Executed, ExecutionError};
|
||||
use futures::{Async, Poll, Future};
|
||||
use futures::sync::oneshot::{self, Sender, Receiver, Canceled};
|
||||
use network::PeerId;
|
||||
use util::{RwLock, Mutex};
|
||||
use parking_lot::{RwLock, Mutex};
|
||||
|
||||
use net::{
|
||||
self, Handler, PeerStatus, Status, Capabilities,
|
||||
|
@ -25,13 +25,16 @@ use ethcore::receipt::Receipt;
|
||||
use ethcore::state::{self, ProvedExecution};
|
||||
use ethcore::transaction::SignedTransaction;
|
||||
use vm::EnvInfo;
|
||||
use hash::{KECCAK_NULL_RLP, KECCAK_EMPTY, KECCAK_EMPTY_LIST_RLP, keccak};
|
||||
|
||||
use request::{self as net_request, IncompleteRequest, CompleteRequest, Output, OutputKind, Field};
|
||||
|
||||
use rlp::{RlpStream, UntrustedRlp};
|
||||
use util::{Address, Bytes, DBValue, HashDB, Mutex, H256, U256};
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::H256;
|
||||
use parking_lot::Mutex;
|
||||
use util::{Address, Bytes, DBValue, HashDB};
|
||||
use util::memorydb::MemoryDB;
|
||||
use util::sha3::{Hashable, SHA3_NULL_RLP, SHA3_EMPTY, SHA3_EMPTY_LIST_RLP};
|
||||
use util::trie::{Trie, TrieDB, TrieError};
|
||||
|
||||
const SUPPLIED_MATCHES: &'static str = "supplied responses always match produced requests; enforced by `check_response`; qed";
|
||||
@ -276,7 +279,7 @@ impl From<Request> for CheckedRequest {
|
||||
Request::Account(req) => {
|
||||
let net_req = net_request::IncompleteAccountRequest {
|
||||
block_hash: req.header.field(),
|
||||
address_hash: ::util::Hashable::sha3(&req.address).into(),
|
||||
address_hash: ::hash::keccak(&req.address).into(),
|
||||
};
|
||||
CheckedRequest::Account(req, net_req)
|
||||
}
|
||||
@ -366,7 +369,7 @@ impl CheckedRequest {
|
||||
}
|
||||
CheckedRequest::Receipts(ref check, ref req) => {
|
||||
// empty transactions -> no receipts
|
||||
if check.0.as_ref().ok().map_or(false, |hdr| hdr.receipts_root() == SHA3_NULL_RLP) {
|
||||
if check.0.as_ref().ok().map_or(false, |hdr| hdr.receipts_root() == KECCAK_NULL_RLP) {
|
||||
return Some(Response::Receipts(Vec::new()));
|
||||
}
|
||||
|
||||
@ -377,7 +380,7 @@ impl CheckedRequest {
|
||||
CheckedRequest::Body(ref check, ref req) => {
|
||||
// check for empty body.
|
||||
if let Some(hdr) = check.0.as_ref().ok() {
|
||||
if hdr.transactions_root() == SHA3_NULL_RLP && hdr.uncles_hash() == SHA3_EMPTY_LIST_RLP {
|
||||
if hdr.transactions_root() == KECCAK_NULL_RLP && hdr.uncles_hash() == KECCAK_EMPTY_LIST_RLP {
|
||||
let mut stream = RlpStream::new_list(3);
|
||||
stream.append_raw(hdr.rlp().as_raw(), 1);
|
||||
stream.begin_list(0);
|
||||
@ -422,7 +425,7 @@ impl CheckedRequest {
|
||||
})
|
||||
}
|
||||
CheckedRequest::Code(_, ref req) => {
|
||||
if req.code_hash.as_ref().map_or(false, |&h| h == SHA3_EMPTY) {
|
||||
if req.code_hash.as_ref().map_or(false, |&h| h == KECCAK_EMPTY) {
|
||||
Some(Response::Code(Vec::new()))
|
||||
} else {
|
||||
None
|
||||
@ -571,8 +574,8 @@ impl net_request::ResponseLike for Response {
|
||||
match *self {
|
||||
Response::HeaderProof((ref hash, _)) => f(0, Output::Hash(*hash)),
|
||||
Response::Account(None) => {
|
||||
f(0, Output::Hash(SHA3_EMPTY)); // code hash
|
||||
f(1, Output::Hash(SHA3_NULL_RLP)); // storage root.
|
||||
f(0, Output::Hash(KECCAK_EMPTY)); // code hash
|
||||
f(1, Output::Hash(KECCAK_NULL_RLP)); // storage root.
|
||||
}
|
||||
Response::Account(Some(ref acc)) => {
|
||||
f(0, Output::Hash(acc.code_hash));
|
||||
@ -688,7 +691,7 @@ impl HeaderByHash {
|
||||
};
|
||||
|
||||
let header = headers.get(0).ok_or(Error::Empty)?;
|
||||
let hash = header.sha3();
|
||||
let hash = header.hash();
|
||||
match hash == expected_hash {
|
||||
true => {
|
||||
cache.lock().insert_block_header(hash, header.clone());
|
||||
@ -708,12 +711,12 @@ impl Body {
|
||||
pub fn check_response(&self, cache: &Mutex<::cache::Cache>, body: &encoded::Body) -> Result<encoded::Block, Error> {
|
||||
// check the integrity of the the body against the header
|
||||
let header = self.0.as_ref()?;
|
||||
let tx_root = ::util::triehash::ordered_trie_root(body.rlp().at(0).iter().map(|r| r.as_raw().to_vec()));
|
||||
let tx_root = ::triehash::ordered_trie_root(body.rlp().at(0).iter().map(|r| r.as_raw().to_vec()));
|
||||
if tx_root != header.transactions_root() {
|
||||
return Err(Error::WrongTrieRoot(header.transactions_root(), tx_root));
|
||||
}
|
||||
|
||||
let uncles_hash = body.rlp().at(1).as_raw().sha3();
|
||||
let uncles_hash = keccak(body.rlp().at(1).as_raw());
|
||||
if uncles_hash != header.uncles_hash() {
|
||||
return Err(Error::WrongHash(header.uncles_hash(), uncles_hash));
|
||||
}
|
||||
@ -738,7 +741,7 @@ impl BlockReceipts {
|
||||
/// Check a response with receipts against the stored header.
|
||||
pub fn check_response(&self, cache: &Mutex<::cache::Cache>, receipts: &[Receipt]) -> Result<Vec<Receipt>, Error> {
|
||||
let receipts_root = self.0.as_ref()?.receipts_root();
|
||||
let found_root = ::util::triehash::ordered_trie_root(receipts.iter().map(|r| ::rlp::encode(r).into_vec()));
|
||||
let found_root = ::triehash::ordered_trie_root(receipts.iter().map(|r| ::rlp::encode(r).into_vec()));
|
||||
|
||||
match receipts_root == found_root {
|
||||
true => {
|
||||
@ -768,7 +771,7 @@ impl Account {
|
||||
let mut db = MemoryDB::new();
|
||||
for node in proof { db.insert(&node[..]); }
|
||||
|
||||
match TrieDB::new(&db, &state_root).and_then(|t| t.get(&self.address.sha3()))? {
|
||||
match TrieDB::new(&db, &state_root).and_then(|t| t.get(&keccak(&self.address)))? {
|
||||
Some(val) => {
|
||||
let rlp = UntrustedRlp::new(&val);
|
||||
Ok(Some(BasicAccount {
|
||||
@ -800,7 +803,7 @@ impl Code {
|
||||
code_hash: &H256,
|
||||
code: &[u8]
|
||||
) -> Result<Vec<u8>, Error> {
|
||||
let found_hash = code.sha3();
|
||||
let found_hash = keccak(code);
|
||||
if &found_hash == code_hash {
|
||||
Ok(code.to_vec())
|
||||
} else {
|
||||
@ -850,9 +853,12 @@ impl TransactionProof {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use util::{MemoryDB, Address, Mutex, H256};
|
||||
use bigint::hash::H256;
|
||||
use util::{MemoryDB, Address};
|
||||
use parking_lot::Mutex;
|
||||
use util::trie::{Trie, TrieMut, SecTrieDB, SecTrieDBMut};
|
||||
use util::trie::recorder::Recorder;
|
||||
use hash::keccak;
|
||||
|
||||
use ethcore::client::{BlockChainClient, TestBlockChainClient, EachBlockWith};
|
||||
use ethcore::header::Header;
|
||||
@ -933,7 +939,7 @@ mod tests {
|
||||
}).collect::<Vec<_>>();
|
||||
|
||||
let mut header = Header::new();
|
||||
let receipts_root = ::util::triehash::ordered_trie_root(
|
||||
let receipts_root = ::triehash::ordered_trie_root(
|
||||
receipts.iter().map(|x| ::rlp::encode(x).into_vec())
|
||||
);
|
||||
|
||||
@ -998,7 +1004,7 @@ mod tests {
|
||||
#[test]
|
||||
fn check_code() {
|
||||
let code = vec![1u8; 256];
|
||||
let code_hash = ::util::Hashable::sha3(&code);
|
||||
let code_hash = keccak(&code);
|
||||
let header = Header::new();
|
||||
let req = Code {
|
||||
header: encoded::Header::new(::rlp::encode(&header).into_vec()).into(),
|
||||
|
@ -22,7 +22,8 @@ use ethcore::header::{Header, Seal};
|
||||
use futures::Future;
|
||||
use network::{PeerId, NodeId};
|
||||
use net::*;
|
||||
use util::{H256, Mutex};
|
||||
use bigint::hash::H256;
|
||||
use parking_lot::Mutex;
|
||||
use time::Duration;
|
||||
use ::request::{self as basic_request, Response};
|
||||
|
||||
|
@ -24,7 +24,8 @@ use ethcore::client::{BlockChainClient, ProvingBlockChainClient};
|
||||
use ethcore::transaction::PendingTransaction;
|
||||
use ethcore::ids::BlockId;
|
||||
use ethcore::encoded;
|
||||
use util::{RwLock, H256};
|
||||
use bigint::hash::H256;
|
||||
use parking_lot::RwLock;
|
||||
|
||||
use cht::{self, BlockInfo};
|
||||
use client::{LightChainClient, AsLightClient};
|
||||
|
@ -28,7 +28,9 @@ use std::collections::hash_map::Entry;
|
||||
|
||||
use ethcore::error::{TransactionError, TransactionImportResult};
|
||||
use ethcore::transaction::{Condition, PendingTransaction, SignedTransaction};
|
||||
use util::{Address, U256, H256, H256FastMap};
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::{H256, H256FastMap};
|
||||
use util::Address;
|
||||
|
||||
// Knowledge of an account's current nonce.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
@ -211,7 +211,7 @@ impl<T: IncompleteRequest> DerefMut for Requests<T> {
|
||||
mod tests {
|
||||
use request::*;
|
||||
use super::RequestBuilder;
|
||||
use util::H256;
|
||||
use bigint::hash::H256;
|
||||
|
||||
#[test]
|
||||
fn all_scalar() {
|
||||
|
@ -17,7 +17,7 @@
|
||||
//! Light protocol request types.
|
||||
|
||||
use rlp::{Encodable, Decodable, DecoderError, RlpStream, UntrustedRlp};
|
||||
use util::H256;
|
||||
use bigint::hash::H256;
|
||||
|
||||
mod builder;
|
||||
|
||||
@ -760,7 +760,9 @@ pub mod header {
|
||||
pub mod header_proof {
|
||||
use super::{Field, NoSuchOutput, OutputKind, Output};
|
||||
use rlp::{Encodable, Decodable, DecoderError, RlpStream, UntrustedRlp};
|
||||
use util::{Bytes, U256, H256};
|
||||
use bigint::hash::H256;
|
||||
use bigint::prelude::U256;
|
||||
use util::Bytes;
|
||||
|
||||
/// Potentially incomplete header proof request.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)]
|
||||
@ -854,7 +856,7 @@ pub mod header_proof {
|
||||
/// Request and response for transaction index.
|
||||
pub mod transaction_index {
|
||||
use super::{Field, NoSuchOutput, OutputKind, Output};
|
||||
use util::H256;
|
||||
use bigint::hash::H256;
|
||||
|
||||
/// Potentially incomplete transaction index request.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)]
|
||||
@ -932,7 +934,7 @@ pub mod transaction_index {
|
||||
pub mod block_receipts {
|
||||
use super::{Field, NoSuchOutput, OutputKind, Output};
|
||||
use ethcore::receipt::Receipt;
|
||||
use util::H256;
|
||||
use bigint::hash::H256;
|
||||
|
||||
/// Potentially incomplete block receipts request.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)]
|
||||
@ -1001,7 +1003,7 @@ pub mod block_body {
|
||||
use super::{Field, NoSuchOutput, OutputKind, Output};
|
||||
use ethcore::encoded;
|
||||
use rlp::{Encodable, Decodable, DecoderError, RlpStream, UntrustedRlp};
|
||||
use util::H256;
|
||||
use bigint::hash::H256;
|
||||
|
||||
/// Potentially incomplete block body request.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)]
|
||||
@ -1089,7 +1091,9 @@ pub mod block_body {
|
||||
/// A request for an account proof.
|
||||
pub mod account {
|
||||
use super::{Field, NoSuchOutput, OutputKind, Output};
|
||||
use util::{Bytes, U256, H256};
|
||||
use bigint::hash::H256;
|
||||
use bigint::prelude::U256;
|
||||
use util::Bytes;
|
||||
|
||||
/// Potentially incomplete request for an account proof.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)]
|
||||
@ -1188,7 +1192,8 @@ pub mod account {
|
||||
/// A request for a storage proof.
|
||||
pub mod storage {
|
||||
use super::{Field, NoSuchOutput, OutputKind, Output};
|
||||
use util::{Bytes, H256};
|
||||
use bigint::hash::H256;
|
||||
use util::Bytes;
|
||||
|
||||
/// Potentially incomplete request for an storage proof.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)]
|
||||
@ -1296,7 +1301,8 @@ pub mod storage {
|
||||
/// A request for contract code.
|
||||
pub mod contract_code {
|
||||
use super::{Field, NoSuchOutput, OutputKind, Output};
|
||||
use util::{Bytes, H256};
|
||||
use bigint::hash::H256;
|
||||
use util::Bytes;
|
||||
|
||||
/// Potentially incomplete contract code request.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)]
|
||||
@ -1382,7 +1388,9 @@ pub mod execution {
|
||||
use super::{Field, NoSuchOutput, OutputKind, Output};
|
||||
use ethcore::transaction::Action;
|
||||
use rlp::{Encodable, Decodable, DecoderError, RlpStream, UntrustedRlp};
|
||||
use util::{Bytes, Address, U256, H256, DBValue};
|
||||
use bigint::hash::H256;
|
||||
use bigint::prelude::U256;
|
||||
use util::{Bytes, Address, DBValue};
|
||||
|
||||
/// Potentially incomplete execution proof request.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)]
|
||||
@ -1591,7 +1599,7 @@ mod tests {
|
||||
let full_req = Request::TransactionIndex(req.clone());
|
||||
let res = TransactionIndexResponse {
|
||||
num: 1000,
|
||||
hash: ::util::H256::random(),
|
||||
hash: ::bigint::hash::H256::random(),
|
||||
index: 4,
|
||||
};
|
||||
let full_res = Response::TransactionIndex(res.clone());
|
||||
|
@ -29,6 +29,7 @@ const SECRETSTORE_ACL_STORAGE_ABI: &'static str = include_str!("res/secretstore_
|
||||
const VALIDATOR_SET_ABI: &'static str = include_str!("res/validator_set.json");
|
||||
const VALIDATOR_REPORT_ABI: &'static str = include_str!("res/validator_report.json");
|
||||
const PEER_SET_ABI: &'static str = include_str!("res/peer_set.json");
|
||||
const TX_ACL_ABI: &'static str = include_str!("res/tx_acl.json");
|
||||
|
||||
const TEST_VALIDATOR_SET_ABI: &'static str = include_str!("res/test_validator_set.json");
|
||||
|
||||
@ -55,6 +56,7 @@ fn main() {
|
||||
build_file("ValidatorSet", VALIDATOR_SET_ABI, "validator_set.rs");
|
||||
build_file("ValidatorReport", VALIDATOR_REPORT_ABI, "validator_report.rs");
|
||||
build_file("PeerSet", PEER_SET_ABI, "peer_set.rs");
|
||||
build_file("TransactAcl", TX_ACL_ABI, "tx_acl.rs");
|
||||
|
||||
build_test_contracts();
|
||||
}
|
||||
|
@ -302,7 +302,8 @@ fn detokenize(name: &str, output_type: ParamType) -> String {
|
||||
}
|
||||
ParamType::Uint(width) => {
|
||||
let read_uint = match width {
|
||||
8 | 16 | 32 | 64 => format!("bigint::prelude::U256(u).low_u64() as u{}", width),
|
||||
8 => "u[31] as u8".into(),
|
||||
16 | 32 | 64 => format!("BigEndian::read_u{}(&u[{}..])", width, 32 - (width / 8)),
|
||||
_ => format!("bigint::prelude::U{}::from(&u[..])", width),
|
||||
};
|
||||
|
||||
|
1
ethcore/native_contracts/res/tx_acl.json
Normal file
1
ethcore/native_contracts/res/tx_acl.json
Normal file
@ -0,0 +1 @@
|
||||
[{"constant":false,"inputs":[{"name":"sender","type":"address"}],"name":"allowedTxTypes","outputs":[{"name":"","type":"uint32"}],"payable":false,"stateMutability":"nonpayable","type":"function"}]
|
@ -31,6 +31,7 @@ mod secretstore_acl_storage;
|
||||
mod validator_set;
|
||||
mod validator_report;
|
||||
mod peer_set;
|
||||
mod tx_acl;
|
||||
|
||||
pub mod test_contracts;
|
||||
|
||||
@ -42,3 +43,4 @@ pub use self::secretstore_acl_storage::SecretStoreAclStorage;
|
||||
pub use self::validator_set::ValidatorSet;
|
||||
pub use self::validator_report::ValidatorReport;
|
||||
pub use self::peer_set::PeerSet;
|
||||
pub use self::tx_acl::TransactAcl;
|
||||
|
@ -14,7 +14,8 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
extern {
|
||||
pub fn sha3_256(out: *mut u8, outlen: usize, input: *const u8, inputlen: usize) -> i32;
|
||||
pub fn sha3_512(out: *mut u8, outlen: usize, input: *const u8, inputlen: usize) -> i32;
|
||||
}
|
||||
#![allow(unused_mut, unused_variables, unused_imports)]
|
||||
|
||||
//! Transact permissions contract.
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/tx_acl.rs"));
|
@ -9,8 +9,10 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
[dependencies]
|
||||
ethcore = { path = ".."}
|
||||
ethcore-util = { path = "../../util" }
|
||||
ethcore-bigint = { path = "../../util/bigint" }
|
||||
ethcore-io = { path = "../../util/io" }
|
||||
ethcore-network = { path = "../../util/network" }
|
||||
native-contracts = { path = "../native_contracts" }
|
||||
futures = "0.1"
|
||||
log = "0.3"
|
||||
parking_lot = "0.4"
|
||||
|
@ -18,9 +18,11 @@
|
||||
|
||||
extern crate ethcore;
|
||||
extern crate ethcore_util as util;
|
||||
extern crate ethcore_bigint as bigint;
|
||||
extern crate ethcore_network as network;
|
||||
extern crate native_contracts;
|
||||
extern crate futures;
|
||||
extern crate parking_lot;
|
||||
#[cfg(test)] extern crate ethcore_io as io;
|
||||
#[macro_use] extern crate log;
|
||||
|
||||
@ -29,7 +31,9 @@ use std::collections::HashMap;
|
||||
use native_contracts::PeerSet as Contract;
|
||||
use network::{NodeId, ConnectionFilter, ConnectionDirection};
|
||||
use ethcore::client::{BlockChainClient, BlockId, ChainNotify};
|
||||
use util::{Mutex, Address, H256, Bytes};
|
||||
use bigint::hash::H256;
|
||||
use util::{Address, Bytes};
|
||||
use parking_lot::Mutex;
|
||||
use futures::Future;
|
||||
|
||||
const MAX_CACHE_SIZE: usize = 4096;
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
//! DB backend wrapper for Account trie
|
||||
use std::collections::HashMap;
|
||||
use hash::{KECCAK_NULL_RLP, keccak};
|
||||
use bigint::hash::H256;
|
||||
use util::*;
|
||||
use rlp::NULL_RLP;
|
||||
|
||||
@ -79,7 +81,7 @@ impl<'db> AccountDB<'db> {
|
||||
/// Create a new AccountDB from an address.
|
||||
#[cfg(test)]
|
||||
pub fn new(db: &'db HashDB, address: &Address) -> Self {
|
||||
Self::from_hash(db, address.sha3())
|
||||
Self::from_hash(db, keccak(address))
|
||||
}
|
||||
|
||||
/// Create a new AcountDB from an address' hash.
|
||||
@ -97,14 +99,14 @@ impl<'db> HashDB for AccountDB<'db>{
|
||||
}
|
||||
|
||||
fn get(&self, key: &H256) -> Option<DBValue> {
|
||||
if key == &SHA3_NULL_RLP {
|
||||
if key == &KECCAK_NULL_RLP {
|
||||
return Some(DBValue::from_slice(&NULL_RLP));
|
||||
}
|
||||
self.db.get(&combine_key(&self.address_hash, key))
|
||||
}
|
||||
|
||||
fn contains(&self, key: &H256) -> bool {
|
||||
if key == &SHA3_NULL_RLP {
|
||||
if key == &KECCAK_NULL_RLP {
|
||||
return true;
|
||||
}
|
||||
self.db.contains(&combine_key(&self.address_hash, key))
|
||||
@ -133,7 +135,7 @@ impl<'db> AccountDBMut<'db> {
|
||||
/// Create a new AccountDB from an address.
|
||||
#[cfg(test)]
|
||||
pub fn new(db: &'db mut HashDB, address: &Address) -> Self {
|
||||
Self::from_hash(db, address.sha3())
|
||||
Self::from_hash(db, keccak(address))
|
||||
}
|
||||
|
||||
/// Create a new AcountDB from an address' hash.
|
||||
@ -156,14 +158,14 @@ impl<'db> HashDB for AccountDBMut<'db>{
|
||||
}
|
||||
|
||||
fn get(&self, key: &H256) -> Option<DBValue> {
|
||||
if key == &SHA3_NULL_RLP {
|
||||
if key == &KECCAK_NULL_RLP {
|
||||
return Some(DBValue::from_slice(&NULL_RLP));
|
||||
}
|
||||
self.db.get(&combine_key(&self.address_hash, key))
|
||||
}
|
||||
|
||||
fn contains(&self, key: &H256) -> bool {
|
||||
if key == &SHA3_NULL_RLP {
|
||||
if key == &KECCAK_NULL_RLP {
|
||||
return true;
|
||||
}
|
||||
self.db.contains(&combine_key(&self.address_hash, key))
|
||||
@ -171,16 +173,16 @@ impl<'db> HashDB for AccountDBMut<'db>{
|
||||
|
||||
fn insert(&mut self, value: &[u8]) -> H256 {
|
||||
if value == &NULL_RLP {
|
||||
return SHA3_NULL_RLP.clone();
|
||||
return KECCAK_NULL_RLP.clone();
|
||||
}
|
||||
let k = value.sha3();
|
||||
let k = keccak(value);
|
||||
let ak = combine_key(&self.address_hash, &k);
|
||||
self.db.emplace(ak, DBValue::from_slice(value));
|
||||
k
|
||||
}
|
||||
|
||||
fn emplace(&mut self, key: H256, value: DBValue) {
|
||||
if key == SHA3_NULL_RLP {
|
||||
if key == KECCAK_NULL_RLP {
|
||||
return;
|
||||
}
|
||||
let key = combine_key(&self.address_hash, &key);
|
||||
@ -188,7 +190,7 @@ impl<'db> HashDB for AccountDBMut<'db>{
|
||||
}
|
||||
|
||||
fn remove(&mut self, key: &H256) {
|
||||
if key == &SHA3_NULL_RLP {
|
||||
if key == &KECCAK_NULL_RLP {
|
||||
return;
|
||||
}
|
||||
let key = combine_key(&self.address_hash, key);
|
||||
@ -204,14 +206,14 @@ impl<'db> HashDB for Wrapping<'db> {
|
||||
}
|
||||
|
||||
fn get(&self, key: &H256) -> Option<DBValue> {
|
||||
if key == &SHA3_NULL_RLP {
|
||||
if key == &KECCAK_NULL_RLP {
|
||||
return Some(DBValue::from_slice(&NULL_RLP));
|
||||
}
|
||||
self.0.get(key)
|
||||
}
|
||||
|
||||
fn contains(&self, key: &H256) -> bool {
|
||||
if key == &SHA3_NULL_RLP {
|
||||
if key == &KECCAK_NULL_RLP {
|
||||
return true;
|
||||
}
|
||||
self.0.contains(key)
|
||||
@ -238,14 +240,14 @@ impl<'db> HashDB for WrappingMut<'db>{
|
||||
}
|
||||
|
||||
fn get(&self, key: &H256) -> Option<DBValue> {
|
||||
if key == &SHA3_NULL_RLP {
|
||||
if key == &KECCAK_NULL_RLP {
|
||||
return Some(DBValue::from_slice(&NULL_RLP));
|
||||
}
|
||||
self.0.get(key)
|
||||
}
|
||||
|
||||
fn contains(&self, key: &H256) -> bool {
|
||||
if key == &SHA3_NULL_RLP {
|
||||
if key == &KECCAK_NULL_RLP {
|
||||
return true;
|
||||
}
|
||||
self.0.contains(key)
|
||||
@ -253,20 +255,20 @@ impl<'db> HashDB for WrappingMut<'db>{
|
||||
|
||||
fn insert(&mut self, value: &[u8]) -> H256 {
|
||||
if value == &NULL_RLP {
|
||||
return SHA3_NULL_RLP.clone();
|
||||
return KECCAK_NULL_RLP.clone();
|
||||
}
|
||||
self.0.insert(value)
|
||||
}
|
||||
|
||||
fn emplace(&mut self, key: H256, value: DBValue) {
|
||||
if key == SHA3_NULL_RLP {
|
||||
if key == KECCAK_NULL_RLP {
|
||||
return;
|
||||
}
|
||||
self.0.emplace(key, value)
|
||||
}
|
||||
|
||||
fn remove(&mut self, key: &H256) {
|
||||
if key == &SHA3_NULL_RLP {
|
||||
if key == &KECCAK_NULL_RLP {
|
||||
return;
|
||||
}
|
||||
self.0.remove(key)
|
||||
|
@ -23,7 +23,7 @@ use self::stores::{AddressBook, DappsSettingsStore, NewDappsPolicy};
|
||||
use std::fmt;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::time::{Instant, Duration};
|
||||
use util::{RwLock};
|
||||
use parking_lot::RwLock;
|
||||
use ethstore::{
|
||||
SimpleSecretStore, SecretStore, Error as SSError, EthStore, EthMultiStore,
|
||||
random_string, SecretVaultRef, StoreAccountRef, OpaqueSecret,
|
||||
@ -794,7 +794,7 @@ mod tests {
|
||||
use std::time::Instant;
|
||||
use ethstore::ethkey::{Generator, Random, Address};
|
||||
use ethstore::{StoreAccountRef, Derivation};
|
||||
use util::H256;
|
||||
use bigint::hash::H256;
|
||||
|
||||
#[test]
|
||||
fn unlock_account_temp() {
|
||||
|
@ -20,7 +20,7 @@
|
||||
pub type LogBloom = ::log_entry::LogBloom;
|
||||
|
||||
/// Constant 2048-bit datum for 0. Often used as a default.
|
||||
pub static ZERO_LOGBLOOM: LogBloom = ::util::hash::H2048([0x00; 256]);
|
||||
pub static ZERO_LOGBLOOM: LogBloom = ::bigint::hash::H2048([0x00; 256]);
|
||||
|
||||
#[cfg_attr(feature="dev", allow(enum_variant_names))]
|
||||
/// Semantic boolean for when a seal/signature is included.
|
||||
|
@ -19,10 +19,14 @@
|
||||
use std::cmp;
|
||||
use std::sync::Arc;
|
||||
use std::collections::HashSet;
|
||||
use hash::{keccak, KECCAK_NULL_RLP, KECCAK_EMPTY_LIST_RLP};
|
||||
use triehash::ordered_trie_root;
|
||||
|
||||
use rlp::{UntrustedRlp, RlpStream, Encodable, Decodable, DecoderError};
|
||||
use util::{Bytes, Address, Hashable, U256, H256, ordered_trie_root, SHA3_NULL_RLP, SHA3_EMPTY_LIST_RLP};
|
||||
use util::error::{Mismatch, OutOfBounds};
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::H256;
|
||||
use util::{Bytes, Address};
|
||||
use unexpected::{Mismatch, OutOfBounds};
|
||||
|
||||
use basic_types::{LogBloom, Seal};
|
||||
use vm::{EnvInfo, LastHashes};
|
||||
@ -398,13 +402,13 @@ impl<'x> OpenBlock<'x> {
|
||||
if let Err(e) = s.engine.on_close_block(&mut s.block) {
|
||||
warn!("Encountered error on closing the block: {}", e);
|
||||
}
|
||||
|
||||
|
||||
if let Err(e) = s.block.state.commit() {
|
||||
warn!("Encountered error on state commit: {}", e);
|
||||
}
|
||||
s.block.header.set_transactions_root(ordered_trie_root(s.block.transactions.iter().map(|e| e.rlp_bytes().into_vec())));
|
||||
let uncle_bytes = s.block.uncles.iter().fold(RlpStream::new_list(s.block.uncles.len()), |mut s, u| {s.append_raw(&u.rlp(Seal::With), 1); s} ).out();
|
||||
s.block.header.set_uncles_hash(uncle_bytes.sha3());
|
||||
s.block.header.set_uncles_hash(keccak(&uncle_bytes));
|
||||
s.block.header.set_state_root(s.block.state.root().clone());
|
||||
s.block.header.set_receipts_root(ordered_trie_root(s.block.receipts.iter().map(|r| r.rlp_bytes().into_vec())));
|
||||
s.block.header.set_log_bloom(s.block.receipts.iter().fold(LogBloom::zero(), |mut b, r| {b = &b | &r.log_bloom; b})); //TODO: use |= operator
|
||||
@ -429,14 +433,14 @@ impl<'x> OpenBlock<'x> {
|
||||
if let Err(e) = s.block.state.commit() {
|
||||
warn!("Encountered error on state commit: {}", e);
|
||||
}
|
||||
if s.block.header.transactions_root().is_zero() || s.block.header.transactions_root() == &SHA3_NULL_RLP {
|
||||
if s.block.header.transactions_root().is_zero() || s.block.header.transactions_root() == &KECCAK_NULL_RLP {
|
||||
s.block.header.set_transactions_root(ordered_trie_root(s.block.transactions.iter().map(|e| e.rlp_bytes().into_vec())));
|
||||
}
|
||||
let uncle_bytes = s.block.uncles.iter().fold(RlpStream::new_list(s.block.uncles.len()), |mut s, u| {s.append_raw(&u.rlp(Seal::With), 1); s} ).out();
|
||||
if s.block.header.uncles_hash().is_zero() || s.block.header.uncles_hash() == &SHA3_EMPTY_LIST_RLP {
|
||||
s.block.header.set_uncles_hash(uncle_bytes.sha3());
|
||||
if s.block.header.uncles_hash().is_zero() || s.block.header.uncles_hash() == &KECCAK_EMPTY_LIST_RLP {
|
||||
s.block.header.set_uncles_hash(keccak(&uncle_bytes));
|
||||
}
|
||||
if s.block.header.receipts_root().is_zero() || s.block.header.receipts_root() == &SHA3_NULL_RLP {
|
||||
if s.block.header.receipts_root().is_zero() || s.block.header.receipts_root() == &KECCAK_NULL_RLP {
|
||||
s.block.header.set_receipts_root(ordered_trie_root(s.block.receipts.iter().map(|r| r.rlp_bytes().into_vec())));
|
||||
}
|
||||
|
||||
@ -469,7 +473,7 @@ impl<'x> IsBlock for LockedBlock {
|
||||
|
||||
impl ClosedBlock {
|
||||
/// Get the hash of the header without seal arguments.
|
||||
pub fn hash(&self) -> H256 { self.header().rlp_sha3(Seal::Without) }
|
||||
pub fn hash(&self) -> H256 { self.header().rlp_keccak(Seal::Without) }
|
||||
|
||||
/// Turn this into a `LockedBlock`, unable to be reopened again.
|
||||
pub fn lock(self) -> LockedBlock {
|
||||
@ -494,7 +498,7 @@ impl ClosedBlock {
|
||||
|
||||
impl LockedBlock {
|
||||
/// Get the hash of the header without seal arguments.
|
||||
pub fn hash(&self) -> H256 { self.header().rlp_sha3(Seal::Without) }
|
||||
pub fn hash(&self) -> H256 { self.header().rlp_keccak(Seal::Without) }
|
||||
|
||||
/// Provide a valid seal in order to turn this into a `SealedBlock`.
|
||||
///
|
||||
|
@ -14,7 +14,9 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use util::{Bytes, U256, H256};
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::H256;
|
||||
use util::Bytes;
|
||||
use header::BlockNumber;
|
||||
|
||||
/// Best block info.
|
||||
|
@ -14,7 +14,8 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use util::{U256,H256};
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::H256;
|
||||
use header::BlockNumber;
|
||||
|
||||
/// Brief info about inserted block.
|
||||
|
@ -22,6 +22,9 @@ use std::mem;
|
||||
use itertools::Itertools;
|
||||
use bloomchain as bc;
|
||||
use heapsize::HeapSizeOf;
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::{H256, H2048};
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use util::*;
|
||||
use rlp::*;
|
||||
use header::*;
|
||||
@ -41,6 +44,7 @@ use db::{self, Writable, Readable, CacheUpdatePolicy};
|
||||
use cache_manager::CacheManager;
|
||||
use encoded;
|
||||
use engines::epoch::{Transition as EpochTransition, PendingTransition as PendingEpochTransition};
|
||||
use ansi_term::Colour;
|
||||
|
||||
const LOG_BLOOMS_LEVELS: usize = 3;
|
||||
const LOG_BLOOMS_ELEMENTS_PER_INDEX: usize = 16;
|
||||
@ -512,7 +516,7 @@ impl BlockChain {
|
||||
// we need to insert genesis into the cache
|
||||
let block = BlockView::new(genesis);
|
||||
let header = block.header_view();
|
||||
let hash = block.sha3();
|
||||
let hash = block.hash();
|
||||
|
||||
let details = BlockDetails {
|
||||
number: header.number(),
|
||||
@ -622,7 +626,7 @@ impl BlockChain {
|
||||
return None;
|
||||
}
|
||||
if let Some(extras) = self.db.read(db::COL_EXTRA, &best_block_hash) as Option<BlockDetails> {
|
||||
type DetailsKey = Key<BlockDetails, Target=H264>;
|
||||
type DetailsKey = Key<BlockDetails, Target=::bigint::hash::H264>;
|
||||
batch.delete(db::COL_EXTRA, &(DetailsKey::key(&best_block_hash)));
|
||||
let hash = extras.parent;
|
||||
let range = extras.number as bc::Number .. extras.number as bc::Number;
|
||||
@ -764,7 +768,7 @@ impl BlockChain {
|
||||
pub fn insert_unordered_block(&self, batch: &mut DBTransaction, bytes: &[u8], receipts: Vec<Receipt>, parent_td: Option<U256>, is_best: bool, is_ancient: bool) -> bool {
|
||||
let block = BlockView::new(bytes);
|
||||
let header = block.header_view();
|
||||
let hash = header.sha3();
|
||||
let hash = header.hash();
|
||||
|
||||
if self.is_known(&hash) {
|
||||
return false;
|
||||
@ -966,7 +970,7 @@ impl BlockChain {
|
||||
// create views onto rlp
|
||||
let block = BlockView::new(bytes);
|
||||
let header = block.header_view();
|
||||
let hash = header.sha3();
|
||||
let hash = header.hash();
|
||||
|
||||
if self.is_known_child(&header.parent_hash(), &hash) {
|
||||
return ImportRoute::none();
|
||||
@ -1005,7 +1009,7 @@ impl BlockChain {
|
||||
|
||||
/// Get inserted block info which is critical to prepare extras updates.
|
||||
fn block_info(&self, header: &HeaderView) -> BlockInfo {
|
||||
let hash = header.sha3();
|
||||
let hash = header.hash();
|
||||
let number = header.number();
|
||||
let parent_hash = header.parent_hash();
|
||||
let parent_details = self.block_details(&parent_hash).unwrap_or_else(|| panic!("Invalid parent hash: {:?}", parent_hash));
|
||||
@ -1466,9 +1470,9 @@ mod tests {
|
||||
#![cfg_attr(feature="dev", allow(similar_names))]
|
||||
use std::sync::Arc;
|
||||
use rustc_hex::FromHex;
|
||||
use hash::keccak;
|
||||
use util::kvdb::KeyValueDB;
|
||||
use util::hash::*;
|
||||
use util::sha3::Hashable;
|
||||
use bigint::hash::*;
|
||||
use receipt::Receipt;
|
||||
use blockchain::{BlockProvider, BlockChain, Config, ImportRoute};
|
||||
use tests::helpers::*;
|
||||
@ -1518,8 +1522,8 @@ mod tests {
|
||||
let mut finalizer = BlockFinalizer::default();
|
||||
let genesis = canon_chain.generate(&mut finalizer).unwrap();
|
||||
let first = canon_chain.generate(&mut finalizer).unwrap();
|
||||
let genesis_hash = BlockView::new(&genesis).header_view().sha3();
|
||||
let first_hash = BlockView::new(&first).header_view().sha3();
|
||||
let genesis_hash = BlockView::new(&genesis).header_view().hash();
|
||||
let first_hash = BlockView::new(&first).header_view().hash();
|
||||
|
||||
let db = new_db();
|
||||
let bc = new_chain(&genesis, db.clone());
|
||||
@ -1549,7 +1553,7 @@ mod tests {
|
||||
let mut canon_chain = ChainGenerator::default();
|
||||
let mut finalizer = BlockFinalizer::default();
|
||||
let genesis = canon_chain.generate(&mut finalizer).unwrap();
|
||||
let genesis_hash = BlockView::new(&genesis).header_view().sha3();
|
||||
let genesis_hash = BlockView::new(&genesis).header_view().hash();
|
||||
|
||||
let db = new_db();
|
||||
let bc = new_chain(&genesis, db.clone());
|
||||
@ -1558,7 +1562,7 @@ mod tests {
|
||||
let mut batch = db.transaction();
|
||||
for _ in 0..10 {
|
||||
let block = canon_chain.generate(&mut finalizer).unwrap();
|
||||
block_hashes.push(BlockView::new(&block).header_view().sha3());
|
||||
block_hashes.push(BlockView::new(&block).header_view().hash());
|
||||
bc.insert_block(&mut batch, &block, vec![]);
|
||||
bc.commit();
|
||||
}
|
||||
@ -1607,14 +1611,14 @@ mod tests {
|
||||
|
||||
assert_eq!(
|
||||
[&b4b, &b3b, &b2b].iter().map(|b| BlockView::new(b).header()).collect::<Vec<_>>(),
|
||||
bc.find_uncle_headers(&BlockView::new(&b4a).header_view().sha3(), 3).unwrap()
|
||||
bc.find_uncle_headers(&BlockView::new(&b4a).header_view().hash(), 3).unwrap()
|
||||
);
|
||||
|
||||
// TODO: insert block that already includes one of them as an uncle to check it's not allowed.
|
||||
}
|
||||
|
||||
fn secret() -> Secret {
|
||||
"".sha3().into()
|
||||
keccak("").into()
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1646,8 +1650,8 @@ mod tests {
|
||||
let b2 = fork_chain
|
||||
.generate(&mut fork_finalizer).unwrap();
|
||||
|
||||
let b1a_hash = BlockView::new(&b1a).header_view().sha3();
|
||||
let b2_hash = BlockView::new(&b2).header_view().sha3();
|
||||
let b1a_hash = BlockView::new(&b1a).header_view().hash();
|
||||
let b2_hash = BlockView::new(&b2).header_view().hash();
|
||||
|
||||
let t1_hash = t1.hash();
|
||||
|
||||
@ -1730,9 +1734,9 @@ mod tests {
|
||||
.with_transaction(t3.clone())
|
||||
.generate(&mut fork_finalizer).unwrap();
|
||||
|
||||
let b1a_hash = BlockView::new(&b1a).header_view().sha3();
|
||||
let b1b_hash = BlockView::new(&b1b).header_view().sha3();
|
||||
let b2_hash = BlockView::new(&b2).header_view().sha3();
|
||||
let b1a_hash = BlockView::new(&b1a).header_view().hash();
|
||||
let b1b_hash = BlockView::new(&b1b).header_view().hash();
|
||||
let b2_hash = BlockView::new(&b2).header_view().hash();
|
||||
|
||||
let t1_hash = t1.hash();
|
||||
let t2_hash = t2.hash();
|
||||
@ -1790,11 +1794,11 @@ mod tests {
|
||||
let b3b = canon_chain.fork(1).generate(&mut finalizer.fork()).unwrap();
|
||||
let b3a = canon_chain.generate(&mut finalizer).unwrap();
|
||||
|
||||
let genesis_hash = BlockView::new(&genesis).header_view().sha3();
|
||||
let b1_hash= BlockView::new(&b1).header_view().sha3();
|
||||
let b2_hash= BlockView::new(&b2).header_view().sha3();
|
||||
let b3a_hash= BlockView::new(&b3a).header_view().sha3();
|
||||
let b3b_hash= BlockView::new(&b3b).header_view().sha3();
|
||||
let genesis_hash = BlockView::new(&genesis).header_view().hash();
|
||||
let b1_hash= BlockView::new(&b1).header_view().hash();
|
||||
let b2_hash= BlockView::new(&b2).header_view().hash();
|
||||
let b3a_hash= BlockView::new(&b3a).header_view().hash();
|
||||
let b3b_hash= BlockView::new(&b3b).header_view().hash();
|
||||
|
||||
// b3a is a part of canon chain, whereas b3b is part of sidechain
|
||||
let best_block_hash = b3a_hash.clone();
|
||||
@ -1910,8 +1914,8 @@ mod tests {
|
||||
let mut finalizer = BlockFinalizer::default();
|
||||
let genesis = canon_chain.generate(&mut finalizer).unwrap();
|
||||
let first = canon_chain.generate(&mut finalizer).unwrap();
|
||||
let genesis_hash = BlockView::new(&genesis).header_view().sha3();
|
||||
let first_hash = BlockView::new(&first).header_view().sha3();
|
||||
let genesis_hash = BlockView::new(&genesis).header_view().hash();
|
||||
let first_hash = BlockView::new(&first).header_view().hash();
|
||||
let db = new_db();
|
||||
|
||||
{
|
||||
@ -2226,9 +2230,9 @@ mod tests {
|
||||
let genesis = canon_chain.generate(&mut finalizer).unwrap();
|
||||
let first = canon_chain.generate(&mut finalizer).unwrap();
|
||||
let second = canon_chain.generate(&mut finalizer).unwrap();
|
||||
let genesis_hash = BlockView::new(&genesis).header_view().sha3();
|
||||
let first_hash = BlockView::new(&first).header_view().sha3();
|
||||
let second_hash = BlockView::new(&second).header_view().sha3();
|
||||
let genesis_hash = BlockView::new(&genesis).header_view().hash();
|
||||
let first_hash = BlockView::new(&first).header_view().hash();
|
||||
let second_hash = BlockView::new(&second).header_view().hash();
|
||||
|
||||
let db = new_db();
|
||||
let bc = new_chain(&genesis, db.clone());
|
||||
@ -2266,7 +2270,7 @@ mod tests {
|
||||
// create a longer fork
|
||||
for i in 0..5 {
|
||||
let canon_block = canon_chain.generate(&mut finalizer).unwrap();
|
||||
let hash = BlockView::new(&canon_block).header_view().sha3();
|
||||
let hash = BlockView::new(&canon_block).header_view().hash();
|
||||
|
||||
bc.insert_block(&mut batch, &canon_block, vec![]);
|
||||
bc.insert_epoch_transition(&mut batch, i, EpochTransition {
|
||||
@ -2279,7 +2283,7 @@ mod tests {
|
||||
|
||||
assert_eq!(bc.best_block_number(), 5);
|
||||
|
||||
let hash = BlockView::new(&uncle).header_view().sha3();
|
||||
let hash = BlockView::new(&uncle).header_view().hash();
|
||||
bc.insert_block(&mut batch, &uncle, vec![]);
|
||||
bc.insert_epoch_transition(&mut batch, 999, EpochTransition {
|
||||
block_hash: hash,
|
||||
|
@ -26,7 +26,8 @@ use header::BlockNumber;
|
||||
use receipt::Receipt;
|
||||
|
||||
use heapsize::HeapSizeOf;
|
||||
use util::{H256, H264, U256};
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::{H256, H264};
|
||||
use util::kvdb::PREFIX_LEN as DB_PREFIX_LEN;
|
||||
|
||||
/// Represents index of extra data in database
|
||||
|
@ -15,7 +15,7 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use rlp::*;
|
||||
use util::{H256, H2048};
|
||||
use bigint::hash::{H256, H2048};
|
||||
use util::bytes::Bytes;
|
||||
use header::Header;
|
||||
use transaction::SignedTransaction;
|
||||
|
@ -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/>.
|
||||
|
||||
use util::hash::H2048;
|
||||
use bigint::hash::H2048;
|
||||
|
||||
pub trait WithBloom {
|
||||
fn with_bloom(self, bloom: H2048) -> Self where Self: Sized;
|
||||
|
@ -14,9 +14,8 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use util::hash::H256;
|
||||
use bigint::hash::H256;
|
||||
use util::bytes::Bytes;
|
||||
use util::sha3::Hashable;
|
||||
use views::BlockView;
|
||||
|
||||
#[derive(Default, Clone)]
|
||||
@ -46,7 +45,7 @@ impl<'a, I> Iterator for Complete<'a, I> where I: Iterator, <I as Iterator>::Ite
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
self.iter.next().map(|item| {
|
||||
let rlp = item.complete(self.finalizer.parent_hash.clone());
|
||||
self.finalizer.parent_hash = BlockView::new(&rlp).header_view().sha3();
|
||||
self.finalizer.parent_hash = BlockView::new(&rlp).header_view().hash();
|
||||
rlp
|
||||
})
|
||||
}
|
||||
|
@ -14,7 +14,9 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use util::{U256, H2048, Bytes};
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::H2048;
|
||||
use util::Bytes;
|
||||
use header::BlockNumber;
|
||||
use transaction::SignedTransaction;
|
||||
use super::fork::Fork;
|
||||
@ -110,8 +112,7 @@ impl Iterator for ChainGenerator {
|
||||
}
|
||||
|
||||
mod tests {
|
||||
use util::hash::{H256, H2048};
|
||||
use util::sha3::Hashable;
|
||||
use bigint::hash::{H256, H2048};
|
||||
use views::BlockView;
|
||||
use blockchain::generator::{ChainIterator, ChainGenerator, BlockFinalizer};
|
||||
|
||||
@ -129,7 +130,7 @@ mod tests {
|
||||
let b1_rlp = canon_chain.generate(&mut finalizer).unwrap();
|
||||
let b1 = BlockView::new(&b1_rlp);
|
||||
|
||||
assert_eq!(b1.header_view().parent_hash(), genesis.header_view().sha3());
|
||||
assert_eq!(b1.header_view().parent_hash(), genesis.header_view().hash());
|
||||
assert_eq!(b1.header_view().number(), 1);
|
||||
|
||||
let mut fork_chain = canon_chain.fork(1);
|
||||
@ -137,13 +138,13 @@ mod tests {
|
||||
let b2_rlp_fork = fork_chain.generate(&mut finalizer.fork()).unwrap();
|
||||
let b2_fork = BlockView::new(&b2_rlp_fork);
|
||||
|
||||
assert_eq!(b2_fork.header_view().parent_hash(), b1.header_view().sha3());
|
||||
assert_eq!(b2_fork.header_view().parent_hash(), b1.header_view().hash());
|
||||
assert_eq!(b2_fork.header_view().number(), 2);
|
||||
|
||||
let b2_rlp = canon_chain.generate(&mut finalizer).unwrap();
|
||||
let b2 = BlockView::new(&b2_rlp);
|
||||
|
||||
assert_eq!(b2.header_view().parent_hash(), b1.header_view().sha3());
|
||||
assert_eq!(b2.header_view().parent_hash(), b1.header_view().hash());
|
||||
assert_eq!(b2.header_view().number(), 2);
|
||||
assert!(b2.header_view().difficulty() > b2_fork.header_view().difficulty());
|
||||
}
|
||||
@ -163,7 +164,7 @@ mod tests {
|
||||
assert_eq!(block0.header_view().parent_hash(), H256::default());
|
||||
|
||||
assert_eq!(block1.header_view().number(), 1);
|
||||
assert_eq!(block1.header_view().parent_hash(), block0.header_view().sha3());
|
||||
assert_eq!(block1.header_view().parent_hash(), block0.header_view().hash());
|
||||
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
//! Import route.
|
||||
|
||||
use util::H256;
|
||||
use bigint::hash::H256;
|
||||
use blockchain::block_info::{BlockInfo, BlockLocation};
|
||||
|
||||
/// Import route for newly inserted block.
|
||||
@ -67,7 +67,8 @@ impl From<BlockInfo> for ImportRoute {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use util::{U256, H256};
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::H256;
|
||||
use blockchain::block_info::{BlockInfo, BlockLocation, BranchBecomingCanonChainData};
|
||||
use blockchain::ImportRoute;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
use std::collections::HashMap;
|
||||
use util::H256;
|
||||
use bigint::hash::H256;
|
||||
use header::BlockNumber;
|
||||
use blockchain::block_info::BlockInfo;
|
||||
use blooms::BloomGroup;
|
||||
|
@ -23,7 +23,10 @@ use crypto::ripemd160::Ripemd160 as Ripemd160Digest;
|
||||
use crypto::digest::Digest;
|
||||
use num::{BigUint, Zero, One};
|
||||
|
||||
use util::{U256, H256, Hashable, BytesRef};
|
||||
use hash::keccak;
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::H256;
|
||||
use util::BytesRef;
|
||||
use ethkey::{Signature, recover as ec_recover};
|
||||
use ethjson;
|
||||
|
||||
@ -228,7 +231,7 @@ impl Impl for EcRecover {
|
||||
let s = Signature::from_rsv(&r, &s, bit);
|
||||
if s.is_valid() {
|
||||
if let Ok(p) = ec_recover(&s, &hash) {
|
||||
let r = p.sha3();
|
||||
let r = keccak(p);
|
||||
output.write(0, &[0; 12]);
|
||||
output.write(12, &r[12..r.len()]);
|
||||
}
|
||||
@ -266,6 +269,34 @@ impl Impl for Ripemd160 {
|
||||
}
|
||||
}
|
||||
|
||||
// calculate modexp: exponentiation by squaring. the `num` crate has pow, but not modular.
|
||||
fn modexp(mut base: BigUint, mut exp: BigUint, modulus: BigUint) -> BigUint {
|
||||
use num::Integer;
|
||||
|
||||
match (base.is_zero(), exp.is_zero()) {
|
||||
(_, true) => return BigUint::one(), // n^0 % m
|
||||
(true, false) => return BigUint::zero(), // 0^n % m, n>0
|
||||
(false, false) if modulus <= BigUint::one() => return BigUint::zero(), // a^b % 1 = 0.
|
||||
_ => {}
|
||||
}
|
||||
|
||||
let mut result = BigUint::one();
|
||||
base = base % &modulus;
|
||||
|
||||
// fast path for base divisible by modulus.
|
||||
if base.is_zero() { return BigUint::zero() }
|
||||
while !exp.is_zero() {
|
||||
if exp.is_odd() {
|
||||
result = (result * &base) % &modulus;
|
||||
}
|
||||
|
||||
exp = exp >> 1;
|
||||
base = (base.clone() * base) % &modulus;
|
||||
}
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
impl Impl for ModexpImpl {
|
||||
fn execute(&self, input: &[u8], output: &mut BytesRef) -> Result<(), Error> {
|
||||
let mut reader = input.chain(io::repeat(0));
|
||||
@ -294,34 +325,6 @@ impl Impl for ModexpImpl {
|
||||
let exp = read_num(exp_len);
|
||||
let modulus = read_num(mod_len);
|
||||
|
||||
// calculate modexp: exponentiation by squaring. the `num` crate has pow, but not modular.
|
||||
fn modexp(mut base: BigUint, mut exp: BigUint, modulus: BigUint) -> BigUint {
|
||||
use num::Integer;
|
||||
|
||||
match (base.is_zero(), exp.is_zero()) {
|
||||
(_, true) => return BigUint::one(), // n^0 % m
|
||||
(true, false) => return BigUint::zero(), // 0^n % m, n>0
|
||||
(false, false) if modulus <= BigUint::one() => return BigUint::zero(), // a^b % 1 = 0.
|
||||
_ => {}
|
||||
}
|
||||
|
||||
let mut result = BigUint::one();
|
||||
base = base % &modulus;
|
||||
|
||||
// fast path for base divisible by modulus.
|
||||
if base.is_zero() { return result }
|
||||
while !exp.is_zero() {
|
||||
if exp.is_odd() {
|
||||
result = (result * &base) % &modulus;
|
||||
}
|
||||
|
||||
exp = exp >> 1;
|
||||
base = (base.clone() * base) % &modulus;
|
||||
}
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
// write output to given memory, left padded and same length as the modulus.
|
||||
let bytes = modexp(base, exp, modulus).to_bytes_be();
|
||||
|
||||
@ -503,10 +506,45 @@ impl Impl for Bn128PairingImpl {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{Builtin, Linear, ethereum_builtin, Pricer, Modexp};
|
||||
use super::{Builtin, Linear, ethereum_builtin, Pricer, Modexp, modexp as me};
|
||||
use ethjson;
|
||||
use util::{U256, BytesRef};
|
||||
use bigint::prelude::U256;
|
||||
use util::BytesRef;
|
||||
use rustc_hex::FromHex;
|
||||
use num::{BigUint, Zero, One};
|
||||
|
||||
#[test]
|
||||
fn modexp_func() {
|
||||
// n^0 % m == 1
|
||||
let mut base = BigUint::parse_bytes(b"12345", 10).unwrap();
|
||||
let mut exp = BigUint::zero();
|
||||
let mut modulus = BigUint::parse_bytes(b"789", 10).unwrap();
|
||||
assert_eq!(me(base, exp, modulus), BigUint::one());
|
||||
|
||||
// 0^n % m == 0
|
||||
base = BigUint::zero();
|
||||
exp = BigUint::parse_bytes(b"12345", 10).unwrap();
|
||||
modulus = BigUint::parse_bytes(b"789", 10).unwrap();
|
||||
assert_eq!(me(base, exp, modulus), BigUint::zero());
|
||||
|
||||
// n^m % 1 == 0
|
||||
base = BigUint::parse_bytes(b"12345", 10).unwrap();
|
||||
exp = BigUint::parse_bytes(b"789", 10).unwrap();
|
||||
modulus = BigUint::one();
|
||||
assert_eq!(me(base, exp, modulus), BigUint::zero());
|
||||
|
||||
// if n % d == 0, then n^m % d == 0
|
||||
base = BigUint::parse_bytes(b"12345", 10).unwrap();
|
||||
exp = BigUint::parse_bytes(b"789", 10).unwrap();
|
||||
modulus = BigUint::parse_bytes(b"15", 10).unwrap();
|
||||
assert_eq!(me(base, exp, modulus), BigUint::zero());
|
||||
|
||||
// others
|
||||
base = BigUint::parse_bytes(b"12345", 10).unwrap();
|
||||
exp = BigUint::parse_bytes(b"789", 10).unwrap();
|
||||
modulus = BigUint::parse_bytes(b"97", 10).unwrap();
|
||||
assert_eq!(me(base, exp, modulus), BigUint::parse_bytes(b"55", 10).unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn identity() {
|
||||
@ -572,14 +610,6 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn ecrecover() {
|
||||
/*let k = KeyPair::from_secret(b"test".sha3()).unwrap();
|
||||
let a: Address = From::from(k.public().sha3());
|
||||
println!("Address: {}", a);
|
||||
let m = b"hello world".sha3();
|
||||
println!("Message: {}", m);
|
||||
let s = k.sign(&m).unwrap();
|
||||
println!("Signed: {}", s);*/
|
||||
|
||||
let f = ethereum_builtin("ecrecover");
|
||||
|
||||
let i = FromHex::from_hex("47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad000000000000000000000000000000000000000000000000000000000000001b650acf9d3f5f0a2c799776a1254355d5f4061762a237396a99a0e0e3fc2bcd6729514a0dacb2e623ac4abd157cb18163ff942280db4d5caad66ddf941ba12e03").unwrap();
|
||||
|
@ -23,7 +23,7 @@ use engines::{Engine, EpochVerifier};
|
||||
use header::Header;
|
||||
|
||||
use rand::Rng;
|
||||
use util::RwLock;
|
||||
use parking_lot::RwLock;
|
||||
|
||||
// do "heavy" verification on ~1/50 blocks, randomly sampled.
|
||||
const HEAVY_VERIFY_RATE: f32 = 0.02;
|
||||
|
@ -15,7 +15,8 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use ipc::IpcConfig;
|
||||
use util::{H256, Bytes};
|
||||
use bigint::hash::H256;
|
||||
use util::Bytes;
|
||||
|
||||
/// Represents what has to be handled by actor listening to chain events
|
||||
#[ipc]
|
||||
|
@ -23,13 +23,18 @@ use time::precise_time_ns;
|
||||
use itertools::Itertools;
|
||||
|
||||
// util
|
||||
use util::{Bytes, PerfTimer, Mutex, RwLock, MutexGuard, Hashable};
|
||||
use hash::keccak;
|
||||
use timer::PerfTimer;
|
||||
use util::UtilError;
|
||||
use util::Bytes;
|
||||
use util::{journaldb, DBValue, TrieFactory, Trie};
|
||||
use util::{U256, H256, Address, H2048};
|
||||
use util::Address;
|
||||
use util::trie::TrieSpec;
|
||||
use util::kvdb::*;
|
||||
|
||||
// other
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::{H256, H2048};
|
||||
use basic_types::Seal;
|
||||
use block::*;
|
||||
use blockchain::{BlockChain, BlockProvider, TreeRoute, ImportRoute};
|
||||
@ -54,6 +59,7 @@ use io::*;
|
||||
use log_entry::LocalizedLogEntry;
|
||||
use miner::{Miner, MinerService, TransactionImportResult};
|
||||
use native_contracts::Registry;
|
||||
use parking_lot::{Mutex, RwLock, MutexGuard};
|
||||
use rand::OsRng;
|
||||
use receipt::{Receipt, LocalizedReceipt};
|
||||
use rlp::UntrustedRlp;
|
||||
@ -247,7 +253,7 @@ impl Client {
|
||||
last_hashes: RwLock::new(VecDeque::new()),
|
||||
factories: factories,
|
||||
history: history,
|
||||
rng: Mutex::new(OsRng::new().map_err(::util::UtilError::StdIo)?),
|
||||
rng: Mutex::new(OsRng::new().map_err(UtilError::from)?),
|
||||
ancient_verifier: Mutex::new(None),
|
||||
on_user_defaults_change: Mutex::new(None),
|
||||
registrar: Mutex::new(None),
|
||||
@ -652,7 +658,7 @@ impl Client {
|
||||
.map(Into::into)
|
||||
.collect();
|
||||
|
||||
assert_eq!(header.hash(), BlockView::new(block_data).header_view().sha3());
|
||||
assert_eq!(header.hash(), BlockView::new(block_data).header_view().hash());
|
||||
|
||||
//let traces = From::from(block.traces().clone().unwrap_or_else(Vec::new));
|
||||
|
||||
@ -1126,7 +1132,9 @@ impl Client {
|
||||
T: trace::Tracer,
|
||||
V: trace::VMTracer,
|
||||
{
|
||||
let options = options.dont_check_nonce();
|
||||
let options = options
|
||||
.dont_check_nonce()
|
||||
.save_output_from_contract();
|
||||
let original_state = if state_diff { Some(state.clone()) } else { None };
|
||||
|
||||
let mut ret = Executive::new(state, env_info, engine).transact_virtual(transaction, options)?;
|
||||
@ -1440,6 +1448,10 @@ impl BlockChainClient for Client {
|
||||
self.state_at(id).and_then(|s| s.code(address).ok()).map(|c| c.map(|c| (&*c).clone()))
|
||||
}
|
||||
|
||||
fn code_hash(&self, address: &Address, id: BlockId) -> Option<H256> {
|
||||
self.state_at(id).and_then(|s| s.code_hash(address).ok())
|
||||
}
|
||||
|
||||
fn balance(&self, address: &Address, id: BlockId) -> Option<U256> {
|
||||
self.state_at(id).and_then(|s| s.balance(address).ok())
|
||||
}
|
||||
@ -1503,7 +1515,7 @@ impl BlockChainClient for Client {
|
||||
};
|
||||
|
||||
let (_, db) = state.drop();
|
||||
let account_db = self.factories.accountdb.readonly(db.as_hashdb(), account.sha3());
|
||||
let account_db = self.factories.accountdb.readonly(db.as_hashdb(), keccak(account));
|
||||
let trie = match self.factories.trie.readonly(account_db.as_hashdb(), &root) {
|
||||
Ok(trie) => trie,
|
||||
_ => {
|
||||
@ -1591,7 +1603,7 @@ impl BlockChainClient for Client {
|
||||
use verification::queue::kind::BlockLike;
|
||||
use verification::queue::kind::blocks::Unverified;
|
||||
|
||||
// create unverified block here so the `sha3` calculation can be cached.
|
||||
// create unverified block here so the `keccak` calculation can be cached.
|
||||
let unverified = Unverified::new(bytes);
|
||||
|
||||
{
|
||||
@ -1792,7 +1804,7 @@ impl BlockChainClient for Client {
|
||||
let dispatch = move |reg_addr, data| {
|
||||
future::done(self.call_contract(BlockId::Latest, reg_addr, data))
|
||||
};
|
||||
r.get_address(dispatch, name.as_bytes().sha3(), "A".to_string()).wait().ok()
|
||||
r.get_address(dispatch, keccak(name.as_bytes()), "A".to_string()).wait().ok()
|
||||
})
|
||||
.and_then(|a| if a.is_zero() { None } else { Some(a) })
|
||||
}
|
||||
@ -2067,16 +2079,16 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn should_return_correct_log_index() {
|
||||
use hash::keccak;
|
||||
use super::transaction_receipt;
|
||||
use ethkey::KeyPair;
|
||||
use log_entry::{LogEntry, LocalizedLogEntry};
|
||||
use receipt::{Receipt, LocalizedReceipt};
|
||||
use transaction::{Transaction, LocalizedTransaction, Action};
|
||||
use util::Hashable;
|
||||
use tests::helpers::TestEngine;
|
||||
|
||||
// given
|
||||
let key = KeyPair::from_secret_slice(&"test".sha3()).unwrap();
|
||||
let key = KeyPair::from_secret_slice(&keccak("test")).unwrap();
|
||||
let secret = key.secret();
|
||||
let engine = TestEngine::new(0);
|
||||
|
||||
|
@ -18,7 +18,9 @@
|
||||
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
use util::{self, U256, H256, journaldb, trie};
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::H256;
|
||||
use util::{self, journaldb, trie};
|
||||
use util::kvdb::{self, KeyValueDB};
|
||||
use {state, state_db, client, executive, trace, transaction, db, spec, pod_state};
|
||||
use factory::Factories;
|
||||
@ -166,7 +168,7 @@ impl<'a> EvmTestClient<'a> {
|
||||
author: *genesis.author(),
|
||||
timestamp: genesis.timestamp(),
|
||||
difficulty: *genesis.difficulty(),
|
||||
last_hashes: Arc::new([util::H256::default(); 256].to_vec()),
|
||||
last_hashes: Arc::new([H256::default(); 256].to_vec()),
|
||||
gas_used: 0.into(),
|
||||
gas_limit: *genesis.gas_limit(),
|
||||
};
|
||||
|
@ -22,6 +22,10 @@ use std::collections::{HashMap, BTreeMap};
|
||||
use std::mem;
|
||||
use itertools::Itertools;
|
||||
use rustc_hex::FromHex;
|
||||
use hash::keccak;
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::{H256, H2048};
|
||||
use parking_lot::RwLock;
|
||||
use util::*;
|
||||
use rlp::*;
|
||||
use ethkey::{Generator, Random};
|
||||
@ -241,7 +245,7 @@ impl TestBlockChainClient {
|
||||
uncle_header.set_parent_hash(self.last_hash.read().clone());
|
||||
uncle_header.set_number(n as BlockNumber);
|
||||
uncles.append(&uncle_header);
|
||||
header.set_uncles_hash(uncles.as_raw().sha3());
|
||||
header.set_uncles_hash(keccak(uncles.as_raw()));
|
||||
uncles
|
||||
},
|
||||
_ => RlpStream::new_list(0)
|
||||
@ -452,6 +456,13 @@ impl BlockChainClient for TestBlockChainClient {
|
||||
}
|
||||
}
|
||||
|
||||
fn code_hash(&self, address: &Address, id: BlockId) -> Option<H256> {
|
||||
match id {
|
||||
BlockId::Latest | BlockId::Pending => self.code.read().get(address).map(|c| keccak(&c)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn balance(&self, address: &Address, id: BlockId) -> Option<U256> {
|
||||
match id {
|
||||
BlockId::Latest | BlockId::Pending => Some(self.balances.read().get(address).cloned().unwrap_or_else(U256::zero)),
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
//! Bridge between Tracedb and Blockchain.
|
||||
|
||||
use util::{H256};
|
||||
use bigint::hash::H256;
|
||||
use header::BlockNumber;
|
||||
use trace::DatabaseExtras as TraceDatabaseExtras;
|
||||
use blockchain::{BlockChain, BlockProvider};
|
||||
|
@ -34,7 +34,9 @@ use trace::LocalizedTrace;
|
||||
use transaction::{LocalizedTransaction, PendingTransaction, SignedTransaction};
|
||||
use verification::queue::QueueInfo as BlockQueueInfo;
|
||||
|
||||
use util::{U256, Address, H256, H2048, Bytes};
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::{H256, H2048};
|
||||
use util::{Address, Bytes};
|
||||
use util::hashdb::DBValue;
|
||||
|
||||
use types::ids::*;
|
||||
@ -96,6 +98,9 @@ pub trait BlockChainClient : Sync + Send {
|
||||
.expect("code will return Some if given BlockId::Latest; qed")
|
||||
}
|
||||
|
||||
/// Get address code hash at given block's state.
|
||||
fn code_hash(&self, address: &Address, id: BlockId) -> Option<H256>;
|
||||
|
||||
/// Get address balance at the given block's state.
|
||||
///
|
||||
/// May not return None if given BlockId::Latest.
|
||||
|
@ -19,7 +19,8 @@
|
||||
use std::ops::Deref;
|
||||
use std::hash::Hash;
|
||||
use std::collections::HashMap;
|
||||
use util::{DBTransaction, KeyValueDB, RwLock};
|
||||
use parking_lot::RwLock;
|
||||
use util::{DBTransaction, KeyValueDB};
|
||||
|
||||
use rlp;
|
||||
|
||||
|
@ -28,8 +28,11 @@ use header::{BlockNumber, Header as FullHeader};
|
||||
use transaction::UnverifiedTransaction;
|
||||
use views;
|
||||
|
||||
use hash::keccak;
|
||||
use heapsize::HeapSizeOf;
|
||||
use util::{Address, Hashable, H256, H2048, U256};
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::{H256, H2048};
|
||||
use util::Address;
|
||||
use rlp::Rlp;
|
||||
|
||||
/// Owning header view.
|
||||
@ -65,7 +68,7 @@ impl Header {
|
||||
// forwarders to borrowed view.
|
||||
impl Header {
|
||||
/// Returns the header hash.
|
||||
pub fn hash(&self) -> H256 { self.sha3() }
|
||||
pub fn hash(&self) -> H256 { keccak(&self.0) }
|
||||
|
||||
/// Returns the parent hash.
|
||||
pub fn parent_hash(&self) -> H256 { self.view().parent_hash() }
|
||||
@ -110,12 +113,6 @@ impl Header {
|
||||
pub fn seal(&self) -> Vec<Vec<u8>> { self.view().seal() }
|
||||
}
|
||||
|
||||
impl Hashable for Header {
|
||||
fn sha3(&self) -> H256 {
|
||||
self.0.sha3()
|
||||
}
|
||||
}
|
||||
|
||||
/// Owning block body view.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "ipc", binary)]
|
||||
@ -219,7 +216,7 @@ impl Block {
|
||||
// forwarders to borrowed header view.
|
||||
impl Block {
|
||||
/// Returns the header hash.
|
||||
pub fn hash(&self) -> H256 { self.header_view().sha3() }
|
||||
pub fn hash(&self) -> H256 { self.header_view().hash() }
|
||||
|
||||
/// Returns the parent hash.
|
||||
pub fn parent_hash(&self) -> H256 { self.header_view().parent_hash() }
|
||||
|
@ -19,7 +19,8 @@
|
||||
use std::collections::{VecDeque};
|
||||
use std::collections::hash_map::{HashMap, Entry};
|
||||
|
||||
use util::{Address, H256};
|
||||
use bigint::hash::H256;
|
||||
use util::Address;
|
||||
|
||||
use engines::validator_set::SimpleList;
|
||||
|
||||
@ -149,7 +150,8 @@ impl<'a> Iterator for Iter<'a> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use util::{Address, H256};
|
||||
use bigint::hash::H256;
|
||||
use util::Address;
|
||||
use super::RollingFinality;
|
||||
|
||||
#[test]
|
||||
|
@ -42,6 +42,11 @@ use ethkey::{verify_address, Signature};
|
||||
use io::{IoContext, IoHandler, TimerToken, IoService};
|
||||
use itertools::{self, Itertools};
|
||||
use rlp::{UntrustedRlp, encode};
|
||||
use bigint::prelude::{U256, U128};
|
||||
use bigint::hash::{H256, H520};
|
||||
use semantic_version::SemanticVersion;
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use unexpected::{Mismatch, OutOfBounds};
|
||||
use util::*;
|
||||
|
||||
mod finality;
|
||||
@ -830,7 +835,9 @@ impl Engine for AuthorityRound {
|
||||
mod tests {
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrdering};
|
||||
use util::*;
|
||||
use hash::keccak;
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::H520;
|
||||
use header::Header;
|
||||
use error::{Error, BlockError};
|
||||
use rlp::encode;
|
||||
@ -884,8 +891,8 @@ mod tests {
|
||||
#[test]
|
||||
fn generates_seal_and_does_not_double_propose() {
|
||||
let tap = Arc::new(AccountProvider::transient_provider());
|
||||
let addr1 = tap.insert_account("1".sha3().into(), "1").unwrap();
|
||||
let addr2 = tap.insert_account("2".sha3().into(), "2").unwrap();
|
||||
let addr1 = tap.insert_account(keccak("1").into(), "1").unwrap();
|
||||
let addr2 = tap.insert_account(keccak("2").into(), "2").unwrap();
|
||||
|
||||
let spec = Spec::new_test_round();
|
||||
let engine = &*spec.engine;
|
||||
@ -916,7 +923,7 @@ mod tests {
|
||||
#[test]
|
||||
fn proposer_switching() {
|
||||
let tap = AccountProvider::transient_provider();
|
||||
let addr = tap.insert_account("0".sha3().into(), "0").unwrap();
|
||||
let addr = tap.insert_account(keccak("0").into(), "0").unwrap();
|
||||
let mut parent_header: Header = Header::default();
|
||||
parent_header.set_seal(vec![encode(&0usize).into_vec()]);
|
||||
parent_header.set_gas_limit("222222".parse::<U256>().unwrap());
|
||||
@ -941,7 +948,7 @@ mod tests {
|
||||
#[test]
|
||||
fn rejects_future_block() {
|
||||
let tap = AccountProvider::transient_provider();
|
||||
let addr = tap.insert_account("0".sha3().into(), "0").unwrap();
|
||||
let addr = tap.insert_account(keccak("0").into(), "0").unwrap();
|
||||
|
||||
let mut parent_header: Header = Header::default();
|
||||
parent_header.set_seal(vec![encode(&0usize).into_vec()]);
|
||||
@ -967,7 +974,7 @@ mod tests {
|
||||
#[test]
|
||||
fn rejects_step_backwards() {
|
||||
let tap = AccountProvider::transient_provider();
|
||||
let addr = tap.insert_account("0".sha3().into(), "0").unwrap();
|
||||
let addr = tap.insert_account(keccak("0").into(), "0").unwrap();
|
||||
|
||||
let mut parent_header: Header = Header::default();
|
||||
parent_header.set_seal(vec![encode(&4usize).into_vec()]);
|
||||
|
@ -19,7 +19,11 @@
|
||||
use std::sync::{Weak, Arc};
|
||||
use std::collections::BTreeMap;
|
||||
use std::cmp;
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::{H256, H520};
|
||||
use parking_lot::RwLock;
|
||||
use util::*;
|
||||
use unexpected::{Mismatch, OutOfBounds};
|
||||
use ethkey::{recover, public_to_address, Signature};
|
||||
use account_provider::AccountProvider;
|
||||
use block::*;
|
||||
@ -31,6 +35,7 @@ use evm::Schedule;
|
||||
use ethjson;
|
||||
use header::{Header, BlockNumber};
|
||||
use client::Client;
|
||||
use semantic_version::SemanticVersion;
|
||||
use super::signer::EngineSigner;
|
||||
use super::validator_set::{ValidatorSet, SimpleList, new_validator_set};
|
||||
|
||||
@ -252,7 +257,8 @@ impl Engine for BasicAuthority {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::sync::Arc;
|
||||
use util::*;
|
||||
use hash::keccak;
|
||||
use bigint::hash::H520;
|
||||
use block::*;
|
||||
use error::{BlockError, Error};
|
||||
use tests::helpers::*;
|
||||
@ -308,7 +314,7 @@ mod tests {
|
||||
#[test]
|
||||
fn can_generate_seal() {
|
||||
let tap = AccountProvider::transient_provider();
|
||||
let addr = tap.insert_account("".sha3().into(), "").unwrap();
|
||||
let addr = tap.insert_account(keccak("").into(), "").unwrap();
|
||||
|
||||
let spec = new_test_authority();
|
||||
let engine = &*spec.engine;
|
||||
@ -326,7 +332,7 @@ mod tests {
|
||||
#[test]
|
||||
fn seals_internally() {
|
||||
let tap = AccountProvider::transient_provider();
|
||||
let authority = tap.insert_account("".sha3().into(), "").unwrap();
|
||||
let authority = tap.insert_account(keccak("").into(), "").unwrap();
|
||||
|
||||
let engine = new_test_authority().engine;
|
||||
assert!(!engine.seals_internally().unwrap());
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
//! Epoch verifiers and transitions.
|
||||
|
||||
use util::H256;
|
||||
use bigint::hash::H256;
|
||||
use error::Error;
|
||||
use header::Header;
|
||||
|
||||
|
@ -64,6 +64,7 @@ impl Engine for InstantSeal {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::sync::Arc;
|
||||
use bigint::hash::H520;
|
||||
use util::*;
|
||||
use tests::helpers::*;
|
||||
use spec::Spec;
|
||||
|
@ -54,7 +54,11 @@ use spec::CommonParams;
|
||||
use transaction::{UnverifiedTransaction, SignedTransaction};
|
||||
|
||||
use ethkey::Signature;
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::H256;
|
||||
use semantic_version::SemanticVersion;
|
||||
use util::*;
|
||||
use unexpected::{Mismatch, OutOfBounds};
|
||||
|
||||
/// Default EIP-210 contrat code.
|
||||
/// As defined in https://github.com/ethereum/EIPs/pull/210/commits/9df24a3714af42e3bf350265bdc75b486c909d7f#diff-e02a92c2fb96c1a1bfb05e4c6e2ef5daR49
|
||||
@ -403,6 +407,8 @@ pub mod common {
|
||||
use state::Substate;
|
||||
use state::CleanupMode;
|
||||
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::H256;
|
||||
use util::*;
|
||||
use super::Engine;
|
||||
|
||||
|
@ -18,7 +18,7 @@ use std::collections::BTreeMap;
|
||||
use util::Address;
|
||||
use builtin::Builtin;
|
||||
use block::{ExecutedBlock, IsBlock};
|
||||
use util::U256;
|
||||
use bigint::prelude::U256;
|
||||
use engines::Engine;
|
||||
use spec::CommonParams;
|
||||
use evm::Schedule;
|
||||
|
@ -17,7 +17,8 @@
|
||||
//! A signer used by Engines which need to sign messages.
|
||||
|
||||
use std::sync::Arc;
|
||||
use util::{H256, Address};
|
||||
use bigint::hash::H256;
|
||||
use util::Address;
|
||||
use ethkey::Signature;
|
||||
use account_provider::{self, AccountProvider};
|
||||
|
||||
|
@ -17,6 +17,8 @@
|
||||
//! Tendermint message handling.
|
||||
|
||||
use std::cmp;
|
||||
use hash::keccak;
|
||||
use bigint::hash::{H256, H520};
|
||||
use util::*;
|
||||
use super::{Height, View, BlockHash, Step};
|
||||
use error::Error;
|
||||
@ -99,7 +101,7 @@ impl ConsensusMessage {
|
||||
pub fn verify(&self) -> Result<Address, Error> {
|
||||
let full_rlp = ::rlp::encode(self);
|
||||
let block_info = Rlp::new(&full_rlp).at(1);
|
||||
let public_key = recover(&self.signature.into(), &block_info.as_raw().sha3())?;
|
||||
let public_key = recover(&self.signature.into(), &keccak(block_info.as_raw()))?;
|
||||
Ok(public_to_address(&public_key))
|
||||
}
|
||||
}
|
||||
@ -194,13 +196,13 @@ pub fn message_full_rlp(signature: &H520, vote_info: &Bytes) -> Bytes {
|
||||
}
|
||||
|
||||
pub fn message_hash(vote_step: VoteStep, block_hash: H256) -> H256 {
|
||||
message_info_rlp(&vote_step, Some(block_hash)).sha3()
|
||||
keccak(message_info_rlp(&vote_step, Some(block_hash)))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::sync::Arc;
|
||||
use util::*;
|
||||
use hash::keccak;
|
||||
use rlp::*;
|
||||
use account_provider::AccountProvider;
|
||||
use header::Header;
|
||||
@ -228,7 +230,7 @@ mod tests {
|
||||
view: 123,
|
||||
step: Step::Precommit,
|
||||
},
|
||||
block_hash: Some("1".sha3())
|
||||
block_hash: Some(keccak("1")),
|
||||
};
|
||||
let raw_rlp = ::rlp::encode(&message).into_vec();
|
||||
let rlp = Rlp::new(&raw_rlp);
|
||||
@ -251,12 +253,12 @@ mod tests {
|
||||
#[test]
|
||||
fn generate_and_verify() {
|
||||
let tap = Arc::new(AccountProvider::transient_provider());
|
||||
let addr = tap.insert_account("0".sha3().into(), "0").unwrap();
|
||||
let addr = tap.insert_account(keccak("0").into(), "0").unwrap();
|
||||
tap.unlock_account_permanently(addr, "0".into()).unwrap();
|
||||
|
||||
let mi = message_info_rlp(&VoteStep::new(123, 2, Step::Precommit), Some(H256::default()));
|
||||
|
||||
let raw_rlp = message_full_rlp(&tap.sign(addr, None, mi.sha3()).unwrap().into(), &mi);
|
||||
let raw_rlp = message_full_rlp(&tap.sign(addr, None, keccak(&mi)).unwrap().into(), &mi);
|
||||
|
||||
let rlp = UntrustedRlp::new(&raw_rlp);
|
||||
let message: ConsensusMessage = rlp.as_val().unwrap();
|
||||
|
@ -28,8 +28,13 @@ mod params;
|
||||
use std::sync::{Weak, Arc};
|
||||
use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrdering};
|
||||
use std::collections::{HashSet, BTreeMap, HashMap};
|
||||
use hash::keccak;
|
||||
use std::cmp;
|
||||
use bigint::prelude::{U128, U256};
|
||||
use bigint::hash::{H256, H520};
|
||||
use parking_lot::RwLock;
|
||||
use util::*;
|
||||
use unexpected::{OutOfBounds, Mismatch};
|
||||
use client::{Client, EngineClient};
|
||||
use error::{Error, BlockError};
|
||||
use header::{Header, BlockNumber};
|
||||
@ -47,6 +52,7 @@ use super::transition::TransitionHandler;
|
||||
use super::vote_collector::VoteCollector;
|
||||
use self::message::*;
|
||||
use self::params::TendermintParams;
|
||||
use semantic_version::SemanticVersion;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
pub enum Step {
|
||||
@ -213,7 +219,7 @@ impl Tendermint {
|
||||
let r = self.view.load(AtomicOrdering::SeqCst);
|
||||
let s = *self.step.read();
|
||||
let vote_info = message_info_rlp(&VoteStep::new(h, r, s), block_hash);
|
||||
match (self.signer.read().address(), self.sign(vote_info.sha3()).map(Into::into)) {
|
||||
match (self.signer.read().address(), self.sign(keccak(&vote_info)).map(Into::into)) {
|
||||
(Some(validator), Ok(signature)) => {
|
||||
let message_rlp = message_full_rlp(&signature, &vote_info);
|
||||
let message = ConsensusMessage::new(signature, h, r, s, block_hash);
|
||||
@ -498,7 +504,7 @@ impl Engine for Tendermint {
|
||||
let view = self.view.load(AtomicOrdering::SeqCst);
|
||||
let bh = Some(header.bare_hash());
|
||||
let vote_info = message_info_rlp(&VoteStep::new(height, view, Step::Propose), bh.clone());
|
||||
if let Ok(signature) = self.sign(vote_info.sha3()).map(Into::into) {
|
||||
if let Ok(signature) = self.sign(keccak(&vote_info)).map(Into::into) {
|
||||
// Insert Propose vote.
|
||||
debug!(target: "engine", "Submitting proposal {} at height {} view {}.", header.bare_hash(), height, view);
|
||||
self.votes.vote(ConsensusMessage::new(signature, height, view, Step::Propose, bh), author);
|
||||
@ -522,7 +528,7 @@ impl Engine for Tendermint {
|
||||
let rlp = UntrustedRlp::new(rlp);
|
||||
let message: ConsensusMessage = rlp.as_val()?;
|
||||
if !self.votes.is_old_or_known(&message) {
|
||||
let sender = public_to_address(&recover(&message.signature.into(), &rlp.at(1)?.as_raw().sha3())?);
|
||||
let sender = public_to_address(&recover(&message.signature.into(), &keccak(rlp.at(1)?.as_raw()))?);
|
||||
if !self.is_authority(&sender) {
|
||||
return Err(EngineError::NotAuthorized(sender).into());
|
||||
}
|
||||
@ -798,7 +804,7 @@ mod tests {
|
||||
|
||||
fn vote<F>(engine: &Engine, signer: F, height: usize, view: usize, step: Step, block_hash: Option<H256>) -> Bytes where F: FnOnce(H256) -> Result<H520, ::account_provider::SignError> {
|
||||
let mi = message_info_rlp(&VoteStep::new(height, view, step), block_hash);
|
||||
let m = message_full_rlp(&signer(mi.sha3()).unwrap().into(), &mi);
|
||||
let m = message_full_rlp(&signer(keccak(&mi)).unwrap().into(), &mi);
|
||||
engine.handle_message(&m).unwrap();
|
||||
m
|
||||
}
|
||||
@ -806,7 +812,7 @@ mod tests {
|
||||
fn proposal_seal(tap: &Arc<AccountProvider>, header: &Header, view: View) -> Vec<Bytes> {
|
||||
let author = header.author();
|
||||
let vote_info = message_info_rlp(&VoteStep::new(header.number() as Height, view, Step::Propose), Some(header.bare_hash()));
|
||||
let signature = tap.sign(*author, None, vote_info.sha3()).unwrap();
|
||||
let signature = tap.sign(*author, None, keccak(vote_info)).unwrap();
|
||||
vec![
|
||||
::rlp::encode(&view).into_vec(),
|
||||
::rlp::encode(&H520::from(signature)).into_vec(),
|
||||
@ -815,7 +821,7 @@ mod tests {
|
||||
}
|
||||
|
||||
fn insert_and_unlock(tap: &Arc<AccountProvider>, acc: &str) -> Address {
|
||||
let addr = tap.insert_account(acc.sha3().into(), acc).unwrap();
|
||||
let addr = tap.insert_account(keccak(acc).into(), acc).unwrap();
|
||||
tap.unlock_account_permanently(addr, acc.into()).unwrap();
|
||||
addr
|
||||
}
|
||||
@ -922,7 +928,7 @@ mod tests {
|
||||
let mut seal = proposal_seal(&tap, &header, 0);
|
||||
|
||||
let vote_info = message_info_rlp(&VoteStep::new(2, 0, Step::Precommit), Some(header.bare_hash()));
|
||||
let signature1 = tap.sign(proposer, None, vote_info.sha3()).unwrap();
|
||||
let signature1 = tap.sign(proposer, None, keccak(&vote_info)).unwrap();
|
||||
|
||||
seal[1] = ::rlp::NULL_RLP.to_vec();
|
||||
seal[2] = ::rlp::encode_list(&vec![H520::from(signature1.clone())]).into_vec();
|
||||
@ -935,7 +941,7 @@ mod tests {
|
||||
}
|
||||
|
||||
let voter = insert_and_unlock(&tap, "0");
|
||||
let signature0 = tap.sign(voter, None, vote_info.sha3()).unwrap();
|
||||
let signature0 = tap.sign(voter, None, keccak(&vote_info)).unwrap();
|
||||
|
||||
seal[2] = ::rlp::encode_list(&vec![H520::from(signature1.clone()), H520::from(signature0.clone())]).into_vec();
|
||||
header.set_seal(seal.clone());
|
||||
@ -943,7 +949,7 @@ mod tests {
|
||||
assert!(engine.verify_block_family(&header, &parent_header, None).is_ok());
|
||||
|
||||
let bad_voter = insert_and_unlock(&tap, "101");
|
||||
let bad_signature = tap.sign(bad_voter, None, vote_info.sha3()).unwrap();
|
||||
let bad_signature = tap.sign(bad_voter, None, keccak(vote_info)).unwrap();
|
||||
|
||||
seal[2] = ::rlp::encode_list(&vec![H520::from(signature1), H520::from(bad_signature)]).into_vec();
|
||||
header.set_seal(seal);
|
||||
@ -1076,10 +1082,10 @@ mod tests {
|
||||
let mut seal = proposal_seal(&tap, &header, 0);
|
||||
|
||||
let vote_info = message_info_rlp(&VoteStep::new(2, 0, Step::Precommit), Some(header.bare_hash()));
|
||||
let signature1 = tap.sign(proposer, None, vote_info.sha3()).unwrap();
|
||||
let signature1 = tap.sign(proposer, None, keccak(&vote_info)).unwrap();
|
||||
|
||||
let voter = insert_and_unlock(&tap, "0");
|
||||
let signature0 = tap.sign(voter, None, vote_info.sha3()).unwrap();
|
||||
let signature0 = tap.sign(voter, None, keccak(&vote_info)).unwrap();
|
||||
|
||||
seal[1] = ::rlp::NULL_RLP.to_vec();
|
||||
seal[2] = ::rlp::encode_list(&vec![H520::from(signature1.clone())]).into_vec();
|
||||
@ -1116,7 +1122,7 @@ mod tests {
|
||||
assert!(epoch_verifier.verify_light(&header).is_ok());
|
||||
|
||||
let bad_voter = insert_and_unlock(&tap, "101");
|
||||
let bad_signature = tap.sign(bad_voter, None, vote_info.sha3()).unwrap();
|
||||
let bad_signature = tap.sign(bad_voter, None, keccak(&vote_info)).unwrap();
|
||||
|
||||
seal[2] = ::rlp::encode_list(&vec![H520::from(signature1), H520::from(bad_signature)]).into_vec();
|
||||
header.set_seal(seal);
|
||||
|
@ -18,6 +18,8 @@
|
||||
/// It can also report validators for misbehaviour with two levels: `reportMalicious` and `reportBenign`.
|
||||
|
||||
use std::sync::Weak;
|
||||
use bigint::hash::H256;
|
||||
use parking_lot::RwLock;
|
||||
use util::*;
|
||||
|
||||
use futures::Future;
|
||||
@ -128,6 +130,8 @@ impl ValidatorSet for ValidatorContract {
|
||||
mod tests {
|
||||
use std::sync::Arc;
|
||||
use rustc_hex::FromHex;
|
||||
use hash::keccak;
|
||||
use bigint::hash::H520;
|
||||
use util::*;
|
||||
use rlp::encode;
|
||||
use spec::Spec;
|
||||
@ -153,7 +157,7 @@ mod tests {
|
||||
#[test]
|
||||
fn reports_validators() {
|
||||
let tap = Arc::new(AccountProvider::transient_provider());
|
||||
let v1 = tap.insert_account("1".sha3().into(), "").unwrap();
|
||||
let v1 = tap.insert_account(keccak("1").into(), "").unwrap();
|
||||
let client = generate_dummy_client_with_spec_and_accounts(Spec::new_validator_contract, Some(tap.clone()));
|
||||
client.engine().register_client(Arc::downgrade(&client));
|
||||
let validator_contract = "0000000000000000000000000000000000000005".parse::<Address>().unwrap();
|
||||
|
@ -25,7 +25,8 @@ mod multi;
|
||||
|
||||
use std::sync::Weak;
|
||||
use ids::BlockId;
|
||||
use util::{Bytes, Address, H256};
|
||||
use bigint::hash::H256;
|
||||
use util::{Bytes, Address};
|
||||
use ethjson::spec::ValidatorSet as ValidatorSpec;
|
||||
use client::Client;
|
||||
use header::{Header, BlockNumber};
|
||||
|
@ -19,7 +19,9 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::sync::Weak;
|
||||
use engines::{Call, Engine};
|
||||
use util::{Bytes, H256, Address, RwLock};
|
||||
use bigint::hash::H256;
|
||||
use parking_lot::RwLock;
|
||||
use util::{Bytes, Address};
|
||||
use ids::BlockId;
|
||||
use header::{BlockNumber, Header};
|
||||
use client::{Client, BlockChainClient};
|
||||
@ -144,6 +146,7 @@ impl ValidatorSet for Multi {
|
||||
mod tests {
|
||||
use std::sync::Arc;
|
||||
use std::collections::BTreeMap;
|
||||
use hash::keccak;
|
||||
use account_provider::AccountProvider;
|
||||
use client::{BlockChainClient, EngineClient};
|
||||
use engines::EpochChange;
|
||||
@ -163,9 +166,9 @@ mod tests {
|
||||
let _ = ::env_logger::init();
|
||||
|
||||
let tap = Arc::new(AccountProvider::transient_provider());
|
||||
let s0: Secret = "0".sha3().into();
|
||||
let s0: Secret = keccak("0").into();
|
||||
let v0 = tap.insert_account(s0.clone(), "").unwrap();
|
||||
let v1 = tap.insert_account("1".sha3().into(), "").unwrap();
|
||||
let v1 = tap.insert_account(keccak("1").into(), "").unwrap();
|
||||
let client = generate_dummy_client_with_spec_and_accounts(Spec::new_validator_multi, Some(tap));
|
||||
client.engine().register_client(Arc::downgrade(&client));
|
||||
|
||||
|
@ -19,9 +19,14 @@
|
||||
use std::sync::{Weak, Arc};
|
||||
use futures::Future;
|
||||
use native_contracts::ValidatorSet as Provider;
|
||||
use hash::keccak;
|
||||
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::{H160, H256};
|
||||
use parking_lot::RwLock;
|
||||
use util::*;
|
||||
use util::cache::MemoryLruCache;
|
||||
use unexpected::Mismatch;
|
||||
use rlp::{UntrustedRlp, RlpStream};
|
||||
|
||||
use basic_types::LogBloom;
|
||||
@ -41,7 +46,7 @@ const MEMOIZE_CAPACITY: usize = 500;
|
||||
const EVENT_NAME: &'static [u8] = &*b"InitiateChange(bytes32,address[])";
|
||||
|
||||
lazy_static! {
|
||||
static ref EVENT_NAME_HASH: H256 = EVENT_NAME.sha3();
|
||||
static ref EVENT_NAME_HASH: H256 = keccak(EVENT_NAME);
|
||||
}
|
||||
|
||||
/// The validator contract should have the following interface:
|
||||
@ -351,7 +356,7 @@ impl ValidatorSet for ValidatorSafeContract {
|
||||
|
||||
// ensure receipts match header.
|
||||
// TODO: optimize? these were just decoded.
|
||||
let found_root = ::util::triehash::ordered_trie_root(
|
||||
let found_root = ::triehash::ordered_trie_root(
|
||||
receipts.iter().map(::rlp::encode).map(|x| x.to_vec())
|
||||
);
|
||||
if found_root != *old_header.receipts_root() {
|
||||
@ -424,6 +429,7 @@ impl ValidatorSet for ValidatorSafeContract {
|
||||
mod tests {
|
||||
use std::sync::Arc;
|
||||
use rustc_hex::FromHex;
|
||||
use hash::keccak;
|
||||
use util::*;
|
||||
use types::ids::BlockId;
|
||||
use spec::Spec;
|
||||
@ -449,9 +455,9 @@ mod tests {
|
||||
#[test]
|
||||
fn knows_validators() {
|
||||
let tap = Arc::new(AccountProvider::transient_provider());
|
||||
let s0: Secret = "1".sha3().into();
|
||||
let s0: Secret = keccak("1").into();
|
||||
let v0 = tap.insert_account(s0.clone(), "").unwrap();
|
||||
let v1 = tap.insert_account("0".sha3().into(), "").unwrap();
|
||||
let v1 = tap.insert_account(keccak("0").into(), "").unwrap();
|
||||
let chain_id = Spec::new_validator_safe_contract().chain_id();
|
||||
let client = generate_dummy_client_with_spec_and_accounts(Spec::new_validator_safe_contract, Some(tap));
|
||||
client.engine().register_client(Arc::downgrade(&client));
|
||||
|
@ -17,7 +17,8 @@
|
||||
/// Preconfigured validator list.
|
||||
|
||||
use heapsize::HeapSizeOf;
|
||||
use util::{H256, Address};
|
||||
use bigint::hash::H256;
|
||||
use util::Address;
|
||||
|
||||
use engines::{Call, Engine};
|
||||
use header::{BlockNumber, Header};
|
||||
|
@ -20,7 +20,8 @@ use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrdering};
|
||||
use heapsize::HeapSizeOf;
|
||||
use util::{Bytes, H256, Address};
|
||||
use bigint::hash::H256;
|
||||
use util::{Bytes, Address};
|
||||
|
||||
use engines::{Call, Engine};
|
||||
use header::{Header, BlockNumber};
|
||||
|
@ -19,6 +19,8 @@
|
||||
use std::fmt::Debug;
|
||||
use std::collections::{BTreeMap, HashSet, HashMap};
|
||||
use std::hash::Hash;
|
||||
use bigint::hash::{H256, H520};
|
||||
use parking_lot:: RwLock;
|
||||
use util::*;
|
||||
use rlp::{Encodable, RlpStream};
|
||||
|
||||
@ -206,6 +208,8 @@ impl <M: Message + Default + Encodable + Debug> VoteCollector<M> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use hash::keccak;
|
||||
use bigint::hash::H160;
|
||||
use util::*;
|
||||
use rlp::*;
|
||||
use super::*;
|
||||
@ -251,7 +255,7 @@ mod tests {
|
||||
#[test]
|
||||
fn seal_retrieval() {
|
||||
let collector = VoteCollector::default();
|
||||
let bh = Some("1".sha3());
|
||||
let bh = Some(keccak("1"));
|
||||
let mut signatures = Vec::new();
|
||||
for _ in 0..5 {
|
||||
signatures.push(H520::random());
|
||||
@ -263,9 +267,9 @@ mod tests {
|
||||
// Good proposal
|
||||
random_vote(&collector, signatures[0].clone(), propose_round.clone(), bh.clone());
|
||||
// Wrong block proposal.
|
||||
random_vote(&collector, signatures[0].clone(), propose_round.clone(), Some("0".sha3()));
|
||||
random_vote(&collector, signatures[0].clone(), propose_round.clone(), Some(keccak("0")));
|
||||
// Wrong block commit.
|
||||
random_vote(&collector, signatures[3].clone(), commit_round.clone(), Some("0".sha3()));
|
||||
random_vote(&collector, signatures[3].clone(), commit_round.clone(), Some(keccak("0")));
|
||||
// Wrong round.
|
||||
random_vote(&collector, signatures[0].clone(), 6, bh.clone());
|
||||
// Wrong round.
|
||||
@ -291,22 +295,22 @@ mod tests {
|
||||
let round1 = 1;
|
||||
let round3 = 3;
|
||||
// good 1
|
||||
random_vote(&collector, H520::random(), round1, Some("0".sha3()));
|
||||
random_vote(&collector, H520::random(), 0, Some("0".sha3()));
|
||||
random_vote(&collector, H520::random(), round1, Some(keccak("0")));
|
||||
random_vote(&collector, H520::random(), 0, Some(keccak("0")));
|
||||
// good 3
|
||||
random_vote(&collector, H520::random(), round3, Some("0".sha3()));
|
||||
random_vote(&collector, H520::random(), 2, Some("0".sha3()));
|
||||
random_vote(&collector, H520::random(), round3, Some(keccak("0")));
|
||||
random_vote(&collector, H520::random(), 2, Some(keccak("0")));
|
||||
// good prevote
|
||||
random_vote(&collector, H520::random(), round1, Some("1".sha3()));
|
||||
random_vote(&collector, H520::random(), round1, Some(keccak("1")));
|
||||
// good prevote
|
||||
let same_sig = H520::random();
|
||||
random_vote(&collector, same_sig.clone(), round1, Some("1".sha3()));
|
||||
random_vote(&collector, same_sig, round1, Some("1".sha3()));
|
||||
random_vote(&collector, same_sig.clone(), round1, Some(keccak("1")));
|
||||
random_vote(&collector, same_sig, round1, Some(keccak("1")));
|
||||
// good precommit
|
||||
random_vote(&collector, H520::random(), round3, Some("1".sha3()));
|
||||
random_vote(&collector, H520::random(), round3, Some(keccak("1")));
|
||||
// good prevote
|
||||
random_vote(&collector, H520::random(), round1, Some("0".sha3()));
|
||||
random_vote(&collector, H520::random(), 4, Some("2".sha3()));
|
||||
random_vote(&collector, H520::random(), round1, Some(keccak("0")));
|
||||
random_vote(&collector, H520::random(), 4, Some(keccak("2")));
|
||||
|
||||
assert_eq!(collector.count_round_votes(&round1), 4);
|
||||
assert_eq!(collector.count_round_votes(&round3), 2);
|
||||
@ -314,7 +318,7 @@ mod tests {
|
||||
let message = TestMessage {
|
||||
signature: H520::default(),
|
||||
step: round1,
|
||||
block_hash: Some("1".sha3())
|
||||
block_hash: Some(keccak("1"))
|
||||
};
|
||||
assert_eq!(collector.count_aligned_votes(&message), 2);
|
||||
}
|
||||
@ -325,11 +329,11 @@ mod tests {
|
||||
let vote = |round, hash| {
|
||||
random_vote(&collector, H520::random(), round, hash);
|
||||
};
|
||||
vote(6, Some("0".sha3()));
|
||||
vote(3, Some("0".sha3()));
|
||||
vote(7, Some("0".sha3()));
|
||||
vote(8, Some("1".sha3()));
|
||||
vote(1, Some("1".sha3()));
|
||||
vote(6, Some(keccak("0")));
|
||||
vote(3, Some(keccak("0")));
|
||||
vote(7, Some(keccak("0")));
|
||||
vote(8, Some(keccak("1")));
|
||||
vote(1, Some(keccak("1")));
|
||||
|
||||
collector.throw_out_old(&7);
|
||||
assert_eq!(collector.len(), 2);
|
||||
@ -340,9 +344,9 @@ mod tests {
|
||||
let collector = VoteCollector::default();
|
||||
let round = 3;
|
||||
// Vote is inserted fine.
|
||||
assert!(full_vote(&collector, H520::random(), round, Some("0".sha3()), &Address::default()));
|
||||
assert!(full_vote(&collector, H520::random(), round, Some(keccak("0")), &Address::default()));
|
||||
// Returns the double voting address.
|
||||
assert!(!full_vote(&collector, H520::random(), round, Some("1".sha3()), &Address::default()));
|
||||
assert!(!full_vote(&collector, H520::random(), round, Some(keccak("1")), &Address::default()));
|
||||
assert_eq!(collector.count_round_votes(&round), 1);
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,10 @@
|
||||
//! General error types for use in ethcore.
|
||||
|
||||
use std::fmt;
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::H256;
|
||||
use util::*;
|
||||
use unexpected::{Mismatch, OutOfBounds};
|
||||
use io::*;
|
||||
use header::BlockNumber;
|
||||
use basic_types::LogBloom;
|
||||
@ -80,6 +83,8 @@ pub enum TransactionError {
|
||||
CodeBanned,
|
||||
/// Invalid chain ID given.
|
||||
InvalidChainId,
|
||||
/// Not enough permissions given by permission contract.
|
||||
NotAllowed,
|
||||
}
|
||||
|
||||
impl fmt::Display for TransactionError {
|
||||
@ -104,6 +109,7 @@ impl fmt::Display for TransactionError {
|
||||
RecipientBanned => "Recipient is temporarily banned.".into(),
|
||||
CodeBanned => "Contract code is temporarily banned.".into(),
|
||||
InvalidChainId => "Transaction of this chain ID is not allowed on this chain.".into(),
|
||||
NotAllowed => "Sender does not have permissions to execute this type of transction".into(),
|
||||
};
|
||||
|
||||
f.write_fmt(format_args!("Transaction error ({})", msg))
|
||||
@ -389,7 +395,7 @@ impl From<ExecutionError> for Error {
|
||||
|
||||
impl From<::rlp::DecoderError> for Error {
|
||||
fn from(err: ::rlp::DecoderError) -> Error {
|
||||
Error::Util(UtilError::Decoder(err))
|
||||
Error::Util(UtilError::from(err))
|
||||
}
|
||||
}
|
||||
|
||||
@ -422,7 +428,7 @@ impl From<BlockImportError> for Error {
|
||||
match err {
|
||||
BlockImportError::Block(e) => Error::Block(e),
|
||||
BlockImportError::Import(e) => Error::Import(e),
|
||||
BlockImportError::Other(s) => Error::Util(UtilError::SimpleString(s)),
|
||||
BlockImportError::Other(s) => Error::Util(UtilError::from(s)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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/>.
|
||||
|
||||
use util::*;
|
||||
use bigint::prelude::U256;
|
||||
|
||||
#[inline]
|
||||
/// 1 Ether in Wei
|
||||
|
@ -17,9 +17,13 @@
|
||||
use std::path::Path;
|
||||
use std::cmp;
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::sync::Arc;
|
||||
use std::sync::{Arc, Weak};
|
||||
use hash::{KECCAK_EMPTY_LIST_RLP};
|
||||
use ethash::{quick_get_difficulty, slow_get_seedhash, EthashManager};
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::{H256, H64};
|
||||
use util::*;
|
||||
use unexpected::{OutOfBounds, Mismatch};
|
||||
use block::*;
|
||||
use builtin::Builtin;
|
||||
use vm::EnvInfo;
|
||||
@ -28,12 +32,15 @@ use trace::{Tracer, ExecutiveTracer, RewardType};
|
||||
use header::{Header, BlockNumber};
|
||||
use state::CleanupMode;
|
||||
use spec::CommonParams;
|
||||
use transaction::UnverifiedTransaction;
|
||||
use transaction::{UnverifiedTransaction, SignedTransaction};
|
||||
use engines::{self, Engine};
|
||||
use evm::Schedule;
|
||||
use ethjson;
|
||||
use rlp::{self, UntrustedRlp};
|
||||
use vm::LastHashes;
|
||||
use semantic_version::SemanticVersion;
|
||||
use tx_filter::{TransactionFilter};
|
||||
use client::{Client, BlockChainClient};
|
||||
|
||||
/// Parity tries to round block.gas_limit to multiple of this constant
|
||||
pub const PARITY_GAS_LIMIT_DETERMINANT: U256 = U256([37, 0, 0, 0]);
|
||||
@ -139,6 +146,7 @@ pub struct Ethash {
|
||||
ethash_params: EthashParams,
|
||||
builtins: BTreeMap<Address, Builtin>,
|
||||
pow: EthashManager,
|
||||
tx_filter: Option<TransactionFilter>,
|
||||
}
|
||||
|
||||
impl Ethash {
|
||||
@ -150,6 +158,7 @@ impl Ethash {
|
||||
builtins: BTreeMap<Address, Builtin>,
|
||||
) -> Arc<Self> {
|
||||
Arc::new(Ethash {
|
||||
tx_filter: TransactionFilter::from_params(¶ms),
|
||||
params,
|
||||
ethash_params,
|
||||
builtins,
|
||||
@ -435,6 +444,14 @@ impl Engine for Arc<Ethash> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn verify_transaction(&self, t: UnverifiedTransaction, header: &Header) -> Result<SignedTransaction, Error> {
|
||||
let signed = SignedTransaction::new(t)?;
|
||||
if !self.tx_filter.as_ref().map_or(true, |filter| filter.transaction_allowed(header.parent_hash(), &signed)) {
|
||||
return Err(From::from(TransactionError::NotAllowed));
|
||||
}
|
||||
Ok(signed)
|
||||
}
|
||||
|
||||
fn epoch_verifier<'a>(&self, _header: &Header, _proof: &'a [u8]) -> engines::ConstructedVerifier<'a> {
|
||||
engines::ConstructedVerifier::Trusted(Box::new(self.clone()))
|
||||
}
|
||||
@ -442,6 +459,13 @@ impl Engine for Arc<Ethash> {
|
||||
fn snapshot_components(&self) -> Option<Box<::snapshot::SnapshotComponents>> {
|
||||
Some(Box::new(::snapshot::PowSnapshot::new(SNAPSHOT_BLOCKS, MAX_SNAPSHOT_BLOCKS)))
|
||||
}
|
||||
|
||||
fn register_client(&self, client: Weak<Client>) {
|
||||
if let Some(ref filter) = self.tx_filter {
|
||||
filter.register_client(client as Weak<BlockChainClient>);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Try to round gas_limit a bit so that:
|
||||
@ -481,7 +505,7 @@ impl Ethash {
|
||||
panic!("Can't calculate genesis block difficulty");
|
||||
}
|
||||
|
||||
let parent_has_uncles = parent.uncles_hash() != &sha3::SHA3_EMPTY_LIST_RLP;
|
||||
let parent_has_uncles = parent.uncles_hash() != &KECCAK_EMPTY_LIST_RLP;
|
||||
|
||||
let min_difficulty = self.ethash_params.minimum_difficulty;
|
||||
|
||||
@ -586,6 +610,8 @@ mod tests {
|
||||
use std::str::FromStr;
|
||||
use std::collections::BTreeMap;
|
||||
use std::sync::Arc;
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::{H64, H256};
|
||||
use util::*;
|
||||
use block::*;
|
||||
use tests::helpers::*;
|
||||
|
@ -92,7 +92,7 @@ pub fn new_metropolis_test() -> Spec { load(None, include_bytes!("../../res/ethe
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use util::*;
|
||||
use bigint::prelude::U256;
|
||||
use state::*;
|
||||
use super::*;
|
||||
use tests::helpers::*;
|
||||
@ -119,7 +119,7 @@ mod tests {
|
||||
|
||||
assert_eq!(morden.state_root(), "f3f4696bbf3b3b07775128eb7a3763279a394e382130f27c21e70233e04946a9".into());
|
||||
let genesis = morden.genesis_block();
|
||||
assert_eq!(BlockView::new(&genesis).header_view().sha3(), "0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303".into());
|
||||
assert_eq!(BlockView::new(&genesis).header_view().hash(), "0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303".into());
|
||||
|
||||
let _ = morden.engine;
|
||||
}
|
||||
@ -130,7 +130,7 @@ mod tests {
|
||||
|
||||
assert_eq!(frontier.state_root(), "d7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544".into());
|
||||
let genesis = frontier.genesis_block();
|
||||
assert_eq!(BlockView::new(&genesis).header_view().sha3(), "d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3".into());
|
||||
assert_eq!(BlockView::new(&genesis).header_view().hash(), "d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3".into());
|
||||
|
||||
let _ = frontier.engine;
|
||||
}
|
||||
|
@ -16,7 +16,8 @@
|
||||
|
||||
//! Transaction execution format module.
|
||||
|
||||
use util::{Bytes, U256, Address, U512, trie};
|
||||
use bigint::prelude::{U256, U512};
|
||||
use util::{Bytes, Address, trie};
|
||||
use vm;
|
||||
use trace::{VMTrace, FlatTrace};
|
||||
use log_entry::LogEntry;
|
||||
|
@ -17,6 +17,9 @@
|
||||
//! Transaction Execution environment.
|
||||
use std::cmp;
|
||||
use std::sync::Arc;
|
||||
use hash::keccak;
|
||||
use bigint::prelude::{U256, U512};
|
||||
use bigint::hash::H256;
|
||||
use util::*;
|
||||
use state::{Backend as StateBackend, State, Substate, CleanupMode};
|
||||
use engines::Engine;
|
||||
@ -47,20 +50,20 @@ pub fn contract_address(address_scheme: CreateContractAddress, sender: &Address,
|
||||
let mut stream = RlpStream::new_list(2);
|
||||
stream.append(sender);
|
||||
stream.append(nonce);
|
||||
(From::from(stream.as_raw().sha3()), None)
|
||||
(From::from(keccak(stream.as_raw())), None)
|
||||
},
|
||||
CreateContractAddress::FromCodeHash => {
|
||||
let code_hash = code.sha3();
|
||||
let code_hash = keccak(code);
|
||||
let mut buffer = [0xffu8; 20 + 32];
|
||||
&mut buffer[20..].copy_from_slice(&code_hash[..]);
|
||||
(From::from((&buffer[..]).sha3()), Some(code_hash))
|
||||
(From::from(keccak(&buffer[..])), Some(code_hash))
|
||||
},
|
||||
CreateContractAddress::FromSenderAndCodeHash => {
|
||||
let code_hash = code.sha3();
|
||||
let code_hash = keccak(code);
|
||||
let mut buffer = [0u8; 20 + 32];
|
||||
&mut buffer[..20].copy_from_slice(&sender[..]);
|
||||
&mut buffer[20..].copy_from_slice(&code_hash[..]);
|
||||
(From::from((&buffer[..]).sha3()), Some(code_hash))
|
||||
(From::from(keccak(&buffer[..])), Some(code_hash))
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -74,6 +77,8 @@ pub struct TransactOptions<T, V> {
|
||||
pub vm_tracer: V,
|
||||
/// Check transaction nonce before execution.
|
||||
pub check_nonce: bool,
|
||||
/// Records the output from init contract calls.
|
||||
pub output_from_init_contract: bool,
|
||||
}
|
||||
|
||||
impl<T, V> TransactOptions<T, V> {
|
||||
@ -83,6 +88,7 @@ impl<T, V> TransactOptions<T, V> {
|
||||
tracer,
|
||||
vm_tracer,
|
||||
check_nonce: true,
|
||||
output_from_init_contract: false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,6 +97,12 @@ impl<T, V> TransactOptions<T, V> {
|
||||
self.check_nonce = false;
|
||||
self
|
||||
}
|
||||
|
||||
/// Saves the output from contract creation.
|
||||
pub fn save_output_from_contract(mut self) -> Self {
|
||||
self.output_from_init_contract = true;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl TransactOptions<trace::ExecutiveTracer, trace::ExecutiveVMTracer> {
|
||||
@ -100,6 +112,7 @@ impl TransactOptions<trace::ExecutiveTracer, trace::ExecutiveVMTracer> {
|
||||
tracer: trace::ExecutiveTracer::default(),
|
||||
vm_tracer: trace::ExecutiveVMTracer::toplevel(),
|
||||
check_nonce: true,
|
||||
output_from_init_contract: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -111,6 +124,7 @@ impl TransactOptions<trace::ExecutiveTracer, trace::NoopVMTracer> {
|
||||
tracer: trace::ExecutiveTracer::default(),
|
||||
vm_tracer: trace::NoopVMTracer,
|
||||
check_nonce: true,
|
||||
output_from_init_contract: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -122,6 +136,7 @@ impl TransactOptions<trace::NoopTracer, trace::ExecutiveVMTracer> {
|
||||
tracer: trace::NoopTracer,
|
||||
vm_tracer: trace::ExecutiveVMTracer::toplevel(),
|
||||
check_nonce: true,
|
||||
output_from_init_contract: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -133,6 +148,7 @@ impl TransactOptions<trace::NoopTracer, trace::NoopVMTracer> {
|
||||
tracer: trace::NoopTracer,
|
||||
vm_tracer: trace::NoopVMTracer,
|
||||
check_nonce: true,
|
||||
output_from_init_contract: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -201,7 +217,7 @@ impl<'a, B: 'a + StateBackend, E: Engine + ?Sized> Executive<'a, B, E> {
|
||||
pub fn transact<T, V>(&'a mut self, t: &SignedTransaction, options: TransactOptions<T, V>)
|
||||
-> Result<Executed, ExecutionError> where T: Tracer, V: VMTracer,
|
||||
{
|
||||
self.transact_with_tracer(t, options.check_nonce, options.tracer, options.vm_tracer)
|
||||
self.transact_with_tracer(t, options.check_nonce, options.output_from_init_contract, options.tracer, options.vm_tracer)
|
||||
}
|
||||
|
||||
/// Execute a transaction in a "virtual" context.
|
||||
@ -226,6 +242,7 @@ impl<'a, B: 'a + StateBackend, E: Engine + ?Sized> Executive<'a, B, E> {
|
||||
&'a mut self,
|
||||
t: &SignedTransaction,
|
||||
check_nonce: bool,
|
||||
output_from_create: bool,
|
||||
mut tracer: T,
|
||||
mut vm_tracer: V
|
||||
) -> Result<Executed, ExecutionError> where T: Tracer, V: VMTracer {
|
||||
@ -294,7 +311,8 @@ impl<'a, B: 'a + StateBackend, E: Engine + ?Sized> Executive<'a, B, E> {
|
||||
data: None,
|
||||
call_type: CallType::None,
|
||||
};
|
||||
(self.create(params, &mut substate, &mut tracer, &mut vm_tracer), vec![])
|
||||
let mut out = if output_from_create { Some(vec![]) } else { None };
|
||||
(self.create(params, &mut substate, &mut out, &mut tracer, &mut vm_tracer), out.unwrap_or_else(Vec::new))
|
||||
},
|
||||
Action::Call(ref address) => {
|
||||
let params = ActionParams {
|
||||
@ -487,6 +505,7 @@ impl<'a, B: 'a + StateBackend, E: Engine + ?Sized> Executive<'a, B, E> {
|
||||
&mut self,
|
||||
params: ActionParams,
|
||||
substate: &mut Substate,
|
||||
output: &mut Option<Bytes>,
|
||||
tracer: &mut T,
|
||||
vm_tracer: &mut V,
|
||||
) -> vm::Result<(U256, ReturnData)> where T: Tracer, V: VMTracer {
|
||||
@ -528,7 +547,7 @@ impl<'a, B: 'a + StateBackend, E: Engine + ?Sized> Executive<'a, B, E> {
|
||||
let mut subvmtracer = vm_tracer.prepare_subtrace(params.code.as_ref().expect("two ways into create (Externalities::create and Executive::transact_with_tracer); both place `Some(...)` `code` in `params`; qed"));
|
||||
|
||||
let res = {
|
||||
self.exec_vm(params, &mut unconfirmed_substate, OutputPolicy::InitContract(trace_output.as_mut()), &mut subtracer, &mut subvmtracer)
|
||||
self.exec_vm(params, &mut unconfirmed_substate, OutputPolicy::InitContract(output.as_mut().or(trace_output.as_mut())), &mut subtracer, &mut subvmtracer)
|
||||
};
|
||||
|
||||
vm_tracer.done_subtrace(subvmtracer);
|
||||
@ -537,7 +556,7 @@ impl<'a, B: 'a + StateBackend, E: Engine + ?Sized> Executive<'a, B, E> {
|
||||
Ok(ref res) => tracer.trace_create(
|
||||
trace_info,
|
||||
gas - res.gas_left,
|
||||
trace_output,
|
||||
trace_output.map(|data| output.as_ref().map(|out| out.to_vec()).unwrap_or(data)),
|
||||
created,
|
||||
subtracer.drain()
|
||||
),
|
||||
@ -658,7 +677,9 @@ mod tests {
|
||||
use rustc_hex::FromHex;
|
||||
use ethkey::{Generator, Random};
|
||||
use super::*;
|
||||
use util::{H256, U256, U512, Address};
|
||||
use bigint::prelude::{U256, U512};
|
||||
use bigint::hash::H256;
|
||||
use util::Address;
|
||||
use util::bytes::BytesRef;
|
||||
use vm::{ActionParams, ActionValue, CallType, EnvInfo, CreateContractAddress};
|
||||
use evm::{Factory, VMType};
|
||||
@ -696,7 +717,7 @@ mod tests {
|
||||
|
||||
let (gas_left, _) = {
|
||||
let mut ex = Executive::new(&mut state, &info, &engine);
|
||||
ex.create(params, &mut substate, &mut NoopTracer, &mut NoopVMTracer).unwrap()
|
||||
ex.create(params, &mut substate, &mut None, &mut NoopTracer, &mut NoopVMTracer).unwrap()
|
||||
};
|
||||
|
||||
assert_eq!(gas_left, U256::from(79_975));
|
||||
@ -754,7 +775,7 @@ mod tests {
|
||||
|
||||
let (gas_left, _) = {
|
||||
let mut ex = Executive::new(&mut state, &info, &engine);
|
||||
ex.create(params, &mut substate, &mut NoopTracer, &mut NoopVMTracer).unwrap()
|
||||
ex.create(params, &mut substate, &mut None, &mut NoopTracer, &mut NoopVMTracer).unwrap()
|
||||
};
|
||||
|
||||
assert_eq!(gas_left, U256::from(62_976));
|
||||
@ -921,7 +942,7 @@ mod tests {
|
||||
|
||||
let (gas_left, _) = {
|
||||
let mut ex = Executive::new(&mut state, &info, &engine);
|
||||
ex.create(params.clone(), &mut substate, &mut tracer, &mut vm_tracer).unwrap()
|
||||
ex.create(params.clone(), &mut substate, &mut None, &mut tracer, &mut vm_tracer).unwrap()
|
||||
};
|
||||
|
||||
assert_eq!(gas_left, U256::from(96_776));
|
||||
@ -1006,7 +1027,7 @@ mod tests {
|
||||
|
||||
let (gas_left, _) = {
|
||||
let mut ex = Executive::new(&mut state, &info, &engine);
|
||||
ex.create(params, &mut substate, &mut NoopTracer, &mut NoopVMTracer).unwrap()
|
||||
ex.create(params, &mut substate, &mut None, &mut NoopTracer, &mut NoopVMTracer).unwrap()
|
||||
};
|
||||
|
||||
assert_eq!(gas_left, U256::from(62_976));
|
||||
@ -1057,7 +1078,7 @@ mod tests {
|
||||
|
||||
{
|
||||
let mut ex = Executive::new(&mut state, &info, &engine);
|
||||
ex.create(params, &mut substate, &mut NoopTracer, &mut NoopVMTracer).unwrap();
|
||||
ex.create(params, &mut substate, &mut None, &mut NoopTracer, &mut NoopVMTracer).unwrap();
|
||||
}
|
||||
|
||||
assert_eq!(substate.contracts_created.len(), 1);
|
||||
@ -1307,8 +1328,8 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
evm_test!{test_sha3: test_sha3_jit, test_sha3_int}
|
||||
fn test_sha3(factory: Factory) {
|
||||
evm_test!{test_keccak: test_keccak_jit, test_keccak_int}
|
||||
fn test_keccak(factory: Factory) {
|
||||
let code = "6064640fffffffff20600055".from_hex().unwrap();
|
||||
|
||||
let sender = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
||||
@ -1330,7 +1351,7 @@ mod tests {
|
||||
|
||||
let result = {
|
||||
let mut ex = Executive::new(&mut state, &info, &engine);
|
||||
ex.create(params, &mut substate, &mut NoopTracer, &mut NoopVMTracer)
|
||||
ex.create(params, &mut substate, &mut None, &mut NoopTracer, &mut NoopVMTracer)
|
||||
};
|
||||
|
||||
match result {
|
||||
|
@ -17,6 +17,8 @@
|
||||
//! Transaction Execution environment.
|
||||
use std::cmp;
|
||||
use std::sync::Arc;
|
||||
use bigint::prelude::U256;
|
||||
use bigint::hash::H256;
|
||||
use util::*;
|
||||
use state::{Backend as StateBackend, State, Substate, CleanupMode};
|
||||
use engines::Engine;
|
||||
@ -222,7 +224,7 @@ impl<'a, T: 'a, V: 'a, B: 'a, E: 'a> Ext for Externalities<'a, T, V, B, E>
|
||||
let mut ex = Executive::from_parent(self.state, self.env_info, self.engine, self.depth, self.static_flag);
|
||||
|
||||
// TODO: handle internal error separately
|
||||
match ex.create(params, self.substate, self.tracer, self.vm_tracer) {
|
||||
match ex.create(params, self.substate, &mut None, self.tracer, self.vm_tracer) {
|
||||
Ok((gas_left, _)) => {
|
||||
self.substate.contracts_created.push(address.clone());
|
||||
ContractCreateResult::Created(address, gas_left)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user