mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 23:31:07 +00:00
stabilize seal_contains_storage (seal0) and seal_set_storage (seal1) (#11378)
This commit is contained in:
committed by
GitHub
parent
4b64c9085a
commit
e45d53552d
@@ -896,7 +896,7 @@ benchmarks! {
|
||||
let code = WasmModule::<T>::from(ModuleDefinition {
|
||||
memory: Some(ImportedMemory::max::<T>()),
|
||||
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::<T>::from(ModuleDefinition {
|
||||
memory: Some(ImportedMemory::max::<T>()),
|
||||
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::<T>::from(ModuleDefinition {
|
||||
memory: Some(ImportedMemory::max::<T>()),
|
||||
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::<T>::from(ModuleDefinition {
|
||||
memory: Some(ImportedMemory::max::<T>()),
|
||||
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::<T>::from(ModuleDefinition {
|
||||
memory: Some(ImportedMemory::max::<T>()),
|
||||
imported_functions: vec![ImportedFunction {
|
||||
module: "__unstable__",
|
||||
module: "seal0",
|
||||
name: "seal_contains_storage",
|
||||
params: vec![ValueType::I32],
|
||||
return_type: Some(ValueType::I32),
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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, <E: Ext>,
|
||||
//
|
||||
// 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, <E: Ext>,
|
||||
//
|
||||
// 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)?;
|
||||
|
||||
Reference in New Issue
Block a user