diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index 08ee2e5604..7a7ba66182 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -1661,11 +1661,6 @@ dependencies = [ "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "nan-preserving-float" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "native-tls" version = "0.2.2" @@ -2609,7 +2604,7 @@ dependencies = [ "sr-std 0.1.0", "substrate-primitives 0.1.0", "wabt 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmi 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3177,7 +3172,7 @@ dependencies = [ "substrate-state-machine 0.1.0", "substrate-trie 0.4.0", "wabt 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmi 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3313,7 +3308,7 @@ dependencies = [ "twox-hash 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "uint 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmi 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4156,12 +4151,11 @@ dependencies = [ [[package]] name = "wasmi" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "nan-preserving-float 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4473,7 +4467,6 @@ dependencies = [ "checksum multihash 0.8.1-pre (git+https://github.com/libp2p/rust-libp2p?rev=d961e656a74d1bab5366d371a06f9e10d5f4a6c5)" = "" "checksum multistream-select 0.1.0 (git+https://github.com/libp2p/rust-libp2p?rev=d961e656a74d1bab5366d371a06f9e10d5f4a6c5)" = "" "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.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ff8e08de0070bbf4c31f452ea2a70db092f36f6f2e4d897adf5674477d488fb2" "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" "checksum nix 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d37e713a259ff641624b6cb20e3b12b2952313ba36b6823c0f16e6cfd9e5de17" @@ -4650,7 +4643,7 @@ dependencies = [ "checksum wabt 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "182ae543249ccf2705f324d233891c1176fca142e137b55ba43d9dbfe93f18a2" "checksum wabt-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ca77c6b934a2b32618941b2f565aac43b8cb7141378c3b4fba4d8fcdcd57da3" "checksum want 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "797464475f30ddb8830cc529aaaae648d581f99e2036a928877dfde027ddf6b3" -"checksum wasmi 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d184c4b7081f30316f74f8d73c197314dcb56ea7af9323522b42a2fa9cb19453" +"checksum wasmi 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8a60b9508cff2b7c27ed41200dd668806280740fadc8c88440e9c88625e84f1a" "checksum websocket 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c9faed2bff8af2ea6b9f8b917d3d00b467583f6781fe3def174a9e33c879703" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" diff --git a/substrate/core/executor/Cargo.toml b/substrate/core/executor/Cargo.toml index a3de26a3cb..c6cddf341c 100644 --- a/substrate/core/executor/Cargo.toml +++ b/substrate/core/executor/Cargo.toml @@ -14,7 +14,7 @@ substrate-state-machine = { path = "../state-machine" } sr-version = { path = "../sr-version" } serde = "1.0" serde_derive = "1.0" -wasmi = { version = "0.4.1" } +wasmi = { version = "0.4.2" } byteorder = "1.1" lazy_static = "1.0" parking_lot = "*" diff --git a/substrate/core/primitives/Cargo.toml b/substrate/core/primitives/Cargo.toml index 171841f1e2..5821a5fe94 100644 --- a/substrate/core/primitives/Cargo.toml +++ b/substrate/core/primitives/Cargo.toml @@ -15,7 +15,7 @@ serde_derive = { version = "1.0", optional = true } uint = { version = "0.5.0-beta", default-features = false } twox-hash = { version = "1.1.0", optional = true } byteorder = { version = "1.1", default-features = false } -wasmi = { version = "0.4.1", optional = true } +wasmi = { version = "0.4.2", optional = true } hash-db = { git = "https://github.com/paritytech/trie", default-features = false } hash256-std-hasher = { git = "https://github.com/paritytech/trie", default-features = false } ring = { version = "0.12", optional = true } diff --git a/substrate/core/sr-sandbox/Cargo.toml b/substrate/core/sr-sandbox/Cargo.toml index 8cb35aed79..daa9408296 100755 --- a/substrate/core/sr-sandbox/Cargo.toml +++ b/substrate/core/sr-sandbox/Cargo.toml @@ -8,7 +8,7 @@ build = "build.rs" rustc_version = "0.2" [dependencies] -wasmi = { version = "0.4.1", optional = true } +wasmi = { version = "0.4.2", optional = true } substrate-primitives = { path = "../primitives", default-features = false } sr-std = { path = "../sr-std", default-features = false } parity-codec = { version = "2.1", default-features = false } diff --git a/substrate/core/test-runtime/wasm/Cargo.lock b/substrate/core/test-runtime/wasm/Cargo.lock index f9c0964148..c268f0c400 100644 --- a/substrate/core/test-runtime/wasm/Cargo.lock +++ b/substrate/core/test-runtime/wasm/Cargo.lock @@ -472,11 +472,6 @@ dependencies = [ "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "nan-preserving-float" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "net2" version = "0.2.33" @@ -985,7 +980,7 @@ dependencies = [ "substrate-serializer 0.1.0", "substrate-state-machine 0.1.0", "substrate-trie 0.4.0", - "wasmi 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1019,7 +1014,7 @@ dependencies = [ "twox-hash 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "uint 0.5.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmi 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1379,12 +1374,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wasmi" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "nan-preserving-float 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1507,7 +1501,6 @@ dependencies = [ "checksum mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "46e73a04c2fa6250b8d802134d56d554a9ec2922bf977777c805ea5def61ce40" "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" -"checksum nan-preserving-float 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34d4f00fcc2f4c9efa8cc971db0da9e28290e28e97af47585e48691ef10ff31f" "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" "checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" "checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea" @@ -1586,7 +1579,7 @@ dependencies = [ "checksum vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "def296d3eb3b12371b2c7d0e83bfe1403e4db2d7a0bba324a12b21c4ee13143d" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -"checksum wasmi 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d184c4b7081f30316f74f8d73c197314dcb56ea7af9323522b42a2fa9cb19453" +"checksum wasmi 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8a60b9508cff2b7c27ed41200dd668806280740fadc8c88440e9c88625e84f1a" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" diff --git a/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm b/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm index 6f1c85ae97..81ccaf36b1 100644 Binary files a/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm and b/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm differ diff --git a/substrate/node/executor/Cargo.toml b/substrate/node/executor/Cargo.toml index 6cbbb2f11e..4c8f5c1030 100644 --- a/substrate/node/executor/Cargo.toml +++ b/substrate/node/executor/Cargo.toml @@ -29,3 +29,6 @@ srml-timestamp = { path = "../../srml/timestamp" } srml-treasury = { path = "../../srml/treasury" } srml-contract = { path = "../../srml/contract" } wabt = "0.4" + +[features] +benchmarks = [] diff --git a/substrate/node/executor/src/lib.rs b/substrate/node/executor/src/lib.rs index aba525ca0e..d6fc59d7d7 100644 --- a/substrate/node/executor/src/lib.rs +++ b/substrate/node/executor/src/lib.rs @@ -17,10 +17,14 @@ //! A `CodeExecutor` specialisation which uses natively compiled runtime when the wasm to be //! executed is equivalent to the natively compiled code. +#![cfg_attr(feature = "benchmarks", feature(test))] + extern crate node_runtime; #[macro_use] extern crate substrate_executor; #[cfg_attr(test, macro_use)] extern crate substrate_primitives as primitives; +#[cfg(feature = "benchmarks")] extern crate test; + #[cfg(test)] extern crate substrate_keyring as keyring; #[cfg(test)] extern crate sr_primitives as runtime_primitives; #[cfg(test)] extern crate srml_support as runtime_support; @@ -747,4 +751,19 @@ mod tests { assert!(t.storage_changes_root(Default::default(), 0).is_some()); } + + #[cfg(feature = "benchmarks")] + mod benches { + use super::*; + use test::Bencher; + + #[bench] + fn wasm_execute_block(b: &mut Bencher) { + b.iter(|| { + let mut t = new_test_ext(false); + WasmExecutor::new().call(&mut t, 8, COMPACT_CODE, "execute_block", &block1(false).0).unwrap(); + WasmExecutor::new().call(&mut t, 8, COMPACT_CODE, "execute_block", &block2().0).unwrap(); + }); + } + } } diff --git a/substrate/node/runtime/wasm/Cargo.lock b/substrate/node/runtime/wasm/Cargo.lock index d340628488..3a032be99a 100644 --- a/substrate/node/runtime/wasm/Cargo.lock +++ b/substrate/node/runtime/wasm/Cargo.lock @@ -472,11 +472,6 @@ dependencies = [ "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "nan-preserving-float" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "net2" version = "0.2.33" @@ -939,7 +934,7 @@ dependencies = [ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", "substrate-primitives 0.1.0", - "wasmi 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1270,7 +1265,7 @@ dependencies = [ "substrate-serializer 0.1.0", "substrate-state-machine 0.1.0", "substrate-trie 0.4.0", - "wasmi 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1316,7 +1311,7 @@ dependencies = [ "twox-hash 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "uint 0.5.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmi 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1659,12 +1654,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wasmi" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "nan-preserving-float 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1787,7 +1781,6 @@ dependencies = [ "checksum mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "46e73a04c2fa6250b8d802134d56d554a9ec2922bf977777c805ea5def61ce40" "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" -"checksum nan-preserving-float 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34d4f00fcc2f4c9efa8cc971db0da9e28290e28e97af47585e48691ef10ff31f" "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" "checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" "checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea" @@ -1868,7 +1861,7 @@ dependencies = [ "checksum vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "def296d3eb3b12371b2c7d0e83bfe1403e4db2d7a0bba324a12b21c4ee13143d" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -"checksum wasmi 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d184c4b7081f30316f74f8d73c197314dcb56ea7af9323522b42a2fa9cb19453" +"checksum wasmi 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8a60b9508cff2b7c27ed41200dd668806280740fadc8c88440e9c88625e84f1a" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" diff --git a/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm b/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm index ef9eb5aba3..c61d791a9b 100644 Binary files a/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm and b/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm differ