Merge master

This commit is contained in:
Jaco Greeff 2017-09-07 13:32:45 +02:00
commit 6d8b511d25
397 changed files with 5175 additions and 3224 deletions

110
Cargo.lock generated
View File

@ -3,6 +3,7 @@ name = "wasm"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore-bigint 0.1.3",
"ethcore-logger 1.8.0", "ethcore-logger 1.8.0",
"ethcore-util 1.8.0", "ethcore-util 1.8.0",
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
@ -196,7 +197,7 @@ name = "bloomable"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"ethcore-bigint 0.1.3", "ethcore-bigint 0.1.3",
"tiny-keccak 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "hash 0.1.0",
] ]
[[package]] [[package]]
@ -299,8 +300,10 @@ name = "common-types"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"bloomable 0.1.0", "bloomable 0.1.0",
"ethcore-bigint 0.1.3",
"ethcore-util 1.8.0", "ethcore-util 1.8.0",
"ethjson 0.1.0", "ethjson 0.1.0",
"hash 0.1.0",
"heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp 0.2.0", "rlp 0.2.0",
"rlp_derive 0.1.0", "rlp_derive 0.1.0",
@ -452,6 +455,14 @@ dependencies = [
"backtrace 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "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]] [[package]]
name = "eth-secp256k1" name = "eth-secp256k1"
version = "0.5.6" version = "0.5.6"
@ -481,16 +492,17 @@ name = "ethash"
version = "1.8.0" version = "1.8.0"
dependencies = [ dependencies = [
"crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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)", "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)", "primal 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"sha3 0.1.0",
] ]
[[package]] [[package]]
name = "ethcore" name = "ethcore"
version = "1.8.0" version = "1.8.0"
dependencies = [ 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)", "bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bloomable 0.1.0", "bloomable 0.1.0",
"bloomchain 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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)", "ethabi 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethash 1.8.0", "ethash 1.8.0",
"ethcore-bigint 0.1.3",
"ethcore-bloom-journal 0.1.0", "ethcore-bloom-journal 0.1.0",
"ethcore-devtools 1.8.0", "ethcore-devtools 1.8.0",
"ethcore-io 1.8.0", "ethcore-io 1.8.0",
@ -517,6 +530,7 @@ dependencies = [
"evm 0.1.0", "evm 0.1.0",
"futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
"hardware-wallet 1.8.0", "hardware-wallet 1.8.0",
"hash 0.1.0",
"heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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)", "itertools 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)",
@ -527,17 +541,21 @@ dependencies = [
"native-contracts 0.1.0", "native-contracts 0.1.0",
"num 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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", "price-info 1.7.0",
"rand 0.3.14 (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 0.2.0",
"rlp_derive 0.1.0", "rlp_derive 0.1.0",
"rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "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-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)", "semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"stats 0.1.0", "stats 0.1.0",
"table 0.1.0", "table 0.1.0",
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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", "using_queue 0.1.0",
"vm 0.1.0", "vm 0.1.0",
"wasm 0.1.0", "wasm 0.1.0",
@ -584,6 +602,7 @@ dependencies = [
name = "ethcore-ipc" name = "ethcore-ipc"
version = "1.8.0" version = "1.8.0"
dependencies = [ dependencies = [
"ethcore-bigint 0.1.3",
"ethcore-devtools 1.8.0", "ethcore-devtools 1.8.0",
"ethcore-util 1.8.0", "ethcore-util 1.8.0",
"nanomsg 0.5.1 (git+https://github.com/paritytech/nanomsg.rs.git?branch=parity-1.7)", "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 = [ dependencies = [
"bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore 1.8.0", "ethcore 1.8.0",
"ethcore-bigint 0.1.3",
"ethcore-devtools 1.8.0", "ethcore-devtools 1.8.0",
"ethcore-io 1.8.0", "ethcore-io 1.8.0",
"ethcore-ipc 1.8.0", "ethcore-ipc 1.8.0",
@ -654,9 +674,11 @@ dependencies = [
"ethcore-util 1.8.0", "ethcore-util 1.8.0",
"evm 0.1.0", "evm 0.1.0",
"futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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)", "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)", "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)", "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp 0.2.0", "rlp 0.2.0",
"rlp_derive 0.1.0", "rlp_derive 0.1.0",
@ -665,6 +687,7 @@ dependencies = [
"smallvec 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"stats 0.1.0", "stats 0.1.0",
"time 0.1.35 (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",
"vm 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)", "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)", "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)", "clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore-bigint 0.1.3",
"ethcore-devtools 1.8.0", "ethcore-devtools 1.8.0",
"ethcore-io 1.8.0", "ethcore-io 1.8.0",
"ethcore-logger 1.8.0", "ethcore-logger 1.8.0",
"ethcore-util 1.8.0", "ethcore-util 1.8.0",
"ethcrypto 0.1.0", "ethcrypto 0.1.0",
"ethkey 0.2.0", "ethkey 0.2.0",
"hash 0.1.0",
"igd 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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)", "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)", "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)", "ethabi 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore 1.8.0", "ethcore 1.8.0",
"ethcore-bigint 0.1.3",
"ethcore-devtools 1.8.0", "ethcore-devtools 1.8.0",
"ethcore-ipc 1.8.0", "ethcore-ipc 1.8.0",
"ethcore-ipc-codegen 1.8.0", "ethcore-ipc-codegen 1.8.0",
@ -730,6 +756,7 @@ dependencies = [
"ethkey 0.2.0", "ethkey 0.2.0",
"futures 0.1.11 (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)", "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)", "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)", "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)", "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
@ -751,6 +778,7 @@ name = "ethcore-stratum"
version = "1.8.0" version = "1.8.0"
dependencies = [ dependencies = [
"env_logger 0.4.2 (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-devtools 1.8.0",
"ethcore-ipc 1.8.0", "ethcore-ipc 1.8.0",
"ethcore-ipc-codegen 1.8.0", "ethcore-ipc-codegen 1.8.0",
@ -758,11 +786,13 @@ dependencies = [
"ethcore-logger 1.8.0", "ethcore-logger 1.8.0",
"ethcore-util 1.8.0", "ethcore-util 1.8.0",
"futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "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-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-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)", "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)", "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)", "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)", "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)", "tokio-core 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -771,31 +801,29 @@ dependencies = [
name = "ethcore-util" name = "ethcore-util"
version = "1.8.0" version = "1.8.0"
dependencies = [ 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)", "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)", "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)", "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)", "eth-secp256k1 0.5.6 (git+https://github.com/paritytech/rust-secp256k1)",
"ethcore-bigint 0.1.3", "ethcore-bigint 0.1.3",
"ethcore-bloom-journal 0.1.0", "ethcore-bloom-journal 0.1.0",
"ethcore-devtools 1.8.0", "ethcore-devtools 1.8.0",
"ethcore-logger 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)", "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)", "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)", "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)", "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)", "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)", "regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp 0.2.0", "rlp 0.2.0",
"rocksdb 0.4.5 (git+https://github.com/paritytech/rust-rocksdb)", "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-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)", "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)", "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)", "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)", "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)", "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)", "env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore 1.8.0", "ethcore 1.8.0",
"ethcore-bigint 0.1.3",
"ethcore-devtools 1.8.0", "ethcore-devtools 1.8.0",
"ethcore-io 1.8.0", "ethcore-io 1.8.0",
"ethcore-ipc 1.8.0", "ethcore-ipc 1.8.0",
@ -901,6 +930,7 @@ dependencies = [
"ethcore-network 1.8.0", "ethcore-network 1.8.0",
"ethcore-util 1.8.0", "ethcore-util 1.8.0",
"ethkey 0.2.0", "ethkey 0.2.0",
"hash 0.1.0",
"heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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)", "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)", "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)", "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)", "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"triehash 0.1.0",
] ]
[[package]] [[package]]
@ -919,14 +950,17 @@ dependencies = [
"bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"common-types 0.1.0", "common-types 0.1.0",
"ethcore-bigint 0.1.3",
"ethcore-logger 1.8.0", "ethcore-logger 1.8.0",
"ethcore-util 1.8.0", "ethcore-util 1.8.0",
"ethjson 0.1.0", "ethjson 0.1.0",
"evmjit 1.8.0", "evmjit 1.8.0",
"hash 0.1.0",
"heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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)", "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)", "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", "rlp 0.2.0",
"rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"vm 0.1.0", "vm 0.1.0",
@ -939,6 +973,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"docopt 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "docopt 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore 1.8.0", "ethcore 1.8.0",
"ethcore-bigint 0.1.3",
"ethcore-util 1.8.0", "ethcore-util 1.8.0",
"ethjson 0.1.0", "ethjson 0.1.0",
"evm 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)", "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]] [[package]]
name = "heapsize" name = "heapsize"
version = "0.4.0" version = "0.4.0"
@ -1189,6 +1234,7 @@ dependencies = [
name = "ipc-common-types" name = "ipc-common-types"
version = "1.8.0" version = "1.8.0"
dependencies = [ dependencies = [
"ethcore-bigint 0.1.3",
"ethcore-ipc 1.8.0", "ethcore-ipc 1.8.0",
"ethcore-ipc-codegen 1.8.0", "ethcore-ipc-codegen 1.8.0",
"ethcore-util 1.8.0", "ethcore-util 1.8.0",
@ -1624,12 +1670,14 @@ name = "node-filter"
version = "1.8.0" version = "1.8.0"
dependencies = [ dependencies = [
"ethcore 1.8.0", "ethcore 1.8.0",
"ethcore-bigint 0.1.3",
"ethcore-io 1.8.0", "ethcore-io 1.8.0",
"ethcore-network 1.8.0", "ethcore-network 1.8.0",
"ethcore-util 1.8.0", "ethcore-util 1.8.0",
"futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"native-contracts 0.1.0", "native-contracts 0.1.0",
"parking_lot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -1828,12 +1876,14 @@ version = "1.8.0"
dependencies = [ dependencies = [
"ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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)", "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)", "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)", "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)", "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)", "env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore 1.8.0", "ethcore 1.8.0",
"ethcore-bigint 0.1.3",
"ethcore-devtools 1.8.0", "ethcore-devtools 1.8.0",
"ethcore-io 1.8.0", "ethcore-io 1.8.0",
"ethcore-ipc 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)", "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 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)", "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)", "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)", "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)", "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-rpc-client 1.4.0",
"parity-updater 1.8.0", "parity-updater 1.8.0",
"parity-whisper 0.1.0", "parity-whisper 0.1.0",
"parking_lot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"path 0.1.0", "path 0.1.0",
"pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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)", "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)", "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)", "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-devtools 1.8.0",
"ethcore-util 1.8.0", "ethcore-util 1.8.0",
"fetch 0.1.0", "fetch 0.1.0",
"futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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-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)", "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-hash-fetch 1.8.0",
"parity-reactor 0.1.0", "parity-reactor 0.1.0",
"parity-ui 1.8.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)", "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)", "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)", "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" version = "1.8.0"
dependencies = [ dependencies = [
"ethabi 2.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-bigint 0.1.3",
"ethcore-util 1.8.0", "ethcore-util 1.8.0",
"fetch 0.1.0", "fetch 0.1.0",
"futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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 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)", "mime_guess 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"native-contracts 0.1.0", "native-contracts 0.1.0",
"parity-reactor 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)", "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)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -1958,6 +2016,7 @@ version = "1.8.0"
dependencies = [ dependencies = [
"cid 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "cid 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore 1.8.0", "ethcore 1.8.0",
"ethcore-bigint 0.1.3",
"ethcore-util 1.8.0", "ethcore-util 1.8.0",
"jsonrpc-http-server 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)",
"mime 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1992,10 +2051,12 @@ dependencies = [
name = "parity-rpc" name = "parity-rpc"
version = "1.8.0" version = "1.8.0"
dependencies = [ 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)", "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)", "clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"ethash 1.8.0", "ethash 1.8.0",
"ethcore 1.8.0", "ethcore 1.8.0",
"ethcore-bigint 0.1.3",
"ethcore-devtools 1.8.0", "ethcore-devtools 1.8.0",
"ethcore-io 1.8.0", "ethcore-io 1.8.0",
"ethcore-ipc 1.8.0", "ethcore-ipc 1.8.0",
@ -2010,6 +2071,7 @@ dependencies = [
"fetch 0.1.0", "fetch 0.1.0",
"futures 0.1.11 (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)", "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)", "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-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)", "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)", "order-stat 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-reactor 0.1.0", "parity-reactor 0.1.0",
"parity-updater 1.8.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)", "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)", "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp 0.2.0", "rlp 0.2.0",
@ -2046,11 +2109,13 @@ version = "1.4.0"
dependencies = [ dependencies = [
"ethcore-util 1.8.0", "ethcore-util 1.8.0",
"futures 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "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-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)", "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)", "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)", "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-rpc 1.8.0", "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)", "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 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)", "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2094,7 +2159,7 @@ dependencies = [
[[package]] [[package]]
name = "parity-ui-precompiled" name = "parity-ui-precompiled"
version = "1.4.0" 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 = [ dependencies = [
"parity-dapps-glue 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-dapps-glue 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -2105,6 +2170,7 @@ version = "1.8.0"
dependencies = [ dependencies = [
"ethabi 2.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 1.8.0",
"ethcore-bigint 0.1.3",
"ethcore-ipc 1.8.0", "ethcore-ipc 1.8.0",
"ethcore-ipc-codegen 1.8.0", "ethcore-ipc-codegen 1.8.0",
"ethcore-util 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)", "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-hash-fetch 1.8.0", "parity-hash-fetch 1.8.0",
"parity-reactor 0.1.0", "parity-reactor 0.1.0",
"parking_lot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"path 0.1.0", "path 0.1.0",
"target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "libc 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "semantic_version"
version = "0.1.0"
[[package]] [[package]]
name = "semver" name = "semver"
version = "0.1.20" version = "0.1.20"
@ -2694,13 +2765,6 @@ name = "sha1"
version = "0.2.0" version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" 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]] [[package]]
name = "shell32-sys" name = "shell32-sys"
version = "0.1.1" version = "0.1.1"
@ -3072,11 +3136,24 @@ dependencies = [
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "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]] [[package]]
name = "typeable" name = "typeable"
version = "0.1.2" version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "unexpected"
version = "0.1.0"
[[package]] [[package]]
name = "unicase" name = "unicase"
version = "1.4.0" version = "1.4.0"
@ -3182,9 +3259,11 @@ version = "0.1.0"
dependencies = [ dependencies = [
"byteorder 1.0.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", "common-types 0.1.0",
"ethcore-bigint 0.1.3",
"ethcore-util 1.8.0", "ethcore-util 1.8.0",
"ethjson 0.1.0", "ethjson 0.1.0",
"evmjit 1.8.0", "evmjit 1.8.0",
"hash 0.1.0",
"lazy_static 0.2.8 (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)", "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp 0.2.0", "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 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 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 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 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 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" "checksum ethabi 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0c3d62319ee0f35abf20afe8859dd2668195912614346447bb2dee9fb8da7c62"

View File

@ -11,12 +11,14 @@ log = "0.3"
env_logger = "0.4" env_logger = "0.4"
rustc-hex = "1.0" rustc-hex = "1.0"
docopt = "0.8" docopt = "0.8"
clap = "2"
time = "0.1" time = "0.1"
num_cpus = "1.2" num_cpus = "1.2"
number_prefix = "0.2" number_prefix = "0.2"
rpassword = "0.2.1" rpassword = "0.2.1"
semver = "0.6" semver = "0.6"
ansi_term = "0.9" ansi_term = "0.9"
parking_lot = "0.4"
regex = "0.2" regex = "0.2"
isatty = "0.1" isatty = "0.1"
toml = "0.4" toml = "0.4"
@ -33,6 +35,7 @@ jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "pa
ethsync = { path = "sync" } ethsync = { path = "sync" }
ethcore = { path = "ethcore" } ethcore = { path = "ethcore" }
ethcore-util = { path = "util" } ethcore-util = { path = "util" }
ethcore-bigint = { path = "util/bigint" }
ethcore-io = { path = "util/io" } ethcore-io = { path = "util/io" }
ethcore-devtools = { path = "devtools" } ethcore-devtools = { path = "devtools" }
ethcore-ipc = { path = "ipc/rpc" } ethcore-ipc = { path = "ipc/rpc" }
@ -57,6 +60,7 @@ parity-updater = { path = "updater" }
parity-whisper = { path = "whisper" } parity-whisper = { path = "whisper" }
path = { path = "util/path" } path = { path = "util/path" }
panic_hook = { path = "panic_hook" } panic_hook = { path = "panic_hook" }
hash = { path = "util/hash" }
parity-dapps = { path = "dapps", optional = true } parity-dapps = { path = "dapps", optional = true }
clippy = { version = "0.0.103", optional = true} clippy = { version = "0.0.103", optional = true}

View File

@ -13,6 +13,7 @@ futures = "0.1"
linked-hash-map = "0.3" linked-hash-map = "0.3"
log = "0.3" log = "0.3"
parity-dapps-glue = "1.7" parity-dapps-glue = "1.7"
parking_lot = "0.4"
mime = "0.2" mime = "0.2"
mime_guess = "1.6.1" mime_guess = "1.6.1"
rand = "0.3" 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" } jsonrpc-http-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.7" }
ethcore-util = { path = "../util" } ethcore-util = { path = "../util" }
ethcore-bigint = { path = "../util/bigint" }
fetch = { path = "../util/fetch" } fetch = { path = "../util/fetch" }
node-health = { path = "./node-health" } node-health = { path = "./node-health" }
parity-hash-fetch = { path = "../hash-fetch" } parity-hash-fetch = { path = "../hash-fetch" }
parity-reactor = { path = "../util/reactor" } parity-reactor = { path = "../util/reactor" }
parity-ui = { path = "./ui" } parity-ui = { path = "./ui" }
hash = { path = "../util/hash" }
clippy = { version = "0.0.103", optional = true} clippy = { version = "0.0.103", optional = true}

View File

@ -19,9 +19,9 @@ use std::{fs, fmt};
use std::io::{self, Read, Write}; use std::io::{self, Read, Write};
use std::path::PathBuf; use std::path::PathBuf;
use fetch::{self, Mime}; use fetch::{self, Mime};
use util::H256; use hash::keccak_buffer;
use bigint::hash::H256;
use util::sha3::sha3;
use page::{LocalPageEndpoint, PageCache}; use page::{LocalPageEndpoint, PageCache};
use handlers::{ContentValidator, ValidatorResponse}; use handlers::{ContentValidator, ValidatorResponse};
use apps::manifest::{MANIFEST_FILENAME, deserialize_manifest, serialize_manifest, Manifest}; use apps::manifest::{MANIFEST_FILENAME, deserialize_manifest, serialize_manifest, Manifest};
@ -57,9 +57,9 @@ fn write_response_and_check_hash(
file.flush()?; file.flush()?;
// Validate hash // 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 mut file = io::BufReader::new(fs::File::open(&content_path)?);
let hash = sha3(&mut file)?; let hash = keccak_buffer(&mut file)?;
if id == hash { if id == hash {
Ok((file.into_inner(), content_path)) Ok((file.into_inner(), content_path))
} else { } else {

View File

@ -32,7 +32,7 @@ use hyper;
use hyper::status::StatusCode; use hyper::status::StatusCode;
use {Embeddable, SyncStatus, random_filename}; use {Embeddable, SyncStatus, random_filename};
use util::Mutex; use parking_lot::Mutex;
use page::LocalPageEndpoint; use page::LocalPageEndpoint;
use handlers::{ContentHandler, ContentFetcherHandler}; use handlers::{ContentHandler, ContentFetcherHandler};
use endpoint::{Endpoint, EndpointPath, Handler}; use endpoint::{Endpoint, EndpointPath, Handler};

View File

@ -23,7 +23,7 @@ use std::time::{Instant, Duration};
use fetch::{self, Fetch}; use fetch::{self, Fetch};
use futures::Future; use futures::Future;
use parity_reactor::Remote; use parity_reactor::Remote;
use util::Mutex; use parking_lot::Mutex;
use hyper::{server, Decoder, Encoder, Next, Method, Control}; use hyper::{server, Decoder, Encoder, Next, Method, Control};
use hyper::net::HttpStream; use hyper::net::HttpStream;

View File

@ -24,6 +24,7 @@ extern crate futures;
extern crate itertools; extern crate itertools;
extern crate linked_hash_map; extern crate linked_hash_map;
extern crate mime_guess; extern crate mime_guess;
extern crate parking_lot;
extern crate rand; extern crate rand;
extern crate rustc_hex; extern crate rustc_hex;
extern crate serde; extern crate serde;
@ -37,12 +38,14 @@ extern crate jsonrpc_core;
extern crate jsonrpc_http_server; extern crate jsonrpc_http_server;
extern crate ethcore_util as util; extern crate ethcore_util as util;
extern crate ethcore_bigint as bigint;
extern crate fetch; extern crate fetch;
extern crate node_health; extern crate node_health;
extern crate parity_dapps_glue as parity_dapps; extern crate parity_dapps_glue as parity_dapps;
extern crate parity_hash_fetch as hash_fetch; extern crate parity_hash_fetch as hash_fetch;
extern crate parity_reactor; extern crate parity_reactor;
extern crate parity_ui; extern crate parity_ui;
extern crate hash;
#[macro_use] #[macro_use]
extern crate log; extern crate log;
@ -72,7 +75,7 @@ use std::collections::HashMap;
use std::mem; use std::mem;
use std::path::PathBuf; use std::path::PathBuf;
use std::sync::Arc; use std::sync::Arc;
use util::RwLock; use parking_lot::RwLock;
use jsonrpc_http_server::{self as http, hyper, Origin}; use jsonrpc_http_server::{self as http, hyper, Origin};

View File

@ -16,7 +16,7 @@
use std::{io, thread, time}; use std::{io, thread, time};
use std::sync::{atomic, mpsc, Arc}; use std::sync::{atomic, mpsc, Arc};
use util::Mutex; use parking_lot::Mutex;
use futures::{self, Future}; use futures::{self, Future};
use fetch::{self, Fetch}; use fetch::{self, Fetch};

View File

@ -20,7 +20,9 @@ use std::collections::HashMap;
use rustc_hex::FromHex; use rustc_hex::FromHex;
use hash_fetch::urlhint::ContractClient; 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 REGISTRAR: &'static str = "8e4e9b13d4b45cb0befc93c3061b1408f67316b2";
const URLHINT: &'static str = "deadbeefcafe0000000000000000000000000000"; const URLHINT: &'static str = "deadbeefcafe0000000000000000000000000000";

View File

@ -7,10 +7,10 @@ authors = ["Parity Technologies <admin@parity.io>"]
[dependencies] [dependencies]
log = "0.3" log = "0.3"
sha3 = { path = "../util/sha3" } hash = { path = "../util/hash" }
primal = "0.2.3" primal = "0.2.3"
parking_lot = "0.4" parking_lot = "0.4"
crunchy = "0.1.0" crunchy = "0.1.0"
[features] [features]
benches = [] benches = []

View File

@ -23,7 +23,7 @@ use primal::is_prime;
use std::cell::Cell; use std::cell::Cell;
use std::mem; use std::mem;
use std::ptr; use std::ptr;
use sha3; use hash;
use std::slice; use std::slice;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::io::{self, Read, Write}; use std::io::{self, Read, Write};
@ -200,7 +200,7 @@ impl SeedHashCompute {
#[inline] #[inline]
pub fn resume_compute_seedhash(mut hash: H256, start_epoch: u64, end_epoch: u64) -> H256 { pub fn resume_compute_seedhash(mut hash: H256, start_epoch: u64, end_epoch: u64) -> H256 {
for _ in start_epoch..end_epoch { 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 hash
} }
@ -214,14 +214,14 @@ fn fnv_hash(x: u32, y: u32) -> u32 {
return x.wrapping_mul(FNV_PRIME) ^ y; return x.wrapping_mul(FNV_PRIME) ^ y;
} }
fn sha3_512(input: &[u8], output: &mut [u8]) { fn keccak_512(input: &[u8], output: &mut [u8]) {
unsafe { sha3::sha3_512(output.as_mut_ptr(), output.len(), input.as_ptr(), input.len()) }; unsafe { hash::keccak_512(output.as_mut_ptr(), output.len(), input.as_ptr(), input.len()) };
} }
fn sha3_512_inplace(input: &mut [u8]) { fn keccak_512_inplace(input: &mut [u8]) {
// This is safe since `sha3_*` uses an internal buffer and copies the result to the output. This // 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. // 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 { 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 /// Boundary recovered from mix hash
pub fn quick_get_difficulty(header_hash: &H256, nonce: u64, mix_hash: &H256) -> H256 { pub fn quick_get_difficulty(header_hash: &H256, nonce: u64, mix_hash: &H256) -> H256 {
unsafe { 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 // 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 // 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(); let mut buf: [u8; 64 + 32] = mem::uninitialized();
ptr::copy_nonoverlapping(header_hash.as_ptr(), buf.as_mut_ptr(), 32); ptr::copy_nonoverlapping(header_hash.as_ptr(), buf.as_mut_ptr(), 32);
ptr::copy_nonoverlapping(mem::transmute(&nonce), buf[32..].as_mut_ptr(), 8); 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); 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(); 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 hash
} }
@ -320,7 +320,7 @@ fn hash_compute(light: &Light, full_size: usize, header_hash: &H256, nonce: u64)
half_mix: unsafe { half_mix: unsafe {
// Pack `header_hash` and `nonce` together // Pack `header_hash` and `nonce` together
// We explicitly write the first 40 bytes, leaving the last 24 as uninitialized. Then // 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. // leaving it fully initialized.
let mut out: [u8; NODE_BYTES] = mem::uninitialized(); 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>(), mem::size_of::<u64>(),
); );
// compute sha3-512 hash and replicate across mix // compute keccak-512 hash and replicate across mix
sha3::sha3_512( hash::keccak_512(
out.as_mut_ptr(), out.as_mut_ptr(),
NODE_BYTES, NODE_BYTES,
out.as_ptr(), out.as_ptr(),
@ -427,10 +427,10 @@ fn hash_compute(light: &Light, full_size: usize, header_hash: &H256, nonce: u64)
let value: H256 = unsafe { let value: H256 = unsafe {
// We can interpret the buffer as an array of `u8`s, since it's `repr(C)`. // We can interpret the buffer as an array of `u8`s, since it's `repr(C)`.
let read_ptr: *const u8 = mem::transmute(&buf); 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. // overlapping arrays as input.
let write_ptr: *mut u8 = mem::transmute(&mut buf.compress_bytes); let write_ptr: *mut u8 = mem::transmute(&mut buf.compress_bytes);
sha3::sha3_256( hash::keccak_256(
write_ptr, write_ptr,
buf.compress_bytes.len(), buf.compress_bytes.len(),
read_ptr, 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(); let mut ret = cache[node_index as usize % num_parent_nodes].clone();
ret.as_words_mut()[0] ^= node_index; 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); debug_assert_eq!(NODE_WORDS, 16);
for i in 0..ETHASH_DATASET_PARENTS as u32 { 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 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 // Use uninit instead of unnecessarily writing `size_of::<Node>() * num_nodes` 0s
nodes.set_len(num_nodes); 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 { 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); 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);
} }
} }
} }

View File

@ -20,7 +20,7 @@
#![cfg_attr(feature = "benches", feature(test))] #![cfg_attr(feature = "benches", feature(test))]
extern crate primal; extern crate primal;
extern crate sha3; extern crate hash;
extern crate parking_lot; extern crate parking_lot;
#[macro_use] #[macro_use]

View File

@ -11,6 +11,7 @@ build = "build.rs"
"ethcore-ipc-codegen" = { path = "../ipc/codegen" } "ethcore-ipc-codegen" = { path = "../ipc/codegen" }
[dependencies] [dependencies]
ansi_term = "0.9"
bit-set = "0.4" bit-set = "0.4"
bloomchain = "0.1" bloomchain = "0.1"
bn = { git = "https://github.com/paritytech/bn" } bn = { git = "https://github.com/paritytech/bn" }
@ -29,6 +30,7 @@ ethcore-ipc-nano = { path = "../ipc/nano" }
ethcore-logger = { path = "../logger" } ethcore-logger = { path = "../logger" }
ethcore-stratum = { path = "../stratum" } ethcore-stratum = { path = "../stratum" }
ethcore-util = { path = "../util" } ethcore-util = { path = "../util" }
ethcore-bigint = { path = "../util/bigint" }
ethjson = { path = "../json" } ethjson = { path = "../json" }
ethkey = { path = "../ethkey" } ethkey = { path = "../ethkey" }
ethstore = { path = "../ethstore" } ethstore = { path = "../ethstore" }
@ -45,6 +47,7 @@ lru-cache = "0.1.0"
native-contracts = { path = "native_contracts" } native-contracts = { path = "native_contracts" }
num = "0.1" num = "0.1"
num_cpus = "1.2" num_cpus = "1.2"
parking_lot = "0.4"
price-info = { path = "../price-info" } price-info = { path = "../price-info" }
rand = "0.3" rand = "0.3"
rlp = { path = "../util/rlp" } rlp = { path = "../util/rlp" }
@ -60,6 +63,10 @@ table = { path = "../util/table" }
bloomable = { path = "../util/bloomable" } bloomable = { path = "../util/bloomable" }
vm = { path = "vm" } vm = { path = "vm" }
wasm = { path = "wasm" } wasm = { path = "wasm" }
hash = { path = "../util/hash" }
triehash = { path = "../util/triehash" }
semantic_version = { path = "../util/semantic_version" }
unexpected = { path = "../util/unexpected" }
[dev-dependencies] [dev-dependencies]
native-contracts = { path = "native_contracts", features = ["test_contracts"] } native-contracts = { path = "native_contracts", features = ["test_contracts"] }

View File

@ -8,6 +8,7 @@ bit-set = "0.4"
byteorder = "1.0" byteorder = "1.0"
common-types = { path = "../types" } common-types = { path = "../types" }
ethcore-util = { path = "../../util" } ethcore-util = { path = "../../util" }
ethcore-bigint = { path = "../../util/bigint" }
evmjit = { path = "../../evmjit", optional = true } evmjit = { path = "../../evmjit", optional = true }
ethjson = { path = "../../json" } ethjson = { path = "../../json" }
heapsize = "0.4" heapsize = "0.4"
@ -16,8 +17,10 @@ log = "0.3"
rlp = { path = "../../util/rlp" } rlp = { path = "../../util/rlp" }
vm = { path = "../vm" } vm = { path = "../vm" }
parity-wasm = "0.12" parity-wasm = "0.12"
parking_lot = "0.4"
ethcore-logger = { path = "../../logger" } ethcore-logger = { path = "../../logger" }
wasm-utils = { git = "https://github.com/paritytech/wasm-utils" } wasm-utils = { git = "https://github.com/paritytech/wasm-utils" }
hash = { path = "../../util/hash" }
[dev-dependencies] [dev-dependencies]
rustc-hex = "1.0" rustc-hex = "1.0"

View File

@ -24,6 +24,8 @@ extern crate test;
use self::test::{Bencher, black_box}; use self::test::{Bencher, black_box};
use bigint::prelude::U256;
use bigint::hash::H256;
use util::*; use util::*;
use vm::ActionParams; use vm::ActionParams;
use evm::{self, Factory, VMType}; use evm::{self, Factory, VMType};

View File

@ -17,7 +17,8 @@
//! Evm interface. //! Evm interface.
use std::{ops, cmp, fmt}; use std::{ops, cmp, fmt};
use util::{U128, U256, U512};
use bigint::prelude::{U128, U256, U512};
use vm::{Ext, Result, ReturnData, GasLeft, Error}; 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 /// 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)] #[cfg(test)]
mod tests { mod tests {
use util::U256; use bigint::prelude::U256;
use super::CostType; use super::CostType;
#[test] #[test]

View File

@ -18,7 +18,7 @@
//! //!
use std::sync::Arc; use std::sync::Arc;
use vm::Vm; use vm::Vm;
use util::U256; use bigint::prelude::U256;
use super::interpreter::SharedCache; use super::interpreter::SharedCache;
use super::vmtype::VMType; use super::vmtype::VMType;

View File

@ -15,7 +15,8 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
use std::cmp; use std::cmp;
use util::*; use bigint::prelude::U256;
use bigint::hash::H256;
use super::u256_to_address; use super::u256_to_address;
use {evm, vm}; use {evm, vm};

View File

@ -43,7 +43,7 @@ mod inner {
use evm::instructions::{Instruction, InstructionInfo, INSTRUCTIONS}; use evm::instructions::{Instruction, InstructionInfo, INSTRUCTIONS};
use evm::{CostType}; use evm::{CostType};
use util::U256; use bigint::prelude::U256;
macro_rules! evm_debug { macro_rules! evm_debug {
($x: expr) => { ($x: expr) => {

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
use util::U256; use bigint::prelude::U256;
use vm::ReturnData; use vm::ReturnData;
const MAX_RETURN_WASTE_BYTES: usize = 16384; const MAX_RETURN_WASTE_BYTES: usize = 16384;
@ -134,7 +134,7 @@ impl Memory for Vec<u8> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use util::U256; use bigint::prelude::U256;
use super::Memory; use super::Memory;
#[test] #[test]

View File

@ -26,6 +26,9 @@ mod shared_cache;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::{cmp, mem}; use std::{cmp, mem};
use std::sync::Arc; use std::sync::Arc;
use hash::keccak;
use bigint::prelude::{U256, U512};
use bigint::hash::H256;
use vm::{ use vm::{
self, ActionParams, ActionValue, CallType, MessageCallResult, self, ActionParams, ActionValue, CallType, MessageCallResult,
@ -180,7 +183,7 @@ impl<Cost: CostType> vm::Vm for Interpreter<Cost> {
match result { match result {
InstructionResult::JumpToPosition(position) => { InstructionResult::JumpToPosition(position) => {
if valid_jump_destinations.is_none() { 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)); 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"); 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 => { instructions::SHA3 => {
let offset = stack.pop_back(); let offset = stack.pop_back();
let size = stack.pop_back(); let size = stack.pop_back();
let sha3 = self.mem.read_slice(offset, size).sha3(); let k = keccak(self.mem.read_slice(offset, size));
stack.push(U256::from(&*sha3)); stack.push(U256::from(&*k));
}, },
instructions::SLOAD => { instructions::SLOAD => {
let key = H256::from(&stack.pop_back()); let key = H256::from(&stack.pop_back());
@ -880,7 +883,7 @@ mod tests {
use rustc_hex::FromHex; use rustc_hex::FromHex;
use vmtype::VMType; use vmtype::VMType;
use factory::Factory; use factory::Factory;
use vm::{self, ActionParams, ActionValue}; use vm::{ActionParams, ActionValue};
use vm::tests::{FakeExt, test_finalize}; use vm::tests::{FakeExt, test_finalize};
#[test] #[test]

View File

@ -15,9 +15,10 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
use std::sync::Arc; use std::sync::Arc;
use hash::KECCAK_EMPTY;
use heapsize::HeapSizeOf; use heapsize::HeapSizeOf;
use util::{H256, Mutex}; use bigint::hash::H256;
use util::sha3::*; use parking_lot::Mutex;
use util::cache::MemoryLruCache; use util::cache::MemoryLruCache;
use bit_set::BitSet; use bit_set::BitSet;
use super::super::instructions; use super::super::instructions;
@ -50,7 +51,7 @@ impl SharedCache {
/// Get jump destinations bitmap for a contract. /// Get jump destinations bitmap for a contract.
pub fn jump_destinations(&self, code_hash: &H256, code: &[u8]) -> Arc<BitSet> { 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); return Self::find_jump_destinations(code);
} }

View File

@ -15,6 +15,8 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
//! Just in time compiler execution environment. //! Just in time compiler execution environment.
use bigint::prelude::U256;
use bigint::hash::H256;
use util::*; use util::*;
use evmjit; use evmjit;
use evm::{self, GasLeft}; use evm::{self, GasLeft};

View File

@ -20,13 +20,16 @@ extern crate byteorder;
extern crate bit_set; extern crate bit_set;
extern crate common_types as types; extern crate common_types as types;
extern crate ethcore_util as util; extern crate ethcore_util as util;
extern crate ethcore_bigint as bigint;
extern crate ethjson; extern crate ethjson;
extern crate rlp; extern crate rlp;
extern crate parity_wasm; extern crate parity_wasm;
extern crate parking_lot;
extern crate wasm_utils; extern crate wasm_utils;
extern crate ethcore_logger; extern crate ethcore_logger;
extern crate heapsize; extern crate heapsize;
extern crate vm; extern crate vm;
extern crate hash;
#[macro_use] #[macro_use]
extern crate lazy_static; extern crate lazy_static;

View File

@ -20,6 +20,8 @@ use std::hash::Hash;
use std::sync::Arc; use std::sync::Arc;
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use rustc_hex::FromHex; use rustc_hex::FromHex;
use bigint::prelude::U256;
use bigint::hash::H256;
use util::*; use util::*;
use vm::{self, ActionParams, ActionValue}; use vm::{self, ActionParams, ActionValue};
use vm::tests::{FakeExt, FakeCall, FakeCallType, test_finalize}; use vm::tests::{FakeExt, FakeCall, FakeCallType, test_finalize};

View File

@ -14,6 +14,7 @@ build = "build.rs"
log = "0.3" log = "0.3"
ethcore = { path = ".."} ethcore = { path = ".."}
ethcore-util = { path = "../../util" } ethcore-util = { path = "../../util" }
ethcore-bigint = { path = "../../util/bigint" }
ethcore-network = { path = "../../util/network" } ethcore-network = { path = "../../util/network" }
ethcore-io = { path = "../../util/io" } ethcore-io = { path = "../../util/io" }
ethcore-ipc = { path = "../../ipc/rpc", optional = true } ethcore-ipc = { path = "../../ipc/rpc", optional = true }
@ -31,7 +32,10 @@ itertools = "0.5"
bincode = "0.8.0" bincode = "0.8.0"
serde = "1.0" serde = "1.0"
serde_derive = "1.0" serde_derive = "1.0"
parking_lot = "0.4"
stats = { path = "../../util/stats" } stats = { path = "../../util/stats" }
hash = { path = "../../util/hash" }
triehash = { path = "../../util/triehash" }
[features] [features]
default = [] default = []

View File

@ -27,7 +27,8 @@ use ethcore::receipt::Receipt;
use stats::Corpus; use stats::Corpus;
use time::{SteadyTime, Duration}; use time::{SteadyTime, Duration};
use heapsize::HeapSizeOf; use heapsize::HeapSizeOf;
use util::{U256, H256}; use bigint::prelude::U256;
use bigint::hash::H256;
use util::cache::MemoryLruCache; use util::cache::MemoryLruCache;
/// Configuration for how much data to cache. /// Configuration for how much data to cache.

View File

@ -21,7 +21,9 @@
//! we discarded. //! we discarded.
use ethcore::ids::BlockId; 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 util::trie::{self, TrieMut, TrieDBMut, Trie, TrieDB, Recorder};
use rlp::{RlpStream, UntrustedRlp}; 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 { if v.len() == SIZE as usize {
Some(::util::triehash::trie_root(v)) Some(::triehash::trie_root(v))
} else { } else {
None None
} }

View File

@ -37,11 +37,12 @@ use ethcore::ids::BlockId;
use rlp::{Encodable, Decodable, DecoderError, RlpStream, Rlp, UntrustedRlp}; use rlp::{Encodable, Decodable, DecoderError, RlpStream, Rlp, UntrustedRlp};
use heapsize::HeapSizeOf; use heapsize::HeapSizeOf;
use util::{H256, U256, RwLock}; use bigint::prelude::U256;
use bigint::hash::H256;
use util::kvdb::{DBTransaction, KeyValueDB}; use util::kvdb::{DBTransaction, KeyValueDB};
use cache::Cache; use cache::Cache;
use util::Mutex; use parking_lot::{Mutex, RwLock};
use smallvec::SmallVec; use smallvec::SmallVec;
@ -487,7 +488,7 @@ impl HeaderChain {
/// Get the genesis hash. /// Get the genesis hash.
pub fn genesis_hash(&self) -> H256 { pub fn genesis_hash(&self) -> H256 {
::util::Hashable::sha3(&self.genesis_header) self.genesis_header.hash()
} }
/// Get the best block's data. /// Get the best block's data.
@ -555,7 +556,7 @@ mod tests {
use cache::Cache; use cache::Cache;
use time::Duration; use time::Duration;
use util::Mutex; use parking_lot::Mutex;
fn make_db() -> Arc<::util::KeyValueDB> { fn make_db() -> Arc<::util::KeyValueDB> {
Arc::new(::util::kvdb::in_memory(0)) Arc::new(::util::kvdb::in_memory(0))

View File

@ -30,8 +30,10 @@ use ethcore::spec::Spec;
use ethcore::service::ClientIoMessage; use ethcore::service::ClientIoMessage;
use ethcore::encoded; use ethcore::encoded;
use io::IoChannel; 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 util::kvdb::{KeyValueDB, CompactionProfile};
use self::header_chain::{AncestryIter, HeaderChain}; use self::header_chain::{AncestryIter, HeaderChain};

View File

@ -28,7 +28,7 @@ use io::{IoContext, IoError, IoHandler, IoService};
use util::kvdb::{Database, DatabaseConfig}; use util::kvdb::{Database, DatabaseConfig};
use cache::Cache; use cache::Cache;
use util::Mutex; use parking_lot::Mutex;
use super::{Client, Config as ClientConfig}; use super::{Client, Config as ClientConfig};
@ -117,11 +117,11 @@ mod tests {
use super::Service; use super::Service;
use devtools::RandomTempPath; use devtools::RandomTempPath;
use ethcore::spec::Spec; use ethcore::spec::Spec;
use std::sync::Arc; use std::sync::Arc;
use cache::Cache; use cache::Cache;
use time::Duration; use time::Duration;
use util::Mutex; use parking_lot::Mutex;
#[test] #[test]
fn it_works() { fn it_works() {

View File

@ -70,6 +70,7 @@ extern crate bincode;
extern crate ethcore_io as io; extern crate ethcore_io as io;
extern crate ethcore_network as network; extern crate ethcore_network as network;
extern crate ethcore_util as util; extern crate ethcore_util as util;
extern crate ethcore_bigint as bigint;
extern crate ethcore; extern crate ethcore;
extern crate evm; extern crate evm;
extern crate heapsize; extern crate heapsize;
@ -77,6 +78,7 @@ extern crate futures;
extern crate itertools; extern crate itertools;
extern crate rand; extern crate rand;
extern crate rlp; extern crate rlp;
extern crate parking_lot;
#[macro_use] #[macro_use]
extern crate rlp_derive; extern crate rlp_derive;
extern crate serde; extern crate serde;
@ -84,6 +86,8 @@ extern crate smallvec;
extern crate stats; extern crate stats;
extern crate time; extern crate time;
extern crate vm; extern crate vm;
extern crate hash;
extern crate triehash;
#[cfg(feature = "ipc")] #[cfg(feature = "ipc")]
extern crate ethcore_ipc as ipc; extern crate ethcore_ipc as ipc;

View File

@ -32,7 +32,7 @@ use request::{CompleteRequest, Kind};
use bincode; use bincode;
use time; use time;
use util::{RwLock, Mutex}; use parking_lot::{RwLock, Mutex};
/// Number of time periods samples should be kept for. /// Number of time periods samples should be kept for.
pub const MOVING_SAMPLE_SIZE: usize = 256; pub const MOVING_SAMPLE_SIZE: usize = 256;

View File

@ -23,8 +23,10 @@ use ethcore::transaction::UnverifiedTransaction;
use io::TimerToken; use io::TimerToken;
use network::{HostInfo, NetworkProtocolHandler, NetworkContext, PeerId}; use network::{HostInfo, NetworkProtocolHandler, NetworkContext, PeerId};
use rlp::{RlpStream, UntrustedRlp}; use rlp::{RlpStream, UntrustedRlp};
use util::hash::H256; use bigint::prelude::U256;
use util::{DBValue, Mutex, RwLock, U256}; use bigint::hash::H256;
use util::DBValue;
use parking_lot::{Mutex, RwLock};
use time::{Duration, SteadyTime}; use time::{Duration, SteadyTime};
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
@ -287,7 +289,7 @@ pub type PeerMap = HashMap<PeerId, Mutex<Peer>>;
mod id_guard { mod id_guard {
use network::PeerId; use network::PeerId;
use util::RwLockReadGuard; use parking_lot::RwLockReadGuard;
use super::{PeerMap, ReqId}; use super::{PeerMap, ReqId};

View File

@ -30,7 +30,7 @@ use request::{self, Request};
use super::error::Error; use super::error::Error;
use rlp::*; use rlp::*;
use util::U256; use bigint::prelude::U256;
use time::{Duration, SteadyTime}; use time::{Duration, SteadyTime};
/// Credits value. /// Credits value.

View File

@ -27,7 +27,7 @@ use std::iter::FromIterator;
use request::Request; use request::Request;
use request::NetworkRequests as Requests; use request::NetworkRequests as Requests;
use net::{timeout, ReqId}; use net::{timeout, ReqId};
use util::U256; use bigint::prelude::U256;
use time::{Duration, SteadyTime}; use time::{Duration, SteadyTime};

View File

@ -17,7 +17,8 @@
//! Peer status and capabilities. //! Peer status and capabilities.
use rlp::{DecoderError, Encodable, Decodable, RlpStream, UntrustedRlp}; use rlp::{DecoderError, Encodable, Decodable, RlpStream, UntrustedRlp};
use util::{H256, U256}; use bigint::prelude::U256;
use bigint::hash::H256;
use super::request_credits::FlowParams; use super::request_credits::FlowParams;
@ -373,7 +374,8 @@ pub fn write_announcement(announcement: &Announcement) -> Vec<u8> {
mod tests { mod tests {
use super::*; use super::*;
use super::super::request_credits::FlowParams; use super::super::request_credits::FlowParams;
use util::{U256, H256}; use bigint::prelude::U256;
use bigint::hash::H256;
use rlp::{RlpStream, UntrustedRlp}; use rlp::{RlpStream, UntrustedRlp};
#[test] #[test]

View File

@ -32,7 +32,9 @@ use request;
use request::*; use request::*;
use rlp::*; use rlp::*;
use util::{Address, H256, U256}; use bigint::prelude::U256;
use bigint::hash::H256;
use util::Address;
use std::sync::Arc; 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_1, req.clone(), 0.into(), ::time::SteadyTime::now());
pending_requests.insert(req_id_2, req, 1.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(), local_credits: flow_params.create_credits(),
status: status(provider.client.chain_info()), status: status(provider.client.chain_info()),
capabilities: capabilities.clone(), capabilities: capabilities.clone(),

View File

@ -27,7 +27,7 @@ use ethcore::executed::{Executed, ExecutionError};
use futures::{Async, Poll, Future}; use futures::{Async, Poll, Future};
use futures::sync::oneshot::{self, Sender, Receiver, Canceled}; use futures::sync::oneshot::{self, Sender, Receiver, Canceled};
use network::PeerId; use network::PeerId;
use util::{RwLock, Mutex}; use parking_lot::{RwLock, Mutex};
use net::{ use net::{
self, Handler, PeerStatus, Status, Capabilities, self, Handler, PeerStatus, Status, Capabilities,

View File

@ -25,13 +25,16 @@ use ethcore::receipt::Receipt;
use ethcore::state::{self, ProvedExecution}; use ethcore::state::{self, ProvedExecution};
use ethcore::transaction::SignedTransaction; use ethcore::transaction::SignedTransaction;
use vm::EnvInfo; 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 request::{self as net_request, IncompleteRequest, CompleteRequest, Output, OutputKind, Field};
use rlp::{RlpStream, UntrustedRlp}; 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::memorydb::MemoryDB;
use util::sha3::{Hashable, SHA3_NULL_RLP, SHA3_EMPTY, SHA3_EMPTY_LIST_RLP};
use util::trie::{Trie, TrieDB, TrieError}; use util::trie::{Trie, TrieDB, TrieError};
const SUPPLIED_MATCHES: &'static str = "supplied responses always match produced requests; enforced by `check_response`; qed"; 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) => { Request::Account(req) => {
let net_req = net_request::IncompleteAccountRequest { let net_req = net_request::IncompleteAccountRequest {
block_hash: req.header.field(), 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) CheckedRequest::Account(req, net_req)
} }
@ -366,7 +369,7 @@ impl CheckedRequest {
} }
CheckedRequest::Receipts(ref check, ref req) => { CheckedRequest::Receipts(ref check, ref req) => {
// empty transactions -> no receipts // 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())); return Some(Response::Receipts(Vec::new()));
} }
@ -377,7 +380,7 @@ impl CheckedRequest {
CheckedRequest::Body(ref check, ref req) => { CheckedRequest::Body(ref check, ref req) => {
// check for empty body. // check for empty body.
if let Some(hdr) = check.0.as_ref().ok() { 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); let mut stream = RlpStream::new_list(3);
stream.append_raw(hdr.rlp().as_raw(), 1); stream.append_raw(hdr.rlp().as_raw(), 1);
stream.begin_list(0); stream.begin_list(0);
@ -422,7 +425,7 @@ impl CheckedRequest {
}) })
} }
CheckedRequest::Code(_, ref req) => { 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())) Some(Response::Code(Vec::new()))
} else { } else {
None None
@ -571,8 +574,8 @@ impl net_request::ResponseLike for Response {
match *self { match *self {
Response::HeaderProof((ref hash, _)) => f(0, Output::Hash(*hash)), Response::HeaderProof((ref hash, _)) => f(0, Output::Hash(*hash)),
Response::Account(None) => { Response::Account(None) => {
f(0, Output::Hash(SHA3_EMPTY)); // code hash f(0, Output::Hash(KECCAK_EMPTY)); // code hash
f(1, Output::Hash(SHA3_NULL_RLP)); // storage root. f(1, Output::Hash(KECCAK_NULL_RLP)); // storage root.
} }
Response::Account(Some(ref acc)) => { Response::Account(Some(ref acc)) => {
f(0, Output::Hash(acc.code_hash)); f(0, Output::Hash(acc.code_hash));
@ -688,7 +691,7 @@ impl HeaderByHash {
}; };
let header = headers.get(0).ok_or(Error::Empty)?; let header = headers.get(0).ok_or(Error::Empty)?;
let hash = header.sha3(); let hash = header.hash();
match hash == expected_hash { match hash == expected_hash {
true => { true => {
cache.lock().insert_block_header(hash, header.clone()); 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> { 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 // check the integrity of the the body against the header
let header = self.0.as_ref()?; 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() { if tx_root != header.transactions_root() {
return Err(Error::WrongTrieRoot(header.transactions_root(), tx_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() { if uncles_hash != header.uncles_hash() {
return Err(Error::WrongHash(header.uncles_hash(), 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. /// Check a response with receipts against the stored header.
pub fn check_response(&self, cache: &Mutex<::cache::Cache>, receipts: &[Receipt]) -> Result<Vec<Receipt>, Error> { 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 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 { match receipts_root == found_root {
true => { true => {
@ -768,7 +771,7 @@ impl Account {
let mut db = MemoryDB::new(); let mut db = MemoryDB::new();
for node in proof { db.insert(&node[..]); } 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) => { Some(val) => {
let rlp = UntrustedRlp::new(&val); let rlp = UntrustedRlp::new(&val);
Ok(Some(BasicAccount { Ok(Some(BasicAccount {
@ -800,7 +803,7 @@ impl Code {
code_hash: &H256, code_hash: &H256,
code: &[u8] code: &[u8]
) -> Result<Vec<u8>, Error> { ) -> Result<Vec<u8>, Error> {
let found_hash = code.sha3(); let found_hash = keccak(code);
if &found_hash == code_hash { if &found_hash == code_hash {
Ok(code.to_vec()) Ok(code.to_vec())
} else { } else {
@ -850,9 +853,12 @@ impl TransactionProof {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; 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::{Trie, TrieMut, SecTrieDB, SecTrieDBMut};
use util::trie::recorder::Recorder; use util::trie::recorder::Recorder;
use hash::keccak;
use ethcore::client::{BlockChainClient, TestBlockChainClient, EachBlockWith}; use ethcore::client::{BlockChainClient, TestBlockChainClient, EachBlockWith};
use ethcore::header::Header; use ethcore::header::Header;
@ -933,7 +939,7 @@ mod tests {
}).collect::<Vec<_>>(); }).collect::<Vec<_>>();
let mut header = Header::new(); 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()) receipts.iter().map(|x| ::rlp::encode(x).into_vec())
); );
@ -998,7 +1004,7 @@ mod tests {
#[test] #[test]
fn check_code() { fn check_code() {
let code = vec![1u8; 256]; let code = vec![1u8; 256];
let code_hash = ::util::Hashable::sha3(&code); let code_hash = keccak(&code);
let header = Header::new(); let header = Header::new();
let req = Code { let req = Code {
header: encoded::Header::new(::rlp::encode(&header).into_vec()).into(), header: encoded::Header::new(::rlp::encode(&header).into_vec()).into(),

View File

@ -22,7 +22,8 @@ use ethcore::header::{Header, Seal};
use futures::Future; use futures::Future;
use network::{PeerId, NodeId}; use network::{PeerId, NodeId};
use net::*; use net::*;
use util::{H256, Mutex}; use bigint::hash::H256;
use parking_lot::Mutex;
use time::Duration; use time::Duration;
use ::request::{self as basic_request, Response}; use ::request::{self as basic_request, Response};

View File

@ -24,7 +24,8 @@ use ethcore::client::{BlockChainClient, ProvingBlockChainClient};
use ethcore::transaction::PendingTransaction; use ethcore::transaction::PendingTransaction;
use ethcore::ids::BlockId; use ethcore::ids::BlockId;
use ethcore::encoded; use ethcore::encoded;
use util::{RwLock, H256}; use bigint::hash::H256;
use parking_lot::RwLock;
use cht::{self, BlockInfo}; use cht::{self, BlockInfo};
use client::{LightChainClient, AsLightClient}; use client::{LightChainClient, AsLightClient};

View File

@ -28,7 +28,9 @@ use std::collections::hash_map::Entry;
use ethcore::error::{TransactionError, TransactionImportResult}; use ethcore::error::{TransactionError, TransactionImportResult};
use ethcore::transaction::{Condition, PendingTransaction, SignedTransaction}; 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. // Knowledge of an account's current nonce.
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]

View File

@ -211,7 +211,7 @@ impl<T: IncompleteRequest> DerefMut for Requests<T> {
mod tests { mod tests {
use request::*; use request::*;
use super::RequestBuilder; use super::RequestBuilder;
use util::H256; use bigint::hash::H256;
#[test] #[test]
fn all_scalar() { fn all_scalar() {

View File

@ -17,7 +17,7 @@
//! Light protocol request types. //! Light protocol request types.
use rlp::{Encodable, Decodable, DecoderError, RlpStream, UntrustedRlp}; use rlp::{Encodable, Decodable, DecoderError, RlpStream, UntrustedRlp};
use util::H256; use bigint::hash::H256;
mod builder; mod builder;
@ -760,7 +760,9 @@ pub mod header {
pub mod header_proof { pub mod header_proof {
use super::{Field, NoSuchOutput, OutputKind, Output}; use super::{Field, NoSuchOutput, OutputKind, Output};
use rlp::{Encodable, Decodable, DecoderError, RlpStream, UntrustedRlp}; 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. /// Potentially incomplete header proof request.
#[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)] #[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)]
@ -854,7 +856,7 @@ pub mod header_proof {
/// Request and response for transaction index. /// Request and response for transaction index.
pub mod transaction_index { pub mod transaction_index {
use super::{Field, NoSuchOutput, OutputKind, Output}; use super::{Field, NoSuchOutput, OutputKind, Output};
use util::H256; use bigint::hash::H256;
/// Potentially incomplete transaction index request. /// Potentially incomplete transaction index request.
#[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)] #[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)]
@ -932,7 +934,7 @@ pub mod transaction_index {
pub mod block_receipts { pub mod block_receipts {
use super::{Field, NoSuchOutput, OutputKind, Output}; use super::{Field, NoSuchOutput, OutputKind, Output};
use ethcore::receipt::Receipt; use ethcore::receipt::Receipt;
use util::H256; use bigint::hash::H256;
/// Potentially incomplete block receipts request. /// Potentially incomplete block receipts request.
#[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)] #[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)]
@ -1001,7 +1003,7 @@ pub mod block_body {
use super::{Field, NoSuchOutput, OutputKind, Output}; use super::{Field, NoSuchOutput, OutputKind, Output};
use ethcore::encoded; use ethcore::encoded;
use rlp::{Encodable, Decodable, DecoderError, RlpStream, UntrustedRlp}; use rlp::{Encodable, Decodable, DecoderError, RlpStream, UntrustedRlp};
use util::H256; use bigint::hash::H256;
/// Potentially incomplete block body request. /// Potentially incomplete block body request.
#[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)] #[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)]
@ -1089,7 +1091,9 @@ pub mod block_body {
/// A request for an account proof. /// A request for an account proof.
pub mod account { pub mod account {
use super::{Field, NoSuchOutput, OutputKind, Output}; 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. /// Potentially incomplete request for an account proof.
#[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)] #[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)]
@ -1188,7 +1192,8 @@ pub mod account {
/// A request for a storage proof. /// A request for a storage proof.
pub mod storage { pub mod storage {
use super::{Field, NoSuchOutput, OutputKind, Output}; use super::{Field, NoSuchOutput, OutputKind, Output};
use util::{Bytes, H256}; use bigint::hash::H256;
use util::Bytes;
/// Potentially incomplete request for an storage proof. /// Potentially incomplete request for an storage proof.
#[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)] #[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)]
@ -1296,7 +1301,8 @@ pub mod storage {
/// A request for contract code. /// A request for contract code.
pub mod contract_code { pub mod contract_code {
use super::{Field, NoSuchOutput, OutputKind, Output}; use super::{Field, NoSuchOutput, OutputKind, Output};
use util::{Bytes, H256}; use bigint::hash::H256;
use util::Bytes;
/// Potentially incomplete contract code request. /// Potentially incomplete contract code request.
#[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)] #[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)]
@ -1382,7 +1388,9 @@ pub mod execution {
use super::{Field, NoSuchOutput, OutputKind, Output}; use super::{Field, NoSuchOutput, OutputKind, Output};
use ethcore::transaction::Action; use ethcore::transaction::Action;
use rlp::{Encodable, Decodable, DecoderError, RlpStream, UntrustedRlp}; 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. /// Potentially incomplete execution proof request.
#[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)] #[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)]
@ -1591,7 +1599,7 @@ mod tests {
let full_req = Request::TransactionIndex(req.clone()); let full_req = Request::TransactionIndex(req.clone());
let res = TransactionIndexResponse { let res = TransactionIndexResponse {
num: 1000, num: 1000,
hash: ::util::H256::random(), hash: ::bigint::hash::H256::random(),
index: 4, index: 4,
}; };
let full_res = Response::TransactionIndex(res.clone()); let full_res = Response::TransactionIndex(res.clone());

View File

@ -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_SET_ABI: &'static str = include_str!("res/validator_set.json");
const VALIDATOR_REPORT_ABI: &'static str = include_str!("res/validator_report.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 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"); 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("ValidatorSet", VALIDATOR_SET_ABI, "validator_set.rs");
build_file("ValidatorReport", VALIDATOR_REPORT_ABI, "validator_report.rs"); build_file("ValidatorReport", VALIDATOR_REPORT_ABI, "validator_report.rs");
build_file("PeerSet", PEER_SET_ABI, "peer_set.rs"); build_file("PeerSet", PEER_SET_ABI, "peer_set.rs");
build_file("TransactAcl", TX_ACL_ABI, "tx_acl.rs");
build_test_contracts(); build_test_contracts();
} }

View File

@ -302,7 +302,8 @@ fn detokenize(name: &str, output_type: ParamType) -> String {
} }
ParamType::Uint(width) => { ParamType::Uint(width) => {
let read_uint = match 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), _ => format!("bigint::prelude::U{}::from(&u[..])", width),
}; };

View File

@ -0,0 +1 @@
[{"constant":false,"inputs":[{"name":"sender","type":"address"}],"name":"allowedTxTypes","outputs":[{"name":"","type":"uint32"}],"payable":false,"stateMutability":"nonpayable","type":"function"}]

View File

@ -31,6 +31,7 @@ mod secretstore_acl_storage;
mod validator_set; mod validator_set;
mod validator_report; mod validator_report;
mod peer_set; mod peer_set;
mod tx_acl;
pub mod test_contracts; 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_set::ValidatorSet;
pub use self::validator_report::ValidatorReport; pub use self::validator_report::ValidatorReport;
pub use self::peer_set::PeerSet; pub use self::peer_set::PeerSet;
pub use self::tx_acl::TransactAcl;

View File

@ -14,7 +14,8 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
extern { #![allow(unused_mut, unused_variables, unused_imports)]
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; //! Transact permissions contract.
}
include!(concat!(env!("OUT_DIR"), "/tx_acl.rs"));

View File

@ -9,8 +9,10 @@ authors = ["Parity Technologies <admin@parity.io>"]
[dependencies] [dependencies]
ethcore = { path = ".."} ethcore = { path = ".."}
ethcore-util = { path = "../../util" } ethcore-util = { path = "../../util" }
ethcore-bigint = { path = "../../util/bigint" }
ethcore-io = { path = "../../util/io" } ethcore-io = { path = "../../util/io" }
ethcore-network = { path = "../../util/network" } ethcore-network = { path = "../../util/network" }
native-contracts = { path = "../native_contracts" } native-contracts = { path = "../native_contracts" }
futures = "0.1" futures = "0.1"
log = "0.3" log = "0.3"
parking_lot = "0.4"

View File

@ -18,9 +18,11 @@
extern crate ethcore; extern crate ethcore;
extern crate ethcore_util as util; extern crate ethcore_util as util;
extern crate ethcore_bigint as bigint;
extern crate ethcore_network as network; extern crate ethcore_network as network;
extern crate native_contracts; extern crate native_contracts;
extern crate futures; extern crate futures;
extern crate parking_lot;
#[cfg(test)] extern crate ethcore_io as io; #[cfg(test)] extern crate ethcore_io as io;
#[macro_use] extern crate log; #[macro_use] extern crate log;
@ -29,7 +31,9 @@ use std::collections::HashMap;
use native_contracts::PeerSet as Contract; use native_contracts::PeerSet as Contract;
use network::{NodeId, ConnectionFilter, ConnectionDirection}; use network::{NodeId, ConnectionFilter, ConnectionDirection};
use ethcore::client::{BlockChainClient, BlockId, ChainNotify}; 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; use futures::Future;
const MAX_CACHE_SIZE: usize = 4096; const MAX_CACHE_SIZE: usize = 4096;

View File

@ -16,6 +16,8 @@
//! DB backend wrapper for Account trie //! DB backend wrapper for Account trie
use std::collections::HashMap; use std::collections::HashMap;
use hash::{KECCAK_NULL_RLP, keccak};
use bigint::hash::H256;
use util::*; use util::*;
use rlp::NULL_RLP; use rlp::NULL_RLP;
@ -79,7 +81,7 @@ impl<'db> AccountDB<'db> {
/// Create a new AccountDB from an address. /// Create a new AccountDB from an address.
#[cfg(test)] #[cfg(test)]
pub fn new(db: &'db HashDB, address: &Address) -> Self { 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. /// 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> { fn get(&self, key: &H256) -> Option<DBValue> {
if key == &SHA3_NULL_RLP { if key == &KECCAK_NULL_RLP {
return Some(DBValue::from_slice(&NULL_RLP)); return Some(DBValue::from_slice(&NULL_RLP));
} }
self.db.get(&combine_key(&self.address_hash, key)) self.db.get(&combine_key(&self.address_hash, key))
} }
fn contains(&self, key: &H256) -> bool { fn contains(&self, key: &H256) -> bool {
if key == &SHA3_NULL_RLP { if key == &KECCAK_NULL_RLP {
return true; return true;
} }
self.db.contains(&combine_key(&self.address_hash, key)) self.db.contains(&combine_key(&self.address_hash, key))
@ -133,7 +135,7 @@ impl<'db> AccountDBMut<'db> {
/// Create a new AccountDB from an address. /// Create a new AccountDB from an address.
#[cfg(test)] #[cfg(test)]
pub fn new(db: &'db mut HashDB, address: &Address) -> Self { 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. /// 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> { fn get(&self, key: &H256) -> Option<DBValue> {
if key == &SHA3_NULL_RLP { if key == &KECCAK_NULL_RLP {
return Some(DBValue::from_slice(&NULL_RLP)); return Some(DBValue::from_slice(&NULL_RLP));
} }
self.db.get(&combine_key(&self.address_hash, key)) self.db.get(&combine_key(&self.address_hash, key))
} }
fn contains(&self, key: &H256) -> bool { fn contains(&self, key: &H256) -> bool {
if key == &SHA3_NULL_RLP { if key == &KECCAK_NULL_RLP {
return true; return true;
} }
self.db.contains(&combine_key(&self.address_hash, key)) 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 { fn insert(&mut self, value: &[u8]) -> H256 {
if value == &NULL_RLP { 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); let ak = combine_key(&self.address_hash, &k);
self.db.emplace(ak, DBValue::from_slice(value)); self.db.emplace(ak, DBValue::from_slice(value));
k k
} }
fn emplace(&mut self, key: H256, value: DBValue) { fn emplace(&mut self, key: H256, value: DBValue) {
if key == SHA3_NULL_RLP { if key == KECCAK_NULL_RLP {
return; return;
} }
let key = combine_key(&self.address_hash, &key); let key = combine_key(&self.address_hash, &key);
@ -188,7 +190,7 @@ impl<'db> HashDB for AccountDBMut<'db>{
} }
fn remove(&mut self, key: &H256) { fn remove(&mut self, key: &H256) {
if key == &SHA3_NULL_RLP { if key == &KECCAK_NULL_RLP {
return; return;
} }
let key = combine_key(&self.address_hash, key); 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> { fn get(&self, key: &H256) -> Option<DBValue> {
if key == &SHA3_NULL_RLP { if key == &KECCAK_NULL_RLP {
return Some(DBValue::from_slice(&NULL_RLP)); return Some(DBValue::from_slice(&NULL_RLP));
} }
self.0.get(key) self.0.get(key)
} }
fn contains(&self, key: &H256) -> bool { fn contains(&self, key: &H256) -> bool {
if key == &SHA3_NULL_RLP { if key == &KECCAK_NULL_RLP {
return true; return true;
} }
self.0.contains(key) self.0.contains(key)
@ -238,14 +240,14 @@ impl<'db> HashDB for WrappingMut<'db>{
} }
fn get(&self, key: &H256) -> Option<DBValue> { fn get(&self, key: &H256) -> Option<DBValue> {
if key == &SHA3_NULL_RLP { if key == &KECCAK_NULL_RLP {
return Some(DBValue::from_slice(&NULL_RLP)); return Some(DBValue::from_slice(&NULL_RLP));
} }
self.0.get(key) self.0.get(key)
} }
fn contains(&self, key: &H256) -> bool { fn contains(&self, key: &H256) -> bool {
if key == &SHA3_NULL_RLP { if key == &KECCAK_NULL_RLP {
return true; return true;
} }
self.0.contains(key) self.0.contains(key)
@ -253,20 +255,20 @@ impl<'db> HashDB for WrappingMut<'db>{
fn insert(&mut self, value: &[u8]) -> H256 { fn insert(&mut self, value: &[u8]) -> H256 {
if value == &NULL_RLP { if value == &NULL_RLP {
return SHA3_NULL_RLP.clone(); return KECCAK_NULL_RLP.clone();
} }
self.0.insert(value) self.0.insert(value)
} }
fn emplace(&mut self, key: H256, value: DBValue) { fn emplace(&mut self, key: H256, value: DBValue) {
if key == SHA3_NULL_RLP { if key == KECCAK_NULL_RLP {
return; return;
} }
self.0.emplace(key, value) self.0.emplace(key, value)
} }
fn remove(&mut self, key: &H256) { fn remove(&mut self, key: &H256) {
if key == &SHA3_NULL_RLP { if key == &KECCAK_NULL_RLP {
return; return;
} }
self.0.remove(key) self.0.remove(key)

View File

@ -23,7 +23,7 @@ use self::stores::{AddressBook, DappsSettingsStore, NewDappsPolicy};
use std::fmt; use std::fmt;
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use std::time::{Instant, Duration}; use std::time::{Instant, Duration};
use util::{RwLock}; use parking_lot::RwLock;
use ethstore::{ use ethstore::{
SimpleSecretStore, SecretStore, Error as SSError, EthStore, EthMultiStore, SimpleSecretStore, SecretStore, Error as SSError, EthStore, EthMultiStore,
random_string, SecretVaultRef, StoreAccountRef, OpaqueSecret, random_string, SecretVaultRef, StoreAccountRef, OpaqueSecret,
@ -794,7 +794,7 @@ mod tests {
use std::time::Instant; use std::time::Instant;
use ethstore::ethkey::{Generator, Random, Address}; use ethstore::ethkey::{Generator, Random, Address};
use ethstore::{StoreAccountRef, Derivation}; use ethstore::{StoreAccountRef, Derivation};
use util::H256; use bigint::hash::H256;
#[test] #[test]
fn unlock_account_temp() { fn unlock_account_temp() {

View File

@ -20,7 +20,7 @@
pub type LogBloom = ::log_entry::LogBloom; pub type LogBloom = ::log_entry::LogBloom;
/// Constant 2048-bit datum for 0. Often used as a default. /// 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))] #[cfg_attr(feature="dev", allow(enum_variant_names))]
/// Semantic boolean for when a seal/signature is included. /// Semantic boolean for when a seal/signature is included.

View File

@ -19,10 +19,14 @@
use std::cmp; use std::cmp;
use std::sync::Arc; use std::sync::Arc;
use std::collections::HashSet; 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 rlp::{UntrustedRlp, RlpStream, Encodable, Decodable, DecoderError};
use util::{Bytes, Address, Hashable, U256, H256, ordered_trie_root, SHA3_NULL_RLP, SHA3_EMPTY_LIST_RLP}; use bigint::prelude::U256;
use util::error::{Mismatch, OutOfBounds}; use bigint::hash::H256;
use util::{Bytes, Address};
use unexpected::{Mismatch, OutOfBounds};
use basic_types::{LogBloom, Seal}; use basic_types::{LogBloom, Seal};
use vm::{EnvInfo, LastHashes}; use vm::{EnvInfo, LastHashes};
@ -398,13 +402,13 @@ impl<'x> OpenBlock<'x> {
if let Err(e) = s.engine.on_close_block(&mut s.block) { if let Err(e) = s.engine.on_close_block(&mut s.block) {
warn!("Encountered error on closing the block: {}", e); warn!("Encountered error on closing the block: {}", e);
} }
if let Err(e) = s.block.state.commit() { if let Err(e) = s.block.state.commit() {
warn!("Encountered error on state commit: {}", e); 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()))); 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(); 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_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_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 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() { if let Err(e) = s.block.state.commit() {
warn!("Encountered error on state commit: {}", e); 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()))); 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(); 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 { if s.block.header.uncles_hash().is_zero() || s.block.header.uncles_hash() == &KECCAK_EMPTY_LIST_RLP {
s.block.header.set_uncles_hash(uncle_bytes.sha3()); 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()))); 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 { impl ClosedBlock {
/// Get the hash of the header without seal arguments. /// 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. /// Turn this into a `LockedBlock`, unable to be reopened again.
pub fn lock(self) -> LockedBlock { pub fn lock(self) -> LockedBlock {
@ -494,7 +498,7 @@ impl ClosedBlock {
impl LockedBlock { impl LockedBlock {
/// Get the hash of the header without seal arguments. /// 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`. /// Provide a valid seal in order to turn this into a `SealedBlock`.
/// ///

View File

@ -14,7 +14,9 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // 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; use header::BlockNumber;
/// Best block info. /// Best block info.

View File

@ -14,7 +14,8 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // 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; use header::BlockNumber;
/// Brief info about inserted block. /// Brief info about inserted block.

View File

@ -22,6 +22,9 @@ use std::mem;
use itertools::Itertools; use itertools::Itertools;
use bloomchain as bc; use bloomchain as bc;
use heapsize::HeapSizeOf; use heapsize::HeapSizeOf;
use bigint::prelude::U256;
use bigint::hash::{H256, H2048};
use parking_lot::{Mutex, RwLock};
use util::*; use util::*;
use rlp::*; use rlp::*;
use header::*; use header::*;
@ -41,6 +44,7 @@ use db::{self, Writable, Readable, CacheUpdatePolicy};
use cache_manager::CacheManager; use cache_manager::CacheManager;
use encoded; use encoded;
use engines::epoch::{Transition as EpochTransition, PendingTransition as PendingEpochTransition}; use engines::epoch::{Transition as EpochTransition, PendingTransition as PendingEpochTransition};
use ansi_term::Colour;
const LOG_BLOOMS_LEVELS: usize = 3; const LOG_BLOOMS_LEVELS: usize = 3;
const LOG_BLOOMS_ELEMENTS_PER_INDEX: usize = 16; const LOG_BLOOMS_ELEMENTS_PER_INDEX: usize = 16;
@ -512,7 +516,7 @@ impl BlockChain {
// we need to insert genesis into the cache // we need to insert genesis into the cache
let block = BlockView::new(genesis); let block = BlockView::new(genesis);
let header = block.header_view(); let header = block.header_view();
let hash = block.sha3(); let hash = block.hash();
let details = BlockDetails { let details = BlockDetails {
number: header.number(), number: header.number(),
@ -622,7 +626,7 @@ impl BlockChain {
return None; return None;
} }
if let Some(extras) = self.db.read(db::COL_EXTRA, &best_block_hash) as Option<BlockDetails> { 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))); batch.delete(db::COL_EXTRA, &(DetailsKey::key(&best_block_hash)));
let hash = extras.parent; let hash = extras.parent;
let range = extras.number as bc::Number .. extras.number as bc::Number; 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 { 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 block = BlockView::new(bytes);
let header = block.header_view(); let header = block.header_view();
let hash = header.sha3(); let hash = header.hash();
if self.is_known(&hash) { if self.is_known(&hash) {
return false; return false;
@ -966,7 +970,7 @@ impl BlockChain {
// create views onto rlp // create views onto rlp
let block = BlockView::new(bytes); let block = BlockView::new(bytes);
let header = block.header_view(); let header = block.header_view();
let hash = header.sha3(); let hash = header.hash();
if self.is_known_child(&header.parent_hash(), &hash) { if self.is_known_child(&header.parent_hash(), &hash) {
return ImportRoute::none(); return ImportRoute::none();
@ -1005,7 +1009,7 @@ impl BlockChain {
/// Get inserted block info which is critical to prepare extras updates. /// Get inserted block info which is critical to prepare extras updates.
fn block_info(&self, header: &HeaderView) -> BlockInfo { fn block_info(&self, header: &HeaderView) -> BlockInfo {
let hash = header.sha3(); let hash = header.hash();
let number = header.number(); let number = header.number();
let parent_hash = header.parent_hash(); let parent_hash = header.parent_hash();
let parent_details = self.block_details(&parent_hash).unwrap_or_else(|| panic!("Invalid parent hash: {:?}", 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))] #![cfg_attr(feature="dev", allow(similar_names))]
use std::sync::Arc; use std::sync::Arc;
use rustc_hex::FromHex; use rustc_hex::FromHex;
use hash::keccak;
use util::kvdb::KeyValueDB; use util::kvdb::KeyValueDB;
use util::hash::*; use bigint::hash::*;
use util::sha3::Hashable;
use receipt::Receipt; use receipt::Receipt;
use blockchain::{BlockProvider, BlockChain, Config, ImportRoute}; use blockchain::{BlockProvider, BlockChain, Config, ImportRoute};
use tests::helpers::*; use tests::helpers::*;
@ -1518,8 +1522,8 @@ mod tests {
let mut finalizer = BlockFinalizer::default(); let mut finalizer = BlockFinalizer::default();
let genesis = canon_chain.generate(&mut finalizer).unwrap(); let genesis = canon_chain.generate(&mut finalizer).unwrap();
let first = canon_chain.generate(&mut finalizer).unwrap(); let first = 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 first_hash = BlockView::new(&first).header_view().sha3(); let first_hash = BlockView::new(&first).header_view().hash();
let db = new_db(); let db = new_db();
let bc = new_chain(&genesis, db.clone()); let bc = new_chain(&genesis, db.clone());
@ -1549,7 +1553,7 @@ mod tests {
let mut canon_chain = ChainGenerator::default(); let mut canon_chain = ChainGenerator::default();
let mut finalizer = BlockFinalizer::default(); let mut finalizer = BlockFinalizer::default();
let genesis = canon_chain.generate(&mut finalizer).unwrap(); 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 db = new_db();
let bc = new_chain(&genesis, db.clone()); let bc = new_chain(&genesis, db.clone());
@ -1558,7 +1562,7 @@ mod tests {
let mut batch = db.transaction(); let mut batch = db.transaction();
for _ in 0..10 { for _ in 0..10 {
let block = canon_chain.generate(&mut finalizer).unwrap(); 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.insert_block(&mut batch, &block, vec![]);
bc.commit(); bc.commit();
} }
@ -1607,14 +1611,14 @@ mod tests {
assert_eq!( assert_eq!(
[&b4b, &b3b, &b2b].iter().map(|b| BlockView::new(b).header()).collect::<Vec<_>>(), [&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. // TODO: insert block that already includes one of them as an uncle to check it's not allowed.
} }
fn secret() -> Secret { fn secret() -> Secret {
"".sha3().into() keccak("").into()
} }
#[test] #[test]
@ -1646,8 +1650,8 @@ mod tests {
let b2 = fork_chain let b2 = fork_chain
.generate(&mut fork_finalizer).unwrap(); .generate(&mut fork_finalizer).unwrap();
let b1a_hash = BlockView::new(&b1a).header_view().sha3(); let b1a_hash = BlockView::new(&b1a).header_view().hash();
let b2_hash = BlockView::new(&b2).header_view().sha3(); let b2_hash = BlockView::new(&b2).header_view().hash();
let t1_hash = t1.hash(); let t1_hash = t1.hash();
@ -1730,9 +1734,9 @@ mod tests {
.with_transaction(t3.clone()) .with_transaction(t3.clone())
.generate(&mut fork_finalizer).unwrap(); .generate(&mut fork_finalizer).unwrap();
let b1a_hash = BlockView::new(&b1a).header_view().sha3(); let b1a_hash = BlockView::new(&b1a).header_view().hash();
let b1b_hash = BlockView::new(&b1b).header_view().sha3(); let b1b_hash = BlockView::new(&b1b).header_view().hash();
let b2_hash = BlockView::new(&b2).header_view().sha3(); let b2_hash = BlockView::new(&b2).header_view().hash();
let t1_hash = t1.hash(); let t1_hash = t1.hash();
let t2_hash = t2.hash(); let t2_hash = t2.hash();
@ -1790,11 +1794,11 @@ mod tests {
let b3b = canon_chain.fork(1).generate(&mut finalizer.fork()).unwrap(); let b3b = canon_chain.fork(1).generate(&mut finalizer.fork()).unwrap();
let b3a = canon_chain.generate(&mut finalizer).unwrap(); let b3a = 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 b1_hash= BlockView::new(&b1).header_view().sha3(); let b1_hash= BlockView::new(&b1).header_view().hash();
let b2_hash= BlockView::new(&b2).header_view().sha3(); let b2_hash= BlockView::new(&b2).header_view().hash();
let b3a_hash= BlockView::new(&b3a).header_view().sha3(); let b3a_hash= BlockView::new(&b3a).header_view().hash();
let b3b_hash= BlockView::new(&b3b).header_view().sha3(); let b3b_hash= BlockView::new(&b3b).header_view().hash();
// b3a is a part of canon chain, whereas b3b is part of sidechain // b3a is a part of canon chain, whereas b3b is part of sidechain
let best_block_hash = b3a_hash.clone(); let best_block_hash = b3a_hash.clone();
@ -1910,8 +1914,8 @@ mod tests {
let mut finalizer = BlockFinalizer::default(); let mut finalizer = BlockFinalizer::default();
let genesis = canon_chain.generate(&mut finalizer).unwrap(); let genesis = canon_chain.generate(&mut finalizer).unwrap();
let first = canon_chain.generate(&mut finalizer).unwrap(); let first = 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 first_hash = BlockView::new(&first).header_view().sha3(); let first_hash = BlockView::new(&first).header_view().hash();
let db = new_db(); let db = new_db();
{ {
@ -2226,9 +2230,9 @@ mod tests {
let genesis = canon_chain.generate(&mut finalizer).unwrap(); let genesis = canon_chain.generate(&mut finalizer).unwrap();
let first = canon_chain.generate(&mut finalizer).unwrap(); let first = canon_chain.generate(&mut finalizer).unwrap();
let second = canon_chain.generate(&mut finalizer).unwrap(); let second = 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 first_hash = BlockView::new(&first).header_view().sha3(); let first_hash = BlockView::new(&first).header_view().hash();
let second_hash = BlockView::new(&second).header_view().sha3(); let second_hash = BlockView::new(&second).header_view().hash();
let db = new_db(); let db = new_db();
let bc = new_chain(&genesis, db.clone()); let bc = new_chain(&genesis, db.clone());
@ -2266,7 +2270,7 @@ mod tests {
// create a longer fork // create a longer fork
for i in 0..5 { for i in 0..5 {
let canon_block = canon_chain.generate(&mut finalizer).unwrap(); 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_block(&mut batch, &canon_block, vec![]);
bc.insert_epoch_transition(&mut batch, i, EpochTransition { bc.insert_epoch_transition(&mut batch, i, EpochTransition {
@ -2279,7 +2283,7 @@ mod tests {
assert_eq!(bc.best_block_number(), 5); 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_block(&mut batch, &uncle, vec![]);
bc.insert_epoch_transition(&mut batch, 999, EpochTransition { bc.insert_epoch_transition(&mut batch, 999, EpochTransition {
block_hash: hash, block_hash: hash,

View File

@ -26,7 +26,8 @@ use header::BlockNumber;
use receipt::Receipt; use receipt::Receipt;
use heapsize::HeapSizeOf; 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; use util::kvdb::PREFIX_LEN as DB_PREFIX_LEN;
/// Represents index of extra data in database /// Represents index of extra data in database

View File

@ -15,7 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
use rlp::*; use rlp::*;
use util::{H256, H2048}; use bigint::hash::{H256, H2048};
use util::bytes::Bytes; use util::bytes::Bytes;
use header::Header; use header::Header;
use transaction::SignedTransaction; use transaction::SignedTransaction;

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
use util::hash::H2048; use bigint::hash::H2048;
pub trait WithBloom { pub trait WithBloom {
fn with_bloom(self, bloom: H2048) -> Self where Self: Sized; fn with_bloom(self, bloom: H2048) -> Self where Self: Sized;

View File

@ -14,9 +14,8 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // 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::bytes::Bytes;
use util::sha3::Hashable;
use views::BlockView; use views::BlockView;
#[derive(Default, Clone)] #[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> { fn next(&mut self) -> Option<Self::Item> {
self.iter.next().map(|item| { self.iter.next().map(|item| {
let rlp = item.complete(self.finalizer.parent_hash.clone()); 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 rlp
}) })
} }

View File

@ -14,7 +14,9 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // 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 header::BlockNumber;
use transaction::SignedTransaction; use transaction::SignedTransaction;
use super::fork::Fork; use super::fork::Fork;
@ -110,8 +112,7 @@ impl Iterator for ChainGenerator {
} }
mod tests { mod tests {
use util::hash::{H256, H2048}; use bigint::hash::{H256, H2048};
use util::sha3::Hashable;
use views::BlockView; use views::BlockView;
use blockchain::generator::{ChainIterator, ChainGenerator, BlockFinalizer}; use blockchain::generator::{ChainIterator, ChainGenerator, BlockFinalizer};
@ -129,7 +130,7 @@ mod tests {
let b1_rlp = canon_chain.generate(&mut finalizer).unwrap(); let b1_rlp = canon_chain.generate(&mut finalizer).unwrap();
let b1 = BlockView::new(&b1_rlp); 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); assert_eq!(b1.header_view().number(), 1);
let mut fork_chain = canon_chain.fork(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_rlp_fork = fork_chain.generate(&mut finalizer.fork()).unwrap();
let b2_fork = BlockView::new(&b2_rlp_fork); 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); assert_eq!(b2_fork.header_view().number(), 2);
let b2_rlp = canon_chain.generate(&mut finalizer).unwrap(); let b2_rlp = canon_chain.generate(&mut finalizer).unwrap();
let b2 = BlockView::new(&b2_rlp); 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_eq!(b2.header_view().number(), 2);
assert!(b2.header_view().difficulty() > b2_fork.header_view().difficulty()); 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!(block0.header_view().parent_hash(), H256::default());
assert_eq!(block1.header_view().number(), 1); 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());
} }

View File

@ -16,7 +16,7 @@
//! Import route. //! Import route.
use util::H256; use bigint::hash::H256;
use blockchain::block_info::{BlockInfo, BlockLocation}; use blockchain::block_info::{BlockInfo, BlockLocation};
/// Import route for newly inserted block. /// Import route for newly inserted block.
@ -67,7 +67,8 @@ impl From<BlockInfo> for ImportRoute {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use util::{U256, H256}; use bigint::prelude::U256;
use bigint::hash::H256;
use blockchain::block_info::{BlockInfo, BlockLocation, BranchBecomingCanonChainData}; use blockchain::block_info::{BlockInfo, BlockLocation, BranchBecomingCanonChainData};
use blockchain::ImportRoute; use blockchain::ImportRoute;

View File

@ -1,5 +1,5 @@
use std::collections::HashMap; use std::collections::HashMap;
use util::H256; use bigint::hash::H256;
use header::BlockNumber; use header::BlockNumber;
use blockchain::block_info::BlockInfo; use blockchain::block_info::BlockInfo;
use blooms::BloomGroup; use blooms::BloomGroup;

View File

@ -23,7 +23,10 @@ use crypto::ripemd160::Ripemd160 as Ripemd160Digest;
use crypto::digest::Digest; use crypto::digest::Digest;
use num::{BigUint, Zero, One}; 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 ethkey::{Signature, recover as ec_recover};
use ethjson; use ethjson;
@ -228,7 +231,7 @@ impl Impl for EcRecover {
let s = Signature::from_rsv(&r, &s, bit); let s = Signature::from_rsv(&r, &s, bit);
if s.is_valid() { if s.is_valid() {
if let Ok(p) = ec_recover(&s, &hash) { if let Ok(p) = ec_recover(&s, &hash) {
let r = p.sha3(); let r = keccak(p);
output.write(0, &[0; 12]); output.write(0, &[0; 12]);
output.write(12, &r[12..r.len()]); 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 { impl Impl for ModexpImpl {
fn execute(&self, input: &[u8], output: &mut BytesRef) -> Result<(), Error> { fn execute(&self, input: &[u8], output: &mut BytesRef) -> Result<(), Error> {
let mut reader = input.chain(io::repeat(0)); let mut reader = input.chain(io::repeat(0));
@ -294,34 +325,6 @@ impl Impl for ModexpImpl {
let exp = read_num(exp_len); let exp = read_num(exp_len);
let modulus = read_num(mod_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. // write output to given memory, left padded and same length as the modulus.
let bytes = modexp(base, exp, modulus).to_bytes_be(); let bytes = modexp(base, exp, modulus).to_bytes_be();
@ -503,10 +506,45 @@ impl Impl for Bn128PairingImpl {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::{Builtin, Linear, ethereum_builtin, Pricer, Modexp}; use super::{Builtin, Linear, ethereum_builtin, Pricer, Modexp, modexp as me};
use ethjson; use ethjson;
use util::{U256, BytesRef}; use bigint::prelude::U256;
use util::BytesRef;
use rustc_hex::FromHex; 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] #[test]
fn identity() { fn identity() {
@ -572,14 +610,6 @@ mod tests {
#[test] #[test]
fn ecrecover() { 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 f = ethereum_builtin("ecrecover");
let i = FromHex::from_hex("47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad000000000000000000000000000000000000000000000000000000000000001b650acf9d3f5f0a2c799776a1254355d5f4061762a237396a99a0e0e3fc2bcd6729514a0dacb2e623ac4abd157cb18163ff942280db4d5caad66ddf941ba12e03").unwrap(); let i = FromHex::from_hex("47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad000000000000000000000000000000000000000000000000000000000000001b650acf9d3f5f0a2c799776a1254355d5f4061762a237396a99a0e0e3fc2bcd6729514a0dacb2e623ac4abd157cb18163ff942280db4d5caad66ddf941ba12e03").unwrap();

View File

@ -23,7 +23,7 @@ use engines::{Engine, EpochVerifier};
use header::Header; use header::Header;
use rand::Rng; use rand::Rng;
use util::RwLock; use parking_lot::RwLock;
// do "heavy" verification on ~1/50 blocks, randomly sampled. // do "heavy" verification on ~1/50 blocks, randomly sampled.
const HEAVY_VERIFY_RATE: f32 = 0.02; const HEAVY_VERIFY_RATE: f32 = 0.02;

View File

@ -15,7 +15,8 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
use ipc::IpcConfig; 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 /// Represents what has to be handled by actor listening to chain events
#[ipc] #[ipc]

View File

@ -23,13 +23,18 @@ use time::precise_time_ns;
use itertools::Itertools; use itertools::Itertools;
// util // 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::{journaldb, DBValue, TrieFactory, Trie};
use util::{U256, H256, Address, H2048}; use util::Address;
use util::trie::TrieSpec; use util::trie::TrieSpec;
use util::kvdb::*; use util::kvdb::*;
// other // other
use bigint::prelude::U256;
use bigint::hash::{H256, H2048};
use basic_types::Seal; use basic_types::Seal;
use block::*; use block::*;
use blockchain::{BlockChain, BlockProvider, TreeRoute, ImportRoute}; use blockchain::{BlockChain, BlockProvider, TreeRoute, ImportRoute};
@ -54,6 +59,7 @@ use io::*;
use log_entry::LocalizedLogEntry; use log_entry::LocalizedLogEntry;
use miner::{Miner, MinerService, TransactionImportResult}; use miner::{Miner, MinerService, TransactionImportResult};
use native_contracts::Registry; use native_contracts::Registry;
use parking_lot::{Mutex, RwLock, MutexGuard};
use rand::OsRng; use rand::OsRng;
use receipt::{Receipt, LocalizedReceipt}; use receipt::{Receipt, LocalizedReceipt};
use rlp::UntrustedRlp; use rlp::UntrustedRlp;
@ -247,7 +253,7 @@ impl Client {
last_hashes: RwLock::new(VecDeque::new()), last_hashes: RwLock::new(VecDeque::new()),
factories: factories, factories: factories,
history: history, 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), ancient_verifier: Mutex::new(None),
on_user_defaults_change: Mutex::new(None), on_user_defaults_change: Mutex::new(None),
registrar: Mutex::new(None), registrar: Mutex::new(None),
@ -652,7 +658,7 @@ impl Client {
.map(Into::into) .map(Into::into)
.collect(); .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)); //let traces = From::from(block.traces().clone().unwrap_or_else(Vec::new));
@ -1126,7 +1132,9 @@ impl Client {
T: trace::Tracer, T: trace::Tracer,
V: trace::VMTracer, 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 original_state = if state_diff { Some(state.clone()) } else { None };
let mut ret = Executive::new(state, env_info, engine).transact_virtual(transaction, options)?; 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())) 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> { fn balance(&self, address: &Address, id: BlockId) -> Option<U256> {
self.state_at(id).and_then(|s| s.balance(address).ok()) self.state_at(id).and_then(|s| s.balance(address).ok())
} }
@ -1503,7 +1515,7 @@ impl BlockChainClient for Client {
}; };
let (_, db) = state.drop(); 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) { let trie = match self.factories.trie.readonly(account_db.as_hashdb(), &root) {
Ok(trie) => trie, Ok(trie) => trie,
_ => { _ => {
@ -1591,7 +1603,7 @@ impl BlockChainClient for Client {
use verification::queue::kind::BlockLike; use verification::queue::kind::BlockLike;
use verification::queue::kind::blocks::Unverified; 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); let unverified = Unverified::new(bytes);
{ {
@ -1792,7 +1804,7 @@ impl BlockChainClient for Client {
let dispatch = move |reg_addr, data| { let dispatch = move |reg_addr, data| {
future::done(self.call_contract(BlockId::Latest, 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) }) .and_then(|a| if a.is_zero() { None } else { Some(a) })
} }
@ -2067,16 +2079,16 @@ mod tests {
#[test] #[test]
fn should_return_correct_log_index() { fn should_return_correct_log_index() {
use hash::keccak;
use super::transaction_receipt; use super::transaction_receipt;
use ethkey::KeyPair; use ethkey::KeyPair;
use log_entry::{LogEntry, LocalizedLogEntry}; use log_entry::{LogEntry, LocalizedLogEntry};
use receipt::{Receipt, LocalizedReceipt}; use receipt::{Receipt, LocalizedReceipt};
use transaction::{Transaction, LocalizedTransaction, Action}; use transaction::{Transaction, LocalizedTransaction, Action};
use util::Hashable;
use tests::helpers::TestEngine; use tests::helpers::TestEngine;
// given // given
let key = KeyPair::from_secret_slice(&"test".sha3()).unwrap(); let key = KeyPair::from_secret_slice(&keccak("test")).unwrap();
let secret = key.secret(); let secret = key.secret();
let engine = TestEngine::new(0); let engine = TestEngine::new(0);

View File

@ -18,7 +18,9 @@
use std::fmt; use std::fmt;
use std::sync::Arc; 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 util::kvdb::{self, KeyValueDB};
use {state, state_db, client, executive, trace, transaction, db, spec, pod_state}; use {state, state_db, client, executive, trace, transaction, db, spec, pod_state};
use factory::Factories; use factory::Factories;
@ -166,7 +168,7 @@ impl<'a> EvmTestClient<'a> {
author: *genesis.author(), author: *genesis.author(),
timestamp: genesis.timestamp(), timestamp: genesis.timestamp(),
difficulty: *genesis.difficulty(), 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_used: 0.into(),
gas_limit: *genesis.gas_limit(), gas_limit: *genesis.gas_limit(),
}; };

View File

@ -22,6 +22,10 @@ use std::collections::{HashMap, BTreeMap};
use std::mem; use std::mem;
use itertools::Itertools; use itertools::Itertools;
use rustc_hex::FromHex; use rustc_hex::FromHex;
use hash::keccak;
use bigint::prelude::U256;
use bigint::hash::{H256, H2048};
use parking_lot::RwLock;
use util::*; use util::*;
use rlp::*; use rlp::*;
use ethkey::{Generator, Random}; use ethkey::{Generator, Random};
@ -241,7 +245,7 @@ impl TestBlockChainClient {
uncle_header.set_parent_hash(self.last_hash.read().clone()); uncle_header.set_parent_hash(self.last_hash.read().clone());
uncle_header.set_number(n as BlockNumber); uncle_header.set_number(n as BlockNumber);
uncles.append(&uncle_header); uncles.append(&uncle_header);
header.set_uncles_hash(uncles.as_raw().sha3()); header.set_uncles_hash(keccak(uncles.as_raw()));
uncles uncles
}, },
_ => RlpStream::new_list(0) _ => 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> { fn balance(&self, address: &Address, id: BlockId) -> Option<U256> {
match id { match id {
BlockId::Latest | BlockId::Pending => Some(self.balances.read().get(address).cloned().unwrap_or_else(U256::zero)), BlockId::Latest | BlockId::Pending => Some(self.balances.read().get(address).cloned().unwrap_or_else(U256::zero)),

View File

@ -1,7 +1,7 @@
//! Bridge between Tracedb and Blockchain. //! Bridge between Tracedb and Blockchain.
use util::{H256}; use bigint::hash::H256;
use header::BlockNumber; use header::BlockNumber;
use trace::DatabaseExtras as TraceDatabaseExtras; use trace::DatabaseExtras as TraceDatabaseExtras;
use blockchain::{BlockChain, BlockProvider}; use blockchain::{BlockChain, BlockProvider};

View File

@ -34,7 +34,9 @@ use trace::LocalizedTrace;
use transaction::{LocalizedTransaction, PendingTransaction, SignedTransaction}; use transaction::{LocalizedTransaction, PendingTransaction, SignedTransaction};
use verification::queue::QueueInfo as BlockQueueInfo; 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 util::hashdb::DBValue;
use types::ids::*; use types::ids::*;
@ -96,6 +98,9 @@ pub trait BlockChainClient : Sync + Send {
.expect("code will return Some if given BlockId::Latest; qed") .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. /// Get address balance at the given block's state.
/// ///
/// May not return None if given BlockId::Latest. /// May not return None if given BlockId::Latest.

View File

@ -19,7 +19,8 @@
use std::ops::Deref; use std::ops::Deref;
use std::hash::Hash; use std::hash::Hash;
use std::collections::HashMap; use std::collections::HashMap;
use util::{DBTransaction, KeyValueDB, RwLock}; use parking_lot::RwLock;
use util::{DBTransaction, KeyValueDB};
use rlp; use rlp;

View File

@ -28,8 +28,11 @@ use header::{BlockNumber, Header as FullHeader};
use transaction::UnverifiedTransaction; use transaction::UnverifiedTransaction;
use views; use views;
use hash::keccak;
use heapsize::HeapSizeOf; 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; use rlp::Rlp;
/// Owning header view. /// Owning header view.
@ -65,7 +68,7 @@ impl Header {
// forwarders to borrowed view. // forwarders to borrowed view.
impl Header { impl Header {
/// Returns the header hash. /// Returns the header hash.
pub fn hash(&self) -> H256 { self.sha3() } pub fn hash(&self) -> H256 { keccak(&self.0) }
/// Returns the parent hash. /// Returns the parent hash.
pub fn parent_hash(&self) -> H256 { self.view().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() } 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. /// Owning block body view.
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "ipc", binary)] #[cfg_attr(feature = "ipc", binary)]
@ -219,7 +216,7 @@ impl Block {
// forwarders to borrowed header view. // forwarders to borrowed header view.
impl Block { impl Block {
/// Returns the header hash. /// 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. /// Returns the parent hash.
pub fn parent_hash(&self) -> H256 { self.header_view().parent_hash() } pub fn parent_hash(&self) -> H256 { self.header_view().parent_hash() }

View File

@ -19,7 +19,8 @@
use std::collections::{VecDeque}; use std::collections::{VecDeque};
use std::collections::hash_map::{HashMap, Entry}; use std::collections::hash_map::{HashMap, Entry};
use util::{Address, H256}; use bigint::hash::H256;
use util::Address;
use engines::validator_set::SimpleList; use engines::validator_set::SimpleList;
@ -149,7 +150,8 @@ impl<'a> Iterator for Iter<'a> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use util::{Address, H256}; use bigint::hash::H256;
use util::Address;
use super::RollingFinality; use super::RollingFinality;
#[test] #[test]

View File

@ -42,6 +42,11 @@ use ethkey::{verify_address, Signature};
use io::{IoContext, IoHandler, TimerToken, IoService}; use io::{IoContext, IoHandler, TimerToken, IoService};
use itertools::{self, Itertools}; use itertools::{self, Itertools};
use rlp::{UntrustedRlp, encode}; 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::*; use util::*;
mod finality; mod finality;
@ -830,7 +835,9 @@ impl Engine for AuthorityRound {
mod tests { mod tests {
use std::sync::Arc; use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrdering}; 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 header::Header;
use error::{Error, BlockError}; use error::{Error, BlockError};
use rlp::encode; use rlp::encode;
@ -884,8 +891,8 @@ mod tests {
#[test] #[test]
fn generates_seal_and_does_not_double_propose() { fn generates_seal_and_does_not_double_propose() {
let tap = Arc::new(AccountProvider::transient_provider()); let tap = Arc::new(AccountProvider::transient_provider());
let addr1 = tap.insert_account("1".sha3().into(), "1").unwrap(); let addr1 = tap.insert_account(keccak("1").into(), "1").unwrap();
let addr2 = tap.insert_account("2".sha3().into(), "2").unwrap(); let addr2 = tap.insert_account(keccak("2").into(), "2").unwrap();
let spec = Spec::new_test_round(); let spec = Spec::new_test_round();
let engine = &*spec.engine; let engine = &*spec.engine;
@ -916,7 +923,7 @@ mod tests {
#[test] #[test]
fn proposer_switching() { fn proposer_switching() {
let tap = AccountProvider::transient_provider(); 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(); let mut parent_header: Header = Header::default();
parent_header.set_seal(vec![encode(&0usize).into_vec()]); parent_header.set_seal(vec![encode(&0usize).into_vec()]);
parent_header.set_gas_limit("222222".parse::<U256>().unwrap()); parent_header.set_gas_limit("222222".parse::<U256>().unwrap());
@ -941,7 +948,7 @@ mod tests {
#[test] #[test]
fn rejects_future_block() { fn rejects_future_block() {
let tap = AccountProvider::transient_provider(); 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(); let mut parent_header: Header = Header::default();
parent_header.set_seal(vec![encode(&0usize).into_vec()]); parent_header.set_seal(vec![encode(&0usize).into_vec()]);
@ -967,7 +974,7 @@ mod tests {
#[test] #[test]
fn rejects_step_backwards() { fn rejects_step_backwards() {
let tap = AccountProvider::transient_provider(); 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(); let mut parent_header: Header = Header::default();
parent_header.set_seal(vec![encode(&4usize).into_vec()]); parent_header.set_seal(vec![encode(&4usize).into_vec()]);

View File

@ -19,7 +19,11 @@
use std::sync::{Weak, Arc}; use std::sync::{Weak, Arc};
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::cmp; use std::cmp;
use bigint::prelude::U256;
use bigint::hash::{H256, H520};
use parking_lot::RwLock;
use util::*; use util::*;
use unexpected::{Mismatch, OutOfBounds};
use ethkey::{recover, public_to_address, Signature}; use ethkey::{recover, public_to_address, Signature};
use account_provider::AccountProvider; use account_provider::AccountProvider;
use block::*; use block::*;
@ -31,6 +35,7 @@ use evm::Schedule;
use ethjson; use ethjson;
use header::{Header, BlockNumber}; use header::{Header, BlockNumber};
use client::Client; use client::Client;
use semantic_version::SemanticVersion;
use super::signer::EngineSigner; use super::signer::EngineSigner;
use super::validator_set::{ValidatorSet, SimpleList, new_validator_set}; use super::validator_set::{ValidatorSet, SimpleList, new_validator_set};
@ -252,7 +257,8 @@ impl Engine for BasicAuthority {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::sync::Arc; use std::sync::Arc;
use util::*; use hash::keccak;
use bigint::hash::H520;
use block::*; use block::*;
use error::{BlockError, Error}; use error::{BlockError, Error};
use tests::helpers::*; use tests::helpers::*;
@ -308,7 +314,7 @@ mod tests {
#[test] #[test]
fn can_generate_seal() { fn can_generate_seal() {
let tap = AccountProvider::transient_provider(); 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 spec = new_test_authority();
let engine = &*spec.engine; let engine = &*spec.engine;
@ -326,7 +332,7 @@ mod tests {
#[test] #[test]
fn seals_internally() { fn seals_internally() {
let tap = AccountProvider::transient_provider(); 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; let engine = new_test_authority().engine;
assert!(!engine.seals_internally().unwrap()); assert!(!engine.seals_internally().unwrap());

View File

@ -16,7 +16,7 @@
//! Epoch verifiers and transitions. //! Epoch verifiers and transitions.
use util::H256; use bigint::hash::H256;
use error::Error; use error::Error;
use header::Header; use header::Header;

View File

@ -64,6 +64,7 @@ impl Engine for InstantSeal {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::sync::Arc; use std::sync::Arc;
use bigint::hash::H520;
use util::*; use util::*;
use tests::helpers::*; use tests::helpers::*;
use spec::Spec; use spec::Spec;

View File

@ -54,7 +54,11 @@ use spec::CommonParams;
use transaction::{UnverifiedTransaction, SignedTransaction}; use transaction::{UnverifiedTransaction, SignedTransaction};
use ethkey::Signature; use ethkey::Signature;
use bigint::prelude::U256;
use bigint::hash::H256;
use semantic_version::SemanticVersion;
use util::*; use util::*;
use unexpected::{Mismatch, OutOfBounds};
/// Default EIP-210 contrat code. /// Default EIP-210 contrat code.
/// As defined in https://github.com/ethereum/EIPs/pull/210/commits/9df24a3714af42e3bf350265bdc75b486c909d7f#diff-e02a92c2fb96c1a1bfb05e4c6e2ef5daR49 /// 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::Substate;
use state::CleanupMode; use state::CleanupMode;
use bigint::prelude::U256;
use bigint::hash::H256;
use util::*; use util::*;
use super::Engine; use super::Engine;

View File

@ -18,7 +18,7 @@ use std::collections::BTreeMap;
use util::Address; use util::Address;
use builtin::Builtin; use builtin::Builtin;
use block::{ExecutedBlock, IsBlock}; use block::{ExecutedBlock, IsBlock};
use util::U256; use bigint::prelude::U256;
use engines::Engine; use engines::Engine;
use spec::CommonParams; use spec::CommonParams;
use evm::Schedule; use evm::Schedule;

View File

@ -17,7 +17,8 @@
//! A signer used by Engines which need to sign messages. //! A signer used by Engines which need to sign messages.
use std::sync::Arc; use std::sync::Arc;
use util::{H256, Address}; use bigint::hash::H256;
use util::Address;
use ethkey::Signature; use ethkey::Signature;
use account_provider::{self, AccountProvider}; use account_provider::{self, AccountProvider};

View File

@ -17,6 +17,8 @@
//! Tendermint message handling. //! Tendermint message handling.
use std::cmp; use std::cmp;
use hash::keccak;
use bigint::hash::{H256, H520};
use util::*; use util::*;
use super::{Height, View, BlockHash, Step}; use super::{Height, View, BlockHash, Step};
use error::Error; use error::Error;
@ -99,7 +101,7 @@ impl ConsensusMessage {
pub fn verify(&self) -> Result<Address, Error> { pub fn verify(&self) -> Result<Address, Error> {
let full_rlp = ::rlp::encode(self); let full_rlp = ::rlp::encode(self);
let block_info = Rlp::new(&full_rlp).at(1); 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)) 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 { 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)] #[cfg(test)]
mod tests { mod tests {
use std::sync::Arc; use std::sync::Arc;
use util::*; use hash::keccak;
use rlp::*; use rlp::*;
use account_provider::AccountProvider; use account_provider::AccountProvider;
use header::Header; use header::Header;
@ -228,7 +230,7 @@ mod tests {
view: 123, view: 123,
step: Step::Precommit, step: Step::Precommit,
}, },
block_hash: Some("1".sha3()) block_hash: Some(keccak("1")),
}; };
let raw_rlp = ::rlp::encode(&message).into_vec(); let raw_rlp = ::rlp::encode(&message).into_vec();
let rlp = Rlp::new(&raw_rlp); let rlp = Rlp::new(&raw_rlp);
@ -251,12 +253,12 @@ mod tests {
#[test] #[test]
fn generate_and_verify() { fn generate_and_verify() {
let tap = Arc::new(AccountProvider::transient_provider()); 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(); tap.unlock_account_permanently(addr, "0".into()).unwrap();
let mi = message_info_rlp(&VoteStep::new(123, 2, Step::Precommit), Some(H256::default())); 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 rlp = UntrustedRlp::new(&raw_rlp);
let message: ConsensusMessage = rlp.as_val().unwrap(); let message: ConsensusMessage = rlp.as_val().unwrap();

View File

@ -28,8 +28,13 @@ mod params;
use std::sync::{Weak, Arc}; use std::sync::{Weak, Arc};
use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrdering}; use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrdering};
use std::collections::{HashSet, BTreeMap, HashMap}; use std::collections::{HashSet, BTreeMap, HashMap};
use hash::keccak;
use std::cmp; use std::cmp;
use bigint::prelude::{U128, U256};
use bigint::hash::{H256, H520};
use parking_lot::RwLock;
use util::*; use util::*;
use unexpected::{OutOfBounds, Mismatch};
use client::{Client, EngineClient}; use client::{Client, EngineClient};
use error::{Error, BlockError}; use error::{Error, BlockError};
use header::{Header, BlockNumber}; use header::{Header, BlockNumber};
@ -47,6 +52,7 @@ use super::transition::TransitionHandler;
use super::vote_collector::VoteCollector; use super::vote_collector::VoteCollector;
use self::message::*; use self::message::*;
use self::params::TendermintParams; use self::params::TendermintParams;
use semantic_version::SemanticVersion;
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)] #[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
pub enum Step { pub enum Step {
@ -213,7 +219,7 @@ impl Tendermint {
let r = self.view.load(AtomicOrdering::SeqCst); let r = self.view.load(AtomicOrdering::SeqCst);
let s = *self.step.read(); let s = *self.step.read();
let vote_info = message_info_rlp(&VoteStep::new(h, r, s), block_hash); 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)) => { (Some(validator), Ok(signature)) => {
let message_rlp = message_full_rlp(&signature, &vote_info); let message_rlp = message_full_rlp(&signature, &vote_info);
let message = ConsensusMessage::new(signature, h, r, s, block_hash); 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 view = self.view.load(AtomicOrdering::SeqCst);
let bh = Some(header.bare_hash()); let bh = Some(header.bare_hash());
let vote_info = message_info_rlp(&VoteStep::new(height, view, Step::Propose), bh.clone()); 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. // Insert Propose vote.
debug!(target: "engine", "Submitting proposal {} at height {} view {}.", header.bare_hash(), height, view); 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); 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 rlp = UntrustedRlp::new(rlp);
let message: ConsensusMessage = rlp.as_val()?; let message: ConsensusMessage = rlp.as_val()?;
if !self.votes.is_old_or_known(&message) { 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) { if !self.is_authority(&sender) {
return Err(EngineError::NotAuthorized(sender).into()); 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> { 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 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(); engine.handle_message(&m).unwrap();
m m
} }
@ -806,7 +812,7 @@ mod tests {
fn proposal_seal(tap: &Arc<AccountProvider>, header: &Header, view: View) -> Vec<Bytes> { fn proposal_seal(tap: &Arc<AccountProvider>, header: &Header, view: View) -> Vec<Bytes> {
let author = header.author(); let author = header.author();
let vote_info = message_info_rlp(&VoteStep::new(header.number() as Height, view, Step::Propose), Some(header.bare_hash())); 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![ vec![
::rlp::encode(&view).into_vec(), ::rlp::encode(&view).into_vec(),
::rlp::encode(&H520::from(signature)).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 { 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(); tap.unlock_account_permanently(addr, acc.into()).unwrap();
addr addr
} }
@ -922,7 +928,7 @@ mod tests {
let mut seal = proposal_seal(&tap, &header, 0); 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 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[1] = ::rlp::NULL_RLP.to_vec();
seal[2] = ::rlp::encode_list(&vec![H520::from(signature1.clone())]).into_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 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(); seal[2] = ::rlp::encode_list(&vec![H520::from(signature1.clone()), H520::from(signature0.clone())]).into_vec();
header.set_seal(seal.clone()); header.set_seal(seal.clone());
@ -943,7 +949,7 @@ mod tests {
assert!(engine.verify_block_family(&header, &parent_header, None).is_ok()); assert!(engine.verify_block_family(&header, &parent_header, None).is_ok());
let bad_voter = insert_and_unlock(&tap, "101"); 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(); seal[2] = ::rlp::encode_list(&vec![H520::from(signature1), H520::from(bad_signature)]).into_vec();
header.set_seal(seal); header.set_seal(seal);
@ -1076,10 +1082,10 @@ mod tests {
let mut seal = proposal_seal(&tap, &header, 0); 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 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 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[1] = ::rlp::NULL_RLP.to_vec();
seal[2] = ::rlp::encode_list(&vec![H520::from(signature1.clone())]).into_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()); assert!(epoch_verifier.verify_light(&header).is_ok());
let bad_voter = insert_and_unlock(&tap, "101"); 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(); seal[2] = ::rlp::encode_list(&vec![H520::from(signature1), H520::from(bad_signature)]).into_vec();
header.set_seal(seal); header.set_seal(seal);

View File

@ -18,6 +18,8 @@
/// It can also report validators for misbehaviour with two levels: `reportMalicious` and `reportBenign`. /// It can also report validators for misbehaviour with two levels: `reportMalicious` and `reportBenign`.
use std::sync::Weak; use std::sync::Weak;
use bigint::hash::H256;
use parking_lot::RwLock;
use util::*; use util::*;
use futures::Future; use futures::Future;
@ -128,6 +130,8 @@ impl ValidatorSet for ValidatorContract {
mod tests { mod tests {
use std::sync::Arc; use std::sync::Arc;
use rustc_hex::FromHex; use rustc_hex::FromHex;
use hash::keccak;
use bigint::hash::H520;
use util::*; use util::*;
use rlp::encode; use rlp::encode;
use spec::Spec; use spec::Spec;
@ -153,7 +157,7 @@ mod tests {
#[test] #[test]
fn reports_validators() { fn reports_validators() {
let tap = Arc::new(AccountProvider::transient_provider()); 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())); let client = generate_dummy_client_with_spec_and_accounts(Spec::new_validator_contract, Some(tap.clone()));
client.engine().register_client(Arc::downgrade(&client)); client.engine().register_client(Arc::downgrade(&client));
let validator_contract = "0000000000000000000000000000000000000005".parse::<Address>().unwrap(); let validator_contract = "0000000000000000000000000000000000000005".parse::<Address>().unwrap();

View File

@ -25,7 +25,8 @@ mod multi;
use std::sync::Weak; use std::sync::Weak;
use ids::BlockId; use ids::BlockId;
use util::{Bytes, Address, H256}; use bigint::hash::H256;
use util::{Bytes, Address};
use ethjson::spec::ValidatorSet as ValidatorSpec; use ethjson::spec::ValidatorSet as ValidatorSpec;
use client::Client; use client::Client;
use header::{Header, BlockNumber}; use header::{Header, BlockNumber};

View File

@ -19,7 +19,9 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::sync::Weak; use std::sync::Weak;
use engines::{Call, Engine}; 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 ids::BlockId;
use header::{BlockNumber, Header}; use header::{BlockNumber, Header};
use client::{Client, BlockChainClient}; use client::{Client, BlockChainClient};
@ -144,6 +146,7 @@ impl ValidatorSet for Multi {
mod tests { mod tests {
use std::sync::Arc; use std::sync::Arc;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use hash::keccak;
use account_provider::AccountProvider; use account_provider::AccountProvider;
use client::{BlockChainClient, EngineClient}; use client::{BlockChainClient, EngineClient};
use engines::EpochChange; use engines::EpochChange;
@ -163,9 +166,9 @@ mod tests {
let _ = ::env_logger::init(); let _ = ::env_logger::init();
let tap = Arc::new(AccountProvider::transient_provider()); 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 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)); let client = generate_dummy_client_with_spec_and_accounts(Spec::new_validator_multi, Some(tap));
client.engine().register_client(Arc::downgrade(&client)); client.engine().register_client(Arc::downgrade(&client));

View File

@ -19,9 +19,14 @@
use std::sync::{Weak, Arc}; use std::sync::{Weak, Arc};
use futures::Future; use futures::Future;
use native_contracts::ValidatorSet as Provider; 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::*;
use util::cache::MemoryLruCache; use util::cache::MemoryLruCache;
use unexpected::Mismatch;
use rlp::{UntrustedRlp, RlpStream}; use rlp::{UntrustedRlp, RlpStream};
use basic_types::LogBloom; use basic_types::LogBloom;
@ -41,7 +46,7 @@ const MEMOIZE_CAPACITY: usize = 500;
const EVENT_NAME: &'static [u8] = &*b"InitiateChange(bytes32,address[])"; const EVENT_NAME: &'static [u8] = &*b"InitiateChange(bytes32,address[])";
lazy_static! { 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: /// The validator contract should have the following interface:
@ -351,7 +356,7 @@ impl ValidatorSet for ValidatorSafeContract {
// ensure receipts match header. // ensure receipts match header.
// TODO: optimize? these were just decoded. // 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()) receipts.iter().map(::rlp::encode).map(|x| x.to_vec())
); );
if found_root != *old_header.receipts_root() { if found_root != *old_header.receipts_root() {
@ -424,6 +429,7 @@ impl ValidatorSet for ValidatorSafeContract {
mod tests { mod tests {
use std::sync::Arc; use std::sync::Arc;
use rustc_hex::FromHex; use rustc_hex::FromHex;
use hash::keccak;
use util::*; use util::*;
use types::ids::BlockId; use types::ids::BlockId;
use spec::Spec; use spec::Spec;
@ -449,9 +455,9 @@ mod tests {
#[test] #[test]
fn knows_validators() { fn knows_validators() {
let tap = Arc::new(AccountProvider::transient_provider()); 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 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 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)); let client = generate_dummy_client_with_spec_and_accounts(Spec::new_validator_safe_contract, Some(tap));
client.engine().register_client(Arc::downgrade(&client)); client.engine().register_client(Arc::downgrade(&client));

View File

@ -17,7 +17,8 @@
/// Preconfigured validator list. /// Preconfigured validator list.
use heapsize::HeapSizeOf; use heapsize::HeapSizeOf;
use util::{H256, Address}; use bigint::hash::H256;
use util::Address;
use engines::{Call, Engine}; use engines::{Call, Engine};
use header::{BlockNumber, Header}; use header::{BlockNumber, Header};

View File

@ -20,7 +20,8 @@ use std::str::FromStr;
use std::sync::Arc; use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrdering}; use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrdering};
use heapsize::HeapSizeOf; use heapsize::HeapSizeOf;
use util::{Bytes, H256, Address}; use bigint::hash::H256;
use util::{Bytes, Address};
use engines::{Call, Engine}; use engines::{Call, Engine};
use header::{Header, BlockNumber}; use header::{Header, BlockNumber};

View File

@ -19,6 +19,8 @@
use std::fmt::Debug; use std::fmt::Debug;
use std::collections::{BTreeMap, HashSet, HashMap}; use std::collections::{BTreeMap, HashSet, HashMap};
use std::hash::Hash; use std::hash::Hash;
use bigint::hash::{H256, H520};
use parking_lot:: RwLock;
use util::*; use util::*;
use rlp::{Encodable, RlpStream}; use rlp::{Encodable, RlpStream};
@ -206,6 +208,8 @@ impl <M: Message + Default + Encodable + Debug> VoteCollector<M> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use hash::keccak;
use bigint::hash::H160;
use util::*; use util::*;
use rlp::*; use rlp::*;
use super::*; use super::*;
@ -251,7 +255,7 @@ mod tests {
#[test] #[test]
fn seal_retrieval() { fn seal_retrieval() {
let collector = VoteCollector::default(); let collector = VoteCollector::default();
let bh = Some("1".sha3()); let bh = Some(keccak("1"));
let mut signatures = Vec::new(); let mut signatures = Vec::new();
for _ in 0..5 { for _ in 0..5 {
signatures.push(H520::random()); signatures.push(H520::random());
@ -263,9 +267,9 @@ mod tests {
// Good proposal // Good proposal
random_vote(&collector, signatures[0].clone(), propose_round.clone(), bh.clone()); random_vote(&collector, signatures[0].clone(), propose_round.clone(), bh.clone());
// Wrong block proposal. // 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. // 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. // Wrong round.
random_vote(&collector, signatures[0].clone(), 6, bh.clone()); random_vote(&collector, signatures[0].clone(), 6, bh.clone());
// Wrong round. // Wrong round.
@ -291,22 +295,22 @@ mod tests {
let round1 = 1; let round1 = 1;
let round3 = 3; let round3 = 3;
// good 1 // good 1
random_vote(&collector, H520::random(), round1, Some("0".sha3())); random_vote(&collector, H520::random(), round1, Some(keccak("0")));
random_vote(&collector, H520::random(), 0, Some("0".sha3())); random_vote(&collector, H520::random(), 0, Some(keccak("0")));
// good 3 // good 3
random_vote(&collector, H520::random(), round3, Some("0".sha3())); random_vote(&collector, H520::random(), round3, Some(keccak("0")));
random_vote(&collector, H520::random(), 2, Some("0".sha3())); random_vote(&collector, H520::random(), 2, Some(keccak("0")));
// good prevote // good prevote
random_vote(&collector, H520::random(), round1, Some("1".sha3())); random_vote(&collector, H520::random(), round1, Some(keccak("1")));
// good prevote // good prevote
let same_sig = H520::random(); let same_sig = H520::random();
random_vote(&collector, same_sig.clone(), round1, Some("1".sha3())); random_vote(&collector, same_sig.clone(), round1, Some(keccak("1")));
random_vote(&collector, same_sig, round1, Some("1".sha3())); random_vote(&collector, same_sig, round1, Some(keccak("1")));
// good precommit // good precommit
random_vote(&collector, H520::random(), round3, Some("1".sha3())); random_vote(&collector, H520::random(), round3, Some(keccak("1")));
// good prevote // good prevote
random_vote(&collector, H520::random(), round1, Some("0".sha3())); random_vote(&collector, H520::random(), round1, Some(keccak("0")));
random_vote(&collector, H520::random(), 4, Some("2".sha3())); random_vote(&collector, H520::random(), 4, Some(keccak("2")));
assert_eq!(collector.count_round_votes(&round1), 4); assert_eq!(collector.count_round_votes(&round1), 4);
assert_eq!(collector.count_round_votes(&round3), 2); assert_eq!(collector.count_round_votes(&round3), 2);
@ -314,7 +318,7 @@ mod tests {
let message = TestMessage { let message = TestMessage {
signature: H520::default(), signature: H520::default(),
step: round1, step: round1,
block_hash: Some("1".sha3()) block_hash: Some(keccak("1"))
}; };
assert_eq!(collector.count_aligned_votes(&message), 2); assert_eq!(collector.count_aligned_votes(&message), 2);
} }
@ -325,11 +329,11 @@ mod tests {
let vote = |round, hash| { let vote = |round, hash| {
random_vote(&collector, H520::random(), round, hash); random_vote(&collector, H520::random(), round, hash);
}; };
vote(6, Some("0".sha3())); vote(6, Some(keccak("0")));
vote(3, Some("0".sha3())); vote(3, Some(keccak("0")));
vote(7, Some("0".sha3())); vote(7, Some(keccak("0")));
vote(8, Some("1".sha3())); vote(8, Some(keccak("1")));
vote(1, Some("1".sha3())); vote(1, Some(keccak("1")));
collector.throw_out_old(&7); collector.throw_out_old(&7);
assert_eq!(collector.len(), 2); assert_eq!(collector.len(), 2);
@ -340,9 +344,9 @@ mod tests {
let collector = VoteCollector::default(); let collector = VoteCollector::default();
let round = 3; let round = 3;
// Vote is inserted fine. // 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. // 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); assert_eq!(collector.count_round_votes(&round), 1);
} }
} }

View File

@ -17,7 +17,10 @@
//! General error types for use in ethcore. //! General error types for use in ethcore.
use std::fmt; use std::fmt;
use bigint::prelude::U256;
use bigint::hash::H256;
use util::*; use util::*;
use unexpected::{Mismatch, OutOfBounds};
use io::*; use io::*;
use header::BlockNumber; use header::BlockNumber;
use basic_types::LogBloom; use basic_types::LogBloom;
@ -80,6 +83,8 @@ pub enum TransactionError {
CodeBanned, CodeBanned,
/// Invalid chain ID given. /// Invalid chain ID given.
InvalidChainId, InvalidChainId,
/// Not enough permissions given by permission contract.
NotAllowed,
} }
impl fmt::Display for TransactionError { impl fmt::Display for TransactionError {
@ -104,6 +109,7 @@ impl fmt::Display for TransactionError {
RecipientBanned => "Recipient is temporarily banned.".into(), RecipientBanned => "Recipient is temporarily banned.".into(),
CodeBanned => "Contract code is temporarily banned.".into(), CodeBanned => "Contract code is temporarily banned.".into(),
InvalidChainId => "Transaction of this chain ID is not allowed on this chain.".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)) f.write_fmt(format_args!("Transaction error ({})", msg))
@ -389,7 +395,7 @@ impl From<ExecutionError> for Error {
impl From<::rlp::DecoderError> for Error { impl From<::rlp::DecoderError> for Error {
fn from(err: ::rlp::DecoderError) -> 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 { match err {
BlockImportError::Block(e) => Error::Block(e), BlockImportError::Block(e) => Error::Block(e),
BlockImportError::Import(e) => Error::Import(e), BlockImportError::Import(e) => Error::Import(e),
BlockImportError::Other(s) => Error::Util(UtilError::SimpleString(s)), BlockImportError::Other(s) => Error::Util(UtilError::from(s)),
} }
} }
} }

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
use util::*; use bigint::prelude::U256;
#[inline] #[inline]
/// 1 Ether in Wei /// 1 Ether in Wei

View File

@ -17,9 +17,13 @@
use std::path::Path; use std::path::Path;
use std::cmp; use std::cmp;
use std::collections::{BTreeMap, HashMap}; 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 ethash::{quick_get_difficulty, slow_get_seedhash, EthashManager};
use bigint::prelude::U256;
use bigint::hash::{H256, H64};
use util::*; use util::*;
use unexpected::{OutOfBounds, Mismatch};
use block::*; use block::*;
use builtin::Builtin; use builtin::Builtin;
use vm::EnvInfo; use vm::EnvInfo;
@ -28,12 +32,15 @@ use trace::{Tracer, ExecutiveTracer, RewardType};
use header::{Header, BlockNumber}; use header::{Header, BlockNumber};
use state::CleanupMode; use state::CleanupMode;
use spec::CommonParams; use spec::CommonParams;
use transaction::UnverifiedTransaction; use transaction::{UnverifiedTransaction, SignedTransaction};
use engines::{self, Engine}; use engines::{self, Engine};
use evm::Schedule; use evm::Schedule;
use ethjson; use ethjson;
use rlp::{self, UntrustedRlp}; use rlp::{self, UntrustedRlp};
use vm::LastHashes; 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 /// Parity tries to round block.gas_limit to multiple of this constant
pub const PARITY_GAS_LIMIT_DETERMINANT: U256 = U256([37, 0, 0, 0]); pub const PARITY_GAS_LIMIT_DETERMINANT: U256 = U256([37, 0, 0, 0]);
@ -139,6 +146,7 @@ pub struct Ethash {
ethash_params: EthashParams, ethash_params: EthashParams,
builtins: BTreeMap<Address, Builtin>, builtins: BTreeMap<Address, Builtin>,
pow: EthashManager, pow: EthashManager,
tx_filter: Option<TransactionFilter>,
} }
impl Ethash { impl Ethash {
@ -150,6 +158,7 @@ impl Ethash {
builtins: BTreeMap<Address, Builtin>, builtins: BTreeMap<Address, Builtin>,
) -> Arc<Self> { ) -> Arc<Self> {
Arc::new(Ethash { Arc::new(Ethash {
tx_filter: TransactionFilter::from_params(&params),
params, params,
ethash_params, ethash_params,
builtins, builtins,
@ -435,6 +444,14 @@ impl Engine for Arc<Ethash> {
Ok(()) 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> { fn epoch_verifier<'a>(&self, _header: &Header, _proof: &'a [u8]) -> engines::ConstructedVerifier<'a> {
engines::ConstructedVerifier::Trusted(Box::new(self.clone())) engines::ConstructedVerifier::Trusted(Box::new(self.clone()))
} }
@ -442,6 +459,13 @@ impl Engine for Arc<Ethash> {
fn snapshot_components(&self) -> Option<Box<::snapshot::SnapshotComponents>> { fn snapshot_components(&self) -> Option<Box<::snapshot::SnapshotComponents>> {
Some(Box::new(::snapshot::PowSnapshot::new(SNAPSHOT_BLOCKS, MAX_SNAPSHOT_BLOCKS))) Some(Box::new(::snapshot::PowSnapshot::new(SNAPSHOT_BLOCKS, MAX_SNAPSHOT_BLOCKS)))
} }
fn 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: // Try to round gas_limit a bit so that:
@ -481,7 +505,7 @@ impl Ethash {
panic!("Can't calculate genesis block difficulty"); 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; let min_difficulty = self.ethash_params.minimum_difficulty;
@ -586,6 +610,8 @@ mod tests {
use std::str::FromStr; use std::str::FromStr;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::sync::Arc; use std::sync::Arc;
use bigint::prelude::U256;
use bigint::hash::{H64, H256};
use util::*; use util::*;
use block::*; use block::*;
use tests::helpers::*; use tests::helpers::*;

View File

@ -92,7 +92,7 @@ pub fn new_metropolis_test() -> Spec { load(None, include_bytes!("../../res/ethe
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use util::*; use bigint::prelude::U256;
use state::*; use state::*;
use super::*; use super::*;
use tests::helpers::*; use tests::helpers::*;
@ -119,7 +119,7 @@ mod tests {
assert_eq!(morden.state_root(), "f3f4696bbf3b3b07775128eb7a3763279a394e382130f27c21e70233e04946a9".into()); assert_eq!(morden.state_root(), "f3f4696bbf3b3b07775128eb7a3763279a394e382130f27c21e70233e04946a9".into());
let genesis = morden.genesis_block(); 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; let _ = morden.engine;
} }
@ -130,7 +130,7 @@ mod tests {
assert_eq!(frontier.state_root(), "d7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544".into()); assert_eq!(frontier.state_root(), "d7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544".into());
let genesis = frontier.genesis_block(); 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; let _ = frontier.engine;
} }

View File

@ -16,7 +16,8 @@
//! Transaction execution format module. //! Transaction execution format module.
use util::{Bytes, U256, Address, U512, trie}; use bigint::prelude::{U256, U512};
use util::{Bytes, Address, trie};
use vm; use vm;
use trace::{VMTrace, FlatTrace}; use trace::{VMTrace, FlatTrace};
use log_entry::LogEntry; use log_entry::LogEntry;

View File

@ -17,6 +17,9 @@
//! Transaction Execution environment. //! Transaction Execution environment.
use std::cmp; use std::cmp;
use std::sync::Arc; use std::sync::Arc;
use hash::keccak;
use bigint::prelude::{U256, U512};
use bigint::hash::H256;
use util::*; use util::*;
use state::{Backend as StateBackend, State, Substate, CleanupMode}; use state::{Backend as StateBackend, State, Substate, CleanupMode};
use engines::Engine; use engines::Engine;
@ -47,20 +50,20 @@ pub fn contract_address(address_scheme: CreateContractAddress, sender: &Address,
let mut stream = RlpStream::new_list(2); let mut stream = RlpStream::new_list(2);
stream.append(sender); stream.append(sender);
stream.append(nonce); stream.append(nonce);
(From::from(stream.as_raw().sha3()), None) (From::from(keccak(stream.as_raw())), None)
}, },
CreateContractAddress::FromCodeHash => { CreateContractAddress::FromCodeHash => {
let code_hash = code.sha3(); let code_hash = keccak(code);
let mut buffer = [0xffu8; 20 + 32]; let mut buffer = [0xffu8; 20 + 32];
&mut buffer[20..].copy_from_slice(&code_hash[..]); &mut buffer[20..].copy_from_slice(&code_hash[..]);
(From::from((&buffer[..]).sha3()), Some(code_hash)) (From::from(keccak(&buffer[..])), Some(code_hash))
}, },
CreateContractAddress::FromSenderAndCodeHash => { CreateContractAddress::FromSenderAndCodeHash => {
let code_hash = code.sha3(); let code_hash = keccak(code);
let mut buffer = [0u8; 20 + 32]; let mut buffer = [0u8; 20 + 32];
&mut buffer[..20].copy_from_slice(&sender[..]); &mut buffer[..20].copy_from_slice(&sender[..]);
&mut buffer[20..].copy_from_slice(&code_hash[..]); &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, pub vm_tracer: V,
/// Check transaction nonce before execution. /// Check transaction nonce before execution.
pub check_nonce: bool, pub check_nonce: bool,
/// Records the output from init contract calls.
pub output_from_init_contract: bool,
} }
impl<T, V> TransactOptions<T, V> { impl<T, V> TransactOptions<T, V> {
@ -83,6 +88,7 @@ impl<T, V> TransactOptions<T, V> {
tracer, tracer,
vm_tracer, vm_tracer,
check_nonce: true, check_nonce: true,
output_from_init_contract: false,
} }
} }
@ -91,6 +97,12 @@ impl<T, V> TransactOptions<T, V> {
self.check_nonce = false; self.check_nonce = false;
self 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> { impl TransactOptions<trace::ExecutiveTracer, trace::ExecutiveVMTracer> {
@ -100,6 +112,7 @@ impl TransactOptions<trace::ExecutiveTracer, trace::ExecutiveVMTracer> {
tracer: trace::ExecutiveTracer::default(), tracer: trace::ExecutiveTracer::default(),
vm_tracer: trace::ExecutiveVMTracer::toplevel(), vm_tracer: trace::ExecutiveVMTracer::toplevel(),
check_nonce: true, check_nonce: true,
output_from_init_contract: false,
} }
} }
} }
@ -111,6 +124,7 @@ impl TransactOptions<trace::ExecutiveTracer, trace::NoopVMTracer> {
tracer: trace::ExecutiveTracer::default(), tracer: trace::ExecutiveTracer::default(),
vm_tracer: trace::NoopVMTracer, vm_tracer: trace::NoopVMTracer,
check_nonce: true, check_nonce: true,
output_from_init_contract: false,
} }
} }
} }
@ -122,6 +136,7 @@ impl TransactOptions<trace::NoopTracer, trace::ExecutiveVMTracer> {
tracer: trace::NoopTracer, tracer: trace::NoopTracer,
vm_tracer: trace::ExecutiveVMTracer::toplevel(), vm_tracer: trace::ExecutiveVMTracer::toplevel(),
check_nonce: true, check_nonce: true,
output_from_init_contract: false,
} }
} }
} }
@ -133,6 +148,7 @@ impl TransactOptions<trace::NoopTracer, trace::NoopVMTracer> {
tracer: trace::NoopTracer, tracer: trace::NoopTracer,
vm_tracer: trace::NoopVMTracer, vm_tracer: trace::NoopVMTracer,
check_nonce: true, 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>) pub fn transact<T, V>(&'a mut self, t: &SignedTransaction, options: TransactOptions<T, V>)
-> Result<Executed, ExecutionError> where T: Tracer, V: VMTracer, -> 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. /// 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, &'a mut self,
t: &SignedTransaction, t: &SignedTransaction,
check_nonce: bool, check_nonce: bool,
output_from_create: bool,
mut tracer: T, mut tracer: T,
mut vm_tracer: V mut vm_tracer: V
) -> Result<Executed, ExecutionError> where T: Tracer, V: VMTracer { ) -> 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, data: None,
call_type: CallType::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) => { Action::Call(ref address) => {
let params = ActionParams { let params = ActionParams {
@ -487,6 +505,7 @@ impl<'a, B: 'a + StateBackend, E: Engine + ?Sized> Executive<'a, B, E> {
&mut self, &mut self,
params: ActionParams, params: ActionParams,
substate: &mut Substate, substate: &mut Substate,
output: &mut Option<Bytes>,
tracer: &mut T, tracer: &mut T,
vm_tracer: &mut V, vm_tracer: &mut V,
) -> vm::Result<(U256, ReturnData)> where T: Tracer, V: VMTracer { ) -> 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 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 = { 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); 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( Ok(ref res) => tracer.trace_create(
trace_info, trace_info,
gas - res.gas_left, gas - res.gas_left,
trace_output, trace_output.map(|data| output.as_ref().map(|out| out.to_vec()).unwrap_or(data)),
created, created,
subtracer.drain() subtracer.drain()
), ),
@ -658,7 +677,9 @@ mod tests {
use rustc_hex::FromHex; use rustc_hex::FromHex;
use ethkey::{Generator, Random}; use ethkey::{Generator, Random};
use super::*; 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 util::bytes::BytesRef;
use vm::{ActionParams, ActionValue, CallType, EnvInfo, CreateContractAddress}; use vm::{ActionParams, ActionValue, CallType, EnvInfo, CreateContractAddress};
use evm::{Factory, VMType}; use evm::{Factory, VMType};
@ -696,7 +717,7 @@ mod tests {
let (gas_left, _) = { let (gas_left, _) = {
let mut ex = Executive::new(&mut state, &info, &engine); 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)); assert_eq!(gas_left, U256::from(79_975));
@ -754,7 +775,7 @@ mod tests {
let (gas_left, _) = { let (gas_left, _) = {
let mut ex = Executive::new(&mut state, &info, &engine); 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)); assert_eq!(gas_left, U256::from(62_976));
@ -921,7 +942,7 @@ mod tests {
let (gas_left, _) = { let (gas_left, _) = {
let mut ex = Executive::new(&mut state, &info, &engine); 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)); assert_eq!(gas_left, U256::from(96_776));
@ -1006,7 +1027,7 @@ mod tests {
let (gas_left, _) = { let (gas_left, _) = {
let mut ex = Executive::new(&mut state, &info, &engine); 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)); assert_eq!(gas_left, U256::from(62_976));
@ -1057,7 +1078,7 @@ mod tests {
{ {
let mut ex = Executive::new(&mut state, &info, &engine); 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); assert_eq!(substate.contracts_created.len(), 1);
@ -1307,8 +1328,8 @@ mod tests {
} }
} }
evm_test!{test_sha3: test_sha3_jit, test_sha3_int} evm_test!{test_keccak: test_keccak_jit, test_keccak_int}
fn test_sha3(factory: Factory) { fn test_keccak(factory: Factory) {
let code = "6064640fffffffff20600055".from_hex().unwrap(); let code = "6064640fffffffff20600055".from_hex().unwrap();
let sender = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap(); let sender = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
@ -1330,7 +1351,7 @@ mod tests {
let result = { let result = {
let mut ex = Executive::new(&mut state, &info, &engine); 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 { match result {

View File

@ -17,6 +17,8 @@
//! Transaction Execution environment. //! Transaction Execution environment.
use std::cmp; use std::cmp;
use std::sync::Arc; use std::sync::Arc;
use bigint::prelude::U256;
use bigint::hash::H256;
use util::*; use util::*;
use state::{Backend as StateBackend, State, Substate, CleanupMode}; use state::{Backend as StateBackend, State, Substate, CleanupMode};
use engines::Engine; 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); let mut ex = Executive::from_parent(self.state, self.env_info, self.engine, self.depth, self.static_flag);
// TODO: handle internal error separately // 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, _)) => { Ok((gas_left, _)) => {
self.substate.contracts_created.push(address.clone()); self.substate.contracts_created.push(address.clone());
ContractCreateResult::Created(address, gas_left) ContractCreateResult::Created(address, gas_left)

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