From 31ab53712597193e3ad3de12a84d2b65cbd5acdd Mon Sep 17 00:00:00 2001 From: pgherveou Date: Fri, 24 Mar 2023 09:33:43 +0100 Subject: [PATCH 01/43] [Contracts review] Overflowing bounded `DeletionQueue` allows DoS against contract termination --- frame/contracts/src/lib.rs | 116 ++++++++++++++++++++------------- frame/contracts/src/storage.rs | 25 ++++--- 2 files changed, 81 insertions(+), 60 deletions(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index cd4b7daa6da0f..cac394cb61e1f 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -106,7 +106,7 @@ use crate::{ wasm::{OwnerInfo, PrefabWasmModule, TryInstantiate}, weights::WeightInfo, }; -use codec::{Codec, Encode, HasCompact}; +use codec::{Codec, Decode, Encode, HasCompact, MaxEncodedLen}; use environmental::*; use frame_support::{ dispatch::{Dispatchable, GetDispatchInfo, Pays, PostDispatchInfo}, @@ -245,24 +245,6 @@ pub mod pallet { /// memory usage of your runtime. type CallStack: Array>; - /// The maximum number of contracts that can be pending for deletion. - /// - /// When a contract is deleted by calling `seal_terminate` it becomes inaccessible - /// immediately, but the deletion of the storage items it has accumulated is performed - /// later. The contract is put into the deletion queue. This defines how many - /// contracts can be queued up at the same time. If that limit is reached `seal_terminate` - /// will fail. The action must be retried in a later block in that case. - /// - /// The reasons for limiting the queue depth are: - /// - /// 1. The queue is in storage in order to be persistent between blocks. We want to limit - /// the amount of storage that can be consumed. - /// 2. The queue is stored in a vector and needs to be decoded as a whole when reading - /// it at the end of each block. Longer queues take more weight to decode and hence - /// limit the amount of items that can be deleted per block. - #[pallet::constant] - type DeletionQueueDepth: Get; - /// The maximum amount of weight that can be consumed per block for lazy trie removal. /// /// The amount of weight that is dedicated per block to work on the deletion queue. Larger @@ -329,25 +311,6 @@ pub mod pallet { .saturating_add(T::WeightInfo::on_process_deletion_queue_batch()) } - fn on_initialize(_block: T::BlockNumber) -> Weight { - // We want to process the deletion_queue in the on_idle hook. Only in the case - // that the queue length has reached its maximal depth, we process it here. - let max_len = T::DeletionQueueDepth::get() as usize; - let queue_len = >::decode_len().unwrap_or(0); - if queue_len >= max_len { - // We do not want to go above the block limit and rather avoid lazy deletion - // in that case. This should only happen on runtime upgrades. - let weight_limit = T::BlockWeights::get() - .max_block - .saturating_sub(System::::block_weight().total()) - .min(T::DeletionWeightLimit::get()); - ContractInfo::::process_deletion_queue_batch(weight_limit) - .saturating_add(T::WeightInfo::on_process_deletion_queue_batch()) - } else { - T::WeightInfo::on_process_deletion_queue_batch() - } - } - fn integrity_test() { // Total runtime memory is expected to have 128Mb upper limit const MAX_RUNTIME_MEM: u32 = 1024 * 1024 * 128; @@ -860,12 +823,6 @@ pub mod pallet { /// in this error. Note that this usually shouldn't happen as deploying such contracts /// is rejected. NoChainExtension, - /// Removal of a contract failed because the deletion queue is full. - /// - /// This can happen when calling `seal_terminate`. - /// The queue is filled by deleting contracts and emptied by a fixed amount each block. - /// Trying again during another block is the only way to resolve this issue. - DeletionQueueFull, /// A contract with the same AccountId already exists. DuplicateContract, /// A contract self destructed in its constructor. @@ -951,8 +908,75 @@ pub mod pallet { /// Child trie deletion is a heavy operation depending on the amount of storage items /// stored in said trie. Therefore this operation is performed lazily in `on_initialize`. #[pallet::storage] - pub(crate) type DeletionQueue = - StorageValue<_, BoundedVec, ValueQuery>; + pub(crate) type DeletionQueueMap = StorageMap<_, Twox64Concat, u64, DeletedContract>; + + #[pallet::storage] + pub(crate) type DeletionQueueNonce = + StorageValue<_, DeletionQueueNonces, ValueQuery>; +} + +#[derive(Encode, Decode, TypeInfo, MaxEncodedLen, Clone, Default)] +struct DeletionQueueNonces { + insert_nonce: u64, + delete_nonce: u64, +} + +impl DeletionQueueNonces { + fn delete_plus_one(&mut self) -> &mut Self { + self.delete_nonce.saturating_plus_one(); + self + } + + fn insert_plus_one(&mut self) -> &mut Self { + self.insert_nonce.saturating_plus_one(); + self + } +} + +struct DeletionQueue { + nonces: DeletionQueueNonces, + _phantom: PhantomData, +} +// +struct DeletionQueueEntry<'a, T: Config> { + contract: DeletedContract, + queue: &'a mut DeletionQueue, +} + +impl<'a, T: Config> DeletionQueueEntry<'a, T> { + fn get(&self) -> &DeletedContract { + &self.contract + } + + fn remove(self) { + >::remove(self.queue.nonces.delete_nonce); + >::set(self.queue.nonces.delete_plus_one().clone()); + } +} + +impl DeletionQueue { + fn load() -> Self { + let nonces = >::get(); + Self { nonces, _phantom: PhantomData } + } + + fn len(&self) -> u64 { + self.nonces.insert_nonce - self.nonces.delete_nonce + } + + fn is_empty(&self) -> bool { + self.nonces.insert_nonce == self.nonces.delete_nonce + } + + fn insert(&mut self, contract: DeletedContract) { + >::insert(self.nonces.insert_nonce, contract); + >::set(self.nonces.insert_plus_one().clone()); + } + + fn next(&mut self) -> DeletionQueueEntry { + let contract = >::get(self.nonces.delete_nonce).unwrap(); // TODO + DeletionQueueEntry { contract, queue: self } + } } /// Context of a contract invocation. diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index 19c5f391d670b..7f5cbdb3a84e7 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -205,20 +205,20 @@ impl ContractInfo { /// /// You must make sure that the contract is also removed when queuing the trie for deletion. pub fn queue_trie_for_deletion(&self) -> DispatchResult { - >::try_append(DeletedContract { trie_id: self.trie_id.clone() }) - .map_err(|_| >::DeletionQueueFull.into()) + DeletionQueue::::load().insert(DeletedContract { trie_id: self.trie_id.clone() }); + Ok(()) } /// Calculates the weight that is necessary to remove one key from the trie and how many /// of those keys can be deleted from the deletion queue given the supplied queue length /// and weight limit. - pub fn deletion_budget(queue_len: usize, weight_limit: Weight) -> (Weight, u32) { + pub fn deletion_budget(queue_len: u64, weight_limit: Weight) -> (Weight, u32) { let base_weight = T::WeightInfo::on_process_deletion_queue_batch(); let weight_per_queue_item = T::WeightInfo::on_initialize_per_queue_item(1) - T::WeightInfo::on_initialize_per_queue_item(0); let weight_per_key = T::WeightInfo::on_initialize_per_trie_key(1) - T::WeightInfo::on_initialize_per_trie_key(0); - let decoding_weight = weight_per_queue_item.saturating_mul(queue_len as u64); + let decoding_weight = weight_per_queue_item.saturating_mul(queue_len); // `weight_per_key` being zero makes no sense and would constitute a failure to // benchmark properly. We opt for not removing any keys at all in this case. @@ -235,11 +235,13 @@ impl ContractInfo { /// /// It returns the amount of weight used for that task. pub fn process_deletion_queue_batch(weight_limit: Weight) -> Weight { - let queue_len = >::decode_len().unwrap_or(0); + let mut queue = >::load(); + let queue_len = queue.len(); + if queue_len == 0 { return Weight::zero() } - + // let (weight_per_key, mut remaining_key_budget) = Self::deletion_budget(queue_len, weight_limit); @@ -250,14 +252,11 @@ impl ContractInfo { return weight_limit } - let mut queue = >::get(); - while !queue.is_empty() && remaining_key_budget > 0 { - // Cannot panic due to loop condition - let trie = &mut queue[0]; + let entry = queue.next(); #[allow(deprecated)] let outcome = child::kill_storage( - &ChildInfo::new_default(&trie.trie_id), + &ChildInfo::new_default(&entry.get().trie_id), Some(remaining_key_budget), ); let keys_removed = match outcome { @@ -266,14 +265,12 @@ impl ContractInfo { KillStorageResult::AllRemoved(c) => { // We do not care to preserve order. The contract is deleted already and // no one waits for the trie to be deleted. - queue.swap_remove(0); + entry.remove(); c }, }; remaining_key_budget = remaining_key_budget.saturating_sub(keys_removed); } - - >::put(queue); weight_limit.saturating_sub(weight_per_key.saturating_mul(u64::from(remaining_key_budget))) } From 8a0b92f85250741cebd8779b1f0d73d0bf411acb Mon Sep 17 00:00:00 2001 From: pgherveou Date: Fri, 24 Mar 2023 09:44:43 +0100 Subject: [PATCH 02/43] wip --- frame/contracts/src/storage.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index 7f5cbdb3a84e7..fdbc9eaef2bf6 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -209,6 +209,7 @@ impl ContractInfo { Ok(()) } + /// TODO revisit this /// Calculates the weight that is necessary to remove one key from the trie and how many /// of those keys can be deleted from the deletion queue given the supplied queue length /// and weight limit. @@ -241,10 +242,11 @@ impl ContractInfo { if queue_len == 0 { return Weight::zero() } - // + let (weight_per_key, mut remaining_key_budget) = Self::deletion_budget(queue_len, weight_limit); + // TODO revisit this // We want to check whether we have enough weight to decode the queue before // proceeding. Too little weight for decoding might happen during runtime upgrades // which consume the whole block before the other `on_initialize` blocks are called. @@ -271,6 +273,7 @@ impl ContractInfo { }; remaining_key_budget = remaining_key_budget.saturating_sub(keys_removed); } + weight_limit.saturating_sub(weight_per_key.saturating_mul(u64::from(remaining_key_budget))) } From 10cccfd0fe5fdd6b520c6818ebc11ec515f193f8 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Fri, 24 Mar 2023 09:49:31 +0100 Subject: [PATCH 03/43] wip --- frame/contracts/src/storage.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index fdbc9eaef2bf6..3a087925d4e33 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -263,10 +263,11 @@ impl ContractInfo { ); let keys_removed = match outcome { // This happens when our budget wasn't large enough to remove all keys. - KillStorageResult::SomeRemaining(c) => c, + KillStorageResult::SomeRemaining(c) => { + // TODO revisit this ensure that we break, after this since + c + }, KillStorageResult::AllRemoved(c) => { - // We do not care to preserve order. The contract is deleted already and - // no one waits for the trie to be deleted. entry.remove(); c }, From 329fe92222804cf4ace37238e235d959ce386093 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Mon, 27 Mar 2023 08:59:18 +0200 Subject: [PATCH 04/43] wip --- frame/contracts/src/benchmarking/mod.rs | 1 + frame/contracts/src/lib.rs | 56 ++++++++++++++++--------- frame/contracts/src/migration.rs | 30 ++++++++++++- frame/contracts/src/storage.rs | 23 +++++----- 4 files changed, 78 insertions(+), 32 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 5494b57b65a2a..e80bfb456c178 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -219,6 +219,7 @@ benchmarks! { ContractInfo::::process_deletion_queue_batch(Weight::MAX) } + // TODO simplify this #[pov_mode = Measured] on_initialize_per_queue_item { let q in 0..1024.min(T::DeletionQueueDepth::get()); diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index cac394cb61e1f..b5bbf4fb488ed 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -906,10 +906,12 @@ pub mod pallet { /// Evicted contracts that await child trie deletion. /// /// Child trie deletion is a heavy operation depending on the amount of storage items - /// stored in said trie. Therefore this operation is performed lazily in `on_initialize`. + /// stored in said trie. Therefore this operation is performed lazily in `on_idle`. #[pallet::storage] pub(crate) type DeletionQueueMap = StorageMap<_, Twox64Concat, u64, DeletedContract>; + /// A pair of monotonic counters used to index the latest contract marked for deletion + /// and the latest deleted contract #[pallet::storage] pub(crate) type DeletionQueueNonce = StorageValue<_, DeletionQueueNonces, ValueQuery>; @@ -917,65 +919,81 @@ pub mod pallet { #[derive(Encode, Decode, TypeInfo, MaxEncodedLen, Clone, Default)] struct DeletionQueueNonces { + /// Monotonic counter used as a key for inserting new deleted contract in the DeletionQueueMap. + /// The nonce is incremented after each insertion insert_nonce: u64, + /// the index used to read the next element to be deleted + /// the nonce is incremented after each deletion delete_nonce: u64, } impl DeletionQueueNonces { - fn delete_plus_one(&mut self) -> &mut Self { - self.delete_nonce.saturating_plus_one(); - self + /// increment the delete nonce and return the new value + fn delete_inc(&mut self) -> Self { + self.delete_nonce = self.delete_nonce.wrapping_add(1); + self.clone() } - fn insert_plus_one(&mut self) -> &mut Self { - self.insert_nonce.saturating_plus_one(); - self + /// increment the insert nonce and return the new value + fn insert_inc(&mut self) -> Self { + self.insert_nonce = self.insert_nonce.wrapping_add(1); + self.clone() } } +/// Utility struct to manage the deletion queue struct DeletionQueue { nonces: DeletionQueueNonces, _phantom: PhantomData, } -// + +/// View on a contract that is marked for deletion +/// The struct takes a mutable reference to the deletion queue so that the contract can be removed, +/// and none can be added in the meantime. struct DeletionQueueEntry<'a, T: Config> { contract: DeletedContract, queue: &'a mut DeletionQueue, } impl<'a, T: Config> DeletionQueueEntry<'a, T> { - fn get(&self) -> &DeletedContract { + /// Get a reference to the contract that is marked for deletion. + fn contract(&self) -> &DeletedContract { &self.contract } + /// Remove the contract from the deletion queue. fn remove(self) { >::remove(self.queue.nonces.delete_nonce); - >::set(self.queue.nonces.delete_plus_one().clone()); + >::set(self.queue.nonces.delete_inc()); } } impl DeletionQueue { + /// Load the Deletion Queue nonces. fn load() -> Self { let nonces = >::get(); Self { nonces, _phantom: PhantomData } } + /// The number of contracts marked for deletion. fn len(&self) -> u64 { - self.nonces.insert_nonce - self.nonces.delete_nonce - } - - fn is_empty(&self) -> bool { - self.nonces.insert_nonce == self.nonces.delete_nonce + self.nonces.insert_nonce.wrapping_sub(self.nonces.insert_nonce) } + /// Insert a contract in the deletion queue. fn insert(&mut self, contract: DeletedContract) { >::insert(self.nonces.insert_nonce, contract); - >::set(self.nonces.insert_plus_one().clone()); + >::set(self.nonces.insert_inc()); } - fn next(&mut self) -> DeletionQueueEntry { - let contract = >::get(self.nonces.delete_nonce).unwrap(); // TODO - DeletionQueueEntry { contract, queue: self } + /// Fetch the next contract to be deleted. + fn next(&mut self) -> Option> { + if self.len() == 0 { + return None + } + + >::get(self.nonces.delete_nonce) + .map(|contract| DeletionQueueEntry { contract, queue: self }) } } diff --git a/frame/contracts/src/migration.rs b/frame/contracts/src/migration.rs index 96a4c3203474c..25f051b0985b4 100644 --- a/frame/contracts/src/migration.rs +++ b/frame/contracts/src/migration.rs @@ -59,7 +59,11 @@ impl OnRuntimeUpgrade for Migration { v9::migrate::(&mut weight); } - StorageVersion::new(9).put::>(); + if version < 10 { + v10::migrate::(&mut weight); + } + + StorageVersion::new(10).put::>(); weight.saturating_accrue(T::DbWeight::get().writes(1)); weight @@ -400,6 +404,30 @@ mod v9 { } } +mod v10 { + + use super::*; + use crate::storage::DeletedContract; + + #[storage_alias] + type DeletionQueue = StorageValue, Vec>; + + pub fn migrate(weight: &mut Weight) { + let Some(contracts) = DeletionQueue::::take() else { return }; + weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1)); + + let mut queue = crate::DeletionQueue::::load(); + weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 0)); + + let queue_len = contracts.len() as u64; + for contract in contracts { + queue.insert(contract); + } + + weight.saturating_accrue(T::DbWeight::get().reads_writes(0, queue_len + 1)); + } +} + // Post checks always need to be run against the latest storage version. This is why we // do not scope them in the per version modules. They always need to be ported to the latest // version. diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index 3a087925d4e33..842078ee63ae5 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -209,7 +209,6 @@ impl ContractInfo { Ok(()) } - /// TODO revisit this /// Calculates the weight that is necessary to remove one key from the trie and how many /// of those keys can be deleted from the deletion queue given the supplied queue length /// and weight limit. @@ -246,7 +245,6 @@ impl ContractInfo { let (weight_per_key, mut remaining_key_budget) = Self::deletion_budget(queue_len, weight_limit); - // TODO revisit this // We want to check whether we have enough weight to decode the queue before // proceeding. Too little weight for decoding might happen during runtime upgrades // which consume the whole block before the other `on_initialize` blocks are called. @@ -254,25 +252,26 @@ impl ContractInfo { return weight_limit } - while !queue.is_empty() && remaining_key_budget > 0 { - let entry = queue.next(); + while remaining_key_budget > 0 { + let Some(entry) = queue.next() else { break }; + #[allow(deprecated)] let outcome = child::kill_storage( - &ChildInfo::new_default(&entry.get().trie_id), + &ChildInfo::new_default(&entry.contract().trie_id), Some(remaining_key_budget), ); - let keys_removed = match outcome { + + match outcome { // This happens when our budget wasn't large enough to remove all keys. - KillStorageResult::SomeRemaining(c) => { - // TODO revisit this ensure that we break, after this since - c + KillStorageResult::SomeRemaining(keys_removed) => { + remaining_key_budget = remaining_key_budget.saturating_sub(keys_removed); + break }, - KillStorageResult::AllRemoved(c) => { + KillStorageResult::AllRemoved(keys_removed) => { entry.remove(); - c + remaining_key_budget = remaining_key_budget.saturating_sub(keys_removed); }, }; - remaining_key_budget = remaining_key_budget.saturating_sub(keys_removed); } weight_limit.saturating_sub(weight_per_key.saturating_mul(u64::from(remaining_key_budget))) From b5495824ff7edf1c212084cc95a7d5cc59c50de2 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Mon, 27 Mar 2023 10:37:13 +0200 Subject: [PATCH 05/43] wip --- bin/node/runtime/src/lib.rs | 2 - frame/contracts/src/benchmarking/mod.rs | 6 +- frame/contracts/src/lib.rs | 47 ++++++++------ frame/contracts/src/storage.rs | 15 +---- frame/contracts/src/tests.rs | 82 ------------------------- 5 files changed, 31 insertions(+), 121 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 48bea5ddc101f..6bd8620c4008d 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1198,7 +1198,6 @@ impl pallet_tips::Config for Runtime { parameter_types! { pub const DepositPerItem: Balance = deposit(1, 0); pub const DepositPerByte: Balance = deposit(0, 1); - pub const DeletionQueueDepth: u32 = 128; // The lazy deletion runs inside on_initialize. pub DeletionWeightLimit: Weight = RuntimeBlockWeights::get() .per_class @@ -1227,7 +1226,6 @@ impl pallet_contracts::Config for Runtime { type WeightPrice = pallet_transaction_payment::Pallet; type WeightInfo = pallet_contracts::weights::SubstrateWeight; type ChainExtension = (); - type DeletionQueueDepth = DeletionQueueDepth; type DeletionWeightLimit = DeletionWeightLimit; type Schedule = Schedule; type AddressGenerator = pallet_contracts::DefaultAddressGenerator; diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index e80bfb456c178..21e23c2458dda 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -219,10 +219,9 @@ benchmarks! { ContractInfo::::process_deletion_queue_batch(Weight::MAX) } - // TODO simplify this #[pov_mode = Measured] on_initialize_per_queue_item { - let q in 0..1024.min(T::DeletionQueueDepth::get()); + let q in 0..1024; for i in 0 .. q { let instance = Contract::::with_index(i, WasmModule::dummy(), vec![])?; instance.info()?.queue_trie_for_deletion()?; @@ -3022,9 +3021,8 @@ benchmarks! { #[cfg(feature = "std")] { let weight_limit = T::DeletionWeightLimit::get(); - let max_queue_depth = T::DeletionQueueDepth::get() as usize; let empty_queue_throughput = ContractInfo::::deletion_budget(0, weight_limit); - let full_queue_throughput = ContractInfo::::deletion_budget(max_queue_depth, weight_limit); + let full_queue_throughput = ContractInfo::::deletion_budget(1024, weight_limit); println!("{:#?}", Schedule::::default()); println!("###############################################"); println!("Lazy deletion weight per key: {}", empty_queue_throughput.0); diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index b5bbf4fb488ed..e770b5a435df7 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -249,7 +249,7 @@ pub mod pallet { /// /// The amount of weight that is dedicated per block to work on the deletion queue. Larger /// values allow more trie keys to be deleted in each block but reduce the amount of - /// weight that is left for transactions. See [`Self::DeletionQueueDepth`] for more + /// weight that is left for transactions. See [`Self::DeletionQueue`] for more /// information about the deletion queue. #[pallet::constant] type DeletionWeightLimit: Get; @@ -908,40 +908,46 @@ pub mod pallet { /// Child trie deletion is a heavy operation depending on the amount of storage items /// stored in said trie. Therefore this operation is performed lazily in `on_idle`. #[pallet::storage] - pub(crate) type DeletionQueueMap = StorageMap<_, Twox64Concat, u64, DeletedContract>; + pub(crate) type DeletionQueueMap = StorageMap<_, Twox64Concat, u32, DeletedContract>; /// A pair of monotonic counters used to index the latest contract marked for deletion - /// and the latest deleted contract + /// and the latest deleted contract in DeletionQueueMap. #[pallet::storage] pub(crate) type DeletionQueueNonce = StorageValue<_, DeletionQueueNonces, ValueQuery>; } -#[derive(Encode, Decode, TypeInfo, MaxEncodedLen, Clone, Default)] +/// DeletionQueueNonces is a pair of monotonic counters used to index contracts marked for deletion, +/// and the latest deleted contract. +#[derive(Encode, Decode, TypeInfo, MaxEncodedLen, Clone, Copy, Default)] struct DeletionQueueNonces { /// Monotonic counter used as a key for inserting new deleted contract in the DeletionQueueMap. - /// The nonce is incremented after each insertion - insert_nonce: u64, - /// the index used to read the next element to be deleted - /// the nonce is incremented after each deletion - delete_nonce: u64, + /// The nonce is incremented after each insertion. + insert_nonce: u32, + /// The index used to read the next element to be deleted in the DeletionQueueMap. + /// The nonce is incremented after each deletion. + delete_nonce: u32, } impl DeletionQueueNonces { - /// increment the delete nonce and return the new value - fn delete_inc(&mut self) -> Self { + /// Increment the delete nonce and return the new value. + fn delete_inc(&mut self) -> &mut Self { self.delete_nonce = self.delete_nonce.wrapping_add(1); - self.clone() + self } - /// increment the insert nonce and return the new value - fn insert_inc(&mut self) -> Self { + /// Increment the insert nonce and return the new value. + fn insert_inc(&mut self) -> &mut Self { self.insert_nonce = self.insert_nonce.wrapping_add(1); - self.clone() + self } } -/// Utility struct to manage the deletion queue +/// DeletionQueue manage the removal of contracts storage that are marked for deletion. +/// +/// When a contract is deleted by calling `seal_terminate` it becomes inaccessible +/// immediately, but the deletion of the storage items it has accumulated is performed +/// later. struct DeletionQueue { nonces: DeletionQueueNonces, _phantom: PhantomData, @@ -964,26 +970,27 @@ impl<'a, T: Config> DeletionQueueEntry<'a, T> { /// Remove the contract from the deletion queue. fn remove(self) { >::remove(self.queue.nonces.delete_nonce); - >::set(self.queue.nonces.delete_inc()); + >::set(*self.queue.nonces.delete_inc()); } } impl DeletionQueue { - /// Load the Deletion Queue nonces. + /// Load the Deletion Queue nonces, so we can perform read or write operations on the + /// DeletionQueueMap storage fn load() -> Self { let nonces = >::get(); Self { nonces, _phantom: PhantomData } } /// The number of contracts marked for deletion. - fn len(&self) -> u64 { + fn len(&self) -> u32 { self.nonces.insert_nonce.wrapping_sub(self.nonces.insert_nonce) } /// Insert a contract in the deletion queue. fn insert(&mut self, contract: DeletedContract) { >::insert(self.nonces.insert_nonce, contract); - >::set(self.nonces.insert_inc()); + >::set(*self.nonces.insert_inc()); } /// Fetch the next contract to be deleted. diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index 842078ee63ae5..93d865db60d95 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -212,13 +212,13 @@ impl ContractInfo { /// Calculates the weight that is necessary to remove one key from the trie and how many /// of those keys can be deleted from the deletion queue given the supplied queue length /// and weight limit. - pub fn deletion_budget(queue_len: u64, weight_limit: Weight) -> (Weight, u32) { + pub fn deletion_budget(queue_len: u32, weight_limit: Weight) -> (Weight, u32) { let base_weight = T::WeightInfo::on_process_deletion_queue_batch(); let weight_per_queue_item = T::WeightInfo::on_initialize_per_queue_item(1) - T::WeightInfo::on_initialize_per_queue_item(0); let weight_per_key = T::WeightInfo::on_initialize_per_trie_key(1) - T::WeightInfo::on_initialize_per_trie_key(0); - let decoding_weight = weight_per_queue_item.saturating_mul(queue_len); + let decoding_weight = weight_per_queue_item.saturating_mul(queue_len as u64); // `weight_per_key` being zero makes no sense and would constitute a failure to // benchmark properly. We opt for not removing any keys at all in this case. @@ -281,17 +281,6 @@ impl ContractInfo { pub fn load_code_hash(account: &AccountIdOf) -> Option> { >::get(account).map(|i| i.code_hash) } - - /// Fill up the queue in order to exercise the limits during testing. - #[cfg(test)] - pub fn fill_queue_with_dummies() { - use frame_support::{traits::Get, BoundedVec}; - let queue: Vec = (0..T::DeletionQueueDepth::get()) - .map(|_| DeletedContract { trie_id: TrieId::default() }) - .collect(); - let bounded: BoundedVec<_, _> = queue.try_into().map_err(|_| ()).unwrap(); - >::put(bounded); - } } #[derive(Encode, Decode, TypeInfo, MaxEncodedLen)] diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 146e5fd24ad07..f54751076961e 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -399,7 +399,6 @@ impl Config for Test { type WeightInfo = (); type ChainExtension = (TestExtension, DisabledExtension, RevertingExtension, TempStorageExtension); - type DeletionQueueDepth = ConstU32<1024>; type DeletionWeightLimit = DeletionWeightLimit; type Schedule = MySchedule; type DepositPerByte = DepositPerByte; @@ -1972,25 +1971,6 @@ fn lazy_removal_works() { }); } -#[test] -fn lazy_removal_on_full_queue_works_on_initialize() { - ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - // Fill the deletion queue with dummy values, so that on_initialize attempts - // to clear the queue - ContractInfo::::fill_queue_with_dummies(); - - let queue_len_initial = >::decode_len().unwrap_or(0); - - // Run the lazy removal - Contracts::on_initialize(System::block_number()); - - let queue_len_after_on_initialize = >::decode_len().unwrap_or(0); - - // Queue length should be decreased after call of on_initialize() - assert!(queue_len_initial - queue_len_after_on_initialize > 0); - }); -} - #[test] fn lazy_batch_removal_works() { let (code, _hash) = compile_module::("self_destruct").unwrap(); @@ -2139,33 +2119,6 @@ fn lazy_removal_partial_remove_works() { }); } -#[test] -fn lazy_removal_does_no_run_on_full_queue_and_full_block() { - ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - // Fill up the block which should prevent the lazy storage removal from running. - System::register_extra_weight_unchecked( - ::BlockWeights::get().max_block, - DispatchClass::Mandatory, - ); - - // Fill the deletion queue with dummy values, so that on_initialize attempts - // to clear the queue - ContractInfo::::fill_queue_with_dummies(); - - // Check that on_initialize() tries to perform lazy removal but removes nothing - // as no more weight is left for that. - let weight_used = Contracts::on_initialize(System::block_number()); - let base = <::WeightInfo as WeightInfo>::on_process_deletion_queue_batch(); - assert_eq!(weight_used, base); - - // Check that the deletion queue is still full after execution of the - // on_initialize() hook. - let max_len: u32 = ::DeletionQueueDepth::get(); - let queue_len: u32 = >::decode_len().unwrap_or(0).try_into().unwrap(); - assert_eq!(max_len, queue_len); - }); -} - #[test] fn lazy_removal_does_no_run_on_low_remaining_weight() { let (code, _hash) = compile_module::("self_destruct").unwrap(); @@ -2313,41 +2266,6 @@ fn lazy_removal_does_not_use_all_weight() { }); } -#[test] -fn deletion_queue_full() { - let (code, _hash) = compile_module::("self_destruct").unwrap(); - ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); - let _ = Balances::deposit_creating(&ALICE, 1000 * min_balance); - - let addr = Contracts::bare_instantiate( - ALICE, - min_balance * 100, - GAS_LIMIT, - None, - Code::Upload(code), - vec![], - vec![], - false, - ) - .result - .unwrap() - .account_id; - - // fill the deletion queue up until its limit - ContractInfo::::fill_queue_with_dummies(); - - // Terminate the contract should fail - assert_err_ignore_postinfo!( - Contracts::call(RuntimeOrigin::signed(ALICE), addr.clone(), 0, GAS_LIMIT, None, vec![],), - Error::::DeletionQueueFull, - ); - - // Contract should exist because removal failed - get_contract(&addr); - }); -} - #[test] fn refcounter() { let (wasm, code_hash) = compile_module::("self_destruct").unwrap(); From 71f01f36a1e3b2e5a0a5d16fcb2a7d186a9c0a97 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Mon, 27 Mar 2023 12:12:56 +0200 Subject: [PATCH 06/43] wip --- frame/contracts/src/lib.rs | 8 ++++---- frame/contracts/src/tests.rs | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index e770b5a435df7..69f87324275d7 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -947,15 +947,15 @@ impl DeletionQueueNonces { /// /// When a contract is deleted by calling `seal_terminate` it becomes inaccessible /// immediately, but the deletion of the storage items it has accumulated is performed -/// later. +/// later by pulling the contract from the deletion queue in the `on_idle` hook. struct DeletionQueue { nonces: DeletionQueueNonces, _phantom: PhantomData, } /// View on a contract that is marked for deletion -/// The struct takes a mutable reference to the deletion queue so that the contract can be removed, -/// and none can be added in the meantime. +/// The struct takes a mutable reference on the deletion queue so that the contract can be removed, +/// and none can be added or read in the meantime. struct DeletionQueueEntry<'a, T: Config> { contract: DeletedContract, queue: &'a mut DeletionQueue, @@ -984,7 +984,7 @@ impl DeletionQueue { /// The number of contracts marked for deletion. fn len(&self) -> u32 { - self.nonces.insert_nonce.wrapping_sub(self.nonces.insert_nonce) + self.nonces.insert_nonce.wrapping_sub(self.nonces.delete_nonce) } /// Insert a contract in the deletion queue. diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index f54751076961e..a2bcf2467ed33 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -26,22 +26,22 @@ use crate::{ wasm::{Determinism, PrefabWasmModule, ReturnCode as RuntimeReturnCode}, weights::WeightInfo, BalanceOf, Code, CodeStorage, Config, ContractInfo, ContractInfoOf, DefaultAddressGenerator, - DeletionQueue, Error, Pallet, Schedule, + Error, Pallet, Schedule, }; use assert_matches::assert_matches; use codec::Encode; use frame_support::{ assert_err, assert_err_ignore_postinfo, assert_noop, assert_ok, - dispatch::{DispatchClass, DispatchErrorWithPostInfo, PostDispatchInfo}, + dispatch::{DispatchErrorWithPostInfo, PostDispatchInfo}, parameter_types, storage::child, traits::{ - ConstU32, ConstU64, Contains, Currency, ExistenceRequirement, Get, LockableCurrency, - OnIdle, OnInitialize, WithdrawReasons, + ConstU32, ConstU64, Contains, Currency, ExistenceRequirement, LockableCurrency, OnIdle, + OnInitialize, WithdrawReasons, }, weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight}, }; -use frame_system::{self as system, EventRecord, Phase}; +use frame_system::{EventRecord, Phase}; use pretty_assertions::{assert_eq, assert_ne}; use sp_io::hashing::blake2_256; use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; From aed8821c061abd11f3910f1811afa769c4b170f8 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Mon, 27 Mar 2023 12:21:51 +0200 Subject: [PATCH 07/43] fix doc --- frame/contracts/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 69f87324275d7..4a40094163894 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -249,8 +249,7 @@ pub mod pallet { /// /// The amount of weight that is dedicated per block to work on the deletion queue. Larger /// values allow more trie keys to be deleted in each block but reduce the amount of - /// weight that is left for transactions. See [`Self::DeletionQueue`] for more - /// information about the deletion queue. + /// weight that is left for transactions. #[pallet::constant] type DeletionWeightLimit: Get; From 85cca3abe003d8e4ac2e7bb2c366c2b827a949fd Mon Sep 17 00:00:00 2001 From: pgherveou Date: Mon, 27 Mar 2023 12:45:06 +0200 Subject: [PATCH 08/43] wip --- frame/contracts/src/migration.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/frame/contracts/src/migration.rs b/frame/contracts/src/migration.rs index 25f051b0985b4..06e38afddd878 100644 --- a/frame/contracts/src/migration.rs +++ b/frame/contracts/src/migration.rs @@ -405,7 +405,6 @@ mod v9 { } mod v10 { - use super::*; use crate::storage::DeletedContract; From 1d27eeb76073e39b55b08404b66583c8827b1737 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Mon, 27 Mar 2023 22:54:10 +0200 Subject: [PATCH 09/43] PR review --- bin/node/runtime/src/lib.rs | 7 -- frame/contracts/src/benchmarking/mod.rs | 2 +- frame/contracts/src/lib.rs | 109 ++---------------------- frame/contracts/src/migration.rs | 29 +------ frame/contracts/src/storage.rs | 84 +++++++++++++++++- frame/contracts/src/tests.rs | 5 +- 6 files changed, 94 insertions(+), 142 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 6bd8620c4008d..5562dc263ddc8 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1198,12 +1198,6 @@ impl pallet_tips::Config for Runtime { parameter_types! { pub const DepositPerItem: Balance = deposit(1, 0); pub const DepositPerByte: Balance = deposit(0, 1); - // The lazy deletion runs inside on_initialize. - pub DeletionWeightLimit: Weight = RuntimeBlockWeights::get() - .per_class - .get(DispatchClass::Normal) - .max_total - .unwrap_or(RuntimeBlockWeights::get().max_block); pub Schedule: pallet_contracts::Schedule = Default::default(); } @@ -1226,7 +1220,6 @@ impl pallet_contracts::Config for Runtime { type WeightPrice = pallet_transaction_payment::Pallet; type WeightInfo = pallet_contracts::weights::SubstrateWeight; type ChainExtension = (); - type DeletionWeightLimit = DeletionWeightLimit; type Schedule = Schedule; type AddressGenerator = pallet_contracts::DefaultAddressGenerator; type MaxCodeLen = ConstU32<{ 123 * 1024 }>; diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 21e23c2458dda..eeee8385359d4 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -3020,7 +3020,7 @@ benchmarks! { print_schedule { #[cfg(feature = "std")] { - let weight_limit = T::DeletionWeightLimit::get(); + let weight_limit = Weight::from_parts(100_000_000_000, 3 * 1024 * 1024); let empty_queue_throughput = ContractInfo::::deletion_budget(0, weight_limit); let full_queue_throughput = ContractInfo::::deletion_budget(1024, weight_limit); println!("{:#?}", Schedule::::default()); diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 4a40094163894..c5fabf3b66e77 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -102,11 +102,11 @@ mod tests; use crate::{ exec::{AccountIdOf, ErrorOrigin, ExecError, Executable, Key, Stack as ExecStack}, gas::GasMeter, - storage::{meter::Meter as StorageMeter, ContractInfo, DeletedContract}, + storage::{meter::Meter as StorageMeter, ContractInfo, DeletedContract, DeletionQueue}, wasm::{OwnerInfo, PrefabWasmModule, TryInstantiate}, weights::WeightInfo, }; -use codec::{Codec, Decode, Encode, HasCompact, MaxEncodedLen}; +use codec::{Codec, Encode, HasCompact}; use environmental::*; use frame_support::{ dispatch::{Dispatchable, GetDispatchInfo, Pays, PostDispatchInfo}, @@ -245,14 +245,6 @@ pub mod pallet { /// memory usage of your runtime. type CallStack: Array>; - /// The maximum amount of weight that can be consumed per block for lazy trie removal. - /// - /// The amount of weight that is dedicated per block to work on the deletion queue. Larger - /// values allow more trie keys to be deleted in each block but reduce the amount of - /// weight that is left for transactions. - #[pallet::constant] - type DeletionWeightLimit: Get; - /// The amount of balance a caller has to pay for each byte of storage. /// /// # Note @@ -909,98 +901,15 @@ pub mod pallet { #[pallet::storage] pub(crate) type DeletionQueueMap = StorageMap<_, Twox64Concat, u32, DeletedContract>; - /// A pair of monotonic counters used to index the latest contract marked for deletion + /// A pair of monotonic counters used to track the latest contract marked for deletion /// and the latest deleted contract in DeletionQueueMap. + /// + /// These two nonces let us keep track of the length of the queue, so we can calculate the + /// weight of the deletion budget, additionally, when we iterate the map to remove contracts, we + /// simply use the `delete_nonce` counter and don't pay the cost of an extra call to + /// `sp_io::storage::next_key` to lookup the next entry in the map #[pallet::storage] - pub(crate) type DeletionQueueNonce = - StorageValue<_, DeletionQueueNonces, ValueQuery>; -} - -/// DeletionQueueNonces is a pair of monotonic counters used to index contracts marked for deletion, -/// and the latest deleted contract. -#[derive(Encode, Decode, TypeInfo, MaxEncodedLen, Clone, Copy, Default)] -struct DeletionQueueNonces { - /// Monotonic counter used as a key for inserting new deleted contract in the DeletionQueueMap. - /// The nonce is incremented after each insertion. - insert_nonce: u32, - /// The index used to read the next element to be deleted in the DeletionQueueMap. - /// The nonce is incremented after each deletion. - delete_nonce: u32, -} - -impl DeletionQueueNonces { - /// Increment the delete nonce and return the new value. - fn delete_inc(&mut self) -> &mut Self { - self.delete_nonce = self.delete_nonce.wrapping_add(1); - self - } - - /// Increment the insert nonce and return the new value. - fn insert_inc(&mut self) -> &mut Self { - self.insert_nonce = self.insert_nonce.wrapping_add(1); - self - } -} - -/// DeletionQueue manage the removal of contracts storage that are marked for deletion. -/// -/// When a contract is deleted by calling `seal_terminate` it becomes inaccessible -/// immediately, but the deletion of the storage items it has accumulated is performed -/// later by pulling the contract from the deletion queue in the `on_idle` hook. -struct DeletionQueue { - nonces: DeletionQueueNonces, - _phantom: PhantomData, -} - -/// View on a contract that is marked for deletion -/// The struct takes a mutable reference on the deletion queue so that the contract can be removed, -/// and none can be added or read in the meantime. -struct DeletionQueueEntry<'a, T: Config> { - contract: DeletedContract, - queue: &'a mut DeletionQueue, -} - -impl<'a, T: Config> DeletionQueueEntry<'a, T> { - /// Get a reference to the contract that is marked for deletion. - fn contract(&self) -> &DeletedContract { - &self.contract - } - - /// Remove the contract from the deletion queue. - fn remove(self) { - >::remove(self.queue.nonces.delete_nonce); - >::set(*self.queue.nonces.delete_inc()); - } -} - -impl DeletionQueue { - /// Load the Deletion Queue nonces, so we can perform read or write operations on the - /// DeletionQueueMap storage - fn load() -> Self { - let nonces = >::get(); - Self { nonces, _phantom: PhantomData } - } - - /// The number of contracts marked for deletion. - fn len(&self) -> u32 { - self.nonces.insert_nonce.wrapping_sub(self.nonces.delete_nonce) - } - - /// Insert a contract in the deletion queue. - fn insert(&mut self, contract: DeletedContract) { - >::insert(self.nonces.insert_nonce, contract); - >::set(*self.nonces.insert_inc()); - } - - /// Fetch the next contract to be deleted. - fn next(&mut self) -> Option> { - if self.len() == 0 { - return None - } - - >::get(self.nonces.delete_nonce) - .map(|contract| DeletionQueueEntry { contract, queue: self }) - } + pub(crate) type DeletionQueueNonces = StorageValue<_, DeletionQueue, ValueQuery>; } /// Context of a contract invocation. diff --git a/frame/contracts/src/migration.rs b/frame/contracts/src/migration.rs index 06e38afddd878..96a4c3203474c 100644 --- a/frame/contracts/src/migration.rs +++ b/frame/contracts/src/migration.rs @@ -59,11 +59,7 @@ impl OnRuntimeUpgrade for Migration { v9::migrate::(&mut weight); } - if version < 10 { - v10::migrate::(&mut weight); - } - - StorageVersion::new(10).put::>(); + StorageVersion::new(9).put::>(); weight.saturating_accrue(T::DbWeight::get().writes(1)); weight @@ -404,29 +400,6 @@ mod v9 { } } -mod v10 { - use super::*; - use crate::storage::DeletedContract; - - #[storage_alias] - type DeletionQueue = StorageValue, Vec>; - - pub fn migrate(weight: &mut Weight) { - let Some(contracts) = DeletionQueue::::take() else { return }; - weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1)); - - let mut queue = crate::DeletionQueue::::load(); - weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 0)); - - let queue_len = contracts.len() as u64; - for contract in contracts { - queue.insert(contract); - } - - weight.saturating_accrue(T::DbWeight::get().reads_writes(0, queue_len + 1)); - } -} - // Post checks always need to be run against the latest storage version. This is why we // do not scope them in the per version modules. They always need to be ported to the latest // version. diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index 93d865db60d95..faf825531e8b6 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -22,8 +22,8 @@ pub mod meter; use crate::{ exec::{AccountIdOf, Key}, weights::WeightInfo, - AddressGenerator, BalanceOf, CodeHash, Config, ContractInfoOf, DeletionQueue, Error, Pallet, - TrieId, SENTINEL, + AddressGenerator, BalanceOf, CodeHash, Config, ContractInfoOf, DeletionQueueMap, + DeletionQueueNonces, Error, Pallet, TrieId, SENTINEL, }; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ @@ -38,7 +38,7 @@ use sp_runtime::{ traits::{Hash, Saturating, Zero}, RuntimeDebug, }; -use sp_std::{ops::Deref, prelude::*}; +use sp_std::{marker::PhantomData, ops::Deref, prelude::*}; /// Information for managing an account and its sub trie abstraction. /// This is the required info to cache for an account. @@ -341,3 +341,81 @@ impl Deref for DepositAccount { &self.0 } } + +/// DeletionQueue manage the removal of contracts storage that are marked for deletion. +/// +/// When a contract is deleted by calling `seal_terminate` it becomes inaccessible +/// immediately, but the deletion of the storage items it has accumulated is performed +/// later by pulling the contract from the queue in the `on_idle` hook. +#[derive(Encode, Decode, TypeInfo, MaxEncodedLen, Clone)] +#[scale_info(skip_type_params(T))] +pub struct DeletionQueue { + /// Monotonic counter used as a key for inserting new deleted contract in the DeletionQueueMap. + /// The nonce is incremented after each insertion. + insert_nonce: u32, + /// The index used to read the next element to be deleted in the DeletionQueueMap. + /// The nonce is incremented after each deletion. + delete_nonce: u32, + + _phantom: PhantomData, +} + +impl Default for DeletionQueue { + fn default() -> Self { + Self { insert_nonce: 0, delete_nonce: 0, _phantom: Default::default() } + } +} + +/// View on a contract that is marked for deletion +/// The struct takes a mutable reference on the deletion queue so that the contract can be removed, +/// and none can be added or read in the meantime. +struct DeletionQueueEntry<'a, T: Config> { + contract: DeletedContract, + queue: &'a mut DeletionQueue, +} + +impl<'a, T: Config> DeletionQueueEntry<'a, T> { + /// Get a reference to the contract that is marked for deletion. + fn contract(&self) -> &DeletedContract { + &self.contract + } + + /// Remove the contract from the deletion queue. + fn remove(self) { + >::remove(self.queue.delete_nonce); + self.queue.delete_nonce = self.queue.delete_nonce.wrapping_add(1); + >::set(self.queue.clone()); + } +} + +impl DeletionQueue { + /// Load the Deletion Queue nonces, so we can perform read or write operations on the + /// DeletionQueueMap storage + fn load() -> Self { + >::get() + } + + /// The number of contracts marked for deletion. + fn len(&self) -> u32 { + self.insert_nonce.wrapping_sub(self.delete_nonce) + } + + /// Insert a contract in the deletion queue. + fn insert(&mut self, contract: DeletedContract) { + >::insert(self.insert_nonce, contract); + self.insert_nonce = self.insert_nonce.wrapping_add(1); + >::set(self.clone()); + } + + /// Fetch the next contract to be deleted. + fn next(&mut self) -> Option> { + if self.len() == 0 { + return None + } + + let entry = >::get(self.delete_nonce); + let entry = entry.map(|contract| DeletionQueueEntry { contract, queue: self }); + + entry + } +} diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index a2bcf2467ed33..cc624ad7051ae 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -383,7 +383,6 @@ impl Contains for TestFilter { } parameter_types! { - pub const DeletionWeightLimit: Weight = GAS_LIMIT; pub static UnstableInterface: bool = true; } @@ -399,7 +398,6 @@ impl Config for Test { type WeightInfo = (); type ChainExtension = (TestExtension, DisabledExtension, RevertingExtension, TempStorageExtension); - type DeletionWeightLimit = DeletionWeightLimit; type Schedule = MySchedule; type DepositPerByte = DepositPerByte; type DepositPerItem = DepositPerItem; @@ -457,7 +455,8 @@ fn compile_module(fixture_name: &str) -> wat::Result<(Vec, Date: Mon, 27 Mar 2023 23:30:18 +0200 Subject: [PATCH 10/43] unbreak tests --- frame/contracts/src/tests.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index cc624ad7051ae..f39f006f0c47b 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -455,8 +455,7 @@ fn compile_module(fixture_name: &str) -> wat::Result<(Vec, Date: Tue, 28 Mar 2023 10:32:04 +0200 Subject: [PATCH 11/43] fixes --- frame/contracts/src/benchmarking/mod.rs | 5 ++--- frame/contracts/src/storage.rs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index eeee8385359d4..e272dfaebe0ca 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -3020,9 +3020,8 @@ benchmarks! { print_schedule { #[cfg(feature = "std")] { - let weight_limit = Weight::from_parts(100_000_000_000, 3 * 1024 * 1024); - let empty_queue_throughput = ContractInfo::::deletion_budget(0, weight_limit); - let full_queue_throughput = ContractInfo::::deletion_budget(1024, weight_limit); + let empty_queue_throughput = ContractInfo::::deletion_budget(0, Weight::MAX); + let full_queue_throughput = ContractInfo::::deletion_budget(1024, Weight::MAX); println!("{:#?}", Schedule::::default()); println!("###############################################"); println!("Lazy deletion weight per key: {}", empty_queue_throughput.0); diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index faf825531e8b6..36b8291fa58e9 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -288,7 +288,7 @@ pub struct DeletedContract { pub(crate) trie_id: TrieId, } -/// Information about what happended to the pre-existing value when calling [`ContractInfo::write`]. +/// Information about what happened to the pre-existing value when calling [`ContractInfo::write`]. #[cfg_attr(test, derive(Debug, PartialEq))] pub enum WriteOutcome { /// No value existed at the specified key. From 2e722bd34deb4471cdfa90d8445f795f3a0326bf Mon Sep 17 00:00:00 2001 From: pgherveou Date: Tue, 28 Mar 2023 15:36:33 +0200 Subject: [PATCH 12/43] update budget computation --- frame/contracts/src/benchmarking/mod.rs | 17 +++----------- frame/contracts/src/lib.rs | 7 +++--- frame/contracts/src/storage.rs | 18 +++++--------- frame/contracts/src/tests.rs | 4 ++-- frame/contracts/src/weights.rs | 31 ------------------------- 5 files changed, 14 insertions(+), 63 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index e272dfaebe0ca..449f02965932c 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -219,18 +219,6 @@ benchmarks! { ContractInfo::::process_deletion_queue_batch(Weight::MAX) } - #[pov_mode = Measured] - on_initialize_per_queue_item { - let q in 0..1024; - for i in 0 .. q { - let instance = Contract::::with_index(i, WasmModule::dummy(), vec![])?; - instance.info()?.queue_trie_for_deletion()?; - ContractInfoOf::::remove(instance.account_id); - } - }: { - ContractInfo::::process_deletion_queue_batch(Weight::MAX) - } - // This benchmarks the additional weight that is charged when a contract is executed the // first time after a new schedule was deployed: For every new schedule a contract needs // to re-run the instrumentation once. @@ -239,6 +227,7 @@ benchmarks! { let c in 0 .. Perbill::from_percent(49).mul_ceil(T::MaxCodeLen::get()); let WasmModule { code, hash, .. } = WasmModule::::sized(c, Location::Call); Contracts::::store_code_raw(code, whitelisted_caller())?; + let schedule = T::Schedule::get(); let mut gas_meter = GasMeter::new(Weight::MAX); let mut module = PrefabWasmModule::from_storage(hash, &schedule, &mut gas_meter)?; @@ -3020,8 +3009,8 @@ benchmarks! { print_schedule { #[cfg(feature = "std")] { - let empty_queue_throughput = ContractInfo::::deletion_budget(0, Weight::MAX); - let full_queue_throughput = ContractInfo::::deletion_budget(1024, Weight::MAX); + let empty_queue_throughput = ContractInfo::::deletion_budget(Weight::MAX); + let full_queue_throughput = ContractInfo::::deletion_budget(Weight::MAX); println!("{:#?}", Schedule::::default()); println!("###############################################"); println!("Lazy deletion weight per key: {}", empty_queue_throughput.0); diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index c5fabf3b66e77..084427fee9ac0 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -904,10 +904,9 @@ pub mod pallet { /// A pair of monotonic counters used to track the latest contract marked for deletion /// and the latest deleted contract in DeletionQueueMap. /// - /// These two nonces let us keep track of the length of the queue, so we can calculate the - /// weight of the deletion budget, additionally, when we iterate the map to remove contracts, we - /// simply use the `delete_nonce` counter and don't pay the cost of an extra call to - /// `sp_io::storage::next_key` to lookup the next entry in the map + /// When we iterate the map to remove contracts, we simply use the `delete_nonce` counter and + /// don't pay the cost of an extra call to `sp_io::storage::next_key` to lookup the next entry + /// in the map #[pallet::storage] pub(crate) type DeletionQueueNonces = StorageValue<_, DeletionQueue, ValueQuery>; } diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index 36b8291fa58e9..b88625d7e1ce5 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -212,19 +212,15 @@ impl ContractInfo { /// Calculates the weight that is necessary to remove one key from the trie and how many /// of those keys can be deleted from the deletion queue given the supplied queue length /// and weight limit. - pub fn deletion_budget(queue_len: u32, weight_limit: Weight) -> (Weight, u32) { + pub fn deletion_budget(weight_limit: Weight) -> (Weight, u32) { let base_weight = T::WeightInfo::on_process_deletion_queue_batch(); - let weight_per_queue_item = T::WeightInfo::on_initialize_per_queue_item(1) - - T::WeightInfo::on_initialize_per_queue_item(0); let weight_per_key = T::WeightInfo::on_initialize_per_trie_key(1) - T::WeightInfo::on_initialize_per_trie_key(0); - let decoding_weight = weight_per_queue_item.saturating_mul(queue_len as u64); // `weight_per_key` being zero makes no sense and would constitute a failure to // benchmark properly. We opt for not removing any keys at all in this case. let key_budget = weight_limit .saturating_sub(base_weight) - .saturating_sub(decoding_weight) .checked_div_per_component(&weight_per_key) .unwrap_or(0) as u32; @@ -236,14 +232,12 @@ impl ContractInfo { /// It returns the amount of weight used for that task. pub fn process_deletion_queue_batch(weight_limit: Weight) -> Weight { let mut queue = >::load(); - let queue_len = queue.len(); - if queue_len == 0 { + if queue.is_empty() { return Weight::zero() } - let (weight_per_key, mut remaining_key_budget) = - Self::deletion_budget(queue_len, weight_limit); + let (weight_per_key, mut remaining_key_budget) = Self::deletion_budget(weight_limit); // We want to check whether we have enough weight to decode the queue before // proceeding. Too little weight for decoding might happen during runtime upgrades @@ -396,8 +390,8 @@ impl DeletionQueue { } /// The number of contracts marked for deletion. - fn len(&self) -> u32 { - self.insert_nonce.wrapping_sub(self.delete_nonce) + fn is_empty(&self) -> bool { + self.insert_nonce.wrapping_sub(self.delete_nonce) == 0 } /// Insert a contract in the deletion queue. @@ -409,7 +403,7 @@ impl DeletionQueue { /// Fetch the next contract to be deleted. fn next(&mut self) -> Option> { - if self.len() == 0 { + if self.is_empty() { return None } diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index f39f006f0c47b..f64a3c40f77e7 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -2032,7 +2032,7 @@ fn lazy_removal_partial_remove_works() { // We create a contract with some extra keys above the weight limit let extra_keys = 7u32; let weight_limit = Weight::from_parts(5_000_000_000, 0); - let (_, max_keys) = ContractInfo::::deletion_budget(1, weight_limit); + let (_, max_keys) = ContractInfo::::deletion_budget(weight_limit); let vals: Vec<_> = (0..max_keys + extra_keys) .map(|i| (blake2_256(&i.encode()), (i as u32), (i as u32).encode())) .collect(); @@ -2210,7 +2210,7 @@ fn lazy_removal_does_not_use_all_weight() { .account_id; let info = get_contract(&addr); - let (weight_per_key, max_keys) = ContractInfo::::deletion_budget(1, weight_limit); + let (weight_per_key, max_keys) = ContractInfo::::deletion_budget(weight_limit); // We create a contract with one less storage item than we can remove within the limit let vals: Vec<_> = (0..max_keys - 1) diff --git a/frame/contracts/src/weights.rs b/frame/contracts/src/weights.rs index dfe6fb20de7bc..0a2d4c0d33b22 100644 --- a/frame/contracts/src/weights.rs +++ b/frame/contracts/src/weights.rs @@ -51,7 +51,6 @@ use sp_std::marker::PhantomData; pub trait WeightInfo { fn on_process_deletion_queue_batch() -> Weight; fn on_initialize_per_trie_key(k: u32, ) -> Weight; - fn on_initialize_per_queue_item(q: u32, ) -> Weight; fn reinstrument(c: u32, ) -> Weight; fn call_with_code_per_byte(c: u32, ) -> Weight; fn instantiate_with_code(c: u32, i: u32, s: u32, ) -> Weight; @@ -198,21 +197,6 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(k.into()))) .saturating_add(Weight::from_parts(0, 70).saturating_mul(k.into())) } - /// Storage: Contracts DeletionQueue (r:1 w:1) - /// Proof: Contracts DeletionQueue (max_values: Some(1), max_size: Some(16642), added: 17137, mode: Measured) - /// The range of component `q` is `[0, 128]`. - fn on_initialize_per_queue_item(q: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `250 + q * (33 ±0)` - // Estimated: `1725 + q * (33 ±0)` - // Minimum execution time: 2_718_000 picoseconds. - Weight::from_parts(11_436_305, 1725) - // Standard Error: 3_619 - .saturating_add(Weight::from_parts(1_296_955, 0).saturating_mul(q.into())) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - .saturating_add(Weight::from_parts(0, 33).saturating_mul(q.into())) - } /// Storage: Contracts PristineCode (r:1 w:0) /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) /// Storage: Contracts CodeStorage (r:0 w:1) @@ -2155,21 +2139,6 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(k.into()))) .saturating_add(Weight::from_parts(0, 70).saturating_mul(k.into())) } - /// Storage: Contracts DeletionQueue (r:1 w:1) - /// Proof: Contracts DeletionQueue (max_values: Some(1), max_size: Some(16642), added: 17137, mode: Measured) - /// The range of component `q` is `[0, 128]`. - fn on_initialize_per_queue_item(q: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `250 + q * (33 ±0)` - // Estimated: `1725 + q * (33 ±0)` - // Minimum execution time: 2_718_000 picoseconds. - Weight::from_parts(11_436_305, 1725) - // Standard Error: 3_619 - .saturating_add(Weight::from_parts(1_296_955, 0).saturating_mul(q.into())) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - .saturating_add(Weight::from_parts(0, 33).saturating_mul(q.into())) - } /// Storage: Contracts PristineCode (r:1 w:0) /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) /// Storage: Contracts CodeStorage (r:0 w:1) From 2867a3c375abe03d80772d4b10048cf48dff379c Mon Sep 17 00:00:00 2001 From: pgherveou Date: Tue, 28 Mar 2023 17:55:08 +0200 Subject: [PATCH 13/43] PR comment: use BlockWeights::get().max_block --- frame/contracts/src/benchmarking/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 449f02965932c..62f271108f177 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -3009,8 +3009,9 @@ benchmarks! { print_schedule { #[cfg(feature = "std")] { - let empty_queue_throughput = ContractInfo::::deletion_budget(Weight::MAX); - let full_queue_throughput = ContractInfo::::deletion_budget(Weight::MAX); + let max_weight = ::BlockWeights::get().max_block; + let empty_queue_throughput = ContractInfo::::deletion_budget(max_weight); + let full_queue_throughput = ContractInfo::::deletion_budget(max_weight); println!("{:#?}", Schedule::::default()); println!("###############################################"); println!("Lazy deletion weight per key: {}", empty_queue_throughput.0); From 3a17f2bdc44b284e4470007504c49112b2d23c54 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Tue, 28 Mar 2023 17:56:07 +0200 Subject: [PATCH 14/43] PR comment: Update queue_trie_for_deletion signature --- frame/contracts/src/benchmarking/mod.rs | 2 +- frame/contracts/src/exec.rs | 2 +- frame/contracts/src/storage.rs | 7 +++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 62f271108f177..607d12b39831b 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -214,7 +214,7 @@ benchmarks! { on_initialize_per_trie_key { let k in 0..1024; let instance = Contract::::with_storage(WasmModule::dummy(), k, T::Schedule::get().limits.payload_len)?; - instance.info()?.queue_trie_for_deletion()?; + instance.info()?.queue_trie_for_deletion(); }: { ContractInfo::::process_deletion_queue_batch(Weight::MAX) } diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 51ea234f27376..03e1c4fd32585 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -1204,7 +1204,7 @@ where T::Currency::reducible_balance(&frame.account_id, Expendable, Polite), ExistenceRequirement::AllowDeath, )?; - info.queue_trie_for_deletion()?; + info.queue_trie_for_deletion(); ContractInfoOf::::remove(&frame.account_id); E::remove_user(info.code_hash); Contracts::::deposit_event( diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index b88625d7e1ce5..1f8a9d7a61fda 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -27,7 +27,7 @@ use crate::{ }; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ - dispatch::{DispatchError, DispatchResult}, + dispatch::DispatchError, storage::child::{self, ChildInfo}, weights::Weight, RuntimeDebugNoBound, @@ -204,9 +204,8 @@ impl ContractInfo { /// Push a contract's trie to the deletion queue for lazy removal. /// /// You must make sure that the contract is also removed when queuing the trie for deletion. - pub fn queue_trie_for_deletion(&self) -> DispatchResult { + pub fn queue_trie_for_deletion(&self) { DeletionQueue::::load().insert(DeletedContract { trie_id: self.trie_id.clone() }); - Ok(()) } /// Calculates the weight that is necessary to remove one key from the trie and how many @@ -410,6 +409,6 @@ impl DeletionQueue { let entry = >::get(self.delete_nonce); let entry = entry.map(|contract| DeletionQueueEntry { contract, queue: self }); - entry + entr } } From f7f1f42391b1e4864781107ce7e0636d33df9051 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Tue, 28 Mar 2023 17:58:10 +0200 Subject: [PATCH 15/43] PR comment: update deletion budget docstring --- frame/contracts/src/storage.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index 1f8a9d7a61fda..e9039cd35a27b 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -209,8 +209,7 @@ impl ContractInfo { } /// Calculates the weight that is necessary to remove one key from the trie and how many - /// of those keys can be deleted from the deletion queue given the supplied queue length - /// and weight limit. + /// of those keys can be deleted from the deletion queue given the supplied weight limit. pub fn deletion_budget(weight_limit: Weight) -> (Weight, u32) { let base_weight = T::WeightInfo::on_process_deletion_queue_batch(); let weight_per_key = T::WeightInfo::on_initialize_per_trie_key(1) - @@ -226,7 +225,7 @@ impl ContractInfo { (weight_per_key, key_budget) } - /// Delete as many items from the deletion queue possible within the supplied weight limit. + /// Delete as many items from the deletion queue possible within the supplied weight limit.j /// /// It returns the amount of weight used for that task. pub fn process_deletion_queue_batch(weight_limit: Weight) -> Weight { @@ -409,6 +408,6 @@ impl DeletionQueue { let entry = >::get(self.delete_nonce); let entry = entry.map(|contract| DeletionQueueEntry { contract, queue: self }); - entr + entry } } From 20a18c36a88ab40a879adbb0a75ed4f94c2b1ee3 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Tue, 28 Mar 2023 18:00:16 +0200 Subject: [PATCH 16/43] PR comment: impl Default with derive(DefaultNoBound) --- frame/contracts/src/storage.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index e9039cd35a27b..3c1d3782937ed 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -30,7 +30,7 @@ use frame_support::{ dispatch::DispatchError, storage::child::{self, ChildInfo}, weights::Weight, - RuntimeDebugNoBound, + DefaultNoBound, RuntimeDebugNoBound, }; use scale_info::TypeInfo; use sp_io::KillStorageResult; @@ -339,7 +339,7 @@ impl Deref for DepositAccount { /// When a contract is deleted by calling `seal_terminate` it becomes inaccessible /// immediately, but the deletion of the storage items it has accumulated is performed /// later by pulling the contract from the queue in the `on_idle` hook. -#[derive(Encode, Decode, TypeInfo, MaxEncodedLen, Clone)] +#[derive(Encode, Decode, TypeInfo, MaxEncodedLen, DefaultNoBound, Clone)] #[scale_info(skip_type_params(T))] pub struct DeletionQueue { /// Monotonic counter used as a key for inserting new deleted contract in the DeletionQueueMap. @@ -352,12 +352,6 @@ pub struct DeletionQueue { _phantom: PhantomData, } -impl Default for DeletionQueue { - fn default() -> Self { - Self { insert_nonce: 0, delete_nonce: 0, _phantom: Default::default() } - } -} - /// View on a contract that is marked for deletion /// The struct takes a mutable reference on the deletion queue so that the contract can be removed, /// and none can be added or read in the meantime. From bd99f9368d22eb34113130b0f4e8d2c4f549a319 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Tue, 28 Mar 2023 18:08:10 +0200 Subject: [PATCH 17/43] PR comment: Remove DeletedContract --- frame/contracts/src/lib.rs | 4 ++-- frame/contracts/src/storage.rs | 25 ++++++++++--------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 084427fee9ac0..db774e4c7ab17 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -102,7 +102,7 @@ mod tests; use crate::{ exec::{AccountIdOf, ErrorOrigin, ExecError, Executable, Key, Stack as ExecStack}, gas::GasMeter, - storage::{meter::Meter as StorageMeter, ContractInfo, DeletedContract, DeletionQueue}, + storage::{meter::Meter as StorageMeter, ContractInfo, DeletionQueue}, wasm::{OwnerInfo, PrefabWasmModule, TryInstantiate}, weights::WeightInfo, }; @@ -899,7 +899,7 @@ pub mod pallet { /// Child trie deletion is a heavy operation depending on the amount of storage items /// stored in said trie. Therefore this operation is performed lazily in `on_idle`. #[pallet::storage] - pub(crate) type DeletionQueueMap = StorageMap<_, Twox64Concat, u32, DeletedContract>; + pub(crate) type DeletionQueueMap = StorageMap<_, Twox64Concat, u32, TrieId>; /// A pair of monotonic counters used to track the latest contract marked for deletion /// and the latest deleted contract in DeletionQueueMap. diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index 3c1d3782937ed..b12caa2892778 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -205,7 +205,7 @@ impl ContractInfo { /// /// You must make sure that the contract is also removed when queuing the trie for deletion. pub fn queue_trie_for_deletion(&self) { - DeletionQueue::::load().insert(DeletedContract { trie_id: self.trie_id.clone() }); + DeletionQueue::::load().insert(self.trie_id.clone()); } /// Calculates the weight that is necessary to remove one key from the trie and how many @@ -249,7 +249,7 @@ impl ContractInfo { #[allow(deprecated)] let outcome = child::kill_storage( - &ChildInfo::new_default(&entry.contract().trie_id), + &ChildInfo::new_default(&entry.trie_id), Some(remaining_key_budget), ); @@ -275,10 +275,10 @@ impl ContractInfo { } } -#[derive(Encode, Decode, TypeInfo, MaxEncodedLen)] -pub struct DeletedContract { - pub(crate) trie_id: TrieId, -} +// #[derive(Encode, Decode, TypeInfo, MaxEncodedLen)] +// pub struct DeletedContract { +// pub(crate) trie_id: TrieId, +// } /// Information about what happened to the pre-existing value when calling [`ContractInfo::write`]. #[cfg_attr(test, derive(Debug, PartialEq))] @@ -356,16 +356,11 @@ pub struct DeletionQueue { /// The struct takes a mutable reference on the deletion queue so that the contract can be removed, /// and none can be added or read in the meantime. struct DeletionQueueEntry<'a, T: Config> { - contract: DeletedContract, + trie_id: TrieId, queue: &'a mut DeletionQueue, } impl<'a, T: Config> DeletionQueueEntry<'a, T> { - /// Get a reference to the contract that is marked for deletion. - fn contract(&self) -> &DeletedContract { - &self.contract - } - /// Remove the contract from the deletion queue. fn remove(self) { >::remove(self.queue.delete_nonce); @@ -387,8 +382,8 @@ impl DeletionQueue { } /// Insert a contract in the deletion queue. - fn insert(&mut self, contract: DeletedContract) { - >::insert(self.insert_nonce, contract); + fn insert(&mut self, trie_id: TrieId) { + >::insert(self.insert_nonce, trie_id); self.insert_nonce = self.insert_nonce.wrapping_add(1); >::set(self.clone()); } @@ -400,7 +395,7 @@ impl DeletionQueue { } let entry = >::get(self.delete_nonce); - let entry = entry.map(|contract| DeletionQueueEntry { contract, queue: self }); + let entry = entry.map(|trie_id| DeletionQueueEntry { trie_id, queue: self }); entry } From 737a48a2b9f35381ea55dcaef198535bf0da47da Mon Sep 17 00:00:00 2001 From: pgherveou Date: Tue, 28 Mar 2023 21:07:51 +0200 Subject: [PATCH 18/43] PR comment Add ring_buffer test --- frame/contracts/src/storage.rs | 10 +++++ frame/contracts/src/tests.rs | 78 ++++++++++++++++++++++++++++++++-- 2 files changed, 85 insertions(+), 3 deletions(-) diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index b12caa2892778..fcaa6e30c19d6 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -400,3 +400,13 @@ impl DeletionQueue { entry } } + +#[cfg(test)] +impl DeletionQueue { + pub fn from_test_values(insert_nonce: u32, delete_nonce: u32) -> Self { + DeletionQueue { insert_nonce, delete_nonce, _phantom: Default::default() } + } + pub fn as_test_tuple(&self) -> (u32, u32) { + (self.insert_nonce, self.delete_nonce) + } +} diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index f64a3c40f77e7..8ac10383c2ffd 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -22,11 +22,12 @@ use crate::{ Result as ExtensionResult, RetVal, ReturnFlags, SysConfig, }, exec::{Frame, Key}, + storage::DeletionQueue, tests::test_utils::{get_contract, get_contract_checked}, wasm::{Determinism, PrefabWasmModule, ReturnCode as RuntimeReturnCode}, weights::WeightInfo, BalanceOf, Code, CodeStorage, Config, ContractInfo, ContractInfoOf, DefaultAddressGenerator, - Error, Pallet, Schedule, + DeletionQueueNonces, Error, Pallet, Schedule, }; use assert_matches::assert_matches; use codec::Encode; @@ -451,7 +452,7 @@ impl ExtBuilder { /// with it's hash. /// /// The fixture files are located under the `fixtures/` directory. -fn compile_module(fixture_name: &str) -> wat::Result<(Vec, ::Output)> +pub fn compile_module(fixture_name: &str) -> wat::Result<(Vec, ::Output)> where T: frame_system::Config, { @@ -2160,7 +2161,7 @@ fn lazy_removal_does_no_run_on_low_remaining_weight() { // But value should be still there as the lazy removal did not run, yet. assert_matches!(child::get(trie, &[99]), Some(42)); - // Assign a remaining weight which is too low for a successfull deletion of the contract + // Assign a remaining weight which is too low for a successful deletion of the contract let low_remaining_weight = <::WeightInfo as WeightInfo>::on_process_deletion_queue_batch(); @@ -2264,6 +2265,77 @@ fn lazy_removal_does_not_use_all_weight() { }); } +#[test] +fn deletion_queue_ring_buffer_overflow() { + let (code, _hash) = compile_module::("self_destruct").unwrap(); + let mut ext = ExtBuilder::default().existential_deposit(50).build(); + + // setup the deletion queue with custom nonces + ext.execute_with(|| { + // manually se the nonces of the deletion queue + let queue = DeletionQueue::from_test_values(u32::MAX - 1, u32::MAX - 1); + >::set(queue); + }); + + // commit the changes to the storage + ext.commit_all().unwrap(); + + ext.execute_with(|| { + let min_balance = ::Currency::minimum_balance(); + let _ = Balances::deposit_creating(&ALICE, 1000 * min_balance); + let mut tries: Vec = vec![]; + + // add 3 contracts to the deletion queue + for i in 0..3u8 { + let addr = Contracts::bare_instantiate( + ALICE, + min_balance * 100, + GAS_LIMIT, + None, + Code::Upload(code.clone()), + vec![], + vec![i], + false, + ) + .result + .unwrap() + .account_id; + + let info = get_contract(&addr); + let trie = &info.child_trie_info(); + + // Put value into the contracts child trie + child::put(trie, &[99], &42); + + // Terminate the contract. Contract info should be gone, but value should be still + // there as the lazy removal did not run, yet. + assert_ok!(Contracts::call( + RuntimeOrigin::signed(ALICE), + addr.clone(), + 0, + GAS_LIMIT, + None, + vec![] + )); + + assert!(!>::contains_key(&addr)); + assert_matches!(child::get(trie, &[99]), Some(42)); + + tries.push(trie.clone()) + } + + // Run single lazy removal + Contracts::on_idle(System::block_number(), Weight::MAX); + + // The single lazy removal should have removed all queued tries + for trie in tries.iter() { + assert_matches!(child::get::(trie, &[99]), None); + } + + // nonces values should go from u32::MAX - 1 to 1 + assert_eq!(>::get().as_test_tuple(), (1, 1)); + }) +} #[test] fn refcounter() { let (wasm, code_hash) = compile_module::("self_destruct").unwrap(); From 2d44b3d2e4d51566d9012bdd73fc2433faaf1d3c Mon Sep 17 00:00:00 2001 From: pgherveou Date: Tue, 28 Mar 2023 21:12:14 +0200 Subject: [PATCH 19/43] remove missed comment --- frame/contracts/src/storage.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index fcaa6e30c19d6..5f1b78e247079 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -275,11 +275,6 @@ impl ContractInfo { } } -// #[derive(Encode, Decode, TypeInfo, MaxEncodedLen)] -// pub struct DeletedContract { -// pub(crate) trie_id: TrieId, -// } - /// Information about what happened to the pre-existing value when calling [`ContractInfo::write`]. #[cfg_attr(test, derive(Debug, PartialEq))] pub enum WriteOutcome { From b0bbbcf0137f439f15ac5069d91cbb4cca0dc0be Mon Sep 17 00:00:00 2001 From: pgherveou Date: Tue, 28 Mar 2023 21:16:08 +0200 Subject: [PATCH 20/43] misc comments --- frame/contracts/src/storage.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index 5f1b78e247079..f33a8b9a0f3b8 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -347,7 +347,7 @@ pub struct DeletionQueue { _phantom: PhantomData, } -/// View on a contract that is marked for deletion +/// View on a contract that is marked for deletion. /// The struct takes a mutable reference on the deletion queue so that the contract can be removed, /// and none can be added or read in the meantime. struct DeletionQueueEntry<'a, T: Config> { @@ -366,7 +366,7 @@ impl<'a, T: Config> DeletionQueueEntry<'a, T> { impl DeletionQueue { /// Load the Deletion Queue nonces, so we can perform read or write operations on the - /// DeletionQueueMap storage + /// DeletionQueueMap storage. fn load() -> Self { >::get() } From d4600e00934b90e5882cf5288f36f98911b51722 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Mon, 27 Mar 2023 15:44:20 +0200 Subject: [PATCH 21/43] contracts: add sr25519_recover --- frame/contracts/src/exec.rs | 8 ++++ frame/contracts/src/tests.rs | 77 ++++++++++++++++++++++++++---------- 2 files changed, 64 insertions(+), 21 deletions(-) diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 51ea234f27376..a597b090049e3 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -1347,6 +1347,14 @@ where secp256k1_ecdsa_recover_compressed(signature, message_hash).map_err(|_| ()) } + fn sr25519_recover( + &self, + signature: &[u8; 65], + message_hash: &[u8; 32], + ) -> Result<[u8; 33], ()> { + todo!() + } + fn ecdsa_to_eth_address(&self, pk: &[u8; 33]) -> Result<[u8; 20], ()> { ECDSAPublic(*pk).to_eth_address() } diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 146e5fd24ad07..7d658088d4cbb 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -2846,7 +2846,61 @@ fn gas_call_runtime_reentrancy_guarded() { #[test] fn ecdsa_recover() { - let (wasm, _code_hash) = compile_module::("ecdsa_recover").unwrap(); + #[rustfmt::skip] + let signature: [u8; 65] = [ + 161, 234, 203, 74, 147, 96, 51, 212, 5, 174, 231, 9, 142, 48, 137, 201, + 162, 118, 192, 67, 239, 16, 71, 216, 125, 86, 167, 139, 70, 7, 86, 241, + 33, 87, 154, 251, 81, 29, 160, 4, 176, 239, 88, 211, 244, 232, 232, 52, + 211, 234, 100, 115, 230, 47, 80, 44, 152, 166, 62, 50, 8, 13, 86, 175, + 28, + ]; + #[rustfmt::skip] + let message_hash: [u8; 32] = [ + 162, 28, 244, 179, 96, 76, 244, 178, 188, 83, 230, 248, 143, 106, 77, 117, + 239, 95, 244, 171, 65, 95, 62, 153, 174, 166, 182, 28, 130, 73, 196, 208 + ]; + #[rustfmt::skip] + let expected_compressed_public_key: [u8; 33] = [ + 2, 121, 190, 102, 126, 249, 220, 187, 172, 85, 160, 98, 149, 206, 135, 11, + 7, 2, 155, 252, 219, 45, 206, 40, 217, 89, 242, 129, 91, 22, 248, 23, + 152, + ]; + + signature_recover("ecdsa_recover", &signature, &message_hash, &expected_compressed_public_key); +} + +#[test] +fn sr25519_recover() { + #[rustfmt::skip] + let signature: [u8; 65] = [ + 161, 234, 203, 74, 147, 96, 51, 212, 5, 174, 231, 9, 142, 48, 137, 201, + 162, 118, 192, 67, 239, 16, 71, 216, 125, 86, 167, 139, 70, 7, 86, 241, + 33, 87, 154, 251, 81, 29, 160, 4, 176, 239, 88, 211, 244, 232, 232, 52, + 211, 234, 100, 115, 230, 47, 80, 44, 152, 166, 62, 50, 8, 13, 86, 175, + 28, + ]; + #[rustfmt::skip] + let message_hash: [u8; 32] = [ + 162, 28, 244, 179, 96, 76, 244, 178, 188, 83, 230, 248, 143, 106, 77, 117, + 239, 95, 244, 171, 65, 95, 62, 153, 174, 166, 182, 28, 130, 73, 196, 208 + ]; + #[rustfmt::skip] + let expected_compressed_public_key: [u8; 33] = [ + 2, 121, 190, 102, 126, 249, 220, 187, 172, 85, 160, 98, 149, 206, 135, 11, + 7, 2, 155, 252, 219, 45, 206, 40, 217, 89, 242, 129, 91, 22, 248, 23, + 152, + ]; + + signature_recover("ecdsa_recover", &signature, &message_hash, &expected_compressed_public_key); +} + +fn signature_recover( + fixture: &str, + signature: &[u8], + message_hash: &[u8], + expected_compressed_public_key: &[u8], +) { + let (wasm, _code_hash) = compile_module::(fixture).unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { let _ = Balances::deposit_creating(&ALICE, 1_000_000); @@ -2866,25 +2920,6 @@ fn ecdsa_recover() { .unwrap() .account_id; - #[rustfmt::skip] - let signature: [u8; 65] = [ - 161, 234, 203, 74, 147, 96, 51, 212, 5, 174, 231, 9, 142, 48, 137, 201, - 162, 118, 192, 67, 239, 16, 71, 216, 125, 86, 167, 139, 70, 7, 86, 241, - 33, 87, 154, 251, 81, 29, 160, 4, 176, 239, 88, 211, 244, 232, 232, 52, - 211, 234, 100, 115, 230, 47, 80, 44, 152, 166, 62, 50, 8, 13, 86, 175, - 28, - ]; - #[rustfmt::skip] - let message_hash: [u8; 32] = [ - 162, 28, 244, 179, 96, 76, 244, 178, 188, 83, 230, 248, 143, 106, 77, 117, - 239, 95, 244, 171, 65, 95, 62, 153, 174, 166, 182, 28, 130, 73, 196, 208 - ]; - #[rustfmt::skip] - const EXPECTED_COMPRESSED_PUBLIC_KEY: [u8; 33] = [ - 2, 121, 190, 102, 126, 249, 220, 187, 172, 85, 160, 98, 149, 206, 135, 11, - 7, 2, 155, 252, 219, 45, 206, 40, 217, 89, 242, 129, 91, 22, 248, 23, - 152, - ]; let mut params = vec![]; params.extend_from_slice(&signature); params.extend_from_slice(&message_hash); @@ -2902,7 +2937,7 @@ fn ecdsa_recover() { .result .unwrap(); assert!(!result.did_revert()); - assert_eq!(result.data, EXPECTED_COMPRESSED_PUBLIC_KEY); + assert_eq!(result.data, expected_compressed_public_key); }) } From c30bf2b19171926d212652d9a720e72cd7e0f75c Mon Sep 17 00:00:00 2001 From: pgherveou Date: Tue, 28 Mar 2023 23:10:08 +0200 Subject: [PATCH 22/43] Revert "contracts: add sr25519_recover" This reverts commit d4600e00934b90e5882cf5288f36f98911b51722. --- frame/contracts/src/exec.rs | 8 ---- frame/contracts/src/tests.rs | 77 ++++++++++-------------------------- 2 files changed, 21 insertions(+), 64 deletions(-) diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 089c62cb7f162..03e1c4fd32585 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -1347,14 +1347,6 @@ where secp256k1_ecdsa_recover_compressed(signature, message_hash).map_err(|_| ()) } - fn sr25519_recover( - &self, - signature: &[u8; 65], - message_hash: &[u8; 32], - ) -> Result<[u8; 33], ()> { - todo!() - } - fn ecdsa_to_eth_address(&self, pk: &[u8; 33]) -> Result<[u8; 20], ()> { ECDSAPublic(*pk).to_eth_address() } diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index fe12b6bee0867..8ac10383c2ffd 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -2834,61 +2834,7 @@ fn gas_call_runtime_reentrancy_guarded() { #[test] fn ecdsa_recover() { - #[rustfmt::skip] - let signature: [u8; 65] = [ - 161, 234, 203, 74, 147, 96, 51, 212, 5, 174, 231, 9, 142, 48, 137, 201, - 162, 118, 192, 67, 239, 16, 71, 216, 125, 86, 167, 139, 70, 7, 86, 241, - 33, 87, 154, 251, 81, 29, 160, 4, 176, 239, 88, 211, 244, 232, 232, 52, - 211, 234, 100, 115, 230, 47, 80, 44, 152, 166, 62, 50, 8, 13, 86, 175, - 28, - ]; - #[rustfmt::skip] - let message_hash: [u8; 32] = [ - 162, 28, 244, 179, 96, 76, 244, 178, 188, 83, 230, 248, 143, 106, 77, 117, - 239, 95, 244, 171, 65, 95, 62, 153, 174, 166, 182, 28, 130, 73, 196, 208 - ]; - #[rustfmt::skip] - let expected_compressed_public_key: [u8; 33] = [ - 2, 121, 190, 102, 126, 249, 220, 187, 172, 85, 160, 98, 149, 206, 135, 11, - 7, 2, 155, 252, 219, 45, 206, 40, 217, 89, 242, 129, 91, 22, 248, 23, - 152, - ]; - - signature_recover("ecdsa_recover", &signature, &message_hash, &expected_compressed_public_key); -} - -#[test] -fn sr25519_recover() { - #[rustfmt::skip] - let signature: [u8; 65] = [ - 161, 234, 203, 74, 147, 96, 51, 212, 5, 174, 231, 9, 142, 48, 137, 201, - 162, 118, 192, 67, 239, 16, 71, 216, 125, 86, 167, 139, 70, 7, 86, 241, - 33, 87, 154, 251, 81, 29, 160, 4, 176, 239, 88, 211, 244, 232, 232, 52, - 211, 234, 100, 115, 230, 47, 80, 44, 152, 166, 62, 50, 8, 13, 86, 175, - 28, - ]; - #[rustfmt::skip] - let message_hash: [u8; 32] = [ - 162, 28, 244, 179, 96, 76, 244, 178, 188, 83, 230, 248, 143, 106, 77, 117, - 239, 95, 244, 171, 65, 95, 62, 153, 174, 166, 182, 28, 130, 73, 196, 208 - ]; - #[rustfmt::skip] - let expected_compressed_public_key: [u8; 33] = [ - 2, 121, 190, 102, 126, 249, 220, 187, 172, 85, 160, 98, 149, 206, 135, 11, - 7, 2, 155, 252, 219, 45, 206, 40, 217, 89, 242, 129, 91, 22, 248, 23, - 152, - ]; - - signature_recover("ecdsa_recover", &signature, &message_hash, &expected_compressed_public_key); -} - -fn signature_recover( - fixture: &str, - signature: &[u8], - message_hash: &[u8], - expected_compressed_public_key: &[u8], -) { - let (wasm, _code_hash) = compile_module::(fixture).unwrap(); + let (wasm, _code_hash) = compile_module::("ecdsa_recover").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { let _ = Balances::deposit_creating(&ALICE, 1_000_000); @@ -2908,6 +2854,25 @@ fn signature_recover( .unwrap() .account_id; + #[rustfmt::skip] + let signature: [u8; 65] = [ + 161, 234, 203, 74, 147, 96, 51, 212, 5, 174, 231, 9, 142, 48, 137, 201, + 162, 118, 192, 67, 239, 16, 71, 216, 125, 86, 167, 139, 70, 7, 86, 241, + 33, 87, 154, 251, 81, 29, 160, 4, 176, 239, 88, 211, 244, 232, 232, 52, + 211, 234, 100, 115, 230, 47, 80, 44, 152, 166, 62, 50, 8, 13, 86, 175, + 28, + ]; + #[rustfmt::skip] + let message_hash: [u8; 32] = [ + 162, 28, 244, 179, 96, 76, 244, 178, 188, 83, 230, 248, 143, 106, 77, 117, + 239, 95, 244, 171, 65, 95, 62, 153, 174, 166, 182, 28, 130, 73, 196, 208 + ]; + #[rustfmt::skip] + const EXPECTED_COMPRESSED_PUBLIC_KEY: [u8; 33] = [ + 2, 121, 190, 102, 126, 249, 220, 187, 172, 85, 160, 98, 149, 206, 135, 11, + 7, 2, 155, 252, 219, 45, 206, 40, 217, 89, 242, 129, 91, 22, 248, 23, + 152, + ]; let mut params = vec![]; params.extend_from_slice(&signature); params.extend_from_slice(&message_hash); @@ -2925,7 +2890,7 @@ fn signature_recover( .result .unwrap(); assert!(!result.did_revert()); - assert_eq!(result.data, expected_compressed_public_key); + assert_eq!(result.data, EXPECTED_COMPRESSED_PUBLIC_KEY); }) } From c17e0e69c9070fbc801bdb639c1df38ea6c1d02a Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Tue, 28 Mar 2023 22:40:28 +0000 Subject: [PATCH 23/43] ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts --- frame/contracts/src/weights.rs | 1838 ++++++++++++++++---------------- 1 file changed, 923 insertions(+), 915 deletions(-) diff --git a/frame/contracts/src/weights.rs b/frame/contracts/src/weights.rs index 0a2d4c0d33b22..d1176a5aa469f 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: 2023-03-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-03-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -170,14 +170,14 @@ pub trait WeightInfo { /// Weights for pallet_contracts using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - /// Storage: Contracts DeletionQueue (r:1 w:0) - /// Proof: Contracts DeletionQueue (max_values: Some(1), max_size: Some(16642), added: 17137, mode: Measured) + /// Storage: Contracts DeletionQueueNonces (r:1 w:0) + /// Proof: Contracts DeletionQueueNonces (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) fn on_process_deletion_queue_batch() -> Weight { // Proof Size summary in bytes: // Measured: `109` // Estimated: `1594` - // Minimum execution time: 2_585_000 picoseconds. - Weight::from_parts(2_802_000, 1594) + // Minimum execution time: 2_677_000 picoseconds. + Weight::from_parts(2_899_000, 1594) .saturating_add(T::DbWeight::get().reads(1_u64)) } /// Storage: Skipped Metadata (r:0 w:0) @@ -185,15 +185,15 @@ impl WeightInfo for SubstrateWeight { /// The range of component `k` is `[0, 1024]`. fn on_initialize_per_trie_key(k: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `450 + k * (69 ±0)` - // Estimated: `440 + k * (70 ±0)` - // Minimum execution time: 10_825_000 picoseconds. - Weight::from_parts(5_747_064, 440) - // Standard Error: 1_037 - .saturating_add(Weight::from_parts(973_689, 0).saturating_mul(k.into())) - .saturating_add(T::DbWeight::get().reads(1_u64)) + // Measured: `488 + k * (69 ±0)` + // Estimated: `478 + k * (70 ±0)` + // Minimum execution time: 14_006_000 picoseconds. + Weight::from_parts(8_735_946, 478) + // Standard Error: 1_370 + .saturating_add(Weight::from_parts(989_501, 0).saturating_mul(k.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(k.into()))) - .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(k.into()))) .saturating_add(Weight::from_parts(0, 70).saturating_mul(k.into())) } @@ -206,10 +206,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `238 + c * (1 ±0)` // Estimated: `3951 + c * (2 ±0)` - // Minimum execution time: 37_882_000 picoseconds. - Weight::from_parts(43_548_816, 3951) - // Standard Error: 49 - .saturating_add(Weight::from_parts(53_936, 0).saturating_mul(c.into())) + // Minimum execution time: 30_951_000 picoseconds. + Weight::from_parts(25_988_560, 3951) + // Standard Error: 57 + .saturating_add(Weight::from_parts(54_692, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 2).saturating_mul(c.into())) @@ -229,10 +229,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `707` // Estimated: `21400 + c * (5 ±0)` - // Minimum execution time: 313_392_000 picoseconds. - Weight::from_parts(325_419_093, 21400) - // Standard Error: 25 - .saturating_add(Weight::from_parts(37_877, 0).saturating_mul(c.into())) + // Minimum execution time: 263_107_000 picoseconds. + Weight::from_parts(268_289_665, 21400) + // Standard Error: 33 + .saturating_add(Weight::from_parts(38_534, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 5).saturating_mul(c.into())) @@ -260,14 +260,14 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `270` // Estimated: `26207` - // Minimum execution time: 3_274_352_000 picoseconds. - Weight::from_parts(681_171_416, 26207) - // Standard Error: 336 - .saturating_add(Weight::from_parts(106_391, 0).saturating_mul(c.into())) - // Standard Error: 19 - .saturating_add(Weight::from_parts(1_147, 0).saturating_mul(i.into())) - // Standard Error: 19 - .saturating_add(Weight::from_parts(1_493, 0).saturating_mul(s.into())) + // Minimum execution time: 3_122_319_000 picoseconds. + Weight::from_parts(487_802_180, 26207) + // Standard Error: 345 + .saturating_add(Weight::from_parts(108_237, 0).saturating_mul(c.into())) + // Standard Error: 20 + .saturating_add(Weight::from_parts(1_166, 0).saturating_mul(i.into())) + // Standard Error: 20 + .saturating_add(Weight::from_parts(1_505, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(10_u64)) } @@ -291,12 +291,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `482` // Estimated: `28521` - // Minimum execution time: 1_692_637_000 picoseconds. - Weight::from_parts(283_252_265, 28521) + // Minimum execution time: 1_650_623_000 picoseconds. + Weight::from_parts(286_494_456, 28521) // Standard Error: 8 - .saturating_add(Weight::from_parts(1_498, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(1_438, 0).saturating_mul(i.into())) // Standard Error: 8 - .saturating_add(Weight::from_parts(1_487, 0).saturating_mul(s.into())) + .saturating_add(Weight::from_parts(1_453, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -314,8 +314,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `759` // Estimated: `21615` - // Minimum execution time: 192_369_000 picoseconds. - Weight::from_parts(193_417_000, 21615) + // Minimum execution time: 191_046_000 picoseconds. + Weight::from_parts(192_544_000, 21615) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -332,10 +332,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `109` // Estimated: `7366` - // Minimum execution time: 301_972_000 picoseconds. - Weight::from_parts(313_248_051, 7366) - // Standard Error: 82 - .saturating_add(Weight::from_parts(107_321, 0).saturating_mul(c.into())) + // Minimum execution time: 244_260_000 picoseconds. + Weight::from_parts(254_693_985, 7366) + // Standard Error: 80 + .saturating_add(Weight::from_parts(108_246, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -351,8 +351,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `255` // Estimated: `7950` - // Minimum execution time: 33_013_000 picoseconds. - Weight::from_parts(33_622_000, 7950) + // Minimum execution time: 33_492_000 picoseconds. + Weight::from_parts(34_079_000, 7950) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -366,8 +366,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `570` // Estimated: `19530` - // Minimum execution time: 33_518_000 picoseconds. - Weight::from_parts(33_819_000, 19530) + // Minimum execution time: 33_475_000 picoseconds. + Weight::from_parts(33_856_000, 19530) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -386,10 +386,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `781 + r * (6 ±0)` // Estimated: `21730 + r * (30 ±0)` - // Minimum execution time: 283_945_000 picoseconds. - Weight::from_parts(289_209_599, 21730) - // Standard Error: 901 - .saturating_add(Weight::from_parts(327_601, 0).saturating_mul(r.into())) + // Minimum execution time: 234_197_000 picoseconds. + Weight::from_parts(236_830_305, 21730) + // Standard Error: 818 + .saturating_add(Weight::from_parts(336_446, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -409,10 +409,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `839 + r * (240 ±0)` // Estimated: `21835 + r * (3675 ±0)` - // Minimum execution time: 284_949_000 picoseconds. - Weight::from_parts(126_196_485, 21835) - // Standard Error: 6_260 - .saturating_add(Weight::from_parts(3_368_849, 0).saturating_mul(r.into())) + // Minimum execution time: 235_872_000 picoseconds. + Weight::from_parts(78_877_890, 21835) + // Standard Error: 6_405 + .saturating_add(Weight::from_parts(3_358_341, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -433,10 +433,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `831 + r * (244 ±0)` // Estimated: `21855 + r * (3695 ±0)` - // Minimum execution time: 286_429_000 picoseconds. - Weight::from_parts(124_820_396, 21855) - // Standard Error: 6_539 - .saturating_add(Weight::from_parts(4_163_535, 0).saturating_mul(r.into())) + // Minimum execution time: 239_035_000 picoseconds. + Weight::from_parts(93_255_085, 21855) + // Standard Error: 5_922 + .saturating_add(Weight::from_parts(4_144_910, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -457,10 +457,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `788 + r * (6 ±0)` // Estimated: `21770 + r * (30 ±0)` - // Minimum execution time: 285_042_000 picoseconds. - Weight::from_parts(288_096_303, 21770) - // Standard Error: 972 - .saturating_add(Weight::from_parts(409_782, 0).saturating_mul(r.into())) + // Minimum execution time: 236_507_000 picoseconds. + Weight::from_parts(238_253_211, 21770) + // Standard Error: 975 + .saturating_add(Weight::from_parts(413_919, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -480,10 +480,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `778 + r * (3 ±0)` // Estimated: `21735 + r * (15 ±0)` - // Minimum execution time: 282_820_000 picoseconds. - Weight::from_parts(287_104_710, 21735) - // Standard Error: 421 - .saturating_add(Weight::from_parts(167_907, 0).saturating_mul(r.into())) + // Minimum execution time: 235_521_000 picoseconds. + Weight::from_parts(238_397_362, 21735) + // Standard Error: 452 + .saturating_add(Weight::from_parts(160_860, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 15).saturating_mul(r.into())) @@ -503,10 +503,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `782 + r * (6 ±0)` // Estimated: `21740 + r * (30 ±0)` - // Minimum execution time: 284_619_000 picoseconds. - Weight::from_parts(281_326_785, 21740) - // Standard Error: 1_379 - .saturating_add(Weight::from_parts(342_779, 0).saturating_mul(r.into())) + // Minimum execution time: 234_722_000 picoseconds. + Weight::from_parts(242_936_096, 21740) + // Standard Error: 1_178 + .saturating_add(Weight::from_parts(329_075, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -526,10 +526,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `783 + r * (6 ±0)` // Estimated: `21725 + r * (30 ±0)` - // Minimum execution time: 284_703_000 picoseconds. - Weight::from_parts(289_479_932, 21725) - // Standard Error: 745 - .saturating_add(Weight::from_parts(323_625, 0).saturating_mul(r.into())) + // Minimum execution time: 235_654_000 picoseconds. + Weight::from_parts(245_887_792, 21725) + // Standard Error: 903 + .saturating_add(Weight::from_parts(325_168, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -549,10 +549,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `922 + r * (6 ±0)` // Estimated: `24633 + r * (30 ±0)` - // Minimum execution time: 283_610_000 picoseconds. - Weight::from_parts(299_901_534, 24633) - // Standard Error: 1_177 - .saturating_add(Weight::from_parts(1_474_603, 0).saturating_mul(r.into())) + // Minimum execution time: 233_599_000 picoseconds. + Weight::from_parts(251_561_602, 24633) + // Standard Error: 3_348 + .saturating_add(Weight::from_parts(1_475_443, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -572,10 +572,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `792 + r * (6 ±0)` // Estimated: `21825 + r * (30 ±0)` - // Minimum execution time: 284_474_000 picoseconds. - Weight::from_parts(283_540_273, 21825) - // Standard Error: 1_164 - .saturating_add(Weight::from_parts(339_262, 0).saturating_mul(r.into())) + // Minimum execution time: 235_087_000 picoseconds. + Weight::from_parts(235_855_322, 21825) + // Standard Error: 867 + .saturating_add(Weight::from_parts(346_707, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -595,10 +595,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `790 + r * (6 ±0)` // Estimated: `21815 + r * (30 ±0)` - // Minimum execution time: 284_521_000 picoseconds. - Weight::from_parts(285_747_754, 21815) - // Standard Error: 889 - .saturating_add(Weight::from_parts(326_428, 0).saturating_mul(r.into())) + // Minimum execution time: 237_103_000 picoseconds. + Weight::from_parts(239_272_188, 21815) + // Standard Error: 892 + .saturating_add(Weight::from_parts(328_334, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -618,10 +618,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `787 + r * (6 ±0)` // Estimated: `21805 + r * (30 ±0)` - // Minimum execution time: 284_103_000 picoseconds. - Weight::from_parts(283_801_256, 21805) - // Standard Error: 1_051 - .saturating_add(Weight::from_parts(334_081, 0).saturating_mul(r.into())) + // Minimum execution time: 234_761_000 picoseconds. + Weight::from_parts(238_601_784, 21805) + // Standard Error: 725 + .saturating_add(Weight::from_parts(325_758, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -641,10 +641,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `778 + r * (6 ±0)` // Estimated: `21735 + r * (30 ±0)` - // Minimum execution time: 284_187_000 picoseconds. - Weight::from_parts(289_414_364, 21735) - // Standard Error: 796 - .saturating_add(Weight::from_parts(324_603, 0).saturating_mul(r.into())) + // Minimum execution time: 235_249_000 picoseconds. + Weight::from_parts(239_861_242, 21735) + // Standard Error: 751 + .saturating_add(Weight::from_parts(325_795, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -666,10 +666,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `856 + r * (10 ±0)` // Estimated: `24446 + r * (60 ±0)` - // Minimum execution time: 284_953_000 picoseconds. - Weight::from_parts(290_535_752, 24446) - // Standard Error: 2_462 - .saturating_add(Weight::from_parts(1_361_518, 0).saturating_mul(r.into())) + // Minimum execution time: 234_912_000 picoseconds. + Weight::from_parts(254_783_734, 24446) + // Standard Error: 1_610 + .saturating_add(Weight::from_parts(1_307_506, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 60).saturating_mul(r.into())) @@ -689,10 +689,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `745 + r * (4 ±0)` // Estimated: `21555 + r * (20 ±0)` - // Minimum execution time: 160_775_000 picoseconds. - Weight::from_parts(164_652_364, 21555) - // Standard Error: 284 - .saturating_add(Weight::from_parts(132_574, 0).saturating_mul(r.into())) + // Minimum execution time: 160_125_000 picoseconds. + Weight::from_parts(164_915_574, 21555) + // Standard Error: 332 + .saturating_add(Weight::from_parts(132_326, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 20).saturating_mul(r.into())) @@ -712,10 +712,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `780 + r * (6 ±0)` // Estimated: `21740 + r * (30 ±0)` - // Minimum execution time: 284_072_000 picoseconds. - Weight::from_parts(288_418_644, 21740) - // Standard Error: 792 - .saturating_add(Weight::from_parts(272_881, 0).saturating_mul(r.into())) + // Minimum execution time: 234_717_000 picoseconds. + Weight::from_parts(238_540_521, 21740) + // Standard Error: 599 + .saturating_add(Weight::from_parts(277_303, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -735,10 +735,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `784` // Estimated: `21740` - // Minimum execution time: 286_671_000 picoseconds. - Weight::from_parts(292_151_662, 21740) + // Minimum execution time: 235_792_000 picoseconds. + Weight::from_parts(244_114_692, 21740) // Standard Error: 1 - .saturating_add(Weight::from_parts(638, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(589, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -757,10 +757,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `768 + r * (45 ±0)` // Estimated: `21660 + r * (225 ±0)` - // Minimum execution time: 280_334_000 picoseconds. - Weight::from_parts(283_487_571, 21660) - // Standard Error: 267_797 - .saturating_add(Weight::from_parts(3_803_128, 0).saturating_mul(r.into())) + // Minimum execution time: 231_166_000 picoseconds. + Weight::from_parts(233_339_177, 21660) + // Standard Error: 155_889 + .saturating_add(Weight::from_parts(3_124_322, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 225).saturating_mul(r.into())) @@ -780,10 +780,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `778` // Estimated: `21775` - // Minimum execution time: 284_004_000 picoseconds. - Weight::from_parts(283_681_350, 21775) + // Minimum execution time: 235_721_000 picoseconds. + Weight::from_parts(237_413_703, 21775) // Standard Error: 1 - .saturating_add(Weight::from_parts(232, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(177, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -795,26 +795,28 @@ impl WeightInfo for SubstrateWeight { /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Measured) /// Storage: Timestamp Now (r:1 w:0) /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: Contracts DeletionQueue (r:1 w:1) - /// Proof: Contracts DeletionQueue (max_values: Some(1), max_size: Some(16642), added: 17137, mode: Measured) + /// Storage: Contracts DeletionQueueNonces (r:1 w:1) + /// Proof: Contracts DeletionQueueNonces (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: Contracts OwnerInfoOf (r:1 w:1) /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Measured) /// Storage: System EventTopics (r:3 w:3) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: Contracts DeletionQueueMap (r:0 w:1) + /// Proof: Contracts DeletionQueueMap (max_values: None, max_size: Some(142), added: 2617, mode: Measured) /// The range of component `r` is `[0, 1]`. fn seal_terminate(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `810 + r * (356 ±0)` - // Estimated: `25511 + r * (15321 ±0)` - // Minimum execution time: 284_143_000 picoseconds. - Weight::from_parts(287_218_324, 25511) - // Standard Error: 343_611 - .saturating_add(Weight::from_parts(109_895_675, 0).saturating_mul(r.into())) + // Estimated: `26094 + r * (15904 ±0)` + // Minimum execution time: 233_525_000 picoseconds. + Weight::from_parts(235_871_034, 26094) + // Standard Error: 235_338 + .saturating_add(Weight::from_parts(118_659_865, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 15321).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().writes((8_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_parts(0, 15904).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -833,10 +835,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `825 + r * (10 ±0)` // Estimated: `24283 + r * (60 ±0)` - // Minimum execution time: 285_037_000 picoseconds. - Weight::from_parts(299_804_606, 24283) - // Standard Error: 5_518 - .saturating_add(Weight::from_parts(1_848_164, 0).saturating_mul(r.into())) + // Minimum execution time: 235_007_000 picoseconds. + Weight::from_parts(248_419_686, 24283) + // Standard Error: 1_847 + .saturating_add(Weight::from_parts(1_815_822, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 60).saturating_mul(r.into())) @@ -856,10 +858,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `778 + r * (10 ±0)` // Estimated: `21735 + r * (50 ±0)` - // Minimum execution time: 282_886_000 picoseconds. - Weight::from_parts(293_171_736, 21735) - // Standard Error: 2_171 - .saturating_add(Weight::from_parts(3_491_303, 0).saturating_mul(r.into())) + // Minimum execution time: 232_912_000 picoseconds. + Weight::from_parts(256_142_885, 21735) + // Standard Error: 2_741 + .saturating_add(Weight::from_parts(3_542_482, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 50).saturating_mul(r.into())) @@ -880,12 +882,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `797 + t * (32 ±0)` // Estimated: `21840 + t * (2640 ±0)` - // Minimum execution time: 300_675_000 picoseconds. - Weight::from_parts(296_092_420, 21840) - // Standard Error: 130_733 - .saturating_add(Weight::from_parts(2_487_957, 0).saturating_mul(t.into())) - // Standard Error: 36 - .saturating_add(Weight::from_parts(565, 0).saturating_mul(n.into())) + // Minimum execution time: 251_018_000 picoseconds. + Weight::from_parts(245_280_765, 21840) + // Standard Error: 90_317 + .saturating_add(Weight::from_parts(2_434_496, 0).saturating_mul(t.into())) + // Standard Error: 25 + .saturating_add(Weight::from_parts(599, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -907,10 +909,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `777 + r * (7 ±0)` // Estimated: `21725 + r * (35 ±0)` - // Minimum execution time: 166_638_000 picoseconds. - Weight::from_parts(171_353_083, 21725) - // Standard Error: 550 - .saturating_add(Weight::from_parts(238_768, 0).saturating_mul(r.into())) + // Minimum execution time: 164_022_000 picoseconds. + Weight::from_parts(168_658_387, 21725) + // Standard Error: 685 + .saturating_add(Weight::from_parts(238_133, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 35).saturating_mul(r.into())) @@ -930,10 +932,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `125728` // Estimated: `269977` - // Minimum execution time: 414_136_000 picoseconds. - Weight::from_parts(416_093_921, 269977) + // Minimum execution time: 351_043_000 picoseconds. + Weight::from_parts(353_707_344, 269977) // Standard Error: 3 - .saturating_add(Weight::from_parts(794, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(752, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -944,10 +946,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `845 + r * (292 ±0)` // Estimated: `843 + r * (293 ±0)` - // Minimum execution time: 285_920_000 picoseconds. - Weight::from_parts(184_945_789, 843) - // Standard Error: 9_604 - .saturating_add(Weight::from_parts(6_012_522, 0).saturating_mul(r.into())) + // Minimum execution time: 235_854_000 picoseconds. + Weight::from_parts(133_986_225, 843) + // Standard Error: 9_550 + .saturating_add(Weight::from_parts(6_093_051, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -961,10 +963,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1304` // Estimated: `1280` - // Minimum execution time: 299_772_000 picoseconds. - Weight::from_parts(333_451_106, 1280) - // Standard Error: 54 - .saturating_add(Weight::from_parts(579, 0).saturating_mul(n.into())) + // Minimum execution time: 252_321_000 picoseconds. + Weight::from_parts(285_820_577, 1280) + // Standard Error: 60 + .saturating_add(Weight::from_parts(600, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -975,10 +977,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1167 + n * (1 ±0)` // Estimated: `1167 + n * (1 ±0)` - // Minimum execution time: 299_279_000 picoseconds. - Weight::from_parts(302_336_567, 1167) - // Standard Error: 25 - .saturating_add(Weight::from_parts(86, 0).saturating_mul(n.into())) + // Minimum execution time: 252_047_000 picoseconds. + Weight::from_parts(254_244_310, 1167) + // Standard Error: 15 + .saturating_add(Weight::from_parts(144, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -990,10 +992,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `841 + r * (288 ±0)` // Estimated: `845 + r * (289 ±0)` - // Minimum execution time: 284_689_000 picoseconds. - Weight::from_parts(185_207_302, 845) - // Standard Error: 10_030 - .saturating_add(Weight::from_parts(5_871_325, 0).saturating_mul(r.into())) + // Minimum execution time: 235_697_000 picoseconds. + Weight::from_parts(143_200_942, 845) + // Standard Error: 11_358 + .saturating_add(Weight::from_parts(5_934_318, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1007,10 +1009,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1163 + n * (1 ±0)` // Estimated: `1163 + n * (1 ±0)` - // Minimum execution time: 299_364_000 picoseconds. - Weight::from_parts(302_089_070, 1163) - // Standard Error: 23 - .saturating_add(Weight::from_parts(128, 0).saturating_mul(n.into())) + // Minimum execution time: 250_360_000 picoseconds. + Weight::from_parts(252_712_722, 1163) + // Standard Error: 15 + .saturating_add(Weight::from_parts(130, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -1022,10 +1024,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `835 + r * (296 ±0)` // Estimated: `840 + r * (297 ±0)` - // Minimum execution time: 285_175_000 picoseconds. - Weight::from_parts(200_262_957, 840) - // Standard Error: 8_681 - .saturating_add(Weight::from_parts(4_899_266, 0).saturating_mul(r.into())) + // Minimum execution time: 235_613_000 picoseconds. + Weight::from_parts(150_213_792, 840) + // Standard Error: 8_617 + .saturating_add(Weight::from_parts(4_962_874, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1038,10 +1040,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1179 + n * (1 ±0)` // Estimated: `1179 + n * (1 ±0)` - // Minimum execution time: 299_459_000 picoseconds. - Weight::from_parts(302_451_160, 1179) - // Standard Error: 36 - .saturating_add(Weight::from_parts(731, 0).saturating_mul(n.into())) + // Minimum execution time: 249_137_000 picoseconds. + Weight::from_parts(253_529_386, 1179) + // Standard Error: 41 + .saturating_add(Weight::from_parts(612, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -1053,10 +1055,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `856 + r * (288 ±0)` // Estimated: `857 + r * (289 ±0)` - // Minimum execution time: 286_384_000 picoseconds. - Weight::from_parts(203_389_467, 857) - // Standard Error: 8_817 - .saturating_add(Weight::from_parts(4_692_347, 0).saturating_mul(r.into())) + // Minimum execution time: 235_659_000 picoseconds. + Weight::from_parts(158_846_683, 857) + // Standard Error: 7_806 + .saturating_add(Weight::from_parts(4_728_537, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1069,10 +1071,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1166 + n * (1 ±0)` // Estimated: `1166 + n * (1 ±0)` - // Minimum execution time: 297_450_000 picoseconds. - Weight::from_parts(300_459_851, 1166) - // Standard Error: 39 - .saturating_add(Weight::from_parts(108, 0).saturating_mul(n.into())) + // Minimum execution time: 248_553_000 picoseconds. + Weight::from_parts(250_703_269, 1166) + // Standard Error: 17 + .saturating_add(Weight::from_parts(163, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -1084,10 +1086,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `829 + r * (296 ±0)` // Estimated: `836 + r * (297 ±0)` - // Minimum execution time: 285_572_000 picoseconds. - Weight::from_parts(182_642_557, 836) - // Standard Error: 9_977 - .saturating_add(Weight::from_parts(6_090_684, 0).saturating_mul(r.into())) + // Minimum execution time: 236_431_000 picoseconds. + Weight::from_parts(131_745_419, 836) + // Standard Error: 10_161 + .saturating_add(Weight::from_parts(6_182_174, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1101,10 +1103,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1180 + n * (1 ±0)` // Estimated: `1180 + n * (1 ±0)` - // Minimum execution time: 301_344_000 picoseconds. - Weight::from_parts(303_770_522, 1180) - // Standard Error: 29 - .saturating_add(Weight::from_parts(807, 0).saturating_mul(n.into())) + // Minimum execution time: 252_551_000 picoseconds. + Weight::from_parts(254_517_030, 1180) + // Standard Error: 16 + .saturating_add(Weight::from_parts(712, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -1124,10 +1126,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1373 + r * (45 ±0)` // Estimated: `26753 + r * (2700 ±0)` - // Minimum execution time: 286_835_000 picoseconds. - Weight::from_parts(245_206_457, 26753) - // Standard Error: 73_782 - .saturating_add(Weight::from_parts(36_414_448, 0).saturating_mul(r.into())) + // Minimum execution time: 236_663_000 picoseconds. + Weight::from_parts(237_485_000, 26753) + // Standard Error: 42_414 + .saturating_add(Weight::from_parts(36_849_514, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(4_u64)) @@ -1149,10 +1151,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1237 + r * (256 ±0)` // Estimated: `26028 + r * (6235 ±0)` - // Minimum execution time: 287_184_000 picoseconds. - Weight::from_parts(287_525_000, 26028) - // Standard Error: 66_791 - .saturating_add(Weight::from_parts(261_473_539, 0).saturating_mul(r.into())) + // Minimum execution time: 237_101_000 picoseconds. + Weight::from_parts(237_827_000, 26028) + // Standard Error: 82_878 + .saturating_add(Weight::from_parts(211_777_724, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1173,11 +1175,11 @@ impl WeightInfo for SubstrateWeight { fn seal_delegate_call(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0 + r * (502 ±0)` - // Estimated: `21755 + r * (6329 ±10)` - // Minimum execution time: 285_759_000 picoseconds. - Weight::from_parts(286_643_000, 21755) - // Standard Error: 133_180 - .saturating_add(Weight::from_parts(257_186_897, 0).saturating_mul(r.into())) + // Estimated: `21755 + r * (6329 ±3)` + // Minimum execution time: 241_213_000 picoseconds. + Weight::from_parts(241_900_000, 21755) + // Standard Error: 99_976 + .saturating_add(Weight::from_parts(207_520_077, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1200,12 +1202,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1154 + t * (204 ±0)` // Estimated: `31015 + t * (5970 ±0)` - // Minimum execution time: 459_675_000 picoseconds. - Weight::from_parts(427_010_987, 31015) - // Standard Error: 1_277_377 - .saturating_add(Weight::from_parts(36_899_889, 0).saturating_mul(t.into())) + // Minimum execution time: 414_784_000 picoseconds. + Weight::from_parts(384_902_379, 31015) + // Standard Error: 1_228_593 + .saturating_add(Weight::from_parts(33_226_901, 0).saturating_mul(t.into())) // Standard Error: 1 - .saturating_add(Weight::from_parts(651, 0).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(601, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(t.into()))) .saturating_add(T::DbWeight::get().writes(5_u64)) @@ -1231,10 +1233,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1301 + r * (254 ±0)` // Estimated: `30977 + r * (16635 ±0)` - // Minimum execution time: 285_816_000 picoseconds. - Weight::from_parts(286_349_000, 30977) - // Standard Error: 269_144 - .saturating_add(Weight::from_parts(394_282_520, 0).saturating_mul(r.into())) + // Minimum execution time: 236_963_000 picoseconds. + Weight::from_parts(237_711_000, 30977) + // Standard Error: 265_576 + .saturating_add(Weight::from_parts(347_359_908, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(6_u64)) @@ -1262,14 +1264,14 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1071 + t * (187 ±0)` // Estimated: `42684 + t * (3588 ±2)` - // Minimum execution time: 1_708_330_000 picoseconds. - Weight::from_parts(395_059_764, 42684) - // Standard Error: 4_545_552 - .saturating_add(Weight::from_parts(114_039_862, 0).saturating_mul(t.into())) + // Minimum execution time: 1_615_191_000 picoseconds. + Weight::from_parts(337_408_450, 42684) + // Standard Error: 4_581_951 + .saturating_add(Weight::from_parts(115_730_776, 0).saturating_mul(t.into())) // Standard Error: 7 - .saturating_add(Weight::from_parts(1_213, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(1_171, 0).saturating_mul(i.into())) // Standard Error: 7 - .saturating_add(Weight::from_parts(1_379, 0).saturating_mul(s.into())) + .saturating_add(Weight::from_parts(1_346, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(13_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(T::DbWeight::get().writes(10_u64)) @@ -1291,10 +1293,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `777 + r * (8 ±0)` // Estimated: `21710 + r * (40 ±0)` - // Minimum execution time: 283_738_000 picoseconds. - Weight::from_parts(289_885_978, 21710) - // Standard Error: 1_057 - .saturating_add(Weight::from_parts(575_432, 0).saturating_mul(r.into())) + // Minimum execution time: 233_601_000 picoseconds. + Weight::from_parts(246_594_905, 21710) + // Standard Error: 2_840 + .saturating_add(Weight::from_parts(578_751, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -1314,10 +1316,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `785` // Estimated: `21745` - // Minimum execution time: 285_070_000 picoseconds. - Weight::from_parts(283_987_687, 21745) - // Standard Error: 6 - .saturating_add(Weight::from_parts(4_008, 0).saturating_mul(n.into())) + // Minimum execution time: 233_735_000 picoseconds. + Weight::from_parts(243_432_330, 21745) + // Standard Error: 3 + .saturating_add(Weight::from_parts(3_927, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1336,10 +1338,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `779 + r * (8 ±0)` // Estimated: `21725 + r * (40 ±0)` - // Minimum execution time: 281_613_000 picoseconds. - Weight::from_parts(285_429_053, 21725) - // Standard Error: 1_164 - .saturating_add(Weight::from_parts(756_244, 0).saturating_mul(r.into())) + // Minimum execution time: 232_173_000 picoseconds. + Weight::from_parts(239_806_011, 21725) + // Standard Error: 1_530 + .saturating_add(Weight::from_parts(749_641, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -1359,10 +1361,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `787` // Estimated: `21765` - // Minimum execution time: 284_593_000 picoseconds. - Weight::from_parts(278_467_111, 21765) + // Minimum execution time: 235_046_000 picoseconds. + Weight::from_parts(229_500_792, 21765) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_217, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(3_166, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1381,10 +1383,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `779 + r * (8 ±0)` // Estimated: `21740 + r * (40 ±0)` - // Minimum execution time: 281_759_000 picoseconds. - Weight::from_parts(288_807_137, 21740) - // Standard Error: 805 - .saturating_add(Weight::from_parts(424_378, 0).saturating_mul(r.into())) + // Minimum execution time: 231_708_000 picoseconds. + Weight::from_parts(235_347_566, 21740) + // Standard Error: 987 + .saturating_add(Weight::from_parts(428_819, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -1404,10 +1406,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `787` // Estimated: `21785` - // Minimum execution time: 282_666_000 picoseconds. - Weight::from_parts(274_357_944, 21785) - // Standard Error: 2 - .saturating_add(Weight::from_parts(974, 0).saturating_mul(n.into())) + // Minimum execution time: 234_068_000 picoseconds. + Weight::from_parts(226_519_852, 21785) + // Standard Error: 1 + .saturating_add(Weight::from_parts(916, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1426,10 +1428,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `779 + r * (8 ±0)` // Estimated: `21745 + r * (40 ±0)` - // Minimum execution time: 285_073_000 picoseconds. - Weight::from_parts(287_226_796, 21745) - // Standard Error: 951 - .saturating_add(Weight::from_parts(425_368, 0).saturating_mul(r.into())) + // Minimum execution time: 231_872_000 picoseconds. + Weight::from_parts(236_694_763, 21745) + // Standard Error: 870 + .saturating_add(Weight::from_parts(420_853, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -1449,10 +1451,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `787` // Estimated: `21755` - // Minimum execution time: 283_407_000 picoseconds. - Weight::from_parts(276_737_242, 21755) + // Minimum execution time: 233_707_000 picoseconds. + Weight::from_parts(226_312_559, 21755) // Standard Error: 2 - .saturating_add(Weight::from_parts(967, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(924, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -1471,10 +1473,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `822 + r * (76 ±0)` // Estimated: `21705 + r * (385 ±0)` - // Minimum execution time: 285_130_000 picoseconds. - Weight::from_parts(299_449_202, 21705) - // Standard Error: 16_535 - .saturating_add(Weight::from_parts(37_655_189, 0).saturating_mul(r.into())) + // Minimum execution time: 234_962_000 picoseconds. + Weight::from_parts(252_611_292, 21705) + // Standard Error: 20_134 + .saturating_add(Weight::from_parts(37_745_358, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 385).saturating_mul(r.into())) @@ -1493,11 +1495,11 @@ impl WeightInfo for SubstrateWeight { fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `792 + r * (42 ±0)` - // Estimated: `21780 + r * (210 ±0)` - // Minimum execution time: 284_494_000 picoseconds. - Weight::from_parts(282_154_339, 21780) - // Standard Error: 12_278 - .saturating_add(Weight::from_parts(9_501_559, 0).saturating_mul(r.into())) + // Estimated: `21775 + r * (210 ±0)` + // Minimum execution time: 234_869_000 picoseconds. + Weight::from_parts(240_188_331, 21775) + // Standard Error: 9_910 + .saturating_add(Weight::from_parts(9_332_432, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 210).saturating_mul(r.into())) @@ -1518,11 +1520,11 @@ impl WeightInfo for SubstrateWeight { fn seal_set_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0 + r * (964 ±0)` - // Estimated: `29920 + r * (11544 ±7)` - // Minimum execution time: 285_306_000 picoseconds. - Weight::from_parts(286_080_000, 29920) - // Standard Error: 43_813 - .saturating_add(Weight::from_parts(21_758_329, 0).saturating_mul(r.into())) + // Estimated: `29920 + r * (11544 ±10)` + // Minimum execution time: 235_036_000 picoseconds. + Weight::from_parts(235_538_000, 29920) + // Standard Error: 47_360 + .saturating_add(Weight::from_parts(22_113_144, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -1544,10 +1546,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `773 + r * (3 ±0)` // Estimated: `21735 + r * (15 ±0)` - // Minimum execution time: 283_487_000 picoseconds. - Weight::from_parts(289_280_189, 21735) - // Standard Error: 829 - .saturating_add(Weight::from_parts(168_973, 0).saturating_mul(r.into())) + // Minimum execution time: 237_884_000 picoseconds. + Weight::from_parts(243_315_095, 21735) + // Standard Error: 560 + .saturating_add(Weight::from_parts(162_206, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 15).saturating_mul(r.into())) @@ -1567,10 +1569,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1975 + r * (39 ±0)` // Estimated: `27145 + r * (200 ±0)` - // Minimum execution time: 287_413_000 picoseconds. - Weight::from_parts(314_662_286, 27145) - // Standard Error: 1_099 - .saturating_add(Weight::from_parts(262_201, 0).saturating_mul(r.into())) + // Minimum execution time: 239_402_000 picoseconds. + Weight::from_parts(267_214_783, 27145) + // Standard Error: 1_166 + .saturating_add(Weight::from_parts(261_915, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 200).saturating_mul(r.into())) @@ -1592,10 +1594,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `776 + r * (3 ±0)` // Estimated: `24004 + r * (18 ±0)` - // Minimum execution time: 282_601_000 picoseconds. - Weight::from_parts(289_374_203, 24004) - // Standard Error: 452 - .saturating_add(Weight::from_parts(142_661, 0).saturating_mul(r.into())) + // Minimum execution time: 233_153_000 picoseconds. + Weight::from_parts(238_999_965, 24004) + // Standard Error: 291 + .saturating_add(Weight::from_parts(143_971, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 18).saturating_mul(r.into())) @@ -1605,521 +1607,523 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_692_000 picoseconds. - Weight::from_parts(2_069_482, 0) - // Standard Error: 40 - .saturating_add(Weight::from_parts(2_922, 0).saturating_mul(r.into())) + // Minimum execution time: 1_706_000 picoseconds. + Weight::from_parts(1_962_558, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(3_000, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64load(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_690_000 picoseconds. - Weight::from_parts(2_303_602, 0) + // Minimum execution time: 1_870_000 picoseconds. + Weight::from_parts(2_481_243, 0) // Standard Error: 4 - .saturating_add(Weight::from_parts(6_433, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(6_346, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64store(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_701_000 picoseconds. - Weight::from_parts(2_321_142, 0) + // Minimum execution time: 1_830_000 picoseconds. + Weight::from_parts(2_389_658, 0) // Standard Error: 4 - .saturating_add(Weight::from_parts(6_025, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_997, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_select(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_656_000 picoseconds. - Weight::from_parts(2_090_881, 0) - // Standard Error: 5 - .saturating_add(Weight::from_parts(7_941, 0).saturating_mul(r.into())) + // Minimum execution time: 1_734_000 picoseconds. + Weight::from_parts(2_170_618, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(7_919, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_if(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_659_000 picoseconds. - Weight::from_parts(1_816_547, 0) - // Standard Error: 5 - .saturating_add(Weight::from_parts(10_578, 0).saturating_mul(r.into())) + // Minimum execution time: 1_661_000 picoseconds. + Weight::from_parts(1_945_771, 0) + // Standard Error: 11 + .saturating_add(Weight::from_parts(10_840, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_br(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_683_000 picoseconds. - Weight::from_parts(1_970_907, 0) - // Standard Error: 12 - .saturating_add(Weight::from_parts(4_636, 0).saturating_mul(r.into())) + // Minimum execution time: 1_682_000 picoseconds. + Weight::from_parts(1_970_774, 0) + // Standard Error: 11 + .saturating_add(Weight::from_parts(4_569, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_br_if(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_651_000 picoseconds. - Weight::from_parts(2_263_817, 0) - // Standard Error: 68 - .saturating_add(Weight::from_parts(7_529, 0).saturating_mul(r.into())) + // Minimum execution time: 1_668_000 picoseconds. + Weight::from_parts(1_227_080, 0) + // Standard Error: 76 + .saturating_add(Weight::from_parts(8_066, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_br_table(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_687_000 picoseconds. - Weight::from_parts(1_349_186, 0) - // Standard Error: 31 - .saturating_add(Weight::from_parts(9_732, 0).saturating_mul(r.into())) + // Minimum execution time: 1_653_000 picoseconds. + Weight::from_parts(1_394_759, 0) + // Standard Error: 39 + .saturating_add(Weight::from_parts(9_566, 0).saturating_mul(r.into())) } /// The range of component `e` is `[1, 256]`. - fn instr_br_table_per_entry(_e: u32, ) -> Weight { + fn instr_br_table_per_entry(e: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_777_000 picoseconds. - Weight::from_parts(2_036_446, 0) + // Minimum execution time: 1_771_000 picoseconds. + Weight::from_parts(1_905_594, 0) + // Standard Error: 147 + .saturating_add(Weight::from_parts(925, 0).saturating_mul(e.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_call(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_686_000 picoseconds. - Weight::from_parts(464_449, 0) - // Standard Error: 383 - .saturating_add(Weight::from_parts(19_121, 0).saturating_mul(r.into())) + // Minimum execution time: 1_863_000 picoseconds. + Weight::from_parts(2_472_635, 0) + // Standard Error: 13 + .saturating_add(Weight::from_parts(17_892, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_call_indirect(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_855_000 picoseconds. - Weight::from_parts(3_381_585, 0) + // Minimum execution time: 2_013_000 picoseconds. + Weight::from_parts(3_077_100, 0) // Standard Error: 18 - .saturating_add(Weight::from_parts(24_245, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(24_287, 0).saturating_mul(r.into())) } /// The range of component `l` is `[0, 1024]`. fn instr_call_per_local(l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_792_000 picoseconds. - Weight::from_parts(2_006_024, 0) - // Standard Error: 16 - .saturating_add(Weight::from_parts(2_181, 0).saturating_mul(l.into())) + // Minimum execution time: 1_818_000 picoseconds. + Weight::from_parts(2_109_143, 0) + // Standard Error: 34 + .saturating_add(Weight::from_parts(1_249, 0).saturating_mul(l.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_local_get(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_918_000 picoseconds. - Weight::from_parts(4_618_761, 0) - // Standard Error: 49 - .saturating_add(Weight::from_parts(2_312, 0).saturating_mul(r.into())) + // Minimum execution time: 3_083_000 picoseconds. + Weight::from_parts(3_291_328, 0) + // Standard Error: 1 + .saturating_add(Weight::from_parts(2_505, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_local_set(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_889_000 picoseconds. - Weight::from_parts(4_151_280, 0) + // Minimum execution time: 2_987_000 picoseconds. + Weight::from_parts(3_276_863, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_623, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(3_617, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_local_tee(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_880_000 picoseconds. - Weight::from_parts(4_225_780, 0) + // Minimum execution time: 2_942_000 picoseconds. + Weight::from_parts(3_350_581, 0) // Standard Error: 3 - .saturating_add(Weight::from_parts(3_847, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(3_976, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_global_get(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_765_000 picoseconds. - Weight::from_parts(2_216_674, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(8_393, 0).saturating_mul(r.into())) + // Minimum execution time: 1_867_000 picoseconds. + Weight::from_parts(2_920_748, 0) + // Standard Error: 44 + .saturating_add(Weight::from_parts(8_229, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_global_set(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_764_000 picoseconds. - Weight::from_parts(2_246_735, 0) - // Standard Error: 5 - .saturating_add(Weight::from_parts(8_877, 0).saturating_mul(r.into())) + // Minimum execution time: 1_757_000 picoseconds. + Weight::from_parts(2_235_198, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(8_815, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_memory_current(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_758_000 picoseconds. - Weight::from_parts(1_922_386, 0) - // Standard Error: 94 - .saturating_add(Weight::from_parts(3_868, 0).saturating_mul(r.into())) + // Minimum execution time: 1_824_000 picoseconds. + Weight::from_parts(1_941_816, 0) + // Standard Error: 86 + .saturating_add(Weight::from_parts(4_043, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 16]`. fn instr_memory_grow(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_635_000 picoseconds. - Weight::from_parts(1_118_785, 0) - // Standard Error: 134_978 - .saturating_add(Weight::from_parts(16_343_664, 0).saturating_mul(r.into())) + // Minimum execution time: 1_793_000 picoseconds. + Weight::from_parts(1_104_829, 0) + // Standard Error: 137_800 + .saturating_add(Weight::from_parts(13_336_784, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64clz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_648_000 picoseconds. - Weight::from_parts(2_012_545, 0) + // Minimum execution time: 1_693_000 picoseconds. + Weight::from_parts(2_037_305, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_824, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(4_044, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64ctz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_688_000 picoseconds. - Weight::from_parts(1_995_956, 0) + // Minimum execution time: 1_751_000 picoseconds. + Weight::from_parts(2_082_016, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_757, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(3_767, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64popcnt(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_631_000 picoseconds. - Weight::from_parts(2_011_493, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(3_755, 0).saturating_mul(r.into())) + // Minimum execution time: 1_751_000 picoseconds. + Weight::from_parts(2_110_625, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(3_754, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64eqz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_667_000 picoseconds. - Weight::from_parts(1_958_798, 0) + // Minimum execution time: 1_756_000 picoseconds. + Weight::from_parts(2_100_327, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_677, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(3_664, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64extendsi32(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_674_000 picoseconds. - Weight::from_parts(2_009_555, 0) - // Standard Error: 7 - .saturating_add(Weight::from_parts(3_863, 0).saturating_mul(r.into())) + // Minimum execution time: 1_643_000 picoseconds. + Weight::from_parts(2_169_153, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(3_961, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64extendui32(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_659_000 picoseconds. - Weight::from_parts(2_014_985, 0) + // Minimum execution time: 1_704_000 picoseconds. + Weight::from_parts(2_049_172, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_821, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(3_833, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i32wrapi64(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_640_000 picoseconds. - Weight::from_parts(2_013_939, 0) + // Minimum execution time: 1_726_000 picoseconds. + Weight::from_parts(2_064_387, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_708, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(3_745, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64eq(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_631_000 picoseconds. - Weight::from_parts(2_002_814, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(6_008, 0).saturating_mul(r.into())) + // Minimum execution time: 1_696_000 picoseconds. + Weight::from_parts(2_426_905, 0) + // Standard Error: 56 + .saturating_add(Weight::from_parts(5_915, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64ne(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_647_000 picoseconds. - Weight::from_parts(2_032_158, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(5_944, 0).saturating_mul(r.into())) + // Minimum execution time: 1_617_000 picoseconds. + Weight::from_parts(2_035_161, 0) + // Standard Error: 94 + .saturating_add(Weight::from_parts(6_073, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64lts(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_669_000 picoseconds. - Weight::from_parts(2_040_386, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(6_009, 0).saturating_mul(r.into())) + // Minimum execution time: 1_756_000 picoseconds. + Weight::from_parts(2_098_926, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(6_002, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64ltu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_637_000 picoseconds. - Weight::from_parts(1_983_695, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(6_027, 0).saturating_mul(r.into())) + // Minimum execution time: 1_706_000 picoseconds. + Weight::from_parts(2_257_972, 0) + // Standard Error: 23 + .saturating_add(Weight::from_parts(5_982, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64gts(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_701_000 picoseconds. - Weight::from_parts(2_054_295, 0) + // Minimum execution time: 1_761_000 picoseconds. + Weight::from_parts(2_114_141, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(5_799, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_815, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64gtu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_653_000 picoseconds. - Weight::from_parts(2_749_807, 0) - // Standard Error: 90 - .saturating_add(Weight::from_parts(5_945, 0).saturating_mul(r.into())) + // Minimum execution time: 1_700_000 picoseconds. + Weight::from_parts(2_053_201, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(6_137, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64les(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_651_000 picoseconds. - Weight::from_parts(1_979_111, 0) + // Minimum execution time: 1_705_000 picoseconds. + Weight::from_parts(2_101_782, 0) // Standard Error: 3 - .saturating_add(Weight::from_parts(6_011, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(6_014, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64leu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_743_000 picoseconds. - Weight::from_parts(2_058_081, 0) + // Minimum execution time: 1_856_000 picoseconds. + Weight::from_parts(2_149_707, 0) // Standard Error: 3 - .saturating_add(Weight::from_parts(6_085, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(6_086, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64ges(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_638_000 picoseconds. - Weight::from_parts(2_038_929, 0) + // Minimum execution time: 1_739_000 picoseconds. + Weight::from_parts(2_143_216, 0) // Standard Error: 3 - .saturating_add(Weight::from_parts(5_941, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_934, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64geu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_641_000 picoseconds. - Weight::from_parts(2_036_587, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(6_008, 0).saturating_mul(r.into())) + // Minimum execution time: 1_716_000 picoseconds. + Weight::from_parts(2_065_762, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(6_009, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64add(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_624_000 picoseconds. - Weight::from_parts(2_080_562, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(5_826, 0).saturating_mul(r.into())) + // Minimum execution time: 1_664_000 picoseconds. + Weight::from_parts(3_062_283, 0) + // Standard Error: 94 + .saturating_add(Weight::from_parts(5_645, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64sub(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_652_000 picoseconds. - Weight::from_parts(2_039_535, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(6_137, 0).saturating_mul(r.into())) + // Minimum execution time: 1_671_000 picoseconds. + Weight::from_parts(2_011_145, 0) + // Standard Error: 44 + .saturating_add(Weight::from_parts(6_220, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64mul(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_666_000 picoseconds. - Weight::from_parts(2_056_354, 0) - // Standard Error: 6 - .saturating_add(Weight::from_parts(5_780, 0).saturating_mul(r.into())) + // Minimum execution time: 1_759_000 picoseconds. + Weight::from_parts(2_095_420, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(5_723, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64divs(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_648_000 picoseconds. - Weight::from_parts(2_077_695, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(11_775, 0).saturating_mul(r.into())) + // Minimum execution time: 1_672_000 picoseconds. + Weight::from_parts(2_184_044, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(11_782, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64divu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_797_000 picoseconds. - Weight::from_parts(2_772_388, 0) - // Standard Error: 33 - .saturating_add(Weight::from_parts(10_333, 0).saturating_mul(r.into())) + // Minimum execution time: 1_752_000 picoseconds. + Weight::from_parts(2_276_209, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(10_513, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64rems(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_699_000 picoseconds. - Weight::from_parts(2_174_288, 0) - // Standard Error: 6 - .saturating_add(Weight::from_parts(11_778, 0).saturating_mul(r.into())) + // Minimum execution time: 1_711_000 picoseconds. + Weight::from_parts(2_720_989, 0) + // Standard Error: 24 + .saturating_add(Weight::from_parts(11_884, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64remu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_685_000 picoseconds. - Weight::from_parts(2_091_037, 0) + // Minimum execution time: 1_713_000 picoseconds. + Weight::from_parts(2_091_403, 0) // Standard Error: 3 - .saturating_add(Weight::from_parts(10_694, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(10_628, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64and(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_636_000 picoseconds. - Weight::from_parts(1_975_521, 0) + // Minimum execution time: 1_704_000 picoseconds. + Weight::from_parts(2_054_652, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(5_695, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_672, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64or(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_619_000 picoseconds. - Weight::from_parts(2_045_492, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(5_770, 0).saturating_mul(r.into())) + // Minimum execution time: 1_743_000 picoseconds. + Weight::from_parts(2_032_806, 0) + // Standard Error: 19 + .saturating_add(Weight::from_parts(5_795, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64xor(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_668_000 picoseconds. - Weight::from_parts(2_055_460, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(5_851, 0).saturating_mul(r.into())) + // Minimum execution time: 1_667_000 picoseconds. + Weight::from_parts(2_031_702, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(5_923, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64shl(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_681_000 picoseconds. - Weight::from_parts(2_023_370, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(5_853, 0).saturating_mul(r.into())) + // Minimum execution time: 1_735_000 picoseconds. + Weight::from_parts(2_946_634, 0) + // Standard Error: 54 + .saturating_add(Weight::from_parts(5_685, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64shrs(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_714_000 picoseconds. - Weight::from_parts(2_067_584, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(6_133, 0).saturating_mul(r.into())) + // Minimum execution time: 1_652_000 picoseconds. + Weight::from_parts(2_023_049, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(6_146, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64shru(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_602_000 picoseconds. - Weight::from_parts(2_055_530, 0) - // Standard Error: 138 - .saturating_add(Weight::from_parts(6_014, 0).saturating_mul(r.into())) + // Minimum execution time: 1_654_000 picoseconds. + Weight::from_parts(2_148_951, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(5_869, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64rotl(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_709_000 picoseconds. - Weight::from_parts(2_016_365, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(5_985, 0).saturating_mul(r.into())) + // Minimum execution time: 1_730_000 picoseconds. + Weight::from_parts(2_130_543, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(5_999, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64rotr(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_661_000 picoseconds. - Weight::from_parts(2_003_063, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(5_863, 0).saturating_mul(r.into())) + // Minimum execution time: 1_728_000 picoseconds. + Weight::from_parts(2_172_886, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(5_843, 0).saturating_mul(r.into())) } } // For backwards compatibility and tests impl WeightInfo for () { - /// Storage: Contracts DeletionQueue (r:1 w:0) - /// Proof: Contracts DeletionQueue (max_values: Some(1), max_size: Some(16642), added: 17137, mode: Measured) + /// Storage: Contracts DeletionQueueNonces (r:1 w:0) + /// Proof: Contracts DeletionQueueNonces (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) fn on_process_deletion_queue_batch() -> Weight { // Proof Size summary in bytes: // Measured: `109` // Estimated: `1594` - // Minimum execution time: 2_585_000 picoseconds. - Weight::from_parts(2_802_000, 1594) + // Minimum execution time: 2_677_000 picoseconds. + Weight::from_parts(2_899_000, 1594) .saturating_add(RocksDbWeight::get().reads(1_u64)) } /// Storage: Skipped Metadata (r:0 w:0) @@ -2127,15 +2131,15 @@ impl WeightInfo for () { /// The range of component `k` is `[0, 1024]`. fn on_initialize_per_trie_key(k: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `450 + k * (69 ±0)` - // Estimated: `440 + k * (70 ±0)` - // Minimum execution time: 10_825_000 picoseconds. - Weight::from_parts(5_747_064, 440) - // Standard Error: 1_037 - .saturating_add(Weight::from_parts(973_689, 0).saturating_mul(k.into())) - .saturating_add(RocksDbWeight::get().reads(1_u64)) + // Measured: `488 + k * (69 ±0)` + // Estimated: `478 + k * (70 ±0)` + // Minimum execution time: 14_006_000 picoseconds. + Weight::from_parts(8_735_946, 478) + // Standard Error: 1_370 + .saturating_add(Weight::from_parts(989_501, 0).saturating_mul(k.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(k.into()))) - .saturating_add(RocksDbWeight::get().writes(1_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(k.into()))) .saturating_add(Weight::from_parts(0, 70).saturating_mul(k.into())) } @@ -2148,10 +2152,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `238 + c * (1 ±0)` // Estimated: `3951 + c * (2 ±0)` - // Minimum execution time: 37_882_000 picoseconds. - Weight::from_parts(43_548_816, 3951) - // Standard Error: 49 - .saturating_add(Weight::from_parts(53_936, 0).saturating_mul(c.into())) + // Minimum execution time: 30_951_000 picoseconds. + Weight::from_parts(25_988_560, 3951) + // Standard Error: 57 + .saturating_add(Weight::from_parts(54_692, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 2).saturating_mul(c.into())) @@ -2171,10 +2175,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `707` // Estimated: `21400 + c * (5 ±0)` - // Minimum execution time: 313_392_000 picoseconds. - Weight::from_parts(325_419_093, 21400) - // Standard Error: 25 - .saturating_add(Weight::from_parts(37_877, 0).saturating_mul(c.into())) + // Minimum execution time: 263_107_000 picoseconds. + Weight::from_parts(268_289_665, 21400) + // Standard Error: 33 + .saturating_add(Weight::from_parts(38_534, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 5).saturating_mul(c.into())) @@ -2202,14 +2206,14 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `270` // Estimated: `26207` - // Minimum execution time: 3_274_352_000 picoseconds. - Weight::from_parts(681_171_416, 26207) - // Standard Error: 336 - .saturating_add(Weight::from_parts(106_391, 0).saturating_mul(c.into())) - // Standard Error: 19 - .saturating_add(Weight::from_parts(1_147, 0).saturating_mul(i.into())) - // Standard Error: 19 - .saturating_add(Weight::from_parts(1_493, 0).saturating_mul(s.into())) + // Minimum execution time: 3_122_319_000 picoseconds. + Weight::from_parts(487_802_180, 26207) + // Standard Error: 345 + .saturating_add(Weight::from_parts(108_237, 0).saturating_mul(c.into())) + // Standard Error: 20 + .saturating_add(Weight::from_parts(1_166, 0).saturating_mul(i.into())) + // Standard Error: 20 + .saturating_add(Weight::from_parts(1_505, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(10_u64)) } @@ -2233,12 +2237,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `482` // Estimated: `28521` - // Minimum execution time: 1_692_637_000 picoseconds. - Weight::from_parts(283_252_265, 28521) + // Minimum execution time: 1_650_623_000 picoseconds. + Weight::from_parts(286_494_456, 28521) // Standard Error: 8 - .saturating_add(Weight::from_parts(1_498, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(1_438, 0).saturating_mul(i.into())) // Standard Error: 8 - .saturating_add(Weight::from_parts(1_487, 0).saturating_mul(s.into())) + .saturating_add(Weight::from_parts(1_453, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -2256,8 +2260,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `759` // Estimated: `21615` - // Minimum execution time: 192_369_000 picoseconds. - Weight::from_parts(193_417_000, 21615) + // Minimum execution time: 191_046_000 picoseconds. + Weight::from_parts(192_544_000, 21615) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -2274,10 +2278,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `109` // Estimated: `7366` - // Minimum execution time: 301_972_000 picoseconds. - Weight::from_parts(313_248_051, 7366) - // Standard Error: 82 - .saturating_add(Weight::from_parts(107_321, 0).saturating_mul(c.into())) + // Minimum execution time: 244_260_000 picoseconds. + Weight::from_parts(254_693_985, 7366) + // Standard Error: 80 + .saturating_add(Weight::from_parts(108_246, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -2293,8 +2297,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `255` // Estimated: `7950` - // Minimum execution time: 33_013_000 picoseconds. - Weight::from_parts(33_622_000, 7950) + // Minimum execution time: 33_492_000 picoseconds. + Weight::from_parts(34_079_000, 7950) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -2308,8 +2312,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `570` // Estimated: `19530` - // Minimum execution time: 33_518_000 picoseconds. - Weight::from_parts(33_819_000, 19530) + // Minimum execution time: 33_475_000 picoseconds. + Weight::from_parts(33_856_000, 19530) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -2328,10 +2332,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `781 + r * (6 ±0)` // Estimated: `21730 + r * (30 ±0)` - // Minimum execution time: 283_945_000 picoseconds. - Weight::from_parts(289_209_599, 21730) - // Standard Error: 901 - .saturating_add(Weight::from_parts(327_601, 0).saturating_mul(r.into())) + // Minimum execution time: 234_197_000 picoseconds. + Weight::from_parts(236_830_305, 21730) + // Standard Error: 818 + .saturating_add(Weight::from_parts(336_446, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2351,10 +2355,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `839 + r * (240 ±0)` // Estimated: `21835 + r * (3675 ±0)` - // Minimum execution time: 284_949_000 picoseconds. - Weight::from_parts(126_196_485, 21835) - // Standard Error: 6_260 - .saturating_add(Weight::from_parts(3_368_849, 0).saturating_mul(r.into())) + // Minimum execution time: 235_872_000 picoseconds. + Weight::from_parts(78_877_890, 21835) + // Standard Error: 6_405 + .saturating_add(Weight::from_parts(3_358_341, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -2375,10 +2379,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `831 + r * (244 ±0)` // Estimated: `21855 + r * (3695 ±0)` - // Minimum execution time: 286_429_000 picoseconds. - Weight::from_parts(124_820_396, 21855) - // Standard Error: 6_539 - .saturating_add(Weight::from_parts(4_163_535, 0).saturating_mul(r.into())) + // Minimum execution time: 239_035_000 picoseconds. + Weight::from_parts(93_255_085, 21855) + // Standard Error: 5_922 + .saturating_add(Weight::from_parts(4_144_910, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -2399,10 +2403,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `788 + r * (6 ±0)` // Estimated: `21770 + r * (30 ±0)` - // Minimum execution time: 285_042_000 picoseconds. - Weight::from_parts(288_096_303, 21770) - // Standard Error: 972 - .saturating_add(Weight::from_parts(409_782, 0).saturating_mul(r.into())) + // Minimum execution time: 236_507_000 picoseconds. + Weight::from_parts(238_253_211, 21770) + // Standard Error: 975 + .saturating_add(Weight::from_parts(413_919, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2422,10 +2426,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `778 + r * (3 ±0)` // Estimated: `21735 + r * (15 ±0)` - // Minimum execution time: 282_820_000 picoseconds. - Weight::from_parts(287_104_710, 21735) - // Standard Error: 421 - .saturating_add(Weight::from_parts(167_907, 0).saturating_mul(r.into())) + // Minimum execution time: 235_521_000 picoseconds. + Weight::from_parts(238_397_362, 21735) + // Standard Error: 452 + .saturating_add(Weight::from_parts(160_860, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 15).saturating_mul(r.into())) @@ -2445,10 +2449,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `782 + r * (6 ±0)` // Estimated: `21740 + r * (30 ±0)` - // Minimum execution time: 284_619_000 picoseconds. - Weight::from_parts(281_326_785, 21740) - // Standard Error: 1_379 - .saturating_add(Weight::from_parts(342_779, 0).saturating_mul(r.into())) + // Minimum execution time: 234_722_000 picoseconds. + Weight::from_parts(242_936_096, 21740) + // Standard Error: 1_178 + .saturating_add(Weight::from_parts(329_075, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2468,10 +2472,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `783 + r * (6 ±0)` // Estimated: `21725 + r * (30 ±0)` - // Minimum execution time: 284_703_000 picoseconds. - Weight::from_parts(289_479_932, 21725) - // Standard Error: 745 - .saturating_add(Weight::from_parts(323_625, 0).saturating_mul(r.into())) + // Minimum execution time: 235_654_000 picoseconds. + Weight::from_parts(245_887_792, 21725) + // Standard Error: 903 + .saturating_add(Weight::from_parts(325_168, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2491,10 +2495,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `922 + r * (6 ±0)` // Estimated: `24633 + r * (30 ±0)` - // Minimum execution time: 283_610_000 picoseconds. - Weight::from_parts(299_901_534, 24633) - // Standard Error: 1_177 - .saturating_add(Weight::from_parts(1_474_603, 0).saturating_mul(r.into())) + // Minimum execution time: 233_599_000 picoseconds. + Weight::from_parts(251_561_602, 24633) + // Standard Error: 3_348 + .saturating_add(Weight::from_parts(1_475_443, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2514,10 +2518,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `792 + r * (6 ±0)` // Estimated: `21825 + r * (30 ±0)` - // Minimum execution time: 284_474_000 picoseconds. - Weight::from_parts(283_540_273, 21825) - // Standard Error: 1_164 - .saturating_add(Weight::from_parts(339_262, 0).saturating_mul(r.into())) + // Minimum execution time: 235_087_000 picoseconds. + Weight::from_parts(235_855_322, 21825) + // Standard Error: 867 + .saturating_add(Weight::from_parts(346_707, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2537,10 +2541,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `790 + r * (6 ±0)` // Estimated: `21815 + r * (30 ±0)` - // Minimum execution time: 284_521_000 picoseconds. - Weight::from_parts(285_747_754, 21815) - // Standard Error: 889 - .saturating_add(Weight::from_parts(326_428, 0).saturating_mul(r.into())) + // Minimum execution time: 237_103_000 picoseconds. + Weight::from_parts(239_272_188, 21815) + // Standard Error: 892 + .saturating_add(Weight::from_parts(328_334, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2560,10 +2564,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `787 + r * (6 ±0)` // Estimated: `21805 + r * (30 ±0)` - // Minimum execution time: 284_103_000 picoseconds. - Weight::from_parts(283_801_256, 21805) - // Standard Error: 1_051 - .saturating_add(Weight::from_parts(334_081, 0).saturating_mul(r.into())) + // Minimum execution time: 234_761_000 picoseconds. + Weight::from_parts(238_601_784, 21805) + // Standard Error: 725 + .saturating_add(Weight::from_parts(325_758, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2583,10 +2587,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `778 + r * (6 ±0)` // Estimated: `21735 + r * (30 ±0)` - // Minimum execution time: 284_187_000 picoseconds. - Weight::from_parts(289_414_364, 21735) - // Standard Error: 796 - .saturating_add(Weight::from_parts(324_603, 0).saturating_mul(r.into())) + // Minimum execution time: 235_249_000 picoseconds. + Weight::from_parts(239_861_242, 21735) + // Standard Error: 751 + .saturating_add(Weight::from_parts(325_795, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2608,10 +2612,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `856 + r * (10 ±0)` // Estimated: `24446 + r * (60 ±0)` - // Minimum execution time: 284_953_000 picoseconds. - Weight::from_parts(290_535_752, 24446) - // Standard Error: 2_462 - .saturating_add(Weight::from_parts(1_361_518, 0).saturating_mul(r.into())) + // Minimum execution time: 234_912_000 picoseconds. + Weight::from_parts(254_783_734, 24446) + // Standard Error: 1_610 + .saturating_add(Weight::from_parts(1_307_506, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 60).saturating_mul(r.into())) @@ -2631,10 +2635,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `745 + r * (4 ±0)` // Estimated: `21555 + r * (20 ±0)` - // Minimum execution time: 160_775_000 picoseconds. - Weight::from_parts(164_652_364, 21555) - // Standard Error: 284 - .saturating_add(Weight::from_parts(132_574, 0).saturating_mul(r.into())) + // Minimum execution time: 160_125_000 picoseconds. + Weight::from_parts(164_915_574, 21555) + // Standard Error: 332 + .saturating_add(Weight::from_parts(132_326, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 20).saturating_mul(r.into())) @@ -2654,10 +2658,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `780 + r * (6 ±0)` // Estimated: `21740 + r * (30 ±0)` - // Minimum execution time: 284_072_000 picoseconds. - Weight::from_parts(288_418_644, 21740) - // Standard Error: 792 - .saturating_add(Weight::from_parts(272_881, 0).saturating_mul(r.into())) + // Minimum execution time: 234_717_000 picoseconds. + Weight::from_parts(238_540_521, 21740) + // Standard Error: 599 + .saturating_add(Weight::from_parts(277_303, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 30).saturating_mul(r.into())) @@ -2677,10 +2681,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `784` // Estimated: `21740` - // Minimum execution time: 286_671_000 picoseconds. - Weight::from_parts(292_151_662, 21740) + // Minimum execution time: 235_792_000 picoseconds. + Weight::from_parts(244_114_692, 21740) // Standard Error: 1 - .saturating_add(Weight::from_parts(638, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(589, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -2699,10 +2703,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `768 + r * (45 ±0)` // Estimated: `21660 + r * (225 ±0)` - // Minimum execution time: 280_334_000 picoseconds. - Weight::from_parts(283_487_571, 21660) - // Standard Error: 267_797 - .saturating_add(Weight::from_parts(3_803_128, 0).saturating_mul(r.into())) + // Minimum execution time: 231_166_000 picoseconds. + Weight::from_parts(233_339_177, 21660) + // Standard Error: 155_889 + .saturating_add(Weight::from_parts(3_124_322, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 225).saturating_mul(r.into())) @@ -2722,10 +2726,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `778` // Estimated: `21775` - // Minimum execution time: 284_004_000 picoseconds. - Weight::from_parts(283_681_350, 21775) + // Minimum execution time: 235_721_000 picoseconds. + Weight::from_parts(237_413_703, 21775) // Standard Error: 1 - .saturating_add(Weight::from_parts(232, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(177, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -2737,26 +2741,28 @@ impl WeightInfo for () { /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Measured) /// Storage: Timestamp Now (r:1 w:0) /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: Contracts DeletionQueue (r:1 w:1) - /// Proof: Contracts DeletionQueue (max_values: Some(1), max_size: Some(16642), added: 17137, mode: Measured) + /// Storage: Contracts DeletionQueueNonces (r:1 w:1) + /// Proof: Contracts DeletionQueueNonces (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: Contracts OwnerInfoOf (r:1 w:1) /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Measured) /// Storage: System EventTopics (r:3 w:3) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: Contracts DeletionQueueMap (r:0 w:1) + /// Proof: Contracts DeletionQueueMap (max_values: None, max_size: Some(142), added: 2617, mode: Measured) /// The range of component `r` is `[0, 1]`. fn seal_terminate(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `810 + r * (356 ±0)` - // Estimated: `25511 + r * (15321 ±0)` - // Minimum execution time: 284_143_000 picoseconds. - Weight::from_parts(287_218_324, 25511) - // Standard Error: 343_611 - .saturating_add(Weight::from_parts(109_895_675, 0).saturating_mul(r.into())) + // Estimated: `26094 + r * (15904 ±0)` + // Minimum execution time: 233_525_000 picoseconds. + Weight::from_parts(235_871_034, 26094) + // Standard Error: 235_338 + .saturating_add(Weight::from_parts(118_659_865, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((6_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(RocksDbWeight::get().writes((7_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 15321).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().writes((8_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_parts(0, 15904).saturating_mul(r.into())) } /// Storage: System Account (r:1 w:0) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) @@ -2775,10 +2781,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `825 + r * (10 ±0)` // Estimated: `24283 + r * (60 ±0)` - // Minimum execution time: 285_037_000 picoseconds. - Weight::from_parts(299_804_606, 24283) - // Standard Error: 5_518 - .saturating_add(Weight::from_parts(1_848_164, 0).saturating_mul(r.into())) + // Minimum execution time: 235_007_000 picoseconds. + Weight::from_parts(248_419_686, 24283) + // Standard Error: 1_847 + .saturating_add(Weight::from_parts(1_815_822, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 60).saturating_mul(r.into())) @@ -2798,10 +2804,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `778 + r * (10 ±0)` // Estimated: `21735 + r * (50 ±0)` - // Minimum execution time: 282_886_000 picoseconds. - Weight::from_parts(293_171_736, 21735) - // Standard Error: 2_171 - .saturating_add(Weight::from_parts(3_491_303, 0).saturating_mul(r.into())) + // Minimum execution time: 232_912_000 picoseconds. + Weight::from_parts(256_142_885, 21735) + // Standard Error: 2_741 + .saturating_add(Weight::from_parts(3_542_482, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 50).saturating_mul(r.into())) @@ -2822,12 +2828,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `797 + t * (32 ±0)` // Estimated: `21840 + t * (2640 ±0)` - // Minimum execution time: 300_675_000 picoseconds. - Weight::from_parts(296_092_420, 21840) - // Standard Error: 130_733 - .saturating_add(Weight::from_parts(2_487_957, 0).saturating_mul(t.into())) - // Standard Error: 36 - .saturating_add(Weight::from_parts(565, 0).saturating_mul(n.into())) + // Minimum execution time: 251_018_000 picoseconds. + Weight::from_parts(245_280_765, 21840) + // Standard Error: 90_317 + .saturating_add(Weight::from_parts(2_434_496, 0).saturating_mul(t.into())) + // Standard Error: 25 + .saturating_add(Weight::from_parts(599, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -2849,10 +2855,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `777 + r * (7 ±0)` // Estimated: `21725 + r * (35 ±0)` - // Minimum execution time: 166_638_000 picoseconds. - Weight::from_parts(171_353_083, 21725) - // Standard Error: 550 - .saturating_add(Weight::from_parts(238_768, 0).saturating_mul(r.into())) + // Minimum execution time: 164_022_000 picoseconds. + Weight::from_parts(168_658_387, 21725) + // Standard Error: 685 + .saturating_add(Weight::from_parts(238_133, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 35).saturating_mul(r.into())) @@ -2872,10 +2878,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `125728` // Estimated: `269977` - // Minimum execution time: 414_136_000 picoseconds. - Weight::from_parts(416_093_921, 269977) + // Minimum execution time: 351_043_000 picoseconds. + Weight::from_parts(353_707_344, 269977) // Standard Error: 3 - .saturating_add(Weight::from_parts(794, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(752, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -2886,10 +2892,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `845 + r * (292 ±0)` // Estimated: `843 + r * (293 ±0)` - // Minimum execution time: 285_920_000 picoseconds. - Weight::from_parts(184_945_789, 843) - // Standard Error: 9_604 - .saturating_add(Weight::from_parts(6_012_522, 0).saturating_mul(r.into())) + // Minimum execution time: 235_854_000 picoseconds. + Weight::from_parts(133_986_225, 843) + // Standard Error: 9_550 + .saturating_add(Weight::from_parts(6_093_051, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -2903,10 +2909,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1304` // Estimated: `1280` - // Minimum execution time: 299_772_000 picoseconds. - Weight::from_parts(333_451_106, 1280) - // Standard Error: 54 - .saturating_add(Weight::from_parts(579, 0).saturating_mul(n.into())) + // Minimum execution time: 252_321_000 picoseconds. + Weight::from_parts(285_820_577, 1280) + // Standard Error: 60 + .saturating_add(Weight::from_parts(600, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -2917,10 +2923,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1167 + n * (1 ±0)` // Estimated: `1167 + n * (1 ±0)` - // Minimum execution time: 299_279_000 picoseconds. - Weight::from_parts(302_336_567, 1167) - // Standard Error: 25 - .saturating_add(Weight::from_parts(86, 0).saturating_mul(n.into())) + // Minimum execution time: 252_047_000 picoseconds. + Weight::from_parts(254_244_310, 1167) + // Standard Error: 15 + .saturating_add(Weight::from_parts(144, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -2932,10 +2938,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `841 + r * (288 ±0)` // Estimated: `845 + r * (289 ±0)` - // Minimum execution time: 284_689_000 picoseconds. - Weight::from_parts(185_207_302, 845) - // Standard Error: 10_030 - .saturating_add(Weight::from_parts(5_871_325, 0).saturating_mul(r.into())) + // Minimum execution time: 235_697_000 picoseconds. + Weight::from_parts(143_200_942, 845) + // Standard Error: 11_358 + .saturating_add(Weight::from_parts(5_934_318, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -2949,10 +2955,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1163 + n * (1 ±0)` // Estimated: `1163 + n * (1 ±0)` - // Minimum execution time: 299_364_000 picoseconds. - Weight::from_parts(302_089_070, 1163) - // Standard Error: 23 - .saturating_add(Weight::from_parts(128, 0).saturating_mul(n.into())) + // Minimum execution time: 250_360_000 picoseconds. + Weight::from_parts(252_712_722, 1163) + // Standard Error: 15 + .saturating_add(Weight::from_parts(130, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -2964,10 +2970,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `835 + r * (296 ±0)` // Estimated: `840 + r * (297 ±0)` - // Minimum execution time: 285_175_000 picoseconds. - Weight::from_parts(200_262_957, 840) - // Standard Error: 8_681 - .saturating_add(Weight::from_parts(4_899_266, 0).saturating_mul(r.into())) + // Minimum execution time: 235_613_000 picoseconds. + Weight::from_parts(150_213_792, 840) + // Standard Error: 8_617 + .saturating_add(Weight::from_parts(4_962_874, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -2980,10 +2986,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1179 + n * (1 ±0)` // Estimated: `1179 + n * (1 ±0)` - // Minimum execution time: 299_459_000 picoseconds. - Weight::from_parts(302_451_160, 1179) - // Standard Error: 36 - .saturating_add(Weight::from_parts(731, 0).saturating_mul(n.into())) + // Minimum execution time: 249_137_000 picoseconds. + Weight::from_parts(253_529_386, 1179) + // Standard Error: 41 + .saturating_add(Weight::from_parts(612, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -2995,10 +3001,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `856 + r * (288 ±0)` // Estimated: `857 + r * (289 ±0)` - // Minimum execution time: 286_384_000 picoseconds. - Weight::from_parts(203_389_467, 857) - // Standard Error: 8_817 - .saturating_add(Weight::from_parts(4_692_347, 0).saturating_mul(r.into())) + // Minimum execution time: 235_659_000 picoseconds. + Weight::from_parts(158_846_683, 857) + // Standard Error: 7_806 + .saturating_add(Weight::from_parts(4_728_537, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3011,10 +3017,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1166 + n * (1 ±0)` // Estimated: `1166 + n * (1 ±0)` - // Minimum execution time: 297_450_000 picoseconds. - Weight::from_parts(300_459_851, 1166) - // Standard Error: 39 - .saturating_add(Weight::from_parts(108, 0).saturating_mul(n.into())) + // Minimum execution time: 248_553_000 picoseconds. + Weight::from_parts(250_703_269, 1166) + // Standard Error: 17 + .saturating_add(Weight::from_parts(163, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -3026,10 +3032,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `829 + r * (296 ±0)` // Estimated: `836 + r * (297 ±0)` - // Minimum execution time: 285_572_000 picoseconds. - Weight::from_parts(182_642_557, 836) - // Standard Error: 9_977 - .saturating_add(Weight::from_parts(6_090_684, 0).saturating_mul(r.into())) + // Minimum execution time: 236_431_000 picoseconds. + Weight::from_parts(131_745_419, 836) + // Standard Error: 10_161 + .saturating_add(Weight::from_parts(6_182_174, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3043,10 +3049,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1180 + n * (1 ±0)` // Estimated: `1180 + n * (1 ±0)` - // Minimum execution time: 301_344_000 picoseconds. - Weight::from_parts(303_770_522, 1180) - // Standard Error: 29 - .saturating_add(Weight::from_parts(807, 0).saturating_mul(n.into())) + // Minimum execution time: 252_551_000 picoseconds. + Weight::from_parts(254_517_030, 1180) + // Standard Error: 16 + .saturating_add(Weight::from_parts(712, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -3066,10 +3072,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1373 + r * (45 ±0)` // Estimated: `26753 + r * (2700 ±0)` - // Minimum execution time: 286_835_000 picoseconds. - Weight::from_parts(245_206_457, 26753) - // Standard Error: 73_782 - .saturating_add(Weight::from_parts(36_414_448, 0).saturating_mul(r.into())) + // Minimum execution time: 236_663_000 picoseconds. + Weight::from_parts(237_485_000, 26753) + // Standard Error: 42_414 + .saturating_add(Weight::from_parts(36_849_514, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(4_u64)) @@ -3091,10 +3097,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1237 + r * (256 ±0)` // Estimated: `26028 + r * (6235 ±0)` - // Minimum execution time: 287_184_000 picoseconds. - Weight::from_parts(287_525_000, 26028) - // Standard Error: 66_791 - .saturating_add(Weight::from_parts(261_473_539, 0).saturating_mul(r.into())) + // Minimum execution time: 237_101_000 picoseconds. + Weight::from_parts(237_827_000, 26028) + // Standard Error: 82_878 + .saturating_add(Weight::from_parts(211_777_724, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3115,11 +3121,11 @@ impl WeightInfo for () { fn seal_delegate_call(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0 + r * (502 ±0)` - // Estimated: `21755 + r * (6329 ±10)` - // Minimum execution time: 285_759_000 picoseconds. - Weight::from_parts(286_643_000, 21755) - // Standard Error: 133_180 - .saturating_add(Weight::from_parts(257_186_897, 0).saturating_mul(r.into())) + // Estimated: `21755 + r * (6329 ±3)` + // Minimum execution time: 241_213_000 picoseconds. + Weight::from_parts(241_900_000, 21755) + // Standard Error: 99_976 + .saturating_add(Weight::from_parts(207_520_077, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3142,12 +3148,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1154 + t * (204 ±0)` // Estimated: `31015 + t * (5970 ±0)` - // Minimum execution time: 459_675_000 picoseconds. - Weight::from_parts(427_010_987, 31015) - // Standard Error: 1_277_377 - .saturating_add(Weight::from_parts(36_899_889, 0).saturating_mul(t.into())) + // Minimum execution time: 414_784_000 picoseconds. + Weight::from_parts(384_902_379, 31015) + // Standard Error: 1_228_593 + .saturating_add(Weight::from_parts(33_226_901, 0).saturating_mul(t.into())) // Standard Error: 1 - .saturating_add(Weight::from_parts(651, 0).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(601, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(t.into()))) .saturating_add(RocksDbWeight::get().writes(5_u64)) @@ -3173,10 +3179,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1301 + r * (254 ±0)` // Estimated: `30977 + r * (16635 ±0)` - // Minimum execution time: 285_816_000 picoseconds. - Weight::from_parts(286_349_000, 30977) - // Standard Error: 269_144 - .saturating_add(Weight::from_parts(394_282_520, 0).saturating_mul(r.into())) + // Minimum execution time: 236_963_000 picoseconds. + Weight::from_parts(237_711_000, 30977) + // Standard Error: 265_576 + .saturating_add(Weight::from_parts(347_359_908, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((6_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(6_u64)) @@ -3204,14 +3210,14 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1071 + t * (187 ±0)` // Estimated: `42684 + t * (3588 ±2)` - // Minimum execution time: 1_708_330_000 picoseconds. - Weight::from_parts(395_059_764, 42684) - // Standard Error: 4_545_552 - .saturating_add(Weight::from_parts(114_039_862, 0).saturating_mul(t.into())) + // Minimum execution time: 1_615_191_000 picoseconds. + Weight::from_parts(337_408_450, 42684) + // Standard Error: 4_581_951 + .saturating_add(Weight::from_parts(115_730_776, 0).saturating_mul(t.into())) // Standard Error: 7 - .saturating_add(Weight::from_parts(1_213, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(1_171, 0).saturating_mul(i.into())) // Standard Error: 7 - .saturating_add(Weight::from_parts(1_379, 0).saturating_mul(s.into())) + .saturating_add(Weight::from_parts(1_346, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(13_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(RocksDbWeight::get().writes(10_u64)) @@ -3233,10 +3239,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `777 + r * (8 ±0)` // Estimated: `21710 + r * (40 ±0)` - // Minimum execution time: 283_738_000 picoseconds. - Weight::from_parts(289_885_978, 21710) - // Standard Error: 1_057 - .saturating_add(Weight::from_parts(575_432, 0).saturating_mul(r.into())) + // Minimum execution time: 233_601_000 picoseconds. + Weight::from_parts(246_594_905, 21710) + // Standard Error: 2_840 + .saturating_add(Weight::from_parts(578_751, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -3256,10 +3262,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `785` // Estimated: `21745` - // Minimum execution time: 285_070_000 picoseconds. - Weight::from_parts(283_987_687, 21745) - // Standard Error: 6 - .saturating_add(Weight::from_parts(4_008, 0).saturating_mul(n.into())) + // Minimum execution time: 233_735_000 picoseconds. + Weight::from_parts(243_432_330, 21745) + // Standard Error: 3 + .saturating_add(Weight::from_parts(3_927, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3278,10 +3284,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `779 + r * (8 ±0)` // Estimated: `21725 + r * (40 ±0)` - // Minimum execution time: 281_613_000 picoseconds. - Weight::from_parts(285_429_053, 21725) - // Standard Error: 1_164 - .saturating_add(Weight::from_parts(756_244, 0).saturating_mul(r.into())) + // Minimum execution time: 232_173_000 picoseconds. + Weight::from_parts(239_806_011, 21725) + // Standard Error: 1_530 + .saturating_add(Weight::from_parts(749_641, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -3301,10 +3307,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `787` // Estimated: `21765` - // Minimum execution time: 284_593_000 picoseconds. - Weight::from_parts(278_467_111, 21765) + // Minimum execution time: 235_046_000 picoseconds. + Weight::from_parts(229_500_792, 21765) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_217, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(3_166, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3323,10 +3329,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `779 + r * (8 ±0)` // Estimated: `21740 + r * (40 ±0)` - // Minimum execution time: 281_759_000 picoseconds. - Weight::from_parts(288_807_137, 21740) - // Standard Error: 805 - .saturating_add(Weight::from_parts(424_378, 0).saturating_mul(r.into())) + // Minimum execution time: 231_708_000 picoseconds. + Weight::from_parts(235_347_566, 21740) + // Standard Error: 987 + .saturating_add(Weight::from_parts(428_819, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -3346,10 +3352,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `787` // Estimated: `21785` - // Minimum execution time: 282_666_000 picoseconds. - Weight::from_parts(274_357_944, 21785) - // Standard Error: 2 - .saturating_add(Weight::from_parts(974, 0).saturating_mul(n.into())) + // Minimum execution time: 234_068_000 picoseconds. + Weight::from_parts(226_519_852, 21785) + // Standard Error: 1 + .saturating_add(Weight::from_parts(916, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3368,10 +3374,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `779 + r * (8 ±0)` // Estimated: `21745 + r * (40 ±0)` - // Minimum execution time: 285_073_000 picoseconds. - Weight::from_parts(287_226_796, 21745) - // Standard Error: 951 - .saturating_add(Weight::from_parts(425_368, 0).saturating_mul(r.into())) + // Minimum execution time: 231_872_000 picoseconds. + Weight::from_parts(236_694_763, 21745) + // Standard Error: 870 + .saturating_add(Weight::from_parts(420_853, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) @@ -3391,10 +3397,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `787` // Estimated: `21755` - // Minimum execution time: 283_407_000 picoseconds. - Weight::from_parts(276_737_242, 21755) + // Minimum execution time: 233_707_000 picoseconds. + Weight::from_parts(226_312_559, 21755) // Standard Error: 2 - .saturating_add(Weight::from_parts(967, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(924, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -3413,10 +3419,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `822 + r * (76 ±0)` // Estimated: `21705 + r * (385 ±0)` - // Minimum execution time: 285_130_000 picoseconds. - Weight::from_parts(299_449_202, 21705) - // Standard Error: 16_535 - .saturating_add(Weight::from_parts(37_655_189, 0).saturating_mul(r.into())) + // Minimum execution time: 234_962_000 picoseconds. + Weight::from_parts(252_611_292, 21705) + // Standard Error: 20_134 + .saturating_add(Weight::from_parts(37_745_358, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 385).saturating_mul(r.into())) @@ -3435,11 +3441,11 @@ impl WeightInfo for () { fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `792 + r * (42 ±0)` - // Estimated: `21780 + r * (210 ±0)` - // Minimum execution time: 284_494_000 picoseconds. - Weight::from_parts(282_154_339, 21780) - // Standard Error: 12_278 - .saturating_add(Weight::from_parts(9_501_559, 0).saturating_mul(r.into())) + // Estimated: `21775 + r * (210 ±0)` + // Minimum execution time: 234_869_000 picoseconds. + Weight::from_parts(240_188_331, 21775) + // Standard Error: 9_910 + .saturating_add(Weight::from_parts(9_332_432, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 210).saturating_mul(r.into())) @@ -3460,11 +3466,11 @@ impl WeightInfo for () { fn seal_set_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0 + r * (964 ±0)` - // Estimated: `29920 + r * (11544 ±7)` - // Minimum execution time: 285_306_000 picoseconds. - Weight::from_parts(286_080_000, 29920) - // Standard Error: 43_813 - .saturating_add(Weight::from_parts(21_758_329, 0).saturating_mul(r.into())) + // Estimated: `29920 + r * (11544 ±10)` + // Minimum execution time: 235_036_000 picoseconds. + Weight::from_parts(235_538_000, 29920) + // Standard Error: 47_360 + .saturating_add(Weight::from_parts(22_113_144, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -3486,10 +3492,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `773 + r * (3 ±0)` // Estimated: `21735 + r * (15 ±0)` - // Minimum execution time: 283_487_000 picoseconds. - Weight::from_parts(289_280_189, 21735) - // Standard Error: 829 - .saturating_add(Weight::from_parts(168_973, 0).saturating_mul(r.into())) + // Minimum execution time: 237_884_000 picoseconds. + Weight::from_parts(243_315_095, 21735) + // Standard Error: 560 + .saturating_add(Weight::from_parts(162_206, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 15).saturating_mul(r.into())) @@ -3509,10 +3515,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1975 + r * (39 ±0)` // Estimated: `27145 + r * (200 ±0)` - // Minimum execution time: 287_413_000 picoseconds. - Weight::from_parts(314_662_286, 27145) - // Standard Error: 1_099 - .saturating_add(Weight::from_parts(262_201, 0).saturating_mul(r.into())) + // Minimum execution time: 239_402_000 picoseconds. + Weight::from_parts(267_214_783, 27145) + // Standard Error: 1_166 + .saturating_add(Weight::from_parts(261_915, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 200).saturating_mul(r.into())) @@ -3534,10 +3540,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `776 + r * (3 ±0)` // Estimated: `24004 + r * (18 ±0)` - // Minimum execution time: 282_601_000 picoseconds. - Weight::from_parts(289_374_203, 24004) - // Standard Error: 452 - .saturating_add(Weight::from_parts(142_661, 0).saturating_mul(r.into())) + // Minimum execution time: 233_153_000 picoseconds. + Weight::from_parts(238_999_965, 24004) + // Standard Error: 291 + .saturating_add(Weight::from_parts(143_971, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 18).saturating_mul(r.into())) @@ -3547,507 +3553,509 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_692_000 picoseconds. - Weight::from_parts(2_069_482, 0) - // Standard Error: 40 - .saturating_add(Weight::from_parts(2_922, 0).saturating_mul(r.into())) + // Minimum execution time: 1_706_000 picoseconds. + Weight::from_parts(1_962_558, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(3_000, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64load(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_690_000 picoseconds. - Weight::from_parts(2_303_602, 0) + // Minimum execution time: 1_870_000 picoseconds. + Weight::from_parts(2_481_243, 0) // Standard Error: 4 - .saturating_add(Weight::from_parts(6_433, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(6_346, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64store(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_701_000 picoseconds. - Weight::from_parts(2_321_142, 0) + // Minimum execution time: 1_830_000 picoseconds. + Weight::from_parts(2_389_658, 0) // Standard Error: 4 - .saturating_add(Weight::from_parts(6_025, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_997, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_select(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_656_000 picoseconds. - Weight::from_parts(2_090_881, 0) - // Standard Error: 5 - .saturating_add(Weight::from_parts(7_941, 0).saturating_mul(r.into())) + // Minimum execution time: 1_734_000 picoseconds. + Weight::from_parts(2_170_618, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(7_919, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_if(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_659_000 picoseconds. - Weight::from_parts(1_816_547, 0) - // Standard Error: 5 - .saturating_add(Weight::from_parts(10_578, 0).saturating_mul(r.into())) + // Minimum execution time: 1_661_000 picoseconds. + Weight::from_parts(1_945_771, 0) + // Standard Error: 11 + .saturating_add(Weight::from_parts(10_840, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_br(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_683_000 picoseconds. - Weight::from_parts(1_970_907, 0) - // Standard Error: 12 - .saturating_add(Weight::from_parts(4_636, 0).saturating_mul(r.into())) + // Minimum execution time: 1_682_000 picoseconds. + Weight::from_parts(1_970_774, 0) + // Standard Error: 11 + .saturating_add(Weight::from_parts(4_569, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_br_if(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_651_000 picoseconds. - Weight::from_parts(2_263_817, 0) - // Standard Error: 68 - .saturating_add(Weight::from_parts(7_529, 0).saturating_mul(r.into())) + // Minimum execution time: 1_668_000 picoseconds. + Weight::from_parts(1_227_080, 0) + // Standard Error: 76 + .saturating_add(Weight::from_parts(8_066, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_br_table(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_687_000 picoseconds. - Weight::from_parts(1_349_186, 0) - // Standard Error: 31 - .saturating_add(Weight::from_parts(9_732, 0).saturating_mul(r.into())) + // Minimum execution time: 1_653_000 picoseconds. + Weight::from_parts(1_394_759, 0) + // Standard Error: 39 + .saturating_add(Weight::from_parts(9_566, 0).saturating_mul(r.into())) } /// The range of component `e` is `[1, 256]`. - fn instr_br_table_per_entry(_e: u32, ) -> Weight { + fn instr_br_table_per_entry(e: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_777_000 picoseconds. - Weight::from_parts(2_036_446, 0) + // Minimum execution time: 1_771_000 picoseconds. + Weight::from_parts(1_905_594, 0) + // Standard Error: 147 + .saturating_add(Weight::from_parts(925, 0).saturating_mul(e.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_call(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_686_000 picoseconds. - Weight::from_parts(464_449, 0) - // Standard Error: 383 - .saturating_add(Weight::from_parts(19_121, 0).saturating_mul(r.into())) + // Minimum execution time: 1_863_000 picoseconds. + Weight::from_parts(2_472_635, 0) + // Standard Error: 13 + .saturating_add(Weight::from_parts(17_892, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_call_indirect(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_855_000 picoseconds. - Weight::from_parts(3_381_585, 0) + // Minimum execution time: 2_013_000 picoseconds. + Weight::from_parts(3_077_100, 0) // Standard Error: 18 - .saturating_add(Weight::from_parts(24_245, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(24_287, 0).saturating_mul(r.into())) } /// The range of component `l` is `[0, 1024]`. fn instr_call_per_local(l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_792_000 picoseconds. - Weight::from_parts(2_006_024, 0) - // Standard Error: 16 - .saturating_add(Weight::from_parts(2_181, 0).saturating_mul(l.into())) + // Minimum execution time: 1_818_000 picoseconds. + Weight::from_parts(2_109_143, 0) + // Standard Error: 34 + .saturating_add(Weight::from_parts(1_249, 0).saturating_mul(l.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_local_get(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_918_000 picoseconds. - Weight::from_parts(4_618_761, 0) - // Standard Error: 49 - .saturating_add(Weight::from_parts(2_312, 0).saturating_mul(r.into())) + // Minimum execution time: 3_083_000 picoseconds. + Weight::from_parts(3_291_328, 0) + // Standard Error: 1 + .saturating_add(Weight::from_parts(2_505, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_local_set(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_889_000 picoseconds. - Weight::from_parts(4_151_280, 0) + // Minimum execution time: 2_987_000 picoseconds. + Weight::from_parts(3_276_863, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_623, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(3_617, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_local_tee(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_880_000 picoseconds. - Weight::from_parts(4_225_780, 0) + // Minimum execution time: 2_942_000 picoseconds. + Weight::from_parts(3_350_581, 0) // Standard Error: 3 - .saturating_add(Weight::from_parts(3_847, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(3_976, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_global_get(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_765_000 picoseconds. - Weight::from_parts(2_216_674, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(8_393, 0).saturating_mul(r.into())) + // Minimum execution time: 1_867_000 picoseconds. + Weight::from_parts(2_920_748, 0) + // Standard Error: 44 + .saturating_add(Weight::from_parts(8_229, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_global_set(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_764_000 picoseconds. - Weight::from_parts(2_246_735, 0) - // Standard Error: 5 - .saturating_add(Weight::from_parts(8_877, 0).saturating_mul(r.into())) + // Minimum execution time: 1_757_000 picoseconds. + Weight::from_parts(2_235_198, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(8_815, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_memory_current(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_758_000 picoseconds. - Weight::from_parts(1_922_386, 0) - // Standard Error: 94 - .saturating_add(Weight::from_parts(3_868, 0).saturating_mul(r.into())) + // Minimum execution time: 1_824_000 picoseconds. + Weight::from_parts(1_941_816, 0) + // Standard Error: 86 + .saturating_add(Weight::from_parts(4_043, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 16]`. fn instr_memory_grow(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_635_000 picoseconds. - Weight::from_parts(1_118_785, 0) - // Standard Error: 134_978 - .saturating_add(Weight::from_parts(16_343_664, 0).saturating_mul(r.into())) + // Minimum execution time: 1_793_000 picoseconds. + Weight::from_parts(1_104_829, 0) + // Standard Error: 137_800 + .saturating_add(Weight::from_parts(13_336_784, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64clz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_648_000 picoseconds. - Weight::from_parts(2_012_545, 0) + // Minimum execution time: 1_693_000 picoseconds. + Weight::from_parts(2_037_305, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_824, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(4_044, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64ctz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_688_000 picoseconds. - Weight::from_parts(1_995_956, 0) + // Minimum execution time: 1_751_000 picoseconds. + Weight::from_parts(2_082_016, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_757, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(3_767, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64popcnt(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_631_000 picoseconds. - Weight::from_parts(2_011_493, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(3_755, 0).saturating_mul(r.into())) + // Minimum execution time: 1_751_000 picoseconds. + Weight::from_parts(2_110_625, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(3_754, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64eqz(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_667_000 picoseconds. - Weight::from_parts(1_958_798, 0) + // Minimum execution time: 1_756_000 picoseconds. + Weight::from_parts(2_100_327, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_677, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(3_664, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64extendsi32(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_674_000 picoseconds. - Weight::from_parts(2_009_555, 0) - // Standard Error: 7 - .saturating_add(Weight::from_parts(3_863, 0).saturating_mul(r.into())) + // Minimum execution time: 1_643_000 picoseconds. + Weight::from_parts(2_169_153, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(3_961, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64extendui32(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_659_000 picoseconds. - Weight::from_parts(2_014_985, 0) + // Minimum execution time: 1_704_000 picoseconds. + Weight::from_parts(2_049_172, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_821, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(3_833, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i32wrapi64(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_640_000 picoseconds. - Weight::from_parts(2_013_939, 0) + // Minimum execution time: 1_726_000 picoseconds. + Weight::from_parts(2_064_387, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(3_708, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(3_745, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64eq(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_631_000 picoseconds. - Weight::from_parts(2_002_814, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(6_008, 0).saturating_mul(r.into())) + // Minimum execution time: 1_696_000 picoseconds. + Weight::from_parts(2_426_905, 0) + // Standard Error: 56 + .saturating_add(Weight::from_parts(5_915, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64ne(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_647_000 picoseconds. - Weight::from_parts(2_032_158, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(5_944, 0).saturating_mul(r.into())) + // Minimum execution time: 1_617_000 picoseconds. + Weight::from_parts(2_035_161, 0) + // Standard Error: 94 + .saturating_add(Weight::from_parts(6_073, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64lts(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_669_000 picoseconds. - Weight::from_parts(2_040_386, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(6_009, 0).saturating_mul(r.into())) + // Minimum execution time: 1_756_000 picoseconds. + Weight::from_parts(2_098_926, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(6_002, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64ltu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_637_000 picoseconds. - Weight::from_parts(1_983_695, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(6_027, 0).saturating_mul(r.into())) + // Minimum execution time: 1_706_000 picoseconds. + Weight::from_parts(2_257_972, 0) + // Standard Error: 23 + .saturating_add(Weight::from_parts(5_982, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64gts(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_701_000 picoseconds. - Weight::from_parts(2_054_295, 0) + // Minimum execution time: 1_761_000 picoseconds. + Weight::from_parts(2_114_141, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(5_799, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_815, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64gtu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_653_000 picoseconds. - Weight::from_parts(2_749_807, 0) - // Standard Error: 90 - .saturating_add(Weight::from_parts(5_945, 0).saturating_mul(r.into())) + // Minimum execution time: 1_700_000 picoseconds. + Weight::from_parts(2_053_201, 0) + // Standard Error: 2 + .saturating_add(Weight::from_parts(6_137, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64les(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_651_000 picoseconds. - Weight::from_parts(1_979_111, 0) + // Minimum execution time: 1_705_000 picoseconds. + Weight::from_parts(2_101_782, 0) // Standard Error: 3 - .saturating_add(Weight::from_parts(6_011, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(6_014, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64leu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_743_000 picoseconds. - Weight::from_parts(2_058_081, 0) + // Minimum execution time: 1_856_000 picoseconds. + Weight::from_parts(2_149_707, 0) // Standard Error: 3 - .saturating_add(Weight::from_parts(6_085, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(6_086, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64ges(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_638_000 picoseconds. - Weight::from_parts(2_038_929, 0) + // Minimum execution time: 1_739_000 picoseconds. + Weight::from_parts(2_143_216, 0) // Standard Error: 3 - .saturating_add(Weight::from_parts(5_941, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_934, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64geu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_641_000 picoseconds. - Weight::from_parts(2_036_587, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(6_008, 0).saturating_mul(r.into())) + // Minimum execution time: 1_716_000 picoseconds. + Weight::from_parts(2_065_762, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(6_009, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64add(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_624_000 picoseconds. - Weight::from_parts(2_080_562, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(5_826, 0).saturating_mul(r.into())) + // Minimum execution time: 1_664_000 picoseconds. + Weight::from_parts(3_062_283, 0) + // Standard Error: 94 + .saturating_add(Weight::from_parts(5_645, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64sub(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_652_000 picoseconds. - Weight::from_parts(2_039_535, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(6_137, 0).saturating_mul(r.into())) + // Minimum execution time: 1_671_000 picoseconds. + Weight::from_parts(2_011_145, 0) + // Standard Error: 44 + .saturating_add(Weight::from_parts(6_220, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64mul(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_666_000 picoseconds. - Weight::from_parts(2_056_354, 0) - // Standard Error: 6 - .saturating_add(Weight::from_parts(5_780, 0).saturating_mul(r.into())) + // Minimum execution time: 1_759_000 picoseconds. + Weight::from_parts(2_095_420, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(5_723, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64divs(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_648_000 picoseconds. - Weight::from_parts(2_077_695, 0) - // Standard Error: 4 - .saturating_add(Weight::from_parts(11_775, 0).saturating_mul(r.into())) + // Minimum execution time: 1_672_000 picoseconds. + Weight::from_parts(2_184_044, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(11_782, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64divu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_797_000 picoseconds. - Weight::from_parts(2_772_388, 0) - // Standard Error: 33 - .saturating_add(Weight::from_parts(10_333, 0).saturating_mul(r.into())) + // Minimum execution time: 1_752_000 picoseconds. + Weight::from_parts(2_276_209, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(10_513, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64rems(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_699_000 picoseconds. - Weight::from_parts(2_174_288, 0) - // Standard Error: 6 - .saturating_add(Weight::from_parts(11_778, 0).saturating_mul(r.into())) + // Minimum execution time: 1_711_000 picoseconds. + Weight::from_parts(2_720_989, 0) + // Standard Error: 24 + .saturating_add(Weight::from_parts(11_884, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64remu(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_685_000 picoseconds. - Weight::from_parts(2_091_037, 0) + // Minimum execution time: 1_713_000 picoseconds. + Weight::from_parts(2_091_403, 0) // Standard Error: 3 - .saturating_add(Weight::from_parts(10_694, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(10_628, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64and(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_636_000 picoseconds. - Weight::from_parts(1_975_521, 0) + // Minimum execution time: 1_704_000 picoseconds. + Weight::from_parts(2_054_652, 0) // Standard Error: 2 - .saturating_add(Weight::from_parts(5_695, 0).saturating_mul(r.into())) + .saturating_add(Weight::from_parts(5_672, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64or(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_619_000 picoseconds. - Weight::from_parts(2_045_492, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(5_770, 0).saturating_mul(r.into())) + // Minimum execution time: 1_743_000 picoseconds. + Weight::from_parts(2_032_806, 0) + // Standard Error: 19 + .saturating_add(Weight::from_parts(5_795, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64xor(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_668_000 picoseconds. - Weight::from_parts(2_055_460, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(5_851, 0).saturating_mul(r.into())) + // Minimum execution time: 1_667_000 picoseconds. + Weight::from_parts(2_031_702, 0) + // Standard Error: 5 + .saturating_add(Weight::from_parts(5_923, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64shl(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_681_000 picoseconds. - Weight::from_parts(2_023_370, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(5_853, 0).saturating_mul(r.into())) + // Minimum execution time: 1_735_000 picoseconds. + Weight::from_parts(2_946_634, 0) + // Standard Error: 54 + .saturating_add(Weight::from_parts(5_685, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64shrs(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_714_000 picoseconds. - Weight::from_parts(2_067_584, 0) - // Standard Error: 3 - .saturating_add(Weight::from_parts(6_133, 0).saturating_mul(r.into())) + // Minimum execution time: 1_652_000 picoseconds. + Weight::from_parts(2_023_049, 0) + // Standard Error: 4 + .saturating_add(Weight::from_parts(6_146, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64shru(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_602_000 picoseconds. - Weight::from_parts(2_055_530, 0) - // Standard Error: 138 - .saturating_add(Weight::from_parts(6_014, 0).saturating_mul(r.into())) + // Minimum execution time: 1_654_000 picoseconds. + Weight::from_parts(2_148_951, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(5_869, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64rotl(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_709_000 picoseconds. - Weight::from_parts(2_016_365, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(5_985, 0).saturating_mul(r.into())) + // Minimum execution time: 1_730_000 picoseconds. + Weight::from_parts(2_130_543, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(5_999, 0).saturating_mul(r.into())) } /// The range of component `r` is `[0, 5000]`. fn instr_i64rotr(r: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_661_000 picoseconds. - Weight::from_parts(2_003_063, 0) - // Standard Error: 2 - .saturating_add(Weight::from_parts(5_863, 0).saturating_mul(r.into())) + // Minimum execution time: 1_728_000 picoseconds. + Weight::from_parts(2_172_886, 0) + // Standard Error: 3 + .saturating_add(Weight::from_parts(5_843, 0).saturating_mul(r.into())) } } From 1880b62ccbc3705f309519739a5f13eb322ed6ce Mon Sep 17 00:00:00 2001 From: pgherveou Date: Wed, 29 Mar 2023 10:07:01 +0200 Subject: [PATCH 24/43] PR comments update print_schedule --- frame/contracts/src/benchmarking/mod.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 607d12b39831b..1b6971fbfbd3f 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -3010,14 +3010,11 @@ benchmarks! { #[cfg(feature = "std")] { let max_weight = ::BlockWeights::get().max_block; - let empty_queue_throughput = ContractInfo::::deletion_budget(max_weight); - let full_queue_throughput = ContractInfo::::deletion_budget(max_weight); + let (weight_per_key, key_budget) = ContractInfo::::deletion_budget(max_weight); println!("{:#?}", Schedule::::default()); println!("###############################################"); - println!("Lazy deletion weight per key: {}", empty_queue_throughput.0); - println!("Lazy deletion throughput per block (empty queue, full queue): {}, {}", - empty_queue_throughput.1, full_queue_throughput.1, - ); + println!("Lazy deletion weight per key: {weight_per_key}"); + println!("Lazy deletion throughput per block: {key_budget}"); } #[cfg(not(feature = "std"))] Err("Run this bench with a native runtime in order to see the schedule.")?; From 9fc9db6927ac9f7fb5177c149b3ef669d19508fc Mon Sep 17 00:00:00 2001 From: PG Herveou Date: Wed, 29 Mar 2023 10:15:18 +0200 Subject: [PATCH 25/43] Update frame/contracts/src/benchmarking/mod.rs --- frame/contracts/src/benchmarking/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 1b6971fbfbd3f..1bb6f3395fcef 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -227,7 +227,6 @@ benchmarks! { let c in 0 .. Perbill::from_percent(49).mul_ceil(T::MaxCodeLen::get()); let WasmModule { code, hash, .. } = WasmModule::::sized(c, Location::Call); Contracts::::store_code_raw(code, whitelisted_caller())?; - let schedule = T::Schedule::get(); let mut gas_meter = GasMeter::new(Weight::MAX); let mut module = PrefabWasmModule::from_storage(hash, &schedule, &mut gas_meter)?; From c0a7523282549e099185e7f6f6db8e755a7b4742 Mon Sep 17 00:00:00 2001 From: PG Herveou Date: Wed, 29 Mar 2023 10:17:14 +0200 Subject: [PATCH 26/43] Update frame/contracts/src/storage.rs --- frame/contracts/src/storage.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index f33a8b9a0f3b8..f7096dc7d61a7 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -225,7 +225,7 @@ impl ContractInfo { (weight_per_key, key_budget) } - /// Delete as many items from the deletion queue possible within the supplied weight limit.j + /// Delete as many items from the deletion queue possible within the supplied weight limit. /// /// It returns the amount of weight used for that task. pub fn process_deletion_queue_batch(weight_limit: Weight) -> Weight { From efafd7dfdfdd4748989fd676947fd874453f1e72 Mon Sep 17 00:00:00 2001 From: PG Herveou Date: Wed, 29 Mar 2023 10:19:57 +0200 Subject: [PATCH 27/43] Update frame/contracts/src/storage.rs --- frame/contracts/src/storage.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index f7096dc7d61a7..bc3c05a3599e6 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -371,7 +371,7 @@ impl DeletionQueue { >::get() } - /// The number of contracts marked for deletion. + /// Returns `true` if the queue contains no elements. fn is_empty(&self) -> bool { self.insert_nonce.wrapping_sub(self.delete_nonce) == 0 } From 717151e35ed2277e8cd22166b4542f5082eba236 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Wed, 29 Mar 2023 10:23:35 +0200 Subject: [PATCH 28/43] rm temporary fixes --- frame/contracts/src/storage.rs | 4 +--- frame/contracts/src/tests.rs | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index bc3c05a3599e6..10a9d6a293321 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -390,9 +390,7 @@ impl DeletionQueue { } let entry = >::get(self.delete_nonce); - let entry = entry.map(|trie_id| DeletionQueueEntry { trie_id, queue: self }); - - entry + entry.map(|trie_id| DeletionQueueEntry { trie_id, queue: self }); } } diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 8ac10383c2ffd..e2d762aceab79 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -452,7 +452,7 @@ impl ExtBuilder { /// with it's hash. /// /// The fixture files are located under the `fixtures/` directory. -pub fn compile_module(fixture_name: &str) -> wat::Result<(Vec, ::Output)> +fn compile_module(fixture_name: &str) -> wat::Result<(Vec, ::Output)> where T: frame_system::Config, { From 2da3648dd8f33b899815b016d2a26e26dc07fe4c Mon Sep 17 00:00:00 2001 From: pgherveou Date: Wed, 29 Mar 2023 10:29:28 +0200 Subject: [PATCH 29/43] fix extra ; --- frame/contracts/src/storage.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index 10a9d6a293321..531e5d408eaa6 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -390,7 +390,7 @@ impl DeletionQueue { } let entry = >::get(self.delete_nonce); - entry.map(|trie_id| DeletionQueueEntry { trie_id, queue: self }); + entry.map(|trie_id| DeletionQueueEntry { trie_id, queue: self }) } } From 5751764d3d656b1f8254babff21ea9752ae2e90a Mon Sep 17 00:00:00 2001 From: PG Herveou Date: Thu, 30 Mar 2023 12:18:29 +0200 Subject: [PATCH 30/43] Update frame/contracts/src/storage.rs Co-authored-by: juangirini --- frame/contracts/src/storage.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index 531e5d408eaa6..3669f9cf5fb2c 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -337,7 +337,7 @@ impl Deref for DepositAccount { #[derive(Encode, Decode, TypeInfo, MaxEncodedLen, DefaultNoBound, Clone)] #[scale_info(skip_type_params(T))] pub struct DeletionQueue { - /// Monotonic counter used as a key for inserting new deleted contract in the DeletionQueueMap. + /// Monotonic counter used as a key for inserting a new deleted contract in the DeletionQueueMap. /// The nonce is incremented after each insertion. insert_nonce: u32, /// The index used to read the next element to be deleted in the DeletionQueueMap. From b31603e208bef061e8c0f9443c4c519c55d94c40 Mon Sep 17 00:00:00 2001 From: PG Herveou Date: Thu, 30 Mar 2023 12:31:28 +0200 Subject: [PATCH 31/43] Update frame/contracts/src/storage.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander Theißen --- frame/contracts/src/storage.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index 3669f9cf5fb2c..805154f830d8b 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -338,11 +338,11 @@ impl Deref for DepositAccount { #[scale_info(skip_type_params(T))] pub struct DeletionQueue { /// Monotonic counter used as a key for inserting a new deleted contract in the DeletionQueueMap. - /// The nonce is incremented after each insertion. - insert_nonce: u32, + /// The counter is incremented after each insertion. + insert_counter: u32, /// The index used to read the next element to be deleted in the DeletionQueueMap. - /// The nonce is incremented after each deletion. - delete_nonce: u32, + /// The counter is incremented after each deletion. + delete_counter: u32, _phantom: PhantomData, } From e269ad43d129c628a1b9ee38fa3e76e79fa90097 Mon Sep 17 00:00:00 2001 From: PG Herveou Date: Thu, 30 Mar 2023 12:31:56 +0200 Subject: [PATCH 32/43] Update frame/contracts/src/lib.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander Theißen --- frame/contracts/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index db774e4c7ab17..d1cddda44547a 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -908,7 +908,7 @@ pub mod pallet { /// don't pay the cost of an extra call to `sp_io::storage::next_key` to lookup the next entry /// in the map #[pallet::storage] - pub(crate) type DeletionQueueNonces = StorageValue<_, DeletionQueue, ValueQuery>; + pub(crate) type DeletionQueueCounter = StorageValue<_, DeletionQueue, ValueQuery>; } /// Context of a contract invocation. From 2f1d4fa15a764ce2bfed2488b1d36754857cce08 Mon Sep 17 00:00:00 2001 From: PG Herveou Date: Thu, 30 Mar 2023 12:32:22 +0200 Subject: [PATCH 33/43] Update frame/contracts/src/lib.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander Theißen --- frame/contracts/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index d1cddda44547a..f3502dee62b42 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -899,7 +899,7 @@ pub mod pallet { /// Child trie deletion is a heavy operation depending on the amount of storage items /// stored in said trie. Therefore this operation is performed lazily in `on_idle`. #[pallet::storage] - pub(crate) type DeletionQueueMap = StorageMap<_, Twox64Concat, u32, TrieId>; + pub(crate) type DeletionQueue = StorageMap<_, Twox64Concat, u32, TrieId>; /// A pair of monotonic counters used to track the latest contract marked for deletion /// and the latest deleted contract in DeletionQueueMap. From 0b985aa5ad114a42003519b712d25a6acc40b0ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 29 Mar 2023 09:17:50 +0200 Subject: [PATCH 34/43] Support stable rust for compiling the runtime (#13580) * Support stable rust for compiling the runtime This pull request brings support for compiling the runtime with stable Rust. This requires at least rust 1.68.0 to work on stable. The code is written in a way that it is backwards compatible and should automatically work when someone compiles with 1.68.0+ stable. * We always support nightlies! * :facepalm: * Sort by version * Review feedback * Review feedback * Fix version parsing * Apply suggestions from code review Co-authored-by: Koute --------- Co-authored-by: Koute --- Cargo.lock | 1 + primitives/io/Cargo.toml | 4 + primitives/io/build.rs | 27 ++++ primitives/io/src/lib.rs | 4 +- utils/wasm-builder/README.md | 11 +- utils/wasm-builder/src/lib.rs | 124 ++++++++++----- utils/wasm-builder/src/prerequisites.rs | 9 +- utils/wasm-builder/src/version.rs | 198 ++++++++++++++++++++++++ 8 files changed, 327 insertions(+), 51 deletions(-) create mode 100644 primitives/io/build.rs create mode 100644 utils/wasm-builder/src/version.rs diff --git a/Cargo.lock b/Cargo.lock index 33bca4005483c..cf30a6a94ae8f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10474,6 +10474,7 @@ dependencies = [ "libsecp256k1", "log", "parity-scale-codec", + "rustversion", "secp256k1", "sp-core", "sp-externalities", diff --git a/primitives/io/Cargo.toml b/primitives/io/Cargo.toml index e56bfcf56041a..c6e716396aea4 100644 --- a/primitives/io/Cargo.toml +++ b/primitives/io/Cargo.toml @@ -9,6 +9,7 @@ repository = "https://github.com/paritytech/substrate/" description = "I/O for Substrate runtimes" documentation = "https://docs.rs/sp-io" readme = "README.md" +build = "build.rs" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] @@ -37,6 +38,9 @@ ed25519-dalek = { version = "1.0.1", default-features = false, optional = true } # Force the usage of ed25519, this is being used in `ed25519-dalek`. ed25519 = { version = "1.5.2", optional = true } +[build-dependencies] +rustversion = "1.0.6" + [features] default = ["std"] std = [ diff --git a/primitives/io/build.rs b/primitives/io/build.rs new file mode 100644 index 0000000000000..8a9c0b6420b29 --- /dev/null +++ b/primitives/io/build.rs @@ -0,0 +1,27 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#[rustversion::before(1.68)] +fn main() { + if !cfg!(feature = "std") { + println!("cargo:rustc-cfg=enable_alloc_error_handler"); + } +} + +#[rustversion::since(1.68)] +fn main() {} diff --git a/primitives/io/src/lib.rs b/primitives/io/src/lib.rs index 306ac8e60c529..72300eb102177 100644 --- a/primitives/io/src/lib.rs +++ b/primitives/io/src/lib.rs @@ -19,7 +19,7 @@ #![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] -#![cfg_attr(not(feature = "std"), feature(alloc_error_handler))] +#![cfg_attr(enable_alloc_error_handler, feature(alloc_error_handler))] #![cfg_attr( feature = "std", doc = "Substrate runtime standard library as compiled when linked with Rust's standard library." @@ -1643,7 +1643,7 @@ pub fn panic(info: &core::panic::PanicInfo) -> ! { } /// A default OOM handler for WASM environment. -#[cfg(all(not(feature = "disable_oom"), not(feature = "std")))] +#[cfg(all(not(feature = "disable_oom"), enable_alloc_error_handler))] #[alloc_error_handler] pub fn oom(_: core::alloc::Layout) -> ! { #[cfg(feature = "improved_panic_error_reporting")] diff --git a/utils/wasm-builder/README.md b/utils/wasm-builder/README.md index a10611cc26a00..b1ccb1b35b10e 100644 --- a/utils/wasm-builder/README.md +++ b/utils/wasm-builder/README.md @@ -77,8 +77,13 @@ Wasm builder requires the following prerequisites for building the Wasm binary: - rust nightly + `wasm32-unknown-unknown` toolchain -If a specific rust nightly is installed with `rustup`, it is important that the wasm target is installed -as well. For example if installing the rust nightly from 20.02.2020 using `rustup install nightly-2020-02-20`, -the wasm target needs to be installed as well `rustup target add wasm32-unknown-unknown --toolchain nightly-2020-02-20`. +or + +- rust stable and version at least 1.68.0 + `wasm32-unknown-unknown` toolchain + +If a specific rust is installed with `rustup`, it is important that the wasm target is +installed as well. For example if installing the rust from 20.02.2020 using `rustup +install nightly-2020-02-20`, the wasm target needs to be installed as well `rustup target add +wasm32-unknown-unknown --toolchain nightly-2020-02-20`. License: Apache-2.0 diff --git a/utils/wasm-builder/src/lib.rs b/utils/wasm-builder/src/lib.rs index 659b955256af7..8405b5a0bda9e 100644 --- a/utils/wasm-builder/src/lib.rs +++ b/utils/wasm-builder/src/lib.rs @@ -100,8 +100,12 @@ //! //! - rust nightly + `wasm32-unknown-unknown` toolchain //! -//! If a specific rust nightly is installed with `rustup`, it is important that the wasm target is -//! installed as well. For example if installing the rust nightly from 20.02.2020 using `rustup +//! or +//! +//! - rust stable and version at least 1.68.0 + `wasm32-unknown-unknown` toolchain +//! +//! If a specific rust is installed with `rustup`, it is important that the wasm target is +//! installed as well. For example if installing the rust from 20.02.2020 using `rustup //! install nightly-2020-02-20`, the wasm target needs to be installed as well `rustup target add //! wasm32-unknown-unknown --toolchain nightly-2020-02-20`. @@ -111,9 +115,11 @@ use std::{ path::{Path, PathBuf}, process::Command, }; +use version::Version; mod builder; mod prerequisites; +mod version; mod wasm_project; pub use builder::{WasmBuilder, WasmBuilderSelectProject}; @@ -172,53 +178,59 @@ fn copy_file_if_changed(src: PathBuf, dst: PathBuf) { } } -/// Get a cargo command that compiles with nightly -fn get_nightly_cargo() -> CargoCommand { +/// Get a cargo command that should be used to invoke the compilation. +fn get_cargo_command() -> CargoCommand { let env_cargo = CargoCommand::new(&env::var("CARGO").expect("`CARGO` env variable is always set by cargo")); let default_cargo = CargoCommand::new("cargo"); - let rustup_run_nightly = CargoCommand::new_with_args("rustup", &["run", "nightly", "cargo"]); let wasm_toolchain = env::var(WASM_BUILD_TOOLCHAIN).ok(); // First check if the user requested a specific toolchain - if let Some(cmd) = wasm_toolchain.and_then(|t| get_rustup_nightly(Some(t))) { + if let Some(cmd) = + wasm_toolchain.map(|t| CargoCommand::new_with_args("rustup", &["run", &t, "cargo"])) + { cmd - } else if env_cargo.is_nightly() { + } else if env_cargo.supports_substrate_wasm_env() { env_cargo - } else if default_cargo.is_nightly() { + } else if default_cargo.supports_substrate_wasm_env() { default_cargo - } else if rustup_run_nightly.is_nightly() { - rustup_run_nightly } else { - // If no command before provided us with a nightly compiler, we try to search one - // with rustup. If that fails as well, we return the default cargo and let the prequisities - // check fail. - get_rustup_nightly(None).unwrap_or(default_cargo) + // If no command before provided us with a cargo that supports our Substrate wasm env, we + // try to search one with rustup. If that fails as well, we return the default cargo and let + // the prequisities check fail. + get_rustup_command().unwrap_or(default_cargo) } } -/// Get a nightly from rustup. If `selected` is `Some(_)`, a `CargoCommand` using the given -/// nightly is returned. -fn get_rustup_nightly(selected: Option) -> Option { +/// Get the newest rustup command that supports our Substrate wasm env. +/// +/// Stable versions are always favored over nightly versions even if the nightly versions are +/// newer. +fn get_rustup_command() -> Option { let host = format!("-{}", env::var("HOST").expect("`HOST` is always set by cargo")); - let version = match selected { - Some(selected) => selected, - None => { - let output = Command::new("rustup").args(&["toolchain", "list"]).output().ok()?.stdout; - let lines = output.as_slice().lines(); + let output = Command::new("rustup").args(&["toolchain", "list"]).output().ok()?.stdout; + let lines = output.as_slice().lines(); + + let mut versions = Vec::new(); + for line in lines.filter_map(|l| l.ok()) { + let rustup_version = line.trim_end_matches(&host); + + let cmd = CargoCommand::new_with_args("rustup", &["run", &rustup_version, "cargo"]); - let mut latest_nightly = None; - for line in lines.filter_map(|l| l.ok()) { - if line.starts_with("nightly-") && line.ends_with(&host) { - // Rustup prints them sorted - latest_nightly = Some(line.clone()); - } - } + if !cmd.supports_substrate_wasm_env() { + continue + } + + let Some(cargo_version) = cmd.version() else { continue; }; - latest_nightly?.trim_end_matches(&host).into() - }, - }; + versions.push((cargo_version, rustup_version.to_string())); + } + + // Sort by the parsed version to get the latest version (greatest version) at the end of the + // vec. + versions.sort_by_key(|v| v.0); + let version = &versions.last()?.1; Some(CargoCommand::new_with_args("rustup", &["run", &version, "cargo"])) } @@ -228,17 +240,23 @@ fn get_rustup_nightly(selected: Option) -> Option { struct CargoCommand { program: String, args: Vec, + version: Option, } impl CargoCommand { fn new(program: &str) -> Self { - CargoCommand { program: program.into(), args: Vec::new() } + let version = Self::extract_version(program, &[]); + + CargoCommand { program: program.into(), args: Vec::new(), version } } fn new_with_args(program: &str, args: &[&str]) -> Self { + let version = Self::extract_version(program, args); + CargoCommand { program: program.into(), args: args.iter().map(ToString::to_string).collect(), + version, } } @@ -248,20 +266,40 @@ impl CargoCommand { cmd } - /// Check if the supplied cargo command is a nightly version - fn is_nightly(&self) -> bool { + fn extract_version(program: &str, args: &[&str]) -> Option { + let version = Command::new(program) + .args(args) + .arg("--version") + .output() + .ok() + .and_then(|o| String::from_utf8(o.stdout).ok())?; + + Version::extract(&version) + } + + /// Returns the version of this cargo command or `None` if it failed to extract the version. + fn version(&self) -> Option { + self.version + } + + /// Check if the supplied cargo command supports our Substrate wasm environment. + /// + /// This means that either the cargo version is at minimum 1.68.0 or this is a nightly cargo. + /// + /// Assumes that cargo version matches the rustc version. + fn supports_substrate_wasm_env(&self) -> bool { // `RUSTC_BOOTSTRAP` tells a stable compiler to behave like a nightly. So, when this env // variable is set, we can assume that whatever rust compiler we have, it is a nightly // compiler. For "more" information, see: // https://github.com/rust-lang/rust/blob/fa0f7d0080d8e7e9eb20aa9cbf8013f96c81287f/src/libsyntax/feature_gate/check.rs#L891 - env::var("RUSTC_BOOTSTRAP").is_ok() || - self.command() - .arg("--version") - .output() - .map_err(|_| ()) - .and_then(|o| String::from_utf8(o.stdout).map_err(|_| ())) - .unwrap_or_default() - .contains("-nightly") + if env::var("RUSTC_BOOTSTRAP").is_ok() { + return true + } + + let Some(version) = self.version() else { return false }; + + // Check if major and minor are greater or equal than 1.68 or this is a nightly. + version.major > 1 || (version.major == 1 && version.minor >= 68) || version.is_nightly } } diff --git a/utils/wasm-builder/src/prerequisites.rs b/utils/wasm-builder/src/prerequisites.rs index ca07a029281a8..f5a985ab92b5d 100644 --- a/utils/wasm-builder/src/prerequisites.rs +++ b/utils/wasm-builder/src/prerequisites.rs @@ -35,10 +35,13 @@ fn print_error_message(message: &str) -> String { /// /// Returns the versioned cargo command on success. pub(crate) fn check() -> Result { - let cargo_command = crate::get_nightly_cargo(); + let cargo_command = crate::get_cargo_command(); - if !cargo_command.is_nightly() { - return Err(print_error_message("Rust nightly not installed, please install it!")) + if !cargo_command.supports_substrate_wasm_env() { + return Err(print_error_message( + "Cannot compile the WASM runtime: no compatible Rust compiler found!\n\ + Install at least Rust 1.68.0 or a recent nightly version.", + )) } check_wasm_toolchain_installed(cargo_command) diff --git a/utils/wasm-builder/src/version.rs b/utils/wasm-builder/src/version.rs new file mode 100644 index 0000000000000..77e62b394bd55 --- /dev/null +++ b/utils/wasm-builder/src/version.rs @@ -0,0 +1,198 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use std::cmp::Ordering; + +/// The version of rustc/cargo. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub struct Version { + pub major: u32, + pub minor: u32, + pub patch: u32, + pub is_nightly: bool, + pub year: u32, + pub month: u32, + pub day: u32, +} + +impl Version { + /// Returns if `self` is a stable version. + pub fn is_stable(&self) -> bool { + !self.is_nightly + } + + /// Return if `self` is a nightly version. + pub fn is_nightly(&self) -> bool { + self.is_nightly + } + + /// Extract from the given `version` string. + pub fn extract(version: &str) -> Option { + let mut is_nightly = false; + let version_parts = version + .trim() + .split(" ") + .nth(1)? + .split(".") + .filter_map(|v| { + if let Some(rest) = v.strip_suffix("-nightly") { + is_nightly = true; + rest.parse().ok() + } else { + v.parse().ok() + } + }) + .collect::>(); + + if version_parts.len() != 3 { + return None + } + + let date = version.split(" ").nth(3)?; + + let date_parts = date + .split("-") + .filter_map(|v| v.trim().strip_suffix(")").unwrap_or(v).parse().ok()) + .collect::>(); + + if date_parts.len() != 3 { + return None + } + + Some(Version { + major: version_parts[0], + minor: version_parts[1], + patch: version_parts[2], + is_nightly, + year: date_parts[0], + month: date_parts[1], + day: date_parts[2], + }) + } +} + +/// Ordering is done in the following way: +/// +/// 1. `stable` > `nightly` +/// 2. Then compare major, minor and patch. +/// 3. Last compare the date. +impl Ord for Version { + fn cmp(&self, other: &Self) -> Ordering { + if self == other { + return Ordering::Equal + } + + // Ensure that `stable > nightly` + if self.is_stable() && other.is_nightly() { + return Ordering::Greater + } else if self.is_nightly() && other.is_stable() { + return Ordering::Less + } + + let to_compare = [ + (self.major, other.major), + (self.minor, other.minor), + (self.patch, other.patch), + (self.year, other.year), + (self.month, other.month), + (self.day, other.day), + ]; + + to_compare + .iter() + .find_map(|(l, r)| if l != r { l.partial_cmp(&r) } else { None }) + // We already checked this right at the beginning, so we should never return here + // `Equal`. + .unwrap_or(Ordering::Equal) + } +} + +impl PartialOrd for Version { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn version_compare_and_extract_works() { + let version_1_66_0 = Version::extract("cargo 1.66.0 (d65d197ad 2022-11-15)").unwrap(); + let version_1_66_1 = Version::extract("cargo 1.66.1 (d65d197ad 2022-11-15)").unwrap(); + let version_1_66_0_nightly = + Version::extract("cargo 1.66.0-nightly (d65d197ad 2022-10-15)").unwrap(); + let version_1_66_0_nightly_older_date = + Version::extract("cargo 1.66.0-nightly (d65d197ad 2022-10-14)").unwrap(); + let version_1_65_0 = Version::extract("cargo 1.65.0 (d65d197ad 2022-10-15)").unwrap(); + let version_1_65_0_older_date = + Version::extract("cargo 1.65.0 (d65d197ad 2022-10-14)").unwrap(); + + assert!(version_1_66_1 > version_1_66_0); + assert!(version_1_66_1 > version_1_65_0); + assert!(version_1_66_1 > version_1_66_0_nightly); + assert!(version_1_66_1 > version_1_66_0_nightly_older_date); + assert!(version_1_66_1 > version_1_65_0_older_date); + + assert!(version_1_66_0 > version_1_65_0); + assert!(version_1_66_0 > version_1_66_0_nightly); + assert!(version_1_66_0 > version_1_66_0_nightly_older_date); + assert!(version_1_66_0 > version_1_65_0_older_date); + + assert!(version_1_65_0 > version_1_66_0_nightly); + assert!(version_1_65_0 > version_1_66_0_nightly_older_date); + assert!(version_1_65_0 > version_1_65_0_older_date); + + let mut versions = vec![ + version_1_66_0, + version_1_66_0_nightly, + version_1_66_0_nightly_older_date, + version_1_65_0_older_date, + version_1_65_0, + version_1_66_1, + ]; + versions.sort_by(|a, b| b.cmp(a)); + + let expected_versions_order = vec![ + version_1_66_1, + version_1_66_0, + version_1_65_0, + version_1_65_0_older_date, + version_1_66_0_nightly, + version_1_66_0_nightly_older_date, + ]; + assert_eq!(expected_versions_order, versions); + } + + #[test] + fn parse_with_newline() { + let version_1_66_0 = Version::extract("cargo 1.66.0 (d65d197ad 2022-11-15)\n").unwrap(); + assert_eq!( + Version { + major: 1, + minor: 66, + patch: 0, + is_nightly: false, + year: 2022, + month: 11, + day: 15 + }, + version_1_66_0 + ); + } +} From dedef6943c278869ffeaba95f9df641692b66485 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Thu, 30 Mar 2023 12:54:19 +0200 Subject: [PATCH 35/43] github PR commit fixes --- frame/contracts/src/lib.rs | 2 +- frame/contracts/src/storage.rs | 32 ++++++++++++++++---------------- frame/contracts/src/tests.rs | 6 +++--- frame/contracts/src/weights.rs | 16 ++++++++-------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index f3502dee62b42..9d35768908f87 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -904,7 +904,7 @@ pub mod pallet { /// A pair of monotonic counters used to track the latest contract marked for deletion /// and the latest deleted contract in DeletionQueueMap. /// - /// When we iterate the map to remove contracts, we simply use the `delete_nonce` counter and + /// When we iterate the map to remove contracts, we simply use the delete counter and /// don't pay the cost of an extra call to `sp_io::storage::next_key` to lookup the next entry /// in the map #[pallet::storage] diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index 805154f830d8b..85b0addc5d32d 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -22,8 +22,8 @@ pub mod meter; use crate::{ exec::{AccountIdOf, Key}, weights::WeightInfo, - AddressGenerator, BalanceOf, CodeHash, Config, ContractInfoOf, DeletionQueueMap, - DeletionQueueNonces, Error, Pallet, TrieId, SENTINEL, + AddressGenerator, BalanceOf, CodeHash, Config, ContractInfoOf, + DeletionQueue as DeletionQueueMap, DeletionQueueCounter, Error, Pallet, TrieId, SENTINEL, }; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ @@ -337,10 +337,10 @@ impl Deref for DepositAccount { #[derive(Encode, Decode, TypeInfo, MaxEncodedLen, DefaultNoBound, Clone)] #[scale_info(skip_type_params(T))] pub struct DeletionQueue { - /// Monotonic counter used as a key for inserting a new deleted contract in the DeletionQueueMap. + /// Monotonic counter used as a key for inserting a new deleted contract in the queue. /// The counter is incremented after each insertion. insert_counter: u32, - /// The index used to read the next element to be deleted in the DeletionQueueMap. + /// The index used to read the next element to be deleted in the queue. /// The counter is incremented after each deletion. delete_counter: u32, @@ -358,9 +358,9 @@ struct DeletionQueueEntry<'a, T: Config> { impl<'a, T: Config> DeletionQueueEntry<'a, T> { /// Remove the contract from the deletion queue. fn remove(self) { - >::remove(self.queue.delete_nonce); - self.queue.delete_nonce = self.queue.delete_nonce.wrapping_add(1); - >::set(self.queue.clone()); + >::remove(self.queue.delete_counter); + self.queue.delete_counter = self.queue.delete_counter.wrapping_add(1); + >::set(self.queue.clone()); } } @@ -368,19 +368,19 @@ impl DeletionQueue { /// Load the Deletion Queue nonces, so we can perform read or write operations on the /// DeletionQueueMap storage. fn load() -> Self { - >::get() + >::get() } /// Returns `true` if the queue contains no elements. fn is_empty(&self) -> bool { - self.insert_nonce.wrapping_sub(self.delete_nonce) == 0 + self.insert_index.wrapping_sub(self.delete_counter) == 0 } /// Insert a contract in the deletion queue. fn insert(&mut self, trie_id: TrieId) { - >::insert(self.insert_nonce, trie_id); - self.insert_nonce = self.insert_nonce.wrapping_add(1); - >::set(self.clone()); + >::insert(self.insert_index, trie_id); + self.insert_index = self.insert_index.wrapping_add(1); + >::set(self.clone()); } /// Fetch the next contract to be deleted. @@ -389,17 +389,17 @@ impl DeletionQueue { return None } - let entry = >::get(self.delete_nonce); + let entry = >::get(self.delete_counter); entry.map(|trie_id| DeletionQueueEntry { trie_id, queue: self }) } } #[cfg(test)] impl DeletionQueue { - pub fn from_test_values(insert_nonce: u32, delete_nonce: u32) -> Self { - DeletionQueue { insert_nonce, delete_nonce, _phantom: Default::default() } + pub fn from_test_values(insert_index: u32, delete_counter: u32) -> Self { + Self { insert_index, delete_counter, _phantom: Default::default() } } pub fn as_test_tuple(&self) -> (u32, u32) { - (self.insert_nonce, self.delete_nonce) + (self.insert_index, self.delete_counter) } } diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index e2d762aceab79..aabfe44775070 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -27,7 +27,7 @@ use crate::{ wasm::{Determinism, PrefabWasmModule, ReturnCode as RuntimeReturnCode}, weights::WeightInfo, BalanceOf, Code, CodeStorage, Config, ContractInfo, ContractInfoOf, DefaultAddressGenerator, - DeletionQueueNonces, Error, Pallet, Schedule, + DeletionQueueCounter, Error, Pallet, Schedule, }; use assert_matches::assert_matches; use codec::Encode; @@ -2274,7 +2274,7 @@ fn deletion_queue_ring_buffer_overflow() { ext.execute_with(|| { // manually se the nonces of the deletion queue let queue = DeletionQueue::from_test_values(u32::MAX - 1, u32::MAX - 1); - >::set(queue); + >::set(queue); }); // commit the changes to the storage @@ -2333,7 +2333,7 @@ fn deletion_queue_ring_buffer_overflow() { } // nonces values should go from u32::MAX - 1 to 1 - assert_eq!(>::get().as_test_tuple(), (1, 1)); + assert_eq!(>::get().as_test_tuple(), (1, 1)); }) } #[test] diff --git a/frame/contracts/src/weights.rs b/frame/contracts/src/weights.rs index d1176a5aa469f..af05f7bf2de3f 100644 --- a/frame/contracts/src/weights.rs +++ b/frame/contracts/src/weights.rs @@ -170,8 +170,8 @@ pub trait WeightInfo { /// Weights for pallet_contracts using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - /// Storage: Contracts DeletionQueueNonces (r:1 w:0) - /// Proof: Contracts DeletionQueueNonces (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) + /// Storage: Contracts DeletionQueueCounter (r:1 w:0) + /// Proof: Contracts DeletionQueueCounter (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) fn on_process_deletion_queue_batch() -> Weight { // Proof Size summary in bytes: // Measured: `109` @@ -795,8 +795,8 @@ impl WeightInfo for SubstrateWeight { /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Measured) /// Storage: Timestamp Now (r:1 w:0) /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: Contracts DeletionQueueNonces (r:1 w:1) - /// Proof: Contracts DeletionQueueNonces (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) + /// Storage: Contracts DeletionQueueCounter (r:1 w:1) + /// Proof: Contracts DeletionQueueCounter (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: Contracts OwnerInfoOf (r:1 w:1) /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Measured) /// Storage: System EventTopics (r:3 w:3) @@ -2116,8 +2116,8 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { - /// Storage: Contracts DeletionQueueNonces (r:1 w:0) - /// Proof: Contracts DeletionQueueNonces (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) + /// Storage: Contracts DeletionQueueCounter (r:1 w:0) + /// Proof: Contracts DeletionQueueCounter (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) fn on_process_deletion_queue_batch() -> Weight { // Proof Size summary in bytes: // Measured: `109` @@ -2741,8 +2741,8 @@ impl WeightInfo for () { /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Measured) /// Storage: Timestamp Now (r:1 w:0) /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: Contracts DeletionQueueNonces (r:1 w:1) - /// Proof: Contracts DeletionQueueNonces (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) + /// Storage: Contracts DeletionQueueCounter (r:1 w:1) + /// Proof: Contracts DeletionQueueCounter (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) /// Storage: Contracts OwnerInfoOf (r:1 w:1) /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Measured) /// Storage: System EventTopics (r:3 w:3) From 6b31f972d52502ffa0f564fe48ddcadc334222f5 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Thu, 30 Mar 2023 12:56:20 +0200 Subject: [PATCH 36/43] Revert "Support stable rust for compiling the runtime (#13580)" This reverts commit 0b985aa5ad114a42003519b712d25a6acc40b0ad. --- Cargo.lock | 1 - primitives/io/Cargo.toml | 4 - primitives/io/build.rs | 27 ---- primitives/io/src/lib.rs | 4 +- utils/wasm-builder/README.md | 11 +- utils/wasm-builder/src/lib.rs | 124 +++++---------- utils/wasm-builder/src/prerequisites.rs | 9 +- utils/wasm-builder/src/version.rs | 198 ------------------------ 8 files changed, 51 insertions(+), 327 deletions(-) delete mode 100644 primitives/io/build.rs delete mode 100644 utils/wasm-builder/src/version.rs diff --git a/Cargo.lock b/Cargo.lock index cf30a6a94ae8f..33bca4005483c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10474,7 +10474,6 @@ dependencies = [ "libsecp256k1", "log", "parity-scale-codec", - "rustversion", "secp256k1", "sp-core", "sp-externalities", diff --git a/primitives/io/Cargo.toml b/primitives/io/Cargo.toml index c6e716396aea4..e56bfcf56041a 100644 --- a/primitives/io/Cargo.toml +++ b/primitives/io/Cargo.toml @@ -9,7 +9,6 @@ repository = "https://github.com/paritytech/substrate/" description = "I/O for Substrate runtimes" documentation = "https://docs.rs/sp-io" readme = "README.md" -build = "build.rs" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] @@ -38,9 +37,6 @@ ed25519-dalek = { version = "1.0.1", default-features = false, optional = true } # Force the usage of ed25519, this is being used in `ed25519-dalek`. ed25519 = { version = "1.5.2", optional = true } -[build-dependencies] -rustversion = "1.0.6" - [features] default = ["std"] std = [ diff --git a/primitives/io/build.rs b/primitives/io/build.rs deleted file mode 100644 index 8a9c0b6420b29..0000000000000 --- a/primitives/io/build.rs +++ /dev/null @@ -1,27 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#[rustversion::before(1.68)] -fn main() { - if !cfg!(feature = "std") { - println!("cargo:rustc-cfg=enable_alloc_error_handler"); - } -} - -#[rustversion::since(1.68)] -fn main() {} diff --git a/primitives/io/src/lib.rs b/primitives/io/src/lib.rs index 72300eb102177..306ac8e60c529 100644 --- a/primitives/io/src/lib.rs +++ b/primitives/io/src/lib.rs @@ -19,7 +19,7 @@ #![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] -#![cfg_attr(enable_alloc_error_handler, feature(alloc_error_handler))] +#![cfg_attr(not(feature = "std"), feature(alloc_error_handler))] #![cfg_attr( feature = "std", doc = "Substrate runtime standard library as compiled when linked with Rust's standard library." @@ -1643,7 +1643,7 @@ pub fn panic(info: &core::panic::PanicInfo) -> ! { } /// A default OOM handler for WASM environment. -#[cfg(all(not(feature = "disable_oom"), enable_alloc_error_handler))] +#[cfg(all(not(feature = "disable_oom"), not(feature = "std")))] #[alloc_error_handler] pub fn oom(_: core::alloc::Layout) -> ! { #[cfg(feature = "improved_panic_error_reporting")] diff --git a/utils/wasm-builder/README.md b/utils/wasm-builder/README.md index b1ccb1b35b10e..a10611cc26a00 100644 --- a/utils/wasm-builder/README.md +++ b/utils/wasm-builder/README.md @@ -77,13 +77,8 @@ Wasm builder requires the following prerequisites for building the Wasm binary: - rust nightly + `wasm32-unknown-unknown` toolchain -or - -- rust stable and version at least 1.68.0 + `wasm32-unknown-unknown` toolchain - -If a specific rust is installed with `rustup`, it is important that the wasm target is -installed as well. For example if installing the rust from 20.02.2020 using `rustup -install nightly-2020-02-20`, the wasm target needs to be installed as well `rustup target add -wasm32-unknown-unknown --toolchain nightly-2020-02-20`. +If a specific rust nightly is installed with `rustup`, it is important that the wasm target is installed +as well. For example if installing the rust nightly from 20.02.2020 using `rustup install nightly-2020-02-20`, +the wasm target needs to be installed as well `rustup target add wasm32-unknown-unknown --toolchain nightly-2020-02-20`. License: Apache-2.0 diff --git a/utils/wasm-builder/src/lib.rs b/utils/wasm-builder/src/lib.rs index 8405b5a0bda9e..659b955256af7 100644 --- a/utils/wasm-builder/src/lib.rs +++ b/utils/wasm-builder/src/lib.rs @@ -100,12 +100,8 @@ //! //! - rust nightly + `wasm32-unknown-unknown` toolchain //! -//! or -//! -//! - rust stable and version at least 1.68.0 + `wasm32-unknown-unknown` toolchain -//! -//! If a specific rust is installed with `rustup`, it is important that the wasm target is -//! installed as well. For example if installing the rust from 20.02.2020 using `rustup +//! If a specific rust nightly is installed with `rustup`, it is important that the wasm target is +//! installed as well. For example if installing the rust nightly from 20.02.2020 using `rustup //! install nightly-2020-02-20`, the wasm target needs to be installed as well `rustup target add //! wasm32-unknown-unknown --toolchain nightly-2020-02-20`. @@ -115,11 +111,9 @@ use std::{ path::{Path, PathBuf}, process::Command, }; -use version::Version; mod builder; mod prerequisites; -mod version; mod wasm_project; pub use builder::{WasmBuilder, WasmBuilderSelectProject}; @@ -178,59 +172,53 @@ fn copy_file_if_changed(src: PathBuf, dst: PathBuf) { } } -/// Get a cargo command that should be used to invoke the compilation. -fn get_cargo_command() -> CargoCommand { +/// Get a cargo command that compiles with nightly +fn get_nightly_cargo() -> CargoCommand { let env_cargo = CargoCommand::new(&env::var("CARGO").expect("`CARGO` env variable is always set by cargo")); let default_cargo = CargoCommand::new("cargo"); + let rustup_run_nightly = CargoCommand::new_with_args("rustup", &["run", "nightly", "cargo"]); let wasm_toolchain = env::var(WASM_BUILD_TOOLCHAIN).ok(); // First check if the user requested a specific toolchain - if let Some(cmd) = - wasm_toolchain.map(|t| CargoCommand::new_with_args("rustup", &["run", &t, "cargo"])) - { + if let Some(cmd) = wasm_toolchain.and_then(|t| get_rustup_nightly(Some(t))) { cmd - } else if env_cargo.supports_substrate_wasm_env() { + } else if env_cargo.is_nightly() { env_cargo - } else if default_cargo.supports_substrate_wasm_env() { + } else if default_cargo.is_nightly() { default_cargo + } else if rustup_run_nightly.is_nightly() { + rustup_run_nightly } else { - // If no command before provided us with a cargo that supports our Substrate wasm env, we - // try to search one with rustup. If that fails as well, we return the default cargo and let - // the prequisities check fail. - get_rustup_command().unwrap_or(default_cargo) + // If no command before provided us with a nightly compiler, we try to search one + // with rustup. If that fails as well, we return the default cargo and let the prequisities + // check fail. + get_rustup_nightly(None).unwrap_or(default_cargo) } } -/// Get the newest rustup command that supports our Substrate wasm env. -/// -/// Stable versions are always favored over nightly versions even if the nightly versions are -/// newer. -fn get_rustup_command() -> Option { +/// Get a nightly from rustup. If `selected` is `Some(_)`, a `CargoCommand` using the given +/// nightly is returned. +fn get_rustup_nightly(selected: Option) -> Option { let host = format!("-{}", env::var("HOST").expect("`HOST` is always set by cargo")); - let output = Command::new("rustup").args(&["toolchain", "list"]).output().ok()?.stdout; - let lines = output.as_slice().lines(); - - let mut versions = Vec::new(); - for line in lines.filter_map(|l| l.ok()) { - let rustup_version = line.trim_end_matches(&host); - - let cmd = CargoCommand::new_with_args("rustup", &["run", &rustup_version, "cargo"]); + let version = match selected { + Some(selected) => selected, + None => { + let output = Command::new("rustup").args(&["toolchain", "list"]).output().ok()?.stdout; + let lines = output.as_slice().lines(); - if !cmd.supports_substrate_wasm_env() { - continue - } - - let Some(cargo_version) = cmd.version() else { continue; }; + let mut latest_nightly = None; + for line in lines.filter_map(|l| l.ok()) { + if line.starts_with("nightly-") && line.ends_with(&host) { + // Rustup prints them sorted + latest_nightly = Some(line.clone()); + } + } - versions.push((cargo_version, rustup_version.to_string())); - } - - // Sort by the parsed version to get the latest version (greatest version) at the end of the - // vec. - versions.sort_by_key(|v| v.0); - let version = &versions.last()?.1; + latest_nightly?.trim_end_matches(&host).into() + }, + }; Some(CargoCommand::new_with_args("rustup", &["run", &version, "cargo"])) } @@ -240,23 +228,17 @@ fn get_rustup_command() -> Option { struct CargoCommand { program: String, args: Vec, - version: Option, } impl CargoCommand { fn new(program: &str) -> Self { - let version = Self::extract_version(program, &[]); - - CargoCommand { program: program.into(), args: Vec::new(), version } + CargoCommand { program: program.into(), args: Vec::new() } } fn new_with_args(program: &str, args: &[&str]) -> Self { - let version = Self::extract_version(program, args); - CargoCommand { program: program.into(), args: args.iter().map(ToString::to_string).collect(), - version, } } @@ -266,40 +248,20 @@ impl CargoCommand { cmd } - fn extract_version(program: &str, args: &[&str]) -> Option { - let version = Command::new(program) - .args(args) - .arg("--version") - .output() - .ok() - .and_then(|o| String::from_utf8(o.stdout).ok())?; - - Version::extract(&version) - } - - /// Returns the version of this cargo command or `None` if it failed to extract the version. - fn version(&self) -> Option { - self.version - } - - /// Check if the supplied cargo command supports our Substrate wasm environment. - /// - /// This means that either the cargo version is at minimum 1.68.0 or this is a nightly cargo. - /// - /// Assumes that cargo version matches the rustc version. - fn supports_substrate_wasm_env(&self) -> bool { + /// Check if the supplied cargo command is a nightly version + fn is_nightly(&self) -> bool { // `RUSTC_BOOTSTRAP` tells a stable compiler to behave like a nightly. So, when this env // variable is set, we can assume that whatever rust compiler we have, it is a nightly // compiler. For "more" information, see: // https://github.com/rust-lang/rust/blob/fa0f7d0080d8e7e9eb20aa9cbf8013f96c81287f/src/libsyntax/feature_gate/check.rs#L891 - if env::var("RUSTC_BOOTSTRAP").is_ok() { - return true - } - - let Some(version) = self.version() else { return false }; - - // Check if major and minor are greater or equal than 1.68 or this is a nightly. - version.major > 1 || (version.major == 1 && version.minor >= 68) || version.is_nightly + env::var("RUSTC_BOOTSTRAP").is_ok() || + self.command() + .arg("--version") + .output() + .map_err(|_| ()) + .and_then(|o| String::from_utf8(o.stdout).map_err(|_| ())) + .unwrap_or_default() + .contains("-nightly") } } diff --git a/utils/wasm-builder/src/prerequisites.rs b/utils/wasm-builder/src/prerequisites.rs index f5a985ab92b5d..ca07a029281a8 100644 --- a/utils/wasm-builder/src/prerequisites.rs +++ b/utils/wasm-builder/src/prerequisites.rs @@ -35,13 +35,10 @@ fn print_error_message(message: &str) -> String { /// /// Returns the versioned cargo command on success. pub(crate) fn check() -> Result { - let cargo_command = crate::get_cargo_command(); + let cargo_command = crate::get_nightly_cargo(); - if !cargo_command.supports_substrate_wasm_env() { - return Err(print_error_message( - "Cannot compile the WASM runtime: no compatible Rust compiler found!\n\ - Install at least Rust 1.68.0 or a recent nightly version.", - )) + if !cargo_command.is_nightly() { + return Err(print_error_message("Rust nightly not installed, please install it!")) } check_wasm_toolchain_installed(cargo_command) diff --git a/utils/wasm-builder/src/version.rs b/utils/wasm-builder/src/version.rs deleted file mode 100644 index 77e62b394bd55..0000000000000 --- a/utils/wasm-builder/src/version.rs +++ /dev/null @@ -1,198 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use std::cmp::Ordering; - -/// The version of rustc/cargo. -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub struct Version { - pub major: u32, - pub minor: u32, - pub patch: u32, - pub is_nightly: bool, - pub year: u32, - pub month: u32, - pub day: u32, -} - -impl Version { - /// Returns if `self` is a stable version. - pub fn is_stable(&self) -> bool { - !self.is_nightly - } - - /// Return if `self` is a nightly version. - pub fn is_nightly(&self) -> bool { - self.is_nightly - } - - /// Extract from the given `version` string. - pub fn extract(version: &str) -> Option { - let mut is_nightly = false; - let version_parts = version - .trim() - .split(" ") - .nth(1)? - .split(".") - .filter_map(|v| { - if let Some(rest) = v.strip_suffix("-nightly") { - is_nightly = true; - rest.parse().ok() - } else { - v.parse().ok() - } - }) - .collect::>(); - - if version_parts.len() != 3 { - return None - } - - let date = version.split(" ").nth(3)?; - - let date_parts = date - .split("-") - .filter_map(|v| v.trim().strip_suffix(")").unwrap_or(v).parse().ok()) - .collect::>(); - - if date_parts.len() != 3 { - return None - } - - Some(Version { - major: version_parts[0], - minor: version_parts[1], - patch: version_parts[2], - is_nightly, - year: date_parts[0], - month: date_parts[1], - day: date_parts[2], - }) - } -} - -/// Ordering is done in the following way: -/// -/// 1. `stable` > `nightly` -/// 2. Then compare major, minor and patch. -/// 3. Last compare the date. -impl Ord for Version { - fn cmp(&self, other: &Self) -> Ordering { - if self == other { - return Ordering::Equal - } - - // Ensure that `stable > nightly` - if self.is_stable() && other.is_nightly() { - return Ordering::Greater - } else if self.is_nightly() && other.is_stable() { - return Ordering::Less - } - - let to_compare = [ - (self.major, other.major), - (self.minor, other.minor), - (self.patch, other.patch), - (self.year, other.year), - (self.month, other.month), - (self.day, other.day), - ]; - - to_compare - .iter() - .find_map(|(l, r)| if l != r { l.partial_cmp(&r) } else { None }) - // We already checked this right at the beginning, so we should never return here - // `Equal`. - .unwrap_or(Ordering::Equal) - } -} - -impl PartialOrd for Version { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn version_compare_and_extract_works() { - let version_1_66_0 = Version::extract("cargo 1.66.0 (d65d197ad 2022-11-15)").unwrap(); - let version_1_66_1 = Version::extract("cargo 1.66.1 (d65d197ad 2022-11-15)").unwrap(); - let version_1_66_0_nightly = - Version::extract("cargo 1.66.0-nightly (d65d197ad 2022-10-15)").unwrap(); - let version_1_66_0_nightly_older_date = - Version::extract("cargo 1.66.0-nightly (d65d197ad 2022-10-14)").unwrap(); - let version_1_65_0 = Version::extract("cargo 1.65.0 (d65d197ad 2022-10-15)").unwrap(); - let version_1_65_0_older_date = - Version::extract("cargo 1.65.0 (d65d197ad 2022-10-14)").unwrap(); - - assert!(version_1_66_1 > version_1_66_0); - assert!(version_1_66_1 > version_1_65_0); - assert!(version_1_66_1 > version_1_66_0_nightly); - assert!(version_1_66_1 > version_1_66_0_nightly_older_date); - assert!(version_1_66_1 > version_1_65_0_older_date); - - assert!(version_1_66_0 > version_1_65_0); - assert!(version_1_66_0 > version_1_66_0_nightly); - assert!(version_1_66_0 > version_1_66_0_nightly_older_date); - assert!(version_1_66_0 > version_1_65_0_older_date); - - assert!(version_1_65_0 > version_1_66_0_nightly); - assert!(version_1_65_0 > version_1_66_0_nightly_older_date); - assert!(version_1_65_0 > version_1_65_0_older_date); - - let mut versions = vec![ - version_1_66_0, - version_1_66_0_nightly, - version_1_66_0_nightly_older_date, - version_1_65_0_older_date, - version_1_65_0, - version_1_66_1, - ]; - versions.sort_by(|a, b| b.cmp(a)); - - let expected_versions_order = vec![ - version_1_66_1, - version_1_66_0, - version_1_65_0, - version_1_65_0_older_date, - version_1_66_0_nightly, - version_1_66_0_nightly_older_date, - ]; - assert_eq!(expected_versions_order, versions); - } - - #[test] - fn parse_with_newline() { - let version_1_66_0 = Version::extract("cargo 1.66.0 (d65d197ad 2022-11-15)\n").unwrap(); - assert_eq!( - Version { - major: 1, - minor: 66, - patch: 0, - is_nightly: false, - year: 2022, - month: 11, - day: 15 - }, - version_1_66_0 - ); - } -} From 4cec441e88a292f9f751658a24d4e568026a4536 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Thu, 30 Mar 2023 13:03:51 +0200 Subject: [PATCH 37/43] Restore DeletionQueueMap --- frame/contracts/src/lib.rs | 2 +- frame/contracts/src/storage.rs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 9d35768908f87..b4a498b074ffd 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -899,7 +899,7 @@ pub mod pallet { /// Child trie deletion is a heavy operation depending on the amount of storage items /// stored in said trie. Therefore this operation is performed lazily in `on_idle`. #[pallet::storage] - pub(crate) type DeletionQueue = StorageMap<_, Twox64Concat, u32, TrieId>; + pub(crate) type DeletionQueueMap = StorageMap<_, Twox64Concat, u32, TrieId>; /// A pair of monotonic counters used to track the latest contract marked for deletion /// and the latest deleted contract in DeletionQueueMap. diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index 85b0addc5d32d..ac57c2277411b 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -22,8 +22,8 @@ pub mod meter; use crate::{ exec::{AccountIdOf, Key}, weights::WeightInfo, - AddressGenerator, BalanceOf, CodeHash, Config, ContractInfoOf, - DeletionQueue as DeletionQueueMap, DeletionQueueCounter, Error, Pallet, TrieId, SENTINEL, + AddressGenerator, BalanceOf, CodeHash, Config, ContractInfoOf, DeletionQueueCounter, + DeletionQueueMap, Error, Pallet, TrieId, SENTINEL, }; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ @@ -373,13 +373,13 @@ impl DeletionQueue { /// Returns `true` if the queue contains no elements. fn is_empty(&self) -> bool { - self.insert_index.wrapping_sub(self.delete_counter) == 0 + self.insert_counter.wrapping_sub(self.delete_counter) == 0 } /// Insert a contract in the deletion queue. fn insert(&mut self, trie_id: TrieId) { - >::insert(self.insert_index, trie_id); - self.insert_index = self.insert_index.wrapping_add(1); + >::insert(self.insert_counter, trie_id); + self.insert_counter = self.insert_counter.wrapping_add(1); >::set(self.clone()); } @@ -396,10 +396,10 @@ impl DeletionQueue { #[cfg(test)] impl DeletionQueue { - pub fn from_test_values(insert_index: u32, delete_counter: u32) -> Self { - Self { insert_index, delete_counter, _phantom: Default::default() } + pub fn from_test_values(insert_counter: u32, delete_counter: u32) -> Self { + Self { insert_counter, delete_counter, _phantom: Default::default() } } pub fn as_test_tuple(&self) -> (u32, u32) { - (self.insert_index, self.delete_counter) + (self.insert_counter, self.delete_counter) } } From 092d51ca2547d969d2d322ec0bbe487070273baf Mon Sep 17 00:00:00 2001 From: pgherveou Date: Thu, 30 Mar 2023 13:24:32 +0200 Subject: [PATCH 38/43] fix namings --- frame/contracts/src/lib.rs | 9 +++++---- frame/contracts/src/storage.rs | 22 +++++++++++----------- frame/contracts/src/tests.rs | 4 ++-- frame/contracts/src/weights.rs | 8 ++++---- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index b4a498b074ffd..70ab3d3a49334 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -102,7 +102,7 @@ mod tests; use crate::{ exec::{AccountIdOf, ErrorOrigin, ExecError, Executable, Key, Stack as ExecStack}, gas::GasMeter, - storage::{meter::Meter as StorageMeter, ContractInfo, DeletionQueue}, + storage::{meter::Meter as StorageMeter, ContractInfo, DeletionQueueManager}, wasm::{OwnerInfo, PrefabWasmModule, TryInstantiate}, weights::WeightInfo, }; @@ -899,16 +899,17 @@ pub mod pallet { /// Child trie deletion is a heavy operation depending on the amount of storage items /// stored in said trie. Therefore this operation is performed lazily in `on_idle`. #[pallet::storage] - pub(crate) type DeletionQueueMap = StorageMap<_, Twox64Concat, u32, TrieId>; + pub(crate) type DeletionQueue = StorageMap<_, Twox64Concat, u32, TrieId>; /// A pair of monotonic counters used to track the latest contract marked for deletion - /// and the latest deleted contract in DeletionQueueMap. + /// and the latest deleted contract in queue. /// /// When we iterate the map to remove contracts, we simply use the delete counter and /// don't pay the cost of an extra call to `sp_io::storage::next_key` to lookup the next entry /// in the map #[pallet::storage] - pub(crate) type DeletionQueueCounter = StorageValue<_, DeletionQueue, ValueQuery>; + pub(crate) type DeletionQueueCounter = + StorageValue<_, DeletionQueueManager, ValueQuery>; } /// Context of a contract invocation. diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index ac57c2277411b..b319f6ce1a164 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -23,7 +23,7 @@ use crate::{ exec::{AccountIdOf, Key}, weights::WeightInfo, AddressGenerator, BalanceOf, CodeHash, Config, ContractInfoOf, DeletionQueueCounter, - DeletionQueueMap, Error, Pallet, TrieId, SENTINEL, + DeletionQueue, Error, Pallet, TrieId, SENTINEL, }; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ @@ -205,7 +205,7 @@ impl ContractInfo { /// /// You must make sure that the contract is also removed when queuing the trie for deletion. pub fn queue_trie_for_deletion(&self) { - DeletionQueue::::load().insert(self.trie_id.clone()); + DeletionQueueManager::::load().insert(self.trie_id.clone()); } /// Calculates the weight that is necessary to remove one key from the trie and how many @@ -229,7 +229,7 @@ impl ContractInfo { /// /// It returns the amount of weight used for that task. pub fn process_deletion_queue_batch(weight_limit: Weight) -> Weight { - let mut queue = >::load(); + let mut queue = >::load(); if queue.is_empty() { return Weight::zero() @@ -336,7 +336,7 @@ impl Deref for DepositAccount { /// later by pulling the contract from the queue in the `on_idle` hook. #[derive(Encode, Decode, TypeInfo, MaxEncodedLen, DefaultNoBound, Clone)] #[scale_info(skip_type_params(T))] -pub struct DeletionQueue { +pub struct DeletionQueueManager { /// Monotonic counter used as a key for inserting a new deleted contract in the queue. /// The counter is incremented after each insertion. insert_counter: u32, @@ -352,21 +352,21 @@ pub struct DeletionQueue { /// and none can be added or read in the meantime. struct DeletionQueueEntry<'a, T: Config> { trie_id: TrieId, - queue: &'a mut DeletionQueue, + queue: &'a mut DeletionQueueManager, } impl<'a, T: Config> DeletionQueueEntry<'a, T> { /// Remove the contract from the deletion queue. fn remove(self) { - >::remove(self.queue.delete_counter); + >::remove(self.queue.delete_counter); self.queue.delete_counter = self.queue.delete_counter.wrapping_add(1); >::set(self.queue.clone()); } } -impl DeletionQueue { +impl DeletionQueueManager { /// Load the Deletion Queue nonces, so we can perform read or write operations on the - /// DeletionQueueMap storage. + /// DeletionQueue storage. fn load() -> Self { >::get() } @@ -378,7 +378,7 @@ impl DeletionQueue { /// Insert a contract in the deletion queue. fn insert(&mut self, trie_id: TrieId) { - >::insert(self.insert_counter, trie_id); + >::insert(self.insert_counter, trie_id); self.insert_counter = self.insert_counter.wrapping_add(1); >::set(self.clone()); } @@ -389,13 +389,13 @@ impl DeletionQueue { return None } - let entry = >::get(self.delete_counter); + let entry = >::get(self.delete_counter); entry.map(|trie_id| DeletionQueueEntry { trie_id, queue: self }) } } #[cfg(test)] -impl DeletionQueue { +impl DeletionQueueManager { pub fn from_test_values(insert_counter: u32, delete_counter: u32) -> Self { Self { insert_counter, delete_counter, _phantom: Default::default() } } diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index aabfe44775070..0a7ae0485173b 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -22,7 +22,7 @@ use crate::{ Result as ExtensionResult, RetVal, ReturnFlags, SysConfig, }, exec::{Frame, Key}, - storage::DeletionQueue, + storage::DeletionQueueManager, tests::test_utils::{get_contract, get_contract_checked}, wasm::{Determinism, PrefabWasmModule, ReturnCode as RuntimeReturnCode}, weights::WeightInfo, @@ -2273,7 +2273,7 @@ fn deletion_queue_ring_buffer_overflow() { // setup the deletion queue with custom nonces ext.execute_with(|| { // manually se the nonces of the deletion queue - let queue = DeletionQueue::from_test_values(u32::MAX - 1, u32::MAX - 1); + let queue = DeletionQueueManager::from_test_values(u32::MAX - 1, u32::MAX - 1); >::set(queue); }); diff --git a/frame/contracts/src/weights.rs b/frame/contracts/src/weights.rs index af05f7bf2de3f..22a24aa27fe01 100644 --- a/frame/contracts/src/weights.rs +++ b/frame/contracts/src/weights.rs @@ -801,8 +801,8 @@ impl WeightInfo for SubstrateWeight { /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Measured) /// Storage: System EventTopics (r:3 w:3) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// Storage: Contracts DeletionQueueMap (r:0 w:1) - /// Proof: Contracts DeletionQueueMap (max_values: None, max_size: Some(142), added: 2617, mode: Measured) + /// Storage: Contracts DeletionQueue (r:0 w:1) + /// Proof: Contracts DeletionQueue (max_values: None, max_size: Some(142), added: 2617, mode: Measured) /// The range of component `r` is `[0, 1]`. fn seal_terminate(r: u32, ) -> Weight { // Proof Size summary in bytes: @@ -2747,8 +2747,8 @@ impl WeightInfo for () { /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Measured) /// Storage: System EventTopics (r:3 w:3) /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// Storage: Contracts DeletionQueueMap (r:0 w:1) - /// Proof: Contracts DeletionQueueMap (max_values: None, max_size: Some(142), added: 2617, mode: Measured) + /// Storage: Contracts DeletionQueue (r:0 w:1) + /// Proof: Contracts DeletionQueue (max_values: None, max_size: Some(142), added: 2617, mode: Measured) /// The range of component `r` is `[0, 1]`. fn seal_terminate(r: u32, ) -> Weight { // Proof Size summary in bytes: From 6df076fd7a33081bc46f80ca3c9a03ec2e5ec2f3 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Thu, 30 Mar 2023 13:26:42 +0200 Subject: [PATCH 39/43] PR comment --- frame/contracts/src/storage.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index b319f6ce1a164..099a5b365f6f0 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -22,8 +22,8 @@ pub mod meter; use crate::{ exec::{AccountIdOf, Key}, weights::WeightInfo, - AddressGenerator, BalanceOf, CodeHash, Config, ContractInfoOf, DeletionQueueCounter, - DeletionQueue, Error, Pallet, TrieId, SENTINEL, + AddressGenerator, BalanceOf, CodeHash, Config, ContractInfoOf, DeletionQueue, + DeletionQueueCounter, Error, Pallet, TrieId, SENTINEL, }; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ @@ -348,10 +348,12 @@ pub struct DeletionQueueManager { } /// View on a contract that is marked for deletion. -/// The struct takes a mutable reference on the deletion queue so that the contract can be removed, -/// and none can be added or read in the meantime. struct DeletionQueueEntry<'a, T: Config> { + /// the trie id of the contract to delete. trie_id: TrieId, + + /// A mutable reference on the queue so that the contract can be removed, and none can be added + /// or read in the meantime. queue: &'a mut DeletionQueueManager, } From 9d277cd8a74ae596c3ce6fbf96d3ccadc91c3aae Mon Sep 17 00:00:00 2001 From: pgherveou Date: Thu, 30 Mar 2023 13:33:29 +0200 Subject: [PATCH 40/43] move comments --- frame/contracts/src/lib.rs | 4 ---- frame/contracts/src/storage.rs | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 70ab3d3a49334..dc93a7f06ff2d 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -903,10 +903,6 @@ pub mod pallet { /// A pair of monotonic counters used to track the latest contract marked for deletion /// and the latest deleted contract in queue. - /// - /// When we iterate the map to remove contracts, we simply use the delete counter and - /// don't pay the cost of an extra call to `sp_io::storage::next_key` to lookup the next entry - /// in the map #[pallet::storage] pub(crate) type DeletionQueueCounter = StorageValue<_, DeletionQueueManager, ValueQuery>; diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index 099a5b365f6f0..d4a921af7ab33 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -386,6 +386,10 @@ impl DeletionQueueManager { } /// Fetch the next contract to be deleted. + /// + /// Note: + /// we use the delete counter to get the next value to read from the queue and thus don't pay + /// the cost of an extra call to `sp_io::storage::next_key` to lookup the next entry in the map fn next(&mut self) -> Option> { if self.is_empty() { return None From 5da9750225219d47558745187f0bed601d57e46d Mon Sep 17 00:00:00 2001 From: PG Herveou Date: Thu, 30 Mar 2023 13:41:41 +0200 Subject: [PATCH 41/43] Update frame/contracts/src/storage.rs --- frame/contracts/src/storage.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index d4a921af7ab33..55e4e13c60052 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -329,7 +329,7 @@ impl Deref for DepositAccount { } } -/// DeletionQueue manage the removal of contracts storage that are marked for deletion. +/// Manage the removal of contracts storage that are marked for deletion. /// /// When a contract is deleted by calling `seal_terminate` it becomes inaccessible /// immediately, but the deletion of the storage items it has accumulated is performed From 1e5eaaf76c1a85384542ecd313b82d61e0f1ca12 Mon Sep 17 00:00:00 2001 From: PG Herveou Date: Thu, 30 Mar 2023 13:43:18 +0200 Subject: [PATCH 42/43] Update frame/contracts/src/storage.rs --- frame/contracts/src/storage.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index 55e4e13c60052..bbfd630554403 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -337,7 +337,7 @@ impl Deref for DepositAccount { #[derive(Encode, Decode, TypeInfo, MaxEncodedLen, DefaultNoBound, Clone)] #[scale_info(skip_type_params(T))] pub struct DeletionQueueManager { - /// Monotonic counter used as a key for inserting a new deleted contract in the queue. + /// Counter used as a key for inserting a new deleted contract in the queue. /// The counter is incremented after each insertion. insert_counter: u32, /// The index used to read the next element to be deleted in the queue. From cec7e08a8f273177e3df82a9fbf2b04dde680110 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Thu, 30 Mar 2023 13:48:35 +0200 Subject: [PATCH 43/43] fixes --- frame/contracts/src/storage.rs | 7 ++----- frame/contracts/src/tests.rs | 5 ++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/frame/contracts/src/storage.rs b/frame/contracts/src/storage.rs index bbfd630554403..769caef0736fe 100644 --- a/frame/contracts/src/storage.rs +++ b/frame/contracts/src/storage.rs @@ -255,10 +255,7 @@ impl ContractInfo { match outcome { // This happens when our budget wasn't large enough to remove all keys. - KillStorageResult::SomeRemaining(keys_removed) => { - remaining_key_budget = remaining_key_budget.saturating_sub(keys_removed); - break - }, + KillStorageResult::SomeRemaining(_) => return weight_limit, KillStorageResult::AllRemoved(keys_removed) => { entry.remove(); remaining_key_budget = remaining_key_budget.saturating_sub(keys_removed); @@ -367,7 +364,7 @@ impl<'a, T: Config> DeletionQueueEntry<'a, T> { } impl DeletionQueueManager { - /// Load the Deletion Queue nonces, so we can perform read or write operations on the + /// Load the `DeletionQueueCounter`, so we can perform read or write operations on the /// DeletionQueue storage. fn load() -> Self { >::get() diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 0a7ae0485173b..beaec458e36f7 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -2270,9 +2270,8 @@ fn deletion_queue_ring_buffer_overflow() { let (code, _hash) = compile_module::("self_destruct").unwrap(); let mut ext = ExtBuilder::default().existential_deposit(50).build(); - // setup the deletion queue with custom nonces + // setup the deletion queue with custom counters ext.execute_with(|| { - // manually se the nonces of the deletion queue let queue = DeletionQueueManager::from_test_values(u32::MAX - 1, u32::MAX - 1); >::set(queue); }); @@ -2332,7 +2331,7 @@ fn deletion_queue_ring_buffer_overflow() { assert_matches!(child::get::(trie, &[99]), None); } - // nonces values should go from u32::MAX - 1 to 1 + // insert and delete counter values should go from u32::MAX - 1 to 1 assert_eq!(>::get().as_test_tuple(), (1, 1)); }) }