diff --git a/.gitignore b/.gitignore index 1b70fb7bcb660..2e0651ba435d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -/target/ +**/target/ **/*.rs.bk *.swp .wasm-binaries diff --git a/Cargo.lock b/Cargo.lock index e044fbd7d1527..9a9201b139bef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -281,11 +281,11 @@ dependencies = [ [[package]] name = "cid" version = "0.2.3" -source = "git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2#6aa139a12dbea3d75d898ce0b2af7fcec129e294" +source = "git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294#6aa139a12dbea3d75d898ce0b2af7fcec129e294" dependencies = [ "integer-encoding 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "multibase 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "multihash 0.8.1-pre (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "multihash 0.8.1-pre (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", ] [[package]] @@ -430,7 +430,7 @@ dependencies = [ [[package]] name = "datastore" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2#6aa139a12dbea3d75d898ce0b2af7fcec129e294" +source = "git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294#6aa139a12dbea3d75d898ce0b2af7fcec129e294" dependencies = [ "base64 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "chashmap 2.2.1 (git+https://github.com/redox-os/tfs)", @@ -632,11 +632,6 @@ dependencies = [ "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ethcore-bytes" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity.git#4145be863bec10038fc0ac5d36a41365b5087344" - [[package]] name = "ethcore-crypto" version = "0.1.0" @@ -753,17 +748,19 @@ dependencies = [ [[package]] name = "fixed-hash" -version = "0.1.3" -source = "git+https://github.com/rphmeier/primitives.git?branch=compile-for-wasm#8dc457899afdaf968ff7f16140b03d1e37b01d71" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.41 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "fixed-hash" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.2.2" +source = "git+https://github.com/paritytech/parity-common#22209e14805e5764f7fe81259324d34eab179264" dependencies = [ "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.41 (registry+https://github.com/rust-lang/crates.io-index)", @@ -858,11 +855,10 @@ dependencies = [ [[package]] name = "hashdb" -version = "0.1.1" -source = "git+https://github.com/paritytech/parity.git#4145be863bec10038fc0ac5d36a41365b5087344" +version = "0.2.1" +source = "git+https://github.com/paritytech/parity-common#22209e14805e5764f7fe81259324d34eab179264" dependencies = [ "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1073,15 +1069,6 @@ dependencies = [ "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "keccak-hash" -version = "0.1.2" -source = "git+https://github.com/paritytech/parity.git#4145be863bec10038fc0ac5d36a41365b5087344" -dependencies = [ - "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "kernel32-sys" version = "0.2.2" @@ -1094,35 +1081,34 @@ dependencies = [ [[package]] name = "kvdb" version = "0.1.0" -source = "git+https://github.com/paritytech/parity.git#4145be863bec10038fc0ac5d36a41365b5087344" +source = "git+https://github.com/paritytech/parity-common#22209e14805e5764f7fe81259324d34eab179264" dependencies = [ "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethcore-bytes 0.1.0 (git+https://github.com/paritytech/parity.git)", + "parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)", ] [[package]] name = "kvdb-memorydb" version = "0.1.0" -source = "git+https://github.com/paritytech/parity.git#4145be863bec10038fc0ac5d36a41365b5087344" +source = "git+https://github.com/paritytech/parity-common#22209e14805e5764f7fe81259324d34eab179264" dependencies = [ - "kvdb 0.1.0 (git+https://github.com/paritytech/parity.git)", - "parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common)", + "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "kvdb-rocksdb" version = "0.1.0" -source = "git+https://github.com/paritytech/parity.git#4145be863bec10038fc0ac5d36a41365b5087344" +source = "git+https://github.com/paritytech/parity-common#22209e14805e5764f7fe81259324d34eab179264" dependencies = [ "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fs-swap 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "kvdb 0.1.0 (git+https://github.com/paritytech/parity.git)", + "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "rocksdb 0.4.5 (git+https://github.com/paritytech/rust-rocksdb)", ] @@ -1155,26 +1141,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libp2p" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2#6aa139a12dbea3d75d898ce0b2af7fcec129e294" +source = "git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294#6aa139a12dbea3d75d898ce0b2af7fcec129e294" dependencies = [ "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", - "libp2p-dns 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", - "libp2p-floodsub 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", - "libp2p-identify 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", - "libp2p-kad 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", - "libp2p-mplex 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", - "libp2p-peerstore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", - "libp2p-ping 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", - "libp2p-ratelimit 0.1.1 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", - "libp2p-relay 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", - "libp2p-secio 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", - "libp2p-tcp-transport 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", - "libp2p-transport-timeout 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", - "libp2p-websocket 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", - "libp2p-yamux 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", - "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", + "libp2p-dns 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", + "libp2p-floodsub 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", + "libp2p-identify 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", + "libp2p-kad 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", + "libp2p-mplex 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", + "libp2p-peerstore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", + "libp2p-ping 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", + "libp2p-ratelimit 0.1.1 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", + "libp2p-relay 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", + "libp2p-secio 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", + "libp2p-tcp-transport 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", + "libp2p-transport-timeout 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", + "libp2p-websocket 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", + "libp2p-yamux 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", + "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "stdweb 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-current-thread 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1184,20 +1170,20 @@ dependencies = [ [[package]] name = "libp2p-core" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2#6aa139a12dbea3d75d898ce0b2af7fcec129e294" +source = "git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294#6aa139a12dbea3d75d898ce0b2af7fcec129e294" dependencies = [ "bs58 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", - "multihash 0.8.1-pre (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", - "multistream-select 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", + "multihash 0.8.1-pre (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", + "multistream-select 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rw-stream-sink 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "rw-stream-sink 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "smallvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1205,12 +1191,12 @@ dependencies = [ [[package]] name = "libp2p-dns" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2#6aa139a12dbea3d75d898ce0b2af7fcec129e294" +source = "git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294#6aa139a12dbea3d75d898ce0b2af7fcec129e294" dependencies = [ "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "tokio-dns-unofficial 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1218,60 +1204,60 @@ dependencies = [ [[package]] name = "libp2p-floodsub" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2#6aa139a12dbea3d75d898ce0b2af7fcec129e294" +source = "git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294#6aa139a12dbea3d75d898ce0b2af7fcec129e294" dependencies = [ "bs58 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", ] [[package]] name = "libp2p-identify" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2#6aa139a12dbea3d75d898ce0b2af7fcec129e294" +source = "git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294#6aa139a12dbea3d75d898ce0b2af7fcec129e294" dependencies = [ "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", - "libp2p-peerstore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", + "libp2p-peerstore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", ] [[package]] name = "libp2p-kad" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2#6aa139a12dbea3d75d898ce0b2af7fcec129e294" +source = "git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294#6aa139a12dbea3d75d898ce0b2af7fcec129e294" dependencies = [ "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "bigint 4.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "bs58 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "datastore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "datastore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", - "libp2p-identify 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", - "libp2p-ping 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", + "libp2p-identify 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", + "libp2p-ping 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1279,35 +1265,35 @@ dependencies = [ "tokio-codec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", ] [[package]] name = "libp2p-mplex" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2#6aa139a12dbea3d75d898ce0b2af7fcec129e294" +source = "git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294#6aa139a12dbea3d75d898ce0b2af7fcec129e294" dependencies = [ "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", ] [[package]] name = "libp2p-peerstore" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2#6aa139a12dbea3d75d898ce0b2af7fcec129e294" +source = "git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294#6aa139a12dbea3d75d898ce0b2af7fcec129e294" dependencies = [ "bs58 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "datastore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "datastore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", - "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", + "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1316,14 +1302,14 @@ dependencies = [ [[package]] name = "libp2p-ping" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2#6aa139a12dbea3d75d898ce0b2af7fcec129e294" +source = "git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294#6aa139a12dbea3d75d898ce0b2af7fcec129e294" dependencies = [ "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", - "multistream-select 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", + "multistream-select 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1333,11 +1319,11 @@ dependencies = [ [[package]] name = "libp2p-ratelimit" version = "0.1.1" -source = "git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2#6aa139a12dbea3d75d898ce0b2af7fcec129e294" +source = "git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294#6aa139a12dbea3d75d898ce0b2af7fcec129e294" dependencies = [ "aio-limited 0.1.0 (git+https://github.com/paritytech/aio-limited.git)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1346,37 +1332,37 @@ dependencies = [ [[package]] name = "libp2p-relay" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2#6aa139a12dbea3d75d898ce0b2af7fcec129e294" +source = "git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294#6aa139a12dbea3d75d898ce0b2af7fcec129e294" dependencies = [ "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", - "libp2p-peerstore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", + "libp2p-peerstore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "protobuf 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", ] [[package]] name = "libp2p-secio" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2#6aa139a12dbea3d75d898ce0b2af7fcec129e294" +source = "git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294#6aa139a12dbea3d75d898ce0b2af7fcec129e294" dependencies = [ "asn1_der 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "eth-secp256k1 0.5.7 (git+https://github.com/paritytech/rust-secp256k1)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "rw-stream-sink 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "rw-stream-sink 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1384,12 +1370,12 @@ dependencies = [ [[package]] name = "libp2p-tcp-transport" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2#6aa139a12dbea3d75d898ce0b2af7fcec129e294" +source = "git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294#6aa139a12dbea3d75d898ce0b2af7fcec129e294" dependencies = [ "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "tk-listen 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1398,10 +1384,10 @@ dependencies = [ [[package]] name = "libp2p-transport-timeout" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2#6aa139a12dbea3d75d898ce0b2af7fcec129e294" +source = "git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294#6aa139a12dbea3d75d898ce0b2af7fcec129e294" dependencies = [ "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1409,13 +1395,13 @@ dependencies = [ [[package]] name = "libp2p-websocket" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2#6aa139a12dbea3d75d898ce0b2af7fcec129e294" +source = "git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294#6aa139a12dbea3d75d898ce0b2af7fcec129e294" dependencies = [ "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", - "rw-stream-sink 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", + "rw-stream-sink 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "stdweb 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "websocket 0.20.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1424,11 +1410,11 @@ dependencies = [ [[package]] name = "libp2p-yamux" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2#6aa139a12dbea3d75d898ce0b2af7fcec129e294" +source = "git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294#6aa139a12dbea3d75d898ce0b2af7fcec129e294" dependencies = [ "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "yamux 0.1.0 (git+https://github.com/paritytech/yamux)", @@ -1504,16 +1490,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "memorydb" -version = "0.1.1" -source = "git+https://github.com/paritytech/parity.git#4145be863bec10038fc0ac5d36a41365b5087344" +version = "0.2.1" +source = "git+https://github.com/paritytech/parity-common#22209e14805e5764f7fe81259324d34eab179264" dependencies = [ "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hashdb 0.1.1 (git+https://github.com/paritytech/parity.git)", + "hashdb 0.2.1 (git+https://github.com/paritytech/parity-common)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "keccak-hash 0.1.2 (git+https://github.com/paritytech/parity.git)", - "plain_hasher 0.1.0 (git+https://github.com/paritytech/parity.git)", - "rlp 0.2.1 (git+https://github.com/paritytech/parity.git)", + "plain_hasher 0.2.0 (git+https://github.com/paritytech/parity-common)", + "rlp 0.2.1 (git+https://github.com/paritytech/parity-common)", ] [[package]] @@ -1564,10 +1548,10 @@ dependencies = [ [[package]] name = "multiaddr" version = "0.3.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2#6aa139a12dbea3d75d898ce0b2af7fcec129e294" +source = "git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294#6aa139a12dbea3d75d898ce0b2af7fcec129e294" dependencies = [ "byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cid 0.2.3 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "cid 0.2.3 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "integer-encoding 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1582,7 +1566,7 @@ dependencies = [ [[package]] name = "multihash" version = "0.8.1-pre" -source = "git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2#6aa139a12dbea3d75d898ce0b2af7fcec129e294" +source = "git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294#6aa139a12dbea3d75d898ce0b2af7fcec129e294" dependencies = [ "sha1 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1592,14 +1576,14 @@ dependencies = [ [[package]] name = "multistream-select" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2#6aa139a12dbea3d75d898ce0b2af7fcec129e294" +source = "git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294#6aa139a12dbea3d75d898ce0b2af7fcec129e294" dependencies = [ "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", ] [[package]] @@ -1714,6 +1698,23 @@ dependencies = [ "stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parity-bytes" +version = "0.1.0" +source = "git+https://github.com/paritytech/parity-common#22209e14805e5764f7fe81259324d34eab179264" + +[[package]] +name = "parity-crypto" +version = "0.1.0" +source = "git+https://github.com/paritytech/parity-common#22209e14805e5764f7fe81259324d34eab179264" +dependencies = [ + "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ring 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "parity-wasm" version = "0.31.0" @@ -1772,20 +1773,14 @@ dependencies = [ [[package]] name = "patricia-trie" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity.git#4145be863bec10038fc0ac5d36a41365b5087344" +version = "0.2.1" +source = "git+https://github.com/paritytech/parity-common#22209e14805e5764f7fe81259324d34eab179264" dependencies = [ "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethcore-bytes 0.1.0 (git+https://github.com/paritytech/parity.git)", - "ethcore-logger 1.12.0 (git+https://github.com/paritytech/parity.git)", - "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hashdb 0.1.1 (git+https://github.com/paritytech/parity.git)", - "keccak-hash 0.1.2 (git+https://github.com/paritytech/parity.git)", + "hashdb 0.2.1 (git+https://github.com/paritytech/parity-common)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "memorydb 0.1.1 (git+https://github.com/paritytech/parity.git)", + "parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.1 (git+https://github.com/paritytech/parity.git)", - "triehash 0.1.0 (git+https://github.com/paritytech/parity.git)", ] [[package]] @@ -1800,11 +1795,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "plain_hasher" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity.git#4145be863bec10038fc0ac5d36a41365b5087344" +version = "0.2.0" +source = "git+https://github.com/paritytech/parity-common#22209e14805e5764f7fe81259324d34eab179264" dependencies = [ "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1841,9 +1835,9 @@ dependencies = [ name = "polkadot-availability-store" version = "0.1.0" dependencies = [ - "kvdb 0.1.0 (git+https://github.com/paritytech/parity.git)", - "kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity.git)", - "kvdb-rocksdb 0.1.0 (git+https://github.com/paritytech/parity.git)", + "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common)", + "kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common)", + "kvdb-rocksdb 0.1.0 (git+https://github.com/paritytech/parity-common)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "polkadot-primitives 0.1.0", @@ -1933,6 +1927,7 @@ version = "0.1.0" dependencies = [ "polkadot-runtime 0.1.0", "substrate-executor 0.1.0", + "substrate-primitives 0.1.0", ] [[package]] @@ -2313,7 +2308,7 @@ dependencies = [ [[package]] name = "rlp" version = "0.2.1" -source = "git+https://github.com/paritytech/parity.git#4145be863bec10038fc0ac5d36a41365b5087344" +source = "git+https://github.com/paritytech/parity-common#22209e14805e5764f7fe81259324d34eab179264" dependencies = [ "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2396,7 +2391,7 @@ dependencies = [ [[package]] name = "rw-stream-sink" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2#6aa139a12dbea3d75d898ce0b2af7fcec129e294" +source = "git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294#6aa139a12dbea3d75d898ce0b2af7fcec129e294" dependencies = [ "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2693,9 +2688,13 @@ dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "hashdb 0.2.1 (git+https://github.com/paritytech/parity-common)", + "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "patricia-trie 0.2.1 (git+https://github.com/paritytech/parity-common)", + "rlp 0.2.1 (git+https://github.com/paritytech/parity-common)", "slog 2.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-bft 0.1.0", "substrate-codec 0.1.0", @@ -2715,15 +2714,13 @@ dependencies = [ name = "substrate-client-db" version = "0.1.0" dependencies = [ - "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hashdb 0.1.1 (git+https://github.com/paritytech/parity.git)", - "kvdb 0.1.0 (git+https://github.com/paritytech/parity.git)", - "kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity.git)", - "kvdb-rocksdb 0.1.0 (git+https://github.com/paritytech/parity.git)", + "hashdb 0.2.1 (git+https://github.com/paritytech/parity-common)", + "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common)", + "kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common)", + "kvdb-rocksdb 0.1.0 (git+https://github.com/paritytech/parity-common)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "memorydb 0.1.1 (git+https://github.com/paritytech/parity.git)", + "memorydb 0.2.1 (git+https://github.com/paritytech/parity-common)", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "patricia-trie 0.1.0 (git+https://github.com/paritytech/parity.git)", "substrate-client 0.1.0", "substrate-codec 0.1.0", "substrate-codec-derive 0.1.0", @@ -2760,6 +2757,7 @@ dependencies = [ "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "ed25519 0.1.0", "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hashdb 0.2.1 (git+https://github.com/paritytech/parity-common)", "hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2772,6 +2770,7 @@ dependencies = [ "substrate-runtime-version 0.1.0", "substrate-serializer 0.1.0", "substrate-state-machine 0.1.0", + "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "triehash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "twox-hash 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "wabt 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2806,8 +2805,8 @@ version = "0.1.0" dependencies = [ "ed25519 0.1.0", "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethcore-crypto 0.1.0 (git+https://github.com/paritytech/parity.git)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-crypto 0.1.0 (git+https://github.com/paritytech/parity-common)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2860,7 +2859,6 @@ dependencies = [ "assert_matches 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethcore-bytes 0.1.0 (git+https://github.com/paritytech/parity.git)", "ethcore-io 1.12.0 (git+https://github.com/paritytech/parity.git)", "ethcore-logger 1.12.0 (git+https://github.com/paritytech/parity.git)", "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2868,8 +2866,9 @@ dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.41 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)", + "libp2p 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)", "parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2885,8 +2884,14 @@ dependencies = [ "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "fixed-hash 0.1.3 (git+https://github.com/rphmeier/primitives.git?branch=compile-for-wasm)", + "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fixed-hash 0.2.2 (git+https://github.com/paritytech/parity-common)", + "hashdb 0.2.1 (git+https://github.com/paritytech/parity-common)", + "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "patricia-trie 0.2.1 (git+https://github.com/paritytech/parity-common)", + "plain_hasher 0.2.0 (git+https://github.com/paritytech/parity-common)", "pretty_assertions 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rlp 0.2.1 (git+https://github.com/paritytech/parity-common)", "rustc-hex 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2894,8 +2899,9 @@ dependencies = [ "substrate-codec-derive 0.1.0", "substrate-runtime-std 0.1.0", "substrate-serializer 0.1.0", + "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "twox-hash 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "uint 0.1.2 (git+https://github.com/rphmeier/primitives.git?branch=compile-for-wasm)", + "uint 0.3.0 (git+https://github.com/paritytech/parity-common)", "wasmi 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2962,6 +2968,7 @@ dependencies = [ "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-codec 0.1.0", + "substrate-primitives 0.1.0", "substrate-runtime-consensus 0.1.0", "substrate-runtime-io 0.1.0", "substrate-runtime-primitives 0.1.0", @@ -3253,15 +3260,16 @@ name = "substrate-state-machine" version = "0.1.0" dependencies = [ "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hashdb 0.1.1 (git+https://github.com/paritytech/parity.git)", + "hashdb 0.2.1 (git+https://github.com/paritytech/parity-common)", + "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "memorydb 0.1.1 (git+https://github.com/paritytech/parity.git)", + "memorydb 0.2.1 (git+https://github.com/paritytech/parity-common)", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "patricia-trie 0.1.0 (git+https://github.com/paritytech/parity.git)", + "patricia-trie 0.2.1 (git+https://github.com/paritytech/parity-common)", + "rlp 0.2.1 (git+https://github.com/paritytech/parity-common)", "substrate-primitives 0.1.0", - "triehash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "triehash 0.2.0 (git+https://github.com/paritytech/parity-common)", ] [[package]] @@ -3282,6 +3290,7 @@ dependencies = [ name = "substrate-test-client" version = "0.1.0" dependencies = [ + "hashdb 0.2.1 (git+https://github.com/paritytech/parity-common)", "rhododendron 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-bft 0.1.0", "substrate-client 0.1.0", @@ -3656,24 +3665,23 @@ dependencies = [ [[package]] name = "triehash" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity.git#4145be863bec10038fc0ac5d36a41365b5087344" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "keccak-hash 0.1.2 (git+https://github.com/paritytech/parity.git)", - "rlp 0.2.1 (git+https://github.com/paritytech/parity.git)", + "keccak-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "triehash" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.2.0" +source = "git+https://github.com/paritytech/parity-common#22209e14805e5764f7fe81259324d34eab179264" dependencies = [ "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "keccak-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hashdb 0.2.1 (git+https://github.com/paritytech/parity-common)", + "rlp 0.2.1 (git+https://github.com/paritytech/parity-common)", ] [[package]] @@ -3706,23 +3714,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "uint" -version = "0.1.2" -source = "git+https://github.com/rphmeier/primitives.git?branch=compile-for-wasm#8dc457899afdaf968ff7f16140b03d1e37b01d71" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "uint" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.3.0" +source = "git+https://github.com/paritytech/parity-common#22209e14805e5764f7fe81259324d34eab179264" dependencies = [ "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3805,7 +3813,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "varint" version = "0.1.0" -source = "git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2#6aa139a12dbea3d75d898ce0b2af7fcec129e294" +source = "git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294#6aa139a12dbea3d75d898ce0b2af7fcec129e294" dependencies = [ "bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4019,7 +4027,7 @@ dependencies = [ "checksum cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "405216fd8fe65f718daa7102ea808a946b6ce40c742998fbfd3463645552de18" "checksum chashmap 2.2.1 (git+https://github.com/redox-os/tfs)" = "" "checksum chrono 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1cce36c92cb605414e9b824f866f5babe0a0368e39ea07393b9b63cf3844c0e6" -"checksum cid 0.2.3 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)" = "" +"checksum cid 0.2.3 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)" = "" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum cmake 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "95470235c31c726d72bf2e1f421adc1e65b9d561bf5529612cbe1a72da1467b3" @@ -4036,7 +4044,7 @@ dependencies = [ "checksum crossbeam-utils 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d636a8b3bcc1b409d7ffd3facef8f21dcb4009626adbd0c5e6c4305c07253c7b" "checksum crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a2f4a431c5c9f662e1200b7c7f02c34e91361150e382089a8f2dec3ba680cbda" "checksum ctrlc 1.1.1 (git+https://github.com/paritytech/rust-ctrlc.git)" = "" -"checksum datastore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)" = "" +"checksum datastore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)" = "" "checksum difference 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3304d19798a8e067e48d8e69b2c37f0b5e9b4e462504ad9e27e9f3fce02bba8" "checksum digest 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3cae2388d706b52f2f2f9afe280f9d768be36544bd71d1b8120cb34ea6450b55" "checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab" @@ -4048,7 +4056,6 @@ dependencies = [ "checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02" "checksum eth-secp256k1 0.5.7 (git+https://github.com/paritytech/rust-secp256k1)" = "" "checksum ethbloom 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a93a43ce2e9f09071449da36bfa7a1b20b950ee344b6904ff23de493b03b386" -"checksum ethcore-bytes 0.1.0 (git+https://github.com/paritytech/parity.git)" = "" "checksum ethcore-crypto 0.1.0 (git+https://github.com/paritytech/parity.git)" = "" "checksum ethcore-io 1.12.0 (git+https://github.com/paritytech/parity.git)" = "" "checksum ethcore-logger 1.12.0 (git+https://github.com/paritytech/parity.git)" = "" @@ -4059,8 +4066,8 @@ dependencies = [ "checksum exit-future 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9aa7b56cef68c4182db7212dece19cc9f6e2916cf9412e57e6cea53ec02f316d" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" "checksum fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b1ee15a7050e5580b3712877157068ea713b245b080ff302ae2ca973cfcd9baa" -"checksum fixed-hash 0.1.3 (git+https://github.com/rphmeier/primitives.git?branch=compile-for-wasm)" = "" "checksum fixed-hash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b18d6fd718fb4396e7a9c93ac59ba7143501467ca7a143c145b5555a571d5576" +"checksum fixed-hash 0.2.2 (git+https://github.com/paritytech/parity-common)" = "" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" "checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" @@ -4073,7 +4080,7 @@ dependencies = [ "checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d" "checksum getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "b900c08c1939860ce8b54dc6a89e26e00c04c380fd0e09796799bd7f12861e05" "checksum globset 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "142754da2c9b3722affd909f9e27f2a6700a7a303f362971e0a74c652005a43d" -"checksum hashdb 0.1.1 (git+https://github.com/paritytech/parity.git)" = "" +"checksum hashdb 0.2.1 (git+https://github.com/paritytech/parity-common)" = "" "checksum heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" "checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" "checksum hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4da5f0e01bd8a71a224a4eedecaacfcabda388dbb7a80faf04d3514287572d95" @@ -4095,32 +4102,31 @@ dependencies = [ "checksum jsonrpc-server-utils 8.0.1 (git+https://github.com/paritytech/jsonrpc.git)" = "" "checksum jsonrpc-ws-server 8.0.0 (git+https://github.com/paritytech/jsonrpc.git)" = "" "checksum keccak-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b7f51f30d7986536accaec4a6a288008dfb3dbffe8a2863a65292bc395a3ae7" -"checksum keccak-hash 0.1.2 (git+https://github.com/paritytech/parity.git)" = "" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum kvdb 0.1.0 (git+https://github.com/paritytech/parity.git)" = "" -"checksum kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity.git)" = "" -"checksum kvdb-rocksdb 0.1.0 (git+https://github.com/paritytech/parity.git)" = "" +"checksum kvdb 0.1.0 (git+https://github.com/paritytech/parity-common)" = "" +"checksum kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common)" = "" +"checksum kvdb-rocksdb 0.1.0 (git+https://github.com/paritytech/parity-common)" = "" "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" "checksum lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e6412c5e2ad9584b0b8e979393122026cdd6d2a80b933f890dcd694ddbe73739" "checksum lazycell 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a6f08839bc70ef4a3fe1d566d5350f519c5912ea86be0df1740a7d247c7fc0ef" "checksum libc 0.2.41 (registry+https://github.com/rust-lang/crates.io-index)" = "ac8ebf8343a981e2fa97042b14768f02ed3e1d602eac06cae6166df3c8ced206" -"checksum libp2p 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)" = "" -"checksum libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)" = "" -"checksum libp2p-dns 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)" = "" -"checksum libp2p-floodsub 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)" = "" -"checksum libp2p-identify 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)" = "" -"checksum libp2p-kad 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)" = "" -"checksum libp2p-mplex 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)" = "" -"checksum libp2p-peerstore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)" = "" -"checksum libp2p-ping 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)" = "" -"checksum libp2p-ratelimit 0.1.1 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)" = "" -"checksum libp2p-relay 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)" = "" -"checksum libp2p-secio 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)" = "" -"checksum libp2p-tcp-transport 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)" = "" -"checksum libp2p-transport-timeout 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)" = "" -"checksum libp2p-websocket 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)" = "" -"checksum libp2p-yamux 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)" = "" +"checksum libp2p 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)" = "" +"checksum libp2p-core 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)" = "" +"checksum libp2p-dns 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)" = "" +"checksum libp2p-floodsub 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)" = "" +"checksum libp2p-identify 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)" = "" +"checksum libp2p-kad 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)" = "" +"checksum libp2p-mplex 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)" = "" +"checksum libp2p-peerstore 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)" = "" +"checksum libp2p-ping 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)" = "" +"checksum libp2p-ratelimit 0.1.1 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)" = "" +"checksum libp2p-relay 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)" = "" +"checksum libp2p-secio 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)" = "" +"checksum libp2p-tcp-transport 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)" = "" +"checksum libp2p-transport-timeout 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)" = "" +"checksum libp2p-websocket 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)" = "" +"checksum libp2p-yamux 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)" = "" "checksum linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "70fb39025bc7cdd76305867c4eccf2f2dcf6e9a57f5b21a93e1c2d86cd03ec9e" "checksum local-encoding 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1ceb20f39ff7ae42f3ff9795f3986b1daad821caaa1e1732a0944103a5a1a66" "checksum lock_api 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "949826a5ccf18c1b3a7c3d57692778d21768b79e46eb9dd07bfc4c2160036c54" @@ -4131,15 +4137,15 @@ dependencies = [ "checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d" "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" "checksum memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" -"checksum memorydb 0.1.1 (git+https://github.com/paritytech/parity.git)" = "" +"checksum memorydb 0.2.1 (git+https://github.com/paritytech/parity-common)" = "" "checksum mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0" "checksum mime 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0b28683d0b09bbc20be1c9b3f6f24854efb1356ffcffee08ea3f6e65596e85fa" "checksum mio 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)" = "6d771e3ef92d58a8da8df7d6976bfca9371ed1de6619d9d5a5ce5b1f29b85bfe" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" -"checksum multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)" = "" +"checksum multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)" = "" "checksum multibase 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b9c35dac080fd6e16a99924c8dfdef0af89d797dd851adab25feaffacf7850d6" -"checksum multihash 0.8.1-pre (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)" = "" -"checksum multistream-select 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)" = "" +"checksum multihash 0.8.1-pre (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)" = "" +"checksum multistream-select 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)" = "" "checksum names 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef320dab323286b50fb5cdda23f61c796a72a89998ab565ca32525c5c556f2da" "checksum nan-preserving-float 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34d4f00fcc2f4c9efa8cc971db0da9e28290e28e97af47585e48691ef10ff31f" "checksum native-tls 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f74dbadc8b43df7864539cedb7bc91345e532fdd913cfdc23ad94f4d2d40fbc0" @@ -4153,16 +4159,18 @@ dependencies = [ "checksum openssl 0.9.24 (registry+https://github.com/rust-lang/crates.io-index)" = "a3605c298474a3aa69de92d21139fb5e2a81688d308262359d85cdd0d12a7985" "checksum openssl-sys 0.9.33 (registry+https://github.com/rust-lang/crates.io-index)" = "d8abc04833dcedef24221a91852931df2f63e3369ae003134e70aff3645775cc" "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" +"checksum parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)" = "" +"checksum parity-crypto 0.1.0 (git+https://github.com/paritytech/parity-common)" = "" "checksum parity-wasm 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1c91199d14bd5b78ecade323d4a891d094799749c1b9e82d9c590c2e2849a40" "checksum parity-wordlist 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d0dec124478845b142f68b446cbee953d14d4b41f1bc0425024417720dce693" "checksum parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "149d8f5b97f3c1133e3cfcd8886449959e856b557ff281e292b733d7c69e005e" "checksum parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4d05f1349491390b1730afba60bb20d55761bef489a954546b58b4b34e1e2ac" "checksum parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "901d6514273469bb17380c1ac3f51fb3ce54be1f960e51a6f04901eba313ab8d" "checksum parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "4db1a8ccf734a7bce794cc19b3df06ed87ab2f3907036b693c68f56b4d4537fa" -"checksum patricia-trie 0.1.0 (git+https://github.com/paritytech/parity.git)" = "" +"checksum patricia-trie 0.2.1 (git+https://github.com/paritytech/parity-common)" = "" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum pkg-config 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "110d5ee3593dbb73f56294327fe5668bcc997897097cbc76b51e7aed3f52452f" -"checksum plain_hasher 0.1.0 (git+https://github.com/paritytech/parity.git)" = "" +"checksum plain_hasher 0.2.0 (git+https://github.com/paritytech/parity-common)" = "" "checksum pretty_assertions 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "28ea5118e2f41bfbc974b28d88c07621befd1fa5d6ec23549be96302a1a59dd2" "checksum proc-macro-hack 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ba8d4f9257b85eb6cdf13f055cea3190520aab1409ca2ab43493ea4820c25f0" "checksum proc-macro-hack-impl 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d5cb6f960ad471404618e9817c0e5d10b1ae74cfdf01fab89ea0641fe7fb2892" @@ -4190,7 +4198,7 @@ dependencies = [ "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum rhododendron 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3d2b4c928dfb981e491432f0809e93c99857112b0a348a93eee6b13e0bf0f0f3" "checksum ring 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6f7d28b30a72c01b458428e0ae988d4149c20d902346902be881e3edc4bb325c" -"checksum rlp 0.2.1 (git+https://github.com/paritytech/parity.git)" = "" +"checksum rlp 0.2.1 (git+https://github.com/paritytech/parity-common)" = "" "checksum rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "89db7f8dfdd5eb7ab3ac3ece7a07fd273a680b4b224cb231181280e8996f9f0b" "checksum rocksdb 0.4.5 (git+https://github.com/paritytech/rust-rocksdb)" = "" "checksum rocksdb-sys 0.3.0 (git+https://github.com/paritytech/rust-rocksdb)" = "" @@ -4200,7 +4208,7 @@ dependencies = [ "checksum rustc-hex 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2b03280c2813907a030785570c577fb27d3deec8da4c18566751ade94de0ace" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" "checksum rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a54aa04a10c68c1c4eacb4337fd883b435997ede17a9385784b990777686b09a" -"checksum rw-stream-sink 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)" = "" +"checksum rw-stream-sink 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)" = "" "checksum safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f7bf422d23a88c16d5090d455f182bc99c60af4df6a345c63428acf5129e347" "checksum safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e27a8b19b835f7aea908818e871f5cc3a5a186550c30773be987e155e8163d8f" "checksum schannel 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "85fd9df495640643ad2d00443b3d78aae69802ad488debab4f1dd52fc1806ade" @@ -4266,15 +4274,15 @@ dependencies = [ "checksum trace-time 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5aea07da6582e957c6e737eeb63a5af79e648eeeaaaba8fd9a417f1124bafa41" "checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" "checksum transaction-pool 1.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0f1fc049d9f039d3e9264f97f978309b94b5a5c56a5c18d28f91f469cef2b367" -"checksum triehash 0.1.0 (git+https://github.com/paritytech/parity.git)" = "" "checksum triehash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2033893a813c70e7d8a739ca6c36dc0a7a2c913ec718d7cbf84a3837bbe3c7ce" +"checksum triehash 0.2.0 (git+https://github.com/paritytech/parity-common)" = "" "checksum try-lock 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee2aa4715743892880f70885373966c83d73ef1b0838a664ef0c76fffd35e7c2" "checksum twox-hash 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "475352206e7a290c5fccc27624a163e8d0d115f7bb60ca18a64fc9ce056d7435" "checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" "checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d" -"checksum uint 0.1.2 (git+https://github.com/rphmeier/primitives.git?branch=compile-for-wasm)" = "" "checksum uint 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "38051a96565903d81c9a9210ce11076b2218f3b352926baa1f5f6abbdfce8273" +"checksum uint 0.3.0 (git+https://github.com/paritytech/parity-common)" = "" "checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" "checksum unicase 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "284b6d3db520d67fbe88fd778c21510d1b0ba4a551e5d0fbb023d33405f6de8a" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" @@ -4286,7 +4294,7 @@ dependencies = [ "checksum untrusted 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f392d7819dbe58833e26872f5f6f0d68b7bbbe90fc3667e98731c4a15ad9a7ae" "checksum url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f808aadd8cfec6ef90e4a14eb46f24511824d1ac596b9682703c87056c8678b7" "checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" -"checksum varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?branch=polkadot-2)" = "" +"checksum varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=6aa139a12dbea3d75d898ce0b2af7fcec129e294)" = "" "checksum vcpkg 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7ed0f6789c8a85ca41bbc1c9d175422116a9869bd1cf31bb08e1493ecce60380" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum vergen 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c3365f36c57e5df714a34be40902b27a992eeddb9996eca52d0584611cf885d" diff --git a/demo/executor/src/lib.rs b/demo/executor/src/lib.rs index 346f26d1e079e..ed028a5c20165 100644 --- a/demo/executor/src/lib.rs +++ b/demo/executor/src/lib.rs @@ -47,7 +47,7 @@ mod tests { use keyring::Keyring; use runtime_support::{Hashable, StorageValue, StorageMap}; use state_machine::{CodeExecutor, TestExternalities}; - use primitives::twox_128; + use primitives::{twox_128, KeccakHasher}; use demo_primitives::{Hash, BlockNumber, AccountId}; use runtime_primitives::traits::Header as HeaderT; use runtime_primitives::{ApplyOutcome, ApplyError, ApplyResult, MaybeUnsigned}; @@ -100,7 +100,7 @@ mod tests { #[test] fn panic_execution_with_foreign_code_gives_error() { - let mut t: TestExternalities = map![ + let mut t: TestExternalities = map![ twox_128(&>::key_for(alice())).to_vec() => vec![69u8, 0, 0, 0, 0, 0, 0, 0], twox_128(>::key()).to_vec() => vec![70u8; 8], twox_128(>::key()).to_vec() => vec![0u8; 8], @@ -119,7 +119,7 @@ mod tests { #[test] fn bad_extrinsic_with_native_equivalent_code_gives_error() { - let mut t: TestExternalities = map![ + let mut t: TestExternalities = map![ twox_128(&>::key_for(alice())).to_vec() => vec![69u8, 0, 0, 0, 0, 0, 0, 0], twox_128(>::key()).to_vec() => vec![70u8; 8], twox_128(>::key()).to_vec() => vec![0u8; 8], @@ -138,7 +138,7 @@ mod tests { #[test] fn successful_execution_with_native_equivalent_code_gives_ok() { - let mut t: TestExternalities = map![ + let mut t: TestExternalities = map![ twox_128(&>::key_for(alice())).to_vec() => vec![111u8, 0, 0, 0, 0, 0, 0, 0], twox_128(>::key()).to_vec() => vec![0u8; 8], twox_128(>::key()).to_vec() => vec![0u8; 8], @@ -161,7 +161,7 @@ mod tests { #[test] fn successful_execution_with_foreign_code_gives_ok() { - let mut t: TestExternalities = map![ + let mut t: TestExternalities = map![ twox_128(&>::key_for(alice())).to_vec() => vec![111u8, 0, 0, 0, 0, 0, 0, 0], twox_128(>::key()).to_vec() => vec![0u8; 8], twox_128(>::key()).to_vec() => vec![0u8; 8], @@ -182,7 +182,7 @@ mod tests { }); } - fn new_test_ext() -> TestExternalities { + fn new_test_ext() -> TestExternalities { use keyring::Keyring::*; let three = [3u8; 32].into(); GenesisConfig { @@ -212,7 +212,7 @@ mod tests { democracy: Some(Default::default()), council: Some(Default::default()), timestamp: Some(Default::default()), - }.build_storage().unwrap() + }.build_storage().unwrap().into() } fn construct_block(number: BlockNumber, parent_hash: Hash, state_root: Hash, extrinsics: Vec) -> (Vec, Hash) { @@ -247,6 +247,9 @@ mod tests { construct_block( 1, [69u8; 32].into(), + // Blake + // hex!("3437bf4b182ab17bb322af5c67e55f6be487a77084ad2b4e27ddac7242e4ad21").into(), + // Keccak hex!("c563199c60df7d914262b1775b284870f3a5da2f24b56d2c6288b37c815a6cd9").into(), vec![BareExtrinsic { signed: alice(), @@ -260,6 +263,9 @@ mod tests { construct_block( 2, block1().1, + // Blake + // hex!("741fcb660e6fa9f625fbcd993b49f6c1cc4040f5e0cc8727afdedf11fd3c464b").into(), + // Keccak hex!("83f71d5475f63350825b0301de322233d3711a9f3fcfd74050d1534af47a36b3").into(), vec![ BareExtrinsic { @@ -313,6 +319,9 @@ mod tests { construct_block( 1, [69u8; 32].into(), + // Blake + // hex!("2c7231a9c210a7aa4bea169d944bc4aaacd517862b244b8021236ffa7f697991").into(), + // Keccak hex!("06d026c0d687ec583660a6052de6f89acdb24ea964d06be3831c837c3c426966").into(), vec![BareExtrinsic { signed: alice(), @@ -371,7 +380,7 @@ mod tests { #[test] fn native_big_block_import_succeeds() { let mut t = new_test_ext(); - + let r = Executor::with_heap_pages(8).call(&mut t, COMPACT_CODE, "execute_block", &block1big().0, true).0; assert!(r.is_ok()); } @@ -386,7 +395,7 @@ mod tests { #[test] fn panic_execution_gives_error() { - let mut t: TestExternalities = map![ + let mut t: TestExternalities = map![ twox_128(&>::key_for(alice())).to_vec() => vec![69u8, 0, 0, 0, 0, 0, 0, 0], twox_128(>::key()).to_vec() => vec![70u8; 8], twox_128(>::key()).to_vec() => vec![0u8; 8], @@ -406,7 +415,7 @@ mod tests { #[test] fn successful_execution_gives_ok() { - let mut t: TestExternalities = map![ + let mut t: TestExternalities = map![ twox_128(&>::key_for(alice())).to_vec() => vec![111u8, 0, 0, 0, 0, 0, 0, 0], twox_128(>::key()).to_vec() => vec![0u8; 8], twox_128(>::key()).to_vec() => vec![0u8; 8], diff --git a/polkadot/api/src/full.rs b/polkadot/api/src/full.rs index 5358e1bd3a39e..7ccffecd1d772 100644 --- a/polkadot/api/src/full.rs +++ b/polkadot/api/src/full.rs @@ -30,6 +30,7 @@ use primitives::{ SessionKey, Timestamp, UncheckedExtrinsic, }; use primitives::parachain::{DutyRoster, Id as ParaId}; +use substrate_primitives::{KeccakHasher, RlpCodec}; use {BlockBuilder, PolkadotApi, LocalPolkadotApi, ErrorKind, Error, Result}; @@ -60,7 +61,7 @@ macro_rules! with_runtime { }} } -impl> BlockBuilder for ClientBlockBuilder>, Block> { +impl> BlockBuilder for ClientBlockBuilder>, Block, KeccakHasher, RlpCodec> { fn push_extrinsic(&mut self, extrinsic: UncheckedExtrinsic) -> Result<()> { self.push(extrinsic).map_err(Into::into) } @@ -71,8 +72,8 @@ impl> BlockBuilder for ClientBlockBuilder> PolkadotApi for Client>, Block> { - type BlockBuilder = ClientBlockBuilder>, Block>; +impl> PolkadotApi for Client>, Block> { + type BlockBuilder = ClientBlockBuilder>, Block, KeccakHasher, RlpCodec>; fn session_keys(&self, at: &BlockId) -> Result> { with_runtime!(self, at, ::runtime::Consensus::authorities) @@ -158,7 +159,7 @@ impl> PolkadotApi for Client> LocalPolkadotApi for Client>, Block> +impl> LocalPolkadotApi for Client>, Block> {} #[cfg(test)] @@ -184,7 +185,7 @@ mod tests { ] } - fn client() -> Client, LocalCallExecutor, NativeExecutor>, Block> { + fn client() -> Client, LocalCallExecutor, NativeExecutor>, Block> { let genesis_config = GenesisConfig { consensus: Some(ConsensusConfig { code: LocalDispatch::native_equivalent().to_vec(), diff --git a/polkadot/api/src/light.rs b/polkadot/api/src/light.rs index a281cde6e3a58..7a3a357db96db 100644 --- a/polkadot/api/src/light.rs +++ b/polkadot/api/src/light.rs @@ -27,6 +27,7 @@ use primitives::{ use runtime::Address; use primitives::parachain::{DutyRoster, Id as ParaId}; use {PolkadotApi, BlockBuilder, RemotePolkadotApi, Result, ErrorKind}; +use substrate_primitives::{KeccakHasher, RlpCodec}; /// Light block builder. TODO: make this work (efficiently) #[derive(Clone, Copy)] @@ -43,9 +44,9 @@ impl BlockBuilder for LightBlockBuilder { } /// Remote polkadot API implementation. -pub struct RemotePolkadotApiWrapper, E: CallExecutor>(pub Arc>); +pub struct RemotePolkadotApiWrapper, E: CallExecutor>(pub Arc>); -impl, E: CallExecutor> PolkadotApi for RemotePolkadotApiWrapper { +impl, E: CallExecutor> PolkadotApi for RemotePolkadotApiWrapper { type BlockBuilder = LightBlockBuilder; fn session_keys(&self, at: &BlockId) -> Result> { @@ -104,4 +105,4 @@ impl, E: CallExecutor> PolkadotApi for RemotePolkadotAp } } -impl, E: CallExecutor> RemotePolkadotApi for RemotePolkadotApiWrapper {} +impl, E: CallExecutor> RemotePolkadotApi for RemotePolkadotApiWrapper {} diff --git a/polkadot/availability-store/Cargo.toml b/polkadot/availability-store/Cargo.toml index 9a926310b04b4..fe60e9c992c98 100644 --- a/polkadot/availability-store/Cargo.toml +++ b/polkadot/availability-store/Cargo.toml @@ -10,6 +10,6 @@ parking_lot = "0.4" log = "0.3" substrate-codec = { path = "../../substrate/codec" } substrate-primitives = { path = "../../substrate/primitives" } -kvdb = { git = "https://github.com/paritytech/parity.git" } -kvdb-rocksdb = { git = "https://github.com/paritytech/parity.git" } -kvdb-memorydb = { git = "https://github.com/paritytech/parity.git" } +kvdb = { git = "https://github.com/paritytech/parity-common.git" } +kvdb-rocksdb = { git = "https://github.com/paritytech/parity-common.git" } +kvdb-memorydb = { git = "https://github.com/paritytech/parity-common.git" } diff --git a/polkadot/availability-store/src/lib.rs b/polkadot/availability-store/src/lib.rs index 33ace5794cfe7..5237ca498194d 100644 --- a/polkadot/availability-store/src/lib.rs +++ b/polkadot/availability-store/src/lib.rs @@ -66,20 +66,6 @@ pub struct Data { pub extrinsic: Option, } -fn extract_io_err(err: ::kvdb::Error) -> io::Error { - match err { - ::kvdb::Error(::kvdb::ErrorKind::Io(io_err), _) => io_err, - ::kvdb::Error(::kvdb::ErrorKind::Msg(msg), _) => io::Error::new( - io::ErrorKind::Other, - msg, - ), - x => io::Error::new( - io::ErrorKind::Other, - format!("Unexpected error variant: {:?}", x), // only necessary because of nonexaustive match. - ) - } -} - fn block_data_key(relay_parent: &Hash, candidate_hash: &Hash) -> Vec { (relay_parent, candidate_hash, 0i8).encode() } @@ -99,14 +85,13 @@ impl Store { pub fn new(config: Config) -> io::Result { let mut db_config = DatabaseConfig::with_columns(Some(columns::NUM_COLUMNS)); db_config.memory_budget = config.cache_size; - db_config.wal = true; let path = config.path.to_str().ok_or_else(|| io::Error::new( io::ErrorKind::Other, format!("Bad database path: {:?}", config.path), ))?; - let db = Database::open(&db_config, &path).map_err(extract_io_err)?; + let db = Database::open(&db_config, &path)?; Ok(Store { inner: Arc::new(db), @@ -151,7 +136,7 @@ impl Store { ); } - self.inner.write(tx).map_err(extract_io_err) + self.inner.write(tx) } /// Note that a set of candidates have been included in a finalized block with given hash and parent hash. @@ -175,7 +160,7 @@ impl Store { } } - self.inner.write(tx).map_err(extract_io_err) + self.inner.write(tx) } /// Query block data. diff --git a/polkadot/executor/Cargo.toml b/polkadot/executor/Cargo.toml index e7cfc5b77203d..3e62a0ce23b64 100644 --- a/polkadot/executor/Cargo.toml +++ b/polkadot/executor/Cargo.toml @@ -6,4 +6,5 @@ description = "Polkadot node implementation in Rust." [dependencies] substrate-executor = { path = "../../substrate/executor" } +substrate-primitives = { path = "../../substrate/primitives" } polkadot-runtime = { path = "../runtime" } diff --git a/polkadot/executor/src/lib.rs b/polkadot/executor/src/lib.rs index 82cd5cd47851c..f8fc6a238b6b8 100644 --- a/polkadot/executor/src/lib.rs +++ b/polkadot/executor/src/lib.rs @@ -19,5 +19,6 @@ extern crate polkadot_runtime; #[macro_use] extern crate substrate_executor; +extern crate substrate_primitives as primitives; native_executor_instance!(pub Executor, polkadot_runtime::api::dispatch, polkadot_runtime::VERSION, include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm")); diff --git a/polkadot/runtime/src/parachains.rs b/polkadot/runtime/src/parachains.rs index 677b86e847cc8..98cbebe36404f 100644 --- a/polkadot/runtime/src/parachains.rs +++ b/polkadot/runtime/src/parachains.rs @@ -30,7 +30,10 @@ use substrate_runtime_support::dispatch::Result; use rstd::marker::PhantomData; #[cfg(any(feature = "std", test))] -use {runtime_io, runtime_primitives}; +use runtime_primitives; + +#[cfg(any(feature = "std", test))] +use std::collections::HashMap; pub trait Trait: system::Trait + session::Trait { /// The position of the set_heads call in the block. @@ -214,8 +217,7 @@ impl Default for GenesisConfig { #[cfg(any(feature = "std", test))] impl runtime_primitives::BuildStorage for GenesisConfig { - fn build_storage(mut self) -> ::std::result::Result { - use std::collections::HashMap; + fn build_storage(mut self) -> ::std::result::Result, Vec>, String> { use codec::Encode; self.parachains.sort_unstable_by_key(|&(ref id, _, _)| id.clone()); @@ -235,15 +237,15 @@ impl runtime_primitives::BuildStorage for GenesisConfig map.insert(head_key, genesis.encode()); } - Ok(map.into()) + Ok(map) } } #[cfg(test)] mod tests { use super::*; - use runtime_io::with_externalities; - use substrate_primitives::H256; + use runtime_io::{TestExternalities, with_externalities}; + use substrate_primitives::{H256, KeccakHasher}; use runtime_primitives::BuildStorage; use runtime_primitives::traits::{HasPublicAux, Identity, BlakeTwo256}; use runtime_primitives::testing::{Digest, Header}; @@ -284,7 +286,7 @@ mod tests { type Parachains = Module; - fn new_test_ext(parachains: Vec<(Id, Vec, Vec)>) -> runtime_io::TestExternalities { + fn new_test_ext(parachains: Vec<(Id, Vec, Vec)>) -> TestExternalities { let mut t = system::GenesisConfig::::default().build_storage().unwrap(); t.extend(consensus::GenesisConfig::{ code: vec![], @@ -299,7 +301,7 @@ mod tests { parachains: parachains, phantom: PhantomData, }.build_storage().unwrap()); - t + t.into() } #[test] diff --git a/polkadot/runtime/wasm/Cargo.lock b/polkadot/runtime/wasm/Cargo.lock index 7f6ce977734eb..b452d6cfaddce 100644 --- a/polkadot/runtime/wasm/Cargo.lock +++ b/polkadot/runtime/wasm/Cargo.lock @@ -1,16 +1,3 @@ -[[package]] -name = "aho-corasick" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "ansi_term" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "arrayvec" version = "0.4.7" @@ -19,16 +6,6 @@ dependencies = [ "nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "atty" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.41 (registry+https://github.com/rust-lang/crates.io-index)", - "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "base58" version = "0.1.0" @@ -124,15 +101,6 @@ dependencies = [ "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "env_logger" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "environmental" version = "0.1.0" @@ -149,27 +117,6 @@ dependencies = [ "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ethcore-bytes" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity.git#dec390a89fe038337399315daf15e628ffbb4d8e" - -[[package]] -name = "ethcore-logger" -version = "1.12.0" -source = "git+https://github.com/paritytech/parity.git#dec390a89fe038337399315daf15e628ffbb4d8e" -dependencies = [ - "ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", - "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "ethereum-types" version = "0.3.2" @@ -194,17 +141,19 @@ dependencies = [ [[package]] name = "fixed-hash" -version = "0.1.3" -source = "git+https://github.com/rphmeier/primitives.git?branch=compile-for-wasm#8dc457899afdaf968ff7f16140b03d1e37b01d71" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.41 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "fixed-hash" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.2.2" +source = "git+https://github.com/paritytech/parity-common#26baede0d9cd8cdad3511d75408228051dbc23dd" dependencies = [ "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.41 (registry+https://github.com/rust-lang/crates.io-index)", @@ -233,11 +182,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "hashdb" -version = "0.1.1" -source = "git+https://github.com/paritytech/parity.git#dec390a89fe038337399315daf15e628ffbb4d8e" +version = "0.2.1" +source = "git+https://github.com/paritytech/parity-common#26baede0d9cd8cdad3511d75408228051dbc23dd" dependencies = [ "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -280,15 +228,6 @@ dependencies = [ "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "keccak-hash" -version = "0.1.2" -source = "git+https://github.com/paritytech/parity.git#dec390a89fe038337399315daf15e628ffbb4d8e" -dependencies = [ - "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "lazy_static" version = "0.2.11" @@ -320,14 +259,6 @@ dependencies = [ "cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "memchr" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.41 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "memoffset" version = "0.2.1" @@ -340,16 +271,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "memorydb" -version = "0.1.1" -source = "git+https://github.com/paritytech/parity.git#dec390a89fe038337399315daf15e628ffbb4d8e" +version = "0.2.1" +source = "git+https://github.com/paritytech/parity-common#26baede0d9cd8cdad3511d75408228051dbc23dd" dependencies = [ "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hashdb 0.1.1 (git+https://github.com/paritytech/parity.git)", + "hashdb 0.2.1 (git+https://github.com/paritytech/parity-common)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "keccak-hash 0.1.2 (git+https://github.com/paritytech/parity.git)", - "plain_hasher 0.1.0 (git+https://github.com/paritytech/parity.git)", - "rlp 0.2.1 (git+https://github.com/paritytech/parity.git)", + "plain_hasher 0.2.0 (git+https://github.com/paritytech/parity-common)", + "rlp 0.2.1 (git+https://github.com/paritytech/parity-common)", ] [[package]] @@ -383,6 +312,11 @@ dependencies = [ "stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parity-bytes" +version = "0.1.0" +source = "git+https://github.com/paritytech/parity-common#26baede0d9cd8cdad3511d75408228051dbc23dd" + [[package]] name = "parity-wasm" version = "0.31.0" @@ -400,15 +334,6 @@ dependencies = [ "parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "parking_lot" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "parking_lot_core" version = "0.2.14" @@ -422,29 +347,22 @@ dependencies = [ [[package]] name = "patricia-trie" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity.git#dec390a89fe038337399315daf15e628ffbb4d8e" +version = "0.2.1" +source = "git+https://github.com/paritytech/parity-common#26baede0d9cd8cdad3511d75408228051dbc23dd" dependencies = [ "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethcore-bytes 0.1.0 (git+https://github.com/paritytech/parity.git)", - "ethcore-logger 1.12.0 (git+https://github.com/paritytech/parity.git)", - "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hashdb 0.1.1 (git+https://github.com/paritytech/parity.git)", - "keccak-hash 0.1.2 (git+https://github.com/paritytech/parity.git)", + "hashdb 0.2.1 (git+https://github.com/paritytech/parity-common)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "memorydb 0.1.1 (git+https://github.com/paritytech/parity.git)", + "parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.1 (git+https://github.com/paritytech/parity.git)", - "triehash 0.1.0 (git+https://github.com/paritytech/parity.git)", ] [[package]] name = "plain_hasher" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity.git#dec390a89fe038337399315daf15e628ffbb4d8e" +version = "0.2.0" +source = "git+https://github.com/paritytech/parity-common#26baede0d9cd8cdad3511d75408228051dbc23dd" dependencies = [ "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -565,39 +483,6 @@ dependencies = [ "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "redox_syscall" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "redox_termios" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "regex" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "regex-syntax" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "ring" version = "0.12.1" @@ -613,7 +498,7 @@ dependencies = [ [[package]] name = "rlp" version = "0.2.1" -source = "git+https://github.com/paritytech/parity.git#dec390a89fe038337399315daf15e628ffbb4d8e" +source = "git+https://github.com/paritytech/parity-common#26baede0d9cd8cdad3511d75408228051dbc23dd" dependencies = [ "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -736,15 +621,21 @@ dependencies = [ "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "fixed-hash 0.1.3 (git+https://github.com/rphmeier/primitives.git?branch=compile-for-wasm)", + "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fixed-hash 0.2.2 (git+https://github.com/paritytech/parity-common)", + "hashdb 0.2.1 (git+https://github.com/paritytech/parity-common)", + "patricia-trie 0.2.1 (git+https://github.com/paritytech/parity-common)", + "plain_hasher 0.2.0 (git+https://github.com/paritytech/parity-common)", + "rlp 0.2.1 (git+https://github.com/paritytech/parity-common)", "rustc-hex 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.64 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.64 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-codec 0.1.0", "substrate-codec-derive 0.1.0", "substrate-runtime-std 0.1.0", + "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "twox-hash 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "uint 0.1.2 (git+https://github.com/rphmeier/primitives.git?branch=compile-for-wasm)", + "uint 0.2.2 (git+https://github.com/paritytech/parity-common)", "wasmi 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -981,15 +872,16 @@ name = "substrate-state-machine" version = "0.1.0" dependencies = [ "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hashdb 0.1.1 (git+https://github.com/paritytech/parity.git)", + "hashdb 0.2.1 (git+https://github.com/paritytech/parity-common)", + "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "memorydb 0.1.1 (git+https://github.com/paritytech/parity.git)", + "memorydb 0.2.1 (git+https://github.com/paritytech/parity-common)", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "patricia-trie 0.1.0 (git+https://github.com/paritytech/parity.git)", + "patricia-trie 0.2.1 (git+https://github.com/paritytech/parity-common)", + "rlp 0.2.1 (git+https://github.com/paritytech/parity-common)", "substrate-primitives 0.1.0", - "triehash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "triehash 0.2.0 (git+https://github.com/paritytech/parity-common)", ] [[package]] @@ -1002,35 +894,6 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "termion" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.41 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "thread_local" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "time" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.41 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "tiny-keccak" version = "1.4.2" @@ -1041,24 +904,23 @@ dependencies = [ [[package]] name = "triehash" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity.git#dec390a89fe038337399315daf15e628ffbb4d8e" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "keccak-hash 0.1.2 (git+https://github.com/paritytech/parity.git)", - "rlp 0.2.1 (git+https://github.com/paritytech/parity.git)", + "keccak-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "triehash" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.2.0" +source = "git+https://github.com/paritytech/parity-common#26baede0d9cd8cdad3511d75408228051dbc23dd" dependencies = [ "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "keccak-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hashdb 0.2.1 (git+https://github.com/paritytech/parity-common)", + "rlp 0.2.1 (git+https://github.com/paritytech/parity-common)", ] [[package]] @@ -1069,28 +931,23 @@ dependencies = [ "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ucd-util" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "uint" -version = "0.1.2" -source = "git+https://github.com/rphmeier/primitives.git?branch=compile-for-wasm#8dc457899afdaf968ff7f16140b03d1e37b01d71" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "uint" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.2.2" +source = "git+https://github.com/paritytech/parity-common#26baede0d9cd8cdad3511d75408228051dbc23dd" dependencies = [ "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1113,11 +970,6 @@ name = "untrusted" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "utf8-ranges" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "void" version = "1.0.2" @@ -1154,10 +1006,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] -"checksum aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6531d44de723825aa81398a6415283229725a00fa30713812ab9323faa82fc4" -"checksum ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6b3568b48b7cefa6b8ce125f9bb4989e52fbcc29ebea88df04cc7c5f12f70455" "checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef" -"checksum atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2fc4a1aa4c24c0718a250f0681885c1af91419d242f29eb8f2ab28502d80dbd1" "checksum base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" "checksum bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789" "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" @@ -1170,44 +1019,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9" "checksum crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a2f4a431c5c9f662e1200b7c7f02c34e91361150e382089a8f2dec3ba680cbda" "checksum elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "88d4851b005ef16de812ea9acdb7bece2f0a40dd86c07b85631d7dafa54537bb" -"checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" "checksum ethbloom 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a93a43ce2e9f09071449da36bfa7a1b20b950ee344b6904ff23de493b03b386" -"checksum ethcore-bytes 0.1.0 (git+https://github.com/paritytech/parity.git)" = "" -"checksum ethcore-logger 1.12.0 (git+https://github.com/paritytech/parity.git)" = "" "checksum ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c48729b8aea8aedb12cf4cb2e5cef439fdfe2dda4a89e47eeebd15778ef53b6" "checksum ethereum-types-serialize 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ac59a21a9ce98e188f3dace9eb67a6c4a3c67ec7fbc7218cb827852679dc002" -"checksum fixed-hash 0.1.3 (git+https://github.com/rphmeier/primitives.git?branch=compile-for-wasm)" = "" "checksum fixed-hash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b18d6fd718fb4396e7a9c93ac59ba7143501467ca7a143c145b5555a571d5576" +"checksum fixed-hash 0.2.2 (git+https://github.com/paritytech/parity-common)" = "" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" -"checksum hashdb 0.1.1 (git+https://github.com/paritytech/parity.git)" = "" +"checksum hashdb 0.2.1 (git+https://github.com/paritytech/parity-common)" = "" "checksum heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" "checksum hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4da5f0e01bd8a71a224a4eedecaacfcabda388dbb7a80faf04d3514287572d95" "checksum hex-literal-impl 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1d340b6514f232f6db1bd16db65302a5278a04fef9ce867cb932e7e5fa21130a" "checksum integer-sqrt 0.1.0 (git+https://github.com/paritytech/integer-sqrt-rs.git)" = "" "checksum keccak-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b7f51f30d7986536accaec4a6a288008dfb3dbffe8a2863a65292bc395a3ae7" -"checksum keccak-hash 0.1.2 (git+https://github.com/paritytech/parity.git)" = "" "checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" "checksum lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e6412c5e2ad9584b0b8e979393122026cdd6d2a80b933f890dcd694ddbe73739" "checksum libc 0.2.41 (registry+https://github.com/rust-lang/crates.io-index)" = "ac8ebf8343a981e2fa97042b14768f02ed3e1d602eac06cae6166df3c8ced206" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" "checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2" -"checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d" "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" "checksum memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" -"checksum memorydb 0.1.1 (git+https://github.com/paritytech/parity.git)" = "" +"checksum memorydb 0.2.1 (git+https://github.com/paritytech/parity-common)" = "" "checksum nan-preserving-float 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34d4f00fcc2f4c9efa8cc971db0da9e28290e28e97af47585e48691ef10ff31f" "checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" "checksum num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "775393e285254d2f5004596d69bb8bc1149754570dcc08cf30cabeba67955e28" "checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" +"checksum parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)" = "" "checksum parity-wasm 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1c91199d14bd5b78ecade323d4a891d094799749c1b9e82d9c590c2e2849a40" "checksum parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "149d8f5b97f3c1133e3cfcd8886449959e856b557ff281e292b733d7c69e005e" -"checksum parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4d05f1349491390b1730afba60bb20d55761bef489a954546b58b4b34e1e2ac" "checksum parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "4db1a8ccf734a7bce794cc19b3df06ed87ab2f3907036b693c68f56b4d4537fa" -"checksum patricia-trie 0.1.0 (git+https://github.com/paritytech/parity.git)" = "" -"checksum plain_hasher 0.1.0 (git+https://github.com/paritytech/parity.git)" = "" +"checksum patricia-trie 0.2.1 (git+https://github.com/paritytech/parity-common)" = "" +"checksum plain_hasher 0.2.0 (git+https://github.com/paritytech/parity-common)" = "" "checksum proc-macro-hack 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ba8d4f9257b85eb6cdf13f055cea3190520aab1409ca2ab43493ea4820c25f0" "checksum proc-macro-hack-impl 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d5cb6f960ad471404618e9817c0e5d10b1ae74cfdf01fab89ea0641fe7fb2892" "checksum proc-macro2 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1fa93823f53cfd0f5ac117b189aed6cfdfb2cfc0a9d82e956dd7927595ed7d46" @@ -1216,12 +1060,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5" "checksum rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b614fe08b6665cb9a231d07ac1364b0ef3cb3698f1239ee0c4c3a88a524f54c8" "checksum rayon-core 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9d24ad214285a7729b174ed6d3bcfcb80177807f959d95fafd5bfc5c4f201ac8" -"checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" -"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" -"checksum regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384" -"checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7" "checksum ring 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6f7d28b30a72c01b458428e0ae988d4149c20d902346902be881e3edc4bb325c" -"checksum rlp 0.2.1 (git+https://github.com/paritytech/parity.git)" = "" +"checksum rlp 0.2.1 (git+https://github.com/paritytech/parity-common)" = "" "checksum rlp 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "89db7f8dfdd5eb7ab3ac3ece7a07fd273a680b4b224cb231181280e8996f9f0b" "checksum rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0ceb8ce7a5e520de349e1fa172baeba4a9e8d5ef06c47471863530bc4972ee1e" "checksum rustc-hex 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2b03280c2813907a030785570c577fb27d3deec8da4c18566751ade94de0ace" @@ -1235,20 +1075,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum smallvec 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "211a489e65e94b103926d2054ae515a1cdb5d515ea0ef414fee23b7e043ce748" "checksum stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "15132e0e364248108c5e2c02e3ab539be8d6f5d52a01ca9bbf27ed657316f02b" "checksum syn 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6dfd71b2be5a58ee30a6f8ea355ba8290d397131c00dfa55c3d34e6e13db5101" -"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" -"checksum thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279ef31c19ededf577bfd12dfae728040a21f635b06a24cd670ff510edd38963" -"checksum time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "d825be0eb33fda1a7e68012d51e9c7f451dc1a69391e7fdc197060bb8c56667b" "checksum tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e9175261fbdb60781fcd388a4d6cc7e14764a2b629a7ad94abb439aed223a44f" -"checksum triehash 0.1.0 (git+https://github.com/paritytech/parity.git)" = "" "checksum triehash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2033893a813c70e7d8a739ca6c36dc0a7a2c913ec718d7cbf84a3837bbe3c7ce" +"checksum triehash 0.2.0 (git+https://github.com/paritytech/parity-common)" = "" "checksum twox-hash 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "475352206e7a290c5fccc27624a163e8d0d115f7bb60ca18a64fc9ce056d7435" -"checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d" -"checksum uint 0.1.2 (git+https://github.com/rphmeier/primitives.git?branch=compile-for-wasm)" = "" "checksum uint 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "38051a96565903d81c9a9210ce11076b2218f3b352926baa1f5f6abbdfce8273" +"checksum uint 0.2.2 (git+https://github.com/paritytech/parity-common)" = "" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" "checksum untrusted 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f392d7819dbe58833e26872f5f6f0d68b7bbbe90fc3667e98731c4a15ad9a7ae" -"checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum wasmi 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "522fe3fdd44a56f25cd5ddcd8ccdb1cf2e982ceb28fcb00f41d8a018ae5245a8" "checksum winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "04e3bd221fcbe8a271359c04f21a76db7d0c6028862d1bb5512d85e1e2eb5bb3" diff --git a/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm b/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm index 055036f6662de..8e1771edf57bf 100644 Binary files a/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm and b/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm differ diff --git a/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.wasm b/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.wasm index 6bc54e865541b..292e560248502 100755 Binary files a/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.wasm and b/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.wasm differ diff --git a/polkadot/service/src/lib.rs b/polkadot/service/src/lib.rs index 3814a1c98da38..4e59a22ca2b1f 100644 --- a/polkadot/service/src/lib.rs +++ b/polkadot/service/src/lib.rs @@ -53,6 +53,7 @@ use client::Client; use polkadot_network::{PolkadotProtocol, consensus::ConsensusNetwork}; use tokio::runtime::TaskExecutor; use service::FactoryFullConfiguration; +use primitives::{KeccakHasher, RlpCodec}; pub use service::{Roles, PruningMode, ExtrinsicPoolOptions, ErrorKind, Error, ComponentBlock, LightComponents, FullComponents}; @@ -69,9 +70,9 @@ pub trait Components: service::Components { /// Polkadot API. type Api: 'static + PolkadotApi + Send + Sync; /// Client backend. - type Backend: 'static + client::backend::Backend; + type Backend: 'static + client::backend::Backend; /// Client executor. - type Executor: 'static + client::CallExecutor + Send + Sync; + type Executor: 'static + client::CallExecutor + Send + Sync; } impl Components for service::LightComponents { @@ -271,8 +272,8 @@ pub struct TransactionPoolAdapter where A: Send + Sync, E: Send + Sync impl TransactionPoolAdapter where A: Send + Sync, - B: client::backend::Backend + Send + Sync, - E: client::CallExecutor + Send + Sync, + B: client::backend::Backend + Send + Sync, + E: client::CallExecutor + Send + Sync, { fn best_block_id(&self) -> Option { self.client.info() @@ -286,8 +287,8 @@ impl TransactionPoolAdapter impl network::TransactionPool for TransactionPoolAdapter where - B: client::backend::Backend + Send + Sync, - E: client::CallExecutor + Send + Sync, + B: client::backend::Backend + Send + Sync, + E: client::CallExecutor + Send + Sync, A: polkadot_api::PolkadotApi + Send + Sync, { fn transactions(&self) -> Vec<(Hash, Vec)> { @@ -338,8 +339,8 @@ impl network::TransactionPool for TransactionPoolAdapter service::ExtrinsicPool for TransactionPoolAdapter where - B: client::backend::Backend + Send + Sync + 'static, - E: client::CallExecutor + Send + Sync + 'static, + B: client::backend::Backend + Send + Sync + 'static, + E: client::CallExecutor + Send + Sync + 'static, A: polkadot_api::PolkadotApi + Send + Sync + 'static, { type Api = TransactionPool; diff --git a/polkadot/transaction-pool/src/lib.rs b/polkadot/transaction-pool/src/lib.rs index 96ad1050d95d0..3ba340921ac8a 100644 --- a/polkadot/transaction-pool/src/lib.rs +++ b/polkadot/transaction-pool/src/lib.rs @@ -184,12 +184,10 @@ impl txpool::Scoring for Scoring { } fn should_replace(&self, old: &VerifiedTransaction, _new: &VerifiedTransaction) -> Choice { - if old.is_fully_verified() { - // Don't allow new transactions if we are reaching the limit. - Choice::RejectNew - } else { - // Always replace not fully verified transactions. - Choice::ReplaceOld + // Always replace not fully verified transactions. + match old.is_fully_verified() { + true => Choice::RejectNew, + false => Choice::ReplaceOld } } } diff --git a/substrate/client/Cargo.toml b/substrate/client/Cargo.toml index 5b347395763b7..59ab16ba4811c 100644 --- a/substrate/client/Cargo.toml +++ b/substrate/client/Cargo.toml @@ -13,6 +13,7 @@ hex-literal = "0.1" futures = "0.1.17" ed25519 = { path = "../ed25519" } slog = "^2" +heapsize = "0.4" substrate-bft = { path = "../bft" } substrate-codec = { path = "../codec" } substrate-executor = { path = "../executor" } @@ -23,6 +24,9 @@ substrate-runtime-primitives = { path = "../runtime/primitives" } substrate-state-machine = { path = "../state-machine" } substrate-keyring = { path = "../../substrate/keyring" } substrate-telemetry = { path = "../telemetry" } +hashdb = { git = "https://github.com/paritytech/parity-common" } +patricia-trie = { git = "https://github.com/paritytech/parity-common" } +rlp = { git = "https://github.com/paritytech/parity-common" } [dev-dependencies] substrate-test-client = { path = "../test-client" } diff --git a/substrate/client/db/Cargo.toml b/substrate/client/db/Cargo.toml index 52805843aa7db..6fc8242335ac4 100644 --- a/substrate/client/db/Cargo.toml +++ b/substrate/client/db/Cargo.toml @@ -6,12 +6,10 @@ authors = ["Parity Technologies "] [dependencies] parking_lot = "0.4" log = "0.3" -kvdb = { git = "https://github.com/paritytech/parity.git" } -kvdb-rocksdb = { git = "https://github.com/paritytech/parity.git" } -ethereum-types = "0.3" -hashdb = { git = "https://github.com/paritytech/parity.git" } -patricia-trie = { git = "https://github.com/paritytech/parity.git" } -memorydb = { git = "https://github.com/paritytech/parity.git" } +kvdb = { git = "https://github.com/paritytech/parity-common" } +kvdb-rocksdb = { git = "https://github.com/paritytech/parity-common" } +hashdb = { git = "https://github.com/paritytech/parity-common" } +memorydb = { git = "https://github.com/paritytech/parity-common" } substrate-primitives = { path = "../../../substrate/primitives" } substrate-runtime-primitives = { path = "../../../substrate/runtime/primitives" } substrate-client = { path = "../../../substrate/client" } @@ -23,4 +21,4 @@ substrate-executor = { path = "../../../substrate/executor" } substrate-state-db = { path = "../../../substrate/state-db" } [dev-dependencies] -kvdb-memorydb = { git = "https://github.com/paritytech/parity.git" } +kvdb-memorydb = { git = "https://github.com/paritytech/parity-common" } diff --git a/substrate/client/db/src/lib.rs b/substrate/client/db/src/lib.rs index 46ab7e654b385..2fa5fb61515ef 100644 --- a/substrate/client/db/src/lib.rs +++ b/substrate/client/db/src/lib.rs @@ -46,19 +46,21 @@ mod utils; use std::sync::Arc; use std::path::PathBuf; +use std::io; use codec::{Decode, Encode}; +use hashdb::Hasher; use kvdb::{KeyValueDB, DBTransaction}; use memorydb::MemoryDB; use parking_lot::RwLock; -use primitives::{H256, AuthorityId}; +use primitives::{H256, AuthorityId, KeccakHasher, RlpCodec}; use runtime_primitives::generic::BlockId; use runtime_primitives::bft::Justification; use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, As, Hash, HashFor, NumberFor, Zero}; use runtime_primitives::BuildStorage; use state_machine::backend::Backend as StateBackend; use executor::RuntimeInfo; -use state_machine::{CodeExecutor, TrieH256, DBValue, ExecutionStrategy}; +use state_machine::{CodeExecutor, DBValue, ExecutionStrategy}; use utils::{Meta, db_err, meta_keys, number_to_db_key, open_database, read_db, read_id, read_meta}; use state_db::StateDb; pub use state_db::PruningMode; @@ -66,7 +68,7 @@ pub use state_db::PruningMode; const FINALIZATION_WINDOW: u64 = 32; /// DB-backed patricia trie state, transaction type is an overlay of changes to commit. -pub type DbState = state_machine::TrieBackend; +pub type DbState = state_machine::TrieBackend; /// Database settings. pub struct DatabaseSettings { @@ -87,7 +89,7 @@ pub fn new_client( ) -> Result, client::LocalCallExecutor, E>, Block>, client::error::Error> where Block: BlockT, - E: CodeExecutor + RuntimeInfo, + E: CodeExecutor + RuntimeInfo, S: BuildStorage, { let backend = Arc::new(Backend::new(settings, FINALIZATION_WINDOW)?); @@ -116,7 +118,7 @@ struct PendingBlock { struct StateMetaDb<'a>(&'a KeyValueDB); impl<'a> state_db::MetaDb for StateMetaDb<'a> { - type Error = kvdb::Error; + type Error = io::Error; fn get_meta(&self, key: &[u8]) -> Result>, Self::Error> { self.0.get(columns::STATE_META, key).map(|r| r.map(|v| v.to_vec())) @@ -215,13 +217,16 @@ impl client::blockchain::Backend for BlockchainDb { } /// Database transaction -pub struct BlockImportOperation { +pub struct BlockImportOperation { old_state: DbState, - updates: MemoryDB, + updates: MemoryDB, pending_block: Option>, } -impl client::backend::BlockImportOperation for BlockImportOperation { +impl client::backend::BlockImportOperation +for BlockImportOperation +where Block: BlockT, +{ type State = DbState; fn state(&self) -> Result, client::error::Error> { @@ -243,7 +248,7 @@ impl client::backend::BlockImportOperation for BlockImport // currently authorities are not cached on full nodes } - fn update_storage(&mut self, update: MemoryDB) -> Result<(), client::error::Error> { + fn update_storage(&mut self, update: MemoryDB) -> Result<(), client::error::Error> { self.updates = update; Ok(()) } @@ -261,15 +266,15 @@ struct StorageDb { pub state_db: StateDb, } -impl state_machine::Storage for StorageDb { - fn get(&self, key: &TrieH256) -> Result, String> { +impl state_machine::Storage for StorageDb { + fn get(&self, key: &H256) -> Result, String> { self.state_db.get(&key.0.into(), self).map(|r| r.map(|v| DBValue::from_slice(&v))) .map_err(|e| format!("Database backend error: {:?}", e)) } } impl state_db::HashDb for StorageDb { - type Error = kvdb::Error; + type Error = io::Error; type Hash = H256; fn get(&self, key: &H256) -> Result>, Self::Error> { @@ -305,7 +310,7 @@ impl Backend { fn from_kvdb(db: Arc, pruning: PruningMode, finalization_window: u64) -> Result { let blockchain = BlockchainDb::new(db.clone())?; - let map_e = |e: state_db::Error| ::client::error::Error::from(format!("State database error: {:?}", e)); + let map_e = |e: state_db::Error| ::client::error::Error::from(format!("State database error: {:?}", e)); let state_db: StateDb = StateDb::new(pruning, &StateMetaDb(&*db)).map_err(map_e)?; let storage_db = StorageDb { db, @@ -335,8 +340,8 @@ fn apply_state_commit(transaction: &mut DBTransaction, commit: state_db::CommitS } } -impl client::backend::Backend for Backend { - type BlockImportOperation = BlockImportOperation; +impl client::backend::Backend for Backend where Block: BlockT { + type BlockImportOperation = BlockImportOperation; type Blockchain = BlockchainDb; type State = DbState; @@ -450,14 +455,14 @@ impl client::backend::Backend for Backend { } self.blockchain.header(block).and_then(|maybe_hdr| maybe_hdr.map(|hdr| { - let root: TrieH256 = TrieH256::from_slice(hdr.state_root().as_ref()); + let root: H256 = H256::from_slice(hdr.state_root().as_ref()); DbState::with_storage(self.storage.clone(), root) }).ok_or_else(|| client::error::ErrorKind::UnknownBlock(format!("{:?}", block)).into())) } } -impl client::backend::LocalBackend for Backend -{} +impl client::backend::LocalBackend for Backend +where Block: BlockT {} #[cfg(test)] mod tests { diff --git a/substrate/client/db/src/utils.rs b/substrate/client/db/src/utils.rs index ea5a8f2e77a27..cc735950dba3d 100644 --- a/substrate/client/db/src/utils.rs +++ b/substrate/client/db/src/utils.rs @@ -18,8 +18,9 @@ //! full and light storages. use std::sync::Arc; +use std::io; -use kvdb::{self, KeyValueDB, DBTransaction}; +use kvdb::{KeyValueDB, DBTransaction}; use kvdb_rocksdb::{Database, DatabaseConfig}; use client; @@ -83,20 +84,15 @@ pub fn db_key_to_number(key: &[u8]) -> client::error::Result where N: As client::error::Error { +pub fn db_err(err: io::Error) -> client::error::Error { use std::error::Error; - match err.kind() { - &kvdb::ErrorKind::Io(ref err) => client::error::ErrorKind::Backend(err.description().into()).into(), - &kvdb::ErrorKind::Msg(ref m) => client::error::ErrorKind::Backend(m.clone()).into(), - _ => client::error::ErrorKind::Backend("Unknown backend error".into()).into(), - } + client::error::ErrorKind::Backend(err.description().into()).into() } /// Open RocksDB database. pub fn open_database(config: &DatabaseSettings, db_type: &str) -> client::error::Result> { let mut db_config = DatabaseConfig::with_columns(Some(NUM_COLUMNS)); db_config.memory_budget = config.cache_size; - db_config.wal = true; let path = config.path.to_str().ok_or_else(|| client::error::ErrorKind::Backend("Invalid database path".into()))?; let db = Database::open(&db_config, &path).map_err(db_err)?; diff --git a/substrate/client/src/backend.rs b/substrate/client/src/backend.rs index 8de27a39b4645..4509f3d19019a 100644 --- a/substrate/client/src/backend.rs +++ b/substrate/client/src/backend.rs @@ -22,11 +22,18 @@ use runtime_primitives::bft::Justification; use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{Block as BlockT, NumberFor}; use state_machine::backend::Backend as StateBackend; +use patricia_trie::NodeCodec; +use hashdb::Hasher; /// Block insertion operation. Keeps hold if the inserted block state and data. -pub trait BlockImportOperation { +pub trait BlockImportOperation +where + Block: BlockT, + H: Hasher, + C: NodeCodec, +{ /// Associated state backend type. - type State: StateBackend; + type State: StateBackend; /// Returns pending state. Returns None for backends with locally-unavailable state data. fn state(&self) -> error::Result>; @@ -43,7 +50,7 @@ pub trait BlockImportOperation { /// has been used to check justification of this block). fn update_authorities(&mut self, authorities: Vec); /// Inject storage data into the database. - fn update_storage(&mut self, update: ::Transaction) -> error::Result<()>; + fn update_storage(&mut self, update: >::Transaction) -> error::Result<()>; /// Inject storage data into the database replacing any existing data. fn reset_storage, Vec)>>(&mut self, iter: I) -> error::Result<()>; } @@ -56,13 +63,18 @@ pub trait BlockImportOperation { /// /// The same applies for live `BlockImportOperation`s: while an import operation building on a parent `P` /// is alive, the state for `P` should not be pruned. -pub trait Backend: Send + Sync { +pub trait Backend: Send + Sync +where + Block: BlockT, + H: Hasher, + C: NodeCodec, +{ /// Associated block insertion operation type. - type BlockImportOperation: BlockImportOperation; + type BlockImportOperation: BlockImportOperation; /// Associated blockchain backend type. type Blockchain: ::blockchain::Backend; /// Associated state backend type. - type State: StateBackend; + type State: StateBackend; /// Begin a new block insertion transaction with given parent block id. /// When constructing the genesis, this is called with all-zero hash. @@ -79,7 +91,17 @@ pub trait Backend: Send + Sync { } /// Mark for all Backend implementations, that are making use of state data, stored locally. -pub trait LocalBackend: Backend {} +pub trait LocalBackend: Backend +where + Block: BlockT, + H: Hasher, + C: NodeCodec, +{} /// Mark for all Backend implementations, that are fetching required state data from remote nodes. -pub trait RemoteBackend: Backend {} +pub trait RemoteBackend: Backend +where + Block: BlockT, + H: Hasher, + C: NodeCodec, +{} diff --git a/substrate/client/src/block_builder.rs b/substrate/client/src/block_builder.rs index bc5c29a37f86d..30216f4157f27 100644 --- a/substrate/client/src/block_builder.rs +++ b/substrate/client/src/block_builder.rs @@ -23,12 +23,20 @@ use runtime_primitives::traits::{Header as HeaderT, Hash, Block as BlockT, One, use runtime_primitives::generic::BlockId; use {backend, error, Client, CallExecutor}; use runtime_primitives::{ApplyResult, ApplyOutcome}; +use patricia_trie::NodeCodec; +use primitives::{KeccakHasher, RlpCodec}; +use hashdb::Hasher; +use rlp::Encodable; /// Utility for building new (valid) blocks from a stream of extrinsics. -pub struct BlockBuilder where - B: backend::Backend, - E: CallExecutor + Clone, +pub struct BlockBuilder +where + B: backend::Backend, + E: CallExecutor + Clone, Block: BlockT, + H: Hasher, + H::Out: Encodable + Ord, + C: NodeCodec, { header: ::Header, extrinsics: Vec<::Extrinsic>, @@ -37,9 +45,10 @@ pub struct BlockBuilder where changes: state_machine::OverlayedChanges, } -impl BlockBuilder where - B: backend::Backend, - E: CallExecutor + Clone, +impl BlockBuilder +where + B: backend::Backend, + E: CallExecutor + Clone, Block: BlockT, { /// Create a new instance of builder from the given client, building on the latest block. diff --git a/substrate/client/src/call_executor.rs b/substrate/client/src/call_executor.rs index ac561b5a549a3..6da6d0a04f00b 100644 --- a/substrate/client/src/call_executor.rs +++ b/substrate/client/src/call_executor.rs @@ -15,12 +15,17 @@ // along with Polkadot. If not, see . use std::sync::Arc; +use std::cmp::Ord; use runtime_primitives::generic::BlockId; use runtime_primitives::traits::Block as BlockT; -use state_machine::{self, OverlayedChanges, Ext, +use state_machine::{self, OverlayedChanges, Ext, CodeExecutor, ExecutionManager, native_when_possible}; use runtime_io::Externalities; use executor::{RuntimeVersion, RuntimeInfo}; +use patricia_trie::NodeCodec; +use primitives::{KeccakHasher, RlpCodec}; +use hashdb::Hasher; +use rlp::Encodable; use backend; use error; @@ -35,7 +40,13 @@ pub struct CallResult { } /// Method call executor. -pub trait CallExecutor { +pub trait CallExecutor +where + B: BlockT, + H: Hasher, + H::Out: Ord + Encodable, + C: NodeCodec, +{ /// Externalities error type. type Error: state_machine::Error; @@ -57,7 +68,7 @@ pub trait CallExecutor { /// /// No changes are made. fn call_at_state< - S: state_machine::Backend, + S: state_machine::Backend, F: FnOnce(Result, Self::Error>, Result, Self::Error>) -> Result, Self::Error>, >(&self, state: &S, @@ -70,7 +81,7 @@ pub trait CallExecutor { /// Execute a call to a contract on top of given state, gathering execution proof. /// /// No changes are made. - fn prove_at_state(&self, + fn prove_at_state>(&self, state: S, overlay: &mut OverlayedChanges, method: &str, @@ -104,11 +115,11 @@ impl Clone for LocalCallExecutor where E: Clone { } } -impl CallExecutor for LocalCallExecutor - where - B: backend::LocalBackend, - E: CodeExecutor + RuntimeInfo, - Block: BlockT, +impl CallExecutor for LocalCallExecutor +where + B: backend::LocalBackend, + E: CodeExecutor + RuntimeInfo, + Block: BlockT, { type Error = E::Error; @@ -140,7 +151,7 @@ impl CallExecutor for LocalCallExecutor } fn call_at_state< - S: state_machine::Backend, + S: state_machine::Backend, F: FnOnce(Result, Self::Error>, Result, Self::Error>) -> Result, Self::Error>, >(&self, state: &S, @@ -159,7 +170,7 @@ impl CallExecutor for LocalCallExecutor ).map_err(Into::into) } - fn prove_at_state(&self, + fn prove_at_state>(&self, state: S, changes: &mut OverlayedChanges, method: &str, diff --git a/substrate/client/src/client.rs b/substrate/client/src/client.rs index 4ae139c7294d5..2bd8e9f8a6863 100644 --- a/substrate/client/src/client.rs +++ b/substrate/client/src/client.rs @@ -23,6 +23,7 @@ use primitives::AuthorityId; use runtime_primitives::{bft::Justification, generic::{BlockId, SignedBlock, Block as RuntimeBlock}}; use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, Zero, One, As, NumberFor}; use runtime_primitives::BuildStorage; +use primitives::{KeccakHasher, RlpCodec}; use primitives::storage::{StorageKey, StorageData}; use codec::Decode; use state_machine::{ @@ -163,9 +164,9 @@ impl JustifiedHeader { pub fn new_in_mem( executor: E, genesis_storage: S, -) -> error::Result, LocalCallExecutor, E>, Block>> +) -> error::Result, LocalCallExecutor, E>, Block>> where - E: CodeExecutor + RuntimeInfo, + E: CodeExecutor + RuntimeInfo, S: BuildStorage, Block: BlockT, { @@ -175,8 +176,8 @@ pub fn new_in_mem( } impl Client where - B: backend::Backend, - E: CallExecutor, + B: backend::Backend, + E: CallExecutor, Block: BlockT, { /// Creates new Substrate Client with given blockchain and code executor. @@ -284,12 +285,16 @@ impl Client where } /// Create a new block, built on the head of the chain. - pub fn new_block(&self) -> error::Result> where E: Clone { + pub fn new_block(&self) -> error::Result> + where E: Clone + { block_builder::BlockBuilder::new(self) } /// Create a new block, built on top of `parent`. - pub fn new_block_at(&self, parent: &BlockId) -> error::Result> where E: Clone { + pub fn new_block_at(&self, parent: &BlockId) -> error::Result> + where E: Clone + { block_builder::BlockBuilder::at_block(parent, &self) } @@ -504,8 +509,8 @@ impl Client where impl bft::BlockImport for Client where - B: backend::Backend, - E: CallExecutor, + B: backend::Backend, + E: CallExecutor, Block: BlockT, { fn import_block( @@ -527,8 +532,8 @@ impl bft::BlockImport for Client impl bft::Authorities for Client where - B: backend::Backend, - E: CallExecutor, + B: backend::Backend, + E: CallExecutor, Block: BlockT, { fn authorities(&self, at: &BlockId) -> Result, bft::Error> { @@ -549,9 +554,9 @@ impl bft::Authorities for Client } impl BlockchainEvents for Client - where - E: CallExecutor, - Block: BlockT, +where + E: CallExecutor, + Block: BlockT, { /// Get block import event stream. fn import_notification_stream(&self) -> BlockchainEventStream { @@ -567,10 +572,10 @@ impl BlockchainEvents for Client } impl ChainHead for Client - where - B: backend::Backend, - E: CallExecutor, - Block: BlockT, +where + B: backend::Backend, + E: CallExecutor, + Block: BlockT, { fn best_block_header(&self) -> error::Result<::Header> { Client::best_block_header(self) @@ -579,8 +584,8 @@ impl ChainHead for Client impl BlockBody for Client where - B: backend::Backend, - E: CallExecutor, + B: backend::Backend, + E: CallExecutor, Block: BlockT, { fn block_body(&self, id: &BlockId) -> error::Result::Extrinsic>>> { diff --git a/substrate/client/src/genesis.rs b/substrate/client/src/genesis.rs index 1062ba92c5043..88d99e88e4da9 100644 --- a/substrate/client/src/genesis.rs +++ b/substrate/client/src/genesis.rs @@ -51,6 +51,7 @@ mod tests { use test_client::runtime::genesismap::{GenesisConfig, additional_storage_with_genesis}; use test_client::runtime::{Hash, Transfer, Block, BlockNumber, Header, Digest, Extrinsic}; use ed25519::{Public, Pair}; + use primitives::{KeccakHasher, RlpCodec}; native_executor_instance!(Executor, test_client::runtime::api::dispatch, test_client::runtime::VERSION, include_bytes!("../../test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm")); @@ -58,7 +59,7 @@ mod tests { NativeExecutionDispatch::with_heap_pages(8) } - fn construct_block(backend: &InMemory, number: BlockNumber, parent_hash: Hash, state_root: Hash, txs: Vec) -> (Vec, Hash) { + fn construct_block(backend: &InMemory, number: BlockNumber, parent_hash: Hash, state_root: Hash, txs: Vec) -> (Vec, Hash) { use triehash::ordered_trie_root; let transactions = txs.into_iter().map(|tx| { @@ -115,7 +116,7 @@ mod tests { (vec![].and(&Block { header, extrinsics: transactions }), hash) } - fn block1(genesis_hash: Hash, backend: &InMemory) -> (Vec, Hash) { + fn block1(genesis_hash: Hash, backend: &InMemory) -> (Vec, Hash) { construct_block( backend, 1, diff --git a/substrate/client/src/in_mem.rs b/substrate/client/src/in_mem.rs index a12323610a723..e42e83f75fc5a 100644 --- a/substrate/client/src/in_mem.rs +++ b/substrate/client/src/in_mem.rs @@ -28,6 +28,9 @@ use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, Zero, Numbe use runtime_primitives::bft::Justification; use blockchain::{self, BlockStatus}; use state_machine::backend::{Backend as StateBackend, InMemory}; +use patricia_trie::NodeCodec; +use hashdb::Hasher; +use heapsize::HeapSizeOf; struct PendingBlock { block: StoredBlock, @@ -248,15 +251,21 @@ impl light::blockchain::Storage for Blockchain { } /// In-memory operation. -pub struct BlockImportOperation { +pub struct BlockImportOperation> { pending_block: Option>, pending_authorities: Option>, - old_state: InMemory, - new_state: Option, + old_state: InMemory, + new_state: Option>, } -impl backend::BlockImportOperation for BlockImportOperation { - type State = InMemory; +impl backend::BlockImportOperation for BlockImportOperation +where + Block: BlockT, + H: Hasher, + C: NodeCodec, + H::Out: HeapSizeOf, +{ + type State = InMemory; fn state(&self) -> error::Result> { Ok(Some(&self.old_state)) @@ -281,7 +290,7 @@ impl backend::BlockImportOperation for BlockImportOperatio self.pending_authorities = Some(authorities); } - fn update_storage(&mut self, update: ::Transaction) -> error::Result<()> { + fn update_storage(&mut self, update: as StateBackend>::Transaction) -> error::Result<()> { self.new_state = Some(self.old_state.update(update)); Ok(()) } @@ -293,18 +302,24 @@ impl backend::BlockImportOperation for BlockImportOperatio } /// In-memory backend. Keeps all states and blocks in memory. Useful for testing. -pub struct Backend where +pub struct Backend +where Block: BlockT, + H: Hasher, + C: NodeCodec { - states: RwLock>, + states: RwLock>>, blockchain: Blockchain, } -impl Backend where +impl Backend +where Block: BlockT, + H: Hasher, + C: NodeCodec { /// Create a new instance of in-mem backend. - pub fn new() -> Backend { + pub fn new() -> Backend { Backend { states: RwLock::new(HashMap::new()), blockchain: Blockchain::new(), @@ -312,12 +327,16 @@ impl Backend where } } -impl backend::Backend for Backend where +impl backend::Backend for Backend +where Block: BlockT, + H: Hasher, + H::Out: HeapSizeOf, + C: NodeCodec + Send + Sync, { - type BlockImportOperation = BlockImportOperation; + type BlockImportOperation = BlockImportOperation; type Blockchain = Blockchain; - type State = InMemory; + type State = InMemory; fn begin_operation(&self, block: BlockId) -> error::Result { let state = match block { @@ -366,7 +385,13 @@ impl backend::Backend for Backend where } } -impl backend::LocalBackend for Backend {} +impl backend::LocalBackend for Backend +where + Block: BlockT, + H: Hasher, + H::Out: HeapSizeOf, + C: NodeCodec + Send + Sync, +{} impl Cache { fn insert(&self, at: Block::Hash, authorities: Option>) { diff --git a/substrate/client/src/lib.rs b/substrate/client/src/lib.rs index 0032fc64e4f03..457502b3d6df1 100644 --- a/substrate/client/src/lib.rs +++ b/substrate/client/src/lib.rs @@ -36,6 +36,10 @@ extern crate fnv; extern crate futures; extern crate parking_lot; extern crate triehash; +extern crate patricia_trie; +extern crate hashdb; +extern crate rlp; +extern crate heapsize; #[macro_use] extern crate error_chain; #[macro_use] extern crate log; diff --git a/substrate/client/src/light/backend.rs b/substrate/client/src/light/backend.rs index 03b188b5f6866..9187566f5b090 100644 --- a/substrate/client/src/light/backend.rs +++ b/substrate/client/src/light/backend.rs @@ -24,14 +24,19 @@ use parking_lot::RwLock; use primitives::AuthorityId; use runtime_primitives::{bft::Justification, generic::BlockId}; use runtime_primitives::traits::{Block as BlockT, NumberFor}; -use state_machine::{Backend as StateBackend, TrieBackend as StateTrieBackend, - TryIntoTrieBackend as TryIntoStateTrieBackend}; +use state_machine::{ + Backend as StateBackend, + TrieBackend as StateTrieBackend, + TryIntoTrieBackend as TryIntoStateTrieBackend +}; use backend::{Backend as ClientBackend, BlockImportOperation, RemoteBackend}; use blockchain::HeaderBackend as BlockchainHeaderBackend; use error::{Error as ClientError, ErrorKind as ClientErrorKind, Result as ClientResult}; use light::blockchain::{Blockchain, Storage as BlockchainStorage}; use light::fetcher::{Fetcher, RemoteReadRequest}; +use patricia_trie::NodeCodec; +use hashdb::Hasher; /// Light client backend. pub struct Backend { @@ -66,10 +71,12 @@ impl Backend { } } -impl ClientBackend for Backend where +impl ClientBackend for Backend where Block: BlockT, S: BlockchainStorage, - F: Fetcher + F: Fetcher, + H: Hasher, + C: NodeCodec, { type BlockImportOperation = ImportOperation; type Blockchain = Blockchain; @@ -112,13 +119,22 @@ impl ClientBackend for Backend where } } -impl RemoteBackend for Backend where Block: BlockT, S: BlockchainStorage, F: Fetcher {} +impl RemoteBackend for Backend +where + Block: BlockT, + S: BlockchainStorage, + F: Fetcher, + H: Hasher, + C: NodeCodec, +{} -impl BlockImportOperation for ImportOperation - where - Block: BlockT, - S: BlockchainStorage, - F: Fetcher, +impl BlockImportOperation for ImportOperation +where + Block: BlockT, + F: Fetcher, + S: BlockchainStorage, + H: Hasher, + C: NodeCodec, { type State = OnDemandState; @@ -143,7 +159,7 @@ impl BlockImportOperation for ImportOperation self.authorities = Some(authorities); } - fn update_storage(&mut self, _update: ::Transaction) -> ClientResult<()> { + fn update_storage(&mut self, _update: >::Transaction) -> ClientResult<()> { // we're not storing anything locally => ignore changes Ok(()) } @@ -154,11 +170,13 @@ impl BlockImportOperation for ImportOperation } } -impl StateBackend for OnDemandState +impl StateBackend for OnDemandState where Block: BlockT, S: BlockchainStorage, F: Fetcher, + H: Hasher, + C: NodeCodec, { type Error = ClientError; type Transaction = (); @@ -186,9 +204,9 @@ impl StateBackend for OnDemandState // whole state is not available on light node } - fn storage_root(&self, _delta: I) -> ([u8; 32], Self::Transaction) + fn storage_root(&self, _delta: I) -> (H::Out, Self::Transaction) where I: IntoIterator, Option>)> { - ([0; 32], ()) + (H::Out::default(), ()) } fn pairs(&self) -> Vec<(Vec, Vec)> { @@ -197,8 +215,14 @@ impl StateBackend for OnDemandState } } -impl TryIntoStateTrieBackend for OnDemandState where Block: BlockT, F: Fetcher { - fn try_into_trie_backend(self) -> Option { +impl TryIntoStateTrieBackend for OnDemandState +where + Block: BlockT, + F: Fetcher, + H: Hasher, + C: NodeCodec, +{ + fn try_into_trie_backend(self) -> Option> { None } } @@ -214,6 +238,7 @@ pub mod tests { use light::new_fetch_checker; use light::fetcher::{Fetcher, FetchChecker, RemoteCallRequest}; use super::*; + use primitives::{KeccakHasher, RlpCodec}; pub type OkCallFetcher = Mutex; @@ -246,7 +271,7 @@ pub mod tests { // check remote read proof locally let local_executor = test_client::LocalExecutor::with_heap_pages(8); - let local_checker = new_fetch_checker(local_executor); + let local_checker = new_fetch_checker::<_, KeccakHasher, RlpCodec>(local_executor); let request = RemoteReadRequest { block: remote_block_hash, header: remote_block_header, diff --git a/substrate/client/src/light/call_executor.rs b/substrate/client/src/light/call_executor.rs index 13355f5d7ccfe..cdbd7ac727932 100644 --- a/substrate/client/src/light/call_executor.rs +++ b/substrate/client/src/light/call_executor.rs @@ -23,7 +23,12 @@ use futures::{IntoFuture, Future}; use runtime_primitives::generic::BlockId; use runtime_primitives::traits::{Block as BlockT, Header as HeaderT}; use state_machine::{Backend as StateBackend, CodeExecutor, OverlayedChanges, - execution_proof_check, TrieH256, ExecutionManager}; + execution_proof_check, ExecutionManager}; +use primitives::H256; +use patricia_trie::NodeCodec; +use hashdb::Hasher; +use rlp::Encodable; +use primitives::{KeccakHasher, RlpCodec}; use blockchain::Backend as ChainBackend; use call_executor::{CallExecutor, CallResult}; @@ -31,6 +36,7 @@ use error::{Error as ClientError, ErrorKind as ClientErrorKind, Result as Client use light::fetcher::{Fetcher, RemoteCallRequest}; use executor::RuntimeVersion; use codec::Decode; +use heapsize::HeapSizeOf; /// Call executor that executes methods on remote node, querying execution proof /// and checking proof by re-executing locally. @@ -46,7 +52,7 @@ impl RemoteCallExecutor { } } -impl CallExecutor for RemoteCallExecutor +impl CallExecutor for RemoteCallExecutor where Block: BlockT, B: ChainBackend, @@ -77,19 +83,25 @@ impl CallExecutor for RemoteCallExecutor } fn call_at_state< - S: StateBackend, - H: FnOnce(Result, Self::Error>, Result, Self::Error>) -> Result, Self::Error> + S: StateBackend, + FF: FnOnce(Result, Self::Error>, Result, Self::Error>) -> Result, Self::Error> >(&self, _state: &S, _changes: &mut OverlayedChanges, _method: &str, _call_data: &[u8], - _m: ExecutionManager + _m: ExecutionManager ) -> ClientResult<(Vec, S::Transaction)> { Err(ClientErrorKind::NotAvailableOnLightClient.into()) } - fn prove_at_state(&self, _state: S, _changes: &mut OverlayedChanges, _method: &str, _call_data: &[u8]) -> ClientResult<(Vec, Vec>)> { + fn prove_at_state>( + &self, + _state: S, + _changes: &mut OverlayedChanges, + _method: &str, + _call_data: &[u8] + ) -> ClientResult<(Vec, Vec>)> { Err(ClientErrorKind::NotAvailableOnLightClient.into()) } @@ -99,20 +111,23 @@ impl CallExecutor for RemoteCallExecutor } /// Check remote execution proof using given backend. -pub fn check_execution_proof( +pub fn check_execution_proof( executor: &E, request: &RemoteCallRequest
, remote_proof: Vec> ) -> ClientResult where Header: HeaderT, - E: CodeExecutor, + E: CodeExecutor, + H: Hasher, + H::Out: Ord + Encodable + HeapSizeOf + From, + C: NodeCodec, { let local_state_root = request.header.state_root(); let mut changes = OverlayedChanges::default(); - let (local_result, _) = execution_proof_check( - TrieH256::from_slice(local_state_root.as_ref()).into(), + let (local_result, _) = execution_proof_check::( + H256::from_slice(local_state_root.as_ref()).into(), remote_proof, &mut changes, executor, @@ -127,6 +142,7 @@ mod tests { use test_client; use executor::NativeExecutionDispatch; use super::*; + use primitives::RlpCodec; #[test] fn execution_proof_is_generated_and_checked() { @@ -138,10 +154,10 @@ mod tests { // 'fetch' execution proof from remote node let remote_execution_proof = remote_client.execution_proof(&remote_block_id, "authorities", &[]).unwrap().1; - + // check remote execution proof locally let local_executor = test_client::LocalExecutor::with_heap_pages(8); - check_execution_proof(&local_executor, &RemoteCallRequest { + check_execution_proof::<_, _, _, RlpCodec>(&local_executor, &RemoteCallRequest { block: test_client::runtime::Hash::default(), header: test_client::runtime::Header { state_root: remote_block_storage_root.into(), diff --git a/substrate/client/src/light/fetcher.rs b/substrate/client/src/light/fetcher.rs index 07c26a471dee8..694abeb8f17a5 100644 --- a/substrate/client/src/light/fetcher.rs +++ b/substrate/client/src/light/fetcher.rs @@ -18,8 +18,14 @@ use futures::IntoFuture; +use primitives::H256; +use hashdb::Hasher; +use patricia_trie::NodeCodec; +use rlp::Encodable; +use heapsize::HeapSizeOf; use runtime_primitives::traits::{Block as BlockT, Header as HeaderT}; use state_machine::{CodeExecutor, read_proof_check}; +use std::marker::PhantomData; use call_executor::CallResult; use error::{Error as ClientError, Result as ClientResult}; @@ -83,24 +89,29 @@ pub trait FetchChecker: Send + Sync { } /// Remote data checker. -pub struct LightDataChecker { +pub struct LightDataChecker { executor: E, + _hasher: PhantomData, + _codec: PhantomData, } -impl LightDataChecker { +impl LightDataChecker { /// Create new light data checker. pub fn new(executor: E) -> Self { Self { - executor, + executor, _hasher: PhantomData, _codec: PhantomData } } } -impl FetchChecker for LightDataChecker +impl FetchChecker for LightDataChecker where Block: BlockT, - Block::Hash: Into<[u8; 32]>, - E: CodeExecutor, + Block::Hash: Into, + E: CodeExecutor, + H: Hasher, + C: NodeCodec + Sync + Send, + H::Out: Ord + Encodable + HeapSizeOf + From, { fn check_read_proof( &self, @@ -108,7 +119,7 @@ impl FetchChecker for LightDataChecker remote_proof: Vec> ) -> ClientResult>> { let local_state_root = request.header.state_root().clone(); - read_proof_check(local_state_root.into(), remote_proof, &request.key).map_err(Into::into) + read_proof_check::(local_state_root.into(), remote_proof, &request.key).map_err(Into::into) } fn check_execution_proof( @@ -116,6 +127,6 @@ impl FetchChecker for LightDataChecker request: &RemoteCallRequest, remote_proof: Vec> ) -> ClientResult { - check_execution_proof(&self.executor, request, remote_proof) + check_execution_proof::<_, _, H, C>(&self.executor, request, remote_proof) } } diff --git a/substrate/client/src/light/mod.rs b/substrate/client/src/light/mod.rs index 57bd8ce45beb7..ba175b14a883d 100644 --- a/substrate/client/src/light/mod.rs +++ b/substrate/client/src/light/mod.rs @@ -33,6 +33,8 @@ use light::backend::Backend; use light::blockchain::{Blockchain, Storage as BlockchainStorage}; use light::call_executor::RemoteCallExecutor; use light::fetcher::{Fetcher, LightDataChecker}; +use hashdb::Hasher; +use patricia_trie::NodeCodec; /// Create an instance of light client blockchain backend. pub fn new_light_blockchain, F>(storage: S) -> Arc> { @@ -62,11 +64,13 @@ pub fn new_light( } /// Create an instance of fetch data checker. -pub fn new_fetch_checker( +pub fn new_fetch_checker( executor: E, -) -> LightDataChecker +) -> LightDataChecker where - E: CodeExecutor, + E: CodeExecutor, + H: Hasher, + C: NodeCodec, { LightDataChecker::new(executor) } diff --git a/substrate/executor/Cargo.toml b/substrate/executor/Cargo.toml index 11294d23ef263..a90c2065c61da 100644 --- a/substrate/executor/Cargo.toml +++ b/substrate/executor/Cargo.toml @@ -21,6 +21,8 @@ twox-hash = "1.1.0" lazy_static = "1.0" parking_lot = "*" log = "0.3" +hashdb = { git = "https://github.com/paritytech/parity-common" } +tiny-keccak = "1.4" [dev-dependencies] assert_matches = "1.1" diff --git a/substrate/executor/src/lib.rs b/substrate/executor/src/lib.rs index 3a399e7e3a7b2..f0605849d5fa1 100644 --- a/substrate/executor/src/lib.rs +++ b/substrate/executor/src/lib.rs @@ -42,6 +42,9 @@ extern crate byteorder; extern crate triehash; extern crate parking_lot; extern crate twox_hash; +extern crate hashdb; +extern crate tiny_keccak; + #[macro_use] extern crate log; #[macro_use] @@ -73,6 +76,7 @@ pub use native_executor::{with_native_environment, NativeExecutor, NativeExecuti pub use state_machine::Externalities; pub use runtime_version::RuntimeVersion; pub use codec::Codec; +use primitives::KeccakHasher; /// Provides runtime information. pub trait RuntimeInfo { @@ -80,7 +84,7 @@ pub trait RuntimeInfo { const NATIVE_VERSION: Option; /// Extract RuntimeVersion of given :code block - fn runtime_version ( + fn runtime_version> ( &self, ext: &mut E, code: &[u8] diff --git a/substrate/executor/src/native_executor.rs b/substrate/executor/src/native_executor.rs index 0b132ae9ab1fa..c1bd44fd935d8 100644 --- a/substrate/executor/src/native_executor.rs +++ b/substrate/executor/src/native_executor.rs @@ -25,6 +25,7 @@ use twox_hash::XxHash; use std::hash::Hasher; use parking_lot::{Mutex, MutexGuard}; use RuntimeInfo; +use primitives::KeccakHasher; // For the internal Runtime Cache: // Is it compatible enough to run this natively or do we need to fall back on the WasmModule @@ -56,7 +57,7 @@ fn gen_cache_key(code: &[u8]) -> u64 { /// fetch a runtime version from the cache or if there is no cached version yet, create /// the runtime version entry for `code`, determines whether `Compatibility::IsCompatible` /// can be used by by comparing returned RuntimeVersion to `ref_version` -fn fetch_cached_runtime_version<'a, E: Externalities>( +fn fetch_cached_runtime_version<'a, E: Externalities>( wasm_executor: &WasmExecutor, cache: &'a mut MutexGuard, ext: &mut E, @@ -94,8 +95,8 @@ fn safe_call(f: F) -> Result /// Set up the externalities and safe calling environment to execute calls to a native runtime. /// /// If the inner closure panics, it will be caught and return an error. -pub fn with_native_environment(ext: &mut Externalities, f: F) -> Result - where F: ::std::panic::UnwindSafe + FnOnce() -> U +pub fn with_native_environment(ext: &mut Externalities, f: F) -> Result +where F: ::std::panic::UnwindSafe + FnOnce() -> U { ::runtime_io::with_externalities(ext, move || safe_call(f)) } @@ -107,7 +108,8 @@ pub trait NativeExecutionDispatch: Send + Sync { /// Dispatch a method and input data to be executed natively. Returns `Some` result or `None` /// if the `method` is unknown. Panics if there's an unrecoverable error. - fn dispatch(ext: &mut Externalities, method: &str, data: &[u8]) -> Result>; + // fn dispatch(ext: &mut Externalities, method: &str, data: &[u8]) -> Result>; + fn dispatch(ext: &mut Externalities, method: &str, data: &[u8]) -> Result>; /// Get native runtime version. const VERSION: RuntimeVersion; @@ -150,7 +152,7 @@ impl Clone for NativeExecutor { impl RuntimeInfo for NativeExecutor { const NATIVE_VERSION: Option = Some(D::VERSION); - fn runtime_version( + fn runtime_version>( &self, ext: &mut E, code: &[u8], @@ -163,10 +165,10 @@ impl RuntimeInfo for NativeExecutor { } } -impl CodeExecutor for NativeExecutor { +impl CodeExecutor for NativeExecutor { type Error = Error; - fn call( + fn call>( &self, ext: &mut E, code: &[u8], @@ -195,6 +197,8 @@ macro_rules! native_executor_instance { native_executor_instance!(IMPL $name, $dispatcher, $version, $code); }; (IMPL $name:ident, $dispatcher:path, $version:path, $code:expr) => { + // TODO: this is not so great – I think I should go back to have dispatch take a type param and modify this macro to accept a type param and then pass it in from the test-client instead + use primitives::KeccakHasher as _KeccakHasher; impl $crate::NativeExecutionDispatch for $name { const VERSION: $crate::RuntimeVersion = $version; fn native_equivalent() -> &'static [u8] { @@ -202,8 +206,7 @@ macro_rules! native_executor_instance { // get a proper build script, this must be strictly adhered to or things will go wrong. $code } - - fn dispatch(ext: &mut $crate::Externalities, method: &str, data: &[u8]) -> $crate::error::Result> { + fn dispatch(ext: &mut $crate::Externalities<_KeccakHasher>, method: &str, data: &[u8]) -> $crate::error::Result> { $crate::with_native_environment(ext, move || $dispatcher(method, data))? .ok_or_else(|| $crate::error::ErrorKind::MethodNotFound(method.to_owned()).into()) } diff --git a/substrate/executor/src/wasm_executor.rs b/substrate/executor/src/wasm_executor.rs index 7ea33bea3b84a..2b222d3ac0ce8 100644 --- a/substrate/executor/src/wasm_executor.rs +++ b/substrate/executor/src/wasm_executor.rs @@ -18,6 +18,7 @@ use std::cmp::Ordering; use std::collections::HashMap; + use wasmi::{ Module, ModuleInstance, MemoryInstance, MemoryRef, TableRef, ImportsBuilder }; @@ -29,8 +30,11 @@ use wasm_utils::UserError; use primitives::{blake2_256, twox_128, twox_256}; use primitives::hexdisplay::HexDisplay; use primitives::sandbox as sandbox_primitives; +use primitives::KeccakHasher; use triehash::ordered_trie_root; use sandbox; +use tiny_keccak::keccak256; + struct Heap { end: u32, @@ -71,7 +75,7 @@ macro_rules! debug_trace { ( $( $x:tt )* ) => () } -struct FunctionExecutor<'e, E: Externalities + 'e> { +struct FunctionExecutor<'e, E: Externalities + 'e> { sandbox_store: sandbox::Store, heap: Heap, memory: MemoryRef, @@ -80,7 +84,7 @@ struct FunctionExecutor<'e, E: Externalities + 'e> { hash_lookup: HashMap, Vec>, } -impl<'e, E: Externalities> FunctionExecutor<'e, E> { +impl<'e, E: Externalities> FunctionExecutor<'e, E> { fn new(m: MemoryRef, heap_pages: usize, t: Option, e: &'e mut E) -> Result { Ok(FunctionExecutor { sandbox_store: sandbox::Store::new(), @@ -93,7 +97,7 @@ impl<'e, E: Externalities> FunctionExecutor<'e, E> { } } -impl<'e, E: Externalities> sandbox::SandboxCapabilities for FunctionExecutor<'e, E> { +impl<'e, E: Externalities> sandbox::SandboxCapabilities for FunctionExecutor<'e, E> { fn store(&self) -> &sandbox::Store { &self.sandbox_store } @@ -138,6 +142,7 @@ impl ReadPrimitive for MemoryInstance { } } +// TODO: this macro does not support `where` clauses and that seems somewhat tricky to add impl_function_executor!(this: FunctionExecutor<'e, E>, ext_print_utf8(utf8_data: *const u8, utf8_len: u32) => { if let Ok(utf8) = this.memory.get(utf8_data, utf8_len as usize) { @@ -285,7 +290,7 @@ impl_function_executor!(this: FunctionExecutor<'e, E>, }, ext_storage_root(result: *mut u8) => { let r = this.ext.storage_root(); - this.memory.set(result, &r[..]).map_err(|_| UserError("Invalid attempt to set memory in ext_storage_root"))?; + this.memory.set(result, r.as_ref()).map_err(|_| UserError("Invalid attempt to set memory in ext_storage_root"))?; Ok(()) }, ext_enumerated_trie_root(values_data: *const u8, lens_data: *const u32, lens_len: u32, result: *mut u8) => { @@ -348,6 +353,15 @@ impl_function_executor!(this: FunctionExecutor<'e, E>, this.memory.set(out, &result).map_err(|_| UserError("Invalid attempt to set result in ext_blake2_256"))?; Ok(()) }, + ext_keccak256(data: *const u8, len: u32, out: *mut u8) => { + let result = if len == 0 { + keccak256(&[0u8; 0]) + } else { + keccak256(&this.memory.get(data, len as usize).map_err(|_| UserError("Invalid attempt to get data in ext_keccak256"))?) + }; + this.memory.set(out, &result).map_err(|_| UserError("Invalid attempt to set result in ext_keccak256"))?; + Ok(()) + }, ext_ed25519_verify(msg_data: *const u8, msg_len: u32, sig_data: *const u8, pubkey_data: *const u8) -> u32 => { let mut sig = [0u8; 64]; this.memory.get_into(sig_data, &mut sig[..]).map_err(|_| UserError("Invalid attempt to get signature in ext_ed25519_verify"))?; @@ -476,7 +490,7 @@ impl_function_executor!(this: FunctionExecutor<'e, E>, this.sandbox_store.memory_teardown(memory_idx)?; Ok(()) }, - => <'e, E: Externalities + 'e> + => <'e, E: Externalities + 'e> ); /// Wasm rust executor for contracts. @@ -508,7 +522,7 @@ impl WasmExecutor { /// Call a given method in the given code. /// This should be used for tests only. - pub fn call( + pub fn call>( &self, ext: &mut E, code: &[u8], @@ -520,7 +534,7 @@ impl WasmExecutor { } /// Call a given method in the given wasm-module runtime. - pub fn call_in_wasm_module( + pub fn call_in_wasm_module>( &self, ext: &mut E, module: &Module, @@ -632,7 +646,7 @@ mod tests { assert_eq!(output, b"all ok!".to_vec()); - let expected: HashMap<_, _> = map![ + let expected : TestExternalities<_> = map![ b"input".to_vec() => b"Hello world".to_vec(), b"foo".to_vec() => b"bar".to_vec(), b"baz".to_vec() => b"bar".to_vec() @@ -655,7 +669,7 @@ mod tests { assert_eq!(output, b"all ok!".to_vec()); - let expected: HashMap<_, _> = map![ + let expected: TestExternalities<_> = map![ b"aaa".to_vec() => b"1".to_vec(), b"aab".to_vec() => b"2".to_vec(), b"bbb".to_vec() => b"5".to_vec() diff --git a/substrate/executor/wasm/Cargo.lock b/substrate/executor/wasm/Cargo.lock index 9d2f6ce2eff55..c1f049b09a6f1 100644 --- a/substrate/executor/wasm/Cargo.lock +++ b/substrate/executor/wasm/Cargo.lock @@ -18,14 +18,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "fixed-hash" -version = "0.1.3" -source = "git+https://github.com/rphmeier/primitives.git?branch=compile-for-wasm#8dc457899afdaf968ff7f16140b03d1e37b01d71" +version = "0.2.2" +source = "git+https://github.com/paritytech/parity-common#9bcbfa0f10fee1852791ce07338d664817f69521" + +[[package]] +name = "hashdb" +version = "0.2.1" +source = "git+https://github.com/paritytech/parity-common#9bcbfa0f10fee1852791ce07338d664817f69521" [[package]] name = "nodrop" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "plain_hasher" +version = "0.2.0" +source = "git+https://github.com/paritytech/parity-common#9bcbfa0f10fee1852791ce07338d664817f69521" +dependencies = [ + "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "proc-macro2" version = "0.4.9" @@ -115,13 +128,15 @@ version = "0.1.0" dependencies = [ "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "fixed-hash 0.1.3 (git+https://github.com/rphmeier/primitives.git?branch=compile-for-wasm)", + "fixed-hash 0.2.2 (git+https://github.com/paritytech/parity-common)", + "hashdb 0.2.1 (git+https://github.com/paritytech/parity-common)", + "plain_hasher 0.2.0 (git+https://github.com/paritytech/parity-common)", "rustc-hex 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-codec 0.1.0", "substrate-codec-derive 0.1.0", "substrate-runtime-std 0.1.0", - "uint 0.1.2 (git+https://github.com/rphmeier/primitives.git?branch=compile-for-wasm)", + "uint 0.2.2 (git+https://github.com/paritytech/parity-common)", ] [[package]] @@ -166,8 +181,8 @@ dependencies = [ [[package]] name = "uint" -version = "0.1.2" -source = "git+https://github.com/rphmeier/primitives.git?branch=compile-for-wasm#8dc457899afdaf968ff7f16140b03d1e37b01d71" +version = "0.2.2" +source = "git+https://github.com/paritytech/parity-common#9bcbfa0f10fee1852791ce07338d664817f69521" dependencies = [ "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -182,8 +197,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef" "checksum byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "652805b7e73fada9d85e9a6682a4abd490cb52d96aeecc12e33a0de34dfd0d23" "checksum crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a2f4a431c5c9f662e1200b7c7f02c34e91361150e382089a8f2dec3ba680cbda" -"checksum fixed-hash 0.1.3 (git+https://github.com/rphmeier/primitives.git?branch=compile-for-wasm)" = "" +"checksum fixed-hash 0.2.2 (git+https://github.com/paritytech/parity-common)" = "" +"checksum hashdb 0.2.1 (git+https://github.com/paritytech/parity-common)" = "" "checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" +"checksum plain_hasher 0.2.0 (git+https://github.com/paritytech/parity-common)" = "" "checksum proc-macro2 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "cccdc7557a98fe98453030f077df7f3a042052fae465bb61d2c2c41435cfd9b6" "checksum quote 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3372dc35766b36a99ce2352bd1b6ea0137c38d215cc0c8780bf6de6df7842ba9" "checksum rustc-hex 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2b03280c2813907a030785570c577fb27d3deec8da4c18566751ade94de0ace" @@ -192,5 +209,5 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)" = "db99f3919e20faa51bb2996057f5031d8685019b5a06139b1ce761da671b8526" "checksum syn 0.14.7 (registry+https://github.com/rust-lang/crates.io-index)" = "e2e13df71f29f9440b50261a5882c86eac334f1badb3134ec26f0de2f1418e44" -"checksum uint 0.1.2 (git+https://github.com/rphmeier/primitives.git?branch=compile-for-wasm)" = "" +"checksum uint 0.2.2 (git+https://github.com/paritytech/parity-common)" = "" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" diff --git a/substrate/executor/wasm/target/wasm32-unknown-unknown/release/runtime_test.compact.wasm b/substrate/executor/wasm/target/wasm32-unknown-unknown/release/runtime_test.compact.wasm index fae5a8dbb520f..ad7e8d7ad171d 100644 Binary files a/substrate/executor/wasm/target/wasm32-unknown-unknown/release/runtime_test.compact.wasm and b/substrate/executor/wasm/target/wasm32-unknown-unknown/release/runtime_test.compact.wasm differ diff --git a/substrate/executor/wasm/target/wasm32-unknown-unknown/release/runtime_test.wasm b/substrate/executor/wasm/target/wasm32-unknown-unknown/release/runtime_test.wasm index 62077bffa0e41..4dd7ec49e42eb 100755 Binary files a/substrate/executor/wasm/target/wasm32-unknown-unknown/release/runtime_test.wasm and b/substrate/executor/wasm/target/wasm32-unknown-unknown/release/runtime_test.wasm differ diff --git a/substrate/keystore/Cargo.toml b/substrate/keystore/Cargo.toml index 88ec623f34d4d..5aa791ca4d99c 100644 --- a/substrate/keystore/Cargo.toml +++ b/substrate/keystore/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" authors = ["Parity Technologies "] [dependencies] -ethcore-crypto = { git = "https://github.com/paritytech/parity.git", default_features = false } +parity-crypto = { git = "https://github.com/paritytech/parity-common.git", default_features = false } ed25519 = { path = "../ed25519" } error-chain = "0.12" hex = "0.3" diff --git a/substrate/keystore/src/lib.rs b/substrate/keystore/src/lib.rs index 14033b4109556..015cad74e9c48 100644 --- a/substrate/keystore/src/lib.rs +++ b/substrate/keystore/src/lib.rs @@ -16,7 +16,7 @@ //! Keystore (and session key management) for ed25519 based chains like Polkadot. -extern crate ethcore_crypto as crypto; +extern crate parity_crypto as crypto; extern crate subtle; extern crate ed25519; extern crate rand; diff --git a/substrate/network-libp2p/Cargo.toml b/substrate/network-libp2p/Cargo.toml index ef8c5b911d2a2..2ff26882e6fbc 100644 --- a/substrate/network-libp2p/Cargo.toml +++ b/substrate/network-libp2p/Cargo.toml @@ -11,7 +11,8 @@ bytes = "0.4" error-chain = { version = "0.12", default-features = false } fnv = "1.0" futures = "0.1" -libp2p = { git = "https://github.com/tomaka/libp2p-rs", branch = "polkadot-2", default-features = false, features = ["libp2p-secio", "libp2p-secio-secp256k1"] } +# libp2p = { git = "https://github.com/tomaka/libp2p-rs", branch = "polkadot-2", default-features = false, features = ["libp2p-secio", "libp2p-secio-secp256k1"] } +libp2p = { git = "https://github.com/tomaka/libp2p-rs", rev = "6aa139a12dbea3d75d898ce0b2af7fcec129e294", default-features = false, features = ["libp2p-secio", "libp2p-secio-secp256k1"] } ethcore-io = { git = "https://github.com/paritytech/parity.git" } ethkey = { git = "https://github.com/paritytech/parity.git" } ethereum-types = "0.3" @@ -26,6 +27,6 @@ unsigned-varint = { version = "0.1", features = ["codec"] } [dev-dependencies] assert_matches = "1.2" -ethcore-bytes = { git = "https://github.com/paritytech/parity.git" } +parity-bytes = { git = "https://github.com/paritytech/parity-common.git" } ethcore-io = { git = "https://github.com/paritytech/parity.git" } ethcore-logger = { git = "https://github.com/paritytech/parity.git" } diff --git a/substrate/network-libp2p/tests/tests.rs b/substrate/network-libp2p/tests/tests.rs index 5016b61b37581..a74772171950c 100644 --- a/substrate/network-libp2p/tests/tests.rs +++ b/substrate/network-libp2p/tests/tests.rs @@ -15,7 +15,7 @@ // along with Parity. If not, see . extern crate parking_lot; -extern crate ethcore_bytes; +extern crate parity_bytes; extern crate ethcore_io as io; extern crate ethcore_logger; extern crate substrate_network_libp2p; @@ -26,7 +26,7 @@ use std::sync::Arc; use std::thread; use std::time::*; use parking_lot::Mutex; -use ethcore_bytes::Bytes; +use parity_bytes::Bytes; use substrate_network_libp2p::*; use ethkey::{Random, Generator}; use io::TimerToken; diff --git a/substrate/network/src/chain.rs b/substrate/network/src/chain.rs index d698ab0900aa7..bc8cee13ecf52 100644 --- a/substrate/network/src/chain.rs +++ b/substrate/network/src/chain.rs @@ -21,6 +21,7 @@ use client::error::Error; use runtime_primitives::traits::{Block as BlockT, Header as HeaderT}; use runtime_primitives::generic::BlockId; use runtime_primitives::bft::Justification; +use primitives::{KeccakHasher, RlpCodec}; /// Local client abstraction for the network. pub trait Client: Send + Sync { @@ -53,8 +54,8 @@ pub trait Client: Send + Sync { } impl Client for SubstrateClient where - B: client::backend::Backend + Send + Sync + 'static, - E: CallExecutor + Send + Sync + 'static, + B: client::backend::Backend + Send + Sync + 'static, + E: CallExecutor + Send + Sync + 'static, Block: BlockT, { fn import(&self, origin: BlockOrigin, header: Block::Header, justification: Justification, body: Option>) -> Result { diff --git a/substrate/network/src/test/mod.rs b/substrate/network/src/test/mod.rs index 5a8d82d448398..9d98a66d948b7 100644 --- a/substrate/network/src/test/mod.rs +++ b/substrate/network/src/test/mod.rs @@ -26,6 +26,7 @@ use runtime_primitives::traits::Block as BlockT; use runtime_primitives::generic::BlockId; use io::SyncIo; use protocol::{Context, Protocol}; +use primitives::{KeccakHasher, RlpCodec}; use config::ProtocolConfig; use service::TransactionPool; use network_libp2p::{NodeIndex, SessionInfo, Severity}; @@ -172,7 +173,9 @@ impl Peer { fn flush(&self) { } - fn generate_blocks(&self, count: usize, mut edit_block: F) where F: FnMut(&mut BlockBuilder) { + fn generate_blocks(&self, count: usize, mut edit_block: F) + where F: FnMut(&mut BlockBuilder) + { for _ in 0 .. count { let mut builder = self.client.new_block().unwrap(); edit_block(&mut builder); diff --git a/substrate/primitives/Cargo.toml b/substrate/primitives/Cargo.toml index ebfbb71cae803..9e2a882846e3b 100644 --- a/substrate/primitives/Cargo.toml +++ b/substrate/primitives/Cargo.toml @@ -8,19 +8,28 @@ crunchy = "0.1" substrate-runtime-std = { path = "../runtime-std", default_features = false } substrate-codec = { path = "../codec", default_features = false } substrate-codec-derive = { path = "../codec/derive", default_features = false } -fixed-hash = { git = "https://github.com/rphmeier/primitives.git", branch = "compile-for-wasm", default_features = false } +elastic-array = {version = "0.10", optional = true } +fixed-hash = { git = "https://github.com/paritytech/parity-common", default_features = false } rustc-hex = { version = "2.0", default_features = false } serde = { version = "1.0", default_features = false } serde_derive = { version = "1.0", optional = true } -uint = { git = "https://github.com/rphmeier/primitives.git", branch = "compile-for-wasm", default_features = false } +uint = { git = "https://github.com/paritytech/parity-common", default_features = false } +rlp = { git = "https://github.com/paritytech/parity-common", optional = true } twox-hash = { version = "1.1.0", optional = true } byteorder = { version = "1.1", default_features = false } -blake2-rfc = { version = "0.2.18", optional = true } wasmi = { version = "0.4", optional = true } +hashdb = { git = "https://github.com/paritytech/parity-common", default_features = false } +patricia-trie = { git = "https://github.com/paritytech/parity-common", optional = true } +plain_hasher = { git = "https://github.com/paritytech/parity-common", default_features = false } + +blake2-rfc = { version = "0.2.18", optional = true } +# Switch back to Blake after PoC-3 is out and remove this +tiny-keccak = { version = "1.4", optional = true } [dev-dependencies] substrate-serializer = { path = "../serializer" } pretty_assertions = "0.4" +heapsize = "0.4" [features] default = ["std"] @@ -28,12 +37,18 @@ std = [ "wasmi", "uint/std", "fixed-hash/std", + "fixed-hash/heapsizeof", + "fixed-hash/libc", "substrate-codec/std", "substrate-runtime-std/std", "serde/std", "rustc-hex/std", "twox-hash", "blake2-rfc", + "tiny-keccak", "serde_derive", - "byteorder/std" + "byteorder/std", + "patricia-trie", + "rlp", + "elastic-array", ] diff --git a/substrate/primitives/src/hash.rs b/substrate/primitives/src/hash.rs index a0dc5f4c1cc75..89f2961b95283 100644 --- a/substrate/primitives/src/hash.rs +++ b/substrate/primitives/src/hash.rs @@ -21,6 +21,10 @@ use serde::{Serialize, Serializer, Deserialize, Deserializer}; #[cfg(feature = "std")] use bytes; +#[cfg(feature = "std")] +use core::cmp; +#[cfg(feature = "std")] +use rlp::{Rlp, RlpStream, DecoderError}; macro_rules! impl_rest { ($name: ident, $len: expr) => { @@ -49,6 +53,29 @@ macro_rules! impl_rest { <[u8; $len] as ::codec::Decode>::decode(input).map($name) } } + + #[cfg(feature = "std")] + impl ::rlp::Encodable for $name { + fn rlp_append(&self, s: &mut RlpStream) { + s.encoder().encode_value(self); + } + } + + #[cfg(feature = "std")] + impl ::rlp::Decodable for $name { + fn decode(rlp: &Rlp) -> Result { + rlp.decoder().decode_value(|bytes| match bytes.len().cmp(&$len) { + cmp::Ordering::Less => Err(DecoderError::RlpIsTooShort), + cmp::Ordering::Greater => Err(DecoderError::RlpIsTooBig), + cmp::Ordering::Equal => { + let mut t = [0u8; $len]; + t.copy_from_slice(bytes); + Ok($name(t)) + } + }) + } + } + } } @@ -63,6 +90,26 @@ impl_rest!(H512, 64); mod tests { use super::*; use substrate_serializer as ser; + use rlp::{Encodable, RlpStream}; + + #[test] + fn test_hash_is_encodable() { + let h = H160::from(21); + let mut s = RlpStream::new(); + h.rlp_append(&mut s); + assert_eq!(s.drain().into_vec(), &[148, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21]); + } + + #[test] + fn test_hash_is_decodable() { + let data = vec![148, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 123]; + let res = ::rlp::decode::(&data); + assert!(res.is_ok()); + assert_eq!(res.unwrap(), H160::from(123)); + + let res = ::rlp::decode::(&data); + assert!(res.is_err()); + } #[test] fn test_h160() { @@ -109,4 +156,11 @@ mod tests { assert!(ser::from_str::("\"0\"").unwrap_err().is_data()); assert!(ser::from_str::("\"10\"").unwrap_err().is_data()); } + + #[test] + fn test_heapsizeof() { + use heapsize::HeapSizeOf; + let h = H256::new(); + assert_eq!(h.heap_size_of_children(), 0); + } } diff --git a/substrate/primitives/src/hasher.rs b/substrate/primitives/src/hasher.rs new file mode 100644 index 0000000000000..6096540aa347d --- /dev/null +++ b/substrate/primitives/src/hasher.rs @@ -0,0 +1,88 @@ +// Copyright 2018 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Polkadot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Polkadot. If not, see . + +//! Polkadot Blake2b Hasher implementation + +use hashdb::Hasher; +use plain_hasher::PlainHasher; +use hash::H256; + +// Use this when switching to Blake2 after PoC-3 +// pub mod blake { +// use super::{Hasher, PlainHasher, H256}; +// #[cfg(feature = "std")] +// use hashing::blake2_256; + +// #[cfg(not(feature = "std"))] +// extern "C" { +// fn ext_blake2_256(data: *const u8, len: u32, out: *mut u8); +// } +// #[cfg(not(feature = "std"))] +// fn blake2_256(data: &[u8]) -> [u8; 32] { +// let mut result: [u8; 32] = Default::default(); +// unsafe { +// ext_blake2_256(data.as_ptr(), data.len() as u32, result.as_mut_ptr()); +// } +// result +// } + +// /// Concrete implementation of Hasher using Blake2b 256-bit hashes +// #[derive(Debug)] +// pub struct BlakeHasher; + +// impl Hasher for BlakeHasher { +// type Out = H256; +// type StdHasher = PlainHasher; +// const LENGTH:usize = 32; +// fn hash(x: &[u8]) -> Self::Out { +// blake2_256(x).into() +// } +// } +// } + +pub mod keccak { + use super::{Hasher, PlainHasher, H256}; + + #[cfg(feature = "std")] + use tiny_keccak::keccak256; + + #[cfg(not(feature = "std"))] + extern "C" { + fn ext_keccak256(data: *const u8, len: u32, out: *mut u8); + } + + #[cfg(not(feature = "std"))] + fn keccak256(data: &[u8]) -> [u8; 32] { + let mut result: [u8; 32] = Default::default(); + unsafe { + ext_keccak256(data.as_ptr(), data.len() as u32, result.as_mut_ptr()); + } + result + } + + /// Concrete implementation of Hasher using Keccak 256-bit hashes + #[derive(Debug)] + pub struct KeccakHasher; + + impl Hasher for KeccakHasher { + type Out = H256; + type StdHasher = PlainHasher; + const LENGTH : usize = 32; + fn hash(x: &[u8]) -> Self::Out { + keccak256(x).into() + } + } +} \ No newline at end of file diff --git a/substrate/primitives/src/lib.rs b/substrate/primitives/src/lib.rs index 4ead8c4633c2e..07f658dd8ae9d 100644 --- a/substrate/primitives/src/lib.rs +++ b/substrate/primitives/src/lib.rs @@ -33,13 +33,20 @@ extern crate substrate_codec_derive; extern crate rustc_hex; extern crate byteorder; extern crate substrate_codec as codec; +#[cfg(feature = "std")] +extern crate rlp; #[cfg(feature = "std")] extern crate serde; #[cfg(feature = "std")] extern crate twox_hash; + #[cfg(feature = "std")] extern crate blake2_rfc; +// Switch back to Blake after PoC-3 is out +#[cfg(feature = "std")] +extern crate tiny_keccak; + #[cfg(feature = "std")] #[macro_use] extern crate serde_derive; @@ -47,12 +54,21 @@ extern crate serde_derive; extern crate core; #[cfg(feature = "std")] extern crate wasmi; +extern crate hashdb; +extern crate plain_hasher; +#[cfg(feature = "std")] +extern crate patricia_trie; +#[cfg(feature = "std")] +extern crate elastic_array; extern crate substrate_runtime_std as rstd; #[cfg(test)] extern crate substrate_serializer; +#[cfg(test)] +extern crate heapsize; + #[cfg(test)] #[macro_use] extern crate pretty_assertions; @@ -77,18 +93,28 @@ pub use hashing::{blake2_256, twox_128, twox_256}; pub mod hexdisplay; pub mod hash; +mod hasher; pub mod sandbox; pub mod storage; pub mod uint; mod authority_id; +#[cfg(feature = "std")] +mod rlp_codec; #[cfg(test)] mod tests; pub use self::hash::{H160, H256, H512}; -pub use self::uint::{U256, U512}; +pub use self::uint::U256; pub use authority_id::AuthorityId; +// Switch back to Blake after PoC-3 is out +// pub use self::hasher::blake::BlakeHasher; +pub use self::hasher::keccak::KeccakHasher; + +#[cfg(feature = "std")] +pub use self::rlp_codec::RlpCodec; + /// A 512-bit value interpreted as a signature. pub type Signature = hash::H512; diff --git a/substrate/primitives/src/rlp_codec.rs b/substrate/primitives/src/rlp_codec.rs new file mode 100644 index 0000000000000..5a779cb738dee --- /dev/null +++ b/substrate/primitives/src/rlp_codec.rs @@ -0,0 +1,129 @@ +// Copyright 2018 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Polkadot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Polkadot. If not, see . + +//! Polkadot Blake2b (trie) NodeCodec implementation + +use elastic_array::{ElasticArray1024, ElasticArray128}; +use hashdb::Hasher; +use rlp::{DecoderError, RlpStream, Rlp, Prototype}; +use core::marker::PhantomData; +use patricia_trie::{NibbleSlice, NodeCodec, node::Node, ChildReference}; + +use hash::H256; +// When switching to Blake2, use this instead: +// use BlakeHasher; +use KeccakHasher; + +/// Concrete implementation of a `NodeCodec` with Rlp encoding, generic over the `Hasher` +pub struct RlpNodeCodec {mark: PhantomData} + +/// Convenience type for a Keccak/Rlp flavoured NodeCodec +pub type RlpCodec = RlpNodeCodec; +// When switching to Blake2, use this instead: +// pub type RlpCodec = RlpNodeCodec; + +impl NodeCodec for RlpCodec { + type Error = DecoderError; + // When switching to Blake2, use this null node + // const HASHED_NULL_NODE : H256 = H256( [0x45, 0xb0, 0xcf, 0xc2, 0x20, 0xce, 0xec, 0x5b, 0x7c, 0x1c, 0x62, 0xc4, 0xd4, 0x19, 0x3d, 0x38, 0xe4, 0xeb, 0xa4, 0x8e, 0x88, 0x15, 0x72, 0x9c, 0xe7, 0x5f, 0x9c, 0xa, 0xb0, 0xe4, 0xc1, 0xc0] ); + const HASHED_NULL_NODE : H256 = H256( [0x56, 0xe8, 0x1f, 0x17, 0x1b, 0xcc, 0x55, 0xa6, 0xff, 0x83, 0x45, 0xe6, 0x92, 0xc0, 0xf8, 0x6e, 0x5b, 0x48, 0xe0, 0x1b, 0x99, 0x6c, 0xad, 0xc0, 0x01, 0x62, 0x2f, 0xb5, 0xe3, 0x63, 0xb4, 0x21] ); + fn decode(data: &[u8]) -> ::std::result::Result { + let r = Rlp::new(data); + match r.prototype()? { + // either leaf or extension - decode first item with NibbleSlice::??? + // and use is_leaf return to figure out which. + // if leaf, second item is a value (is_data()) + // if extension, second item is a node (either SHA3 to be looked up and + // fed back into this function or inline RLP which can be fed back into this function). + Prototype::List(2) => match NibbleSlice::from_encoded(r.at(0)?.data()?) { + (slice, true) => Ok(Node::Leaf(slice, r.at(1)?.data()?)), + (slice, false) => Ok(Node::Extension(slice, r.at(1)?.as_raw())), + }, + // branch - first 16 are nodes, 17th is a value (or empty). + Prototype::List(17) => { + let mut nodes = [&[] as &[u8]; 16]; + for i in 0..16 { + nodes[i] = r.at(i)?.as_raw(); + } + Ok(Node::Branch(nodes, if r.at(16)?.is_empty() { None } else { Some(r.at(16)?.data()?) })) + }, + // an empty branch index. + Prototype::Data(0) => Ok(Node::Empty), + // something went wrong. + _ => Err(DecoderError::Custom("Rlp is not valid.")) + } + } + fn try_decode_hash(data: &[u8]) -> Option<::Out> { + let r = Rlp::new(data); + if r.is_data() && r.size() == KeccakHasher::LENGTH { + Some(r.as_val().expect("Hash is the correct size; qed")) + } else { + None + } + } + fn is_empty_node(data: &[u8]) -> bool { + Rlp::new(data).is_empty() + } + fn empty_node() -> ElasticArray1024 { + let mut stream = RlpStream::new(); + stream.append_empty_data(); + stream.drain() + } + + fn leaf_node(partial: &[u8], value: &[u8]) -> ElasticArray1024 { + let mut stream = RlpStream::new_list(2); + stream.append(&partial); + stream.append(&value); + stream.drain() + } + + fn ext_node(partial: &[u8], child_ref: ChildReference<::Out>) -> ElasticArray1024 { + let mut stream = RlpStream::new_list(2); + stream.append(&partial); + match child_ref { + ChildReference::Hash(h) => stream.append(&h), + ChildReference::Inline(inline_data, len) => { + let bytes = &AsRef::<[u8]>::as_ref(&inline_data)[..len]; + stream.append_raw(bytes, 1) + }, + }; + stream.drain() + } + + fn branch_node(children: I, value: Option>) -> ElasticArray1024 + where I: IntoIterator::Out>>> + { + let mut stream = RlpStream::new_list(17); + for child_ref in children { + match child_ref { + Some(c) => match c { + ChildReference::Hash(h) => stream.append(&h), + ChildReference::Inline(inline_data, len) => { + let bytes = &AsRef::<[u8]>::as_ref(&inline_data)[..len]; + stream.append_raw(bytes, 1) + }, + }, + None => stream.append_empty_data() + }; + } + if let Some(value) = value { + stream.append(&&*value); + } else { + stream.append_empty_data(); + } + stream.drain() + } +} \ No newline at end of file diff --git a/substrate/primitives/src/uint.rs b/substrate/primitives/src/uint.rs index b14a8aa4fd6ba..92ab73b70a716 100644 --- a/substrate/primitives/src/uint.rs +++ b/substrate/primitives/src/uint.rs @@ -44,9 +44,7 @@ macro_rules! impl_serde { } construct_uint!(U256, 4); -construct_uint!(U512, 8); impl_serde!(U256, 4); -impl_serde!(U512, 8); #[cfg(test)] mod tests { @@ -68,7 +66,7 @@ mod tests { ($name::from(1_000), "0x3e8"), ($name::from(100_000), "0x186a0"), ($name::from(u64::max_value()), "0xffffffffffffffff"), - ($name::from(u64::max_value()) + 1.into(), "0x10000000000000000"), + ($name::from(u64::max_value()) + $name::from(1), "0x10000000000000000"), ]; for (number, expected) in tests { @@ -87,7 +85,6 @@ mod tests { } test!(U256, test_u256); - test!(U512, test_u512); #[test] fn test_large_values() { diff --git a/substrate/rpc/src/author/mod.rs b/substrate/rpc/src/author/mod.rs index 1d8385c0e9e28..d63bf95a63f34 100644 --- a/substrate/rpc/src/author/mod.rs +++ b/substrate/rpc/src/author/mod.rs @@ -26,7 +26,7 @@ use extrinsic_pool::{ }; use jsonrpc_macros::pubsub; use jsonrpc_pubsub::SubscriptionId; -use primitives::Bytes; +use primitives::{Bytes, KeccakHasher, RlpCodec}; use rpc::futures::{Sink, Stream, Future}; use runtime_primitives::{generic, traits}; use subscriptions::Subscriptions; @@ -89,8 +89,8 @@ impl Author { } impl AuthorApi for Author where - B: client::backend::Backend + Send + Sync + 'static, - E: client::CallExecutor + Send + Sync + 'static, + B: client::backend::Backend + Send + Sync + 'static, + E: client::CallExecutor + Send + Sync + 'static, Block: traits::Block + 'static, Hash: traits::MaybeSerializeDebug + Send + Sync + 'static, InPool: traits::MaybeSerializeDebug + Send + Sync + 'static, diff --git a/substrate/rpc/src/chain/mod.rs b/substrate/rpc/src/chain/mod.rs index 5e00c7f80ab49..5662a5a0b3efb 100644 --- a/substrate/rpc/src/chain/mod.rs +++ b/substrate/rpc/src/chain/mod.rs @@ -26,6 +26,7 @@ use rpc::futures::{stream, Future, Sink, Stream}; use runtime_primitives::generic::{BlockId, SignedBlock}; use runtime_primitives::traits::Block as BlockT; use tokio::runtime::TaskExecutor; +use primitives::{KeccakHasher, RlpCodec}; use subscriptions::Subscriptions; @@ -84,8 +85,8 @@ impl Chain { impl ChainApi for Chain where Block: BlockT + 'static, - B: client::backend::Backend + Send + Sync + 'static, - E: client::CallExecutor + Send + Sync + 'static, + B: client::backend::Backend + Send + Sync + 'static, + E: client::CallExecutor + Send + Sync + 'static, { type Metadata = ::metadata::Metadata; diff --git a/substrate/rpc/src/state/mod.rs b/substrate/rpc/src/state/mod.rs index 0ae462452fe1c..28aa01710955c 100644 --- a/substrate/rpc/src/state/mod.rs +++ b/substrate/rpc/src/state/mod.rs @@ -27,6 +27,7 @@ use jsonrpc_macros::pubsub; use jsonrpc_pubsub::SubscriptionId; use primitives::hexdisplay::HexDisplay; use primitives::storage::{StorageKey, StorageData, StorageChangeSet}; +use primitives::{KeccakHasher, RlpCodec}; use rpc::Result as RpcResult; use rpc::futures::{stream, Future, Sink, Stream}; use runtime_primitives::generic::BlockId; @@ -101,8 +102,8 @@ impl State { impl State where Block: BlockT + 'static, - B: client::backend::Backend + Send + Sync + 'static, - E: CallExecutor + Send + Sync + 'static, + B: client::backend::Backend + Send + Sync + 'static, + E: CallExecutor + Send + Sync + 'static, { fn unwrap_or_best(&self, hash: Trailing) -> Result { Ok(match hash.into() { @@ -114,8 +115,8 @@ impl State where impl StateApi for State where Block: BlockT + 'static, - B: client::backend::Backend + Send + Sync + 'static, - E: CallExecutor + Send + Sync + 'static, + B: client::backend::Backend + Send + Sync + 'static, + E: CallExecutor + Send + Sync + 'static, { type Metadata = ::metadata::Metadata; diff --git a/substrate/runtime-io/with_std.rs b/substrate/runtime-io/with_std.rs index 3d3b2552082b3..f543b8ae2c893 100644 --- a/substrate/runtime-io/with_std.rs +++ b/substrate/runtime-io/with_std.rs @@ -29,12 +29,16 @@ pub extern crate substrate_codec as codec; // re-export hashing functions. pub use primitives::{blake2_256, twox_128, twox_256}; +pub use primitives::KeccakHasher; +// Switch to this after PoC-3 +// pub use primitives::BlakeHasher; pub use substrate_state_machine::{Externalities, TestExternalities}; use primitives::hexdisplay::HexDisplay; +use primitives::H256; // TODO: use the real error, not NoError. -environmental!(ext: trait Externalities); +environmental!(ext: trait Externalities); /// Get `key` from storage and return a `Vec`, empty if there's a problem. pub fn storage(key: &[u8]) -> Option> { @@ -90,10 +94,10 @@ pub fn chain_id() -> u64 { } /// "Commit" all existing operations and get the resultant storage root. -pub fn storage_root() -> [u8; 32] { +pub fn storage_root() -> H256 { ext::with(|ext| ext.storage_root() - ).unwrap_or([0u8; 32]) + ).unwrap_or(H256::new()) } /// A trie root formed from the enumerated items. @@ -125,7 +129,8 @@ pub fn ed25519_verify>(sig: &[u8; 64], msg: &[u8], pubkey: P) -> /// Execute the given closure with global function available whose functionality routes into the /// externalities `ext`. Forwards the value that the closure returns. -pub fn with_externalities R>(ext: &mut Externalities, f: F) -> R { +// NOTE: need a concrete hasher here due to limitations of the `environmental!` macro, otherwise a type param would have been fine I think. +pub fn with_externalities R>(ext: &mut Externalities, f: F) -> R { ext::using(ext, f) } @@ -191,7 +196,7 @@ mod std_tests { #[test] fn storage_works() { - let mut t = TestExternalities::new(); + let mut t = TestExternalities::::new(); assert!(with_externalities(&mut t, || { assert_eq!(storage(b"hello"), None); set_storage(b"hello", b"world"); @@ -212,7 +217,7 @@ mod std_tests { #[test] fn read_storage_works() { - let mut t: TestExternalities = map![ + let mut t: TestExternalities = map![ b":test".to_vec() => b"\x0b\0\0\0Hello world".to_vec() ]; @@ -228,7 +233,7 @@ mod std_tests { #[test] fn clear_prefix_works() { - let mut t: TestExternalities = map![ + let mut t: TestExternalities = map![ b":a".to_vec() => b"\x0b\0\0\0Hello world".to_vec(), b":abcd".to_vec() => b"\x0b\0\0\0Hello world".to_vec(), b":abc".to_vec() => b"\x0b\0\0\0Hello world".to_vec(), diff --git a/substrate/runtime/consensus/src/lib.rs b/substrate/runtime/consensus/src/lib.rs index 13d40afe5eab1..3b9e2554b4631 100644 --- a/substrate/runtime/consensus/src/lib.rs +++ b/substrate/runtime/consensus/src/lib.rs @@ -45,6 +45,11 @@ use runtime_support::storage::unhashed::StorageVec; use primitives::traits::{RefInto, MaybeSerializeDebug, MaybeEmpty}; use primitives::bft::MisbehaviorReport; +#[cfg(any(feature = "std", test))] +use substrate_primitives::KeccakHasher; +#[cfg(any(feature = "std", test))] +use std::collections::HashMap; + pub const AUTHORITY_AT: &'static [u8] = b":auth:"; pub const AUTHORITY_COUNT: &'static [u8] = b":auth:len"; @@ -146,14 +151,14 @@ impl Default for GenesisConfig { #[cfg(any(feature = "std", test))] impl primitives::BuildStorage for GenesisConfig { - fn build_storage(self) -> ::std::result::Result { + fn build_storage(self) -> ::std::result::Result, Vec>, String> { use codec::{Encode, KeyedVec}; let auth_count = self.authorities.len() as u32; - let mut r: runtime_io::TestExternalities = self.authorities.into_iter().enumerate().map(|(i, v)| + let mut r: runtime_io::TestExternalities = self.authorities.into_iter().enumerate().map(|(i, v)| ((i as u32).to_keyed_vec(AUTHORITY_AT), v.encode()) ).collect(); r.insert(AUTHORITY_COUNT.to_vec(), auth_count.encode()); r.insert(CODE.to_vec(), self.code); - Ok(r) + Ok(r.into()) } } diff --git a/substrate/runtime/contract/Cargo.toml b/substrate/runtime/contract/Cargo.toml index 23291d4d67e48..0658425c06cb4 100644 --- a/substrate/runtime/contract/Cargo.toml +++ b/substrate/runtime/contract/Cargo.toml @@ -7,6 +7,7 @@ authors = ["Parity Technologies "] serde = { version = "1.0", default_features = false } serde_derive = { version = "1.0", optional = true } substrate-codec = { path = "../../codec", default_features = false } +substrate-primitives = { path = "../../primitives" } substrate-runtime-consensus = { path = "../../runtime/consensus", default_features = false } substrate-runtime-primitives = { path = "../../runtime/primitives" } substrate-runtime-io = { path = "../../runtime-io", default_features = false } diff --git a/substrate/runtime/contract/src/genesis_config.rs b/substrate/runtime/contract/src/genesis_config.rs index d841f22806a6a..89f94b40b94ef 100644 --- a/substrate/runtime/contract/src/genesis_config.rs +++ b/substrate/runtime/contract/src/genesis_config.rs @@ -22,6 +22,8 @@ use runtime_primitives; use runtime_io::{self, twox_128}; use runtime_support::StorageValue; use codec::Encode; +use std::collections::HashMap; +use substrate_primitives::KeccakHasher; #[derive(Serialize, Deserialize)] #[serde(rename_all = "camelCase")] @@ -35,14 +37,14 @@ pub struct GenesisConfig { } impl runtime_primitives::BuildStorage for GenesisConfig { - fn build_storage(self) -> Result { - let r: runtime_io::TestExternalities = map![ + fn build_storage(self) -> ::std::result::Result, Vec>, String> { + let r: runtime_io::TestExternalities = map![ twox_128(>::key()).to_vec() => self.contract_fee.encode(), twox_128(>::key()).to_vec() => self.call_base_fee.encode(), twox_128(>::key()).to_vec() => self.create_base_fee.encode(), twox_128(>::key()).to_vec() => self.gas_price.encode(), twox_128(>::key()).to_vec() => self.max_depth.encode() ]; - Ok(r) + Ok(r.into()) } } diff --git a/substrate/runtime/contract/src/lib.rs b/substrate/runtime/contract/src/lib.rs index 123574b27c0ac..6761c03442bc6 100644 --- a/substrate/runtime/contract/src/lib.rs +++ b/substrate/runtime/contract/src/lib.rs @@ -65,6 +65,7 @@ extern crate substrate_runtime_session as session; extern crate substrate_runtime_support as runtime_support; extern crate substrate_runtime_primitives as runtime_primitives; +extern crate substrate_primitives; #[cfg(test)] #[macro_use] diff --git a/substrate/runtime/contract/src/tests.rs b/substrate/runtime/contract/src/tests.rs index d9839dae26452..53a324907e572 100644 --- a/substrate/runtime/contract/src/tests.rs +++ b/substrate/runtime/contract/src/tests.rs @@ -20,6 +20,7 @@ use runtime_primitives::testing::{Digest, H256, Header}; use runtime_primitives::traits::{BlakeTwo256, HasPublicAux, Identity}; use runtime_primitives::BuildStorage; use runtime_support::StorageMap; +use substrate_primitives::KeccakHasher; use wabt; use { consensus, runtime_io, session, staking, system, timestamp, CodeOf, ContractAddressFor, @@ -73,7 +74,7 @@ impl ContractAddressFor for DummyContractAddressFor { } } -fn new_test_ext(existential_deposit: u64, gas_price: u64) -> runtime_io::TestExternalities { +fn new_test_ext(existential_deposit: u64, gas_price: u64) -> runtime_io::TestExternalities { let mut t = system::GenesisConfig::::default() .build_storage() .unwrap(); @@ -126,7 +127,7 @@ fn new_test_ext(existential_deposit: u64, gas_price: u64) -> runtime_io::TestExt }.build_storage() .unwrap(), ); - t + t.into() } const CODE_TRANSFER: &str = r#" diff --git a/substrate/runtime/council/src/lib.rs b/substrate/runtime/council/src/lib.rs index 1fd210021a71d..78be6c1804168 100644 --- a/substrate/runtime/council/src/lib.rs +++ b/substrate/runtime/council/src/lib.rs @@ -46,6 +46,8 @@ use primitives::traits::{Zero, One, RefInto, As, AuxLookup}; use substrate_runtime_support::{StorageValue, StorageMap}; use substrate_runtime_support::dispatch::Result; use staking::address::Address; +#[cfg(any(feature = "std", test))] +use std::collections::HashMap; pub mod voting; @@ -590,7 +592,7 @@ impl Default for GenesisConfig { #[cfg(any(feature = "std", test))] impl primitives::BuildStorage for GenesisConfig { - fn build_storage(self) -> ::std::result::Result { + fn build_storage(self) -> ::std::result::Result, Vec>, String> { use codec::Encode; Ok(map![ @@ -614,12 +616,14 @@ impl primitives::BuildStorage for GenesisConfig #[cfg(test)] mod tests { + // These re-exports are here for a reason, edit with care pub use super::*; pub use runtime_io::with_externalities; pub use substrate_primitives::H256; use primitives::BuildStorage; use primitives::traits::{HasPublicAux, Identity, BlakeTwo256}; use primitives::testing::{Digest, Header}; + use substrate_primitives::KeccakHasher; impl_outer_dispatch! { #[derive(Debug, Clone, Eq, Serialize, Deserialize, PartialEq)] @@ -667,7 +671,7 @@ mod tests { } impl Trait for Test {} - pub fn new_test_ext(with_council: bool) -> runtime_io::TestExternalities { + pub fn new_test_ext(with_council: bool) -> runtime_io::TestExternalities { let mut t = system::GenesisConfig::::default().build_storage().unwrap(); t.extend(consensus::GenesisConfig::{ code: vec![], @@ -718,7 +722,7 @@ mod tests { voting_period: 1, }.build_storage().unwrap()); t.extend(timestamp::GenesisConfig::::default().build_storage().unwrap()); - t + t.into() } pub type System = system::Module; @@ -784,7 +788,7 @@ mod tests { }); } - fn new_test_ext_with_candidate_holes() -> runtime_io::TestExternalities { + fn new_test_ext_with_candidate_holes() -> runtime_io::TestExternalities { let mut t = new_test_ext(false); with_externalities(&mut t, || { >::put(vec![0, 0, 1]); diff --git a/substrate/runtime/democracy/src/lib.rs b/substrate/runtime/democracy/src/lib.rs index 6e07a1991bf00..2c07d5b0d0f99 100644 --- a/substrate/runtime/democracy/src/lib.rs +++ b/substrate/runtime/democracy/src/lib.rs @@ -51,6 +51,9 @@ use primitives::traits::{Zero, Executable, RefInto, As, MaybeSerializeDebug}; use substrate_runtime_support::{StorageValue, StorageMap, Parameter, Dispatchable, IsSubType}; use substrate_runtime_support::dispatch::Result; +#[cfg(any(feature = "std", test))] +use std::collections::HashMap; + mod vote_threshold; pub use vote_threshold::{Approved, VoteThreshold}; @@ -339,7 +342,7 @@ impl Default for GenesisConfig { #[cfg(any(feature = "std", test))] impl primitives::BuildStorage for GenesisConfig { - fn build_storage(self) -> ::std::result::Result { + fn build_storage(self) -> ::std::result::Result, Vec>, String> { use codec::Encode; Ok(map![ @@ -357,7 +360,7 @@ impl primitives::BuildStorage for GenesisConfig mod tests { use super::*; use runtime_io::with_externalities; - use substrate_primitives::H256; + use substrate_primitives::{H256, KeccakHasher}; use primitives::BuildStorage; use primitives::traits::{HasPublicAux, Identity, BlakeTwo256}; use primitives::testing::{Digest, Header}; @@ -409,7 +412,7 @@ mod tests { type Proposal = Proposal; } - fn new_test_ext() -> runtime_io::TestExternalities { + fn new_test_ext() -> runtime_io::TestExternalities { let mut t = system::GenesisConfig::::default().build_storage().unwrap(); t.extend(consensus::GenesisConfig::{ code: vec![], @@ -442,7 +445,7 @@ mod tests { minimum_deposit: 1, }.build_storage().unwrap()); t.extend(timestamp::GenesisConfig::::default().build_storage().unwrap()); - t + t.into() } type System = system::Module; diff --git a/substrate/runtime/executive/src/lib.rs b/substrate/runtime/executive/src/lib.rs index a918f062e86a5..6910f65ee3f3e 100644 --- a/substrate/runtime/executive/src/lib.rs +++ b/substrate/runtime/executive/src/lib.rs @@ -218,7 +218,7 @@ mod tests { use super::*; use staking::Call; use runtime_io::with_externalities; - use substrate_primitives::H256; + use substrate_primitives::{H256, KeccakHasher}; use primitives::BuildStorage; use primitives::traits::{HasPublicAux, Identity, Header as HeaderT, BlakeTwo256, AuxLookup}; use primitives::testing::{Digest, Header, Block}; @@ -289,6 +289,7 @@ mod tests { session_reward: 0, }.build_storage().unwrap()); let xt = primitives::testing::TestXt((1, 0, Call::transfer(2.into(), 69))); + let mut t = runtime_io::TestExternalities::from(t); with_externalities(&mut t, || { Executive::initialise_block(&Header::new(1, H256::default(), H256::default(), [69u8; 32].into(), Digest::default())); Executive::apply_extrinsic(xt).unwrap(); @@ -297,13 +298,13 @@ mod tests { }); } - fn new_test_ext() -> runtime_io::TestExternalities { + fn new_test_ext() -> runtime_io::TestExternalities { let mut t = system::GenesisConfig::::default().build_storage().unwrap(); t.extend(consensus::GenesisConfig::::default().build_storage().unwrap()); t.extend(session::GenesisConfig::::default().build_storage().unwrap()); t.extend(staking::GenesisConfig::::default().build_storage().unwrap()); t.extend(timestamp::GenesisConfig::::default().build_storage().unwrap()); - t + t.into() } #[test] @@ -313,8 +314,11 @@ mod tests { header: Header { parent_hash: [69u8; 32].into(), number: 1, + // Blake + // state_root: hex!("02532989c613369596025dfcfc821339fc9861987003924913a5a1382f87034a").into(), + // Keccak state_root: hex!("8fad93b6b9e5251a2e4913598fd0d74a138c0e486eb1133ff8081b429b0c56f2").into(), - extrinsics_root: hex!("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").into(), + extrinsics_root: hex!("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").into(), // REVIEW: I expected this to be wrong with a different hasher? digest: Digest { logs: vec![], }, }, extrinsics: vec![], diff --git a/substrate/runtime/session/src/lib.rs b/substrate/runtime/session/src/lib.rs index 9870b81f9a3a0..59ba338e77a66 100644 --- a/substrate/runtime/session/src/lib.rs +++ b/substrate/runtime/session/src/lib.rs @@ -50,6 +50,9 @@ use primitives::traits::{Zero, One, RefInto, MaybeEmpty, Executable, Convert, As use runtime_support::{StorageValue, StorageMap}; use runtime_support::dispatch::Result; +#[cfg(any(feature = "std", test))] +use std::collections::HashMap; + /// A session has changed. pub trait OnSessionChange { /// Session has changed. @@ -265,7 +268,8 @@ impl Default for GenesisConfig { #[cfg(any(feature = "std", test))] impl primitives::BuildStorage for GenesisConfig { - fn build_storage(self) -> ::std::result::Result { + fn build_storage(self) -> ::std::result::Result, Vec>, String> { + use codec::Encode; use primitives::traits::As; Ok(map![ @@ -282,7 +286,7 @@ impl primitives::BuildStorage for GenesisConfig mod tests { use super::*; use runtime_io::with_externalities; - use substrate_primitives::H256; + use substrate_primitives::{H256, KeccakHasher}; use primitives::BuildStorage; use primitives::traits::{HasPublicAux, Identity, BlakeTwo256}; use primitives::testing::{Digest, Header}; @@ -320,7 +324,7 @@ mod tests { type Timestamp = timestamp::Module; type Session = Module; - fn new_test_ext() -> runtime_io::TestExternalities { + fn new_test_ext() -> runtime_io::TestExternalities { let mut t = system::GenesisConfig::::default().build_storage().unwrap(); t.extend(consensus::GenesisConfig::{ code: vec![], @@ -334,7 +338,7 @@ mod tests { validators: vec![1, 2, 3], broken_percent_late: 30, }.build_storage().unwrap()); - t + t.into() } #[test] diff --git a/substrate/runtime/staking/src/genesis_config.rs b/substrate/runtime/staking/src/genesis_config.rs index 2987725b7a235..af221cc3862ac 100644 --- a/substrate/runtime/staking/src/genesis_config.rs +++ b/substrate/runtime/staking/src/genesis_config.rs @@ -18,10 +18,12 @@ #![cfg(feature = "std")] +use std::collections::HashMap; use rstd::prelude::*; use codec::Encode; use runtime_support::{StorageValue, StorageMap}; use primitives::traits::{Zero, As}; +use substrate_primitives::KeccakHasher; use {runtime_io, primitives}; use super::{Trait, ENUM_SET_SIZE, EnumSet, NextEnumSet, Intentions, CurrentEra, BondingDuration, CreationFee, TransferFee, ReclaimRebate, @@ -118,10 +120,10 @@ impl Default for GenesisConfig { } impl primitives::BuildStorage for GenesisConfig { - fn build_storage(self) -> Result { + fn build_storage(self) -> ::std::result::Result, Vec>, String> { let total_stake: T::Balance = self.balances.iter().fold(Zero::zero(), |acc, &(_, n)| acc + n); - let mut r: runtime_io::TestExternalities = map![ + let mut r: runtime_io::TestExternalities = map![ Self::hash(>::key()).to_vec() => T::AccountIndex::sa(self.balances.len() / ENUM_SET_SIZE).encode(), Self::hash(>::key()).to_vec() => self.intentions.encode(), Self::hash(>::key()).to_vec() => self.sessions_per_era.encode(), @@ -147,6 +149,6 @@ impl primitives::BuildStorage for GenesisConfig { for (who, value) in self.balances.into_iter() { r.insert(Self::hash(&>::key_for(who)).to_vec(), value.encode()); } - Ok(r) + Ok(r.into()) } } diff --git a/substrate/runtime/staking/src/mock.rs b/substrate/runtime/staking/src/mock.rs index dcc96b03735e1..2f3024d78d0ff 100644 --- a/substrate/runtime/staking/src/mock.rs +++ b/substrate/runtime/staking/src/mock.rs @@ -21,7 +21,7 @@ use primitives::BuildStorage; use primitives::traits::{HasPublicAux, Identity}; use primitives::testing::{Digest, Header}; -use substrate_primitives::H256; +use substrate_primitives::{H256, KeccakHasher}; use runtime_io; use {GenesisConfig, Module, Trait, consensus, session, system, timestamp}; @@ -59,7 +59,7 @@ impl Trait for Test { type OnAccountKill = (); } -pub fn new_test_ext(ext_deposit: u64, session_length: u64, sessions_per_era: u64, current_era: u64, monied: bool, reward: u64) -> runtime_io::TestExternalities { +pub fn new_test_ext(ext_deposit: u64, session_length: u64, sessions_per_era: u64, current_era: u64, monied: bool, reward: u64) -> runtime_io::TestExternalities { let mut t = system::GenesisConfig::::default().build_storage().unwrap(); let balance_factor = if ext_deposit > 0 { 256 @@ -102,7 +102,7 @@ pub fn new_test_ext(ext_deposit: u64, session_length: u64, sessions_per_era: u64 t.extend(timestamp::GenesisConfig::{ period: 5 }.build_storage().unwrap()); - t + t.into() } pub type System = system::Module; diff --git a/substrate/runtime/system/src/lib.rs b/substrate/runtime/system/src/lib.rs index 002c540590557..60dd6059b4070 100644 --- a/substrate/runtime/system/src/lib.rs +++ b/substrate/runtime/system/src/lib.rs @@ -49,7 +49,7 @@ use rstd::marker::PhantomData; use codec::Encode; #[cfg(any(feature = "std", test))] -use runtime_io::{twox_128, TestExternalities}; +use runtime_io::{twox_128, TestExternalities, KeccakHasher}; /// Compute the extrinsics root of a list of extrinsics. pub fn extrinsics_root(extrinsics: &[E]) -> H::Output { @@ -142,7 +142,7 @@ impl Module { /// Get the basic externalities for this module, useful for tests. #[cfg(any(feature = "std", test))] - pub fn externalities() -> TestExternalities { + pub fn externalities() -> TestExternalities { map![ twox_128(&>::key_for(T::BlockNumber::zero())).to_vec() => [69u8; 32].encode(), // TODO: replace with Hash::default().encode twox_128(>::key()).to_vec() => T::BlockNumber::one().encode(), @@ -207,7 +207,7 @@ impl Default for GenesisConfig { #[cfg(any(feature = "std", test))] impl primitives::BuildStorage for GenesisConfig { - fn build_storage(self) -> Result { + fn build_storage(self) -> Result { use codec::Encode; Ok(map![ diff --git a/substrate/runtime/timestamp/Cargo.toml b/substrate/runtime/timestamp/Cargo.toml index 1b5637a2c33a6..c87da900bfe19 100644 --- a/substrate/runtime/timestamp/Cargo.toml +++ b/substrate/runtime/timestamp/Cargo.toml @@ -26,6 +26,7 @@ std = [ "substrate-runtime-io/std", "substrate-runtime-support/std", "substrate-runtime-primitives/std", + "substrate-runtime-consensus/std", "serde/std", "serde_derive", "substrate-codec/std", diff --git a/substrate/runtime/timestamp/src/lib.rs b/substrate/runtime/timestamp/src/lib.rs index 0d20bd6b58e97..21a1e8ee84513 100644 --- a/substrate/runtime/timestamp/src/lib.rs +++ b/substrate/runtime/timestamp/src/lib.rs @@ -173,7 +173,7 @@ mod tests { fn timestamp_works() { let mut t = system::GenesisConfig::::default().build_storage().unwrap(); t.extend(GenesisConfig:: { period: 0 }.build_storage().unwrap()); - + let mut t = runtime_io::TestExternalities::from(t); with_externalities(&mut t, || { Timestamp::set_timestamp(42); assert_ok!(Timestamp::aux_dispatch(Call::set(69), &0)); @@ -186,7 +186,7 @@ mod tests { fn double_timestamp_should_fail() { let mut t = system::GenesisConfig::::default().build_storage().unwrap(); t.extend(GenesisConfig:: { period: 5 }.build_storage().unwrap()); - + let mut t = runtime_io::TestExternalities::from(t); with_externalities(&mut t, || { Timestamp::set_timestamp(42); assert_ok!(Timestamp::aux_dispatch(Call::set(69), &0)); @@ -199,7 +199,7 @@ mod tests { fn block_period_is_enforced() { let mut t = system::GenesisConfig::::default().build_storage().unwrap(); t.extend(GenesisConfig:: { period: 5 }.build_storage().unwrap()); - + let mut t = runtime_io::TestExternalities::from(t); with_externalities(&mut t, || { Timestamp::set_timestamp(42); let _ = Timestamp::aux_dispatch(Call::set(46), &0); diff --git a/substrate/service/src/components.rs b/substrate/service/src/components.rs index a6c83db888206..d653168fbbfc5 100644 --- a/substrate/service/src/components.rs +++ b/substrate/service/src/components.rs @@ -28,6 +28,7 @@ use substrate_executor::{NativeExecutor, NativeExecutionDispatch}; use extrinsic_pool::{txpool::Options as ExtrinsicPoolOptions, api::ExtrinsicPool as ExtrinsicPoolApi}; use runtime_primitives::{traits::Block as BlockT, traits::Header as HeaderT, generic::BlockId, BuildStorage}; use config::Configuration; +use primitives::{KeccakHasher, RlpCodec, H256}; // Type aliases. // These exist mainly to avoid typing `::Foo` all over the code. @@ -152,9 +153,9 @@ pub trait Components { /// Associated service factory. type Factory: ServiceFactory; /// Client backend. - type Backend: 'static + client::backend::Backend>; + type Backend: 'static + client::backend::Backend, KeccakHasher, RlpCodec>; /// Client executor. - type Executor: 'static + client::CallExecutor> + Send + Sync; + type Executor: 'static + client::CallExecutor, KeccakHasher, RlpCodec> + Send + Sync; /// Extrinsic pool type. type ExtrinsicPool: ExtrinsicPool>; @@ -215,7 +216,7 @@ pub struct LightComponents { impl Components for LightComponents where - <::Block as BlockT>::Hash: Into<[u8; 32]>, + <::Block as BlockT>::Hash: Into, { type Factory = Factory; type Executor = LightExecutor; @@ -239,7 +240,7 @@ impl Components for LightComponents }; let db_storage = client_db::light::LightStorage::new(db_settings)?; let light_blockchain = client::light::new_light_blockchain(db_storage); - let fetch_checker = Arc::new(client::light::new_fetch_checker(executor)); + let fetch_checker = Arc::new(client::light::new_fetch_checker::<_, KeccakHasher, RlpCodec>(executor)); let fetcher = Arc::new(network::OnDemand::new(fetch_checker)); let client_backend = client::light::new_light_backend(light_blockchain, fetcher.clone()); let client = client::light::new_light(client_backend, fetcher.clone(), &config.chain_spec)?; diff --git a/substrate/state-machine/Cargo.toml b/substrate/state-machine/Cargo.toml index 17b072c4c6687..6e199f429b0be 100644 --- a/substrate/state-machine/Cargo.toml +++ b/substrate/state-machine/Cargo.toml @@ -6,14 +6,15 @@ description = "Substrate State Machine" [dependencies] byteorder = "1.1" -ethereum-types = "0.3" hex-literal = "0.1.0" log = "0.3" parking_lot = "0.4" -triehash = "0.1" +heapsize = "0.4" substrate-primitives = { path = "../primitives", version = "0.1.0" } -hashdb = { git = "https://github.com/paritytech/parity.git" } -memorydb = { git = "https://github.com/paritytech/parity.git" } -patricia-trie = { git = "https://github.com/paritytech/parity.git" } +hashdb = { git = "https://github.com/paritytech/parity-common" } +memorydb = { git = "https://github.com/paritytech/parity-common" } +patricia-trie = { git = "https://github.com/paritytech/parity-common" } +triehash = { git = "https://github.com/paritytech/parity-common" } +rlp = { git = "https://github.com/paritytech/parity-common" } diff --git a/substrate/state-machine/src/backend.rs b/substrate/state-machine/src/backend.rs index 1d3b2108f9e3b..7db1e64d3f25f 100644 --- a/substrate/state-machine/src/backend.rs +++ b/substrate/state-machine/src/backend.rs @@ -17,15 +17,22 @@ //! State machine backends. These manage the code and storage of contracts. use std::{error, fmt}; +use std::cmp::Ord; use std::collections::HashMap; +use std::marker::PhantomData; use std::sync::Arc; + +use hashdb::Hasher; +use rlp::Encodable; use trie_backend::{TryIntoTrieBackend, TrieBackend}; +use patricia_trie::{TrieDBMut, TrieMut, NodeCodec}; +use heapsize::HeapSizeOf; /// A state backend is used to read state data and can have changes committed /// to it. /// /// The clone operation (if implemented) should be cheap. -pub trait Backend: TryIntoTrieBackend { +pub trait Backend>: TryIntoTrieBackend { /// An error type when fetching data is not possible. type Error: super::Error; @@ -46,8 +53,10 @@ pub trait Backend: TryIntoTrieBackend { /// Calculate the storage root, with given delta over what is already stored in /// the backend, and produce a "transaction" that can be used to commit. - fn storage_root(&self, delta: I) -> ([u8; 32], Self::Transaction) - where I: IntoIterator, Option>)>; + fn storage_root(&self, delta: I) -> (H::Out, Self::Transaction) + where + I: IntoIterator, Option>)>, + H::Out: Ord + Encodable; /// Get all key/value pairs into a Vec. fn pairs(&self) -> Vec<(Vec, Vec)>; @@ -70,22 +79,40 @@ impl error::Error for Void { /// In-memory backend. Fully recomputes tries on each commit but useful for /// tests. -#[derive(Clone, PartialEq, Eq)] -pub struct InMemory { +#[derive(Eq)] +pub struct InMemory { inner: Arc, Vec>>, + _hasher: PhantomData, + _codec: PhantomData, } -impl Default for InMemory { +impl Default for InMemory { fn default() -> Self { InMemory { inner: Arc::new(Default::default()), + _hasher: PhantomData, + _codec: PhantomData, + } + } +} + +impl Clone for InMemory { + fn clone(&self) -> Self { + InMemory { + inner: self.inner.clone(), _hasher: PhantomData, _codec: PhantomData, } } } -impl InMemory { +impl PartialEq for InMemory { + fn eq(&self, other: &Self) -> bool { + self.inner.eq(&other.inner) + } +} + +impl> InMemory where H::Out: HeapSizeOf { /// Copy the state, with applied updates - pub fn update(&self, changes: ::Transaction) -> Self { + pub fn update(&self, changes: >::Transaction) -> Self { let mut inner: HashMap<_, _> = (&*self.inner).clone(); for (key, val) in changes { match val { @@ -98,17 +125,17 @@ impl InMemory { } } -impl From, Vec>> for InMemory { +impl From, Vec>> for InMemory { fn from(inner: HashMap, Vec>) -> Self { InMemory { - inner: Arc::new(inner), + inner: Arc::new(inner), _hasher: PhantomData, _codec: PhantomData } } } impl super::Error for Void {} -impl Backend for InMemory { +impl> Backend for InMemory where H::Out: HeapSizeOf { type Error = Void; type Transaction = Vec<(Vec, Option>)>; @@ -124,17 +151,19 @@ impl Backend for InMemory { self.inner.keys().filter(|key| key.starts_with(prefix)).map(|k| &**k).for_each(f); } - fn storage_root(&self, delta: I) -> ([u8; 32], Self::Transaction) - where I: IntoIterator, Option>)> + fn storage_root(&self, delta: I) -> (H::Out, Self::Transaction) + where + I: IntoIterator, Option>)>, + ::Out: Ord + Encodable, { let existing_pairs = self.inner.iter().map(|(k, v)| (k.clone(), Some(v.clone()))); let transaction: Vec<_> = delta.into_iter().collect(); - let root = ::triehash::trie_root(existing_pairs.chain(transaction.iter().cloned()) + let root = ::triehash::trie_root::(existing_pairs.chain(transaction.iter().cloned()) .collect::>() .into_iter() .filter_map(|(k, maybe_val)| maybe_val.map(|val| (k, val))) - ).0; + ); (root, transaction) } @@ -144,16 +173,13 @@ impl Backend for InMemory { } } -impl TryIntoTrieBackend for InMemory { - fn try_into_trie_backend(self) -> Option { - use ethereum_types::H256 as TrieH256; +impl> TryIntoTrieBackend for InMemory where H::Out: HeapSizeOf { + fn try_into_trie_backend(self) -> Option> { use memorydb::MemoryDB; - use patricia_trie::{TrieDBMut, TrieMut}; - - let mut root = TrieH256::default(); - let mut mdb = MemoryDB::default(); + let mut root = ::Out::default(); + let mut mdb = MemoryDB::new(); { - let mut trie = TrieDBMut::new(&mut mdb, &mut root); + let mut trie = TrieDBMut::::new(&mut mdb, &mut root); for (key, value) in self.inner.iter() { if let Err(e) = trie.insert(&key, &value) { warn!(target: "trie", "Failed to write to trie: {}", e); diff --git a/substrate/state-machine/src/ext.rs b/substrate/state-machine/src/ext.rs index 5a8ba096f5753..43129e989474f 100644 --- a/substrate/state-machine/src/ext.rs +++ b/substrate/state-machine/src/ext.rs @@ -16,9 +16,12 @@ //! Conrete externalities implementation. -use std::{error, fmt}; +use std::{error, fmt, cmp::Ord}; use backend::Backend; use {Externalities, OverlayedChanges}; +use hashdb::Hasher; +use rlp::Encodable; +use patricia_trie::NodeCodec; /// Errors that can occur when interacting with the externalities. #[derive(Debug, Copy, Clone)] @@ -50,16 +53,27 @@ impl error::Error for Error { } /// Wraps a read-only backend, call executor, and current overlayed changes. -pub struct Ext<'a, B: 'a + Backend> { +pub struct Ext<'a, H, C, B> +where + H: Hasher, + C: NodeCodec, + B: 'a + Backend, +{ // The overlayed changes to write to. overlay: &'a mut OverlayedChanges, // The storage backend to read from. backend: &'a B, // The transaction necessary to commit to the backend. - transaction: Option<(B::Transaction, [u8; 32])>, + transaction: Option<(B::Transaction, H::Out)>, } -impl<'a, B: 'a + Backend> Ext<'a, B> { +impl<'a, H, C, B> Ext<'a, H, C, B> +where + H: Hasher, + C: NodeCodec, + B: 'a + Backend, + H::Out: Ord + Encodable +{ /// Create a new `Ext` from overlayed changes and read-only backend pub fn new(overlay: &'a mut OverlayedChanges, backend: &'a B) -> Self { Ext { @@ -84,7 +98,12 @@ impl<'a, B: 'a + Backend> Ext<'a, B> { } #[cfg(test)] -impl<'a, B: 'a + Backend> Ext<'a, B> { +impl<'a, H, C, B> Ext<'a, H, C, B> +where + H: Hasher, + C: NodeCodec, + B: 'a + Backend, +{ pub fn storage_pairs(&self) -> Vec<(Vec, Vec)> { use std::collections::HashMap; @@ -99,8 +118,12 @@ impl<'a, B: 'a + Backend> Ext<'a, B> { } } -impl<'a, B: 'a> Externalities for Ext<'a, B> - where B: Backend +impl<'a, B: 'a, H, C> Externalities for Ext<'a, H, C, B> +where + H: Hasher, + C: NodeCodec, + B: 'a + Backend, + H::Out: Ord + Encodable { fn storage(&self, key: &[u8]) -> Option> { self.overlay.storage(key).map(|x| x.map(|x| x.to_vec())).unwrap_or_else(|| @@ -131,7 +154,7 @@ impl<'a, B: 'a> Externalities for Ext<'a, B> 42 } - fn storage_root(&mut self) -> [u8; 32] { + fn storage_root(&mut self) -> H::Out { if let Some((_, ref root)) = self.transaction { return root.clone(); } diff --git a/substrate/state-machine/src/lib.rs b/substrate/state-machine/src/lib.rs index 9b0afc37bb00e..17ccc412287be 100644 --- a/substrate/state-machine/src/lib.rs +++ b/substrate/state-machine/src/lib.rs @@ -24,17 +24,23 @@ extern crate hex_literal; #[macro_use] extern crate log; -extern crate ethereum_types; extern crate hashdb; extern crate memorydb; extern crate triehash; extern crate patricia_trie; - extern crate byteorder; extern crate parking_lot; +extern crate rlp; +extern crate heapsize; +#[cfg(test)] +extern crate substrate_primitives as primitives; use std::collections::HashMap; use std::fmt; +use hashdb::Hasher; +use patricia_trie::NodeCodec; +use rlp::Encodable; +use heapsize::HeapSizeOf; pub mod backend; mod ext; @@ -45,7 +51,7 @@ mod trie_backend; pub use testing::TestExternalities; pub use ext::Ext; pub use backend::Backend; -pub use trie_backend::{TryIntoTrieBackend, TrieBackend, TrieH256, Storage, DBValue}; +pub use trie_backend::{TryIntoTrieBackend, TrieBackend, Storage, DBValue}; /// The overlayed changes to state to be queried on top of the backend. /// @@ -158,7 +164,7 @@ impl fmt::Display for ExecutionError { } /// Externalities: pinned to specific active address. -pub trait Externalities { +pub trait Externalities { /// Read storage of current contract being called. fn storage(&self, key: &[u8]) -> Option>; @@ -187,17 +193,17 @@ pub trait Externalities { fn chain_id(&self) -> u64; /// Get the trie root of the current storage map. - fn storage_root(&mut self) -> [u8; 32]; + fn storage_root(&mut self) -> H::Out where H::Out: Ord + Encodable; } /// Code execution engine. -pub trait CodeExecutor: Sized + Send + Sync { +pub trait CodeExecutor: Sized + Send + Sync { /// Externalities error type. type Error: Error; /// Call a given method in the runtime. Returns a tuple of the result (either the output data /// or an execution error) together with a `bool`, which is true if native execution was used. - fn call( + fn call>( &self, ext: &mut E, code: &[u8], @@ -256,14 +262,21 @@ pub fn always_wasm() -> ExecutionManager, E>, Result( +pub fn execute( backend: &B, overlay: &mut OverlayedChanges, exec: &Exec, method: &str, call_data: &[u8], strategy: ExecutionStrategy, -) -> Result<(Vec, B::Transaction), Box> { +) -> Result<(Vec, B::Transaction), Box> +where + H: Hasher, + C: NodeCodec, + Exec: CodeExecutor, + B: Backend, + H::Out: Ord + Encodable +{ execute_using_consensus_failure_handler( backend, overlay, @@ -289,18 +302,22 @@ pub fn execute( /// /// Note: changes to code will be in place if this call is made again. For running partial /// blocks (e.g. a transaction at a time), ensure a different method is used. -pub fn execute_using_consensus_failure_handler< - B: backend::Backend, - Exec: CodeExecutor, - Handler: FnOnce(Result, Exec::Error>, Result, Exec::Error>) -> Result, Exec::Error> ->( +pub fn execute_using_consensus_failure_handler( backend: &B, overlay: &mut OverlayedChanges, exec: &Exec, method: &str, call_data: &[u8], manager: ExecutionManager, -) -> Result<(Vec, B::Transaction), Box> { +) -> Result<(Vec, B::Transaction), Box> +where + H: Hasher, + C: NodeCodec, + Exec: CodeExecutor, + B: Backend, + H::Out: Ord + Encodable, + Handler: FnOnce(Result, Exec::Error>, Result, Exec::Error>) -> Result, Exec::Error> +{ let strategy: ExecutionStrategy = (&manager).into(); // make a copy. @@ -378,55 +395,77 @@ pub fn execute_using_consensus_failure_handler< /// /// Note: changes to code will be in place if this call is made again. For running partial /// blocks (e.g. a transaction at a time), ensure a different method is used. -pub fn prove_execution( +pub fn prove_execution( backend: B, overlay: &mut OverlayedChanges, exec: &Exec, method: &str, call_data: &[u8], -) -> Result<(Vec, Vec>, ::Transaction), Box> { +) -> Result<(Vec, Vec>, as Backend>::Transaction), Box> +where + H: Hasher, + Exec: CodeExecutor, + C: NodeCodec, + B: TryIntoTrieBackend, + H::Out: Ord + Encodable + HeapSizeOf, +{ let trie_backend = backend.try_into_trie_backend() .ok_or_else(|| Box::new(ExecutionError::UnableToGenerateProof) as Box)?; let proving_backend = proving_backend::ProvingBackend::new(trie_backend); - let (result, transaction) = execute(&proving_backend, overlay, exec, method, call_data, ExecutionStrategy::NativeWhenPossible)?; + let (result, transaction) = execute::(&proving_backend, overlay, exec, method, call_data, ExecutionStrategy::NativeWhenPossible)?; let proof = proving_backend.extract_proof(); Ok((result, proof, transaction)) } /// Check execution proof, generated by `prove_execution` call. -pub fn execution_proof_check( - root: [u8; 32], +pub fn execution_proof_check( + root: H::Out, proof: Vec>, overlay: &mut OverlayedChanges, exec: &Exec, method: &str, call_data: &[u8], -) -> Result<(Vec, memorydb::MemoryDB), Box> { - let backend = proving_backend::create_proof_check_backend(root.into(), proof)?; - execute(&backend, overlay, exec, method, call_data, ExecutionStrategy::NativeWhenPossible) +) -> Result<(Vec, memorydb::MemoryDB), Box> +where +H: Hasher, +C: NodeCodec, +Exec: CodeExecutor, +H::Out: Ord + Encodable + HeapSizeOf, +{ + let backend = proving_backend::create_proof_check_backend::(root.into(), proof)?; + execute::(&backend, overlay, exec, method, call_data, ExecutionStrategy::NativeWhenPossible) } /// Generate storage read proof. -pub fn prove_read( +pub fn prove_read( backend: B, - key: &[u8], + key: &[u8] ) -> Result<(Option>, Vec>), Box> +where + B: TryIntoTrieBackend, + H: Hasher, + C: NodeCodec, + H::Out: Ord + Encodable + HeapSizeOf { let trie_backend = backend.try_into_trie_backend() .ok_or_else(|| Box::new(ExecutionError::UnableToGenerateProof) as Box)?; - let proving_backend = proving_backend::ProvingBackend::new(trie_backend); + let proving_backend = proving_backend::ProvingBackend::::new(trie_backend); let result = proving_backend.storage(key).map_err(|e| Box::new(e) as Box)?; Ok((result, proving_backend.extract_proof())) } /// Check storage read proof, generated by `prove_read` call. -pub fn read_proof_check( - root: [u8; 32], +pub fn read_proof_check( + root: H::Out, proof: Vec>, key: &[u8], ) -> Result>, Box> +where + H: Hasher, + C: NodeCodec, + H::Out: Ord + Encodable + HeapSizeOf { - let backend = proving_backend::create_proof_check_backend(root.into(), proof)?; + let backend = proving_backend::create_proof_check_backend::(root, proof)?; backend.storage(key).map_err(|e| Box::new(e) as Box) } @@ -435,6 +474,7 @@ mod tests { use super::*; use super::backend::InMemory; use super::ext::Ext; + use primitives::{KeccakHasher, RlpCodec, H256}; struct DummyCodeExecutor { native_available: bool, @@ -442,10 +482,10 @@ mod tests { fallback_succeeds: bool, } - impl CodeExecutor for DummyCodeExecutor { + impl CodeExecutor for DummyCodeExecutor { type Error = u8; - fn call( + fn call>( &self, ext: &mut E, _code: &[u8], @@ -506,7 +546,7 @@ mod tests { b"dogglesworth".to_vec() => b"catXXX".to_vec(), b"doug".to_vec() => b"notadog".to_vec() ]; - let backend = InMemory::from(initial); + let backend = InMemory::::from(initial); let mut overlay = OverlayedChanges { committed: map![ b"dog".to_vec() => Some(b"puppy".to_vec()), @@ -519,8 +559,11 @@ mod tests { ], }; let mut ext = Ext::new(&mut overlay, &backend); + // Blake + // const ROOT: [u8; 32] = hex!("6ca394ff9b13d6690a51dea30b1b5c43108e52944d30b9095227c49bae03ff8b"); + // Keccak const ROOT: [u8; 32] = hex!("8aad789dff2f538bca5d8ea56e8abe10f4c7ba3a5dea95fea4cd6e7c3a1168d3"); - assert_eq!(ext.storage_root(), ROOT); + assert_eq!(ext.storage_root(), H256(ROOT)); } #[test] @@ -576,7 +619,7 @@ mod tests { &mut Default::default(), &executor, "test", &[]).unwrap(); // check proof locally - let (local_result, _) = execution_proof_check(remote_root, remote_proof, + let (local_result, _) = execution_proof_check::(remote_root, remote_proof, &mut Default::default(), &executor, "test", &[]).unwrap(); // check that both results are correct @@ -592,7 +635,7 @@ mod tests { b"abc".to_vec() => b"2".to_vec(), b"bbb".to_vec() => b"3".to_vec() ]; - let backend = InMemory::from(initial).try_into_trie_backend().unwrap(); + let backend = InMemory::::from(initial).try_into_trie_backend().unwrap(); let mut overlay = OverlayedChanges { committed: map![ b"aba".to_vec() => Some(b"1312".to_vec()), @@ -631,8 +674,8 @@ mod tests { let remote_root = remote_backend.storage_root(::std::iter::empty()).0; let remote_proof = prove_read(remote_backend, b"value2").unwrap().1; // check proof locally - let local_result1 = read_proof_check(remote_root, remote_proof.clone(), b"value2").unwrap(); - let local_result2 = read_proof_check(remote_root, remote_proof.clone(), &[0xff]).is_ok(); + let local_result1 = read_proof_check::(remote_root, remote_proof.clone(), b"value2").unwrap(); + let local_result2 = read_proof_check::(remote_root, remote_proof.clone(), &[0xff]).is_ok(); // check that results are correct assert_eq!(local_result1, Some(vec![24])); assert_eq!(local_result2, false); diff --git a/substrate/state-machine/src/proving_backend.rs b/substrate/state-machine/src/proving_backend.rs index 70961adc96902..db8d142452eba 100644 --- a/substrate/state-machine/src/proving_backend.rs +++ b/substrate/state-machine/src/proving_backend.rs @@ -17,23 +17,24 @@ //! Proving state machine backend. use std::cell::RefCell; -use ethereum_types::H256 as TrieH256; -use hashdb::HashDB; +use hashdb::{Hasher, HashDB}; use memorydb::MemoryDB; -use patricia_trie::{TrieDB, TrieError, Trie, Recorder}; +use patricia_trie::{TrieDB, Trie, Recorder, NodeCodec}; use trie_backend::{TrieBackend, Ephemeral}; use {Error, ExecutionError, Backend, TryIntoTrieBackend}; +use rlp::Encodable; +use heapsize::HeapSizeOf; /// Patricia trie-based backend which also tracks all touched storage trie values. /// These can be sent to remote node and used as a proof of execution. -pub struct ProvingBackend { - backend: TrieBackend, - proof_recorder: RefCell, +pub struct ProvingBackend> { + backend: TrieBackend, + proof_recorder: RefCell>, } -impl ProvingBackend { +impl> ProvingBackend { /// Create new proving backend. - pub fn new(backend: TrieBackend) -> Self { + pub fn new(backend: TrieBackend) -> Self { ProvingBackend { backend, proof_recorder: RefCell::new(Recorder::new()), @@ -50,22 +51,26 @@ impl ProvingBackend { } } -impl Backend for ProvingBackend { +impl Backend for ProvingBackend +where + H: Hasher, + C: NodeCodec, + H::Out: Ord + Encodable + HeapSizeOf +{ type Error = String; - type Transaction = MemoryDB; + type Transaction = MemoryDB; fn storage(&self, key: &[u8]) -> Result>, Self::Error> { - let mut read_overlay = MemoryDB::default(); + let mut read_overlay = MemoryDB::new(); let eph = Ephemeral::new( self.backend.backend_storage(), &mut read_overlay, ); - - let map_e = |e: Box| format!("Trie lookup error: {}", e); + let map_e = |e| format!("Trie lookup error: {}", e); let mut proof_recorder = self.proof_recorder.try_borrow_mut() .expect("only fails when already borrowed; storage() is non-reentrant; qed"); - TrieDB::new(&eph, &self.backend.root()).map_err(map_e)? + TrieDB::::new(&eph, &self.backend.root()).map_err(map_e)? .get_with(key, &mut *proof_recorder).map(|x| x.map(|val| val.to_vec())).map_err(map_e) } @@ -77,21 +82,29 @@ impl Backend for ProvingBackend { self.backend.pairs() } - fn storage_root(&self, delta: I) -> ([u8; 32], MemoryDB) + fn storage_root(&self, delta: I) -> (H::Out, MemoryDB) where I: IntoIterator, Option>)> { self.backend.storage_root(delta) } } -impl TryIntoTrieBackend for ProvingBackend { - fn try_into_trie_backend(self) -> Option { +impl> TryIntoTrieBackend for ProvingBackend { + fn try_into_trie_backend(self) -> Option> { None } } /// Create proof check backend. -pub fn create_proof_check_backend(root: TrieH256, proof: Vec>) -> Result> { +pub fn create_proof_check_backend( + root: H::Out, + proof: Vec> +) -> Result, Box> +where + H: Hasher, + C: NodeCodec, + H::Out: HeapSizeOf, +{ let mut db = MemoryDB::new(); for item in proof { db.insert(&item); @@ -110,8 +123,9 @@ mod tests { use backend::{InMemory}; use trie_backend::tests::test_trie; use super::*; + use primitives::{KeccakHasher, RlpCodec}; - fn test_proving() -> ProvingBackend { + fn test_proving() -> ProvingBackend { ProvingBackend::new(test_trie()) } @@ -129,7 +143,7 @@ mod tests { #[test] fn proof_is_invalid_when_does_not_contains_root() { - assert!(create_proof_check_backend(1.into(), vec![]).is_err()); + assert!(create_proof_check_backend::(1.into(), vec![]).is_err()); } #[test] @@ -148,7 +162,7 @@ mod tests { #[test] fn proof_recorded_and_checked() { let contents = (0..64).map(|i| (vec![i], Some(vec![i]))).collect::>(); - let in_memory = InMemory::default(); + let in_memory = InMemory::::default(); let in_memory = in_memory.update(contents); let in_memory_root = in_memory.storage_root(::std::iter::empty()).0; (0..64).for_each(|i| assert_eq!(in_memory.storage(&[i]).unwrap().unwrap(), vec![i])); @@ -163,7 +177,7 @@ mod tests { let proof = proving.extract_proof(); - let proof_check = create_proof_check_backend(in_memory_root.into(), proof).unwrap(); + let proof_check = create_proof_check_backend::(in_memory_root.into(), proof).unwrap(); assert_eq!(proof_check.storage(&[42]).unwrap().unwrap(), vec![42]); } } diff --git a/substrate/state-machine/src/testing.rs b/substrate/state-machine/src/testing.rs index 7b85b523cd47a..955cb77464b4e 100644 --- a/substrate/state-machine/src/testing.rs +++ b/substrate/state-machine/src/testing.rs @@ -17,48 +17,105 @@ //! Test implementation for Externalities. use std::collections::HashMap; +use std::cmp::Ord; use super::Externalities; use triehash::trie_root; +use hashdb::Hasher; +use rlp::Encodable; +use std::marker::PhantomData; +use std::iter::FromIterator; + +/// Simple HashMap-based Externalities impl. +#[derive(Debug)] +pub struct TestExternalities { + inner: HashMap, Vec>, + _hasher: PhantomData, +} + +impl TestExternalities { + /// Create a new instance of `TestExternalities` + pub fn new() -> Self { + TestExternalities {inner: HashMap::new(), _hasher: PhantomData} + } + /// Insert key/value + pub fn insert(&mut self, k: Vec, v: Vec) -> Option> { + self.inner.insert(k, v) + } +} + +impl PartialEq for TestExternalities { + fn eq(&self, other: &TestExternalities) -> bool { + self.inner.eq(&other.inner) + } +} + +impl FromIterator<(Vec, Vec)> for TestExternalities { + fn from_iter, Vec)>>(iter: I) -> Self { + let mut t = Self::new(); + for i in iter { + t.inner.insert(i.0, i.1); + } + t + } +} + +impl Default for TestExternalities { + fn default() -> Self { Self::new() } +} + +impl From> for HashMap, Vec> { + fn from(tex: TestExternalities) -> Self { + tex.inner.into() + } +} + +impl From< HashMap, Vec> > for TestExternalities { + fn from(hashmap: HashMap, Vec>) -> Self { + TestExternalities { inner: hashmap, _hasher: PhantomData } + } +} -/// Simple HashMap based Externalities impl. -pub type TestExternalities = HashMap, Vec>; -impl Externalities for TestExternalities { +impl Externalities for TestExternalities where H::Out: Ord + Encodable { fn storage(&self, key: &[u8]) -> Option> { - self.get(key).map(|x| x.to_vec()) + self.inner.get(key).map(|x| x.to_vec()) } fn place_storage(&mut self, key: Vec, maybe_value: Option>) { match maybe_value { - Some(value) => { self.insert(key, value); } - None => { self.remove(&key); } + Some(value) => { self.inner.insert(key, value); } + None => { self.inner.remove(&key); } } } fn clear_prefix(&mut self, prefix: &[u8]) { - self.retain(|key, _| + self.inner.retain(|key, _| !key.starts_with(prefix) ) } fn chain_id(&self) -> u64 { 42 } - fn storage_root(&mut self) -> [u8; 32] { - trie_root(self.clone()).0 + fn storage_root(&mut self) -> H::Out { + trie_root::(self.inner.clone()) } } #[cfg(test)] mod tests { use super::*; + use primitives::{KeccakHasher, H256}; #[test] fn commit_should_work() { - let mut ext = TestExternalities::new(); + let mut ext = TestExternalities::::new(); ext.set_storage(b"doe".to_vec(), b"reindeer".to_vec()); ext.set_storage(b"dog".to_vec(), b"puppy".to_vec()); ext.set_storage(b"dogglesworth".to_vec(), b"cat".to_vec()); + // Blake + // const ROOT: [u8; 32] = hex!("6ca394ff9b13d6690a51dea30b1b5c43108e52944d30b9095227c49bae03ff8b"); + // Keccak const ROOT: [u8; 32] = hex!("8aad789dff2f538bca5d8ea56e8abe10f4c7ba3a5dea95fea4cd6e7c3a1168d3"); - assert_eq!(ext.storage_root(), ROOT); + assert_eq!(ext.storage_root(), H256(ROOT)); } } diff --git a/substrate/state-machine/src/trie_backend.rs b/substrate/state-machine/src/trie_backend.rs index 629dd3ddb3a9c..b9d45d45a7097 100644 --- a/substrate/state-machine/src/trie_backend.rs +++ b/substrate/state-machine/src/trie_backend.rs @@ -15,101 +15,104 @@ // along with Substrate. If not, see . //! Trie-based state machine backend. - +use Backend; +use hashdb::{Hasher, HashDB, AsHashDB}; +use memorydb::MemoryDB; +use patricia_trie::{TrieDB, TrieDBMut, TrieError, Trie, TrieMut, NodeCodec}; use std::collections::HashMap; use std::sync::Arc; -use hashdb::HashDB; -use memorydb::MemoryDB; -use patricia_trie::{TrieDB, TrieDBMut, TrieError, Trie, TrieMut}; -use {Backend}; -pub use ethereum_types::H256 as TrieH256; +use std::marker::PhantomData; +use heapsize::HeapSizeOf; + pub use hashdb::DBValue; /// Backend trie storage trait. -pub trait Storage: Send + Sync { +pub trait Storage: Send + Sync { /// Get a trie node. - fn get(&self, key: &TrieH256) -> Result, String>; + fn get(&self, key: &H::Out) -> Result, String>; } /// Try convert into trie-based backend. -pub trait TryIntoTrieBackend { +pub trait TryIntoTrieBackend> { /// Try to convert self into trie backend. - fn try_into_trie_backend(self) -> Option; + fn try_into_trie_backend(self) -> Option>; } /// Patricia trie-based backend. Transaction type is an overlay of changes to commit. #[derive(Clone)] -pub struct TrieBackend { - storage: TrieBackendStorage, - root: TrieH256, +pub struct TrieBackend> { + storage: TrieBackendStorage, + root: H::Out, + _codec: PhantomData } -impl TrieBackend { +impl> TrieBackend where H::Out: HeapSizeOf { /// Create new trie-based backend. - pub fn with_storage(db: Arc, root: TrieH256) -> Self { + pub fn with_storage(db: Arc>, root: H::Out) -> Self { TrieBackend { storage: TrieBackendStorage::Storage(db), root, + _codec: PhantomData, } } /// Create new trie-based backend for genesis block. - pub fn with_storage_for_genesis(db: Arc) -> Self { - let mut root = TrieH256::default(); - let mut mdb = MemoryDB::default(); - TrieDBMut::new(&mut mdb, &mut root); + pub fn with_storage_for_genesis(db: Arc>) -> Self { + let mut root = ::Out::default(); + let mut mdb = MemoryDB::::new(); + TrieDBMut::::new(&mut mdb, &mut root); Self::with_storage(db, root) } /// Create new trie-based backend backed by MemoryDb storage. - pub fn with_memorydb(db: MemoryDB, root: TrieH256) -> Self { + pub fn with_memorydb(db: MemoryDB, root: H::Out) -> Self { // TODO: check that root is a part of db??? TrieBackend { storage: TrieBackendStorage::MemoryDb(db), root, + _codec: PhantomData, } } /// Get backend storage reference. - pub fn backend_storage(&self) -> &TrieBackendStorage { + pub fn backend_storage(&self) -> &TrieBackendStorage { &self.storage } /// Get trie root. - pub fn root(&self) -> &TrieH256 { + pub fn root(&self) -> &H::Out { &self.root } } impl super::Error for String {} -impl Backend for TrieBackend { +impl> Backend for TrieBackend where H::Out: HeapSizeOf { type Error = String; - type Transaction = MemoryDB; + type Transaction = MemoryDB; fn storage(&self, key: &[u8]) -> Result>, Self::Error> { - let mut read_overlay = MemoryDB::default(); + let mut read_overlay = MemoryDB::new(); let eph = Ephemeral { storage: &self.storage, overlay: &mut read_overlay, }; - let map_e = |e: Box| format!("Trie lookup error: {}", e); - - TrieDB::new(&eph, &self.root).map_err(map_e)? + let map_e = |e| format!("Trie lookup error: {}", e); + TrieDB::::new(&eph, &self.root).map_err(map_e)? .get(key).map(|x| x.map(|val| val.to_vec())).map_err(map_e) } fn for_keys_with_prefix(&self, prefix: &[u8], mut f: F) { - let mut read_overlay = MemoryDB::default(); + let mut read_overlay = MemoryDB::new(); let eph = Ephemeral { storage: &self.storage, overlay: &mut read_overlay, }; - let mut iter = move || -> Result<(), Box> { - let trie = TrieDB::new(&eph, &self.root)?; + let mut iter = move || -> Result<(), Box>> { + let trie = TrieDB::::new(&eph, &self.root)?; let mut iter = trie.iter()?; iter.seek(prefix)?; @@ -133,14 +136,14 @@ impl Backend for TrieBackend { } fn pairs(&self) -> Vec<(Vec, Vec)> { - let mut read_overlay = MemoryDB::default(); + let mut read_overlay = MemoryDB::new(); let eph = Ephemeral { storage: &self.storage, overlay: &mut read_overlay, }; - let collect_all = || -> Result<_, Box> { - let trie = TrieDB::new(&eph, &self.root)?; + let collect_all = || -> Result<_, Box>> { + let trie = TrieDB::::new(&eph, &self.root)?; let mut v = Vec::new(); for x in trie.iter()? { let (key, value) = x?; @@ -159,10 +162,10 @@ impl Backend for TrieBackend { } } - fn storage_root(&self, delta: I) -> ([u8; 32], MemoryDB) + fn storage_root(&self, delta: I) -> (H::Out, MemoryDB) where I: IntoIterator, Option>)> { - let mut write_overlay = MemoryDB::default(); + let mut write_overlay = MemoryDB::new(); let mut root = self.root; { let mut eph = Ephemeral { @@ -170,7 +173,7 @@ impl Backend for TrieBackend { overlay: &mut write_overlay, }; - let mut trie = TrieDBMut::from_existing(&mut eph, &mut root).expect("prior state root to exist"); // TODO: handle gracefully + let mut trie = TrieDBMut::::from_existing(&mut eph, &mut root).expect("prior state root to exist"); // TODO: handle gracefully for (key, change) in delta { let result = match change { Some(val) => trie.insert(&key, &val), @@ -183,23 +186,28 @@ impl Backend for TrieBackend { } } - (root.0.into(), write_overlay) + (root, write_overlay) } } -impl TryIntoTrieBackend for TrieBackend { - fn try_into_trie_backend(self) -> Option { +impl> TryIntoTrieBackend for TrieBackend { + fn try_into_trie_backend(self) -> Option> { Some(self) } } -pub struct Ephemeral<'a> { - storage: &'a TrieBackendStorage, - overlay: &'a mut MemoryDB, +pub struct Ephemeral<'a, H: 'a + Hasher> { + storage: &'a TrieBackendStorage, + overlay: &'a mut MemoryDB, +} + +impl<'a, H: Hasher> AsHashDB for Ephemeral<'a, H> where H::Out: HeapSizeOf { + fn as_hashdb(&self) -> &HashDB { self } + fn as_hashdb_mut(&mut self) -> &mut HashDB { self } } -impl<'a> Ephemeral<'a> { - pub fn new(storage: &'a TrieBackendStorage, overlay: &'a mut MemoryDB) -> Self { +impl<'a, H: Hasher> Ephemeral<'a, H> { + pub fn new(storage: &'a TrieBackendStorage, overlay: &'a mut MemoryDB) -> Self { Ephemeral { storage, overlay, @@ -207,12 +215,12 @@ impl<'a> Ephemeral<'a> { } } -impl<'a> HashDB for Ephemeral<'a> { - fn keys(&self) -> HashMap { +impl<'a, H: Hasher> HashDB for Ephemeral<'a, H> where H::Out: HeapSizeOf { + fn keys(&self) -> HashMap { self.overlay.keys() // TODO: iterate backing } - fn get(&self, key: &TrieH256) -> Option { + fn get(&self, key: &H::Out) -> Option { match self.overlay.raw(key) { Some((val, i)) => { if i <= 0 { @@ -221,7 +229,7 @@ impl<'a> HashDB for Ephemeral<'a> { Some(val) } } - None => match self.storage.get(&key) { + None => match self.storage.get(key) { Ok(x) => x, Err(e) => { warn!(target: "trie", "Failed to read from DB: {}", e); @@ -231,33 +239,33 @@ impl<'a> HashDB for Ephemeral<'a> { } } - fn contains(&self, key: &TrieH256) -> bool { + fn contains(&self, key: &H::Out) -> bool { self.get(key).is_some() } - fn insert(&mut self, value: &[u8]) -> TrieH256 { + fn insert(&mut self, value: &[u8]) -> H::Out { self.overlay.insert(value) } - fn emplace(&mut self, key: TrieH256, value: DBValue) { + fn emplace(&mut self, key: H::Out, value: DBValue) { self.overlay.emplace(key, value) } - fn remove(&mut self, key: &TrieH256) { + fn remove(&mut self, key: &H::Out) { self.overlay.remove(key) } } #[derive(Clone)] -pub enum TrieBackendStorage { +pub enum TrieBackendStorage { /// Key value db + storage column. - Storage(Arc), + Storage(Arc>), /// Hash db. - MemoryDb(MemoryDB), + MemoryDb(MemoryDB), } -impl TrieBackendStorage { - pub fn get(&self, key: &TrieH256) -> Result, String> { +impl TrieBackendStorage { + pub fn get(&self, key: &H::Out) -> Result, String> { match *self { TrieBackendStorage::Storage(ref db) => db.get(key) @@ -272,24 +280,25 @@ impl TrieBackendStorage { pub mod tests { use super::*; use std::collections::HashSet; + use primitives::{KeccakHasher, RlpCodec, H256}; - fn test_db() -> (MemoryDB, TrieH256) { - let mut root = TrieH256::default(); - let mut mdb = MemoryDB::default(); + fn test_db() -> (MemoryDB, H256) { + let mut root = H256::default(); + let mut mdb = MemoryDB::::new(); { - let mut trie = TrieDBMut::new(&mut mdb, &mut root); - trie.insert(b"key", b"value").unwrap(); - trie.insert(b"value1", &[42]).unwrap(); - trie.insert(b"value2", &[24]).unwrap(); - trie.insert(b":code", b"return 42").unwrap(); - for i in 128u8..255u8 { - trie.insert(&[i], &[i]).unwrap(); - } + let mut trie = TrieDBMut::<_, RlpCodec>::new(&mut mdb, &mut root); + trie.insert(b"key", b"value").expect("insert failed"); + trie.insert(b"value1", &[42]).expect("insert failed"); + trie.insert(b"value2", &[24]).expect("insert failed"); + trie.insert(b":code", b"return 42").expect("insert failed"); + for i in 128u8..255u8 { + trie.insert(&[i], &[i]).unwrap(); + } } (mdb, root) } - pub fn test_trie() -> TrieBackend { + pub(crate) fn test_trie() -> TrieBackend { let (mdb, root) = test_db(); TrieBackend::with_memorydb(mdb, root) } @@ -311,12 +320,16 @@ pub mod tests { #[test] fn pairs_are_empty_on_empty_storage() { - assert!(TrieBackend::with_memorydb(MemoryDB::new(), Default::default()).pairs().is_empty()); + let db = TrieBackend::::with_memorydb( + MemoryDB::new(), + Default::default() + ); + assert!(db.pairs().is_empty()); } #[test] fn storage_root_is_non_default() { - assert!(test_trie().storage_root(::std::iter::empty()).0 != [0; 32]); + assert!(test_trie().storage_root(::std::iter::empty()).0 != H256([0; 32])); } #[test] diff --git a/substrate/test-client/Cargo.toml b/substrate/test-client/Cargo.toml index 69920cb48500c..461a29cac80a2 100644 --- a/substrate/test-client/Cargo.toml +++ b/substrate/test-client/Cargo.toml @@ -14,3 +14,5 @@ substrate-primitives = { path = "../primitives" } substrate-runtime-support = { path = "../runtime-support" } substrate-test-runtime = { path = "../test-runtime" } substrate-runtime-primitives = { path = "../runtime/primitives" } +hashdb = { git = "https://github.com/paritytech/parity-common" } + diff --git a/substrate/test-client/src/block_builder_ext.rs b/substrate/test-client/src/block_builder_ext.rs index 17fdbeba0a537..a1894f5fa68f3 100644 --- a/substrate/test-client/src/block_builder_ext.rs +++ b/substrate/test-client/src/block_builder_ext.rs @@ -22,6 +22,7 @@ use keyring; use runtime; use {Backend, Executor}; +use primitives::{KeccakHasher, RlpCodec}; /// Extension trait for test block builder. pub trait BlockBuilderExt { @@ -29,7 +30,7 @@ pub trait BlockBuilderExt { fn push_transfer(&mut self, transfer: runtime::Transfer) -> Result<(), client::error::Error>; } -impl BlockBuilderExt for client::block_builder::BlockBuilder { +impl BlockBuilderExt for client::block_builder::BlockBuilder { fn push_transfer(&mut self, transfer: runtime::Transfer) -> Result<(), client::error::Error> { self.push(sign_tx(transfer)) } diff --git a/substrate/test-client/src/lib.rs b/substrate/test-client/src/lib.rs index a0709210ec843..6a7e52a20103c 100644 --- a/substrate/test-client/src/lib.rs +++ b/substrate/test-client/src/lib.rs @@ -25,6 +25,7 @@ extern crate substrate_primitives as primitives; extern crate substrate_runtime_support as runtime_support; extern crate substrate_runtime_primitives as runtime_primitives; #[macro_use] extern crate substrate_executor as executor; +extern crate hashdb; pub extern crate substrate_client as client; pub extern crate substrate_keyring as keyring; @@ -36,10 +37,12 @@ mod block_builder_ext; pub use client_ext::TestClient; pub use block_builder_ext::BlockBuilderExt; +use primitives::{KeccakHasher, RlpCodec}; + mod local_executor { #![allow(missing_docs)] use super::runtime; - + // TODO: change the macro and pass in the `BlakeHasher` that dispatch needs from here instead native_executor_instance!(pub LocalExecutor, runtime::api::dispatch, runtime::VERSION, include_bytes!("../../test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm")); } @@ -47,7 +50,7 @@ mod local_executor { pub use local_executor::LocalExecutor; /// Test client database backend. -pub type Backend = client::in_mem::Backend; +pub type Backend = client::in_mem::Backend; /// Test client executor. pub type Executor = client::LocalCallExecutor>; diff --git a/substrate/test-runtime/src/system.rs b/substrate/test-runtime/src/system.rs index cb5ae23eb6c32..fcb2b951b6449 100644 --- a/substrate/test-runtime/src/system.rs +++ b/substrate/test-runtime/src/system.rs @@ -171,8 +171,9 @@ mod tests { use codec::{Joiner, KeyedVec}; use keyring::Keyring; use ::{Header, Digest, Extrinsic, Transfer}; + use primitives::KeccakHasher; - fn new_test_ext() -> TestExternalities { + fn new_test_ext() -> TestExternalities { map![ twox_128(b"latest").to_vec() => vec![69u8; 32], twox_128(b":auth:len").to_vec() => vec![].and(&3u32), @@ -195,6 +196,9 @@ mod tests { let h = Header { parent_hash: [69u8; 32].into(), number: 1, + // Blake + // state_root: hex!("0c22599e15fb5e052c84f79a2aab179ba6bb238218fd86bdd4a74ebcc87adfcd").into(), + // Keccak state_root: hex!("97dfcd1f8cbf8845fcb544f89332f1a94c1137f7d1b199ef0b0a6ed217015c3e").into(), extrinsics_root: hex!("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421").into(), digest: Digest { logs: vec![], }, @@ -223,6 +227,9 @@ mod tests { header: Header { parent_hash: [69u8; 32].into(), number: 1, + // Blake + // state_root: hex!("0425393fd07e2a806cfd7e990ee91dc92fe6bba34eab2bf45d5be7d67e24d467").into(), + // Keccak state_root: hex!("0dd8210adaf581464cc68555814a787ed491f8c608d0a0dbbf2208a6d44190b1").into(), extrinsics_root: hex!("951508f2cc0071500a74765ab0fb2f280fdcdd329d5f989dda675010adee99d6").into(), digest: Digest { logs: vec![], }, @@ -248,6 +255,9 @@ mod tests { header: Header { parent_hash: b.header.hash(), number: 2, + // Blake + // state_root: hex!("e32dd1d84d9133ca48078d2d83f2b0db19f9d47229ba98bf5ced0e9f86fac2c7").into(), + // Keccak state_root: hex!("c93f2fd494c386fa32ee76b6198a7ccf5db12c02c3a79755fd2d4646ec2bf8d7").into(), extrinsics_root: hex!("3563642676d7e042c894eedc579ba2d6eeedf9a6c66d9d557599effc9f674372").into(), digest: Digest { logs: vec![], },