From a8214fdcaeb3ac1f30b0d2e215780adbdddb5cd7 Mon Sep 17 00:00:00 2001 From: yarikbratashchuk Date: Wed, 18 May 2022 18:21:16 +0300 Subject: [PATCH 01/25] Add logic, test, broken benchmark --- .../fixtures/reentrant_count_call.wat | 83 +++++++++++++++++++ frame/contracts/src/benchmarking/mod.rs | 20 +++++ frame/contracts/src/exec.rs | 9 ++ frame/contracts/src/schedule.rs | 4 + frame/contracts/src/tests.rs | 33 ++++++++ frame/contracts/src/wasm/mod.rs | 41 +++++++++ frame/contracts/src/wasm/runtime.rs | 12 +++ frame/contracts/src/weights.rs | 25 ++++++ 8 files changed, 227 insertions(+) create mode 100644 frame/contracts/fixtures/reentrant_count_call.wat diff --git a/frame/contracts/fixtures/reentrant_count_call.wat b/frame/contracts/fixtures/reentrant_count_call.wat new file mode 100644 index 0000000000000..56e386c4f7e8a --- /dev/null +++ b/frame/contracts/fixtures/reentrant_count_call.wat @@ -0,0 +1,83 @@ +(module + (import "seal0" "seal_input" (func $seal_input (param i32 i32))) + (import "seal0" "seal_call" (func $seal_call (param i32 i32 i64 i32 i32 i32 i32 i32 i32) (result i32))) + (import "seal0" "seal_delegate_call" (func $seal_delegate_call (param i32 i32 i32 i32 i32 i32) (result i32))) + (import "__unstable__" "seal_reentrant_count" (func $seal_reentrant_count (result i32))) + (import "env" "memory" (memory 1 1)) + + ;; [0, 32) buffer where input is copied + + ;; [32, 36) size of the input buffer + (data (i32.const 32) "\20") + + (func $assert (param i32) + (block $ok + (br_if $ok + (get_local 0) + ) + (unreachable) + ) + ) + (func (export "call") + (local $exit_code i32) + (local $reentrant_count i32) + + (set_local $reentrant_count + (call $seal_reentrant_count) + ) + + (get_local $reentrant_count) + (if + (then + ;; assert reentrant_count == 1 + (call $assert + (i32.eq (get_local $reentrant_count) (i32.const 1)) + ) + + ;; Delegated call to itself + (set_local $exit_code + (call $seal_delegate_call + (i32.const 0) ;; Set no call flags (reentrance is forbidden) + (i32.const 0) ;; Pointer to "callee" code_hash. + (i32.const 0) ;; Input is ignored + (i32.const 0) ;; Length of the input + (i32.const 4294967295) ;; u32 max sentinel value: do not copy output + (i32.const 0) ;; Length is ignored in this case + ) + ) + + ;; Second reentrance is forbidden + (call $assert + (i32.eq (get_local $exit_code) (i32.const 1)) + ) + ) + (else + ;; Reading "callee" contract address (which is the address of the caller) + (call $seal_input (i32.const 0) (i32.const 32)) + + ;; Call to itself + (set_local $exit_code + (call $seal_call + (i32.const 0) ;; Pointer to "callee" address. + (i32.const 32) ;; Length of "callee" address. + (i64.const 0) ;; How much gas to devote for the execution. 0 = all. + (i32.const 0) ;; Pointer to the buffer with value to transfer + (i32.const 0) ;; Length of the buffer with value to transfer. + (i32.const 0) ;; Pointer to input data buffer address + (i32.const 32) ;; Length of input data buffer + (i32.const 0xffffffff) ;; u32 max sentinel value: do not copy output + (i32.const 0) ;; Ptr to output buffer len + ) + ) + + ;; Check for status code 1, due to reentrance in delegated call. + (call $assert + (i32.eq (get_local $exit_code) (i32.const 1)) ;; ReturnCode::ContractTrapped + ) + ) + ) + ) + + (func (export "deploy")) + +) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index e67436fbc9d37..a28ba4c9eaaeb 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -2041,6 +2041,26 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + seal_reentrant_count { + let r in 0 .. API_BENCHMARK_BATCHES; + let code = WasmModule::::from(ModuleDefinition { + memory: Some(ImportedMemory::max::()), + imported_functions: vec![ImportedFunction { + module: "__unstable__", + name: "seal_reentrant_count", + params: vec![], + return_type: Some(ValueType::I32), + }], + call_body: Some(body::repeated(r * API_BENCHMARK_BATCH_SIZE, &[ + Instruction::Call(0), + Instruction::Drop, + ])), + .. Default::default() + }); + let instance = Contract::::new(code, vec![])?; + let origin = RawOrigin::Signed(instance.caller.clone()); + }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + // We make the assumption that pushing a constant and dropping a value takes roughly // the same amount of time. We follow that `t.load` and `drop` both have the weight // of this benchmark / 2. We need to make this assumption because there is no way diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 54a5223b53d21..1f6adf574190d 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -242,6 +242,10 @@ pub trait Ext: sealing::Sealed { /// Sets new code hash for existing contract. fn set_code_hash(&mut self, hash: CodeHash) -> Result<(), DispatchError>; + + /// Returns how often the currently executing contract exists on the call stack + /// in addition to the calling instance. So a value of 0 means no reentrancy. + fn reentrant_count(&mut self) -> u32; } /// Describes the different functions that can be exported by an [`Executable`]. @@ -1230,6 +1234,11 @@ where }); Ok(()) } + + fn reentrant_count(&mut self) -> u32 { + let id: &AccountIdOf = &self.top_frame().account_id; + (self.frames().filter_map(|f| Some(f.delegate_caller.is_none() && &f.account_id == id)).count() - 1).try_into().unwrap() + } } fn deposit_event(topics: Vec, event: Event) { diff --git a/frame/contracts/src/schedule.rs b/frame/contracts/src/schedule.rs index bbbeb72f2cdf6..f440380cb620a 100644 --- a/frame/contracts/src/schedule.rs +++ b/frame/contracts/src/schedule.rs @@ -421,6 +421,9 @@ pub struct HostFnWeights { /// Weight of calling `seal_ecdsa_to_eth_address`. pub ecdsa_to_eth_address: Weight, + /// Weight of calling `seal_reentrant_count`. + pub reentrant_count: Weight, + /// The type parameter is used in the default implementation. #[codec(skip)] pub _phantom: PhantomData, @@ -657,6 +660,7 @@ impl Default for HostFnWeights { hash_blake2_128_per_byte: cost_byte_batched!(seal_hash_blake2_128_per_kb), ecdsa_recover: cost_batched!(seal_ecdsa_recover), ecdsa_to_eth_address: cost_batched!(seal_ecdsa_to_eth_address), + reentrant_count: cost_batched!(seal_reentrant_count), _phantom: PhantomData, } } diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index ce59f5bb858ac..000d51ef8c8fa 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -3151,3 +3151,36 @@ fn set_code_hash() { ); }); } + +#[test] +#[cfg(feature = "unstable-interface")] +fn reentrant_count() { + let (wasm1, code_hash1) = compile_module::("reentrant_count_call").unwrap(); + let contract_addr1 = Contracts::contract_address(&ALICE, &code_hash1, &[]); + + ExtBuilder::default().existential_deposit(100).build().execute_with(|| { + let _ = Balances::deposit_creating(&ALICE, 1_000_000); + + assert_ok!(Contracts::instantiate_with_code( + Origin::signed(ALICE), + 300_000, + GAS_LIMIT, + None, + wasm1, + vec![], + vec![], + )); + + Contracts::bare_call( + ALICE, + contract_addr1.clone(), + 0, + GAS_LIMIT, + None, + AsRef::<[u8]>::as_ref(&contract_addr1).to_vec(), + true, + ) + .result + .unwrap(); + }); +} diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index f12df06b938c8..eb6ea975b2f82 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -327,6 +327,7 @@ mod tests { debug_buffer: Vec, ecdsa_recover: RefCell>, code_hashes: Vec>, + reentrant_count: Vec, } /// The call is mocked and just returns this hardcoded value. @@ -350,6 +351,7 @@ mod tests { gas_meter: GasMeter::new(10_000_000_000), debug_buffer: Default::default(), ecdsa_recover: Default::default(), + reentrant_count: vec![], } } } @@ -506,6 +508,10 @@ mod tests { fn ecdsa_to_eth_address(&self, _pk: &[u8; 33]) -> Result<[u8; 20], ()> { Ok([2u8; 20]) } + fn reentrant_count(&mut self) -> u32 { + self.reentrant_count.push(12u8); + 12 + } } fn execute>(wat: &str, input_data: Vec, mut ext: E) -> ExecResult { @@ -2585,4 +2591,39 @@ mod tests { assert_eq!(mock_ext.code_hashes.pop().unwrap(), H256::from_slice(&[17u8; 32])); } + + #[test] + #[cfg(feature = "unstable-interface")] + fn reentrant_count() { + const CODE: &str = r#" +(module + (import "__unstable__" "seal_reentrant_count" (func $seal_reentrant_count (result i32))) + (import "env" "memory" (memory 1 1)) + (func $assert (param i32) + (block $ok + (br_if $ok + (get_local 0) + ) + (unreachable) + ) + ) + (func (export "call") + (local $exit_code i32) + (set_local $exit_code + (call $seal_reentrant_count) + ) + (call $assert + (i32.eq (get_local $exit_code) (i32.const 12)) + ) + ) + + (func (export "deploy")) +) +"#; + + let mut mock_ext = MockExt::default(); + execute(CODE, vec![], &mut mock_ext).unwrap(); + + assert_eq!(mock_ext.reentrant_count.pop().unwrap(), 12u8); + } } diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index 876bd8848b0b1..12de20760e27b 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -230,6 +230,9 @@ pub enum RuntimeCosts { /// Weight of calling `ecdsa_to_eth_address` #[cfg(feature = "unstable-interface")] EcdsaToEthAddress, + /// Weight of calling `seal_reentrant_count` + #[cfg(feature = "unstable-interface")] + ReentrantCount, } impl RuntimeCosts { @@ -316,6 +319,8 @@ impl RuntimeCosts { SetCodeHash => s.set_code_hash, #[cfg(feature = "unstable-interface")] EcdsaToEthAddress => s.ecdsa_to_eth_address, + #[cfg(feature = "unstable-interface")] + ReentrantCount => s.reentrant_count, }; RuntimeToken { #[cfg(test)] @@ -2090,4 +2095,11 @@ define_env!(Env, , Err(_) => Ok(ReturnCode::EcdsaRecoverFailed), } }, + + // Returns how often the currently executing contract exists on the call stack in addition + // to the calling instance. A value of 0 means no reentrancy. + [__unstable__] seal_reentrant_count(ctx) -> u32 => { + ctx.charge_gas(RuntimeCosts::ReentrantCount)?; + Ok(ctx.ext.reentrant_count() as u32) + }, ); diff --git a/frame/contracts/src/weights.rs b/frame/contracts/src/weights.rs index 85ff2548ca698..826956b931584 100644 --- a/frame/contracts/src/weights.rs +++ b/frame/contracts/src/weights.rs @@ -105,6 +105,7 @@ pub trait WeightInfo { fn seal_ecdsa_recover(r: u32, ) -> Weight; fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight; fn seal_set_code_hash(r: u32, ) -> Weight; + fn seal_reentrant_count(r: u32, ) -> Weight; fn instr_i64const(r: u32, ) -> Weight; fn instr_i64load(r: u32, ) -> Weight; fn instr_i64store(r: u32, ) -> Weight; @@ -825,6 +826,18 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().reads((99 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes((99 as Weight).saturating_mul(r as Weight))) } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1) + fn seal_reentrant_count(r: u32, ) -> Weight { + (91_522_000 as Weight) + // Standard Error: 50_000 + .saturating_add((24_064_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(T::DbWeight::get().reads(5 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } fn instr_i64const(r: u32, ) -> Weight { (74_516_000 as Weight) // Standard Error: 1_000 @@ -1748,6 +1761,18 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads((99 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes((99 as Weight).saturating_mul(r as Weight))) } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1) + fn seal_reentrant_count(r: u32, ) -> Weight { + (91_522_000 as Weight) + // Standard Error: 50_000 + .saturating_add((24_064_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(RocksDbWeight::get().reads(5 as Weight)) + .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + } fn instr_i64const(r: u32, ) -> Weight { (74_516_000 as Weight) // Standard Error: 1_000 From fccd751937684d53cdce9eff84fce1f37ef95e44 Mon Sep 17 00:00:00 2001 From: yarikbratashchuk Date: Mon, 23 May 2022 17:16:08 +0300 Subject: [PATCH 02/25] account_entrance_count --- frame/contracts/src/benchmarking/mod.rs | 33 +++++++++++++++++++++++++ frame/contracts/src/exec.rs | 17 ++++++++++--- frame/contracts/src/schedule.rs | 4 +++ frame/contracts/src/wasm/mod.rs | 1 + frame/contracts/src/wasm/runtime.rs | 16 +++++++++++- frame/contracts/src/weights.rs | 23 +++++++++++++++++ 6 files changed, 89 insertions(+), 5 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index f8dbff5b9394d..ec74e27b9c0d5 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -2075,6 +2075,39 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + seal_account_entrance_count { + let r in 0 .. API_BENCHMARK_BATCHES; + let dummy_code = WasmModule::::dummy_with_bytes(0); + let accounts = (0..r * API_BENCHMARK_BATCH_SIZE) + .map(|i| Contract::with_index(i + 1, dummy_code.clone(), vec![])) + .collect::, _>>()?; + let account_id_len = accounts.get(0).map(|i| i.account_id.encode().len()).unwrap_or(0); + let account_id_bytes = accounts.iter().flat_map(|x| x.account_id.encode()).collect(); + let code = WasmModule::::from(ModuleDefinition { + memory: Some(ImportedMemory::max::()), + imported_functions: vec![ImportedFunction { + module: "__unstable__", + name: "seal_account_entrance_count", + params: vec![ValueType::I32], + return_type: Some(ValueType::I32), + }], + data_segments: vec![ + DataSegment { + offset: 0, + value: account_id_bytes, + }, + ], + call_body: Some(body::repeated_dyn(r * API_BENCHMARK_BATCH_SIZE, vec![ + Counter(0 as u32, account_id_len as u32), // account_ptr + Regular(Instruction::Call(0)), + Regular(Instruction::Drop), + ])), + .. Default::default() + }); + let instance = Contract::::new(code, vec![])?; + let origin = RawOrigin::Signed(instance.caller.clone()); + }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + // We make the assumption that pushing a constant and dropping a value takes roughly // the same amount of time. We follow that `t.load` and `drop` both have the weight // of this benchmark / 2. We need to make this assumption because there is no way diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 7c2ff3a644a81..3be19d1edcef8 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -243,9 +243,14 @@ pub trait Ext: sealing::Sealed { /// Sets new code hash for existing contract. fn set_code_hash(&mut self, hash: CodeHash) -> Result<(), DispatchError>; - /// Returns how often the currently executing contract exists on the call stack - /// in addition to the calling instance. So a value of 0 means no reentrancy. + /// Returns then number of times currently executing contract exists on the call stack in addition + /// to the calling instance. A value of 0 means no reentrancy. fn reentrant_count(&mut self) -> u32; + + /// Returns the number of times specified contract exists on the call stack. Delegated calls are not + /// calculated as separate entrance. + /// A value of 0 means it does not exist on the call stack. + fn account_entrance_count(&mut self, account_id: AccountIdOf) -> u32; } /// Describes the different functions that can be exported by an [`Executable`]. @@ -1233,8 +1238,12 @@ where } fn reentrant_count(&mut self) -> u32 { - let id: &AccountIdOf = &self.top_frame().account_id; - (self.frames().filter_map(|f| Some(f.delegate_caller.is_none() && &f.account_id == id)).count() - 1).try_into().unwrap() + let id: AccountIdOf = self.top_frame().account_id.clone(); + self.account_entrance_count(id) - 1u32 + } + + fn account_entrance_count(&mut self, account_id: AccountIdOf) -> u32 { + self.frames().filter_map(|f| Some(f.delegate_caller.is_none() && &f.account_id == &account_id)).count() as u32 } } diff --git a/frame/contracts/src/schedule.rs b/frame/contracts/src/schedule.rs index 8cab165780619..76314f6c4d29b 100644 --- a/frame/contracts/src/schedule.rs +++ b/frame/contracts/src/schedule.rs @@ -419,6 +419,9 @@ pub struct HostFnWeights { /// Weight of calling `seal_reentrant_count`. pub reentrant_count: Weight, + /// Weight of calling `seal_account_entrance_count`. + pub account_entrance_count: Weight, + /// The type parameter is used in the default implementation. #[codec(skip)] pub _phantom: PhantomData, @@ -655,6 +658,7 @@ impl Default for HostFnWeights { ecdsa_recover: cost_batched!(seal_ecdsa_recover), ecdsa_to_eth_address: cost_batched!(seal_ecdsa_to_eth_address), reentrant_count: cost_batched!(seal_reentrant_count), + account_entrance_count: cost_batched!(seal_account_entrance_count), _phantom: PhantomData, } } diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index 3d48f32f136fd..40f1bb2cc76a6 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -529,6 +529,7 @@ mod tests { self.reentrant_count.push(12u8); 12 } + fn account_entrance_count(&mut self, _account_id: AccountIdOf) -> u32 { unimplemented!() } } fn execute>(wat: &str, input_data: Vec, mut ext: E) -> ExecResult { diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index b05776d5a6ba9..bd8b8435791bc 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -226,6 +226,9 @@ pub enum RuntimeCosts { /// Weight of calling `seal_reentrant_count` #[cfg(feature = "unstable-interface")] ReentrantCount, + /// Weight of calling `seal_account_entrance_count` + #[cfg(feature = "unstable-interface")] + AccountEntranceCount, } impl RuntimeCosts { @@ -307,6 +310,8 @@ impl RuntimeCosts { EcdsaToEthAddress => s.ecdsa_to_eth_address, #[cfg(feature = "unstable-interface")] ReentrantCount => s.reentrant_count, + #[cfg(feature = "unstable-interface")] + AccountEntranceCount => s.account_entrance_count, }; RuntimeToken { #[cfg(test)] @@ -2082,10 +2087,19 @@ define_env!(Env, , } }, - // Returns how often the currently executing contract exists on the call stack in addition + // Returns then number of times currently executing contract exists on the call stack in addition // to the calling instance. A value of 0 means no reentrancy. [__unstable__] seal_reentrant_count(ctx) -> u32 => { ctx.charge_gas(RuntimeCosts::ReentrantCount)?; Ok(ctx.ext.reentrant_count() as u32) }, + + // Returns the number of times specified contract exists on the call stack. Delegated calls are + // not calculated as separate calls. + // A value of 0 means it does not exist on the stack. + [__unstable__] seal_account_entrance_count(ctx, account_ptr: u32) -> u32 => { + ctx.charge_gas(RuntimeCosts::AccountEntranceCount)?; + let account_id: <::T as frame_system::Config>::AccountId = ctx.read_sandbox_memory_as(account_ptr)?; + Ok(ctx.ext.account_entrance_count(account_id) as u32) + }, ); diff --git a/frame/contracts/src/weights.rs b/frame/contracts/src/weights.rs index e51960e41428e..d92770f20eb03 100644 --- a/frame/contracts/src/weights.rs +++ b/frame/contracts/src/weights.rs @@ -108,6 +108,7 @@ pub trait WeightInfo { fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight; fn seal_set_code_hash(r: u32, ) -> Weight; fn seal_reentrant_count(r: u32, ) -> Weight; + fn seal_account_entrance_count(r: u32, ) -> Weight; fn instr_i64const(r: u32, ) -> Weight; fn instr_i64load(r: u32, ) -> Weight; fn instr_i64store(r: u32, ) -> Weight; @@ -849,6 +850,17 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + fn seal_account_entrance_count(r: u32, ) -> Weight { + (179_313_000 as Weight) + // Standard Error: 610_000 + .saturating_add((63_085_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(T::DbWeight::get().reads(4 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } fn instr_i64const(r: u32, ) -> Weight { (74_627_000 as Weight) // Standard Error: 1_000 @@ -1793,6 +1805,17 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + fn seal_account_entrance_count(r: u32, ) -> Weight { + (179_313_000 as Weight) + // Standard Error: 610_000 + .saturating_add((63_085_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(RocksDbWeight::get().reads(4 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + } fn instr_i64const(r: u32, ) -> Weight { (74_627_000 as Weight) // Standard Error: 1_000 From 0a702390cb04ce8b98d69da7ac427762a4dfeb91 Mon Sep 17 00:00:00 2001 From: yarikbratashchuk Date: Sun, 29 May 2022 06:42:45 +0300 Subject: [PATCH 03/25] Addressing comments --- frame/contracts/src/exec.rs | 12 ++++++------ frame/contracts/src/wasm/mod.rs | 9 ++------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 3be19d1edcef8..29bf8ace30247 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -245,12 +245,12 @@ pub trait Ext: sealing::Sealed { /// Returns then number of times currently executing contract exists on the call stack in addition /// to the calling instance. A value of 0 means no reentrancy. - fn reentrant_count(&mut self) -> u32; + fn reentrant_count(&self) -> u32; /// Returns the number of times specified contract exists on the call stack. Delegated calls are not /// calculated as separate entrance. /// A value of 0 means it does not exist on the call stack. - fn account_entrance_count(&mut self, account_id: AccountIdOf) -> u32; + fn account_entrance_count(&self, account_id: &AccountIdOf) -> u32; } /// Describes the different functions that can be exported by an [`Executable`]. @@ -1237,13 +1237,13 @@ where Ok(()) } - fn reentrant_count(&mut self) -> u32 { - let id: AccountIdOf = self.top_frame().account_id.clone(); + fn reentrant_count(&self) -> u32 { + let id: &AccountIdOf = &self.top_frame().account_id; self.account_entrance_count(id) - 1u32 } - fn account_entrance_count(&mut self, account_id: AccountIdOf) -> u32 { - self.frames().filter_map(|f| Some(f.delegate_caller.is_none() && &f.account_id == &account_id)).count() as u32 + fn account_entrance_count(&self, account_id: &AccountIdOf) -> u32 { + self.frames().filter_map(|f| Some(f.delegate_caller.is_none() && &f.account_id == account_id)).count() as u32 } } diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index 40f1bb2cc76a6..f07700c3b0a47 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -344,7 +344,6 @@ mod tests { debug_buffer: Vec, ecdsa_recover: RefCell>, code_hashes: Vec>, - reentrant_count: Vec, } /// The call is mocked and just returns this hardcoded value. @@ -368,7 +367,6 @@ mod tests { gas_meter: GasMeter::new(10_000_000_000), debug_buffer: Default::default(), ecdsa_recover: Default::default(), - reentrant_count: vec![], } } } @@ -525,11 +523,8 @@ mod tests { fn ecdsa_to_eth_address(&self, _pk: &[u8; 33]) -> Result<[u8; 20], ()> { Ok([2u8; 20]) } - fn reentrant_count(&mut self) -> u32 { - self.reentrant_count.push(12u8); - 12 - } - fn account_entrance_count(&mut self, _account_id: AccountIdOf) -> u32 { unimplemented!() } + fn reentrant_count(&self) -> u32 { 12 } + fn account_entrance_count(&self, _account_id: &AccountIdOf) -> u32 { unimplemented!() } } fn execute>(wat: &str, input_data: Vec, mut ext: E) -> ExecResult { From 6f3655a595da170328b94fb273713f4c1bf03632 Mon Sep 17 00:00:00 2001 From: yarikbratashchuk Date: Wed, 1 Jun 2022 19:28:15 +0300 Subject: [PATCH 04/25] Address @agryaznov's comments --- frame/contracts/fixtures/reentrant_count_call.wat | 6 +++--- frame/contracts/src/exec.rs | 2 +- frame/contracts/src/tests.rs | 2 +- frame/contracts/src/wasm/mod.rs | 2 +- frame/contracts/src/wasm/runtime.rs | 15 +++++++++++++-- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/frame/contracts/fixtures/reentrant_count_call.wat b/frame/contracts/fixtures/reentrant_count_call.wat index 56e386c4f7e8a..eb7bad4cd5d95 100644 --- a/frame/contracts/fixtures/reentrant_count_call.wat +++ b/frame/contracts/fixtures/reentrant_count_call.wat @@ -1,6 +1,6 @@ (module - (import "seal0" "seal_input" (func $seal_input (param i32 i32))) - (import "seal0" "seal_call" (func $seal_call (param i32 i32 i64 i32 i32 i32 i32 i32 i32) (result i32))) + (import "seal1" "seal_input" (func $seal_input (param i32 i32))) + (import "seal1" "seal_call" (func $seal_call (param i32 i32 i64 i32 i32 i32 i32 i32 i32) (result i32))) (import "seal0" "seal_delegate_call" (func $seal_delegate_call (param i32 i32 i32 i32 i32 i32) (result i32))) (import "__unstable__" "seal_reentrant_count" (func $seal_reentrant_count (result i32))) (import "env" "memory" (memory 1 1)) @@ -41,7 +41,7 @@ (i32.const 0) ;; Pointer to "callee" code_hash. (i32.const 0) ;; Input is ignored (i32.const 0) ;; Length of the input - (i32.const 4294967295) ;; u32 max sentinel value: do not copy output + (i32.const 0xffffffff) ;; u32 max sentinel value: do not copy output (i32.const 0) ;; Length is ignored in this case ) ) diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 29bf8ace30247..57630753cb275 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -1243,7 +1243,7 @@ where } fn account_entrance_count(&self, account_id: &AccountIdOf) -> u32 { - self.frames().filter_map(|f| Some(f.delegate_caller.is_none() && &f.account_id == account_id)).count() as u32 + self.frames().filter_map(|f| (f.delegate_caller.is_none() && &f.account_id == account_id).then(|| true)).count() as u32 } } diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 33241150289b7..d709d755675e6 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -3231,7 +3231,7 @@ fn set_code_hash() { #[test] #[cfg(feature = "unstable-interface")] -fn reentrant_count() { +fn reentrant_count_works() { let (wasm1, code_hash1) = compile_module::("reentrant_count_call").unwrap(); let contract_addr1 = Contracts::contract_address(&ALICE, &code_hash1, &[]); diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index f07700c3b0a47..cfc2a9272af4f 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -2599,7 +2599,7 @@ mod tests { #[test] #[cfg(feature = "unstable-interface")] - fn reentrant_count() { + fn reentrant_count_works() { const CODE: &str = r#" (module (import "__unstable__" "seal_reentrant_count" (func $seal_reentrant_count (result i32))) diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index bd8b8435791bc..25dc85cfbc3af 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -2088,7 +2088,11 @@ define_env!(Env, , }, // Returns then number of times currently executing contract exists on the call stack in addition - // to the calling instance. A value of 0 means no reentrancy. + // to the calling instance. + // + // # Return Value + // + // Returns 0 when there is no reentrancy [__unstable__] seal_reentrant_count(ctx) -> u32 => { ctx.charge_gas(RuntimeCosts::ReentrantCount)?; Ok(ctx.ext.reentrant_count() as u32) @@ -2096,7 +2100,14 @@ define_env!(Env, , // Returns the number of times specified contract exists on the call stack. Delegated calls are // not calculated as separate calls. - // A value of 0 means it does not exist on the stack. + // + // # Parameters + // + // - `account_ptr`: a pointer to the contract address. + // + // # Return Value + // + // Returns 0 when the contract does not exist on the call stack. [__unstable__] seal_account_entrance_count(ctx, account_ptr: u32) -> u32 => { ctx.charge_gas(RuntimeCosts::AccountEntranceCount)?; let account_id: <::T as frame_system::Config>::AccountId = ctx.read_sandbox_memory_as(account_ptr)?; From f29884b89957eee10f99a9b0d45fbdbff899ee76 Mon Sep 17 00:00:00 2001 From: yarikbratashchuk Date: Thu, 2 Jun 2022 13:56:33 +0300 Subject: [PATCH 05/25] Add test for account_entrance_count, fix ci --- .../fixtures/account_entrance_count_call.wat | 28 ++++++++++++++++ frame/contracts/src/tests.rs | 32 +++++++++++++++++++ frame/contracts/src/wasm/runtime.rs | 4 +-- 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 frame/contracts/fixtures/account_entrance_count_call.wat diff --git a/frame/contracts/fixtures/account_entrance_count_call.wat b/frame/contracts/fixtures/account_entrance_count_call.wat new file mode 100644 index 0000000000000..9afbcde5e4344 --- /dev/null +++ b/frame/contracts/fixtures/account_entrance_count_call.wat @@ -0,0 +1,28 @@ +(module + (import "__unstable__" "seal_account_entrance_count" (func $seal_account_entrance_count (result i32))) + (import "env" "memory" (memory 1 1)) + + (func $assert (param i32) + (block $ok + (br_if $ok + (get_local 0) + ) + (unreachable) + ) + ) + (func (export "call") + (local $entrance_count i32) + + (set_local $entrance_count + (call $seal_account_entrance_count) + ) + + ;; assert account_entrance_count == 1 + (call $assert + (i32.eq (get_local $account_entrance_count) (i32.const 1)) + ) + ) + + (func (export "deploy")) + +) diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index d709d755675e6..307bd3a660578 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -3261,3 +3261,35 @@ fn reentrant_count_works() { .unwrap(); }); } +#[test] +#[cfg(feature = "unstable-interface")] +fn account_entrance_count_works() { + let (wasm1, code_hash1) = compile_module::("account_entrance_count_call").unwrap(); + let contract_addr1 = Contracts::contract_address(&ALICE, &code_hash1, &[]); + + ExtBuilder::default().existential_deposit(100).build().execute_with(|| { + let _ = Balances::deposit_creating(&ALICE, 1_000_000); + + assert_ok!(Contracts::instantiate_with_code( + Origin::signed(ALICE), + 300_000, + GAS_LIMIT, + None, + wasm1, + vec![], + vec![], + )); + + Contracts::bare_call( + ALICE, + contract_addr1.clone(), + 0, + GAS_LIMIT, + None, + AsRef::<[u8]>::as_ref(&contract_addr1).to_vec(), + true, + ) + .result + .unwrap(); + }); +} diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index 25dc85cfbc3af..2d61552c7d61e 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -2110,7 +2110,7 @@ define_env!(Env, , // Returns 0 when the contract does not exist on the call stack. [__unstable__] seal_account_entrance_count(ctx, account_ptr: u32) -> u32 => { ctx.charge_gas(RuntimeCosts::AccountEntranceCount)?; - let account_id: <::T as frame_system::Config>::AccountId = ctx.read_sandbox_memory_as(account_ptr)?; - Ok(ctx.ext.account_entrance_count(account_id) as u32) + let account_id: &<::T as frame_system::Config>::AccountId = ctx.read_sandbox_memory_as(account_ptr)?; + Ok(ctx.ext.account_entrance_count(&account_id) as u32) }, ); From 72c8f83f8583e9f56587b1409252527870a37eb3 Mon Sep 17 00:00:00 2001 From: yarikbratashchuk Date: Thu, 2 Jun 2022 14:01:49 +0300 Subject: [PATCH 06/25] Cargo fmt --- frame/contracts/src/exec.rs | 14 +++++++++----- frame/contracts/src/tests.rs | 8 ++++---- frame/contracts/src/wasm/mod.rs | 8 ++++++-- frame/contracts/src/wasm/runtime.rs | 2 +- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 57630753cb275..d70b0f2b8ab30 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -243,12 +243,12 @@ pub trait Ext: sealing::Sealed { /// Sets new code hash for existing contract. fn set_code_hash(&mut self, hash: CodeHash) -> Result<(), DispatchError>; - /// Returns then number of times currently executing contract exists on the call stack in addition - /// to the calling instance. A value of 0 means no reentrancy. + /// Returns then number of times currently executing contract exists on the call stack in + /// addition to the calling instance. A value of 0 means no reentrancy. fn reentrant_count(&self) -> u32; - /// Returns the number of times specified contract exists on the call stack. Delegated calls are not - /// calculated as separate entrance. + /// Returns the number of times specified contract exists on the call stack. Delegated calls are + /// not calculated as separate entrance. /// A value of 0 means it does not exist on the call stack. fn account_entrance_count(&self, account_id: &AccountIdOf) -> u32; } @@ -1243,7 +1243,11 @@ where } fn account_entrance_count(&self, account_id: &AccountIdOf) -> u32 { - self.frames().filter_map(|f| (f.delegate_caller.is_none() && &f.account_id == account_id).then(|| true)).count() as u32 + self.frames() + .filter_map(|f| { + (f.delegate_caller.is_none() && &f.account_id == account_id).then(|| true) + }) + .count() as u32 } } diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 307bd3a660578..152cafbb541d5 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -3257,8 +3257,8 @@ fn reentrant_count_works() { AsRef::<[u8]>::as_ref(&contract_addr1).to_vec(), true, ) - .result - .unwrap(); + .result + .unwrap(); }); } #[test] @@ -3289,7 +3289,7 @@ fn account_entrance_count_works() { AsRef::<[u8]>::as_ref(&contract_addr1).to_vec(), true, ) - .result - .unwrap(); + .result + .unwrap(); }); } diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index cfc2a9272af4f..9025fd0fe62d3 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -523,8 +523,12 @@ mod tests { fn ecdsa_to_eth_address(&self, _pk: &[u8; 33]) -> Result<[u8; 20], ()> { Ok([2u8; 20]) } - fn reentrant_count(&self) -> u32 { 12 } - fn account_entrance_count(&self, _account_id: &AccountIdOf) -> u32 { unimplemented!() } + fn reentrant_count(&self) -> u32 { + 12 + } + fn account_entrance_count(&self, _account_id: &AccountIdOf) -> u32 { + unimplemented!() + } } fn execute>(wat: &str, input_data: Vec, mut ext: E) -> ExecResult { diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index 2d61552c7d61e..ba6122fd4eca1 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -2110,7 +2110,7 @@ define_env!(Env, , // Returns 0 when the contract does not exist on the call stack. [__unstable__] seal_account_entrance_count(ctx, account_ptr: u32) -> u32 => { ctx.charge_gas(RuntimeCosts::AccountEntranceCount)?; - let account_id: &<::T as frame_system::Config>::AccountId = ctx.read_sandbox_memory_as(account_ptr)?; + let account_id: <::T as frame_system::Config>::AccountId = ctx.read_sandbox_memory_as(account_ptr)?; Ok(ctx.ext.account_entrance_count(&account_id) as u32) }, ); From 0f6f8943d48c264f24dd1c2b8748fa7d6bd13422 Mon Sep 17 00:00:00 2001 From: yarikbratashchuk Date: Thu, 2 Jun 2022 16:27:21 +0300 Subject: [PATCH 07/25] Fix tests --- frame/contracts/fixtures/account_entrance_count_call.wat | 4 ++-- frame/contracts/src/wasm/mod.rs | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/frame/contracts/fixtures/account_entrance_count_call.wat b/frame/contracts/fixtures/account_entrance_count_call.wat index 9afbcde5e4344..03bd30480bec7 100644 --- a/frame/contracts/fixtures/account_entrance_count_call.wat +++ b/frame/contracts/fixtures/account_entrance_count_call.wat @@ -11,9 +11,9 @@ ) ) (func (export "call") - (local $entrance_count i32) + (local $account_entrance_count i32) - (set_local $entrance_count + (set_local $account_entrance_count (call $seal_account_entrance_count) ) diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index 9025fd0fe62d3..9b2683319c45d 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -2632,7 +2632,5 @@ mod tests { let mut mock_ext = MockExt::default(); execute(CODE, vec![], &mut mock_ext).unwrap(); - - assert_eq!(mock_ext.reentrant_count.pop().unwrap(), 12u8); } } From 949c4388eba2a67a93170899a15370d1037f20cf Mon Sep 17 00:00:00 2001 From: yarikbratashchuk Date: Sun, 5 Jun 2022 14:19:31 +0300 Subject: [PATCH 08/25] Fix tests --- .../fixtures/account_entrance_count_call.wat | 13 +++++++++++-- frame/contracts/fixtures/reentrant_count_call.wat | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/frame/contracts/fixtures/account_entrance_count_call.wat b/frame/contracts/fixtures/account_entrance_count_call.wat index 03bd30480bec7..a50a204ab0a7b 100644 --- a/frame/contracts/fixtures/account_entrance_count_call.wat +++ b/frame/contracts/fixtures/account_entrance_count_call.wat @@ -1,7 +1,13 @@ (module - (import "__unstable__" "seal_account_entrance_count" (func $seal_account_entrance_count (result i32))) + (import "seal0" "seal_input" (func $seal_input (param i32 i32))) + (import "__unstable__" "seal_account_entrance_count" (func $seal_account_entrance_count (param i32) (result i32))) (import "env" "memory" (memory 1 1)) + ;; [0, 32) buffer where input is copied + + ;; [32, 36) size of the input buffer + (data (i32.const 32) "\20") + (func $assert (param i32) (block $ok (br_if $ok @@ -13,8 +19,11 @@ (func (export "call") (local $account_entrance_count i32) + ;; Reading "callee" contract address (which is the address of the caller) + (call $seal_input (i32.const 0) (i32.const 32)) + (set_local $account_entrance_count - (call $seal_account_entrance_count) + (call $seal_account_entrance_count (i32.const 0)) ) ;; assert account_entrance_count == 1 diff --git a/frame/contracts/fixtures/reentrant_count_call.wat b/frame/contracts/fixtures/reentrant_count_call.wat index eb7bad4cd5d95..33e424942885d 100644 --- a/frame/contracts/fixtures/reentrant_count_call.wat +++ b/frame/contracts/fixtures/reentrant_count_call.wat @@ -1,6 +1,6 @@ (module - (import "seal1" "seal_input" (func $seal_input (param i32 i32))) - (import "seal1" "seal_call" (func $seal_call (param i32 i32 i64 i32 i32 i32 i32 i32 i32) (result i32))) + (import "seal0" "seal_input" (func $seal_input (param i32 i32))) + (import "seal0" "seal_call" (func $seal_call (param i32 i32 i64 i32 i32 i32 i32 i32 i32) (result i32))) (import "seal0" "seal_delegate_call" (func $seal_delegate_call (param i32 i32 i32 i32 i32 i32) (result i32))) (import "__unstable__" "seal_reentrant_count" (func $seal_reentrant_count (result i32))) (import "env" "memory" (memory 1 1)) From f34b6da3d19bf0184082beb39092fca0e4a52ff3 Mon Sep 17 00:00:00 2001 From: yarikbratashchuk Date: Thu, 16 Jun 2022 13:12:08 +0300 Subject: [PATCH 09/25] Remove delegated call from test, address comments --- .../fixtures/reentrant_count_call.wat | 22 +--------- frame/contracts/src/exec.rs | 2 +- frame/contracts/src/tests.rs | 2 +- frame/contracts/src/wasm/mod.rs | 41 +++++++++++++++++-- 4 files changed, 41 insertions(+), 26 deletions(-) diff --git a/frame/contracts/fixtures/reentrant_count_call.wat b/frame/contracts/fixtures/reentrant_count_call.wat index 33e424942885d..3f274975afa36 100644 --- a/frame/contracts/fixtures/reentrant_count_call.wat +++ b/frame/contracts/fixtures/reentrant_count_call.wat @@ -1,7 +1,6 @@ (module (import "seal0" "seal_input" (func $seal_input (param i32 i32))) (import "seal0" "seal_call" (func $seal_call (param i32 i32 i64 i32 i32 i32 i32 i32 i32) (result i32))) - (import "seal0" "seal_delegate_call" (func $seal_delegate_call (param i32 i32 i32 i32 i32 i32) (result i32))) (import "__unstable__" "seal_reentrant_count" (func $seal_reentrant_count (result i32))) (import "env" "memory" (memory 1 1)) @@ -33,23 +32,6 @@ (call $assert (i32.eq (get_local $reentrant_count) (i32.const 1)) ) - - ;; Delegated call to itself - (set_local $exit_code - (call $seal_delegate_call - (i32.const 0) ;; Set no call flags (reentrance is forbidden) - (i32.const 0) ;; Pointer to "callee" code_hash. - (i32.const 0) ;; Input is ignored - (i32.const 0) ;; Length of the input - (i32.const 0xffffffff) ;; u32 max sentinel value: do not copy output - (i32.const 0) ;; Length is ignored in this case - ) - ) - - ;; Second reentrance is forbidden - (call $assert - (i32.eq (get_local $exit_code) (i32.const 1)) - ) ) (else ;; Reading "callee" contract address (which is the address of the caller) @@ -70,9 +52,9 @@ ) ) - ;; Check for status code 1, due to reentrance in delegated call. + ;; assert reentrant_count == 0 (call $assert - (i32.eq (get_local $exit_code) (i32.const 1)) ;; ReturnCode::ContractTrapped + (i32.eq (get_local $reentrant_count) (i32.const 0)) ) ) ) diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index d70b0f2b8ab30..7dc0233750e48 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -1239,7 +1239,7 @@ where fn reentrant_count(&self) -> u32 { let id: &AccountIdOf = &self.top_frame().account_id; - self.account_entrance_count(id) - 1u32 + self.account_entrance_count(id).checked_sub(1).unwrap_or(0) } fn account_entrance_count(&self, account_id: &AccountIdOf) -> u32 { diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 152cafbb541d5..eb44503c8b6ed 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -3231,7 +3231,7 @@ fn set_code_hash() { #[test] #[cfg(feature = "unstable-interface")] -fn reentrant_count_works() { +fn reentrant_count_works_with_call() { let (wasm1, code_hash1) = compile_module::("reentrant_count_call").unwrap(); let contract_addr1 = Contracts::contract_address(&ALICE, &code_hash1, &[]); diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index 9b2683319c45d..bd29731befa56 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -527,7 +527,7 @@ mod tests { 12 } fn account_entrance_count(&self, _account_id: &AccountIdOf) -> u32 { - unimplemented!() + 12 } } @@ -2617,12 +2617,45 @@ mod tests { ) ) (func (export "call") - (local $exit_code i32) - (set_local $exit_code + (local $return_val i32) + (set_local $return_val (call $seal_reentrant_count) ) (call $assert - (i32.eq (get_local $exit_code) (i32.const 12)) + (i32.eq (get_local $return_val) (i32.const 12)) + ) + ) + + (func (export "deploy")) +) +"#; + + let mut mock_ext = MockExt::default(); + execute(CODE, vec![], &mut mock_ext).unwrap(); + } + + #[test] + #[cfg(feature = "unstable-interface")] + fn account_entrance_count_works() { + const CODE: &str = r#" +(module + (import "__unstable__" "seal_account_entrance_count" (func $seal_account_entrance_count (param i32) (result i32))) + (import "env" "memory" (memory 1 1)) + (func $assert (param i32) + (block $ok + (br_if $ok + (get_local 0) + ) + (unreachable) + ) + ) + (func (export "call") + (local $return_val i32) + (set_local $return_val + (call $seal_account_entrance_count (i32.const 0)) + ) + (call $assert + (i32.eq (get_local $return_val) (i32.const 12)) ) ) From a036585d76e85c578e09cfc5c4cdc49e70e89ff6 Mon Sep 17 00:00:00 2001 From: yarikbratashchuk Date: Tue, 21 Jun 2022 16:42:14 +0300 Subject: [PATCH 10/25] Minor fixes and indentation in wat files --- .../fixtures/account_entrance_count_call.wat | 6 +- .../fixtures/reentrant_count_call.wat | 62 +++++++++---------- frame/contracts/src/benchmarking/mod.rs | 2 +- frame/contracts/src/exec.rs | 8 +-- frame/contracts/src/wasm/runtime.rs | 8 +-- 5 files changed, 42 insertions(+), 44 deletions(-) diff --git a/frame/contracts/fixtures/account_entrance_count_call.wat b/frame/contracts/fixtures/account_entrance_count_call.wat index a50a204ab0a7b..882535be7e2f3 100644 --- a/frame/contracts/fixtures/account_entrance_count_call.wat +++ b/frame/contracts/fixtures/account_entrance_count_call.wat @@ -19,8 +19,8 @@ (func (export "call") (local $account_entrance_count i32) - ;; Reading "callee" contract address (which is the address of the caller) - (call $seal_input (i32.const 0) (i32.const 32)) + ;; Reading "callee" contract address (which is the address of the caller) + (call $seal_input (i32.const 0) (i32.const 32)) (set_local $account_entrance_count (call $seal_account_entrance_count (i32.const 0)) @@ -28,7 +28,7 @@ ;; assert account_entrance_count == 1 (call $assert - (i32.eq (get_local $account_entrance_count) (i32.const 1)) + (i32.eq (get_local $account_entrance_count) (i32.const 1)) ) ) diff --git a/frame/contracts/fixtures/reentrant_count_call.wat b/frame/contracts/fixtures/reentrant_count_call.wat index 3f274975afa36..8aa90213aa37e 100644 --- a/frame/contracts/fixtures/reentrant_count_call.wat +++ b/frame/contracts/fixtures/reentrant_count_call.wat @@ -18,7 +18,7 @@ ) ) (func (export "call") - (local $exit_code i32) + (local $exit_code i32) (local $reentrant_count i32) (set_local $reentrant_count @@ -26,38 +26,38 @@ ) (get_local $reentrant_count) - (if - (then - ;; assert reentrant_count == 1 - (call $assert - (i32.eq (get_local $reentrant_count) (i32.const 1)) - ) - ) - (else - ;; Reading "callee" contract address (which is the address of the caller) - (call $seal_input (i32.const 0) (i32.const 32)) + (if + (then + ;; assert reentrant_count == 1 + (call $assert + (i32.eq (get_local $reentrant_count) (i32.const 1)) + ) + ) + (else + ;; Reading "callee" contract address (which is the address of the caller) + (call $seal_input (i32.const 0) (i32.const 32)) - ;; Call to itself - (set_local $exit_code - (call $seal_call - (i32.const 0) ;; Pointer to "callee" address. - (i32.const 32) ;; Length of "callee" address. - (i64.const 0) ;; How much gas to devote for the execution. 0 = all. - (i32.const 0) ;; Pointer to the buffer with value to transfer - (i32.const 0) ;; Length of the buffer with value to transfer. - (i32.const 0) ;; Pointer to input data buffer address - (i32.const 32) ;; Length of input data buffer - (i32.const 0xffffffff) ;; u32 max sentinel value: do not copy output - (i32.const 0) ;; Ptr to output buffer len - ) - ) + ;; Call to itself + (set_local $exit_code + (call $seal_call + (i32.const 0) ;; Pointer to "callee" address. + (i32.const 32) ;; Length of "callee" address. + (i64.const 0) ;; How much gas to devote for the execution. 0 = all. + (i32.const 0) ;; Pointer to the buffer with value to transfer + (i32.const 0) ;; Length of the buffer with value to transfer. + (i32.const 0) ;; Pointer to input data buffer address + (i32.const 32) ;; Length of input data buffer + (i32.const 0xffffffff) ;; u32 max sentinel value: do not copy output + (i32.const 0) ;; Ptr to output buffer len + ) + ) - ;; assert reentrant_count == 0 - (call $assert - (i32.eq (get_local $reentrant_count) (i32.const 0)) - ) - ) - ) + ;; assert reentrant_count == 0 + (call $assert + (i32.eq (get_local $reentrant_count) (i32.const 0)) + ) + ) + ) ) (func (export "deploy")) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index ec74e27b9c0d5..093e3fca793bc 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -2098,7 +2098,7 @@ benchmarks! { }, ], call_body: Some(body::repeated_dyn(r * API_BENCHMARK_BATCH_SIZE, vec![ - Counter(0 as u32, account_id_len as u32), // account_ptr + Counter(0, account_id_len as u32), // account_ptr Regular(Instruction::Call(0)), Regular(Instruction::Drop), ])), diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 7dc0233750e48..4340035985f1b 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -243,7 +243,7 @@ pub trait Ext: sealing::Sealed { /// Sets new code hash for existing contract. fn set_code_hash(&mut self, hash: CodeHash) -> Result<(), DispatchError>; - /// Returns then number of times currently executing contract exists on the call stack in + /// Returns the number of times the currently executing contract exists on the call stack in /// addition to the calling instance. A value of 0 means no reentrancy. fn reentrant_count(&self) -> u32; @@ -1239,14 +1239,12 @@ where fn reentrant_count(&self) -> u32 { let id: &AccountIdOf = &self.top_frame().account_id; - self.account_entrance_count(id).checked_sub(1).unwrap_or(0) + self.account_entrance_count(id).saturating_sub(1) } fn account_entrance_count(&self, account_id: &AccountIdOf) -> u32 { self.frames() - .filter_map(|f| { - (f.delegate_caller.is_none() && &f.account_id == account_id).then(|| true) - }) + .filter(|f| f.delegate_caller.is_none() && &f.account_id == account_id) .count() as u32 } } diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index ba6122fd4eca1..123ca1868b34d 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -2087,15 +2087,15 @@ define_env!(Env, , } }, - // Returns then number of times currently executing contract exists on the call stack in addition + // Returns the number of times the currently executing contract exists on the call stack in addition // to the calling instance. // // # Return Value // - // Returns 0 when there is no reentrancy + // Returns 0 when there is no reentrancy. [__unstable__] seal_reentrant_count(ctx) -> u32 => { ctx.charge_gas(RuntimeCosts::ReentrantCount)?; - Ok(ctx.ext.reentrant_count() as u32) + Ok(ctx.ext.reentrant_count()) }, // Returns the number of times specified contract exists on the call stack. Delegated calls are @@ -2111,6 +2111,6 @@ define_env!(Env, , [__unstable__] seal_account_entrance_count(ctx, account_ptr: u32) -> u32 => { ctx.charge_gas(RuntimeCosts::AccountEntranceCount)?; let account_id: <::T as frame_system::Config>::AccountId = ctx.read_sandbox_memory_as(account_ptr)?; - Ok(ctx.ext.account_entrance_count(&account_id) as u32) + Ok(ctx.ext.account_entrance_count(&account_id)) }, ); From 3be772e2cfd49e11c1ab87b2d60a639f124ecc7a Mon Sep 17 00:00:00 2001 From: yarikbratashchuk Date: Tue, 21 Jun 2022 18:31:41 +0300 Subject: [PATCH 11/25] Update test for account_entrance_count --- frame/contracts/fixtures/account_entrance_count_call.wat | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frame/contracts/fixtures/account_entrance_count_call.wat b/frame/contracts/fixtures/account_entrance_count_call.wat index 882535be7e2f3..2adc3ba254895 100644 --- a/frame/contracts/fixtures/account_entrance_count_call.wat +++ b/frame/contracts/fixtures/account_entrance_count_call.wat @@ -22,13 +22,14 @@ ;; Reading "callee" contract address (which is the address of the caller) (call $seal_input (i32.const 0) (i32.const 32)) - (set_local $account_entrance_count - (call $seal_account_entrance_count (i32.const 0)) + ;; assert account_entrance_count == 1 + (call $assert + (i32.eq (call $seal_account_entrance_count (i32.const 0)) (i32.const 1)) ) - ;; assert account_entrance_count == 1 + ;; assert account_entrance_count == 0 for another account (call $assert - (i32.eq (get_local $account_entrance_count) (i32.const 1)) + (i32.eq (call $seal_account_entrance_count (i32.const 32)) (i32.const 0)) ) ) From 5fdc1004b0788d8419d532e1bf724adfb7c94409 Mon Sep 17 00:00:00 2001 From: yarikbratashchuk Date: Tue, 21 Jun 2022 19:51:46 +0300 Subject: [PATCH 12/25] Update reentrant_count_call test --- .../fixtures/reentrant_count_call.wat | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/frame/contracts/fixtures/reentrant_count_call.wat b/frame/contracts/fixtures/reentrant_count_call.wat index 8aa90213aa37e..9d41d6f96d69b 100644 --- a/frame/contracts/fixtures/reentrant_count_call.wat +++ b/frame/contracts/fixtures/reentrant_count_call.wat @@ -18,27 +18,25 @@ ) ) (func (export "call") - (local $exit_code i32) + (local $seal_call_exit_code i32) (local $reentrant_count i32) + (local $seen_five_reentrances i32) (set_local $reentrant_count (call $seal_reentrant_count) ) - (get_local $reentrant_count) + (i32.eq (get_local $reentrant_count) (i32.const 5)) (if (then - ;; assert reentrant_count == 1 - (call $assert - (i32.eq (get_local $reentrant_count) (i32.const 1)) - ) + (set_local $seen_five_reentrances (i32.const 1)) ) (else ;; Reading "callee" contract address (which is the address of the caller) (call $seal_input (i32.const 0) (i32.const 32)) ;; Call to itself - (set_local $exit_code + (set_local $seal_call_exit_code (call $seal_call (i32.const 0) ;; Pointer to "callee" address. (i32.const 32) ;; Length of "callee" address. @@ -52,14 +50,26 @@ ) ) - ;; assert reentrant_count == 0 (call $assert - (i32.eq (get_local $reentrant_count) (i32.const 0)) + (i32.eq (get_local $seal_call_exit_code) (i32.const 0)) + ) + ) + ) + + (i32.eq (get_local $seen_five_reentrances) (i32.const 1)) + (if + (then + (call $assert + (i32.eq (get_local $reentrant_count) (i32.const 5)) + ) + ) + (else + (call $assert + (i32.le_s (get_local $reentrant_count) (i32.const 4)) ) ) ) ) (func (export "deploy")) - ) From b656c886d1572f0c67698b4bc8a73ea3e2451ac4 Mon Sep 17 00:00:00 2001 From: yarikbratashchuk Date: Thu, 23 Jun 2022 17:20:13 +0300 Subject: [PATCH 13/25] Delegate call test --- .../reentrant_count_delegated_call.wat | 69 +++++++++++++++++++ frame/contracts/src/tests.rs | 37 ++++++++++ 2 files changed, 106 insertions(+) create mode 100644 frame/contracts/fixtures/reentrant_count_delegated_call.wat diff --git a/frame/contracts/fixtures/reentrant_count_delegated_call.wat b/frame/contracts/fixtures/reentrant_count_delegated_call.wat new file mode 100644 index 0000000000000..76d722469a34a --- /dev/null +++ b/frame/contracts/fixtures/reentrant_count_delegated_call.wat @@ -0,0 +1,69 @@ +(module + (import "seal0" "seal_input" (func $seal_input (param i32 i32))) + (import "seal0" "seal_set_storage" (func $seal_set_storage (param i32 i32 i32))) + (import "seal0" "seal_delegate_call" (func $seal_delegate_call (param i32 i32 i32 i32 i32 i32) (result i32))) + (import "__unstable__" "seal_reentrant_count" (func $seal_reentrant_count (result i32))) + (import "env" "memory" (memory 1 1)) + + ;; [0, 32) buffer where code hash is copied + + ;; [32, 36) buffer for the call stack high + + ;; [36, 40) size of the input buffer + (data (i32.const 36) "\24") + + (func $assert (param i32) + (block $ok + (br_if $ok + (get_local 0) + ) + (unreachable) + ) + ) + (func (export "call") + (local $callstack_high i32) + (local $delegate_call_exit_code i32) + + ;; Reading input + (call $seal_input (i32.const 0) (i32.const 36)) + + ;; reading passed callstack high + (set_local $callstack_high (i32.load (i32.const 32))) + + ;; incrementing callstack high + (i32.store (i32.const 32) (i32.add (i32.load (i32.const 32)) (i32.const 1))) + + ;; reentrance count stays 0 + (call $assert + (i32.eq (call $seal_reentrant_count) (i32.const 0)) + ) + + (i32.eq (get_local $callstack_high) (i32.const 5)) + (if + (then) ;; exit recursion case + (else + ;; Call to itself + (set_local $delegate_call_exit_code + (call $seal_delegate_call + (i32.const 0) ;; Set no call flags + (i32.const 0) ;; Pointer to "callee" code_hash. + (i32.const 0) ;; Input is ingored + (i32.const 36) ;; Length of the input + (i32.const 4294967295) ;; u32 max sentinel value: do not copy output + (i32.const 0) ;; Length is ignored in this case + ) + ) + + (call $assert + (i32.eq (get_local $delegate_call_exit_code) (i32.const 0)) + ) + ) + ) + + (call $assert + (i32.le_s (get_local $callstack_high) (i32.const 5)) + ) + ) + + (func (export "deploy")) +) diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index eb44503c8b6ed..9db43ac5d0aeb 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -3261,6 +3261,43 @@ fn reentrant_count_works_with_call() { .unwrap(); }); } + +#[test] +#[cfg(feature = "unstable-interface")] +fn reentrant_count_works_with_delegated_call() { + let (wasm1, code_hash1) = compile_module::("reentrant_count_delegated_call").unwrap(); + let contract_addr1 = Contracts::contract_address(&ALICE, &code_hash1, &[]); + + ExtBuilder::default().existential_deposit(100).build().execute_with(|| { + let _ = Balances::deposit_creating(&ALICE, 1_000_000); + + assert_ok!(Contracts::instantiate_with_code( + Origin::signed(ALICE), + 300_000, + GAS_LIMIT, + None, + wasm1, + vec![], + vec![], + )); + + let mut input = AsRef::<[u8]>::as_ref(&(code_hash1.clone())).to_vec(); + input.push(1); // adding callstack high to the input + + Contracts::bare_call( + ALICE, + contract_addr1.clone(), + 0, + GAS_LIMIT, + None, + input, + true, + ) + .result + .unwrap(); + }); +} + #[test] #[cfg(feature = "unstable-interface")] fn account_entrance_count_works() { From 17bb81ff9e86453b14eb6c86925e7b9c0ee913a2 Mon Sep 17 00:00:00 2001 From: yarikbratashchuk Date: Fri, 24 Jun 2022 21:01:14 +0300 Subject: [PATCH 14/25] Cargo +nightly fmt --- frame/contracts/src/tests.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 9db43ac5d0aeb..87a887215912b 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -3284,15 +3284,7 @@ fn reentrant_count_works_with_delegated_call() { let mut input = AsRef::<[u8]>::as_ref(&(code_hash1.clone())).to_vec(); input.push(1); // adding callstack high to the input - Contracts::bare_call( - ALICE, - contract_addr1.clone(), - 0, - GAS_LIMIT, - None, - input, - true, - ) + Contracts::bare_call(ALICE, contract_addr1.clone(), 0, GAS_LIMIT, None, input, true) .result .unwrap(); }); From 2f7f40573da2e9c099b7294fe94f414a7552d830 Mon Sep 17 00:00:00 2001 From: yarikbratashchuk Date: Fri, 24 Jun 2022 21:13:30 +0300 Subject: [PATCH 15/25] Address comments --- frame/contracts/src/exec.rs | 2 +- frame/contracts/src/tests.rs | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 4340035985f1b..03abeb96fb2c6 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -247,7 +247,7 @@ pub trait Ext: sealing::Sealed { /// addition to the calling instance. A value of 0 means no reentrancy. fn reentrant_count(&self) -> u32; - /// Returns the number of times specified contract exists on the call stack. Delegated calls are + /// Returns the number of times the specified contract exists on the call stack. Delegated calls are /// not calculated as separate entrance. /// A value of 0 means it does not exist on the call stack. fn account_entrance_count(&self, account_id: &AccountIdOf) -> u32; diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 87a887215912b..54fe8bb35031f 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -3232,8 +3232,8 @@ fn set_code_hash() { #[test] #[cfg(feature = "unstable-interface")] fn reentrant_count_works_with_call() { - let (wasm1, code_hash1) = compile_module::("reentrant_count_call").unwrap(); - let contract_addr1 = Contracts::contract_address(&ALICE, &code_hash1, &[]); + let (wasm, code_hash) = compile_module::("reentrant_count_call").unwrap(); + let contract_addr = Contracts::contract_address(&ALICE, &code_hash, &[]); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { let _ = Balances::deposit_creating(&ALICE, 1_000_000); @@ -3243,18 +3243,18 @@ fn reentrant_count_works_with_call() { 300_000, GAS_LIMIT, None, - wasm1, + wasm, vec![], vec![], )); Contracts::bare_call( ALICE, - contract_addr1.clone(), + contract_addr.clone(), 0, GAS_LIMIT, None, - AsRef::<[u8]>::as_ref(&contract_addr1).to_vec(), + contract_addr.encode(), true, ) .result @@ -3265,8 +3265,8 @@ fn reentrant_count_works_with_call() { #[test] #[cfg(feature = "unstable-interface")] fn reentrant_count_works_with_delegated_call() { - let (wasm1, code_hash1) = compile_module::("reentrant_count_delegated_call").unwrap(); - let contract_addr1 = Contracts::contract_address(&ALICE, &code_hash1, &[]); + let (wasm, code_hash) = compile_module::("reentrant_count_delegated_call").unwrap(); + let contract_addr = Contracts::contract_address(&ALICE, &code_hash, &[]); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { let _ = Balances::deposit_creating(&ALICE, 1_000_000); @@ -3276,15 +3276,15 @@ fn reentrant_count_works_with_delegated_call() { 300_000, GAS_LIMIT, None, - wasm1, + wasm, vec![], vec![], )); - let mut input = AsRef::<[u8]>::as_ref(&(code_hash1.clone())).to_vec(); - input.push(1); // adding callstack high to the input + // adding a callstack height to the input + let input = (code_hash, 1).encode(); - Contracts::bare_call(ALICE, contract_addr1.clone(), 0, GAS_LIMIT, None, input, true) + Contracts::bare_call(ALICE, contract_addr.clone(), 0, GAS_LIMIT, None, input, true) .result .unwrap(); }); @@ -3293,8 +3293,8 @@ fn reentrant_count_works_with_delegated_call() { #[test] #[cfg(feature = "unstable-interface")] fn account_entrance_count_works() { - let (wasm1, code_hash1) = compile_module::("account_entrance_count_call").unwrap(); - let contract_addr1 = Contracts::contract_address(&ALICE, &code_hash1, &[]); + let (wasm, code_hash) = compile_module::("account_entrance_count_call").unwrap(); + let contract_addr = Contracts::contract_address(&ALICE, &code_hash, &[]); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { let _ = Balances::deposit_creating(&ALICE, 1_000_000); @@ -3304,18 +3304,18 @@ fn account_entrance_count_works() { 300_000, GAS_LIMIT, None, - wasm1, + wasm, vec![], vec![], )); Contracts::bare_call( ALICE, - contract_addr1.clone(), + contract_addr.clone(), 0, GAS_LIMIT, None, - AsRef::<[u8]>::as_ref(&contract_addr1).to_vec(), + contract_addr.encode(), true, ) .result From 5f01797140c972c3c0e9ca53bb8b509b111ef962 Mon Sep 17 00:00:00 2001 From: yarikbratashchuk Date: Fri, 24 Jun 2022 21:29:45 +0300 Subject: [PATCH 16/25] Update reentrant_count_works test --- .../fixtures/reentrant_count_call.wat | 48 ++++++++----------- frame/contracts/src/exec.rs | 4 +- frame/contracts/src/tests.rs | 17 +++---- 3 files changed, 28 insertions(+), 41 deletions(-) diff --git a/frame/contracts/fixtures/reentrant_count_call.wat b/frame/contracts/fixtures/reentrant_count_call.wat index 9d41d6f96d69b..9bddac617c594 100644 --- a/frame/contracts/fixtures/reentrant_count_call.wat +++ b/frame/contracts/fixtures/reentrant_count_call.wat @@ -4,10 +4,12 @@ (import "__unstable__" "seal_reentrant_count" (func $seal_reentrant_count (result i32))) (import "env" "memory" (memory 1 1)) - ;; [0, 32) buffer where input is copied + ;; [0, 32) buffer where code hash is copied - ;; [32, 36) size of the input buffer - (data (i32.const 32) "\20") + ;; [32, 36) buffer for the call stack high + + ;; [36, 40) size of the input buffer + (data (i32.const 36) "\24") (func $assert (param i32) (block $ok @@ -18,22 +20,26 @@ ) ) (func (export "call") + (local $manual_reentrant_count i32) (local $seal_call_exit_code i32) - (local $reentrant_count i32) - (local $seen_five_reentrances i32) - (set_local $reentrant_count - (call $seal_reentrant_count) + ;; Reading input + (call $seal_input (i32.const 0) (i32.const 36)) + + ;; reading manually passed reentrant count + (set_local $manual_reentrant_count (i32.load (i32.const 32))) + + ;; reentrance count is calculated correctly + (call $assert + (i32.eq (call $seal_reentrant_count) (get_local $manual_reentrant_count)) ) - (i32.eq (get_local $reentrant_count) (i32.const 5)) + (i32.eq (call $seal_reentrant_count) (i32.const 5)) (if - (then - (set_local $seen_five_reentrances (i32.const 1)) - ) + (then) ;; recursion exit case (else - ;; Reading "callee" contract address (which is the address of the caller) - (call $seal_input (i32.const 0) (i32.const 32)) + ;; incrementing manual reentrant count high + (i32.store (i32.const 32) (i32.add (i32.load (i32.const 32)) (i32.const 1))) ;; Call to itself (set_local $seal_call_exit_code @@ -44,7 +50,7 @@ (i32.const 0) ;; Pointer to the buffer with value to transfer (i32.const 0) ;; Length of the buffer with value to transfer. (i32.const 0) ;; Pointer to input data buffer address - (i32.const 32) ;; Length of input data buffer + (i32.const 36) ;; Length of input data buffer (i32.const 0xffffffff) ;; u32 max sentinel value: do not copy output (i32.const 0) ;; Ptr to output buffer len ) @@ -55,20 +61,6 @@ ) ) ) - - (i32.eq (get_local $seen_five_reentrances) (i32.const 1)) - (if - (then - (call $assert - (i32.eq (get_local $reentrant_count) (i32.const 5)) - ) - ) - (else - (call $assert - (i32.le_s (get_local $reentrant_count) (i32.const 4)) - ) - ) - ) ) (func (export "deploy")) diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 03abeb96fb2c6..3387e9696f63c 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -247,8 +247,8 @@ pub trait Ext: sealing::Sealed { /// addition to the calling instance. A value of 0 means no reentrancy. fn reentrant_count(&self) -> u32; - /// Returns the number of times the specified contract exists on the call stack. Delegated calls are - /// not calculated as separate entrance. + /// Returns the number of times the specified contract exists on the call stack. Delegated calls + /// are not calculated as separate entrance. /// A value of 0 means it does not exist on the call stack. fn account_entrance_count(&self, account_id: &AccountIdOf) -> u32; } diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 54fe8bb35031f..231b71c1bd303 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -3248,17 +3248,12 @@ fn reentrant_count_works_with_call() { vec![], )); - Contracts::bare_call( - ALICE, - contract_addr.clone(), - 0, - GAS_LIMIT, - None, - contract_addr.encode(), - true, - ) - .result - .unwrap(); + // adding reentrant count to the input + let input = (contract_addr.clone(), 0).encode(); + + Contracts::bare_call(ALICE, contract_addr, 0, GAS_LIMIT, None, input, true) + .result + .unwrap(); }); } From 3948142f012968d9f2ca52ef2c87515025d8e22f Mon Sep 17 00:00:00 2001 From: yarikbratashchuk Date: Sun, 3 Jul 2022 14:41:08 +0300 Subject: [PATCH 17/25] Apply weights diff --- frame/contracts/src/weights.rs | 1316 ++++++++++++++++---------------- 1 file changed, 659 insertions(+), 657 deletions(-) diff --git a/frame/contracts/src/weights.rs b/frame/contracts/src/weights.rs index a33060ebf9e08..64c6e008f1184 100644 --- a/frame/contracts/src/weights.rs +++ b/frame/contracts/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for pallet_contracts //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-06-22, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-06-27, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -168,25 +168,25 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: Contracts DeletionQueue (r:1 w:0) fn on_process_deletion_queue_batch() -> Weight { - (1_654_000 as Weight) + (1_665_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `k` is `[0, 1024]`. fn on_initialize_per_trie_key(k: u32, ) -> Weight { - (8_564_000 as Weight) - // Standard Error: 0 - .saturating_add((868_000 as Weight).saturating_mul(k as Weight)) + (7_439_000 as Weight) + // Standard Error: 1_000 + .saturating_add((876_000 as Weight).saturating_mul(k as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) } // Storage: Contracts DeletionQueue (r:1 w:0) - /// The range of component `q` is `[0, 1024]`. + /// The range of component `q` is `[0, 128]`. fn on_initialize_per_queue_item(q: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 5_000 - .saturating_add((1_944_000 as Weight).saturating_mul(q as Weight)) + (8_035_000 as Weight) + // Standard Error: 4_000 + .saturating_add((2_010_000 as Weight).saturating_mul(q as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -194,9 +194,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Contracts CodeStorage (r:0 w:1) /// The range of component `c` is `[0, 64226]`. fn reinstrument(c: u32, ) -> Weight { - (19_016_000 as Weight) + (24_769_000 as Weight) // Standard Error: 0 - .saturating_add((49_000 as Weight).saturating_mul(c as Weight)) + .saturating_add((46_000 as Weight).saturating_mul(c as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -206,9 +206,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) /// The range of component `c` is `[0, 131072]`. fn call_with_code_per_byte(c: u32, ) -> Weight { - (205_194_000 as Weight) + (307_066_000 as Weight) // Standard Error: 0 - .saturating_add((53_000 as Weight).saturating_mul(c as Weight)) + .saturating_add((48_000 as Weight).saturating_mul(c as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } @@ -222,9 +222,9 @@ impl WeightInfo for SubstrateWeight { /// The range of component `c` is `[0, 64226]`. /// The range of component `s` is `[0, 1048576]`. fn instantiate_with_code(c: u32, s: u32, ) -> Weight { - (288_487_000 as Weight) + (334_738_000 as Weight) // Standard Error: 0 - .saturating_add((124_000 as Weight).saturating_mul(c as Weight)) + .saturating_add((113_000 as Weight).saturating_mul(c as Weight)) // Standard Error: 0 .saturating_add((2_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) @@ -238,7 +238,7 @@ impl WeightInfo for SubstrateWeight { // Storage: Contracts OwnerInfoOf (r:1 w:1) /// The range of component `s` is `[0, 1048576]`. fn instantiate(s: u32, ) -> Weight { - (186_136_000 as Weight) + (232_347_000 as Weight) // Standard Error: 0 .saturating_add((2_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(6 as Weight)) @@ -249,7 +249,7 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) // Storage: System Account (r:1 w:1) fn call() -> Weight { - (149_232_000 as Weight) + (203_390_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } @@ -258,9 +258,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Contracts OwnerInfoOf (r:0 w:1) /// The range of component `c` is `[0, 64226]`. fn upload_code(c: u32, ) -> Weight { - (51_721_000 as Weight) + (122_035_000 as Weight) // Standard Error: 0 - .saturating_add((48_000 as Weight).saturating_mul(c as Weight)) + .saturating_add((46_000 as Weight).saturating_mul(c as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -268,14 +268,14 @@ impl WeightInfo for SubstrateWeight { // Storage: Contracts CodeStorage (r:0 w:1) // Storage: Contracts PristineCode (r:0 w:1) fn remove_code() -> Weight { - (30_016_000 as Weight) + (30_759_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } // Storage: Contracts ContractInfoOf (r:1 w:1) // Storage: Contracts OwnerInfoOf (r:2 w:2) fn set_code() -> Weight { - (27_192_000 as Weight) + (27_740_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -285,9 +285,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_caller(r: u32, ) -> Weight { - (206_405_000 as Weight) - // Standard Error: 112_000 - .saturating_add((40_987_000 as Weight).saturating_mul(r as Weight)) + (312_024_000 as Weight) + // Standard Error: 137_000 + .saturating_add((37_587_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -297,9 +297,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_is_contract(r: u32, ) -> Weight { - (106_220_000 as Weight) - // Standard Error: 710_000 - .saturating_add((307_648_000 as Weight).saturating_mul(r as Weight)) + (223_437_000 as Weight) + // Standard Error: 699_000 + .saturating_add((305_422_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -310,9 +310,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_code_hash(r: u32, ) -> Weight { - (104_498_000 as Weight) - // Standard Error: 633_000 - .saturating_add((368_901_000 as Weight).saturating_mul(r as Weight)) + (197_616_000 as Weight) + // Standard Error: 724_000 + .saturating_add((363_712_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -323,9 +323,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_own_code_hash(r: u32, ) -> Weight { - (208_696_000 as Weight) - // Standard Error: 101_000 - .saturating_add((44_445_000 as Weight).saturating_mul(r as Weight)) + (306_664_000 as Weight) + // Standard Error: 123_000 + .saturating_add((41_149_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -335,9 +335,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_caller_is_origin(r: u32, ) -> Weight { - (205_612_000 as Weight) - // Standard Error: 68_000 - .saturating_add((17_145_000 as Weight).saturating_mul(r as Weight)) + (302_772_000 as Weight) + // Standard Error: 70_000 + .saturating_add((15_501_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -347,9 +347,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_address(r: u32, ) -> Weight { - (206_947_000 as Weight) - // Standard Error: 107_000 - .saturating_add((40_789_000 as Weight).saturating_mul(r as Weight)) + (305_370_000 as Weight) + // Standard Error: 124_000 + .saturating_add((37_824_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -359,9 +359,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_gas_left(r: u32, ) -> Weight { - (208_692_000 as Weight) - // Standard Error: 109_000 - .saturating_add((40_600_000 as Weight).saturating_mul(r as Weight)) + (307_568_000 as Weight) + // Standard Error: 114_000 + .saturating_add((37_076_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -371,9 +371,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_balance(r: u32, ) -> Weight { - (209_811_000 as Weight) - // Standard Error: 208_000 - .saturating_add((116_831_000 as Weight).saturating_mul(r as Weight)) + (312_135_000 as Weight) + // Standard Error: 173_000 + .saturating_add((109_819_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -383,9 +383,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_value_transferred(r: u32, ) -> Weight { - (207_406_000 as Weight) - // Standard Error: 117_000 - .saturating_add((40_702_000 as Weight).saturating_mul(r as Weight)) + (305_419_000 as Weight) + // Standard Error: 122_000 + .saturating_add((37_599_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -395,9 +395,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_minimum_balance(r: u32, ) -> Weight { - (209_260_000 as Weight) - // Standard Error: 130_000 - .saturating_add((40_479_000 as Weight).saturating_mul(r as Weight)) + (313_057_000 as Weight) + // Standard Error: 123_000 + .saturating_add((36_935_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -407,9 +407,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_block_number(r: u32, ) -> Weight { - (206_448_000 as Weight) - // Standard Error: 95_000 - .saturating_add((40_134_000 as Weight).saturating_mul(r as Weight)) + (305_779_000 as Weight) + // Standard Error: 126_000 + .saturating_add((37_402_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -419,9 +419,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_now(r: u32, ) -> Weight { - (206_969_000 as Weight) - // Standard Error: 116_000 - .saturating_add((40_251_000 as Weight).saturating_mul(r as Weight)) + (308_311_000 as Weight) + // Standard Error: 125_000 + .saturating_add((37_223_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -432,9 +432,9 @@ impl WeightInfo for SubstrateWeight { // Storage: TransactionPayment NextFeeMultiplier (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_weight_to_fee(r: u32, ) -> Weight { - (211_611_000 as Weight) - // Standard Error: 175_000 - .saturating_add((98_675_000 as Weight).saturating_mul(r as Weight)) + (311_111_000 as Weight) + // Standard Error: 152_000 + .saturating_add((96_086_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -444,9 +444,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_gas(r: u32, ) -> Weight { - (134_484_000 as Weight) - // Standard Error: 57_000 - .saturating_add((19_329_000 as Weight).saturating_mul(r as Weight)) + (184_347_000 as Weight) + // Standard Error: 59_000 + .saturating_add((18_312_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -456,9 +456,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_input(r: u32, ) -> Weight { - (208_556_000 as Weight) - // Standard Error: 125_000 - .saturating_add((40_328_000 as Weight).saturating_mul(r as Weight)) + (310_352_000 as Weight) + // Standard Error: 116_000 + .saturating_add((36_210_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -468,9 +468,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `n` is `[0, 1024]`. fn seal_input_per_kb(n: u32, ) -> Weight { - (268_886_000 as Weight) - // Standard Error: 4_000 - .saturating_add((9_627_000 as Weight).saturating_mul(n as Weight)) + (369_486_000 as Weight) + // Standard Error: 3_000 + .saturating_add((9_684_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -480,7 +480,7 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 1]`. fn seal_return(_r: u32, ) -> Weight { - (203_591_000 as Weight) + (301_862_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -490,9 +490,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `n` is `[0, 1024]`. fn seal_return_per_kb(n: u32, ) -> Weight { - (204_258_000 as Weight) - // Standard Error: 0 - .saturating_add((183_000 as Weight).saturating_mul(n as Weight)) + (301_951_000 as Weight) + // Standard Error: 1_000 + .saturating_add((234_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -504,9 +504,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Contracts OwnerInfoOf (r:1 w:1) /// The range of component `r` is `[0, 1]`. fn seal_terminate(r: u32, ) -> Weight { - (206_625_000 as Weight) - // Standard Error: 672_000 - .saturating_add((59_377_000 as Weight).saturating_mul(r as Weight)) + (315_003_000 as Weight) + // Standard Error: 3_372_000 + .saturating_add((45_783_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -519,9 +519,9 @@ impl WeightInfo for SubstrateWeight { // Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_random(r: u32, ) -> Weight { - (208_866_000 as Weight) - // Standard Error: 164_000 - .saturating_add((133_438_000 as Weight).saturating_mul(r as Weight)) + (313_986_000 as Weight) + // Standard Error: 184_000 + .saturating_add((126_360_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -531,9 +531,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_deposit_event(r: u32, ) -> Weight { - (220_860_000 as Weight) - // Standard Error: 209_000 - .saturating_add((239_951_000 as Weight).saturating_mul(r as Weight)) + (330_772_000 as Weight) + // Standard Error: 250_000 + .saturating_add((231_786_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -545,11 +545,11 @@ impl WeightInfo for SubstrateWeight { /// The range of component `t` is `[0, 4]`. /// The range of component `n` is `[0, 16]`. fn seal_deposit_event_per_topic_and_kb(t: u32, n: u32, ) -> Weight { - (439_782_000 as Weight) - // Standard Error: 1_643_000 - .saturating_add((264_687_000 as Weight).saturating_mul(t as Weight)) - // Standard Error: 323_000 - .saturating_add((67_636_000 as Weight).saturating_mul(n as Weight)) + (536_159_000 as Weight) + // Standard Error: 1_631_000 + .saturating_add((263_688_000 as Weight).saturating_mul(t as Weight)) + // Standard Error: 321_000 + .saturating_add((73_828_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads((80 as Weight).saturating_mul(t as Weight))) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -561,18 +561,18 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_debug_message(r: u32, ) -> Weight { - (140_280_000 as Weight) - // Standard Error: 82_000 - .saturating_add((32_717_000 as Weight).saturating_mul(r as Weight)) + (193_290_000 as Weight) + // Standard Error: 102_000 + .saturating_add((29_884_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_set_storage(r: u32, ) -> Weight { - (161_247_000 as Weight) - // Standard Error: 883_000 - .saturating_add((423_997_000 as Weight).saturating_mul(r as Weight)) + (257_650_000 as Weight) + // Standard Error: 928_000 + .saturating_add((420_511_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -581,9 +581,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_set_storage_per_new_kb(n: u32, ) -> Weight { - (529_247_000 as Weight) - // Standard Error: 2_745_000 - .saturating_add((85_282_000 as Weight).saturating_mul(n as Weight)) + (629_319_000 as Weight) + // Standard Error: 2_729_000 + .saturating_add((94_316_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(55 as Weight)) .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(53 as Weight)) @@ -592,9 +592,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_set_storage_per_old_kb(n: u32, ) -> Weight { - (529_812_000 as Weight) - // Standard Error: 2_513_000 - .saturating_add((74_554_000 as Weight).saturating_mul(n as Weight)) + (623_463_000 as Weight) + // Standard Error: 2_719_000 + .saturating_add((76_192_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(55 as Weight)) .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(53 as Weight)) @@ -603,9 +603,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_clear_storage(r: u32, ) -> Weight { - (184_803_000 as Weight) - // Standard Error: 733_000 - .saturating_add((404_933_000 as Weight).saturating_mul(r as Weight)) + (285_077_000 as Weight) + // Standard Error: 774_000 + .saturating_add((403_199_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) @@ -614,9 +614,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_clear_storage_per_kb(n: u32, ) -> Weight { - (500_958_000 as Weight) - // Standard Error: 2_980_000 - .saturating_add((75_996_000 as Weight).saturating_mul(n as Weight)) + (600_845_000 as Weight) + // Standard Error: 3_055_000 + .saturating_add((76_629_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(55 as Weight)) .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(52 as Weight)) @@ -625,9 +625,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_get_storage(r: u32, ) -> Weight { - (177_682_000 as Weight) - // Standard Error: 743_000 - .saturating_add((338_172_000 as Weight).saturating_mul(r as Weight)) + (273_626_000 as Weight) + // Standard Error: 625_000 + .saturating_add((339_186_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -635,9 +635,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_get_storage_per_kb(n: u32, ) -> Weight { - (465_285_000 as Weight) - // Standard Error: 2_599_000 - .saturating_add((155_106_000 as Weight).saturating_mul(n as Weight)) + (553_849_000 as Weight) + // Standard Error: 2_339_000 + .saturating_add((171_830_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(55 as Weight)) .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -645,9 +645,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_contains_storage(r: u32, ) -> Weight { - (179_118_000 as Weight) - // Standard Error: 572_000 - .saturating_add((311_083_000 as Weight).saturating_mul(r as Weight)) + (288_011_000 as Weight) + // Standard Error: 792_000 + .saturating_add((310_449_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -655,9 +655,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_contains_storage_per_kb(n: u32, ) -> Weight { - (423_056_000 as Weight) - // Standard Error: 2_037_000 - .saturating_add((69_665_000 as Weight).saturating_mul(n as Weight)) + (527_433_000 as Weight) + // Standard Error: 2_095_000 + .saturating_add((69_425_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(54 as Weight)) .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -665,9 +665,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_take_storage(r: u32, ) -> Weight { - (188_884_000 as Weight) - // Standard Error: 761_000 - .saturating_add((432_781_000 as Weight).saturating_mul(r as Weight)) + (284_675_000 as Weight) + // Standard Error: 713_000 + .saturating_add((432_314_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) @@ -676,9 +676,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_take_storage_per_kb(n: u32, ) -> Weight { - (532_408_000 as Weight) - // Standard Error: 3_348_000 - .saturating_add((164_943_000 as Weight).saturating_mul(n as Weight)) + (629_648_000 as Weight) + // Standard Error: 3_390_000 + .saturating_add((179_401_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(55 as Weight)) .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(53 as Weight)) @@ -690,9 +690,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_transfer(r: u32, ) -> Weight { - (127_181_000 as Weight) - // Standard Error: 1_495_000 - .saturating_add((1_500_589_000 as Weight).saturating_mul(r as Weight)) + (275_243_000 as Weight) + // Standard Error: 1_039_000 + .saturating_add((1_473_158_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) @@ -705,8 +705,8 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_call(r: u32, ) -> Weight { (0 as Weight) - // Standard Error: 3_803_000 - .saturating_add((14_860_909_000 as Weight).saturating_mul(r as Weight)) + // Standard Error: 3_670_000 + .saturating_add((22_820_146_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(1 as Weight)) @@ -719,8 +719,8 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_delegate_call(r: u32, ) -> Weight { (0 as Weight) - // Standard Error: 6_045_000 - .saturating_add((14_797_140_000 as Weight).saturating_mul(r as Weight)) + // Standard Error: 6_224_000 + .saturating_add((22_854_789_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads((79 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -731,11 +731,11 @@ impl WeightInfo for SubstrateWeight { /// The range of component `t` is `[0, 1]`. /// The range of component `c` is `[0, 1024]`. fn seal_call_per_transfer_clone_kb(t: u32, c: u32, ) -> Weight { - (9_196_444_000 as Weight) - // Standard Error: 20_486_000 - .saturating_add((1_458_153_000 as Weight).saturating_mul(t as Weight)) - // Standard Error: 8_000 - .saturating_add((9_718_000 as Weight).saturating_mul(c as Weight)) + (13_257_977_000 as Weight) + // Standard Error: 24_879_000 + .saturating_add((1_386_682_000 as Weight).saturating_mul(t as Weight)) + // Standard Error: 10_000 + .saturating_add((9_781_000 as Weight).saturating_mul(c as Weight)) .saturating_add(T::DbWeight::get().reads(85 as Weight)) .saturating_add(T::DbWeight::get().reads((81 as Weight).saturating_mul(t as Weight))) .saturating_add(T::DbWeight::get().writes(81 as Weight)) @@ -750,8 +750,8 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_instantiate(r: u32, ) -> Weight { (0 as Weight) - // Standard Error: 36_253_000 - .saturating_add((21_201_529_000 as Weight).saturating_mul(r as Weight)) + // Standard Error: 36_682_000 + .saturating_add((29_115_109_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().reads((320 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes(3 as Weight)) @@ -766,11 +766,11 @@ impl WeightInfo for SubstrateWeight { /// The range of component `t` is `[0, 1]`. /// The range of component `s` is `[0, 960]`. fn seal_instantiate_per_transfer_salt_kb(t: u32, s: u32, ) -> Weight { - (12_282_498_000 as Weight) - // Standard Error: 48_112_000 - .saturating_add((720_795_000 as Weight).saturating_mul(t as Weight)) - // Standard Error: 22_000 - .saturating_add((124_274_000 as Weight).saturating_mul(s as Weight)) + (16_336_857_000 as Weight) + // Standard Error: 58_313_000 + .saturating_add((689_612_000 as Weight).saturating_mul(t as Weight)) + // Standard Error: 27_000 + .saturating_add((128_264_000 as Weight).saturating_mul(s as Weight)) .saturating_add(T::DbWeight::get().reads(167 as Weight)) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(t as Weight))) .saturating_add(T::DbWeight::get().writes(165 as Weight)) @@ -782,9 +782,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_hash_sha2_256(r: u32, ) -> Weight { - (203_959_000 as Weight) - // Standard Error: 142_000 - .saturating_add((61_311_000 as Weight).saturating_mul(r as Weight)) + (301_670_000 as Weight) + // Standard Error: 144_000 + .saturating_add((59_019_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -794,9 +794,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `n` is `[0, 1024]`. fn seal_hash_sha2_256_per_kb(n: u32, ) -> Weight { - (349_915_000 as Weight) - // Standard Error: 40_000 - .saturating_add((320_652_000 as Weight).saturating_mul(n as Weight)) + (344_105_000 as Weight) + // Standard Error: 32_000 + .saturating_add((326_196_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -806,9 +806,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_hash_keccak_256(r: u32, ) -> Weight { - (209_219_000 as Weight) - // Standard Error: 157_000 - .saturating_add((73_728_000 as Weight).saturating_mul(r as Weight)) + (302_729_000 as Weight) + // Standard Error: 134_000 + .saturating_add((71_001_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -818,9 +818,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `n` is `[0, 1024]`. fn seal_hash_keccak_256_per_kb(n: u32, ) -> Weight { - (208_860_000 as Weight) - // Standard Error: 25_000 - .saturating_add((245_718_000 as Weight).saturating_mul(n as Weight)) + (320_537_000 as Weight) + // Standard Error: 31_000 + .saturating_add((249_717_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -830,9 +830,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_hash_blake2_256(r: u32, ) -> Weight { - (206_165_000 as Weight) - // Standard Error: 138_000 - .saturating_add((51_644_000 as Weight).saturating_mul(r as Weight)) + (303_794_000 as Weight) + // Standard Error: 136_000 + .saturating_add((49_006_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -842,9 +842,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `n` is `[0, 1024]`. fn seal_hash_blake2_256_per_kb(n: u32, ) -> Weight { - (255_955_000 as Weight) - // Standard Error: 14_000 - .saturating_add((95_090_000 as Weight).saturating_mul(n as Weight)) + (392_854_000 as Weight) + // Standard Error: 16_000 + .saturating_add((98_867_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -854,9 +854,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_hash_blake2_128(r: u32, ) -> Weight { - (208_153_000 as Weight) - // Standard Error: 140_000 - .saturating_add((51_264_000 as Weight).saturating_mul(r as Weight)) + (302_356_000 as Weight) + // Standard Error: 131_000 + .saturating_add((48_825_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -866,9 +866,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `n` is `[0, 1024]`. fn seal_hash_blake2_128_per_kb(n: u32, ) -> Weight { - (278_368_000 as Weight) - // Standard Error: 14_000 - .saturating_add((95_006_000 as Weight).saturating_mul(n as Weight)) + (430_384_000 as Weight) + // Standard Error: 20_000 + .saturating_add((98_855_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -878,9 +878,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_ecdsa_recover(r: u32, ) -> Weight { - (331_955_000 as Weight) - // Standard Error: 1_155_000 - .saturating_add((3_069_955_000 as Weight).saturating_mul(r as Weight)) + (459_616_000 as Weight) + // Standard Error: 1_003_000 + .saturating_add((3_064_299_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -890,9 +890,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight { - (207_838_000 as Weight) - // Standard Error: 783_000 - .saturating_add((2_058_503_000 as Weight).saturating_mul(r as Weight)) + (326_960_000 as Weight) + // Standard Error: 1_238_000 + .saturating_add((2_095_205_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -904,8 +904,8 @@ impl WeightInfo for SubstrateWeight { /// The range of component `r` is `[0, 20]`. fn seal_set_code_hash(r: u32, ) -> Weight { (0 as Weight) - // Standard Error: 1_567_000 - .saturating_add((774_380_000 as Weight).saturating_mul(r as Weight)) + // Standard Error: 1_677_000 + .saturating_add((773_112_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads((79 as Weight).saturating_mul(r as Weight))) .saturating_add(T::DbWeight::get().writes((79 as Weight).saturating_mul(r as Weight))) } @@ -913,330 +913,331 @@ impl WeightInfo for SubstrateWeight { // Storage: Contracts ContractInfoOf (r:1 w:1) // Storage: Contracts CodeStorage (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) - // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1) + /// The range of component `r` is `[0, 20]`. fn seal_reentrant_count(r: u32, ) -> Weight { - (91_522_000 as Weight) - // Standard Error: 50_000 - .saturating_add((24_064_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + (304_709_000 as Weight) + // Standard Error: 67_000 + .saturating_add((15_411_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(T::DbWeight::get().reads(4 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) // Storage: Contracts CodeStorage (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) + /// The range of component `r` is `[0, 20]`. fn seal_account_entrance_count(r: u32, ) -> Weight { - (179_313_000 as Weight) - // Standard Error: 610_000 - .saturating_add((63_085_000 as Weight).saturating_mul(r as Weight)) + (328_378_000 as Weight) + // Standard Error: 137_000 + .saturating_add((37_448_000 as Weight).saturating_mul(r as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64const(r: u32, ) -> Weight { - (73_955_000 as Weight) - // Standard Error: 1_000 - .saturating_add((612_000 as Weight).saturating_mul(r as Weight)) + (119_063_000 as Weight) + // Standard Error: 4_000 + .saturating_add((839_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64load(r: u32, ) -> Weight { - (74_057_000 as Weight) - // Standard Error: 3_000 - .saturating_add((1_324_000 as Weight).saturating_mul(r as Weight)) + (118_393_000 as Weight) + // Standard Error: 5_000 + .saturating_add((1_858_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64store(r: u32, ) -> Weight { - (74_137_000 as Weight) - // Standard Error: 5_000 - .saturating_add((1_427_000 as Weight).saturating_mul(r as Weight)) + (119_672_000 as Weight) + // Standard Error: 4_000 + .saturating_add((2_235_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_select(r: u32, ) -> Weight { - (73_844_000 as Weight) - // Standard Error: 1_000 - .saturating_add((1_773_000 as Weight).saturating_mul(r as Weight)) + (118_560_000 as Weight) + // Standard Error: 4_000 + .saturating_add((2_320_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_if(r: u32, ) -> Weight { - (73_979_000 as Weight) - // Standard Error: 3_000 - .saturating_add((1_952_000 as Weight).saturating_mul(r as Weight)) + (118_387_000 as Weight) + // Standard Error: 5_000 + .saturating_add((2_467_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_br(r: u32, ) -> Weight { - (73_924_000 as Weight) - // Standard Error: 3_000 - .saturating_add((941_000 as Weight).saturating_mul(r as Weight)) + (118_878_000 as Weight) + // Standard Error: 4_000 + .saturating_add((1_271_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_br_if(r: u32, ) -> Weight { - (73_574_000 as Weight) - // Standard Error: 5_000 - .saturating_add((1_439_000 as Weight).saturating_mul(r as Weight)) + (118_145_000 as Weight) + // Standard Error: 4_000 + .saturating_add((1_847_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_br_table(r: u32, ) -> Weight { - (73_343_000 as Weight) - // Standard Error: 3_000 - .saturating_add((1_603_000 as Weight).saturating_mul(r as Weight)) + (118_201_000 as Weight) + // Standard Error: 8_000 + .saturating_add((2_071_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `e` is `[1, 256]`. fn instr_br_table_per_entry(e: u32, ) -> Weight { - (76_267_000 as Weight) + (121_244_000 as Weight) // Standard Error: 0 - .saturating_add((4_000 as Weight).saturating_mul(e as Weight)) + .saturating_add((5_000 as Weight).saturating_mul(e as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_call(r: u32, ) -> Weight { - (74_877_000 as Weight) + (120_143_000 as Weight) // Standard Error: 12_000 - .saturating_add((7_144_000 as Weight).saturating_mul(r as Weight)) + .saturating_add((6_437_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_call_indirect(r: u32, ) -> Weight { - (88_665_000 as Weight) - // Standard Error: 20_000 - .saturating_add((9_142_000 as Weight).saturating_mul(r as Weight)) + (132_114_000 as Weight) + // Standard Error: 14_000 + .saturating_add((8_275_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `p` is `[0, 128]`. fn instr_call_indirect_per_param(p: u32, ) -> Weight { - (98_600_000 as Weight) + (141_495_000 as Weight) // Standard Error: 2_000 - .saturating_add((469_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((599_000 as Weight).saturating_mul(p as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_local_get(r: u32, ) -> Weight { - (74_555_000 as Weight) - // Standard Error: 1_000 - .saturating_add((624_000 as Weight).saturating_mul(r as Weight)) + (119_733_000 as Weight) + // Standard Error: 2_000 + .saturating_add((859_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_local_set(r: u32, ) -> Weight { - (74_329_000 as Weight) - // Standard Error: 1_000 - .saturating_add((688_000 as Weight).saturating_mul(r as Weight)) + (118_913_000 as Weight) + // Standard Error: 2_000 + .saturating_add((913_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_local_tee(r: u32, ) -> Weight { - (74_612_000 as Weight) - // Standard Error: 1_000 - .saturating_add((909_000 as Weight).saturating_mul(r as Weight)) + (118_812_000 as Weight) + // Standard Error: 9_000 + .saturating_add((1_248_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_global_get(r: u32, ) -> Weight { - (76_906_000 as Weight) - // Standard Error: 1_000 - .saturating_add((1_192_000 as Weight).saturating_mul(r as Weight)) + (122_692_000 as Weight) + // Standard Error: 4_000 + .saturating_add((1_422_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_global_set(r: u32, ) -> Weight { - (76_979_000 as Weight) + (121_141_000 as Weight) // Standard Error: 2_000 - .saturating_add((1_361_000 as Weight).saturating_mul(r as Weight)) + .saturating_add((1_653_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_memory_current(r: u32, ) -> Weight { - (74_370_000 as Weight) - // Standard Error: 3_000 - .saturating_add((661_000 as Weight).saturating_mul(r as Weight)) + (118_469_000 as Weight) + // Standard Error: 2_000 + .saturating_add((900_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 1]`. fn instr_memory_grow(r: u32, ) -> Weight { - (73_584_000 as Weight) - // Standard Error: 353_000 - .saturating_add((187_114_000 as Weight).saturating_mul(r as Weight)) + (120_650_000 as Weight) + // Standard Error: 20_000 + .saturating_add((227_328_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64clz(r: u32, ) -> Weight { - (74_206_000 as Weight) - // Standard Error: 1_000 - .saturating_add((884_000 as Weight).saturating_mul(r as Weight)) + (118_529_000 as Weight) + // Standard Error: 3_000 + .saturating_add((1_318_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64ctz(r: u32, ) -> Weight { - (73_992_000 as Weight) - // Standard Error: 1_000 - .saturating_add((893_000 as Weight).saturating_mul(r as Weight)) + (118_600_000 as Weight) + // Standard Error: 6_000 + .saturating_add((1_320_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64popcnt(r: u32, ) -> Weight { - (73_985_000 as Weight) - // Standard Error: 2_000 - .saturating_add((891_000 as Weight).saturating_mul(r as Weight)) + (118_719_000 as Weight) + // Standard Error: 6_000 + .saturating_add((1_320_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64eqz(r: u32, ) -> Weight { - (74_117_000 as Weight) - // Standard Error: 4_000 - .saturating_add((901_000 as Weight).saturating_mul(r as Weight)) + (117_810_000 as Weight) + // Standard Error: 8_000 + .saturating_add((1_354_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64extendsi32(r: u32, ) -> Weight { - (73_981_000 as Weight) - // Standard Error: 1_000 - .saturating_add((866_000 as Weight).saturating_mul(r as Weight)) + (118_701_000 as Weight) + // Standard Error: 3_000 + .saturating_add((1_287_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64extendui32(r: u32, ) -> Weight { - (74_104_000 as Weight) + (119_074_000 as Weight) // Standard Error: 3_000 - .saturating_add((868_000 as Weight).saturating_mul(r as Weight)) + .saturating_add((1_273_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i32wrapi64(r: u32, ) -> Weight { - (74_293_000 as Weight) - // Standard Error: 3_000 - .saturating_add((878_000 as Weight).saturating_mul(r as Weight)) + (118_939_000 as Weight) + // Standard Error: 6_000 + .saturating_add((1_324_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64eq(r: u32, ) -> Weight { - (74_055_000 as Weight) - // Standard Error: 2_000 - .saturating_add((1_350_000 as Weight).saturating_mul(r as Weight)) + (118_492_000 as Weight) + // Standard Error: 3_000 + .saturating_add((1_830_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64ne(r: u32, ) -> Weight { - (73_710_000 as Weight) - // Standard Error: 2_000 - .saturating_add((1_360_000 as Weight).saturating_mul(r as Weight)) + (118_708_000 as Weight) + // Standard Error: 6_000 + .saturating_add((1_814_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64lts(r: u32, ) -> Weight { - (73_917_000 as Weight) - // Standard Error: 1_000 - .saturating_add((1_355_000 as Weight).saturating_mul(r as Weight)) + (118_355_000 as Weight) + // Standard Error: 4_000 + .saturating_add((1_832_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64ltu(r: u32, ) -> Weight { - (74_048_000 as Weight) - // Standard Error: 1_000 - .saturating_add((1_360_000 as Weight).saturating_mul(r as Weight)) + (118_636_000 as Weight) + // Standard Error: 4_000 + .saturating_add((1_821_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64gts(r: u32, ) -> Weight { - (74_029_000 as Weight) - // Standard Error: 2_000 - .saturating_add((1_349_000 as Weight).saturating_mul(r as Weight)) + (119_080_000 as Weight) + // Standard Error: 5_000 + .saturating_add((1_809_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64gtu(r: u32, ) -> Weight { - (74_267_000 as Weight) - // Standard Error: 2_000 - .saturating_add((1_353_000 as Weight).saturating_mul(r as Weight)) + (118_676_000 as Weight) + // Standard Error: 3_000 + .saturating_add((1_837_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64les(r: u32, ) -> Weight { - (73_952_000 as Weight) - // Standard Error: 1_000 - .saturating_add((1_350_000 as Weight).saturating_mul(r as Weight)) + (118_613_000 as Weight) + // Standard Error: 4_000 + .saturating_add((1_819_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64leu(r: u32, ) -> Weight { - (73_851_000 as Weight) + (118_453_000 as Weight) // Standard Error: 2_000 - .saturating_add((1_368_000 as Weight).saturating_mul(r as Weight)) + .saturating_add((1_842_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64ges(r: u32, ) -> Weight { - (74_034_000 as Weight) - // Standard Error: 2_000 - .saturating_add((1_348_000 as Weight).saturating_mul(r as Weight)) + (118_272_000 as Weight) + // Standard Error: 6_000 + .saturating_add((1_847_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64geu(r: u32, ) -> Weight { - (73_979_000 as Weight) - // Standard Error: 3_000 - .saturating_add((1_353_000 as Weight).saturating_mul(r as Weight)) + (118_619_000 as Weight) + // Standard Error: 8_000 + .saturating_add((1_837_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64add(r: u32, ) -> Weight { - (74_000_000 as Weight) - // Standard Error: 1_000 - .saturating_add((1_328_000 as Weight).saturating_mul(r as Weight)) + (119_428_000 as Weight) + // Standard Error: 53_000 + .saturating_add((2_287_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64sub(r: u32, ) -> Weight { - (73_883_000 as Weight) - // Standard Error: 1_000 - .saturating_add((1_331_000 as Weight).saturating_mul(r as Weight)) + (118_630_000 as Weight) + // Standard Error: 4_000 + .saturating_add((1_823_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64mul(r: u32, ) -> Weight { - (74_216_000 as Weight) - // Standard Error: 5_000 - .saturating_add((1_324_000 as Weight).saturating_mul(r as Weight)) + (118_636_000 as Weight) + // Standard Error: 3_000 + .saturating_add((1_835_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64divs(r: u32, ) -> Weight { - (73_989_000 as Weight) - // Standard Error: 1_000 - .saturating_add((1_998_000 as Weight).saturating_mul(r as Weight)) + (118_313_000 as Weight) + // Standard Error: 4_000 + .saturating_add((2_469_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64divu(r: u32, ) -> Weight { - (73_857_000 as Weight) - // Standard Error: 4_000 - .saturating_add((2_073_000 as Weight).saturating_mul(r as Weight)) + (118_550_000 as Weight) + // Standard Error: 3_000 + .saturating_add((2_438_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64rems(r: u32, ) -> Weight { - (73_801_000 as Weight) - // Standard Error: 1_000 - .saturating_add((2_027_000 as Weight).saturating_mul(r as Weight)) + (118_464_000 as Weight) + // Standard Error: 5_000 + .saturating_add((2_464_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64remu(r: u32, ) -> Weight { - (74_130_000 as Weight) - // Standard Error: 1_000 - .saturating_add((2_064_000 as Weight).saturating_mul(r as Weight)) + (118_254_000 as Weight) + // Standard Error: 8_000 + .saturating_add((2_453_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64and(r: u32, ) -> Weight { - (74_071_000 as Weight) - // Standard Error: 1_000 - .saturating_add((1_327_000 as Weight).saturating_mul(r as Weight)) + (118_620_000 as Weight) + // Standard Error: 4_000 + .saturating_add((1_835_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64or(r: u32, ) -> Weight { - (74_201_000 as Weight) - // Standard Error: 4_000 - .saturating_add((1_330_000 as Weight).saturating_mul(r as Weight)) + (118_596_000 as Weight) + // Standard Error: 6_000 + .saturating_add((1_845_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64xor(r: u32, ) -> Weight { - (74_241_000 as Weight) - // Standard Error: 1_000 - .saturating_add((1_321_000 as Weight).saturating_mul(r as Weight)) + (118_814_000 as Weight) + // Standard Error: 5_000 + .saturating_add((1_834_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64shl(r: u32, ) -> Weight { - (74_331_000 as Weight) + (118_258_000 as Weight) // Standard Error: 6_000 - .saturating_add((1_347_000 as Weight).saturating_mul(r as Weight)) + .saturating_add((1_865_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64shrs(r: u32, ) -> Weight { - (73_674_000 as Weight) - // Standard Error: 1_000 - .saturating_add((1_359_000 as Weight).saturating_mul(r as Weight)) + (118_665_000 as Weight) + // Standard Error: 3_000 + .saturating_add((1_842_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64shru(r: u32, ) -> Weight { - (73_807_000 as Weight) - // Standard Error: 2_000 - .saturating_add((1_358_000 as Weight).saturating_mul(r as Weight)) + (118_484_000 as Weight) + // Standard Error: 3_000 + .saturating_add((1_850_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64rotl(r: u32, ) -> Weight { - (73_725_000 as Weight) - // Standard Error: 1_000 - .saturating_add((1_358_000 as Weight).saturating_mul(r as Weight)) + (119_520_000 as Weight) + // Standard Error: 29_000 + .saturating_add((1_950_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64rotr(r: u32, ) -> Weight { - (73_755_000 as Weight) - // Standard Error: 3_000 - .saturating_add((1_360_000 as Weight).saturating_mul(r as Weight)) + (118_358_000 as Weight) + // Standard Error: 5_000 + .saturating_add((1_856_000 as Weight).saturating_mul(r as Weight)) } } @@ -1244,25 +1245,25 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { // Storage: Contracts DeletionQueue (r:1 w:0) fn on_process_deletion_queue_batch() -> Weight { - (1_654_000 as Weight) + (1_665_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `k` is `[0, 1024]`. fn on_initialize_per_trie_key(k: u32, ) -> Weight { - (8_564_000 as Weight) - // Standard Error: 0 - .saturating_add((868_000 as Weight).saturating_mul(k as Weight)) + (7_439_000 as Weight) + // Standard Error: 1_000 + .saturating_add((876_000 as Weight).saturating_mul(k as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) } // Storage: Contracts DeletionQueue (r:1 w:0) - /// The range of component `q` is `[0, 1024]`. + /// The range of component `q` is `[0, 128]`. fn on_initialize_per_queue_item(q: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 5_000 - .saturating_add((1_944_000 as Weight).saturating_mul(q as Weight)) + (8_035_000 as Weight) + // Standard Error: 4_000 + .saturating_add((2_010_000 as Weight).saturating_mul(q as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1270,9 +1271,9 @@ impl WeightInfo for () { // Storage: Contracts CodeStorage (r:0 w:1) /// The range of component `c` is `[0, 64226]`. fn reinstrument(c: u32, ) -> Weight { - (19_016_000 as Weight) + (24_769_000 as Weight) // Standard Error: 0 - .saturating_add((49_000 as Weight).saturating_mul(c as Weight)) + .saturating_add((46_000 as Weight).saturating_mul(c as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1282,9 +1283,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) /// The range of component `c` is `[0, 131072]`. fn call_with_code_per_byte(c: u32, ) -> Weight { - (205_194_000 as Weight) + (307_066_000 as Weight) // Standard Error: 0 - .saturating_add((53_000 as Weight).saturating_mul(c as Weight)) + .saturating_add((48_000 as Weight).saturating_mul(c as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } @@ -1298,9 +1299,9 @@ impl WeightInfo for () { /// The range of component `c` is `[0, 64226]`. /// The range of component `s` is `[0, 1048576]`. fn instantiate_with_code(c: u32, s: u32, ) -> Weight { - (288_487_000 as Weight) + (334_738_000 as Weight) // Standard Error: 0 - .saturating_add((124_000 as Weight).saturating_mul(c as Weight)) + .saturating_add((113_000 as Weight).saturating_mul(c as Weight)) // Standard Error: 0 .saturating_add((2_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) @@ -1314,7 +1315,7 @@ impl WeightInfo for () { // Storage: Contracts OwnerInfoOf (r:1 w:1) /// The range of component `s` is `[0, 1048576]`. fn instantiate(s: u32, ) -> Weight { - (186_136_000 as Weight) + (232_347_000 as Weight) // Standard Error: 0 .saturating_add((2_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(6 as Weight)) @@ -1325,7 +1326,7 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) // Storage: System Account (r:1 w:1) fn call() -> Weight { - (149_232_000 as Weight) + (203_390_000 as Weight) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } @@ -1334,9 +1335,9 @@ impl WeightInfo for () { // Storage: Contracts OwnerInfoOf (r:0 w:1) /// The range of component `c` is `[0, 64226]`. fn upload_code(c: u32, ) -> Weight { - (51_721_000 as Weight) + (122_035_000 as Weight) // Standard Error: 0 - .saturating_add((48_000 as Weight).saturating_mul(c as Weight)) + .saturating_add((46_000 as Weight).saturating_mul(c as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } @@ -1344,14 +1345,14 @@ impl WeightInfo for () { // Storage: Contracts CodeStorage (r:0 w:1) // Storage: Contracts PristineCode (r:0 w:1) fn remove_code() -> Weight { - (30_016_000 as Weight) + (30_759_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } // Storage: Contracts ContractInfoOf (r:1 w:1) // Storage: Contracts OwnerInfoOf (r:2 w:2) fn set_code() -> Weight { - (27_192_000 as Weight) + (27_740_000 as Weight) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } @@ -1361,9 +1362,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_caller(r: u32, ) -> Weight { - (206_405_000 as Weight) - // Standard Error: 112_000 - .saturating_add((40_987_000 as Weight).saturating_mul(r as Weight)) + (312_024_000 as Weight) + // Standard Error: 137_000 + .saturating_add((37_587_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1373,9 +1374,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_is_contract(r: u32, ) -> Weight { - (106_220_000 as Weight) - // Standard Error: 710_000 - .saturating_add((307_648_000 as Weight).saturating_mul(r as Weight)) + (223_437_000 as Weight) + // Standard Error: 699_000 + .saturating_add((305_422_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1386,9 +1387,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_code_hash(r: u32, ) -> Weight { - (104_498_000 as Weight) - // Standard Error: 633_000 - .saturating_add((368_901_000 as Weight).saturating_mul(r as Weight)) + (197_616_000 as Weight) + // Standard Error: 724_000 + .saturating_add((363_712_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1399,9 +1400,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_own_code_hash(r: u32, ) -> Weight { - (208_696_000 as Weight) - // Standard Error: 101_000 - .saturating_add((44_445_000 as Weight).saturating_mul(r as Weight)) + (306_664_000 as Weight) + // Standard Error: 123_000 + .saturating_add((41_149_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1411,9 +1412,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_caller_is_origin(r: u32, ) -> Weight { - (205_612_000 as Weight) - // Standard Error: 68_000 - .saturating_add((17_145_000 as Weight).saturating_mul(r as Weight)) + (302_772_000 as Weight) + // Standard Error: 70_000 + .saturating_add((15_501_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1423,9 +1424,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_address(r: u32, ) -> Weight { - (206_947_000 as Weight) - // Standard Error: 107_000 - .saturating_add((40_789_000 as Weight).saturating_mul(r as Weight)) + (305_370_000 as Weight) + // Standard Error: 124_000 + .saturating_add((37_824_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1435,9 +1436,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_gas_left(r: u32, ) -> Weight { - (208_692_000 as Weight) - // Standard Error: 109_000 - .saturating_add((40_600_000 as Weight).saturating_mul(r as Weight)) + (307_568_000 as Weight) + // Standard Error: 114_000 + .saturating_add((37_076_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1447,9 +1448,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_balance(r: u32, ) -> Weight { - (209_811_000 as Weight) - // Standard Error: 208_000 - .saturating_add((116_831_000 as Weight).saturating_mul(r as Weight)) + (312_135_000 as Weight) + // Standard Error: 173_000 + .saturating_add((109_819_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1459,9 +1460,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_value_transferred(r: u32, ) -> Weight { - (207_406_000 as Weight) - // Standard Error: 117_000 - .saturating_add((40_702_000 as Weight).saturating_mul(r as Weight)) + (305_419_000 as Weight) + // Standard Error: 122_000 + .saturating_add((37_599_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1471,9 +1472,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_minimum_balance(r: u32, ) -> Weight { - (209_260_000 as Weight) - // Standard Error: 130_000 - .saturating_add((40_479_000 as Weight).saturating_mul(r as Weight)) + (313_057_000 as Weight) + // Standard Error: 123_000 + .saturating_add((36_935_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1483,9 +1484,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_block_number(r: u32, ) -> Weight { - (206_448_000 as Weight) - // Standard Error: 95_000 - .saturating_add((40_134_000 as Weight).saturating_mul(r as Weight)) + (305_779_000 as Weight) + // Standard Error: 126_000 + .saturating_add((37_402_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1495,9 +1496,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_now(r: u32, ) -> Weight { - (206_969_000 as Weight) - // Standard Error: 116_000 - .saturating_add((40_251_000 as Weight).saturating_mul(r as Weight)) + (308_311_000 as Weight) + // Standard Error: 125_000 + .saturating_add((37_223_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1508,9 +1509,9 @@ impl WeightInfo for () { // Storage: TransactionPayment NextFeeMultiplier (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_weight_to_fee(r: u32, ) -> Weight { - (211_611_000 as Weight) - // Standard Error: 175_000 - .saturating_add((98_675_000 as Weight).saturating_mul(r as Weight)) + (311_111_000 as Weight) + // Standard Error: 152_000 + .saturating_add((96_086_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1520,9 +1521,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_gas(r: u32, ) -> Weight { - (134_484_000 as Weight) - // Standard Error: 57_000 - .saturating_add((19_329_000 as Weight).saturating_mul(r as Weight)) + (184_347_000 as Weight) + // Standard Error: 59_000 + .saturating_add((18_312_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1532,9 +1533,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_input(r: u32, ) -> Weight { - (208_556_000 as Weight) - // Standard Error: 125_000 - .saturating_add((40_328_000 as Weight).saturating_mul(r as Weight)) + (310_352_000 as Weight) + // Standard Error: 116_000 + .saturating_add((36_210_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1544,9 +1545,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `n` is `[0, 1024]`. fn seal_input_per_kb(n: u32, ) -> Weight { - (268_886_000 as Weight) - // Standard Error: 4_000 - .saturating_add((9_627_000 as Weight).saturating_mul(n as Weight)) + (369_486_000 as Weight) + // Standard Error: 3_000 + .saturating_add((9_684_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1556,7 +1557,7 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 1]`. fn seal_return(_r: u32, ) -> Weight { - (203_591_000 as Weight) + (301_862_000 as Weight) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1566,9 +1567,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `n` is `[0, 1024]`. fn seal_return_per_kb(n: u32, ) -> Weight { - (204_258_000 as Weight) - // Standard Error: 0 - .saturating_add((183_000 as Weight).saturating_mul(n as Weight)) + (301_951_000 as Weight) + // Standard Error: 1_000 + .saturating_add((234_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1580,9 +1581,9 @@ impl WeightInfo for () { // Storage: Contracts OwnerInfoOf (r:1 w:1) /// The range of component `r` is `[0, 1]`. fn seal_terminate(r: u32, ) -> Weight { - (206_625_000 as Weight) - // Standard Error: 672_000 - .saturating_add((59_377_000 as Weight).saturating_mul(r as Weight)) + (315_003_000 as Weight) + // Standard Error: 3_372_000 + .saturating_add((45_783_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().reads((4 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1595,9 +1596,9 @@ impl WeightInfo for () { // Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_random(r: u32, ) -> Weight { - (208_866_000 as Weight) - // Standard Error: 164_000 - .saturating_add((133_438_000 as Weight).saturating_mul(r as Weight)) + (313_986_000 as Weight) + // Standard Error: 184_000 + .saturating_add((126_360_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1607,9 +1608,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_deposit_event(r: u32, ) -> Weight { - (220_860_000 as Weight) - // Standard Error: 209_000 - .saturating_add((239_951_000 as Weight).saturating_mul(r as Weight)) + (330_772_000 as Weight) + // Standard Error: 250_000 + .saturating_add((231_786_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1621,11 +1622,11 @@ impl WeightInfo for () { /// The range of component `t` is `[0, 4]`. /// The range of component `n` is `[0, 16]`. fn seal_deposit_event_per_topic_and_kb(t: u32, n: u32, ) -> Weight { - (439_782_000 as Weight) - // Standard Error: 1_643_000 - .saturating_add((264_687_000 as Weight).saturating_mul(t as Weight)) - // Standard Error: 323_000 - .saturating_add((67_636_000 as Weight).saturating_mul(n as Weight)) + (536_159_000 as Weight) + // Standard Error: 1_631_000 + .saturating_add((263_688_000 as Weight).saturating_mul(t as Weight)) + // Standard Error: 321_000 + .saturating_add((73_828_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().reads((80 as Weight).saturating_mul(t as Weight))) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1637,18 +1638,18 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_debug_message(r: u32, ) -> Weight { - (140_280_000 as Weight) - // Standard Error: 82_000 - .saturating_add((32_717_000 as Weight).saturating_mul(r as Weight)) + (193_290_000 as Weight) + // Standard Error: 102_000 + .saturating_add((29_884_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_set_storage(r: u32, ) -> Weight { - (161_247_000 as Weight) - // Standard Error: 883_000 - .saturating_add((423_997_000 as Weight).saturating_mul(r as Weight)) + (257_650_000 as Weight) + // Standard Error: 928_000 + .saturating_add((420_511_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1657,9 +1658,9 @@ impl WeightInfo for () { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_set_storage_per_new_kb(n: u32, ) -> Weight { - (529_247_000 as Weight) - // Standard Error: 2_745_000 - .saturating_add((85_282_000 as Weight).saturating_mul(n as Weight)) + (629_319_000 as Weight) + // Standard Error: 2_729_000 + .saturating_add((94_316_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(55 as Weight)) .saturating_add(RocksDbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(53 as Weight)) @@ -1668,9 +1669,9 @@ impl WeightInfo for () { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_set_storage_per_old_kb(n: u32, ) -> Weight { - (529_812_000 as Weight) - // Standard Error: 2_513_000 - .saturating_add((74_554_000 as Weight).saturating_mul(n as Weight)) + (623_463_000 as Weight) + // Standard Error: 2_719_000 + .saturating_add((76_192_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(55 as Weight)) .saturating_add(RocksDbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(53 as Weight)) @@ -1679,9 +1680,9 @@ impl WeightInfo for () { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_clear_storage(r: u32, ) -> Weight { - (184_803_000 as Weight) - // Standard Error: 733_000 - .saturating_add((404_933_000 as Weight).saturating_mul(r as Weight)) + (285_077_000 as Weight) + // Standard Error: 774_000 + .saturating_add((403_199_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) @@ -1690,9 +1691,9 @@ impl WeightInfo for () { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_clear_storage_per_kb(n: u32, ) -> Weight { - (500_958_000 as Weight) - // Standard Error: 2_980_000 - .saturating_add((75_996_000 as Weight).saturating_mul(n as Weight)) + (600_845_000 as Weight) + // Standard Error: 3_055_000 + .saturating_add((76_629_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(55 as Weight)) .saturating_add(RocksDbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(52 as Weight)) @@ -1701,9 +1702,9 @@ impl WeightInfo for () { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_get_storage(r: u32, ) -> Weight { - (177_682_000 as Weight) - // Standard Error: 743_000 - .saturating_add((338_172_000 as Weight).saturating_mul(r as Weight)) + (273_626_000 as Weight) + // Standard Error: 625_000 + .saturating_add((339_186_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1711,9 +1712,9 @@ impl WeightInfo for () { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_get_storage_per_kb(n: u32, ) -> Weight { - (465_285_000 as Weight) - // Standard Error: 2_599_000 - .saturating_add((155_106_000 as Weight).saturating_mul(n as Weight)) + (553_849_000 as Weight) + // Standard Error: 2_339_000 + .saturating_add((171_830_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(55 as Weight)) .saturating_add(RocksDbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1721,9 +1722,9 @@ impl WeightInfo for () { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_contains_storage(r: u32, ) -> Weight { - (179_118_000 as Weight) - // Standard Error: 572_000 - .saturating_add((311_083_000 as Weight).saturating_mul(r as Weight)) + (288_011_000 as Weight) + // Standard Error: 792_000 + .saturating_add((310_449_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1731,9 +1732,9 @@ impl WeightInfo for () { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_contains_storage_per_kb(n: u32, ) -> Weight { - (423_056_000 as Weight) - // Standard Error: 2_037_000 - .saturating_add((69_665_000 as Weight).saturating_mul(n as Weight)) + (527_433_000 as Weight) + // Standard Error: 2_095_000 + .saturating_add((69_425_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(54 as Weight)) .saturating_add(RocksDbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1741,9 +1742,9 @@ impl WeightInfo for () { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_take_storage(r: u32, ) -> Weight { - (188_884_000 as Weight) - // Standard Error: 761_000 - .saturating_add((432_781_000 as Weight).saturating_mul(r as Weight)) + (284_675_000 as Weight) + // Standard Error: 713_000 + .saturating_add((432_314_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) @@ -1752,9 +1753,9 @@ impl WeightInfo for () { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_take_storage_per_kb(n: u32, ) -> Weight { - (532_408_000 as Weight) - // Standard Error: 3_348_000 - .saturating_add((164_943_000 as Weight).saturating_mul(n as Weight)) + (629_648_000 as Weight) + // Standard Error: 3_390_000 + .saturating_add((179_401_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(55 as Weight)) .saturating_add(RocksDbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(RocksDbWeight::get().writes(53 as Weight)) @@ -1766,9 +1767,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_transfer(r: u32, ) -> Weight { - (127_181_000 as Weight) - // Standard Error: 1_495_000 - .saturating_add((1_500_589_000 as Weight).saturating_mul(r as Weight)) + (275_243_000 as Weight) + // Standard Error: 1_039_000 + .saturating_add((1_473_158_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) @@ -1781,8 +1782,8 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_call(r: u32, ) -> Weight { (0 as Weight) - // Standard Error: 3_803_000 - .saturating_add((14_860_909_000 as Weight).saturating_mul(r as Weight)) + // Standard Error: 3_670_000 + .saturating_add((22_820_146_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().reads((80 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) @@ -1795,8 +1796,8 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_delegate_call(r: u32, ) -> Weight { (0 as Weight) - // Standard Error: 6_045_000 - .saturating_add((14_797_140_000 as Weight).saturating_mul(r as Weight)) + // Standard Error: 6_224_000 + .saturating_add((22_854_789_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads((79 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1807,11 +1808,11 @@ impl WeightInfo for () { /// The range of component `t` is `[0, 1]`. /// The range of component `c` is `[0, 1024]`. fn seal_call_per_transfer_clone_kb(t: u32, c: u32, ) -> Weight { - (9_196_444_000 as Weight) - // Standard Error: 20_486_000 - .saturating_add((1_458_153_000 as Weight).saturating_mul(t as Weight)) - // Standard Error: 8_000 - .saturating_add((9_718_000 as Weight).saturating_mul(c as Weight)) + (13_257_977_000 as Weight) + // Standard Error: 24_879_000 + .saturating_add((1_386_682_000 as Weight).saturating_mul(t as Weight)) + // Standard Error: 10_000 + .saturating_add((9_781_000 as Weight).saturating_mul(c as Weight)) .saturating_add(RocksDbWeight::get().reads(85 as Weight)) .saturating_add(RocksDbWeight::get().reads((81 as Weight).saturating_mul(t as Weight))) .saturating_add(RocksDbWeight::get().writes(81 as Weight)) @@ -1826,8 +1827,8 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_instantiate(r: u32, ) -> Weight { (0 as Weight) - // Standard Error: 36_253_000 - .saturating_add((21_201_529_000 as Weight).saturating_mul(r as Weight)) + // Standard Error: 36_682_000 + .saturating_add((29_115_109_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(6 as Weight)) .saturating_add(RocksDbWeight::get().reads((320 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) @@ -1842,11 +1843,11 @@ impl WeightInfo for () { /// The range of component `t` is `[0, 1]`. /// The range of component `s` is `[0, 960]`. fn seal_instantiate_per_transfer_salt_kb(t: u32, s: u32, ) -> Weight { - (12_282_498_000 as Weight) - // Standard Error: 48_112_000 - .saturating_add((720_795_000 as Weight).saturating_mul(t as Weight)) - // Standard Error: 22_000 - .saturating_add((124_274_000 as Weight).saturating_mul(s as Weight)) + (16_336_857_000 as Weight) + // Standard Error: 58_313_000 + .saturating_add((689_612_000 as Weight).saturating_mul(t as Weight)) + // Standard Error: 27_000 + .saturating_add((128_264_000 as Weight).saturating_mul(s as Weight)) .saturating_add(RocksDbWeight::get().reads(167 as Weight)) .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(t as Weight))) .saturating_add(RocksDbWeight::get().writes(165 as Weight)) @@ -1858,9 +1859,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_hash_sha2_256(r: u32, ) -> Weight { - (203_959_000 as Weight) - // Standard Error: 142_000 - .saturating_add((61_311_000 as Weight).saturating_mul(r as Weight)) + (301_670_000 as Weight) + // Standard Error: 144_000 + .saturating_add((59_019_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1870,9 +1871,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `n` is `[0, 1024]`. fn seal_hash_sha2_256_per_kb(n: u32, ) -> Weight { - (349_915_000 as Weight) - // Standard Error: 40_000 - .saturating_add((320_652_000 as Weight).saturating_mul(n as Weight)) + (344_105_000 as Weight) + // Standard Error: 32_000 + .saturating_add((326_196_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1882,9 +1883,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_hash_keccak_256(r: u32, ) -> Weight { - (209_219_000 as Weight) - // Standard Error: 157_000 - .saturating_add((73_728_000 as Weight).saturating_mul(r as Weight)) + (302_729_000 as Weight) + // Standard Error: 134_000 + .saturating_add((71_001_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1894,9 +1895,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `n` is `[0, 1024]`. fn seal_hash_keccak_256_per_kb(n: u32, ) -> Weight { - (208_860_000 as Weight) - // Standard Error: 25_000 - .saturating_add((245_718_000 as Weight).saturating_mul(n as Weight)) + (320_537_000 as Weight) + // Standard Error: 31_000 + .saturating_add((249_717_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1906,9 +1907,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_hash_blake2_256(r: u32, ) -> Weight { - (206_165_000 as Weight) - // Standard Error: 138_000 - .saturating_add((51_644_000 as Weight).saturating_mul(r as Weight)) + (303_794_000 as Weight) + // Standard Error: 136_000 + .saturating_add((49_006_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1918,9 +1919,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `n` is `[0, 1024]`. fn seal_hash_blake2_256_per_kb(n: u32, ) -> Weight { - (255_955_000 as Weight) - // Standard Error: 14_000 - .saturating_add((95_090_000 as Weight).saturating_mul(n as Weight)) + (392_854_000 as Weight) + // Standard Error: 16_000 + .saturating_add((98_867_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1930,9 +1931,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_hash_blake2_128(r: u32, ) -> Weight { - (208_153_000 as Weight) - // Standard Error: 140_000 - .saturating_add((51_264_000 as Weight).saturating_mul(r as Weight)) + (302_356_000 as Weight) + // Standard Error: 131_000 + .saturating_add((48_825_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1942,9 +1943,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `n` is `[0, 1024]`. fn seal_hash_blake2_128_per_kb(n: u32, ) -> Weight { - (278_368_000 as Weight) - // Standard Error: 14_000 - .saturating_add((95_006_000 as Weight).saturating_mul(n as Weight)) + (430_384_000 as Weight) + // Standard Error: 20_000 + .saturating_add((98_855_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1954,9 +1955,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_ecdsa_recover(r: u32, ) -> Weight { - (331_955_000 as Weight) - // Standard Error: 1_155_000 - .saturating_add((3_069_955_000 as Weight).saturating_mul(r as Weight)) + (459_616_000 as Weight) + // Standard Error: 1_003_000 + .saturating_add((3_064_299_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1966,9 +1967,9 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight { - (207_838_000 as Weight) - // Standard Error: 783_000 - .saturating_add((2_058_503_000 as Weight).saturating_mul(r as Weight)) + (326_960_000 as Weight) + // Standard Error: 1_238_000 + .saturating_add((2_095_205_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -1980,8 +1981,8 @@ impl WeightInfo for () { /// The range of component `r` is `[0, 20]`. fn seal_set_code_hash(r: u32, ) -> Weight { (0 as Weight) - // Standard Error: 1_567_000 - .saturating_add((774_380_000 as Weight).saturating_mul(r as Weight)) + // Standard Error: 1_677_000 + .saturating_add((773_112_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads((79 as Weight).saturating_mul(r as Weight))) .saturating_add(RocksDbWeight::get().writes((79 as Weight).saturating_mul(r as Weight))) } @@ -1989,329 +1990,330 @@ impl WeightInfo for () { // Storage: Contracts ContractInfoOf (r:1 w:1) // Storage: Contracts CodeStorage (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) - // Storage: unknown [0x3a7472616e73616374696f6e5f6c6576656c3a] (r:1 w:1) + /// The range of component `r` is `[0, 20]`. fn seal_reentrant_count(r: u32, ) -> Weight { - (91_522_000 as Weight) - // Standard Error: 50_000 - .saturating_add((24_064_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + (304_709_000 as Weight) + // Standard Error: 67_000 + .saturating_add((15_411_000 as Weight).saturating_mul(r as Weight)) + .saturating_add(RocksDbWeight::get().reads(4 as Weight)) + .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) // Storage: Contracts CodeStorage (r:1 w:0) // Storage: Timestamp Now (r:1 w:0) + /// The range of component `r` is `[0, 20]`. fn seal_account_entrance_count(r: u32, ) -> Weight { - (179_313_000 as Weight) - // Standard Error: 610_000 - .saturating_add((63_085_000 as Weight).saturating_mul(r as Weight)) + (328_378_000 as Weight) + // Standard Error: 137_000 + .saturating_add((37_448_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64const(r: u32, ) -> Weight { - (73_955_000 as Weight) - // Standard Error: 1_000 - .saturating_add((612_000 as Weight).saturating_mul(r as Weight)) + (119_063_000 as Weight) + // Standard Error: 4_000 + .saturating_add((839_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64load(r: u32, ) -> Weight { - (74_057_000 as Weight) - // Standard Error: 3_000 - .saturating_add((1_324_000 as Weight).saturating_mul(r as Weight)) + (118_393_000 as Weight) + // Standard Error: 5_000 + .saturating_add((1_858_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64store(r: u32, ) -> Weight { - (74_137_000 as Weight) - // Standard Error: 5_000 - .saturating_add((1_427_000 as Weight).saturating_mul(r as Weight)) + (119_672_000 as Weight) + // Standard Error: 4_000 + .saturating_add((2_235_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_select(r: u32, ) -> Weight { - (73_844_000 as Weight) - // Standard Error: 1_000 - .saturating_add((1_773_000 as Weight).saturating_mul(r as Weight)) + (118_560_000 as Weight) + // Standard Error: 4_000 + .saturating_add((2_320_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_if(r: u32, ) -> Weight { - (73_979_000 as Weight) - // Standard Error: 3_000 - .saturating_add((1_952_000 as Weight).saturating_mul(r as Weight)) + (118_387_000 as Weight) + // Standard Error: 5_000 + .saturating_add((2_467_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_br(r: u32, ) -> Weight { - (73_924_000 as Weight) - // Standard Error: 3_000 - .saturating_add((941_000 as Weight).saturating_mul(r as Weight)) + (118_878_000 as Weight) + // Standard Error: 4_000 + .saturating_add((1_271_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_br_if(r: u32, ) -> Weight { - (73_574_000 as Weight) - // Standard Error: 5_000 - .saturating_add((1_439_000 as Weight).saturating_mul(r as Weight)) + (118_145_000 as Weight) + // Standard Error: 4_000 + .saturating_add((1_847_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_br_table(r: u32, ) -> Weight { - (73_343_000 as Weight) - // Standard Error: 3_000 - .saturating_add((1_603_000 as Weight).saturating_mul(r as Weight)) + (118_201_000 as Weight) + // Standard Error: 8_000 + .saturating_add((2_071_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `e` is `[1, 256]`. fn instr_br_table_per_entry(e: u32, ) -> Weight { - (76_267_000 as Weight) + (121_244_000 as Weight) // Standard Error: 0 - .saturating_add((4_000 as Weight).saturating_mul(e as Weight)) + .saturating_add((5_000 as Weight).saturating_mul(e as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_call(r: u32, ) -> Weight { - (74_877_000 as Weight) + (120_143_000 as Weight) // Standard Error: 12_000 - .saturating_add((7_144_000 as Weight).saturating_mul(r as Weight)) + .saturating_add((6_437_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_call_indirect(r: u32, ) -> Weight { - (88_665_000 as Weight) - // Standard Error: 20_000 - .saturating_add((9_142_000 as Weight).saturating_mul(r as Weight)) + (132_114_000 as Weight) + // Standard Error: 14_000 + .saturating_add((8_275_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `p` is `[0, 128]`. fn instr_call_indirect_per_param(p: u32, ) -> Weight { - (98_600_000 as Weight) + (141_495_000 as Weight) // Standard Error: 2_000 - .saturating_add((469_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((599_000 as Weight).saturating_mul(p as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_local_get(r: u32, ) -> Weight { - (74_555_000 as Weight) - // Standard Error: 1_000 - .saturating_add((624_000 as Weight).saturating_mul(r as Weight)) + (119_733_000 as Weight) + // Standard Error: 2_000 + .saturating_add((859_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_local_set(r: u32, ) -> Weight { - (74_329_000 as Weight) - // Standard Error: 1_000 - .saturating_add((688_000 as Weight).saturating_mul(r as Weight)) + (118_913_000 as Weight) + // Standard Error: 2_000 + .saturating_add((913_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_local_tee(r: u32, ) -> Weight { - (74_612_000 as Weight) - // Standard Error: 1_000 - .saturating_add((909_000 as Weight).saturating_mul(r as Weight)) + (118_812_000 as Weight) + // Standard Error: 9_000 + .saturating_add((1_248_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_global_get(r: u32, ) -> Weight { - (76_906_000 as Weight) - // Standard Error: 1_000 - .saturating_add((1_192_000 as Weight).saturating_mul(r as Weight)) + (122_692_000 as Weight) + // Standard Error: 4_000 + .saturating_add((1_422_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_global_set(r: u32, ) -> Weight { - (76_979_000 as Weight) + (121_141_000 as Weight) // Standard Error: 2_000 - .saturating_add((1_361_000 as Weight).saturating_mul(r as Weight)) + .saturating_add((1_653_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_memory_current(r: u32, ) -> Weight { - (74_370_000 as Weight) - // Standard Error: 3_000 - .saturating_add((661_000 as Weight).saturating_mul(r as Weight)) + (118_469_000 as Weight) + // Standard Error: 2_000 + .saturating_add((900_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 1]`. fn instr_memory_grow(r: u32, ) -> Weight { - (73_584_000 as Weight) - // Standard Error: 353_000 - .saturating_add((187_114_000 as Weight).saturating_mul(r as Weight)) + (120_650_000 as Weight) + // Standard Error: 20_000 + .saturating_add((227_328_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64clz(r: u32, ) -> Weight { - (74_206_000 as Weight) - // Standard Error: 1_000 - .saturating_add((884_000 as Weight).saturating_mul(r as Weight)) + (118_529_000 as Weight) + // Standard Error: 3_000 + .saturating_add((1_318_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64ctz(r: u32, ) -> Weight { - (73_992_000 as Weight) - // Standard Error: 1_000 - .saturating_add((893_000 as Weight).saturating_mul(r as Weight)) + (118_600_000 as Weight) + // Standard Error: 6_000 + .saturating_add((1_320_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64popcnt(r: u32, ) -> Weight { - (73_985_000 as Weight) - // Standard Error: 2_000 - .saturating_add((891_000 as Weight).saturating_mul(r as Weight)) + (118_719_000 as Weight) + // Standard Error: 6_000 + .saturating_add((1_320_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64eqz(r: u32, ) -> Weight { - (74_117_000 as Weight) - // Standard Error: 4_000 - .saturating_add((901_000 as Weight).saturating_mul(r as Weight)) + (117_810_000 as Weight) + // Standard Error: 8_000 + .saturating_add((1_354_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64extendsi32(r: u32, ) -> Weight { - (73_981_000 as Weight) - // Standard Error: 1_000 - .saturating_add((866_000 as Weight).saturating_mul(r as Weight)) + (118_701_000 as Weight) + // Standard Error: 3_000 + .saturating_add((1_287_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64extendui32(r: u32, ) -> Weight { - (74_104_000 as Weight) + (119_074_000 as Weight) // Standard Error: 3_000 - .saturating_add((868_000 as Weight).saturating_mul(r as Weight)) + .saturating_add((1_273_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i32wrapi64(r: u32, ) -> Weight { - (74_293_000 as Weight) - // Standard Error: 3_000 - .saturating_add((878_000 as Weight).saturating_mul(r as Weight)) + (118_939_000 as Weight) + // Standard Error: 6_000 + .saturating_add((1_324_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64eq(r: u32, ) -> Weight { - (74_055_000 as Weight) - // Standard Error: 2_000 - .saturating_add((1_350_000 as Weight).saturating_mul(r as Weight)) + (118_492_000 as Weight) + // Standard Error: 3_000 + .saturating_add((1_830_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64ne(r: u32, ) -> Weight { - (73_710_000 as Weight) - // Standard Error: 2_000 - .saturating_add((1_360_000 as Weight).saturating_mul(r as Weight)) + (118_708_000 as Weight) + // Standard Error: 6_000 + .saturating_add((1_814_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64lts(r: u32, ) -> Weight { - (73_917_000 as Weight) - // Standard Error: 1_000 - .saturating_add((1_355_000 as Weight).saturating_mul(r as Weight)) + (118_355_000 as Weight) + // Standard Error: 4_000 + .saturating_add((1_832_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64ltu(r: u32, ) -> Weight { - (74_048_000 as Weight) - // Standard Error: 1_000 - .saturating_add((1_360_000 as Weight).saturating_mul(r as Weight)) + (118_636_000 as Weight) + // Standard Error: 4_000 + .saturating_add((1_821_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64gts(r: u32, ) -> Weight { - (74_029_000 as Weight) - // Standard Error: 2_000 - .saturating_add((1_349_000 as Weight).saturating_mul(r as Weight)) + (119_080_000 as Weight) + // Standard Error: 5_000 + .saturating_add((1_809_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64gtu(r: u32, ) -> Weight { - (74_267_000 as Weight) - // Standard Error: 2_000 - .saturating_add((1_353_000 as Weight).saturating_mul(r as Weight)) + (118_676_000 as Weight) + // Standard Error: 3_000 + .saturating_add((1_837_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64les(r: u32, ) -> Weight { - (73_952_000 as Weight) - // Standard Error: 1_000 - .saturating_add((1_350_000 as Weight).saturating_mul(r as Weight)) + (118_613_000 as Weight) + // Standard Error: 4_000 + .saturating_add((1_819_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64leu(r: u32, ) -> Weight { - (73_851_000 as Weight) + (118_453_000 as Weight) // Standard Error: 2_000 - .saturating_add((1_368_000 as Weight).saturating_mul(r as Weight)) + .saturating_add((1_842_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64ges(r: u32, ) -> Weight { - (74_034_000 as Weight) - // Standard Error: 2_000 - .saturating_add((1_348_000 as Weight).saturating_mul(r as Weight)) + (118_272_000 as Weight) + // Standard Error: 6_000 + .saturating_add((1_847_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64geu(r: u32, ) -> Weight { - (73_979_000 as Weight) - // Standard Error: 3_000 - .saturating_add((1_353_000 as Weight).saturating_mul(r as Weight)) + (118_619_000 as Weight) + // Standard Error: 8_000 + .saturating_add((1_837_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64add(r: u32, ) -> Weight { - (74_000_000 as Weight) - // Standard Error: 1_000 - .saturating_add((1_328_000 as Weight).saturating_mul(r as Weight)) + (119_428_000 as Weight) + // Standard Error: 53_000 + .saturating_add((2_287_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64sub(r: u32, ) -> Weight { - (73_883_000 as Weight) - // Standard Error: 1_000 - .saturating_add((1_331_000 as Weight).saturating_mul(r as Weight)) + (118_630_000 as Weight) + // Standard Error: 4_000 + .saturating_add((1_823_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64mul(r: u32, ) -> Weight { - (74_216_000 as Weight) - // Standard Error: 5_000 - .saturating_add((1_324_000 as Weight).saturating_mul(r as Weight)) + (118_636_000 as Weight) + // Standard Error: 3_000 + .saturating_add((1_835_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64divs(r: u32, ) -> Weight { - (73_989_000 as Weight) - // Standard Error: 1_000 - .saturating_add((1_998_000 as Weight).saturating_mul(r as Weight)) + (118_313_000 as Weight) + // Standard Error: 4_000 + .saturating_add((2_469_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64divu(r: u32, ) -> Weight { - (73_857_000 as Weight) - // Standard Error: 4_000 - .saturating_add((2_073_000 as Weight).saturating_mul(r as Weight)) + (118_550_000 as Weight) + // Standard Error: 3_000 + .saturating_add((2_438_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64rems(r: u32, ) -> Weight { - (73_801_000 as Weight) - // Standard Error: 1_000 - .saturating_add((2_027_000 as Weight).saturating_mul(r as Weight)) + (118_464_000 as Weight) + // Standard Error: 5_000 + .saturating_add((2_464_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64remu(r: u32, ) -> Weight { - (74_130_000 as Weight) - // Standard Error: 1_000 - .saturating_add((2_064_000 as Weight).saturating_mul(r as Weight)) + (118_254_000 as Weight) + // Standard Error: 8_000 + .saturating_add((2_453_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64and(r: u32, ) -> Weight { - (74_071_000 as Weight) - // Standard Error: 1_000 - .saturating_add((1_327_000 as Weight).saturating_mul(r as Weight)) + (118_620_000 as Weight) + // Standard Error: 4_000 + .saturating_add((1_835_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64or(r: u32, ) -> Weight { - (74_201_000 as Weight) - // Standard Error: 4_000 - .saturating_add((1_330_000 as Weight).saturating_mul(r as Weight)) + (118_596_000 as Weight) + // Standard Error: 6_000 + .saturating_add((1_845_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64xor(r: u32, ) -> Weight { - (74_241_000 as Weight) - // Standard Error: 1_000 - .saturating_add((1_321_000 as Weight).saturating_mul(r as Weight)) + (118_814_000 as Weight) + // Standard Error: 5_000 + .saturating_add((1_834_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64shl(r: u32, ) -> Weight { - (74_331_000 as Weight) + (118_258_000 as Weight) // Standard Error: 6_000 - .saturating_add((1_347_000 as Weight).saturating_mul(r as Weight)) + .saturating_add((1_865_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64shrs(r: u32, ) -> Weight { - (73_674_000 as Weight) - // Standard Error: 1_000 - .saturating_add((1_359_000 as Weight).saturating_mul(r as Weight)) + (118_665_000 as Weight) + // Standard Error: 3_000 + .saturating_add((1_842_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64shru(r: u32, ) -> Weight { - (73_807_000 as Weight) - // Standard Error: 2_000 - .saturating_add((1_358_000 as Weight).saturating_mul(r as Weight)) + (118_484_000 as Weight) + // Standard Error: 3_000 + .saturating_add((1_850_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64rotl(r: u32, ) -> Weight { - (73_725_000 as Weight) - // Standard Error: 1_000 - .saturating_add((1_358_000 as Weight).saturating_mul(r as Weight)) + (119_520_000 as Weight) + // Standard Error: 29_000 + .saturating_add((1_950_000 as Weight).saturating_mul(r as Weight)) } /// The range of component `r` is `[0, 50]`. fn instr_i64rotr(r: u32, ) -> Weight { - (73_755_000 as Weight) - // Standard Error: 3_000 - .saturating_add((1_360_000 as Weight).saturating_mul(r as Weight)) + (118_358_000 as Weight) + // Standard Error: 5_000 + .saturating_add((1_856_000 as Weight).saturating_mul(r as Weight)) } } From 9c0c06f972f4a22dabf989de42e30547a5b23a68 Mon Sep 17 00:00:00 2001 From: yarikbratashchuk Date: Sun, 3 Jul 2022 14:46:46 +0300 Subject: [PATCH 18/25] Add fixture descriptions --- frame/contracts/fixtures/account_entrance_count_call.wat | 2 ++ frame/contracts/fixtures/reentrant_count_call.wat | 2 ++ frame/contracts/fixtures/reentrant_count_delegated_call.wat | 2 ++ 3 files changed, 6 insertions(+) diff --git a/frame/contracts/fixtures/account_entrance_count_call.wat b/frame/contracts/fixtures/account_entrance_count_call.wat index 2adc3ba254895..51eb17394d485 100644 --- a/frame/contracts/fixtures/account_entrance_count_call.wat +++ b/frame/contracts/fixtures/account_entrance_count_call.wat @@ -1,3 +1,5 @@ +;; This fixture tests if seal_account_entrance_count works as expected +;; testing it with 2 different addresses (module (import "seal0" "seal_input" (func $seal_input (param i32 i32))) (import "__unstable__" "seal_account_entrance_count" (func $seal_account_entrance_count (param i32) (result i32))) diff --git a/frame/contracts/fixtures/reentrant_count_call.wat b/frame/contracts/fixtures/reentrant_count_call.wat index 9bddac617c594..0d85a9d478812 100644 --- a/frame/contracts/fixtures/reentrant_count_call.wat +++ b/frame/contracts/fixtures/reentrant_count_call.wat @@ -1,3 +1,5 @@ +;; This fixture recursively tests if seal_reentrant_count returns correct reentrant count value when +;; using seal_call to make caller contract call to itself (module (import "seal0" "seal_input" (func $seal_input (param i32 i32))) (import "seal0" "seal_call" (func $seal_call (param i32 i32 i64 i32 i32 i32 i32 i32 i32) (result i32))) diff --git a/frame/contracts/fixtures/reentrant_count_delegated_call.wat b/frame/contracts/fixtures/reentrant_count_delegated_call.wat index 76d722469a34a..b4c9d9807a39e 100644 --- a/frame/contracts/fixtures/reentrant_count_delegated_call.wat +++ b/frame/contracts/fixtures/reentrant_count_delegated_call.wat @@ -1,3 +1,5 @@ +;; This fixture recursively tests if seal_reentrant_count returns correct reentrant count value when +;; using seal_delegate_call to make caller contract delegate call to itself (module (import "seal0" "seal_input" (func $seal_input (param i32 i32))) (import "seal0" "seal_set_storage" (func $seal_set_storage (param i32 i32 i32))) From 9c5bb4725785f40afb136fbfb66df324c46d7834 Mon Sep 17 00:00:00 2001 From: yarikbratashchuk Date: Sun, 3 Jul 2022 14:56:32 +0300 Subject: [PATCH 19/25] Update comments as suggested --- frame/contracts/fixtures/reentrant_count_call.wat | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/frame/contracts/fixtures/reentrant_count_call.wat b/frame/contracts/fixtures/reentrant_count_call.wat index 0d85a9d478812..ac86ff4666990 100644 --- a/frame/contracts/fixtures/reentrant_count_call.wat +++ b/frame/contracts/fixtures/reentrant_count_call.wat @@ -6,9 +6,9 @@ (import "__unstable__" "seal_reentrant_count" (func $seal_reentrant_count (result i32))) (import "env" "memory" (memory 1 1)) - ;; [0, 32) buffer where code hash is copied + ;; [0, 32) buffer where contract address is copied - ;; [32, 36) buffer for the call stack high + ;; [32, 36) buffer for the call stack height ;; [36, 40) size of the input buffer (data (i32.const 36) "\24") @@ -22,25 +22,26 @@ ) ) (func (export "call") - (local $manual_reentrant_count i32) + (local $expected_reentrant_count i32) (local $seal_call_exit_code i32) ;; Reading input (call $seal_input (i32.const 0) (i32.const 36)) ;; reading manually passed reentrant count - (set_local $manual_reentrant_count (i32.load (i32.const 32))) + (set_local $expected_reentrant_count (i32.load (i32.const 32))) ;; reentrance count is calculated correctly (call $assert - (i32.eq (call $seal_reentrant_count) (get_local $manual_reentrant_count)) + (i32.eq (call $seal_reentrant_count) (get_local $expected_reentrant_count)) ) + ;; re-enter 5 times in a row and assert that the reentrant counter works as expected (i32.eq (call $seal_reentrant_count) (i32.const 5)) (if (then) ;; recursion exit case (else - ;; incrementing manual reentrant count high + ;; incrementing $expected_reentrant_count passed to the contract (i32.store (i32.const 32) (i32.add (i32.load (i32.const 32)) (i32.const 1))) ;; Call to itself From 35c03493dfd104a120d154d405df015ef13d2865 Mon Sep 17 00:00:00 2001 From: yarikbratashchuk Date: Sun, 3 Jul 2022 18:07:11 +0300 Subject: [PATCH 20/25] Update reentrant_count_call test to use seal_address --- .../fixtures/reentrant_count_call.wat | 26 ++++++++++++------- frame/contracts/src/tests.rs | 4 +-- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/frame/contracts/fixtures/reentrant_count_call.wat b/frame/contracts/fixtures/reentrant_count_call.wat index ac86ff4666990..c98d58e81b42e 100644 --- a/frame/contracts/fixtures/reentrant_count_call.wat +++ b/frame/contracts/fixtures/reentrant_count_call.wat @@ -2,16 +2,20 @@ ;; using seal_call to make caller contract call to itself (module (import "seal0" "seal_input" (func $seal_input (param i32 i32))) - (import "seal0" "seal_call" (func $seal_call (param i32 i32 i64 i32 i32 i32 i32 i32 i32) (result i32))) + (import "seal0" "seal_address" (func $seal_address (param i32 i32))) + (import "seal1" "seal_call" (func $seal_call (param i32 i32 i64 i32 i32 i32 i32 i32) (result i32))) (import "__unstable__" "seal_reentrant_count" (func $seal_reentrant_count (result i32))) (import "env" "memory" (memory 1 1)) - ;; [0, 32) buffer where contract address is copied + ;; [0, 32) reserved for $seal_address output ;; [32, 36) buffer for the call stack height ;; [36, 40) size of the input buffer - (data (i32.const 36) "\24") + (data (i32.const 36) "\04") + + ;; [40, 44) length of the buffer for $seal_address + (data (i32.const 40) "\20") (func $assert (param i32) (block $ok @@ -25,8 +29,11 @@ (local $expected_reentrant_count i32) (local $seal_call_exit_code i32) - ;; Reading input - (call $seal_input (i32.const 0) (i32.const 36)) + ;; reading current contract address + (call $seal_address (i32.const 0) (i32.const 40)) + + ;; reading passed input + (call $seal_input (i32.const 32) (i32.const 36)) ;; reading manually passed reentrant count (set_local $expected_reentrant_count (i32.load (i32.const 32))) @@ -47,13 +54,12 @@ ;; Call to itself (set_local $seal_call_exit_code (call $seal_call - (i32.const 0) ;; Pointer to "callee" address. - (i32.const 32) ;; Length of "callee" address. + (i32.const 8) ;; Allow reentrancy flag set + (i32.const 0) ;; Pointer to "callee" address (i64.const 0) ;; How much gas to devote for the execution. 0 = all. (i32.const 0) ;; Pointer to the buffer with value to transfer - (i32.const 0) ;; Length of the buffer with value to transfer. - (i32.const 0) ;; Pointer to input data buffer address - (i32.const 36) ;; Length of input data buffer + (i32.const 32) ;; Pointer to input data buffer address + (i32.const 4) ;; Length of input data buffer (i32.const 0xffffffff) ;; u32 max sentinel value: do not copy output (i32.const 0) ;; Ptr to output buffer len ) diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 201b71db8407b..8b770dacac8c0 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -3292,8 +3292,8 @@ fn reentrant_count_works_with_call() { vec![], )); - // adding reentrant count to the input - let input = (contract_addr.clone(), 0).encode(); + // passing reentrant count to the input + let input = 0.encode(); Contracts::bare_call(ALICE, contract_addr, 0, GAS_LIMIT, None, input, true) .result From 321a828edde00350fe91b9e5a52313a9b0a6a89e Mon Sep 17 00:00:00 2001 From: Artemka374 Date: Sun, 11 Sep 2022 21:12:11 +0300 Subject: [PATCH 21/25] change account_entrance_count_call fixture to use seal_caller --- .../fixtures/account_entrance_count_call.wat | 45 ++++++++++++++----- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/frame/contracts/fixtures/account_entrance_count_call.wat b/frame/contracts/fixtures/account_entrance_count_call.wat index 51eb17394d485..e661427581ba4 100644 --- a/frame/contracts/fixtures/account_entrance_count_call.wat +++ b/frame/contracts/fixtures/account_entrance_count_call.wat @@ -2,13 +2,17 @@ ;; testing it with 2 different addresses (module (import "seal0" "seal_input" (func $seal_input (param i32 i32))) + (import "seal0" "seal_caller" (func $seal_caller (param i32 i32))) (import "__unstable__" "seal_account_entrance_count" (func $seal_account_entrance_count (param i32) (result i32))) (import "env" "memory" (memory 1 1)) ;; [0, 32) buffer where input is copied + ;; [32, 64) buffer where caller is copied - ;; [32, 36) size of the input buffer - (data (i32.const 32) "\20") + ;; [64, 68) size of the input buffer + (data (i32.const 64) "\20") + ;; [68, 72) size of the caller buffer + (data (i32.const 68) "\20") (func $assert (param i32) (block $ok @@ -18,20 +22,39 @@ (unreachable) ) ) + (func (export "call") (local $account_entrance_count i32) - ;; Reading "callee" contract address (which is the address of the caller) - (call $seal_input (i32.const 0) (i32.const 32)) + ;; Reading "callee" contract address + (call $seal_input (i32.const 0) (i32.const 64)) - ;; assert account_entrance_count == 1 - (call $assert - (i32.eq (call $seal_account_entrance_count (i32.const 0)) (i32.const 1)) - ) + ;; Reading "caller" contract address + (call $seal_caller (i32.const 32) (i32.const 68)) - ;; assert account_entrance_count == 0 for another account - (call $assert - (i32.eq (call $seal_account_entrance_count (i32.const 32)) (i32.const 0)) + (i32.eq + (i32.load (i32.const 0)) + (i32.load (i32.const 32)) + ) + (if + (then + ;; If the caller is the same as the callee then seal_account_entrance_count should be 2 + (call $assert + (i32.eq + (call $seal_account_entrance_count (i32.const 0)) + (i32.const 2) + ) + ) + ) + (else + ;; If the caller is different from the callee then seal_account_entrance_count should be 1 + (call $assert + (i32.eq + (call $seal_account_entrance_count (i32.const 0)) + (i32.const 1) + ) + ) + ) ) ) From 34637952a0d7d56b2bdf3f42eeb4ce6177322426 Mon Sep 17 00:00:00 2001 From: Artemka374 Date: Fri, 4 Nov 2022 20:54:38 +0200 Subject: [PATCH 22/25] fix compilation errors and apply some suggestions --- .../fixtures/account_entrance_count_call.wat | 42 +++--------- .../reentrant_count_delegated_call.wat | 4 +- frame/contracts/src/schedule.rs | 4 +- frame/contracts/src/tests.rs | 15 ++-- frame/contracts/src/wasm/runtime.rs | 68 ++++++++++++------- frame/contracts/src/weights.rs | 32 ++++----- 6 files changed, 81 insertions(+), 84 deletions(-) diff --git a/frame/contracts/fixtures/account_entrance_count_call.wat b/frame/contracts/fixtures/account_entrance_count_call.wat index e661427581ba4..5c929c0b93b4a 100644 --- a/frame/contracts/fixtures/account_entrance_count_call.wat +++ b/frame/contracts/fixtures/account_entrance_count_call.wat @@ -3,16 +3,13 @@ (module (import "seal0" "seal_input" (func $seal_input (param i32 i32))) (import "seal0" "seal_caller" (func $seal_caller (param i32 i32))) + (import "seal0" "seal_return" (func $seal_return (param i32 i32 i32))) (import "__unstable__" "seal_account_entrance_count" (func $seal_account_entrance_count (param i32) (result i32))) (import "env" "memory" (memory 1 1)) ;; [0, 32) buffer where input is copied - ;; [32, 64) buffer where caller is copied - - ;; [64, 68) size of the input buffer - (data (i32.const 64) "\20") - ;; [68, 72) size of the caller buffer - (data (i32.const 68) "\20") + ;; [32, 36) size of the input buffer + (data (i32.const 32) "\20") (func $assert (param i32) (block $ok @@ -27,35 +24,14 @@ (local $account_entrance_count i32) ;; Reading "callee" contract address - (call $seal_input (i32.const 0) (i32.const 64)) - - ;; Reading "caller" contract address - (call $seal_caller (i32.const 32) (i32.const 68)) + (call $seal_input (i32.const 0) (i32.const 32)) - (i32.eq - (i32.load (i32.const 0)) - (i32.load (i32.const 32)) - ) - (if - (then - ;; If the caller is the same as the callee then seal_account_entrance_count should be 2 - (call $assert - (i32.eq - (call $seal_account_entrance_count (i32.const 0)) - (i32.const 2) - ) - ) - ) - (else - ;; If the caller is different from the callee then seal_account_entrance_count should be 1 - (call $assert - (i32.eq - (call $seal_account_entrance_count (i32.const 0)) - (i32.const 1) - ) - ) - ) + (i32.store + (i32.const 36) + (call $seal_account_entrance_count (i32.const 0)) ) + + (call $seal_return (i32.const 0) (i32.const 36) (i32.const 4)) ) (func (export "deploy")) diff --git a/frame/contracts/fixtures/reentrant_count_delegated_call.wat b/frame/contracts/fixtures/reentrant_count_delegated_call.wat index b4c9d9807a39e..87bbbf9c3b91d 100644 --- a/frame/contracts/fixtures/reentrant_count_delegated_call.wat +++ b/frame/contracts/fixtures/reentrant_count_delegated_call.wat @@ -29,10 +29,10 @@ ;; Reading input (call $seal_input (i32.const 0) (i32.const 36)) - ;; reading passed callstack high + ;; reading passed callstack height (set_local $callstack_high (i32.load (i32.const 32))) - ;; incrementing callstack high + ;; incrementing callstack height (i32.store (i32.const 32) (i32.add (i32.load (i32.const 32)) (i32.const 1))) ;; reentrance count stays 0 diff --git a/frame/contracts/src/schedule.rs b/frame/contracts/src/schedule.rs index b252d565120ef..2420225d0bcb2 100644 --- a/frame/contracts/src/schedule.rs +++ b/frame/contracts/src/schedule.rs @@ -424,10 +424,10 @@ pub struct HostFnWeights { pub ecdsa_to_eth_address: u64, /// Weight of calling `seal_reentrant_count`. - pub reentrant_count: Weight, + pub reentrant_count: u64, /// Weight of calling `seal_account_entrance_count`. - pub account_entrance_count: Weight, + pub account_entrance_count: u64, /// The type parameter is used in the default implementation. #[codec(skip)] diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 0a7dc337c24bd..f7351cd760187 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -4394,7 +4394,7 @@ fn reentrant_count_works_with_call() { let _ = Balances::deposit_creating(&ALICE, 1_000_000); assert_ok!(Contracts::instantiate_with_code( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), 300_000, GAS_LIMIT, None, @@ -4406,7 +4406,7 @@ fn reentrant_count_works_with_call() { // passing reentrant count to the input let input = 0.encode(); - Contracts::bare_call(ALICE, contract_addr, 0, GAS_LIMIT, None, input, true) + Contracts::bare_call(ALICE, contract_addr, 0, GAS_LIMIT, None, input, true, Determinism::Deterministic) .result .unwrap(); }); @@ -4422,7 +4422,7 @@ fn reentrant_count_works_with_delegated_call() { let _ = Balances::deposit_creating(&ALICE, 1_000_000); assert_ok!(Contracts::instantiate_with_code( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), 300_000, GAS_LIMIT, None, @@ -4434,7 +4434,7 @@ fn reentrant_count_works_with_delegated_call() { // adding a callstack height to the input let input = (code_hash, 1).encode(); - Contracts::bare_call(ALICE, contract_addr.clone(), 0, GAS_LIMIT, None, input, true) + Contracts::bare_call(ALICE, contract_addr.clone(), 0, GAS_LIMIT, None, input, true, Determinism::Deterministic) .result .unwrap(); }); @@ -4450,7 +4450,7 @@ fn account_entrance_count_works() { let _ = Balances::deposit_creating(&ALICE, 1_000_000); assert_ok!(Contracts::instantiate_with_code( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), 300_000, GAS_LIMIT, None, @@ -4459,7 +4459,7 @@ fn account_entrance_count_works() { vec![], )); - Contracts::bare_call( + let result = Contracts::bare_call( ALICE, contract_addr.clone(), 0, @@ -4467,8 +4467,11 @@ fn account_entrance_count_works() { None, contract_addr.encode(), true, + Determinism::Deterministic ) .result .unwrap(); + + assert_eq!(result.data, 1.encode()); }); } diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index b60f4c7c17db3..e4a8257c4b9f6 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -1198,6 +1198,7 @@ pub mod env { Ok(ReturnCode::KeyNotFound) } } + /// Transfer some value to another account. /// /// # Parameters @@ -1364,6 +1365,7 @@ pub mod env { output_len_ptr, ) } + /// Instantiate a contract with the specified code hash. /// /// # Deprecation @@ -2453,32 +2455,48 @@ pub mod env { }, Err(_) => Ok(ReturnCode::EcdsaRecoverFailed), } - }, + } - // Returns the number of times the currently executing contract exists on the call stack in addition - // to the calling instance. - // - // # Return Value - // - // Returns 0 when there is no reentrancy. - [__unstable__] seal_reentrant_count(ctx) -> u32 => { + /// Returns the number of times the currently executing contract exists on the call stack in addition + /// to the calling instance. + /// + /// # Return Value + /// + /// Returns 0 when there is no reentrancy. + #[unstable] + #[prefixed_alias] + fn reentrant_count(ctx: Runtime, out_ptr: u32) -> Result { ctx.charge_gas(RuntimeCosts::ReentrantCount)?; - Ok(ctx.ext.reentrant_count()) - }, - // Returns the number of times specified contract exists on the call stack. Delegated calls are - // not calculated as separate calls. - // - // # Parameters - // - // - `account_ptr`: a pointer to the contract address. - // - // # Return Value - // - // Returns 0 when the contract does not exist on the call stack. - [__unstable__] seal_account_entrance_count(ctx, account_ptr: u32) -> u32 => { + let count = ctx.ext.reentrant_count(); + + ctx.write_sandbox_memory(out_ptr, &count.to_le_bytes())?; + Ok(ReturnCode::Success) + } + + /// Returns the number of times specified contract exists on the call stack. Delegated calls are + /// not calculated as separate calls. + /// + /// # Parameters + /// + /// - `account_ptr`: a pointer to the contract address. + /// + /// # Return Value + /// + /// Returns 0 when the contract does not exist on the call stack. + #[unstable] + #[prefixed_alias] + fn account_entrance_count( + ctx: Runtime, + account_ptr: u32, + out_ptr: u32, + ) -> Result { ctx.charge_gas(RuntimeCosts::AccountEntranceCount)?; - let account_id: <::T as frame_system::Config>::AccountId = ctx.read_sandbox_memory_as(account_ptr)?; - Ok(ctx.ext.account_entrance_count(&account_id)) - }, -); + let account_id: <::T as frame_system::Config>::AccountId = + ctx.read_sandbox_memory_as(account_ptr)?; + + let count = ctx.ext.account_entrance_count(&account_id); + ctx.write_sandbox_memory(out_ptr, &count.to_le_bytes())?; + Ok(ReturnCode::Success) + } +} diff --git a/frame/contracts/src/weights.rs b/frame/contracts/src/weights.rs index cc7cc283484f0..24c794057f34e 100644 --- a/frame/contracts/src/weights.rs +++ b/frame/contracts/src/weights.rs @@ -1028,11 +1028,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_reentrant_count(r: u32, ) -> Weight { - (304_709_000 as Weight) + Weight::from_ref_time(304_709_000 as u64) // Standard Error: 67_000 - .saturating_add((15_411_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(15_411_000 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -1040,11 +1040,11 @@ impl WeightInfo for SubstrateWeight { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_account_entrance_count(r: u32, ) -> Weight { - (328_378_000 as Weight) + Weight::from_ref_time(328_378_000 as u64) // Standard Error: 137_000 - .saturating_add((37_448_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(37_448_000 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } /// The range of component `r` is `[0, 50]`. fn instr_i64const(r: u32, ) -> Weight { @@ -2268,11 +2268,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_reentrant_count(r: u32, ) -> Weight { - (304_709_000 as Weight) + Weight::from_ref_time(304_709_000 as u64) // Standard Error: 67_000 - .saturating_add((15_411_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(15_411_000 as u64).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(4 as u64)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:0) // Storage: Contracts ContractInfoOf (r:1 w:1) @@ -2280,11 +2280,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_account_entrance_count(r: u32, ) -> Weight { - (328_378_000 as Weight) + Weight::from_ref_time(328_378_000 as u64) // Standard Error: 137_000 - .saturating_add((37_448_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(37_448_000 as u64).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(4 as u64)) + .saturating_add(RocksDbWeight::get().writes(1 as u64)) } /// The range of component `r` is `[0, 50]`. fn instr_i64const(r: u32, ) -> Weight { From 1649d3715cfe4009d7f16b5fceda7d21e2b7de63 Mon Sep 17 00:00:00 2001 From: Artemka374 Date: Sat, 5 Nov 2022 20:26:37 +0200 Subject: [PATCH 23/25] apply suggestions --- .../fixtures/account_entrance_count_call.wat | 4 +--- frame/contracts/src/tests.rs | 4 +++- frame/contracts/src/wasm/runtime.rs | 16 ++++------------ 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/frame/contracts/fixtures/account_entrance_count_call.wat b/frame/contracts/fixtures/account_entrance_count_call.wat index 5c929c0b93b4a..879a61585f7f5 100644 --- a/frame/contracts/fixtures/account_entrance_count_call.wat +++ b/frame/contracts/fixtures/account_entrance_count_call.wat @@ -21,9 +21,7 @@ ) (func (export "call") - (local $account_entrance_count i32) - - ;; Reading "callee" contract address + ;; Reading input address (call $seal_input (i32.const 0) (i32.const 32)) (i32.store diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index f7351cd760187..3b44a280095c3 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -4444,7 +4444,6 @@ fn reentrant_count_works_with_delegated_call() { #[cfg(feature = "unstable-interface")] fn account_entrance_count_works() { let (wasm, code_hash) = compile_module::("account_entrance_count_call").unwrap(); - let contract_addr = Contracts::contract_address(&ALICE, &code_hash, &[]); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { let _ = Balances::deposit_creating(&ALICE, 1_000_000); @@ -4459,6 +4458,8 @@ fn account_entrance_count_works() { vec![], )); + let contract_addr = Contracts::contract_address(&ALICE, &code_hash, &[]); + let result = Contracts::bare_call( ALICE, contract_addr.clone(), @@ -4473,5 +4474,6 @@ fn account_entrance_count_works() { .unwrap(); assert_eq!(result.data, 1.encode()); + assert_ne!(result.data, 2.encode()); }); } diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index e4a8257c4b9f6..e8ab9c503ba05 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -2465,13 +2465,9 @@ pub mod env { /// Returns 0 when there is no reentrancy. #[unstable] #[prefixed_alias] - fn reentrant_count(ctx: Runtime, out_ptr: u32) -> Result { + fn reentrant_count(ctx: Runtime) -> Result { ctx.charge_gas(RuntimeCosts::ReentrantCount)?; - - let count = ctx.ext.reentrant_count(); - - ctx.write_sandbox_memory(out_ptr, &count.to_le_bytes())?; - Ok(ReturnCode::Success) + Ok(ctx.ext.reentrant_count()) } /// Returns the number of times specified contract exists on the call stack. Delegated calls are @@ -2489,14 +2485,10 @@ pub mod env { fn account_entrance_count( ctx: Runtime, account_ptr: u32, - out_ptr: u32, - ) -> Result { + ) -> Result { ctx.charge_gas(RuntimeCosts::AccountEntranceCount)?; let account_id: <::T as frame_system::Config>::AccountId = ctx.read_sandbox_memory_as(account_ptr)?; - - let count = ctx.ext.account_entrance_count(&account_id); - ctx.write_sandbox_memory(out_ptr, &count.to_le_bytes())?; - Ok(ReturnCode::Success) + Ok(ctx.ext.account_entrance_count(&account_id)) } } From 8d94425e79ef0a61ccf3afbc846116144d8c6e1f Mon Sep 17 00:00:00 2001 From: Artemka374 Date: Mon, 7 Nov 2022 15:45:53 +0200 Subject: [PATCH 24/25] cargo fmt --- .../fixtures/account_entrance_count_call.wat | 2 +- frame/contracts/src/tests.rs | 32 +++++++++++++++---- frame/contracts/src/wasm/runtime.rs | 9 ++---- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/frame/contracts/fixtures/account_entrance_count_call.wat b/frame/contracts/fixtures/account_entrance_count_call.wat index 879a61585f7f5..54313d2235f01 100644 --- a/frame/contracts/fixtures/account_entrance_count_call.wat +++ b/frame/contracts/fixtures/account_entrance_count_call.wat @@ -21,7 +21,7 @@ ) (func (export "call") - ;; Reading input address + ;; Reading "callee" input address (call $seal_input (i32.const 0) (i32.const 32)) (i32.store diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 3b44a280095c3..99c6df3882ecc 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -4406,9 +4406,18 @@ fn reentrant_count_works_with_call() { // passing reentrant count to the input let input = 0.encode(); - Contracts::bare_call(ALICE, contract_addr, 0, GAS_LIMIT, None, input, true, Determinism::Deterministic) - .result - .unwrap(); + Contracts::bare_call( + ALICE, + contract_addr, + 0, + GAS_LIMIT, + None, + input, + true, + Determinism::Deterministic, + ) + .result + .unwrap(); }); } @@ -4434,9 +4443,18 @@ fn reentrant_count_works_with_delegated_call() { // adding a callstack height to the input let input = (code_hash, 1).encode(); - Contracts::bare_call(ALICE, contract_addr.clone(), 0, GAS_LIMIT, None, input, true, Determinism::Deterministic) - .result - .unwrap(); + Contracts::bare_call( + ALICE, + contract_addr.clone(), + 0, + GAS_LIMIT, + None, + input, + true, + Determinism::Deterministic, + ) + .result + .unwrap(); }); } @@ -4468,7 +4486,7 @@ fn account_entrance_count_works() { None, contract_addr.encode(), true, - Determinism::Deterministic + Determinism::Deterministic, ) .result .unwrap(); diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index e8ab9c503ba05..2ab11391b17fb 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -2457,8 +2457,8 @@ pub mod env { } } - /// Returns the number of times the currently executing contract exists on the call stack in addition - /// to the calling instance. + /// Returns the number of times the currently executing contract exists on the call stack in + /// addition to the calling instance. /// /// # Return Value /// @@ -2482,10 +2482,7 @@ pub mod env { /// Returns 0 when the contract does not exist on the call stack. #[unstable] #[prefixed_alias] - fn account_entrance_count( - ctx: Runtime, - account_ptr: u32, - ) -> Result { + fn account_entrance_count(ctx: Runtime, account_ptr: u32) -> Result { ctx.charge_gas(RuntimeCosts::AccountEntranceCount)?; let account_id: <::T as frame_system::Config>::AccountId = ctx.read_sandbox_memory_as(account_ptr)?; From 0e48a2dcffaff3211482c3ea7854c2ff679e8d08 Mon Sep 17 00:00:00 2001 From: Artemka374 Date: Thu, 10 Nov 2022 15:01:04 +0200 Subject: [PATCH 25/25] apply suggestions --- .../fixtures/account_entrance_count_call.wat | 6 +++--- .../fixtures/reentrant_count_call.wat | 8 ++++---- .../reentrant_count_delegated_call.wat | 18 +++++++++--------- frame/contracts/src/benchmarking/mod.rs | 8 ++++---- frame/contracts/src/tests.rs | 1 - frame/contracts/src/wasm/mod.rs | 8 ++++---- frame/contracts/src/wasm/runtime.rs | 4 +--- 7 files changed, 25 insertions(+), 28 deletions(-) diff --git a/frame/contracts/fixtures/account_entrance_count_call.wat b/frame/contracts/fixtures/account_entrance_count_call.wat index 54313d2235f01..3958e43e0dbdb 100644 --- a/frame/contracts/fixtures/account_entrance_count_call.wat +++ b/frame/contracts/fixtures/account_entrance_count_call.wat @@ -1,10 +1,10 @@ -;; This fixture tests if seal_account_entrance_count works as expected +;; This fixture tests if account_entrance_count works as expected ;; testing it with 2 different addresses (module (import "seal0" "seal_input" (func $seal_input (param i32 i32))) (import "seal0" "seal_caller" (func $seal_caller (param i32 i32))) (import "seal0" "seal_return" (func $seal_return (param i32 i32 i32))) - (import "__unstable__" "seal_account_entrance_count" (func $seal_account_entrance_count (param i32) (result i32))) + (import "__unstable__" "account_entrance_count" (func $account_entrance_count (param i32) (result i32))) (import "env" "memory" (memory 1 1)) ;; [0, 32) buffer where input is copied @@ -26,7 +26,7 @@ (i32.store (i32.const 36) - (call $seal_account_entrance_count (i32.const 0)) + (call $account_entrance_count (i32.const 0)) ) (call $seal_return (i32.const 0) (i32.const 36) (i32.const 4)) diff --git a/frame/contracts/fixtures/reentrant_count_call.wat b/frame/contracts/fixtures/reentrant_count_call.wat index c98d58e81b42e..5c358f4912c4f 100644 --- a/frame/contracts/fixtures/reentrant_count_call.wat +++ b/frame/contracts/fixtures/reentrant_count_call.wat @@ -1,10 +1,10 @@ -;; This fixture recursively tests if seal_reentrant_count returns correct reentrant count value when +;; This fixture recursively tests if reentrant_count returns correct reentrant count value when ;; using seal_call to make caller contract call to itself (module (import "seal0" "seal_input" (func $seal_input (param i32 i32))) (import "seal0" "seal_address" (func $seal_address (param i32 i32))) (import "seal1" "seal_call" (func $seal_call (param i32 i32 i64 i32 i32 i32 i32 i32) (result i32))) - (import "__unstable__" "seal_reentrant_count" (func $seal_reentrant_count (result i32))) + (import "__unstable__" "reentrant_count" (func $reentrant_count (result i32))) (import "env" "memory" (memory 1 1)) ;; [0, 32) reserved for $seal_address output @@ -40,11 +40,11 @@ ;; reentrance count is calculated correctly (call $assert - (i32.eq (call $seal_reentrant_count) (get_local $expected_reentrant_count)) + (i32.eq (call $reentrant_count) (get_local $expected_reentrant_count)) ) ;; re-enter 5 times in a row and assert that the reentrant counter works as expected - (i32.eq (call $seal_reentrant_count) (i32.const 5)) + (i32.eq (call $reentrant_count) (i32.const 5)) (if (then) ;; recursion exit case (else diff --git a/frame/contracts/fixtures/reentrant_count_delegated_call.wat b/frame/contracts/fixtures/reentrant_count_delegated_call.wat index 87bbbf9c3b91d..53b4f8023a2d5 100644 --- a/frame/contracts/fixtures/reentrant_count_delegated_call.wat +++ b/frame/contracts/fixtures/reentrant_count_delegated_call.wat @@ -1,15 +1,15 @@ -;; This fixture recursively tests if seal_reentrant_count returns correct reentrant count value when +;; This fixture recursively tests if reentrant_count returns correct reentrant count value when ;; using seal_delegate_call to make caller contract delegate call to itself (module (import "seal0" "seal_input" (func $seal_input (param i32 i32))) (import "seal0" "seal_set_storage" (func $seal_set_storage (param i32 i32 i32))) (import "seal0" "seal_delegate_call" (func $seal_delegate_call (param i32 i32 i32 i32 i32 i32) (result i32))) - (import "__unstable__" "seal_reentrant_count" (func $seal_reentrant_count (result i32))) + (import "__unstable__" "reentrant_count" (func $reentrant_count (result i32))) (import "env" "memory" (memory 1 1)) ;; [0, 32) buffer where code hash is copied - ;; [32, 36) buffer for the call stack high + ;; [32, 36) buffer for the call stack height ;; [36, 40) size of the input buffer (data (i32.const 36) "\24") @@ -23,24 +23,24 @@ ) ) (func (export "call") - (local $callstack_high i32) + (local $callstack_height i32) (local $delegate_call_exit_code i32) ;; Reading input (call $seal_input (i32.const 0) (i32.const 36)) ;; reading passed callstack height - (set_local $callstack_high (i32.load (i32.const 32))) + (set_local $callstack_height (i32.load (i32.const 32))) ;; incrementing callstack height (i32.store (i32.const 32) (i32.add (i32.load (i32.const 32)) (i32.const 1))) ;; reentrance count stays 0 (call $assert - (i32.eq (call $seal_reentrant_count) (i32.const 0)) + (i32.eq (call $reentrant_count) (i32.const 0)) ) - (i32.eq (get_local $callstack_high) (i32.const 5)) + (i32.eq (get_local $callstack_height) (i32.const 5)) (if (then) ;; exit recursion case (else @@ -49,7 +49,7 @@ (call $seal_delegate_call (i32.const 0) ;; Set no call flags (i32.const 0) ;; Pointer to "callee" code_hash. - (i32.const 0) ;; Input is ingored + (i32.const 0) ;; Pointer to the input data (i32.const 36) ;; Length of the input (i32.const 4294967295) ;; u32 max sentinel value: do not copy output (i32.const 0) ;; Length is ignored in this case @@ -63,7 +63,7 @@ ) (call $assert - (i32.le_s (get_local $callstack_high) (i32.const 5)) + (i32.le_s (get_local $callstack_height) (i32.const 5)) ) ) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 2e062f4ad2de6..832e7e398f409 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -2086,13 +2086,13 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) - seal_reentrant_count { + reentrant_count { let r in 0 .. API_BENCHMARK_BATCHES; let code = WasmModule::::from(ModuleDefinition { memory: Some(ImportedMemory::max::()), imported_functions: vec![ImportedFunction { module: "__unstable__", - name: "seal_reentrant_count", + name: "reentrant_count", params: vec![], return_type: Some(ValueType::I32), }], @@ -2106,7 +2106,7 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) - seal_account_entrance_count { + account_entrance_count { let r in 0 .. API_BENCHMARK_BATCHES; let dummy_code = WasmModule::::dummy_with_bytes(0); let accounts = (0..r * API_BENCHMARK_BATCH_SIZE) @@ -2118,7 +2118,7 @@ benchmarks! { memory: Some(ImportedMemory::max::()), imported_functions: vec![ImportedFunction { module: "__unstable__", - name: "seal_account_entrance_count", + name: "account_entrance_count", params: vec![ValueType::I32], return_type: Some(ValueType::I32), }], diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 99c6df3882ecc..9d873a7b0a44d 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -4492,6 +4492,5 @@ fn account_entrance_count_works() { .unwrap(); assert_eq!(result.data, 1.encode()); - assert_ne!(result.data, 2.encode()); }); } diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index d13977fe1a4fc..3a8972a2fc034 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -2989,7 +2989,7 @@ mod tests { fn reentrant_count_works() { const CODE: &str = r#" (module - (import "__unstable__" "seal_reentrant_count" (func $seal_reentrant_count (result i32))) + (import "__unstable__" "reentrant_count" (func $reentrant_count (result i32))) (import "env" "memory" (memory 1 1)) (func $assert (param i32) (block $ok @@ -3002,7 +3002,7 @@ mod tests { (func (export "call") (local $return_val i32) (set_local $return_val - (call $seal_reentrant_count) + (call $reentrant_count) ) (call $assert (i32.eq (get_local $return_val) (i32.const 12)) @@ -3022,7 +3022,7 @@ mod tests { fn account_entrance_count_works() { const CODE: &str = r#" (module - (import "__unstable__" "seal_account_entrance_count" (func $seal_account_entrance_count (param i32) (result i32))) + (import "__unstable__" "account_entrance_count" (func $account_entrance_count (param i32) (result i32))) (import "env" "memory" (memory 1 1)) (func $assert (param i32) (block $ok @@ -3035,7 +3035,7 @@ mod tests { (func (export "call") (local $return_val i32) (set_local $return_val - (call $seal_account_entrance_count (i32.const 0)) + (call $account_entrance_count (i32.const 0)) ) (call $assert (i32.eq (get_local $return_val) (i32.const 12)) diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index 2ab11391b17fb..d9c25eb23e679 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -2464,14 +2464,13 @@ pub mod env { /// /// Returns 0 when there is no reentrancy. #[unstable] - #[prefixed_alias] fn reentrant_count(ctx: Runtime) -> Result { ctx.charge_gas(RuntimeCosts::ReentrantCount)?; Ok(ctx.ext.reentrant_count()) } /// Returns the number of times specified contract exists on the call stack. Delegated calls are - /// not calculated as separate calls. + /// not counted as separate calls. /// /// # Parameters /// @@ -2481,7 +2480,6 @@ pub mod env { /// /// Returns 0 when the contract does not exist on the call stack. #[unstable] - #[prefixed_alias] fn account_entrance_count(ctx: Runtime, account_ptr: u32) -> Result { ctx.charge_gas(RuntimeCosts::AccountEntranceCount)?; let account_id: <::T as frame_system::Config>::AccountId =