When deterministic feature will be enabled (turned-off by default) it'll guarantee deterministic

execution of wasm programs across different hardware/circumstances.
This is very useful for Blockchain projects having wasm smart-contracts

This is critical for Blockchain projects that require execution to be deterministic
in order to reach a consensus of the state transition of each smart-contract transaction.
This commit is contained in:
Yaron Wittenstein 2019-10-07 16:58:58 +03:00
parent c8e9530805
commit 6ca5812798
7 changed files with 22 additions and 6 deletions

View File

@ -26,7 +26,7 @@ wabt = "0.9.1"
wasmer-clif-backend = { path = "lib/clif-backend" }
wasmer-singlepass-backend = { path = "lib/singlepass-backend", optional = true }
wasmer-middleware-common = { path = "lib/middleware-common" }
wasmer-runtime = { path = "lib/runtime" }
wasmer-runtime = { path = "lib/runtime", default-features = false }
wasmer-runtime-core = { path = "lib/runtime-core" }
wasmer-emscripten = { path = "lib/emscripten" }
wasmer-llvm-backend = { path = "lib/llvm-backend", optional = true }
@ -101,6 +101,8 @@ backend-singlepass = [
wasi = ["wasmer-wasi"]
managed = ["backend-singlepass", "wasmer-runtime-core/managed"]
deterministic = ["wasmer-runtime/deterministic"]
[[example]]
name = "plugin"
crate-type = ["bin"]

View File

@ -58,3 +58,4 @@ trace = ["debug"]
"backend-singlepass" = []
"backend-llvm" = []
managed = []
deterministic = ["wasmparser/deterministic"]

View File

@ -145,6 +145,9 @@ pub fn validating_parser_config(features: &Features) -> wasmparser::ValidatingPa
enable_simd: features.simd,
enable_bulk_memory: false,
enable_multi_value: false,
#[cfg(feature = "deterministic")]
deterministic_only: true,
},
}
}

View File

@ -145,6 +145,9 @@ pub fn validate_and_report_errors_with_features(
enable_multi_value: false,
enable_reference_types: false,
enable_threads: features.threads,
#[cfg(feature = "deterministic")]
deterministic_only: true,
},
};
let mut parser = wasmparser::ValidatingParser::new(wasm, Some(config));

View File

@ -41,6 +41,7 @@ singlepass = ["wasmer-singlepass-backend"]
default-backend-singlepass = ["singlepass"]
default-backend-llvm = ["llvm"]
default-backend-cranelift = ["cranelift"]
deterministic = ["wasmer-singlepass-backend/deterministic"]
[[bench]]
name = "nginx"

View File

@ -199,13 +199,15 @@ pub fn default_compiler() -> impl Compiler {
feature = "default-backend-llvm",
any(
feature = "default-backend-cranelift",
feature = "default-backend-singlepass"
feature = "default-backend-singlepass",
feature = "deterministic"
)
),
all(
feature = "default-backend-cranelift",
feature = "default-backend-singlepass"
)
any(feature = "default-backend-singlepass", feature = "deterministic")
),
all(feature = "default-backend-singlepass", feature = "deterministic")
))]
compile_error!(
"The `default-backend-X` features are mutually exclusive. Please choose just one"
@ -214,7 +216,7 @@ pub fn default_compiler() -> impl Compiler {
#[cfg(feature = "default-backend-llvm")]
use wasmer_llvm_backend::LLVMCompiler as DefaultCompiler;
#[cfg(feature = "default-backend-singlepass")]
#[cfg(any(feature = "default-backend-singlepass", feature = "deterministic"))]
use wasmer_singlepass_backend::SinglePassCompiler as DefaultCompiler;
#[cfg(feature = "default-backend-cranelift")]

View File

@ -18,3 +18,7 @@ byteorder = "1.3"
nix = "0.15"
libc = "0.2.60"
smallvec = "0.6"
[features]
default = []
deterministic = ["wasmparser/deterministic", "wasmer-runtime-core/deterministic"]