Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
contracts: Upgrade to wasmi 0.28 (#13312)
Browse files Browse the repository at this point in the history
* Upgrade to wasmi 0.28

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts

* Update stale comment

* Renamed variants of `Determinism`

* Compile fix

---------

Co-authored-by: command-bot <>
  • Loading branch information
athei authored Mar 20, 2023
1 parent b8b8cce commit 8f0b0f6
Show file tree
Hide file tree
Showing 15 changed files with 1,338 additions and 1,393 deletions.
21 changes: 11 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2147,7 +2147,7 @@ impl_runtime_apis! {
storage_deposit_limit,
input_data,
true,
pallet_contracts::Determinism::Deterministic,
pallet_contracts::Determinism::Enforced,
)
}

Expand Down
4 changes: 2 additions & 2 deletions frame/contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ serde = { version = "1", optional = true, features = ["derive"] }
smallvec = { version = "1", default-features = false, features = [
"const_generics",
] }
wasmi = { version = "0.20", default-features = false }
wasmparser = { package = "wasmparser-nostd", version = "0.91", default-features = false }
wasmi = { version = "0.28", default-features = false }
wasmparser = { package = "wasmparser-nostd", version = "0.100", default-features = false }
impl-trait-for-tuples = "0.2"

# Only used in benchmarking to generate random contract code
Expand Down
4 changes: 2 additions & 2 deletions frame/contracts/proc-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ fn expand_functions(def: &EnvDef, expand_blocks: bool, host_state: TokenStream2)
let inner = if expand_blocks {
quote! { || #output {
let (memory, ctx) = __caller__
.host_data()
.data()
.memory()
.expect("Memory must be set when setting up host data; qed")
.data_and_store_mut(&mut __caller__);
Expand All @@ -630,7 +630,7 @@ fn expand_functions(def: &EnvDef, expand_blocks: bool, host_state: TokenStream2)
let map_err = if expand_blocks {
quote! {
|reason| {
::wasmi::core::Trap::host(reason)
::wasmi::core::Trap::from(reason)
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion frame/contracts/src/benchmarking/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ pub fn max_pages<T: Config>() -> u32 {

fn inject_gas_metering<T: Config>(module: Module) -> Module {
let schedule = T::Schedule::get();
let gas_rules = schedule.rules(Determinism::Deterministic);
let gas_rules = schedule.rules(Determinism::Enforced);
let backend = gas_metering::host_function::Injector::new("seal0", "gas");
gas_metering::inject(module, backend, &gas_rules).unwrap()
}
12 changes: 6 additions & 6 deletions frame/contracts/src/benchmarking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ benchmarks! {
T::Currency::make_free_balance_be(&caller, caller_funding::<T>());
let WasmModule { code, hash, .. } = WasmModule::<T>::sized(c, Location::Call);
let origin = RawOrigin::Signed(caller.clone());
}: _(origin, code, None, Determinism::Deterministic)
}: _(origin, code, None, Determinism::Enforced)
verify {
// uploading the code reserves some balance in the callers account
assert!(T::Currency::reserved_balance(&caller) > 0u32.into());
Expand All @@ -397,7 +397,7 @@ benchmarks! {
T::Currency::make_free_balance_be(&caller, caller_funding::<T>());
let WasmModule { code, hash, .. } = WasmModule::<T>::dummy();
let origin = RawOrigin::Signed(caller.clone());
let uploaded = <Contracts<T>>::bare_upload_code(caller.clone(), code, None, Determinism::Deterministic)?;
let uploaded = <Contracts<T>>::bare_upload_code(caller.clone(), code, None, Determinism::Enforced)?;
assert_eq!(uploaded.code_hash, hash);
assert_eq!(uploaded.deposit, T::Currency::reserved_balance(&caller));
assert!(<Contract<T>>::code_exists(&hash));
Expand Down Expand Up @@ -941,7 +941,7 @@ benchmarks! {
None,
vec![],
true,
Determinism::Deterministic,
Determinism::Enforced,
)
.result?;
}
Expand Down Expand Up @@ -990,7 +990,7 @@ benchmarks! {
None,
vec![],
true,
Determinism::Deterministic,
Determinism::Enforced,
)
.result?;
}
Expand Down Expand Up @@ -3063,7 +3063,7 @@ benchmarks! {
None,
data,
false,
Determinism::Deterministic,
Determinism::Enforced,
)
.result?;
}
Expand Down Expand Up @@ -3112,7 +3112,7 @@ benchmarks! {
None,
data,
false,
Determinism::Deterministic,
Determinism::Enforced,
)
.result?;
}
Expand Down
Loading

0 comments on commit 8f0b0f6

Please sign in to comment.