From 7bf5c435c7dee688aeee189c573cd937a48d576a Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Mon, 9 May 2022 15:43:23 +0300 Subject: [PATCH] stabilize `seal_contains_storage` (`seal0`) and `seal_set_storage` (`seal1`) --- frame/contracts/src/benchmarking/mod.rs | 10 +++++----- frame/contracts/src/wasm/mod.rs | 6 ++---- frame/contracts/src/wasm/runtime.rs | 6 ++---- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 6411bcb2b589a..194f97f8c878d 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -896,7 +896,7 @@ benchmarks! { let code = WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), imported_functions: vec![ImportedFunction { - module: "__unstable__", + module: "seal1", name: "seal_set_storage", params: vec![ValueType::I32, ValueType::I32, ValueType::I32], return_type: Some(ValueType::I32), @@ -942,7 +942,7 @@ benchmarks! { let code = WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), imported_functions: vec![ImportedFunction { - module: "__unstable__", + module: "seal1", name: "seal_set_storage", params: vec![ValueType::I32, ValueType::I32, ValueType::I32], return_type: Some(ValueType::I32), @@ -988,7 +988,7 @@ benchmarks! { let code = WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), imported_functions: vec![ImportedFunction { - module: "__unstable__", + module: "seal1", name: "seal_set_storage", params: vec![ValueType::I32, ValueType::I32, ValueType::I32], return_type: Some(ValueType::I32), @@ -1233,7 +1233,7 @@ benchmarks! { let code = WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), imported_functions: vec![ImportedFunction { - module: "__unstable__", + module: "seal0", name: "seal_contains_storage", params: vec![ValueType::I32], return_type: Some(ValueType::I32), @@ -1278,7 +1278,7 @@ benchmarks! { let code = WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), imported_functions: vec![ImportedFunction { - module: "__unstable__", + module: "seal0", name: "seal_contains_storage", params: vec![ValueType::I32], return_type: Some(ValueType::I32), diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index 7257fbea6336a..d710cad199f93 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -819,13 +819,12 @@ mod tests { } #[test] - #[cfg(feature = "unstable-interface")] fn contains_storage_works() { const CODE: &str = r#" (module (import "seal0" "seal_return" (func $seal_return (param i32 i32 i32))) (import "seal0" "seal_input" (func $seal_input (param i32 i32))) - (import "__unstable__" "seal_contains_storage" (func $seal_contains_storage (param i32) (result i32))) + (import "seal0" "seal_contains_storage" (func $seal_contains_storage (param i32) (result i32))) (import "env" "memory" (memory 1 1)) ;; [0, 4) size of input buffer (32 byte as we copy the key here) @@ -2163,13 +2162,12 @@ mod tests { } #[test] - #[cfg(feature = "unstable-interface")] fn set_storage_works() { const CODE: &str = r#" (module (import "seal0" "seal_input" (func $seal_input (param i32 i32))) (import "seal0" "seal_return" (func $seal_return (param i32 i32 i32))) - (import "__unstable__" "seal_set_storage" (func $seal_set_storage (param i32 i32 i32) (result i32))) + (import "seal1" "seal_set_storage" (func $seal_set_storage (param i32 i32 i32) (result i32))) (import "env" "memory" (memory 1 1)) ;; 0x1000 = 4k in little endian diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index a6f42ba64a49c..11dfc77616e69 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -185,7 +185,6 @@ pub enum RuntimeCosts { /// Weight of calling `seal_clear_storage` per cleared byte. ClearStorage(u32), /// Weight of calling `seal_contains_storage` per byte of the checked item. - #[cfg(feature = "unstable-interface")] ContainsStorage(u32), /// Weight of calling `seal_get_storage` with the specified size in storage. GetStorage(u32), @@ -269,7 +268,6 @@ impl RuntimeCosts { ClearStorage(len) => s .clear_storage .saturating_add(s.clear_storage_per_byte.saturating_mul(len.into())), - #[cfg(feature = "unstable-interface")] ContainsStorage(len) => s .contains_storage .saturating_add(s.contains_storage_per_byte.saturating_mul(len.into())), @@ -889,7 +887,7 @@ define_env!(Env, , // // Returns the size of the pre-existing value at the specified key if any. Otherwise // `SENTINEL` is returned as a sentinel value. - [__unstable__] seal_set_storage(ctx, key_ptr: u32, value_ptr: u32, value_len: u32) -> u32 => { + [seal1] seal_set_storage(ctx, key_ptr: u32, value_ptr: u32, value_len: u32) -> u32 => { ctx.set_storage(key_ptr, value_ptr, value_len) }, @@ -951,7 +949,7 @@ define_env!(Env, , // // Returns the size of the pre-existing value at the specified key if any. Otherwise // `SENTINEL` is returned as a sentinel value. - [__unstable__] seal_contains_storage(ctx, key_ptr: u32) -> u32 => { + [seal0] seal_contains_storage(ctx, key_ptr: u32) -> u32 => { let charged = ctx.charge_gas(RuntimeCosts::ContainsStorage(ctx.ext.max_value_size()))?; let mut key: StorageKey = [0; 32]; ctx.read_sandbox_memory_into_buf(key_ptr, &mut key)?;