From 71793593e20bdcb4d3216a3edb6c741f91b227d6 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Wed, 26 Apr 2023 10:55:43 +0200 Subject: [PATCH 001/105] contracts: refactor currency to use fungible traits --- frame/contracts/src/exec.rs | 18 +++++++++++------- frame/contracts/src/lib.rs | 11 ++++++----- frame/contracts/src/storage/meter.rs | 17 +++++++---------- frame/contracts/src/wasm/code_cache.rs | 4 ++-- frame/support/src/traits/tokens/misc.rs | 14 +++++++++++--- 5 files changed, 37 insertions(+), 27 deletions(-) diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 03e1c4fd32585..16f70650aa260 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -26,7 +26,11 @@ use frame_support::{ dispatch::{DispatchError, DispatchResult, DispatchResultWithPostInfo, Dispatchable}, storage::{with_transaction, TransactionOutcome}, traits::{ - tokens::{Fortitude::Polite, Preservation::Expendable}, + fungible::{Inspect, Mutate}, + tokens::{ + Fortitude::Polite, + Preservation::{self, Expendable}, + }, Contains, Currency, ExistenceRequirement, OriginTrait, Randomness, Time, }, weights::Weight, @@ -1026,12 +1030,12 @@ where /// Transfer some funds from `from` to `to`. fn transfer( - existence_requirement: ExistenceRequirement, + preservation: Preservation, from: &T::AccountId, to: &T::AccountId, value: BalanceOf, ) -> DispatchResult { - T::Currency::transfer(from, to, value, existence_requirement) + T::Currency::transfer(from, to, value, preservation) .map_err(|_| Error::::TransferFailed)?; Ok(()) } @@ -1047,7 +1051,7 @@ where } let value = frame.value_transferred; - Self::transfer(ExistenceRequirement::KeepAlive, self.caller(), &frame.account_id, value) + Self::transfer(Preservation::Protect, self.caller(), &frame.account_id, value) } /// Reference to the current (top) frame. @@ -1202,7 +1206,7 @@ where &frame.account_id, beneficiary, T::Currency::reducible_balance(&frame.account_id, Expendable, Polite), - ExistenceRequirement::AllowDeath, + Preservation::Expendable, )?; info.queue_trie_for_deletion(); ContractInfoOf::::remove(&frame.account_id); @@ -1218,7 +1222,7 @@ where } fn transfer(&mut self, to: &T::AccountId, value: BalanceOf) -> DispatchResult { - Self::transfer(ExistenceRequirement::KeepAlive, &self.top_frame().account_id, to, value) + Self::transfer(Preservation::Protect, &self.top_frame().account_id, to, value) } fn get_storage(&mut self, key: &Key) -> Option> { @@ -1273,7 +1277,7 @@ where } fn balance(&self) -> BalanceOf { - T::Currency::free_balance(&self.top_frame().account_id) + T::Currency::balance(&self.top_frame().account_id) } fn value_transferred(&self) -> BalanceOf { diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 26b16b3291a2f..dbac8338bc284 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -112,8 +112,8 @@ use frame_support::{ dispatch::{Dispatchable, GetDispatchInfo, Pays, PostDispatchInfo}, ensure, traits::{ - tokens::fungible::Inspect, ConstU32, Contains, Currency, Get, Randomness, - ReservableCurrency, Time, + fungible::{Inspect, Mutate, MutateHold}, + ConstU32, Contains, Currency, Get, Randomness, ReservableCurrency, Time, }, weights::Weight, BoundedVec, WeakBoundedVec, @@ -144,7 +144,7 @@ pub use crate::wasm::api_doc; type CodeHash = ::Hash; type TrieId = BoundedVec>; type BalanceOf = - <::Currency as Currency<::AccountId>>::Balance; + <::Currency as Inspect<::AccountId>>::Balance; type CodeVec = BoundedVec::MaxCodeLen>; type RelaxedCodeVec = WeakBoundedVec::MaxCodeLen>; type AccountIdLookupOf = <::Lookup as StaticLookup>::Source; @@ -193,8 +193,9 @@ pub mod pallet { type Randomness: Randomness; /// The currency in which fees are paid and contract balances are held. - type Currency: ReservableCurrency // TODO: Move to fungible traits - + Inspect>; + type Currency: Inspect + + Mutate + + MutateHold; /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/frame/contracts/src/storage/meter.rs b/frame/contracts/src/storage/meter.rs index ef3e01f6d6c4f..d669741cd4483 100644 --- a/frame/contracts/src/storage/meter.rs +++ b/frame/contracts/src/storage/meter.rs @@ -26,7 +26,8 @@ use frame_support::{ dispatch::DispatchError, ensure, traits::{ - tokens::{Fortitude::Polite, Preservation::Protect, WithdrawConsequence}, + fungible::Mutate, + tokens::{Fortitude::Polite, Preservation, WithdrawConsequence}, Currency, ExistenceRequirement, Get, }, DefaultNoBound, RuntimeDebugNoBound, @@ -409,7 +410,7 @@ where System::::inc_consumers(info.deposit_account())?; // We also need to make sure that the contract's account itself exists. - T::Currency::transfer(origin, contract, ed, ExistenceRequirement::KeepAlive)?; + T::Currency::transfer(origin, contract, ed, Preservation::Protect)?; System::::inc_consumers(contract)?; Ok(deposit) @@ -459,7 +460,7 @@ impl Ext for ReservingExt { // We are sending the `min_leftover` and the `min_balance` from the origin // account as part of a contract call. Hence origin needs to have those left over // as free balance after accounting for all deposits. - let max = T::Currency::reducible_balance(origin, Protect, Polite) + let max = T::Currency::reducible_balance(origin, Preservation::Protect, Polite) .saturating_sub(min_leftover) .saturating_sub(Pallet::::min_balance()); let limit = limit.unwrap_or(max); @@ -494,12 +495,8 @@ impl Ext for ReservingExt { // The sender always has enough balance because we checked that it had enough // balance when instantiating the storage meter. There is no way for the sender // which is a plain account to send away this balance in the meantime. - let result = T::Currency::transfer( - origin, - deposit_account, - *amount, - ExistenceRequirement::KeepAlive, - ); + let result = + T::Currency::transfer(origin, deposit_account, *amount, Preservation::Protect); if let Err(err) = result { log::error!( target: "runtime::contracts", @@ -527,7 +524,7 @@ impl Ext for ReservingExt { origin, *amount, // We can safely use `AllowDeath` because our own consumer prevents an removal. - ExistenceRequirement::AllowDeath, + Preservation::Expendable, ); if matches!(result, Err(_)) { log::error!( diff --git a/frame/contracts/src/wasm/code_cache.rs b/frame/contracts/src/wasm/code_cache.rs index 7dbce367ca96b..712ac9837910c 100644 --- a/frame/contracts/src/wasm/code_cache.rs +++ b/frame/contracts/src/wasm/code_cache.rs @@ -38,7 +38,7 @@ use crate::{ use frame_support::{ dispatch::{DispatchError, DispatchResult}, ensure, - traits::{Get, ReservableCurrency}, + traits::{fungible::MutateHold, Get}, WeakBoundedVec, }; use sp_runtime::traits::BadOrigin; @@ -95,7 +95,7 @@ pub fn store(mut module: PrefabWasmModule, instantiated: bool) -> ); // This `None` case happens only in freshly uploaded modules. This means that // the `owner` is always the origin of the current transaction. - T::Currency::reserve(&new_owner_info.owner, new_owner_info.deposit) + T::Currency::hold(&new_owner_info.owner, new_owner_info.deposit) .map_err(|_| >::StorageDepositNotEnoughFunds)?; new_owner_info.refcount = if instantiated { 1 } else { 0 }; >::insert(&code_hash, orig_code); diff --git a/frame/support/src/traits/tokens/misc.rs b/frame/support/src/traits/tokens/misc.rs index 75aef0e04ea65..6fa1d563a1293 100644 --- a/frame/support/src/traits/tokens/misc.rs +++ b/frame/support/src/traits/tokens/misc.rs @@ -20,7 +20,7 @@ use codec::{Decode, Encode, FullCodec, MaxEncodedLen}; use sp_arithmetic::traits::{AtLeast32BitUnsigned, Zero}; use sp_core::RuntimeDebug; -use sp_runtime::{traits::Convert, ArithmeticError, DispatchError, TokenError}; +use sp_runtime::{traits::Convert, ArithmeticError, DispatchError, FixedPointOperand, TokenError}; use sp_std::fmt::Debug; /// The origin of funds to be used for a deposit operation. @@ -228,7 +228,14 @@ impl Balance for T { } From c0a95d241ff8cdbd7c4dc60523d5df912154d67d Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Wed, 26 Apr 2023 14:23:07 +0200 Subject: [PATCH 002/105] contracts: refactor currency to use fungible traits --- frame/contracts/src/exec.rs | 14 +++++--------- frame/contracts/src/lib.rs | 16 ++++++++++++++-- frame/contracts/src/storage/meter.rs | 2 +- frame/contracts/src/tests.rs | 14 ++++++++++++-- frame/contracts/src/wasm/code_cache.rs | 17 +++++++++++++---- 5 files changed, 45 insertions(+), 18 deletions(-) diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 16f70650aa260..347176dca552f 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -27,11 +27,8 @@ use frame_support::{ storage::{with_transaction, TransactionOutcome}, traits::{ fungible::{Inspect, Mutate}, - tokens::{ - Fortitude::Polite, - Preservation::{self, Expendable}, - }, - Contains, Currency, ExistenceRequirement, OriginTrait, Randomness, Time, + tokens::{Fortitude::Polite, Preservation}, + Contains, OriginTrait, Randomness, Time, }, weights::Weight, Blake2_128Concat, BoundedVec, StorageHasher, @@ -1194,7 +1191,6 @@ where } fn terminate(&mut self, beneficiary: &AccountIdOf) -> Result<(), DispatchError> { - use frame_support::traits::fungible::Inspect; if self.is_recursive() { return Err(Error::::TerminatedWhileReentrant.into()) } @@ -1205,7 +1201,7 @@ where T::Currency::transfer( &frame.account_id, beneficiary, - T::Currency::reducible_balance(&frame.account_id, Expendable, Polite), + T::Currency::reducible_balance(&frame.account_id, Preservation::Expendable, Polite), Preservation::Expendable, )?; info.queue_trie_for_deletion(); @@ -1631,7 +1627,7 @@ mod tests { set_balance(&origin, 100); set_balance(&dest, 0); - MockStack::transfer(ExistenceRequirement::KeepAlive, &origin, &dest, 55).unwrap(); + MockStack::transfer(Preservation::Protect, &origin, &dest, 55).unwrap(); assert_eq!(get_balance(&origin), 45); assert_eq!(get_balance(&dest), 55); @@ -1763,7 +1759,7 @@ mod tests { ExtBuilder::default().build().execute_with(|| { set_balance(&origin, 0); - let result = MockStack::transfer(ExistenceRequirement::KeepAlive, &origin, &dest, 100); + let result = MockStack::transfer(Preservation::Protect, &origin, &dest, 100); assert_eq!(result, Err(Error::::TransferFailed.into())); assert_eq!(get_balance(&origin), 0); diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index dbac8338bc284..258a3961667af 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -112,8 +112,8 @@ use frame_support::{ dispatch::{Dispatchable, GetDispatchInfo, Pays, PostDispatchInfo}, ensure, traits::{ - fungible::{Inspect, Mutate, MutateHold}, - ConstU32, Contains, Currency, Get, Randomness, ReservableCurrency, Time, + fungible::{Inspect, InspectHold, Mutate, MutateHold}, + ConstU32, Contains, Get, Randomness, Time, }, weights::Weight, BoundedVec, WeakBoundedVec, @@ -300,6 +300,10 @@ pub mod pallet { /// The maximum length of the debug buffer in bytes. #[pallet::constant] type MaxDebugBufferLen: Get; + + /// The identifier of the hold reason. + #[pallet::constant] + type HoldReason: Get<>::Reason>; } #[pallet::hooks] @@ -856,6 +860,14 @@ pub mod pallet { Indeterministic, } + /// A reason for the pallet contracts placing a hold on funds. + #[pallet::composite_enum] + pub enum HoldReason { + /// The Pallet has reserved it for storage deposit. + #[codec(index = 0)] + StorageDepositReserve, + } + /// A mapping from an original code hash to the original code, untouched by instrumentation. #[pallet::storage] pub(crate) type PristineCode = StorageMap<_, Identity, CodeHash, CodeVec>; diff --git a/frame/contracts/src/storage/meter.rs b/frame/contracts/src/storage/meter.rs index d669741cd4483..cb7069c57f08c 100644 --- a/frame/contracts/src/storage/meter.rs +++ b/frame/contracts/src/storage/meter.rs @@ -28,7 +28,7 @@ use frame_support::{ traits::{ fungible::Mutate, tokens::{Fortitude::Polite, Preservation, WithdrawConsequence}, - Currency, ExistenceRequirement, Get, + Get, }, DefaultNoBound, RuntimeDebugNoBound, }; diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index bae6c1946e183..2e6859a8fce3f 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -30,7 +30,7 @@ use crate::{ DeletionQueueCounter, Error, Pallet, Schedule, }; use assert_matches::assert_matches; -use codec::Encode; +use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ assert_err, assert_err_ignore_postinfo, assert_noop, assert_ok, dispatch::{DispatchErrorWithPostInfo, PostDispatchInfo}, @@ -44,6 +44,7 @@ use frame_support::{ }; use frame_system::{EventRecord, Phase}; use pretty_assertions::{assert_eq, assert_ne}; +use scale_info::TypeInfo; use sp_io::hashing::blake2_256; use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; use sp_runtime::{ @@ -321,7 +322,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type HoldIdentifier = (); + type HoldIdentifier = HoldIdentifier; type MaxHolds = (); } @@ -367,6 +368,13 @@ impl Default for Filters { } } +#[derive( + Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, MaxEncodedLen, Debug, TypeInfo, +)] +pub enum HoldIdentifier { + StorageDepositReserve, +} + parameter_types! { static CallFilter: Filters = Default::default(); } @@ -385,6 +393,7 @@ impl Contains for TestFilter { parameter_types! { pub static UnstableInterface: bool = true; + pub const HoldReason: HoldIdentifier = HoldIdentifier::StorageDepositReserve; } impl Config for Test { @@ -407,6 +416,7 @@ impl Config for Test { type MaxStorageKeyLen = ConstU32<128>; type UnsafeUnstableInterface = UnstableInterface; type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>; + type HoldReason = HoldReason; } pub const ALICE: AccountId32 = AccountId32::new([1u8; 32]); diff --git a/frame/contracts/src/wasm/code_cache.rs b/frame/contracts/src/wasm/code_cache.rs index 712ac9837910c..ae7aed381daa1 100644 --- a/frame/contracts/src/wasm/code_cache.rs +++ b/frame/contracts/src/wasm/code_cache.rs @@ -38,7 +38,7 @@ use crate::{ use frame_support::{ dispatch::{DispatchError, DispatchResult}, ensure, - traits::{fungible::MutateHold, Get}, + traits::{fungible::MutateHold, tokens::Precision::BestEffort, Get}, WeakBoundedVec, }; use sp_runtime::traits::BadOrigin; @@ -95,8 +95,12 @@ pub fn store(mut module: PrefabWasmModule, instantiated: bool) -> ); // This `None` case happens only in freshly uploaded modules. This means that // the `owner` is always the origin of the current transaction. - T::Currency::hold(&new_owner_info.owner, new_owner_info.deposit) - .map_err(|_| >::StorageDepositNotEnoughFunds)?; + T::Currency::hold( + &T::HoldReason::get(), + &new_owner_info.owner, + new_owner_info.deposit, + ) + .map_err(|_| >::StorageDepositNotEnoughFunds)?; new_owner_info.refcount = if instantiated { 1 } else { 0 }; >::insert(&code_hash, orig_code); >::insert(&code_hash, module); @@ -144,7 +148,12 @@ pub fn try_remove(origin: &T::AccountId, code_hash: CodeHash) -> D if let Some(owner_info) = existing { ensure!(owner_info.refcount == 0, >::CodeInUse); ensure!(&owner_info.owner == origin, BadOrigin); - T::Currency::unreserve(&owner_info.owner, owner_info.deposit); + T::Currency::release( + &T::HoldReason::get(), + &owner_info.owner, + owner_info.deposit, + BestEffort, + )?; *existing = None; >::remove(&code_hash); >::remove(&code_hash); From 5eee85958175c2ac245b94af75d340dad5a5dd94 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Wed, 3 May 2023 09:54:56 +0200 Subject: [PATCH 003/105] contracts: add minor improvements --- frame/contracts/src/wasm/code_cache.rs | 3 +-- frame/support/src/traits/tokens/fungibles/hold.rs | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/frame/contracts/src/wasm/code_cache.rs b/frame/contracts/src/wasm/code_cache.rs index ae7aed381daa1..31ddf26aa10ab 100644 --- a/frame/contracts/src/wasm/code_cache.rs +++ b/frame/contracts/src/wasm/code_cache.rs @@ -99,8 +99,7 @@ pub fn store(mut module: PrefabWasmModule, instantiated: bool) -> &T::HoldReason::get(), &new_owner_info.owner, new_owner_info.deposit, - ) - .map_err(|_| >::StorageDepositNotEnoughFunds)?; + )?; new_owner_info.refcount = if instantiated { 1 } else { 0 }; >::insert(&code_hash, orig_code); >::insert(&code_hash, module); diff --git a/frame/support/src/traits/tokens/fungibles/hold.rs b/frame/support/src/traits/tokens/fungibles/hold.rs index 68580ebff4bce..d87d38c2f6629 100644 --- a/frame/support/src/traits/tokens/fungibles/hold.rs +++ b/frame/support/src/traits/tokens/fungibles/hold.rs @@ -133,7 +133,7 @@ pub trait Inspect: super::Inspect { /// **WARNING** /// Do not use this directly unless you want trouble, since it allows you to alter account balances /// without keeping the issuance up to date. It has no safeguards against accidentally creating -/// token imbalances in your system leading to accidental imflation or deflation. It's really just +/// token imbalances in your system leading to accidental inflation or deflation. It's really just /// for the underlying datatype to implement so the user gets the much safer `Balanced` trait to /// use. pub trait Unbalanced: Inspect { @@ -146,7 +146,7 @@ pub trait Unbalanced: Inspect { /// invariants such as any Existential Deposits needed or overflows/underflows. /// If this cannot be done for some reason (e.g. because the account doesn't exist) then an /// `Err` is returned. - // Implmentation note: This should increment the consumer refs if it moves total on hold from + // Implementation note: This should increment the consumer refs if it moves total on hold from // zero to non-zero and decrement in the opposite direction. // // Since this was not done in the previous logic, this will need either a migration or a From 4acbbe559bd1da1ec0721a8593ff30dc946957fb Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Mon, 8 May 2023 12:23:08 +0200 Subject: [PATCH 004/105] contracts: max holds config set --- frame/contracts/src/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 3d183985abc05..edfa909baa31a 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -324,7 +324,7 @@ impl pallet_balances::Config for Test { type FreezeIdentifier = (); type MaxFreezes = (); type HoldIdentifier = HoldIdentifier; - type MaxHolds = (); + type MaxHolds = ConstU32<1>; } impl pallet_timestamp::Config for Test { From e6d82d168c8694bff425f515e4c9ccf459ef3d93 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Mon, 8 May 2023 12:25:08 +0200 Subject: [PATCH 005/105] contracts: fix some typos --- frame/support/src/traits/tokens/fungible/hold.rs | 6 +++--- frame/support/src/traits/tokens/fungibles/regular.rs | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/frame/support/src/traits/tokens/fungible/hold.rs b/frame/support/src/traits/tokens/fungible/hold.rs index ddcb8c6ac1da8..2605d1797ed2e 100644 --- a/frame/support/src/traits/tokens/fungible/hold.rs +++ b/frame/support/src/traits/tokens/fungible/hold.rs @@ -99,7 +99,7 @@ pub trait Inspect: super::Inspect { /// Check to see if some `amount` of funds of `who` may be placed on hold for the given /// `reason`. Reasons why this may not be true: /// - /// - The implementor supports only a limited number of concurrernt holds on an account which is + /// - The implementor supports only a limited number of concurrent holds on an account which is /// the possible values of `reason`; /// - The main balance of the account is less than `amount`; /// - Removing `amount` from the main balance would kill the account and remove the only @@ -118,7 +118,7 @@ pub trait Inspect: super::Inspect { /// **WARNING** /// Do not use this directly unless you want trouble, since it allows you to alter account balances /// without keeping the issuance up to date. It has no safeguards against accidentally creating -/// token imbalances in your system leading to accidental imflation or deflation. It's really just +/// token imbalances in your system leading to accidental inflation or deflation. It's really just /// for the underlying datatype to implement so the user gets the much safer `Balanced` trait to /// use. pub trait Unbalanced: Inspect { @@ -131,7 +131,7 @@ pub trait Unbalanced: Inspect { /// invariants such as any Existential Deposits needed or overflows/underflows. /// If this cannot be done for some reason (e.g. because the account doesn't exist) then an /// `Err` is returned. - // Implmentation note: This should increment the consumer refs if it moves total on hold from + // Implementation note: This should increment the consumer refs if it moves total on hold from // zero to non-zero and decrement in the opposite direction. // // Since this was not done in the previous logic, this will need either a migration or a diff --git a/frame/support/src/traits/tokens/fungibles/regular.rs b/frame/support/src/traits/tokens/fungibles/regular.rs index 27d1a50b34805..4e8f1e48ed599 100644 --- a/frame/support/src/traits/tokens/fungibles/regular.rs +++ b/frame/support/src/traits/tokens/fungibles/regular.rs @@ -62,7 +62,8 @@ pub trait Inspect: Sized { /// The minimum balance any single account may have. fn minimum_balance(asset: Self::AssetId) -> Self::Balance; - /// Get the total amount of funds whose ultimate bneficial ownership can be determined as `who`. + /// Get the total amount of funds whose ultimate beneficial ownership can be determined as + /// `who`. /// /// This may include funds which are wholly inaccessible to `who`, either temporarily or even /// indefinitely. @@ -135,7 +136,7 @@ impl> Dust { /// **WARNING** /// Do not use this directly unless you want trouble, since it allows you to alter account balances /// without keeping the issuance up to date. It has no safeguards against accidentally creating -/// token imbalances in your system leading to accidental imflation or deflation. It's really just +/// token imbalances in your system leading to accidental inflation or deflation. It's really just /// for the underlying datatype to implement so the user gets the much safer `Balanced` trait to /// use. pub trait Unbalanced: Inspect { From c47ac0d3da2bc89d1f73f3d1b0d623cc831b5d6a Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Mon, 8 May 2023 13:10:08 +0200 Subject: [PATCH 006/105] contracts: map token errors --- frame/contracts/src/wasm/code_cache.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frame/contracts/src/wasm/code_cache.rs b/frame/contracts/src/wasm/code_cache.rs index 31ddf26aa10ab..904a445109a87 100644 --- a/frame/contracts/src/wasm/code_cache.rs +++ b/frame/contracts/src/wasm/code_cache.rs @@ -41,7 +41,7 @@ use frame_support::{ traits::{fungible::MutateHold, tokens::Precision::BestEffort, Get}, WeakBoundedVec, }; -use sp_runtime::traits::BadOrigin; +use sp_runtime::{traits::BadOrigin, TokenError}; use sp_std::vec; /// Put the instrumented module in storage. @@ -99,7 +99,13 @@ pub fn store(mut module: PrefabWasmModule, instantiated: bool) -> &T::HoldReason::get(), &new_owner_info.owner, new_owner_info.deposit, - )?; + // )?; + ) + .map_err(|e| match e { + DispatchError::Token(TokenError::FundsUnavailable) => + >::StorageDepositNotEnoughFunds.into(), + _ => e, + })?; new_owner_info.refcount = if instantiated { 1 } else { 0 }; >::insert(&code_hash, orig_code); >::insert(&code_hash, module); From 4e8a7cce660892d1395d2616d34285b5074f1900 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Mon, 8 May 2023 13:10:37 +0200 Subject: [PATCH 007/105] fix typo --- frame/support/src/traits/tokens/fungible/regular.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frame/support/src/traits/tokens/fungible/regular.rs b/frame/support/src/traits/tokens/fungible/regular.rs index 3476549464032..c0658ad71d2b3 100644 --- a/frame/support/src/traits/tokens/fungible/regular.rs +++ b/frame/support/src/traits/tokens/fungible/regular.rs @@ -58,7 +58,8 @@ pub trait Inspect: Sized { /// The minimum balance any single account may have. fn minimum_balance() -> Self::Balance; - /// Get the total amount of funds whose ultimate bneficial ownership can be determined as `who`. + /// Get the total amount of funds whose ultimate beneficial ownership can be determined as + /// `who`. /// /// This may include funds which are wholly inaccessible to `who`, either temporarily or even /// indefinitely. From 33229ffbcf6f240135fb468b7502cdb756b070da Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Mon, 8 May 2023 15:48:01 +0200 Subject: [PATCH 008/105] contracts: add 0 balance transfer to test --- frame/contracts/src/tests.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index edfa909baa31a..8bcc72860b968 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -1308,6 +1308,15 @@ fn self_destruct_works() { pretty_assertions::assert_eq!( System::events(), vec![ + EventRecord { + phase: Phase::Initialization, + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { + from: ALICE, + to: addr.clone(), + amount: 0, + }), + topics: vec![], + }, EventRecord { phase: Phase::Initialization, event: RuntimeEvent::System(frame_system::Event::KilledAccount { From a1fd0207dc785066ca74f941af09abbe6e0d5d2e Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 9 May 2023 16:34:54 +0200 Subject: [PATCH 009/105] contracts: not transfer if value is zero --- frame/contracts/src/exec.rs | 10 ++++++---- frame/contracts/src/lib.rs | 8 ++++---- frame/contracts/src/tests.rs | 9 --------- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 1d49a4af78bf9..72ce51bf4fbca 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -1067,8 +1067,10 @@ where to: &T::AccountId, value: BalanceOf, ) -> DispatchResult { - T::Currency::transfer(from, to, value, preservation) - .map_err(|_| Error::::TransferFailed)?; + if !value.is_zero() { + T::Currency::transfer(from, to, value, preservation) + .map_err(|_| Error::::TransferFailed)?; + } Ok(()) } @@ -1247,11 +1249,11 @@ where let info = frame.terminate(); frame.nested_storage.terminate(&info); System::::dec_consumers(&frame.account_id); - T::Currency::transfer( + Self::transfer( + Preservation::Expendable, &frame.account_id, beneficiary, T::Currency::reducible_balance(&frame.account_id, Preservation::Expendable, Polite), - Preservation::Expendable, )?; info.queue_trie_for_deletion(); ContractInfoOf::::remove(&frame.account_id); diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 70b67f50d0b51..9512017e81cfb 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -25,10 +25,10 @@ //! //! ## Overview //! -//! This module extends accounts based on the [`Currency`] trait to have smart-contract -//! functionality. It can be used with other modules that implement accounts based on [`Currency`]. -//! These "smart-contract accounts" have the ability to instantiate smart-contracts and make calls -//! to other contract and non-contract accounts. +//! This module extends accounts based on the [`fungible`] traits to have smart-contract +//! functionality. It can be used with other modules that implement accounts based on [`fungible`] +//! traits. These "smart-contract accounts" have the ability to instantiate smart-contracts and make +//! calls to other contract and non-contract accounts. //! //! The smart-contract code is stored once in a code cache, and later retrievable via its hash. //! This means that multiple smart-contracts can be instantiated from the same hash, without diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 8bcc72860b968..edfa909baa31a 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -1308,15 +1308,6 @@ fn self_destruct_works() { pretty_assertions::assert_eq!( System::events(), vec![ - EventRecord { - phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { - from: ALICE, - to: addr.clone(), - amount: 0, - }), - topics: vec![], - }, EventRecord { phase: Phase::Initialization, event: RuntimeEvent::System(frame_system::Event::KilledAccount { From 0967556a4cb3e981032c848bc3ef1b0e9f157f37 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 11 May 2023 11:41:25 +0200 Subject: [PATCH 010/105] contracts: [WIP] add StorageDepositHold --- frame/contracts/src/lib.rs | 22 +++++++++++++++++++++- frame/contracts/src/wasm/code_cache.rs | 1 - 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 9512017e81cfb..7c278532287a9 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -203,7 +203,7 @@ pub mod pallet { /// The currency in which fees are paid and contract balances are held. type Currency: Inspect + Mutate - + MutateHold; + + StorageDepositHold; /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; @@ -787,6 +787,12 @@ pub mod pallet { /// The code hash that was delegate called. code_hash: CodeHash, }, + + Held { + who: T::AccountId, + // amount: BalanceOf, + // reason: >::Reason, + }, } #[pallet::error] @@ -1223,6 +1229,20 @@ impl Invokable for InstantiateInput { } } +pub trait StorageDepositHold: MutateHold { + fn done_hold(reason: &Self::Reason, who: &T::AccountId, amount: Self::Balance) { + // let reason = HoldReason::StorageDepositReserve; + >::deposit_event( + vec![ + T::Hashing::hash_of(who), + T::Hashing::hash_of(&amount), + T::Hashing::hash_of(&reason), + ], + Event::Held { who: who.clone() }, + ); + } +} + impl Pallet { /// Perform a call to a specified contract. /// diff --git a/frame/contracts/src/wasm/code_cache.rs b/frame/contracts/src/wasm/code_cache.rs index 904a445109a87..2e42a50432937 100644 --- a/frame/contracts/src/wasm/code_cache.rs +++ b/frame/contracts/src/wasm/code_cache.rs @@ -99,7 +99,6 @@ pub fn store(mut module: PrefabWasmModule, instantiated: bool) -> &T::HoldReason::get(), &new_owner_info.owner, new_owner_info.deposit, - // )?; ) .map_err(|e| match e { DispatchError::Token(TokenError::FundsUnavailable) => From bcb90778752795818db6f7fca1ae91bb0de0fcb8 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 11 May 2023 18:32:23 +0200 Subject: [PATCH 011/105] contracts: add storage deposit held event --- frame/contracts/src/lib.rs | 32 +++++++++++++------------- frame/contracts/src/wasm/code_cache.rs | 11 +++++++++ 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 7c278532287a9..3b0c241e95c32 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -203,7 +203,7 @@ pub mod pallet { /// The currency in which fees are paid and contract balances are held. type Currency: Inspect + Mutate - + StorageDepositHold; + + MutateHold; /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; @@ -788,9 +788,9 @@ pub mod pallet { code_hash: CodeHash, }, - Held { + StorageDepositHeld { who: T::AccountId, - // amount: BalanceOf, + amount: BalanceOf, // reason: >::Reason, }, } @@ -1229,19 +1229,19 @@ impl Invokable for InstantiateInput { } } -pub trait StorageDepositHold: MutateHold { - fn done_hold(reason: &Self::Reason, who: &T::AccountId, amount: Self::Balance) { - // let reason = HoldReason::StorageDepositReserve; - >::deposit_event( - vec![ - T::Hashing::hash_of(who), - T::Hashing::hash_of(&amount), - T::Hashing::hash_of(&reason), - ], - Event::Held { who: who.clone() }, - ); - } -} +// pub trait StorageDepositHold: MutateHold { +// fn done_hold(reason: &Self::Reason, who: &T::AccountId, amount: Self::Balance) { +// // let reason = HoldReason::StorageDepositReserve; +// >::deposit_event( +// vec![ +// T::Hashing::hash_of(who), +// T::Hashing::hash_of(&amount), +// T::Hashing::hash_of(&reason), +// ], +// Event::Held { who: who.clone() }, +// ); +// } +// } impl Pallet { /// Perform a call to a specified contract. diff --git a/frame/contracts/src/wasm/code_cache.rs b/frame/contracts/src/wasm/code_cache.rs index 2e42a50432937..975013fdc1986 100644 --- a/frame/contracts/src/wasm/code_cache.rs +++ b/frame/contracts/src/wasm/code_cache.rs @@ -41,6 +41,7 @@ use frame_support::{ traits::{fungible::MutateHold, tokens::Precision::BestEffort, Get}, WeakBoundedVec, }; +use sp_api::HashT; use sp_runtime::{traits::BadOrigin, TokenError}; use sp_std::vec; @@ -105,6 +106,16 @@ pub fn store(mut module: PrefabWasmModule, instantiated: bool) -> >::StorageDepositNotEnoughFunds.into(), _ => e, })?; + >::deposit_event( + vec![ + T::Hashing::hash_of(&new_owner_info.owner), + T::Hashing::hash_of(&new_owner_info.deposit), + ], + Event::StorageDepositHeld { + who: new_owner_info.owner.clone(), + amount: new_owner_info.deposit.clone(), + }, + ); new_owner_info.refcount = if instantiated { 1 } else { 0 }; >::insert(&code_hash, orig_code); >::insert(&code_hash, module); From 8f244c4aad8f8a4358ea84d55df9fdc5b63b8ed7 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 11 May 2023 18:45:04 +0200 Subject: [PATCH 012/105] contracts: clean up some code and comments --- frame/contracts/src/lib.rs | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 3b0c241e95c32..02b3495ee17aa 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -788,11 +788,8 @@ pub mod pallet { code_hash: CodeHash, }, - StorageDepositHeld { - who: T::AccountId, - amount: BalanceOf, - // reason: >::Reason, - }, + /// Some funds has been held as storage deposit. + StorageDepositHeld { who: T::AccountId, amount: BalanceOf }, } #[pallet::error] @@ -1229,20 +1226,6 @@ impl Invokable for InstantiateInput { } } -// pub trait StorageDepositHold: MutateHold { -// fn done_hold(reason: &Self::Reason, who: &T::AccountId, amount: Self::Balance) { -// // let reason = HoldReason::StorageDepositReserve; -// >::deposit_event( -// vec![ -// T::Hashing::hash_of(who), -// T::Hashing::hash_of(&amount), -// T::Hashing::hash_of(&reason), -// ], -// Event::Held { who: who.clone() }, -// ); -// } -// } - impl Pallet { /// Perform a call to a specified contract. /// From 73b9285b2dfacbbb1aff5426d52f2dda8cfd9a2a Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 11 May 2023 19:04:18 +0200 Subject: [PATCH 013/105] contracts: add deposit storage released event --- frame/contracts/src/lib.rs | 5 ++- frame/contracts/src/tests.rs | 52 ++++++++++++++++---------- frame/contracts/src/wasm/code_cache.rs | 10 +++++ 3 files changed, 46 insertions(+), 21 deletions(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 02b3495ee17aa..500664c3a76bb 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -788,8 +788,11 @@ pub mod pallet { code_hash: CodeHash, }, - /// Some funds has been held as storage deposit. + /// Some funds have been held as storage deposit. StorageDepositHeld { who: T::AccountId, amount: BalanceOf }, + + /// Some funds have been released from storage deposit. + StorageDepositReleased { who: T::AccountId, amount: BalanceOf }, } #[pallet::error] diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index edfa909baa31a..3e61b47c95a30 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -3316,6 +3316,8 @@ fn upload_code_works() { // Drop previous events initialize_block(2); + let deposit_amount = 173; + assert!(!>::contains_key(code_hash)); assert_ok!(Contracts::upload_code( RuntimeOrigin::signed(ALICE), @@ -3330,11 +3332,11 @@ fn upload_code_works() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Contracts(pallet_contracts::Event::StorageDepositHeld { who: ALICE, - amount: 173, + amount: deposit_amount, }), - topics: vec![], + topics: vec![hash(&ALICE), hash(&deposit_amount)], }, EventRecord { phase: Phase::Initialization, @@ -3404,6 +3406,8 @@ fn remove_code_works() { // Drop previous events initialize_block(2); + let deposit_amount = 173; + assert_ok!(Contracts::upload_code( RuntimeOrigin::signed(ALICE), wasm, @@ -3420,11 +3424,11 @@ fn remove_code_works() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Contracts(pallet_contracts::Event::StorageDepositHeld { who: ALICE, - amount: 173, + amount: deposit_amount, }), - topics: vec![], + topics: vec![hash(&ALICE), hash(&deposit_amount)], }, EventRecord { phase: Phase::Initialization, @@ -3433,11 +3437,13 @@ fn remove_code_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Unreserved { - who: ALICE, - amount: 173, - }), - topics: vec![], + event: RuntimeEvent::Contracts( + pallet_contracts::Event::StorageDepositReleased { + who: ALICE, + amount: deposit_amount, + } + ), + topics: vec![hash(&ALICE), hash(&deposit_amount)], }, EventRecord { phase: Phase::Initialization, @@ -3459,6 +3465,8 @@ fn remove_code_wrong_origin() { // Drop previous events initialize_block(2); + let deposit_amount = 173; + assert_ok!(Contracts::upload_code( RuntimeOrigin::signed(ALICE), wasm, @@ -3476,11 +3484,11 @@ fn remove_code_wrong_origin() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Contracts(pallet_contracts::Event::StorageDepositHeld { who: ALICE, - amount: 173, + amount: deposit_amount, }), - topics: vec![], + topics: vec![hash(&ALICE), hash(&deposit_amount)], }, EventRecord { phase: Phase::Initialization, @@ -3550,6 +3558,8 @@ fn instantiate_with_zero_balance_works() { // Drop previous events initialize_block(2); + let deposit_amount = 173; + // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( ALICE, @@ -3627,11 +3637,11 @@ fn instantiate_with_zero_balance_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Contracts(pallet_contracts::Event::StorageDepositHeld { who: ALICE, - amount: 173, + amount: deposit_amount, }), - topics: vec![], + topics: vec![hash(&ALICE), hash(&deposit_amount)], }, EventRecord { phase: Phase::Initialization, @@ -3661,6 +3671,8 @@ fn instantiate_with_below_existential_deposit_works() { // Drop previous events initialize_block(2); + let deposit_amount = 173; + // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( ALICE, @@ -3747,11 +3759,11 @@ fn instantiate_with_below_existential_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Contracts(pallet_contracts::Event::StorageDepositHeld { who: ALICE, - amount: 173, + amount: deposit_amount, }), - topics: vec![], + topics: vec![hash(&ALICE), hash(&deposit_amount)], }, EventRecord { phase: Phase::Initialization, diff --git a/frame/contracts/src/wasm/code_cache.rs b/frame/contracts/src/wasm/code_cache.rs index 975013fdc1986..f831599c83737 100644 --- a/frame/contracts/src/wasm/code_cache.rs +++ b/frame/contracts/src/wasm/code_cache.rs @@ -169,6 +169,16 @@ pub fn try_remove(origin: &T::AccountId, code_hash: CodeHash) -> D owner_info.deposit, BestEffort, )?; + >::deposit_event( + vec![ + T::Hashing::hash_of(&owner_info.owner), + T::Hashing::hash_of(&owner_info.deposit), + ], + Event::StorageDepositReleased { + who: owner_info.owner.clone(), + amount: owner_info.deposit, + }, + ); *existing = None; >::remove(&code_hash); >::remove(&code_hash); From 26472d5fb65d81a1706bf9b86cbd009b22424a03 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 12 May 2023 10:23:07 +0200 Subject: [PATCH 014/105] contracts: update comment --- 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 500664c3a76bb..5b35fcb6a8061 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -791,7 +791,7 @@ pub mod pallet { /// Some funds have been held as storage deposit. StorageDepositHeld { who: T::AccountId, amount: BalanceOf }, - /// Some funds have been released from storage deposit. + /// Some funds have been released as storage deposit. StorageDepositReleased { who: T::AccountId, amount: BalanceOf }, } From c442b7928b738470b170a7aa381cd55841fc615a Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 12 May 2023 16:44:33 +0200 Subject: [PATCH 015/105] contracts: update slash cannot kill account test --- frame/contracts/src/tests.rs | 223 ++++++++++++++++++----------------- 1 file changed, 112 insertions(+), 111 deletions(-) diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 3e61b47c95a30..53f10ee514305 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -38,8 +38,9 @@ use frame_support::{ parameter_types, storage::child, traits::{ - ConstU32, ConstU64, Contains, Currency, ExistenceRequirement, LockableCurrency, OnIdle, - OnInitialize, WithdrawReasons, + fungible::{BalancedHold, Inspect, InspectHold, Mutate, MutateHold}, + tokens::Preservation, + ConstU32, ConstU64, Contains, LockableCurrency, OnIdle, OnInitialize, WithdrawReasons, }, weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight}, }; @@ -92,7 +93,8 @@ pub mod test_utils { use super::{Balances, Hash, SysConfig, Test}; use crate::{exec::AccountIdOf, CodeHash, Config, ContractInfo, ContractInfoOf, Nonce}; use codec::Encode; - use frame_support::traits::Currency; + use frame_support::traits::fungible::{Inspect, Mutate}; + // use frame_support::traits::Currency; pub fn place_contract(address: &AccountIdOf, code_hash: CodeHash) { let nonce = >::mutate(|counter| { @@ -104,7 +106,7 @@ pub mod test_utils { >::insert(address, contract); } pub fn set_balance(who: &AccountIdOf, amount: u64) { - let imbalance = Balances::deposit_creating(who, amount); + let imbalance = Balances::set_balance(who, amount); drop(imbalance); } pub fn get_balance(who: &AccountIdOf) -> u64 { @@ -538,7 +540,7 @@ impl Default for Origin { #[test] fn calling_plain_account_fails() { ExtBuilder::default().build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 100_000_000); + let _ = Balances::set_balance(&ALICE, 100_000_000); let base_cost = <::WeightInfo as WeightInfo>::call(); assert_eq!( @@ -559,7 +561,7 @@ fn instantiate_and_call_and_deposit_event() { let (wasm, code_hash) = compile_module::("event_and_return_on_deploy").unwrap(); ExtBuilder::default().existential_deposit(1).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); let min_balance = ::Currency::minimum_balance(); let value = 100; @@ -682,7 +684,7 @@ fn deposit_event_max_value_limit() { ExtBuilder::default().existential_deposit(50).build().execute_with(|| { // Create - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, 30_000, @@ -728,7 +730,7 @@ fn run_out_of_gas() { let (wasm, _code_hash) = compile_module::("run_out_of_gas").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { let min_balance = ::Currency::minimum_balance(); - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, @@ -768,7 +770,7 @@ fn instantiate_unique_trie_id() { let (wasm, code_hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(500).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); Contracts::upload_code(RuntimeOrigin::signed(ALICE), wasm, None, Determinism::Enforced) .unwrap(); @@ -835,7 +837,7 @@ fn storage_max_value_limit() { ExtBuilder::default().existential_deposit(50).build().execute_with(|| { // Create - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, 30_000, @@ -886,7 +888,7 @@ fn deploy_and_call_other_contract() { let min_balance = ::Currency::minimum_balance(); // Create - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); let caller_addr = Contracts::bare_instantiate( ALICE, 100_000, @@ -1034,7 +1036,7 @@ fn delegate_call() { let (callee_wasm, callee_code_hash) = compile_module::("delegate_call_lib").unwrap(); ExtBuilder::default().existential_deposit(500).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); // Instantiate the 'caller' let caller_addr = Contracts::bare_instantiate( @@ -1074,7 +1076,7 @@ fn delegate_call() { fn transfer_allow_death_cannot_kill_account() { let (wasm, _code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -1098,11 +1100,11 @@ fn transfer_allow_death_cannot_kill_account() { let total_balance = ::Currency::total_balance(&addr); assert_err!( - <::Currency as Currency>::transfer( + <::Currency as Mutate>::transfer( &addr, &ALICE, total_balance, - ExistenceRequirement::AllowDeath, + Preservation::Expendable, ), TokenError::Frozen, ); @@ -1115,7 +1117,7 @@ fn transfer_allow_death_cannot_kill_account() { fn cannot_self_destruct_through_draning() { let (wasm, _code_hash) = compile_module::("drain").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -1159,7 +1161,7 @@ fn cannot_self_destruct_through_draning() { fn cannot_self_destruct_through_storage_refund_after_price_change() { let (wasm, _code_hash) = compile_module::("store_call").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); let min_balance = ::Currency::minimum_balance(); // Instantiate the BOB contract. @@ -1219,7 +1221,7 @@ fn cannot_self_destruct_through_storage_refund_after_price_change() { fn cannot_self_destruct_while_live() { let (wasm, _code_hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -1263,8 +1265,8 @@ fn cannot_self_destruct_while_live() { fn self_destruct_works() { let (wasm, code_hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(1_000).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); - let _ = Balances::deposit_creating(&DJANGO, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = Balances::set_balance(&DJANGO, 1_000_000); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -1370,7 +1372,7 @@ fn destroy_contract_and_transfer_funds() { ExtBuilder::default().existential_deposit(50).build().execute_with(|| { // Create code hash for bob to instantiate - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); Contracts::bare_upload_code(ALICE, callee_wasm, None, Determinism::Enforced).unwrap(); // This deploys the BOB contract, which in turn deploys the CHARLIE contract during @@ -1414,7 +1416,7 @@ fn destroy_contract_and_transfer_funds() { fn cannot_self_destruct_in_constructor() { let (wasm, _) = compile_module::("self_destructing_constructor").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); // Fail to instantiate the BOB because the contructor calls seal_terminate. assert_err_ignore_postinfo!( @@ -1437,7 +1439,7 @@ fn crypto_hashes() { let (wasm, _code_hash) = compile_module::("crypto_hashes").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); // Instantiate the CRYPTO_HASHES contract. let addr = Contracts::bare_instantiate( @@ -1500,7 +1502,7 @@ fn transfer_return_code() { let (wasm, _code_hash) = compile_module::("transfer_return_code").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { let min_balance = ::Currency::minimum_balance(); - let _ = Balances::deposit_creating(&ALICE, 1000 * min_balance); + let _ = Balances::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, @@ -1518,7 +1520,7 @@ fn transfer_return_code() { .account_id; // Contract has only the minimal balance so any transfer will fail. - Balances::make_free_balance_be(&addr, min_balance); + Balances::set_balance(&addr, min_balance); let result = Contracts::bare_call( ALICE, addr.clone(), @@ -1542,8 +1544,8 @@ fn call_return_code() { let (callee_code, _callee_hash) = compile_module::("ok_trap_revert").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { let min_balance = ::Currency::minimum_balance(); - let _ = Balances::deposit_creating(&ALICE, 1000 * min_balance); - let _ = Balances::deposit_creating(&CHARLIE, 1000 * min_balance); + let _ = Balances::set_balance(&ALICE, 1000 * min_balance); + let _ = Balances::set_balance(&CHARLIE, 1000 * min_balance); let addr_bob = Contracts::bare_instantiate( ALICE, @@ -1559,7 +1561,7 @@ fn call_return_code() { .result .unwrap() .account_id; - Balances::make_free_balance_be(&addr_bob, min_balance); + Balances::set_balance(&addr_bob, min_balance); // Contract calls into Django which is no valid contract let result = Contracts::bare_call( @@ -1591,7 +1593,7 @@ fn call_return_code() { .result .unwrap() .account_id; - Balances::make_free_balance_be(&addr_django, min_balance); + Balances::set_balance(&addr_django, min_balance); // Contract has only the minimal balance so any transfer will fail. let result = Contracts::bare_call( @@ -1614,7 +1616,7 @@ fn call_return_code() { assert_return_code!(result, RuntimeReturnCode::TransferFailed); // Contract has enough balance but callee reverts because "1" is passed. - Balances::make_free_balance_be(&addr_bob, min_balance + 1000); + Balances::set_balance(&addr_bob, min_balance + 1000); let result = Contracts::bare_call( ALICE, addr_bob.clone(), @@ -1662,8 +1664,8 @@ fn instantiate_return_code() { let (callee_code, callee_hash) = compile_module::("ok_trap_revert").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { let min_balance = ::Currency::minimum_balance(); - let _ = Balances::deposit_creating(&ALICE, 1000 * min_balance); - let _ = Balances::deposit_creating(&CHARLIE, 1000 * min_balance); + let _ = Balances::set_balance(&ALICE, 1000 * min_balance); + let _ = Balances::set_balance(&CHARLIE, 1000 * min_balance); let callee_hash = callee_hash.as_ref().to_vec(); assert_ok!(Contracts::instantiate_with_code( @@ -1692,7 +1694,7 @@ fn instantiate_return_code() { .account_id; // Contract has only the minimal balance so any transfer will fail. - Balances::make_free_balance_be(&addr, min_balance); + Balances::set_balance(&addr, min_balance); let result = Contracts::bare_call( ALICE, addr.clone(), @@ -1709,7 +1711,7 @@ fn instantiate_return_code() { assert_return_code!(result, RuntimeReturnCode::TransferFailed); // Contract has enough balance but the passed code hash is invalid - Balances::make_free_balance_be(&addr, min_balance + 10_000); + Balances::set_balance(&addr, min_balance + 10_000); let result = Contracts::bare_call( ALICE, addr.clone(), @@ -1764,7 +1766,7 @@ fn disabled_chain_extension_wont_deploy() { let (code, _hash) = compile_module::("chain_extension").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { let min_balance = ::Currency::minimum_balance(); - let _ = Balances::deposit_creating(&ALICE, 1000 * min_balance); + let _ = Balances::set_balance(&ALICE, 1000 * min_balance); TestExtension::disable(); assert_err_ignore_postinfo!( Contracts::instantiate_with_code( @@ -1786,7 +1788,7 @@ fn disabled_chain_extension_errors_on_call() { let (code, _hash) = compile_module::("chain_extension").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { let min_balance = ::Currency::minimum_balance(); - let _ = Balances::deposit_creating(&ALICE, 1000 * min_balance); + let _ = Balances::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, min_balance * 100, @@ -1814,7 +1816,7 @@ fn chain_extension_works() { let (code, _hash) = compile_module::("chain_extension").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { let min_balance = ::Currency::minimum_balance(); - let _ = Balances::deposit_creating(&ALICE, 1000 * min_balance); + let _ = Balances::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, min_balance * 100, @@ -1961,7 +1963,7 @@ fn chain_extension_temp_storage_works() { let (code, _hash) = compile_module::("chain_extension_temp_storage").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { let min_balance = ::Currency::minimum_balance(); - let _ = Balances::deposit_creating(&ALICE, 1000 * min_balance); + let _ = Balances::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, min_balance * 100, @@ -2008,7 +2010,7 @@ fn lazy_removal_works() { 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 _ = Balances::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, @@ -2060,7 +2062,7 @@ fn lazy_batch_removal_works() { 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 _ = Balances::set_balance(&ALICE, 1000 * min_balance); let mut tries: Vec = vec![]; for i in 0..3u8 { @@ -2128,7 +2130,7 @@ fn lazy_removal_partial_remove_works() { let trie = ext.execute_with(|| { let min_balance = ::Currency::minimum_balance(); - let _ = Balances::deposit_creating(&ALICE, 1000 * min_balance); + let _ = Balances::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, @@ -2210,7 +2212,7 @@ fn lazy_removal_does_no_run_on_low_remaining_weight() { 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 _ = Balances::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, @@ -2282,7 +2284,7 @@ fn lazy_removal_does_not_use_all_weight() { let (trie, vals, weight_per_key) = ext.execute_with(|| { let min_balance = ::Currency::minimum_balance(); - let _ = Balances::deposit_creating(&ALICE, 1000 * min_balance); + let _ = Balances::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, @@ -2370,7 +2372,7 @@ fn deletion_queue_ring_buffer_overflow() { ext.execute_with(|| { let min_balance = ::Currency::minimum_balance(); - let _ = Balances::deposit_creating(&ALICE, 1000 * min_balance); + let _ = Balances::set_balance(&ALICE, 1000 * min_balance); let mut tries: Vec = vec![]; // add 3 contracts to the deletion queue @@ -2429,7 +2431,7 @@ fn deletion_queue_ring_buffer_overflow() { fn refcounter() { let (wasm, code_hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); let min_balance = ::Currency::minimum_balance(); // Create two contracts with the same code and check that they do in fact share it. @@ -2526,7 +2528,7 @@ fn refcounter() { fn reinstrument_does_charge() { let (wasm, code_hash) = compile_module::("return_with_data").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); let min_balance = ::Currency::minimum_balance(); let zero = 0u32.to_le_bytes().encode(); let code_len = wasm.len() as u32; @@ -2610,7 +2612,7 @@ fn debug_message_works() { let (wasm, _code_hash) = compile_module::("debug_message_works").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, 30_000, @@ -2647,7 +2649,7 @@ fn debug_message_logging_disabled() { let (wasm, _code_hash) = compile_module::("debug_message_logging_disabled").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, 30_000, @@ -2686,7 +2688,7 @@ fn debug_message_invalid_utf8() { let (wasm, _code_hash) = compile_module::("debug_message_invalid_utf8").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, 30_000, @@ -2723,7 +2725,7 @@ fn gas_estimation_nested_call_fixed_limit() { let (callee_code, _callee_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { let min_balance = ::Currency::minimum_balance(); - let _ = Balances::deposit_creating(&ALICE, 1000 * min_balance); + let _ = Balances::set_balance(&ALICE, 1000 * min_balance); let addr_caller = Contracts::bare_instantiate( ALICE, @@ -2819,8 +2821,8 @@ fn gas_estimation_call_runtime() { let (callee_code, _callee_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { let min_balance = ::Currency::minimum_balance(); - let _ = Balances::deposit_creating(&ALICE, 1000 * min_balance); - let _ = Balances::deposit_creating(&CHARLIE, 1000 * min_balance); + let _ = Balances::set_balance(&ALICE, 1000 * min_balance); + let _ = Balances::set_balance(&CHARLIE, 1000 * min_balance); let addr_caller = Contracts::bare_instantiate( ALICE, @@ -2898,8 +2900,8 @@ fn call_runtime_reentrancy_guarded() { let (callee_code, _callee_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { let min_balance = ::Currency::minimum_balance(); - let _ = Balances::deposit_creating(&ALICE, 1000 * min_balance); - let _ = Balances::deposit_creating(&CHARLIE, 1000 * min_balance); + let _ = Balances::set_balance(&ALICE, 1000 * min_balance); + let _ = Balances::set_balance(&CHARLIE, 1000 * min_balance); let addr_caller = Contracts::bare_instantiate( ALICE, @@ -2965,7 +2967,7 @@ fn ecdsa_recover() { 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); + let _ = Balances::set_balance(&ALICE, 1_000_000); // Instantiate the ecdsa_recover contract. let addr = Contracts::bare_instantiate( @@ -3029,7 +3031,7 @@ fn bare_instantiate_returns_events() { let (wasm, _code_hash) = compile_module::("transfer_return_code").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { let min_balance = ::Currency::minimum_balance(); - let _ = Balances::deposit_creating(&ALICE, 1000 * min_balance); + let _ = Balances::set_balance(&ALICE, 1000 * min_balance); let result = Contracts::bare_instantiate( ALICE, @@ -3054,7 +3056,7 @@ fn bare_instantiate_does_not_return_events() { let (wasm, _code_hash) = compile_module::("transfer_return_code").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { let min_balance = ::Currency::minimum_balance(); - let _ = Balances::deposit_creating(&ALICE, 1000 * min_balance); + let _ = Balances::set_balance(&ALICE, 1000 * min_balance); let result = Contracts::bare_instantiate( ALICE, @@ -3079,7 +3081,7 @@ fn bare_call_returns_events() { let (wasm, _code_hash) = compile_module::("transfer_return_code").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { let min_balance = ::Currency::minimum_balance(); - let _ = Balances::deposit_creating(&ALICE, 1000 * min_balance); + let _ = Balances::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, @@ -3120,7 +3122,7 @@ fn bare_call_does_not_return_events() { let (wasm, _code_hash) = compile_module::("transfer_return_code").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { let min_balance = ::Currency::minimum_balance(); - let _ = Balances::deposit_creating(&ALICE, 1000 * min_balance); + let _ = Balances::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, @@ -3161,7 +3163,7 @@ fn sr25519_verify() { let (wasm, _code_hash) = compile_module::("sr25519_verify").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); // Instantiate the sr25519_verify contract. let addr = Contracts::bare_instantiate( @@ -3232,7 +3234,7 @@ fn failed_deposit_charge_should_roll_back_call() { let execute = || { ExtBuilder::default().existential_deposit(ED).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); // Instantiate both contracts. let addr_caller = Contracts::bare_instantiate( @@ -3311,7 +3313,7 @@ fn upload_code_works() { let (wasm, code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); // Drop previous events initialize_block(2); @@ -3353,7 +3355,7 @@ fn upload_code_limit_too_low() { let (wasm, _code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); // Drop previous events initialize_block(2); @@ -3377,7 +3379,7 @@ fn upload_code_not_enough_balance() { let (wasm, _code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 150); + let _ = Balances::set_balance(&ALICE, 150); // Drop previous events initialize_block(2); @@ -3401,7 +3403,7 @@ fn remove_code_works() { let (wasm, code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); // Drop previous events initialize_block(2); @@ -3460,7 +3462,7 @@ fn remove_code_wrong_origin() { let (wasm, code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); // Drop previous events initialize_block(2); @@ -3505,7 +3507,7 @@ fn remove_code_in_use() { let (wasm, code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); assert_ok!(Contracts::instantiate_with_code( RuntimeOrigin::signed(ALICE), @@ -3534,7 +3536,7 @@ fn remove_code_not_found() { let (_wasm, code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); // Drop previous events initialize_block(2); @@ -3552,7 +3554,7 @@ fn remove_code_not_found() { fn instantiate_with_zero_balance_works() { let (wasm, code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); let min_balance = ::Currency::minimum_balance(); // Drop previous events @@ -3665,7 +3667,7 @@ fn instantiate_with_zero_balance_works() { fn instantiate_with_below_existential_deposit_works() { let (wasm, code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); let min_balance = ::Currency::minimum_balance(); // Drop previous events @@ -3787,7 +3789,7 @@ fn instantiate_with_below_existential_deposit_works() { fn storage_deposit_works() { let (wasm, _code_hash) = compile_module::("multi_store").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); let mut deposit = ::Currency::minimum_balance(); let addr = Contracts::bare_instantiate( @@ -3926,7 +3928,7 @@ fn storage_deposit_callee_works() { let (wasm_callee, _code_hash_callee) = compile_module::("store_call").unwrap(); const ED: u64 = 200; ExtBuilder::default().existential_deposit(ED).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); // Create both contracts: Constructors do nothing. let addr_caller = Contracts::bare_instantiate( @@ -3983,7 +3985,7 @@ fn set_code_extrinsic() { assert_ne!(code_hash, new_code_hash); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, @@ -4067,12 +4069,15 @@ fn set_code_extrinsic() { #[test] fn slash_cannot_kill_account() { let (wasm, _code_hash) = compile_module::("dummy").unwrap(); - ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let ed = 200; + ExtBuilder::default().existential_deposit(ed).build().execute_with(|| { + let value = 700; + let balance_held = 500; + let _ = Balances::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, - 700, + value, GAS_LIMIT, None, Code::Upload(wasm), @@ -4088,25 +4093,21 @@ fn slash_cannot_kill_account() { // Drop previous events initialize_block(2); - // Try to destroy the account of the contract by slashing. + let _ = Balances::hold(&HoldIdentifier::StorageDepositReserve, &addr, balance_held); + + assert_eq!(Balances::total_balance_on_hold(&addr), balance_held); + + // Try to destroy the account of the contract by slashing the total balance. // The account does not get destroyed because of the consumer reference. // Slashing can for example happen if the contract takes part in staking. - let _ = ::Currency::slash( + let _ = Balances::slash( + &HoldIdentifier::StorageDepositReserve, &addr, - ::Currency::total_balance(&addr), + Balances::total_balance(&addr), ); - assert_eq!( - System::events(), - vec![EventRecord { - phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Slashed { - who: addr.clone(), - amount: 700, // slash didn't remove the minimum balance - }), - topics: vec![], - },] - ); + // Slash only removed the balance held. + assert_eq!(Balances::total_balance(&addr), value + ed - balance_held,); }); } @@ -4115,7 +4116,7 @@ fn contract_reverted() { let (wasm, code_hash) = compile_module::("return_with_data").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); let flags = ReturnFlags::REVERT; let buffer = [4u8, 8, 15, 16, 23, 42]; let input = (flags.bits(), buffer).encode(); @@ -4228,7 +4229,7 @@ fn contract_reverted() { #[test] fn code_rejected_error_works() { ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); let (wasm, _) = compile_module::("invalid_module").unwrap(); assert_noop!( @@ -4293,7 +4294,7 @@ fn set_code_hash() { let (new_wasm, new_code_hash) = compile_module::("new_set_code_hash_contract").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); // Instantiate the 'caller' let contract_addr = Contracts::bare_instantiate( @@ -4396,7 +4397,7 @@ fn set_code_hash() { fn storage_deposit_limit_is_enforced() { let (wasm, _code_hash) = compile_module::("store_call").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); let min_balance = ::Currency::minimum_balance(); // Instantiate the BOB contract. @@ -4472,7 +4473,7 @@ fn deposit_limit_in_nested_calls() { compile_module::("create_storage_and_call").unwrap(); let (wasm_callee, _code_hash_callee) = compile_module::("store_call").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); // Create both contracts: Constructors do nothing. let addr_caller = Contracts::bare_instantiate( @@ -4581,7 +4582,7 @@ fn deposit_limit_in_nested_calls() { >::StorageDepositLimitExhausted, ); - let _ = Balances::make_free_balance_be(&ALICE, 1_000); + let _ = Balances::set_balance(&ALICE, 1_000); // Require more than the sender's balance. // We don't set a special limit for the nested call. @@ -4618,8 +4619,8 @@ fn deposit_limit_in_nested_instantiate() { let (wasm_callee, code_hash_callee) = compile_module::("store_deploy").unwrap(); const ED: u64 = 5; ExtBuilder::default().existential_deposit(ED).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); - let _ = Balances::deposit_creating(&BOB, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = Balances::set_balance(&BOB, 1_000_000); // Create caller contract let addr_caller = Contracts::bare_instantiate( ALICE, @@ -4769,8 +4770,8 @@ fn deposit_limit_in_nested_instantiate() { fn deposit_limit_honors_liquidity_restrictions() { let (wasm, _code_hash) = compile_module::("store_call").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); - let _ = Balances::deposit_creating(&BOB, 1_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = Balances::set_balance(&BOB, 1_000); let min_balance = ::Currency::minimum_balance(); // Instantiate the BOB contract. @@ -4814,8 +4815,8 @@ fn deposit_limit_honors_liquidity_restrictions() { fn deposit_limit_honors_existential_deposit() { let (wasm, _code_hash) = compile_module::("store_call").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); - let _ = Balances::deposit_creating(&BOB, 1_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = Balances::set_balance(&BOB, 1_000); let min_balance = ::Currency::minimum_balance(); // Instantiate the BOB contract. @@ -4858,8 +4859,8 @@ fn deposit_limit_honors_existential_deposit() { fn deposit_limit_honors_min_leftover() { let (wasm, _code_hash) = compile_module::("store_call").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); - let _ = Balances::deposit_creating(&BOB, 1_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = Balances::set_balance(&BOB, 1_000); let min_balance = ::Currency::minimum_balance(); // Instantiate the BOB contract. @@ -4903,7 +4904,7 @@ fn cannot_instantiate_indeterministic_code() { let (wasm, code_hash) = compile_module::("float_instruction").unwrap(); let (caller_wasm, _) = compile_module::("instantiate_return_code").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); // Try to instantiate directly from code assert_err_ignore_postinfo!( @@ -5037,7 +5038,7 @@ fn cannot_set_code_indeterministic_code() { let (wasm, code_hash) = compile_module::("float_instruction").unwrap(); let (caller_wasm, _) = compile_module::("set_code_hash").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); // Put the non deterministic contract on-chain assert_ok!(Contracts::upload_code( @@ -5087,7 +5088,7 @@ fn delegate_call_indeterministic_code() { let (wasm, code_hash) = compile_module::("float_instruction").unwrap(); let (caller_wasm, _) = compile_module::("delegate_call_simple").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); // Put the non deterministic contract on-chain assert_ok!(Contracts::upload_code( @@ -5153,7 +5154,7 @@ fn reentrance_count_works_with_call() { let (wasm, _code_hash) = compile_module::("reentrance_count_call").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); let contract_addr = Contracts::bare_instantiate( ALICE, @@ -5194,7 +5195,7 @@ fn reentrance_count_works_with_delegated_call() { let (wasm, code_hash) = compile_module::("reentrance_count_delegated_call").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); let contract_addr = Contracts::bare_instantiate( ALICE, @@ -5237,7 +5238,7 @@ fn account_reentrance_count_works() { compile_module::("reentrance_count_call").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); let contract_addr = Contracts::bare_instantiate( ALICE, @@ -5353,7 +5354,7 @@ fn root_can_call() { let (wasm, _) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, From 3c515ab665941d653abe7c9aa6e779362c98ba48 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 12 May 2023 18:17:48 +0200 Subject: [PATCH 016/105] contracts: fix tests --- frame/contracts/src/tests.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 53f10ee514305..8a285cd381449 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -38,9 +38,9 @@ use frame_support::{ parameter_types, storage::child, traits::{ - fungible::{BalancedHold, Inspect, InspectHold, Mutate, MutateHold}, + fungible::{BalancedHold, Inspect, InspectHold, Mutate, MutateFreeze, MutateHold}, tokens::Preservation, - ConstU32, ConstU64, Contains, LockableCurrency, OnIdle, OnInitialize, WithdrawReasons, + ConstU32, ConstU64, Contains, OnIdle, OnInitialize, }, weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight}, }; @@ -94,7 +94,6 @@ pub mod test_utils { use crate::{exec::AccountIdOf, CodeHash, Config, ContractInfo, ContractInfoOf, Nonce}; use codec::Encode; use frame_support::traits::fungible::{Inspect, Mutate}; - // use frame_support::traits::Currency; pub fn place_contract(address: &AccountIdOf, code_hash: CodeHash) { let nonce = >::mutate(|counter| { @@ -4069,8 +4068,8 @@ fn set_code_extrinsic() { #[test] fn slash_cannot_kill_account() { let (wasm, _code_hash) = compile_module::("dummy").unwrap(); - let ed = 200; - ExtBuilder::default().existential_deposit(ed).build().execute_with(|| { + const ED: u64 = 200; + ExtBuilder::default().existential_deposit(ED).build().execute_with(|| { let value = 700; let balance_held = 500; let _ = Balances::set_balance(&ALICE, 1_000_000); @@ -4093,7 +4092,7 @@ fn slash_cannot_kill_account() { // Drop previous events initialize_block(2); - let _ = Balances::hold(&HoldIdentifier::StorageDepositReserve, &addr, balance_held); + Balances::hold(&HoldIdentifier::StorageDepositReserve, &addr, balance_held).unwrap(); assert_eq!(Balances::total_balance_on_hold(&addr), balance_held); @@ -4107,7 +4106,7 @@ fn slash_cannot_kill_account() { ); // Slash only removed the balance held. - assert_eq!(Balances::total_balance(&addr), value + ed - balance_held,); + assert_eq!(Balances::total_balance(&addr), value + ED - balance_held,); }); } @@ -4769,9 +4768,11 @@ fn deposit_limit_in_nested_instantiate() { #[test] fn deposit_limit_honors_liquidity_restrictions() { let (wasm, _code_hash) = compile_module::("store_call").unwrap(); - ExtBuilder::default().existential_deposit(200).build().execute_with(|| { + const ED: u64 = 200; + ExtBuilder::default().existential_deposit(ED).build().execute_with(|| { + let bobs_balance = 1_000; let _ = Balances::set_balance(&ALICE, 1_000_000); - let _ = Balances::set_balance(&BOB, 1_000); + let _ = Balances::set_balance(&BOB, bobs_balance); let min_balance = ::Currency::minimum_balance(); // Instantiate the BOB contract. @@ -4794,8 +4795,8 @@ fn deposit_limit_honors_liquidity_restrictions() { assert_eq!(get_contract(&addr).total_deposit(), min_balance); assert_eq!(::Currency::total_balance(&addr), min_balance); - // check that the lock ins honored - Balances::set_lock([0; 8], &BOB, 1_000, WithdrawReasons::TRANSFER); + // check that the hold is honored + Balances::hold(&HoldIdentifier::StorageDepositReserve, &BOB, bobs_balance - ED).unwrap(); assert_err_ignore_postinfo!( Contracts::call( RuntimeOrigin::signed(BOB), @@ -4807,7 +4808,7 @@ fn deposit_limit_honors_liquidity_restrictions() { ), >::StorageDepositNotEnoughFunds, ); - assert_eq!(Balances::free_balance(&BOB), 1_000); + assert_eq!(Balances::free_balance(&BOB), ED); }); } From 4d68a48531f340bfedae874cc6ff41d58875e22c Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 12 May 2023 18:25:43 +0200 Subject: [PATCH 017/105] contracts: add some comments to the slashing test --- frame/contracts/src/tests.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 8a285cd381449..9bd53b22bdbac 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -4092,6 +4092,8 @@ fn slash_cannot_kill_account() { // Drop previous events initialize_block(2); + // We need to hold some balances in order to have something to slash. As slashing can only + // affect balances held under certain HoldIdentifier. Balances::hold(&HoldIdentifier::StorageDepositReserve, &addr, balance_held).unwrap(); assert_eq!(Balances::total_balance_on_hold(&addr), balance_held); From 78fc19e250772549cb03b4339f5cd2279edb2eab Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 12 May 2023 18:27:04 +0200 Subject: [PATCH 018/105] contracts: add some comments to the slashing test --- frame/contracts/src/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 9bd53b22bdbac..04951fdcc75fd 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -4107,7 +4107,7 @@ fn slash_cannot_kill_account() { Balances::total_balance(&addr), ); - // Slash only removed the balance held. + // Slashing only removed the balance held. assert_eq!(Balances::total_balance(&addr), value + ED - balance_held,); }); } From 2c1e2ea442da42d26225a7bac2f9ab3add06c358 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Mon, 15 May 2023 16:15:04 +0200 Subject: [PATCH 019/105] contracts: remove references to Currency --- frame/contracts/README.md | 4 +- frame/contracts/src/benchmarking/mod.rs | 58 ++-- frame/contracts/src/exec.rs | 48 ++-- frame/contracts/src/lib.rs | 12 +- frame/contracts/src/storage/meter.rs | 14 +- frame/contracts/src/tests.rs | 334 ++++++++++++------------ frame/contracts/src/wasm/code_cache.rs | 4 +- 7 files changed, 242 insertions(+), 232 deletions(-) diff --git a/frame/contracts/README.md b/frame/contracts/README.md index 13c5e7253c1d8..56a2c90902738 100644 --- a/frame/contracts/README.md +++ b/frame/contracts/README.md @@ -9,8 +9,8 @@ The Contracts module provides functionality for the runtime to deploy and execut ## Overview -This module extends accounts based on the `Currency` trait to have smart-contract functionality. It can -be used with other modules that implement accounts based on `Currency`. These "smart-contract accounts" +This module extends accounts based on the `fungible` traits to have smart-contract functionality. It can +be used with other modules that implement accounts based on `fungible`. These "smart-contract accounts" have the ability to instantiate smart-contracts and make calls to other contract and non-contract accounts. The smart-contract code is stored once in a `code_cache`, and later retrievable via its `code_hash`. diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index fa9417a59042d..26e89d1868d3d 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -91,7 +91,7 @@ where data: Vec, ) -> Result, &'static str> { let value = Pallet::::min_balance(); - T::Currency::make_free_balance_be(&caller, caller_funding::()); + T::Fungible::make_free_balance_be(&caller, caller_funding::()); let salt = vec![0xff]; let addr = Contracts::::contract_address(&caller, &module.hash, &data, &salt); @@ -157,7 +157,7 @@ where /// Set the balance of the contract to the supplied amount. fn set_balance(&self, balance: BalanceOf) { - T::Currency::make_free_balance_be(&self.account_id, balance); + T::Fungible::make_free_balance_be(&self.account_id, balance); } /// Returns `true` iff all storage entries related to code storage exist. @@ -274,22 +274,22 @@ benchmarks! { let salt = vec![42u8; s as usize]; let value = Pallet::::min_balance(); let caller = whitelisted_caller(); - T::Currency::make_free_balance_be(&caller, caller_funding::()); + T::Fungible::make_free_balance_be(&caller, caller_funding::()); let WasmModule { code, hash, .. } = WasmModule::::sized(c, Location::Call); let origin = RawOrigin::Signed(caller.clone()); let addr = Contracts::::contract_address(&caller, &hash, &input, &salt); }: _(origin, value, Weight::MAX, None, code, input, salt) verify { let deposit_account = Contract::::address_info(&addr)?.deposit_account().clone(); - let deposit = T::Currency::free_balance(&deposit_account); + let deposit = T::Fungible::free_balance(&deposit_account); // uploading the code reserves some balance in the callers account - let code_deposit = T::Currency::reserved_balance(&caller); + let code_deposit = T::Fungible::reserved_balance(&caller); assert_eq!( - T::Currency::free_balance(&caller), + T::Fungible::free_balance(&caller), caller_funding::() - value - deposit - code_deposit - Pallet::::min_balance(), ); // contract has the full value - assert_eq!(T::Currency::free_balance(&addr), value + Pallet::::min_balance()); + assert_eq!(T::Fungible::free_balance(&addr), value + Pallet::::min_balance()); } // Instantiate uses a dummy contract constructor to measure the overhead of the instantiate. @@ -303,7 +303,7 @@ benchmarks! { let salt = vec![42u8; s as usize]; let value = Pallet::::min_balance(); let caller = whitelisted_caller(); - T::Currency::make_free_balance_be(&caller, caller_funding::()); + T::Fungible::make_free_balance_be(&caller, caller_funding::()); let WasmModule { code, hash, .. } = WasmModule::::dummy(); let origin = RawOrigin::Signed(caller.clone()); let addr = Contracts::::contract_address(&caller, &hash, &input, &salt); @@ -311,14 +311,14 @@ benchmarks! { }: _(origin, value, Weight::MAX, None, hash, input, salt) verify { let deposit_account = Contract::::address_info(&addr)?.deposit_account().clone(); - let deposit = T::Currency::free_balance(&deposit_account); + let deposit = T::Fungible::free_balance(&deposit_account); // value was removed from the caller assert_eq!( - T::Currency::free_balance(&caller), + T::Fungible::free_balance(&caller), caller_funding::() - value - deposit - Pallet::::min_balance(), ); // contract has the full value - assert_eq!(T::Currency::free_balance(&addr), value + Pallet::::min_balance()); + assert_eq!(T::Fungible::free_balance(&addr), value + Pallet::::min_balance()); } // We just call a dummy contract to measure the overhead of the call extrinsic. @@ -338,18 +338,18 @@ benchmarks! { let value = Pallet::::min_balance(); let origin = RawOrigin::Signed(instance.caller.clone()); let callee = instance.addr.clone(); - let before = T::Currency::free_balance(&instance.account_id); - let before_deposit = T::Currency::free_balance(&deposit_account); + let before = T::Fungible::free_balance(&instance.account_id); + let before_deposit = T::Fungible::free_balance(&deposit_account); }: _(origin, callee, value, Weight::MAX, None, data) verify { - let deposit = T::Currency::free_balance(&deposit_account); + let deposit = T::Fungible::free_balance(&deposit_account); // value and value transferred via call should be removed from the caller assert_eq!( - T::Currency::free_balance(&instance.caller), + T::Fungible::free_balance(&instance.caller), caller_funding::() - instance.value - value - deposit - Pallet::::min_balance(), ); // contract should have received the value - assert_eq!(T::Currency::free_balance(&instance.account_id), before + value); + assert_eq!(T::Fungible::free_balance(&instance.account_id), before + value); // contract should still exist instance.info()?; } @@ -366,13 +366,13 @@ benchmarks! { upload_code { let c in 0 .. Perbill::from_percent(49).mul_ceil(T::MaxCodeLen::get()); let caller = whitelisted_caller(); - T::Currency::make_free_balance_be(&caller, caller_funding::()); + T::Fungible::make_free_balance_be(&caller, caller_funding::()); let WasmModule { code, hash, .. } = WasmModule::::sized(c, Location::Call); let origin = RawOrigin::Signed(caller.clone()); }: _(origin, code, None, Determinism::Enforced) verify { // uploading the code reserves some balance in the callers account - assert!(T::Currency::reserved_balance(&caller) > 0u32.into()); + assert!(T::Fungible::reserved_balance(&caller) > 0u32.into()); assert!(>::code_exists(&hash)); } @@ -382,17 +382,17 @@ benchmarks! { #[pov_mode = Measured] remove_code { let caller = whitelisted_caller(); - T::Currency::make_free_balance_be(&caller, caller_funding::()); + T::Fungible::make_free_balance_be(&caller, caller_funding::()); let WasmModule { code, hash, .. } = WasmModule::::dummy(); let origin = RawOrigin::Signed(caller.clone()); let uploaded = >::bare_upload_code(caller.clone(), code, None, Determinism::Enforced)?; assert_eq!(uploaded.code_hash, hash); - assert_eq!(uploaded.deposit, T::Currency::reserved_balance(&caller)); + assert_eq!(uploaded.deposit, T::Fungible::reserved_balance(&caller)); assert!(>::code_exists(&hash)); }: _(origin, hash) verify { // removing the code should have unreserved the deposit - assert_eq!(T::Currency::reserved_balance(&caller), 0u32.into()); + assert_eq!(T::Fungible::reserved_balance(&caller), 0u32.into()); assert!(>::code_removed(&hash)); } @@ -809,15 +809,15 @@ benchmarks! { let instance = Contract::::new(code, vec![])?; let origin = RawOrigin::Signed(instance.caller.clone()); let deposit_account = instance.info()?.deposit_account().clone(); - assert_eq!(>::total_balance(&beneficiary), 0u32.into()); - assert_eq!(T::Currency::free_balance(&instance.account_id), Pallet::::min_balance() * 2u32.into()); - assert_ne!(T::Currency::free_balance(&deposit_account), 0u32.into()); + assert_eq!(>::total_balance(&beneficiary), 0u32.into()); + assert_eq!(T::Fungible::free_balance(&instance.account_id), Pallet::::min_balance() * 2u32.into()); + assert_ne!(T::Fungible::free_balance(&deposit_account), 0u32.into()); }: call(origin, instance.addr.clone(), 0u32.into(), Weight::MAX, None, vec![]) verify { if r > 0 { - assert_eq!(>::total_balance(&instance.account_id), 0u32.into()); - assert_eq!(>::total_balance(&deposit_account), 0u32.into()); - assert_eq!(>::total_balance(&beneficiary), Pallet::::min_balance() * 2u32.into()); + assert_eq!(>::total_balance(&instance.account_id), 0u32.into()); + assert_eq!(>::total_balance(&deposit_account), 0u32.into()); + assert_eq!(>::total_balance(&beneficiary), Pallet::::min_balance() * 2u32.into()); } } @@ -1586,12 +1586,12 @@ benchmarks! { instance.set_balance(value * (r + 1).into()); let origin = RawOrigin::Signed(instance.caller.clone()); for account in &accounts { - assert_eq!(>::total_balance(account), 0u32.into()); + assert_eq!(>::total_balance(account), 0u32.into()); } }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) verify { for account in &accounts { - assert_eq!(>::total_balance(account), value); + assert_eq!(>::total_balance(account), value); } } diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 72ce51bf4fbca..55feb881684b9 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -1068,7 +1068,7 @@ where value: BalanceOf, ) -> DispatchResult { if !value.is_zero() { - T::Currency::transfer(from, to, value, preservation) + T::Fungible::transfer(from, to, value, preservation) .map_err(|_| Error::::TransferFailed)?; } Ok(()) @@ -1253,7 +1253,7 @@ where Preservation::Expendable, &frame.account_id, beneficiary, - T::Currency::reducible_balance(&frame.account_id, Preservation::Expendable, Polite), + T::Fungible::reducible_balance(&frame.account_id, Preservation::Expendable, Polite), )?; info.queue_trie_for_deletion(); ContractInfoOf::::remove(&frame.account_id); @@ -1332,7 +1332,7 @@ where } fn balance(&self) -> BalanceOf { - T::Currency::balance(&self.top_frame().account_id) + T::Fungible::balance(&self.top_frame().account_id) } fn value_transferred(&self) -> BalanceOf { @@ -1348,7 +1348,7 @@ where } fn minimum_balance(&self) -> BalanceOf { - T::Currency::minimum_balance() + T::Fungible::minimum_balance() } fn deposit_event(&mut self, topics: Vec, data: Vec) { @@ -1952,7 +1952,7 @@ mod tests { // This one tests passing the input data into a contract via instantiate. ExtBuilder::default().build().execute_with(|| { let schedule = ::Schedule::get(); - let min_balance = ::Currency::minimum_balance(); + let min_balance = ::Fungible::minimum_balance(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); let executable = MockExecutable::from_storage(input_data_ch, &schedule, &mut gas_meter).unwrap(); @@ -2399,7 +2399,7 @@ mod tests { ExtBuilder::default().existential_deposit(15).build().execute_with(|| { let schedule = ::Schedule::get(); - let min_balance = ::Currency::minimum_balance(); + let min_balance = ::Fungible::minimum_balance(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); let executable = MockExecutable::from_storage(dummy_ch, &schedule, &mut gas_meter).unwrap(); @@ -2445,7 +2445,7 @@ mod tests { ExtBuilder::default().existential_deposit(15).build().execute_with(|| { let schedule = ::Schedule::get(); - let min_balance = ::Currency::minimum_balance(); + let min_balance = ::Fungible::minimum_balance(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); let executable = MockExecutable::from_storage(dummy_ch, &schedule, &mut gas_meter).unwrap(); @@ -2490,7 +2490,7 @@ mod tests { Weight::zero(), BalanceOf::::zero(), dummy_ch, - ::Currency::minimum_balance(), + ::Fungible::minimum_balance(), vec![], &[48, 49, 50], ) @@ -2503,7 +2503,7 @@ mod tests { ExtBuilder::default().existential_deposit(15).build().execute_with(|| { let schedule = ::Schedule::get(); - let min_balance = ::Currency::minimum_balance(); + let min_balance = ::Fungible::minimum_balance(); set_balance(&ALICE, min_balance * 100); place_contract(&BOB, instantiator_ch); let contract_origin = Origin::from_account_id(ALICE); @@ -2559,7 +2559,7 @@ mod tests { Weight::zero(), BalanceOf::::zero(), dummy_ch, - ::Currency::minimum_balance(), + ::Fungible::minimum_balance(), vec![], &[], ), @@ -2717,7 +2717,7 @@ mod tests { // This one tests passing the input data into a contract via instantiate. ExtBuilder::default().build().execute_with(|| { let schedule = ::Schedule::get(); - let min_balance = ::Currency::minimum_balance(); + let min_balance = ::Fungible::minimum_balance(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); let executable = MockExecutable::from_storage(code, &schedule, &mut gas_meter).unwrap(); set_balance(&ALICE, min_balance * 10_000); @@ -2751,7 +2751,7 @@ mod tests { let mut debug_buffer = DebugBufferVec::::try_from(Vec::new()).unwrap(); ExtBuilder::default().build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = ::Fungible::minimum_balance(); let schedule = ::Schedule::get(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); set_balance(&ALICE, min_balance * 10); @@ -2787,7 +2787,7 @@ mod tests { let mut debug_buffer = DebugBufferVec::::try_from(Vec::new()).unwrap(); ExtBuilder::default().build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = ::Fungible::minimum_balance(); let schedule = ::Schedule::get(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); set_balance(&ALICE, min_balance * 10); @@ -2827,7 +2827,7 @@ mod tests { ExtBuilder::default().build().execute_with(|| { let schedule: Schedule = ::Schedule::get(); - let min_balance = ::Currency::minimum_balance(); + let min_balance = ::Fungible::minimum_balance(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); set_balance(&ALICE, min_balance * 10); place_contract(&BOB, code_hash); @@ -2954,7 +2954,7 @@ mod tests { }); ExtBuilder::default().build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = ::Fungible::minimum_balance(); let schedule = ::Schedule::get(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); set_balance(&ALICE, min_balance * 10); @@ -3041,7 +3041,7 @@ mod tests { }); ExtBuilder::default().build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = ::Fungible::minimum_balance(); let schedule = ::Schedule::get(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); set_balance(&ALICE, min_balance * 10); @@ -3141,7 +3141,7 @@ mod tests { ExtBuilder::default().build().execute_with(|| { let schedule = ::Schedule::get(); - let min_balance = ::Currency::minimum_balance(); + let min_balance = ::Fungible::minimum_balance(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); let fail_executable = MockExecutable::from_storage(fail_code, &schedule, &mut gas_meter).unwrap(); @@ -3258,7 +3258,7 @@ mod tests { }); ExtBuilder::default().build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = ::Fungible::minimum_balance(); let schedule = ::Schedule::get(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); set_balance(&ALICE, min_balance * 1000); @@ -3386,7 +3386,7 @@ mod tests { }); ExtBuilder::default().build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = ::Fungible::minimum_balance(); let schedule = ::Schedule::get(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); set_balance(&ALICE, min_balance * 1000); @@ -3426,7 +3426,7 @@ mod tests { }); ExtBuilder::default().build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = ::Fungible::minimum_balance(); let schedule = ::Schedule::get(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); set_balance(&ALICE, min_balance * 1000); @@ -3466,7 +3466,7 @@ mod tests { }); ExtBuilder::default().build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = ::Fungible::minimum_balance(); let schedule = ::Schedule::get(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); set_balance(&ALICE, min_balance * 1000); @@ -3523,7 +3523,7 @@ mod tests { }); ExtBuilder::default().build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = ::Fungible::minimum_balance(); let schedule = ::Schedule::get(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); set_balance(&ALICE, min_balance * 1000); @@ -3580,7 +3580,7 @@ mod tests { }); ExtBuilder::default().build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = ::Fungible::minimum_balance(); let schedule = ::Schedule::get(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); set_balance(&ALICE, min_balance * 1000); @@ -3677,7 +3677,7 @@ mod tests { }); ExtBuilder::default().build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = ::Fungible::minimum_balance(); let schedule = ::Schedule::get(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); set_balance(&ALICE, min_balance * 1000); diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 5b35fcb6a8061..ef0c4e942628e 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -143,7 +143,7 @@ pub use crate::wasm::api_doc; type CodeHash = ::Hash; type TrieId = BoundedVec>; type BalanceOf = - <::Currency as Inspect<::AccountId>>::Balance; + <::Fungible as Inspect<::AccountId>>::Balance; type CodeVec = BoundedVec::MaxCodeLen>; type RelaxedCodeVec = WeakBoundedVec::MaxCodeLen>; type AccountIdLookupOf = <::Lookup as StaticLookup>::Source; @@ -200,8 +200,8 @@ pub mod pallet { /// to supply a dummy implementation for this type (because it is never used). type Randomness: Randomness; - /// The currency in which fees are paid and contract balances are held. - type Currency: Inspect + /// The fungible in which fees are paid and contract balances are held. + type Fungible: Inspect + Mutate + MutateHold; @@ -315,7 +315,7 @@ pub mod pallet { /// The identifier of the hold reason. #[pallet::constant] - type HoldReason: Get<>::Reason>; + type HoldReason: Get<>::Reason>; } #[pallet::hooks] @@ -1429,9 +1429,9 @@ impl Pallet { ) } - /// Return the existential deposit of [`Config::Currency`]. + /// Return the existential deposit of [`Config::Fungible`]. fn min_balance() -> BalanceOf { - >>::minimum_balance() + >>::minimum_balance() } /// Convert gas_limit from 1D Weight to a 2D Weight. diff --git a/frame/contracts/src/storage/meter.rs b/frame/contracts/src/storage/meter.rs index da311e0051ce3..8687c698e3813 100644 --- a/frame/contracts/src/storage/meter.rs +++ b/frame/contracts/src/storage/meter.rs @@ -39,7 +39,7 @@ use sp_runtime::{ }; use sp_std::{marker::PhantomData, vec::Vec}; -/// Deposit that uses the native currency's balance type. +/// Deposit that uses the native fungible's balance type. pub type DepositOf = Deposit>; /// A production root storage meter that actually charges from its origin. @@ -91,7 +91,7 @@ pub trait Ext { /// This [`Ext`] is used for actual on-chain execution when balance needs to be charged. /// -/// It uses [`ReservableCurrency`] in order to do accomplish the reserves. +/// It uses [`Mutate`] in order to do accomplish the reserves. pub enum ReservingExt {} /// Used to implement a type state pattern for the meter. @@ -449,7 +449,7 @@ where System::::inc_consumers(info.deposit_account())?; // We also need to make sure that the contract's account itself exists. - T::Currency::transfer(origin, contract, ed, Preservation::Protect)?; + T::Fungible::transfer(origin, contract, ed, Preservation::Protect)?; System::::inc_consumers(contract)?; Ok(deposit) @@ -513,14 +513,14 @@ impl Ext for ReservingExt { // We are sending the `min_leftover` and the `min_balance` from the origin // account as part of a contract call. Hence origin needs to have those left over // as free balance after accounting for all deposits. - let max = T::Currency::reducible_balance(origin, Preservation::Protect, Polite) + let max = T::Fungible::reducible_balance(origin, Preservation::Protect, Polite) .saturating_sub(min_leftover) .saturating_sub(Pallet::::min_balance()); let default = max.min(T::DefaultDepositLimit::get()); let limit = limit.unwrap_or(default); ensure!( limit <= max && - matches!(T::Currency::can_withdraw(origin, limit), WithdrawConsequence::Success), + matches!(T::Fungible::can_withdraw(origin, limit), WithdrawConsequence::Success), >::StorageDepositNotEnoughFunds, ); Ok(limit) @@ -534,14 +534,14 @@ impl Ext for ReservingExt { ) -> Result<(), DispatchError> { match amount { Deposit::Charge(amount) => { - T::Currency::transfer(origin, deposit_account, *amount, Preservation::Protect)?; + T::Fungible::transfer(origin, deposit_account, *amount, Preservation::Protect)?; Ok(()) }, Deposit::Refund(amount) => { if terminated { System::::dec_consumers(&deposit_account); } - T::Currency::transfer( + T::Fungible::transfer( deposit_account, origin, *amount, diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 04951fdcc75fd..300fe990ee4f2 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -38,7 +38,7 @@ use frame_support::{ parameter_types, storage::child, traits::{ - fungible::{BalancedHold, Inspect, InspectHold, Mutate, MutateFreeze, MutateHold}, + fungible::{BalancedHold, Inspect, InspectHold, Mutate, MutateHold}, tokens::Preservation, ConstU32, ConstU64, Contains, OnIdle, OnInitialize, }, @@ -90,7 +90,7 @@ macro_rules! assert_refcount { } pub mod test_utils { - use super::{Balances, Hash, SysConfig, Test}; + use super::{Hash, SysConfig, Test}; use crate::{exec::AccountIdOf, CodeHash, Config, ContractInfo, ContractInfoOf, Nonce}; use codec::Encode; use frame_support::traits::fungible::{Inspect, Mutate}; @@ -100,16 +100,16 @@ pub mod test_utils { *counter += 1; *counter }); - set_balance(address, ::Currency::minimum_balance() * 10); + set_balance(address, ::Fungible::minimum_balance() * 10); let contract = >::new(&address, nonce, code_hash).unwrap(); >::insert(address, contract); } pub fn set_balance(who: &AccountIdOf, amount: u64) { - let imbalance = Balances::set_balance(who, amount); + let imbalance = ::Fungible::set_balance(who, amount); drop(imbalance); } pub fn get_balance(who: &AccountIdOf) -> u64 { - Balances::free_balance(who) + ::Fungible::free_balance(who) } pub fn get_contract(addr: &AccountIdOf) -> ContractInfo { get_contract_checked(addr).unwrap() @@ -419,7 +419,7 @@ parameter_types! { impl Config for Test { type Time = Timestamp; type Randomness = Randomness; - type Currency = Balances; + type Fungible = Balances; type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; type CallFilter = TestFilter; @@ -539,7 +539,7 @@ impl Default for Origin { #[test] fn calling_plain_account_fails() { ExtBuilder::default().build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 100_000_000); + let _ = ::Fungible::set_balance(&ALICE, 100_000_000); let base_cost = <::WeightInfo as WeightInfo>::call(); assert_eq!( @@ -560,8 +560,8 @@ fn instantiate_and_call_and_deposit_event() { let (wasm, code_hash) = compile_module::("event_and_return_on_deploy").unwrap(); ExtBuilder::default().existential_deposit(1).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); - let min_balance = ::Currency::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let min_balance = ::Fungible::minimum_balance(); let value = 100; // We determine the storage deposit limit after uploading because it depends on ALICEs free @@ -683,7 +683,7 @@ fn deposit_event_max_value_limit() { ExtBuilder::default().existential_deposit(50).build().execute_with(|| { // Create - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, 30_000, @@ -728,8 +728,8 @@ fn deposit_event_max_value_limit() { fn run_out_of_gas() { let (wasm, _code_hash) = compile_module::("run_out_of_gas").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); - let _ = Balances::set_balance(&ALICE, 1_000_000); + let min_balance = ::Fungible::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, @@ -769,7 +769,7 @@ fn instantiate_unique_trie_id() { let (wasm, code_hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(500).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); Contracts::upload_code(RuntimeOrigin::signed(ALICE), wasm, None, Determinism::Enforced) .unwrap(); @@ -836,7 +836,7 @@ fn storage_max_value_limit() { ExtBuilder::default().existential_deposit(50).build().execute_with(|| { // Create - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, 30_000, @@ -884,10 +884,10 @@ fn deploy_and_call_other_contract() { let (callee_wasm, callee_code_hash) = compile_module::("return_with_data").unwrap(); ExtBuilder::default().existential_deposit(1).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); + let min_balance = ::Fungible::minimum_balance(); // Create - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); let caller_addr = Contracts::bare_instantiate( ALICE, 100_000, @@ -1035,7 +1035,7 @@ fn delegate_call() { let (callee_wasm, callee_code_hash) = compile_module::("delegate_call_lib").unwrap(); ExtBuilder::default().existential_deposit(500).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); // Instantiate the 'caller' let caller_addr = Contracts::bare_instantiate( @@ -1075,7 +1075,7 @@ fn delegate_call() { fn transfer_allow_death_cannot_kill_account() { let (wasm, _code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -1096,10 +1096,10 @@ fn transfer_allow_death_cannot_kill_account() { // Check that the BOB contract has been instantiated. get_contract(&addr); - let total_balance = ::Currency::total_balance(&addr); + let total_balance = ::Fungible::total_balance(&addr); assert_err!( - <::Currency as Mutate>::transfer( + <::Fungible as Mutate>::transfer( &addr, &ALICE, total_balance, @@ -1108,7 +1108,7 @@ fn transfer_allow_death_cannot_kill_account() { TokenError::Frozen, ); - assert_eq!(::Currency::total_balance(&addr), total_balance); + assert_eq!(::Fungible::total_balance(&addr), total_balance); }); } @@ -1116,7 +1116,7 @@ fn transfer_allow_death_cannot_kill_account() { fn cannot_self_destruct_through_draning() { let (wasm, _code_hash) = compile_module::("drain").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -1150,8 +1150,8 @@ fn cannot_self_destruct_through_draning() { // Make sure the account wasn't remove by sending all free balance away. assert_eq!( - ::Currency::total_balance(&addr), - 1_000 + ::Currency::minimum_balance(), + ::Fungible::total_balance(&addr), + 1_000 + ::Fungible::minimum_balance(), ); }); } @@ -1160,8 +1160,8 @@ fn cannot_self_destruct_through_draning() { fn cannot_self_destruct_through_storage_refund_after_price_change() { let (wasm, _code_hash) = compile_module::("store_call").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); - let min_balance = ::Currency::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let min_balance = ::Fungible::minimum_balance(); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -1182,7 +1182,7 @@ fn cannot_self_destruct_through_storage_refund_after_price_change() { // Check that the BOB contract has been instantiated and has the minimum balance assert_eq!(get_contract(&addr).total_deposit(), min_balance); assert_eq!(get_contract(&addr).extra_deposit(), 0); - assert_eq!(::Currency::total_balance(&addr), min_balance); + assert_eq!(::Fungible::total_balance(&addr), min_balance); // Create 100 bytes of storage with a price of per byte and a single storage item of price 2 assert_ok!(Contracts::call( @@ -1209,7 +1209,7 @@ fn cannot_self_destruct_through_storage_refund_after_price_change() { // Make sure the account wasn't removed by the refund assert_eq!( - ::Currency::total_balance(get_contract(&addr).deposit_account()), + ::Fungible::total_balance(get_contract(&addr).deposit_account()), get_contract(&addr).total_deposit(), ); assert_eq!(get_contract(&addr).extra_deposit(), 2); @@ -1220,7 +1220,7 @@ fn cannot_self_destruct_through_storage_refund_after_price_change() { fn cannot_self_destruct_while_live() { let (wasm, _code_hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -1264,8 +1264,8 @@ fn cannot_self_destruct_while_live() { fn self_destruct_works() { let (wasm, code_hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(1_000).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); - let _ = Balances::set_balance(&DJANGO, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&DJANGO, 1_000_000); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -1300,11 +1300,11 @@ fn self_destruct_works() { // Check that account is gone assert!(get_contract_checked(&addr).is_none()); - assert_eq!(Balances::total_balance(&addr), 0); + assert_eq!(::Fungible::total_balance(&addr), 0); // check that the beneficiary (django) got remaining balance - let ed = ::Currency::minimum_balance(); - assert_eq!(Balances::free_balance(DJANGO), 1_000_000 + 100_000 + ed); + let ed = ::Fungible::minimum_balance(); + assert_eq!(::Fungible::free_balance(DJANGO), 1_000_000 + 100_000 + ed); pretty_assertions::assert_eq!( System::events(), @@ -1371,7 +1371,7 @@ fn destroy_contract_and_transfer_funds() { ExtBuilder::default().existential_deposit(50).build().execute_with(|| { // Create code hash for bob to instantiate - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); Contracts::bare_upload_code(ALICE, callee_wasm, None, Determinism::Enforced).unwrap(); // This deploys the BOB contract, which in turn deploys the CHARLIE contract during @@ -1415,7 +1415,7 @@ fn destroy_contract_and_transfer_funds() { fn cannot_self_destruct_in_constructor() { let (wasm, _) = compile_module::("self_destructing_constructor").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); // Fail to instantiate the BOB because the contructor calls seal_terminate. assert_err_ignore_postinfo!( @@ -1438,7 +1438,7 @@ fn crypto_hashes() { let (wasm, _code_hash) = compile_module::("crypto_hashes").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); // Instantiate the CRYPTO_HASHES contract. let addr = Contracts::bare_instantiate( @@ -1500,8 +1500,8 @@ fn crypto_hashes() { fn transfer_return_code() { let (wasm, _code_hash) = compile_module::("transfer_return_code").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); - let _ = Balances::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Fungible::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, @@ -1519,7 +1519,7 @@ fn transfer_return_code() { .account_id; // Contract has only the minimal balance so any transfer will fail. - Balances::set_balance(&addr, min_balance); + ::Fungible::set_balance(&addr, min_balance); let result = Contracts::bare_call( ALICE, addr.clone(), @@ -1542,9 +1542,9 @@ fn call_return_code() { let (caller_code, _caller_hash) = compile_module::("call_return_code").unwrap(); let (callee_code, _callee_hash) = compile_module::("ok_trap_revert").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); - let _ = Balances::set_balance(&ALICE, 1000 * min_balance); - let _ = Balances::set_balance(&CHARLIE, 1000 * min_balance); + let min_balance = ::Fungible::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); + let _ = ::Fungible::set_balance(&CHARLIE, 1000 * min_balance); let addr_bob = Contracts::bare_instantiate( ALICE, @@ -1560,7 +1560,7 @@ fn call_return_code() { .result .unwrap() .account_id; - Balances::set_balance(&addr_bob, min_balance); + ::Fungible::set_balance(&addr_bob, min_balance); // Contract calls into Django which is no valid contract let result = Contracts::bare_call( @@ -1592,7 +1592,7 @@ fn call_return_code() { .result .unwrap() .account_id; - Balances::set_balance(&addr_django, min_balance); + ::Fungible::set_balance(&addr_django, min_balance); // Contract has only the minimal balance so any transfer will fail. let result = Contracts::bare_call( @@ -1615,7 +1615,7 @@ fn call_return_code() { assert_return_code!(result, RuntimeReturnCode::TransferFailed); // Contract has enough balance but callee reverts because "1" is passed. - Balances::set_balance(&addr_bob, min_balance + 1000); + ::Fungible::set_balance(&addr_bob, min_balance + 1000); let result = Contracts::bare_call( ALICE, addr_bob.clone(), @@ -1662,9 +1662,9 @@ fn instantiate_return_code() { let (caller_code, _caller_hash) = compile_module::("instantiate_return_code").unwrap(); let (callee_code, callee_hash) = compile_module::("ok_trap_revert").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); - let _ = Balances::set_balance(&ALICE, 1000 * min_balance); - let _ = Balances::set_balance(&CHARLIE, 1000 * min_balance); + let min_balance = ::Fungible::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); + let _ = ::Fungible::set_balance(&CHARLIE, 1000 * min_balance); let callee_hash = callee_hash.as_ref().to_vec(); assert_ok!(Contracts::instantiate_with_code( @@ -1693,7 +1693,7 @@ fn instantiate_return_code() { .account_id; // Contract has only the minimal balance so any transfer will fail. - Balances::set_balance(&addr, min_balance); + ::Fungible::set_balance(&addr, min_balance); let result = Contracts::bare_call( ALICE, addr.clone(), @@ -1710,7 +1710,7 @@ fn instantiate_return_code() { assert_return_code!(result, RuntimeReturnCode::TransferFailed); // Contract has enough balance but the passed code hash is invalid - Balances::set_balance(&addr, min_balance + 10_000); + ::Fungible::set_balance(&addr, min_balance + 10_000); let result = Contracts::bare_call( ALICE, addr.clone(), @@ -1764,8 +1764,8 @@ fn instantiate_return_code() { fn disabled_chain_extension_wont_deploy() { let (code, _hash) = compile_module::("chain_extension").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); - let _ = Balances::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Fungible::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); TestExtension::disable(); assert_err_ignore_postinfo!( Contracts::instantiate_with_code( @@ -1786,8 +1786,8 @@ fn disabled_chain_extension_wont_deploy() { fn disabled_chain_extension_errors_on_call() { let (code, _hash) = compile_module::("chain_extension").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); - let _ = Balances::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Fungible::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, min_balance * 100, @@ -1814,8 +1814,8 @@ fn disabled_chain_extension_errors_on_call() { fn chain_extension_works() { let (code, _hash) = compile_module::("chain_extension").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); - let _ = Balances::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Fungible::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, min_balance * 100, @@ -1961,8 +1961,8 @@ fn chain_extension_works() { fn chain_extension_temp_storage_works() { let (code, _hash) = compile_module::("chain_extension_temp_storage").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); - let _ = Balances::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Fungible::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, min_balance * 100, @@ -2008,8 +2008,8 @@ fn chain_extension_temp_storage_works() { fn lazy_removal_works() { let (code, _hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); - let _ = Balances::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Fungible::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, @@ -2060,8 +2060,8 @@ fn lazy_removal_works() { fn lazy_batch_removal_works() { let (code, _hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); - let _ = Balances::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Fungible::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); let mut tries: Vec = vec![]; for i in 0..3u8 { @@ -2128,8 +2128,8 @@ fn lazy_removal_partial_remove_works() { let mut ext = ExtBuilder::default().existential_deposit(50).build(); let trie = ext.execute_with(|| { - let min_balance = ::Currency::minimum_balance(); - let _ = Balances::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Fungible::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, @@ -2210,8 +2210,8 @@ fn lazy_removal_partial_remove_works() { fn lazy_removal_does_no_run_on_low_remaining_weight() { let (code, _hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); - let _ = Balances::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Fungible::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, @@ -2282,8 +2282,8 @@ fn lazy_removal_does_not_use_all_weight() { let mut ext = ExtBuilder::default().existential_deposit(50).build(); let (trie, vals, weight_per_key) = ext.execute_with(|| { - let min_balance = ::Currency::minimum_balance(); - let _ = Balances::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Fungible::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, @@ -2370,8 +2370,8 @@ fn deletion_queue_ring_buffer_overflow() { ext.commit_all().unwrap(); ext.execute_with(|| { - let min_balance = ::Currency::minimum_balance(); - let _ = Balances::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Fungible::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); let mut tries: Vec = vec![]; // add 3 contracts to the deletion queue @@ -2430,8 +2430,8 @@ fn deletion_queue_ring_buffer_overflow() { fn refcounter() { let (wasm, code_hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); - let min_balance = ::Currency::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let min_balance = ::Fungible::minimum_balance(); // Create two contracts with the same code and check that they do in fact share it. let addr0 = Contracts::bare_instantiate( @@ -2527,8 +2527,8 @@ fn refcounter() { fn reinstrument_does_charge() { let (wasm, code_hash) = compile_module::("return_with_data").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); - let min_balance = ::Currency::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let min_balance = ::Fungible::minimum_balance(); let zero = 0u32.to_le_bytes().encode(); let code_len = wasm.len() as u32; @@ -2611,7 +2611,7 @@ fn debug_message_works() { let (wasm, _code_hash) = compile_module::("debug_message_works").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, 30_000, @@ -2648,7 +2648,7 @@ fn debug_message_logging_disabled() { let (wasm, _code_hash) = compile_module::("debug_message_logging_disabled").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, 30_000, @@ -2687,7 +2687,7 @@ fn debug_message_invalid_utf8() { let (wasm, _code_hash) = compile_module::("debug_message_invalid_utf8").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, 30_000, @@ -2723,8 +2723,8 @@ fn gas_estimation_nested_call_fixed_limit() { let (caller_code, _caller_hash) = compile_module::("call_with_limit").unwrap(); let (callee_code, _callee_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); - let _ = Balances::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Fungible::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); let addr_caller = Contracts::bare_instantiate( ALICE, @@ -2819,9 +2819,9 @@ fn gas_estimation_call_runtime() { let (caller_code, _caller_hash) = compile_module::("call_runtime").unwrap(); let (callee_code, _callee_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); - let _ = Balances::set_balance(&ALICE, 1000 * min_balance); - let _ = Balances::set_balance(&CHARLIE, 1000 * min_balance); + let min_balance = ::Fungible::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); + let _ = ::Fungible::set_balance(&CHARLIE, 1000 * min_balance); let addr_caller = Contracts::bare_instantiate( ALICE, @@ -2898,9 +2898,9 @@ fn call_runtime_reentrancy_guarded() { let (caller_code, _caller_hash) = compile_module::("call_runtime").unwrap(); let (callee_code, _callee_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); - let _ = Balances::set_balance(&ALICE, 1000 * min_balance); - let _ = Balances::set_balance(&CHARLIE, 1000 * min_balance); + let min_balance = ::Fungible::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); + let _ = ::Fungible::set_balance(&CHARLIE, 1000 * min_balance); let addr_caller = Contracts::bare_instantiate( ALICE, @@ -2966,7 +2966,7 @@ fn ecdsa_recover() { let (wasm, _code_hash) = compile_module::("ecdsa_recover").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); // Instantiate the ecdsa_recover contract. let addr = Contracts::bare_instantiate( @@ -3029,8 +3029,8 @@ fn ecdsa_recover() { fn bare_instantiate_returns_events() { let (wasm, _code_hash) = compile_module::("transfer_return_code").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); - let _ = Balances::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Fungible::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); let result = Contracts::bare_instantiate( ALICE, @@ -3054,8 +3054,8 @@ fn bare_instantiate_returns_events() { fn bare_instantiate_does_not_return_events() { let (wasm, _code_hash) = compile_module::("transfer_return_code").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); - let _ = Balances::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Fungible::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); let result = Contracts::bare_instantiate( ALICE, @@ -3079,8 +3079,8 @@ fn bare_instantiate_does_not_return_events() { fn bare_call_returns_events() { let (wasm, _code_hash) = compile_module::("transfer_return_code").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); - let _ = Balances::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Fungible::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, @@ -3120,8 +3120,8 @@ fn bare_call_returns_events() { fn bare_call_does_not_return_events() { let (wasm, _code_hash) = compile_module::("transfer_return_code").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Currency::minimum_balance(); - let _ = Balances::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Fungible::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, @@ -3162,7 +3162,7 @@ fn sr25519_verify() { let (wasm, _code_hash) = compile_module::("sr25519_verify").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); // Instantiate the sr25519_verify contract. let addr = Contracts::bare_instantiate( @@ -3233,7 +3233,7 @@ fn failed_deposit_charge_should_roll_back_call() { let execute = || { ExtBuilder::default().existential_deposit(ED).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); // Instantiate both contracts. let addr_caller = Contracts::bare_instantiate( @@ -3312,7 +3312,7 @@ fn upload_code_works() { let (wasm, code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); // Drop previous events initialize_block(2); @@ -3354,7 +3354,7 @@ fn upload_code_limit_too_low() { let (wasm, _code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); // Drop previous events initialize_block(2); @@ -3378,7 +3378,7 @@ fn upload_code_not_enough_balance() { let (wasm, _code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 150); + let _ = ::Fungible::set_balance(&ALICE, 150); // Drop previous events initialize_block(2); @@ -3402,7 +3402,7 @@ fn remove_code_works() { let (wasm, code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); // Drop previous events initialize_block(2); @@ -3461,7 +3461,7 @@ fn remove_code_wrong_origin() { let (wasm, code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); // Drop previous events initialize_block(2); @@ -3506,7 +3506,7 @@ fn remove_code_in_use() { let (wasm, code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); assert_ok!(Contracts::instantiate_with_code( RuntimeOrigin::signed(ALICE), @@ -3535,7 +3535,7 @@ fn remove_code_not_found() { let (_wasm, code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); // Drop previous events initialize_block(2); @@ -3553,8 +3553,8 @@ fn remove_code_not_found() { fn instantiate_with_zero_balance_works() { let (wasm, code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); - let min_balance = ::Currency::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let min_balance = ::Fungible::minimum_balance(); // Drop previous events initialize_block(2); @@ -3582,8 +3582,8 @@ fn instantiate_with_zero_balance_works() { let deposit_account = contract.deposit_account().deref(); // Make sure the account exists even though no free balance was send - assert_eq!(::Currency::free_balance(&addr), min_balance); - assert_eq!(::Currency::total_balance(&addr), min_balance,); + assert_eq!(::Fungible::free_balance(&addr), min_balance); + assert_eq!(::Fungible::total_balance(&addr), min_balance,); assert_eq!( System::events(), @@ -3666,8 +3666,8 @@ fn instantiate_with_zero_balance_works() { fn instantiate_with_below_existential_deposit_works() { let (wasm, code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); - let min_balance = ::Currency::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let min_balance = ::Fungible::minimum_balance(); // Drop previous events initialize_block(2); @@ -3695,8 +3695,8 @@ fn instantiate_with_below_existential_deposit_works() { let deposit_account = contract.deposit_account().deref(); // Make sure the account exists even though not enough free balance was send - assert_eq!(::Currency::free_balance(&addr), min_balance + 50); - assert_eq!(::Currency::total_balance(&addr), min_balance + 50); + assert_eq!(::Fungible::free_balance(&addr), min_balance + 50); + assert_eq!(::Fungible::total_balance(&addr), min_balance + 50); assert_eq!( System::events(), @@ -3788,8 +3788,8 @@ fn instantiate_with_below_existential_deposit_works() { fn storage_deposit_works() { let (wasm, _code_hash) = compile_module::("multi_store").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); - let mut deposit = ::Currency::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let mut deposit = ::Fungible::minimum_balance(); let addr = Contracts::bare_instantiate( ALICE, @@ -3927,7 +3927,7 @@ fn storage_deposit_callee_works() { let (wasm_callee, _code_hash_callee) = compile_module::("store_call").unwrap(); const ED: u64 = 200; ExtBuilder::default().existential_deposit(ED).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); // Create both contracts: Constructors do nothing. let addr_caller = Contracts::bare_instantiate( @@ -3984,7 +3984,7 @@ fn set_code_extrinsic() { assert_ne!(code_hash, new_code_hash); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, @@ -4072,7 +4072,7 @@ fn slash_cannot_kill_account() { ExtBuilder::default().existential_deposit(ED).build().execute_with(|| { let value = 700; let balance_held = 500; - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, @@ -4094,21 +4094,26 @@ fn slash_cannot_kill_account() { // We need to hold some balances in order to have something to slash. As slashing can only // affect balances held under certain HoldIdentifier. - Balances::hold(&HoldIdentifier::StorageDepositReserve, &addr, balance_held).unwrap(); + ::Fungible::hold( + &HoldIdentifier::StorageDepositReserve, + &addr, + balance_held, + ) + .unwrap(); - assert_eq!(Balances::total_balance_on_hold(&addr), balance_held); + assert_eq!(::Fungible::total_balance_on_hold(&addr), balance_held); // Try to destroy the account of the contract by slashing the total balance. // The account does not get destroyed because of the consumer reference. // Slashing can for example happen if the contract takes part in staking. - let _ = Balances::slash( + let _ = ::Fungible::slash( &HoldIdentifier::StorageDepositReserve, &addr, - Balances::total_balance(&addr), + ::Fungible::total_balance(&addr), ); // Slashing only removed the balance held. - assert_eq!(Balances::total_balance(&addr), value + ED - balance_held,); + assert_eq!(::Fungible::total_balance(&addr), value + ED - balance_held,); }); } @@ -4117,7 +4122,7 @@ fn contract_reverted() { let (wasm, code_hash) = compile_module::("return_with_data").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); let flags = ReturnFlags::REVERT; let buffer = [4u8, 8, 15, 16, 23, 42]; let input = (flags.bits(), buffer).encode(); @@ -4230,7 +4235,7 @@ fn contract_reverted() { #[test] fn code_rejected_error_works() { ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); let (wasm, _) = compile_module::("invalid_module").unwrap(); assert_noop!( @@ -4295,7 +4300,7 @@ fn set_code_hash() { let (new_wasm, new_code_hash) = compile_module::("new_set_code_hash_contract").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); // Instantiate the 'caller' let contract_addr = Contracts::bare_instantiate( @@ -4398,8 +4403,8 @@ fn set_code_hash() { fn storage_deposit_limit_is_enforced() { let (wasm, _code_hash) = compile_module::("store_call").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); - let min_balance = ::Currency::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let min_balance = ::Fungible::minimum_balance(); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -4419,7 +4424,7 @@ fn storage_deposit_limit_is_enforced() { // Check that the BOB contract has been instantiated and has the minimum balance assert_eq!(get_contract(&addr).total_deposit(), min_balance); - assert_eq!(::Currency::total_balance(&addr), min_balance); + assert_eq!(::Fungible::total_balance(&addr), min_balance); // Create 1 byte of storage with a price of per byte, // setting insufficient deposit limit, as it requires 3 Balance: @@ -4474,7 +4479,7 @@ fn deposit_limit_in_nested_calls() { compile_module::("create_storage_and_call").unwrap(); let (wasm_callee, _code_hash_callee) = compile_module::("store_call").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); // Create both contracts: Constructors do nothing. let addr_caller = Contracts::bare_instantiate( @@ -4583,7 +4588,7 @@ fn deposit_limit_in_nested_calls() { >::StorageDepositLimitExhausted, ); - let _ = Balances::set_balance(&ALICE, 1_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000); // Require more than the sender's balance. // We don't set a special limit for the nested call. @@ -4620,8 +4625,8 @@ fn deposit_limit_in_nested_instantiate() { let (wasm_callee, code_hash_callee) = compile_module::("store_deploy").unwrap(); const ED: u64 = 5; ExtBuilder::default().existential_deposit(ED).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); - let _ = Balances::set_balance(&BOB, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&BOB, 1_000_000); // Create caller contract let addr_caller = Contracts::bare_instantiate( ALICE, @@ -4678,7 +4683,7 @@ fn deposit_limit_in_nested_instantiate() { >::StorageDepositLimitExhausted, ); // The charges made on instantiation should be rolled back. - assert_eq!(::Currency::free_balance(&BOB), 1_000_000); + assert_eq!(::Fungible::free_balance(&BOB), 1_000_000); // Now we give enough limit for the instantiation itself, but require for 1 more storage // byte in the constructor. Hence +1 Balance to the limit is needed. This should fail on the @@ -4695,7 +4700,7 @@ fn deposit_limit_in_nested_instantiate() { >::StorageDepositLimitExhausted, ); // The charges made on the instantiation should be rolled back. - assert_eq!(::Currency::free_balance(&BOB), 1_000_000); + assert_eq!(::Fungible::free_balance(&BOB), 1_000_000); // Now we set enough limit in parent call, but an insufficient limit for child instantiate. // This should fail during the charging for the instantiation in @@ -4712,7 +4717,7 @@ fn deposit_limit_in_nested_instantiate() { >::StorageDepositLimitExhausted, ); // The charges made on the instantiation should be rolled back. - assert_eq!(::Currency::free_balance(&BOB), 1_000_000); + assert_eq!(::Fungible::free_balance(&BOB), 1_000_000); // Same as above but requires for single added storage // item of 1 byte to be covered by the limit, which implies 3 more Balance. @@ -4730,7 +4735,7 @@ fn deposit_limit_in_nested_instantiate() { >::StorageDepositLimitExhausted, ); // The charges made on the instantiation should be rolled back. - assert_eq!(::Currency::free_balance(&BOB), 1_000_000); + assert_eq!(::Fungible::free_balance(&BOB), 1_000_000); // Set enough deposit limit for the child instantiate. This should succeed. let result = Contracts::bare_call( @@ -4748,18 +4753,18 @@ fn deposit_limit_in_nested_instantiate() { let returned = result.result.unwrap(); // All balance of the caller except ED has been transferred to the callee. // No deposit has been taken from it. - assert_eq!(::Currency::free_balance(&addr_caller), ED); + assert_eq!(::Fungible::free_balance(&addr_caller), ED); // Get address of the deployed contract. let addr_callee = AccountId32::from_slice(&returned.data[0..32]).unwrap(); // 10_000 should be sent to callee from the caller contract, plus ED to be sent from the // origin. - assert_eq!(::Currency::free_balance(&addr_callee), 10_000 + ED); + assert_eq!(::Fungible::free_balance(&addr_callee), 10_000 + ED); // The origin should be charged with: // - callee instantiation deposit = (callee_info_len + 2) // - callee account ED // - for writing an item of 1 byte to storage = 3 Balance assert_eq!( - ::Currency::free_balance(&BOB), + ::Fungible::free_balance(&BOB), 1_000_000 - (callee_info_len + 2 + ED + 3) ); // Check that deposit due to be charged still includes these 3 Balance @@ -4773,9 +4778,9 @@ fn deposit_limit_honors_liquidity_restrictions() { const ED: u64 = 200; ExtBuilder::default().existential_deposit(ED).build().execute_with(|| { let bobs_balance = 1_000; - let _ = Balances::set_balance(&ALICE, 1_000_000); - let _ = Balances::set_balance(&BOB, bobs_balance); - let min_balance = ::Currency::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&BOB, bobs_balance); + let min_balance = ::Fungible::minimum_balance(); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -4795,10 +4800,15 @@ fn deposit_limit_honors_liquidity_restrictions() { // Check that the contract has been instantiated and has the minimum balance assert_eq!(get_contract(&addr).total_deposit(), min_balance); - assert_eq!(::Currency::total_balance(&addr), min_balance); + assert_eq!(::Fungible::total_balance(&addr), min_balance); // check that the hold is honored - Balances::hold(&HoldIdentifier::StorageDepositReserve, &BOB, bobs_balance - ED).unwrap(); + ::Fungible::hold( + &HoldIdentifier::StorageDepositReserve, + &BOB, + bobs_balance - ED, + ) + .unwrap(); assert_err_ignore_postinfo!( Contracts::call( RuntimeOrigin::signed(BOB), @@ -4810,7 +4820,7 @@ fn deposit_limit_honors_liquidity_restrictions() { ), >::StorageDepositNotEnoughFunds, ); - assert_eq!(Balances::free_balance(&BOB), ED); + assert_eq!(::Fungible::free_balance(&BOB), ED); }); } @@ -4818,9 +4828,9 @@ fn deposit_limit_honors_liquidity_restrictions() { fn deposit_limit_honors_existential_deposit() { let (wasm, _code_hash) = compile_module::("store_call").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); - let _ = Balances::set_balance(&BOB, 1_000); - let min_balance = ::Currency::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&BOB, 1_000); + let min_balance = ::Fungible::minimum_balance(); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -4840,7 +4850,7 @@ fn deposit_limit_honors_existential_deposit() { // Check that the contract has been instantiated and has the minimum balance assert_eq!(get_contract(&addr).total_deposit(), min_balance); - assert_eq!(::Currency::total_balance(&addr), min_balance); + assert_eq!(::Fungible::total_balance(&addr), min_balance); // check that the deposit can't bring the account below the existential deposit assert_err_ignore_postinfo!( @@ -4854,7 +4864,7 @@ fn deposit_limit_honors_existential_deposit() { ), >::StorageDepositNotEnoughFunds, ); - assert_eq!(Balances::free_balance(&BOB), 1_000); + assert_eq!(::Fungible::free_balance(&BOB), 1_000); }); } @@ -4862,9 +4872,9 @@ fn deposit_limit_honors_existential_deposit() { fn deposit_limit_honors_min_leftover() { let (wasm, _code_hash) = compile_module::("store_call").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); - let _ = Balances::set_balance(&BOB, 1_000); - let min_balance = ::Currency::minimum_balance(); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&BOB, 1_000); + let min_balance = ::Fungible::minimum_balance(); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -4884,7 +4894,7 @@ fn deposit_limit_honors_min_leftover() { // Check that the contract has been instantiated and has the minimum balance assert_eq!(get_contract(&addr).total_deposit(), min_balance); - assert_eq!(::Currency::total_balance(&addr), min_balance); + assert_eq!(::Fungible::total_balance(&addr), min_balance); // check that the minimum leftover (value send) is considered assert_err_ignore_postinfo!( @@ -4898,7 +4908,7 @@ fn deposit_limit_honors_min_leftover() { ), >::StorageDepositNotEnoughFunds, ); - assert_eq!(Balances::free_balance(&BOB), 1_000); + assert_eq!(::Fungible::free_balance(&BOB), 1_000); }); } @@ -4907,7 +4917,7 @@ fn cannot_instantiate_indeterministic_code() { let (wasm, code_hash) = compile_module::("float_instruction").unwrap(); let (caller_wasm, _) = compile_module::("instantiate_return_code").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); // Try to instantiate directly from code assert_err_ignore_postinfo!( @@ -5041,7 +5051,7 @@ fn cannot_set_code_indeterministic_code() { let (wasm, code_hash) = compile_module::("float_instruction").unwrap(); let (caller_wasm, _) = compile_module::("set_code_hash").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); // Put the non deterministic contract on-chain assert_ok!(Contracts::upload_code( @@ -5091,7 +5101,7 @@ fn delegate_call_indeterministic_code() { let (wasm, code_hash) = compile_module::("float_instruction").unwrap(); let (caller_wasm, _) = compile_module::("delegate_call_simple").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); // Put the non deterministic contract on-chain assert_ok!(Contracts::upload_code( @@ -5157,7 +5167,7 @@ fn reentrance_count_works_with_call() { let (wasm, _code_hash) = compile_module::("reentrance_count_call").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); let contract_addr = Contracts::bare_instantiate( ALICE, @@ -5198,7 +5208,7 @@ fn reentrance_count_works_with_delegated_call() { let (wasm, code_hash) = compile_module::("reentrance_count_delegated_call").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); let contract_addr = Contracts::bare_instantiate( ALICE, @@ -5241,7 +5251,7 @@ fn account_reentrance_count_works() { compile_module::("reentrance_count_call").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); let contract_addr = Contracts::bare_instantiate( ALICE, @@ -5357,7 +5367,7 @@ fn root_can_call() { let (wasm, _) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = Balances::set_balance(&ALICE, 1_000_000); + let _ = ::Fungible::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, diff --git a/frame/contracts/src/wasm/code_cache.rs b/frame/contracts/src/wasm/code_cache.rs index f831599c83737..5a3fce4d6c6f9 100644 --- a/frame/contracts/src/wasm/code_cache.rs +++ b/frame/contracts/src/wasm/code_cache.rs @@ -96,7 +96,7 @@ pub fn store(mut module: PrefabWasmModule, instantiated: bool) -> ); // This `None` case happens only in freshly uploaded modules. This means that // the `owner` is always the origin of the current transaction. - T::Currency::hold( + T::Fungible::hold( &T::HoldReason::get(), &new_owner_info.owner, new_owner_info.deposit, @@ -163,7 +163,7 @@ pub fn try_remove(origin: &T::AccountId, code_hash: CodeHash) -> D if let Some(owner_info) = existing { ensure!(owner_info.refcount == 0, >::CodeInUse); ensure!(&owner_info.owner == origin, BadOrigin); - T::Currency::release( + T::Fungible::release( &T::HoldReason::get(), &owner_info.owner, owner_info.deposit, From 1c82beffad60986274b154db3705cfd619816704 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Mon, 15 May 2023 18:49:49 +0200 Subject: [PATCH 020/105] contracts: do not transfer if from equals to --- frame/contracts/src/exec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 55feb881684b9..15bc96bc58def 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -1067,7 +1067,7 @@ where to: &T::AccountId, value: BalanceOf, ) -> DispatchResult { - if !value.is_zero() { + if !value.is_zero() && from != to { T::Fungible::transfer(from, to, value, preservation) .map_err(|_| Error::::TransferFailed)?; } From 921d89cdb239cf3416d7970cc6e76919bf993874 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 6 Jun 2023 08:30:45 +0200 Subject: [PATCH 021/105] bound BalanceOf --- frame/contracts/src/benchmarking/mod.rs | 2 +- frame/contracts/src/exec.rs | 34 +++++++-- frame/contracts/src/migration.rs | 8 +-- frame/contracts/src/migration/v10.rs | 92 ++++++++++++++++--------- frame/contracts/src/storage/meter.rs | 16 +++-- 5 files changed, 102 insertions(+), 50 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 784e208360ce6..75c6d3e5bcac0 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -251,7 +251,7 @@ benchmarks! { whitelisted_caller(), WasmModule::dummy(), vec![], )?; - v10::store_old_contrat_info::(contract.account_id.clone(), contract.info()?); + v10::store_old_contract_info::(contract.account_id.clone(), contract.info()?); let mut m = v10::Migration::::default(); }: { m.step(); diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 15bc96bc58def..450954cffb64b 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -43,7 +43,10 @@ use sp_core::{ sr25519::{Public as SR25519Public, Signature as SR25519Signature}, }; use sp_io::{crypto::secp256k1_ecdsa_recover_compressed, hashing::blake2_256}; -use sp_runtime::traits::{Convert, Hash, Zero}; +use sp_runtime::{ + traits::{Convert, Hash, Zero}, + FixedPointOperand, +}; use sp_std::{marker::PhantomData, mem, prelude::*, vec::Vec}; pub type AccountIdOf = ::AccountId; @@ -145,7 +148,9 @@ pub trait Ext: sealing::Sealed { value: BalanceOf, input_data: Vec, allows_reentry: bool, - ) -> Result; + ) -> Result + where + BalanceOf: FixedPointOperand; /// Execute code in the current frame. /// @@ -631,7 +636,10 @@ where input_data: Vec, debug_message: Option<&'a mut DebugBufferVec>, determinism: Determinism, - ) -> Result { + ) -> Result + where + BalanceOf: FixedPointOperand, + { let (mut stack, executable) = Self::new( FrameArgs::Call { dest, cached_info: None, delegated_call: None }, origin, @@ -665,7 +673,10 @@ where input_data: Vec, salt: &[u8], debug_message: Option<&'a mut DebugBufferVec>, - ) -> Result<(T::AccountId, ExecReturnValue), ExecError> { + ) -> Result<(T::AccountId, ExecReturnValue), ExecError> + where + BalanceOf: FixedPointOperand, + { let (mut stack, executable) = Self::new( FrameArgs::Instantiate { sender: origin.clone(), @@ -842,7 +853,10 @@ where /// Run the current (top) frame. /// /// This can be either a call or an instantiate. - fn run(&mut self, executable: E, input_data: Vec) -> Result { + fn run(&mut self, executable: E, input_data: Vec) -> Result + where + BalanceOf: FixedPointOperand, + { let frame = self.top_frame(); let entry_point = frame.entry_point; let delegated_code_hash = @@ -966,7 +980,10 @@ where /// /// This is called after running the current frame. It commits cached values to storage /// and invalidates all stale references to it that might exist further down the call stack. - fn pop_frame(&mut self, persist: bool) { + fn pop_frame(&mut self, persist: bool) + where + BalanceOf: FixedPointOperand, + { // Revert changes to the nonce in case of a failed instantiation. if !persist && self.top_frame().entry_point == ExportedFunction::Constructor { self.nonce.as_mut().map(|c| *c = c.wrapping_sub(1)); @@ -1153,7 +1170,10 @@ where value: BalanceOf, input_data: Vec, allows_reentry: bool, - ) -> Result { + ) -> Result + where + BalanceOf: FixedPointOperand, + { // Before pushing the new frame: Protect the caller contract against reentrancy attacks. // It is important to do this before calling `allows_reentry` so that a direct recursion // is caught by it. diff --git a/frame/contracts/src/migration.rs b/frame/contracts/src/migration.rs index a75d5cc1a1f4d..6c527ee5c5fca 100644 --- a/frame/contracts/src/migration.rs +++ b/frame/contracts/src/migration.rs @@ -58,9 +58,9 @@ fn invalid_version(version: StorageVersion) -> ! { /// The cursor used to store the state of the current migration step. pub type Cursor = BoundedVec>; -// In benchmark and tests we use noop migrations, to test and bench the migration framework itself. -#[cfg(not(any(feature = "runtime-benchmarks", test)))] -type Migrations = (v9::Migration, v10::Migration, v11::Migration); +// // In benchmark and tests we use noop migrations, to test and bench the migration framework +// itself. #[cfg(not(any(feature = "runtime-benchmarks", test)))] +// type Migrations = (v9::Migration, v10::Migration, v11::Migration); /// IsFinished describes whether a migration is finished or not. pub enum IsFinished { @@ -207,7 +207,7 @@ pub trait MigrateSequence: private::Sealed { /// Performs all necessary migrations based on `StorageVersion`. #[cfg(not(any(feature = "runtime-benchmarks", test)))] -pub struct Migration>(PhantomData<(T, M)>); +pub struct Migration(PhantomData<(T, M)>); /// Custom migration for running runtime-benchmarks and tests. #[cfg(any(feature = "runtime-benchmarks", test))] diff --git a/frame/contracts/src/migration/v10.rs b/frame/contracts/src/migration/v10.rs index cddf67a53c4f8..3f4177334de40 100644 --- a/frame/contracts/src/migration/v10.rs +++ b/frame/contracts/src/migration/v10.rs @@ -23,7 +23,7 @@ use crate::{ exec::AccountIdOf, migration::{IsFinished, Migrate}, weights::WeightInfo, - BalanceOf, CodeHash, Config, Pallet, TrieId, Weight, LOG_TARGET, + CodeHash, Config, Pallet, TrieId, Weight, LOG_TARGET, }; use codec::{Decode, Encode}; use core::cmp::{max, min}; @@ -32,9 +32,8 @@ use frame_support::{ pallet_prelude::*, storage_alias, traits::{ - fungible::Inspect, - tokens::{Fortitude::Polite, Preservation::Preserve}, - Currency, ExistenceRequirement, ReservableCurrency, + tokens::{fungible::Inspect, Fortitude::Polite, Preservation::Preserve}, + ExistenceRequirement, ReservableCurrency, }, DefaultNoBound, }; @@ -47,29 +46,46 @@ use sp_std::{marker::PhantomData, ops::Deref, prelude::*}; mod old { use super::*; + pub type BalanceOf> = ::AccountId, + >>::Balance; + + /// Old Currency type traits + /// + /// This trait holds what the old [`T::Currency`] type required before is was replaced by + /// [`T::Fungible`] + pub trait CurrencyOf: + ReservableCurrency<::AccountId> + + Inspect<::AccountId, Balance = BalanceOf> + { + } + #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)] #[scale_info(skip_type_params(T))] - pub struct ContractInfo { + pub struct ContractInfo> { pub trie_id: TrieId, pub code_hash: CodeHash, pub storage_bytes: u32, pub storage_items: u32, - pub storage_byte_deposit: BalanceOf, - pub storage_item_deposit: BalanceOf, - pub storage_base_deposit: BalanceOf, + pub storage_byte_deposit: BalanceOf, + pub storage_item_deposit: BalanceOf, + pub storage_base_deposit: BalanceOf, } #[storage_alias] - pub type ContractInfoOf = StorageMap< + pub type ContractInfoOf> = StorageMap< Pallet, Twox64Concat, ::AccountId, - ContractInfo, + ContractInfo, >; } #[cfg(feature = "runtime-benchmarks")] -pub fn store_old_contrat_info(account: T::AccountId, info: crate::ContractInfo) { +pub fn store_old_contract_info>( + account: T::AccountId, + info: crate::ContractInfo, +) { let info = old::ContractInfo { trie_id: info.trie_id, code_hash: info.code_hash, @@ -79,7 +95,7 @@ pub fn store_old_contrat_info(account: T::AccountId, info: crate::Con storage_item_deposit: Default::default(), storage_base_deposit: Default::default(), }; - old::ContractInfoOf::::insert(account, info); + old::ContractInfoOf::::insert(account, info); } #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebugNoBound, TypeInfo, MaxEncodedLen)] @@ -96,28 +112,32 @@ impl Deref for DepositAccount { #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)] #[scale_info(skip_type_params(T))] -pub struct ContractInfo { +pub struct ContractInfo> { pub trie_id: TrieId, deposit_account: DepositAccount, pub code_hash: CodeHash, storage_bytes: u32, storage_items: u32, - pub storage_byte_deposit: BalanceOf, - storage_item_deposit: BalanceOf, - storage_base_deposit: BalanceOf, + pub storage_byte_deposit: old::BalanceOf, + storage_item_deposit: old::BalanceOf, + storage_base_deposit: old::BalanceOf, } #[derive(Encode, Decode, MaxEncodedLen, DefaultNoBound)] -pub struct Migration { +pub struct Migration> { last_key: Option>>, - _phantom: PhantomData, + _phantom: PhantomData<(T, Currency)>, } #[storage_alias] -type ContractInfoOf = - StorageMap, Twox64Concat, ::AccountId, ContractInfo>; - -impl Migrate for Migration { +type ContractInfoOf> = StorageMap< + Pallet, + Twox64Concat, + ::AccountId, + ContractInfo, +>; + +impl> Migrate for Migration { const VERSION: u16 = 10; fn max_step_weight() -> Weight { @@ -126,13 +146,15 @@ impl Migrate for Migration { fn step(&mut self) -> (IsFinished, Weight) { let mut iter = if let Some(last_key) = self.last_key.take() { - old::ContractInfoOf::::iter_from(last_key.to_vec()) + old::ContractInfoOf::::iter_from(last_key.to_vec()) } else { - old::ContractInfoOf::::iter() + old::ContractInfoOf::::iter() }; if let Some((account, contract)) = iter.next() { - let min_balance = Pallet::::min_balance(); + let min_balance = ::AccountId, + >>::minimum_balance(); log::debug!(target: LOG_TARGET, "Account: 0x{} ", HexDisplay::from(&account.encode())); // Store last key for next migration step @@ -150,7 +172,7 @@ impl Migrate for Migration { // Unreserve the existing deposit // Note we can't use repatriate_reserve, because it only works with existing accounts - let remaining = T::Currency::unreserve(&account, old_deposit); + let remaining = Currency::unreserve(&account, old_deposit); if !remaining.is_zero() { log::warn!( target: LOG_TARGET, @@ -163,9 +185,9 @@ impl Migrate for Migration { // Attempt to transfer the old deposit to the deposit account. let amount = old_deposit .saturating_sub(min_balance) - .min(T::Currency::reducible_balance(&account, Preserve, Polite)); + .min(Currency::reducible_balance(&account, Preserve, Polite)); - let new_deposit = T::Currency::transfer( + let new_deposit = Currency::transfer( &account, &deposit_account, amount, @@ -182,7 +204,7 @@ impl Migrate for Migration { // If it fails we fallback to minting the ED. .unwrap_or_else(|err| { log::error!(target: LOG_TARGET, "Failed to transfer ED, reason: {:?}", err); - T::Currency::deposit_creating(&deposit_account, min_balance); + Currency::deposit_creating(&deposit_account, min_balance); min_balance }); @@ -222,7 +244,7 @@ impl Migrate for Migration { storage_base_deposit, }; - ContractInfoOf::::insert(&account, new_contract_info); + ContractInfoOf::::insert(&account, new_contract_info); (IsFinished::No, T::WeightInfo::v10_migration_step()) } else { log::debug!(target: LOG_TARGET, "Done Migrating contract info"); @@ -232,7 +254,7 @@ impl Migrate for Migration { #[cfg(feature = "try-runtime")] fn pre_upgrade_step() -> Result, TryRuntimeError> { - let sample: Vec<_> = old::ContractInfoOf::::iter().take(10).collect(); + let sample: Vec<_> = old::ContractInfoOf::::iter().take(10).collect(); log::debug!(target: LOG_TARGET, "Taking sample of {} contracts", sample.len()); Ok(sample.encode()) @@ -240,14 +262,16 @@ impl Migrate for Migration { #[cfg(feature = "try-runtime")] fn post_upgrade_step(state: Vec) -> Result<(), TryRuntimeError> { - let sample = - )> as Decode>::decode(&mut &state[..]).unwrap(); + let sample = )> as Decode>::decode( + &mut &state[..], + ) + .unwrap(); log::debug!(target: LOG_TARGET, "Validating sample of {} contracts", sample.len()); for (account, old_contract) in sample { log::debug!(target: LOG_TARGET, "==="); log::debug!(target: LOG_TARGET, "Account: 0x{} ", HexDisplay::from(&account.encode())); - let contract = ContractInfoOf::::get(&account).unwrap(); + let contract = ContractInfoOf::::get(&account).unwrap(); ensure!(old_contract.trie_id == contract.trie_id, "invalid trie_id"); ensure!(old_contract.code_hash == contract.code_hash, "invalid code_hash"); ensure!(old_contract.storage_bytes == contract.storage_bytes, "invalid storage_bytes"); diff --git a/frame/contracts/src/storage/meter.rs b/frame/contracts/src/storage/meter.rs index 8687c698e3813..0d80e59c04c71 100644 --- a/frame/contracts/src/storage/meter.rs +++ b/frame/contracts/src/storage/meter.rs @@ -35,7 +35,7 @@ use frame_support::{ use pallet_contracts_primitives::StorageDeposit as Deposit; use sp_runtime::{ traits::{Saturating, Zero}, - FixedPointNumber, FixedU128, + FixedPointNumber, FixedPointOperand, FixedU128, }; use sp_std::{marker::PhantomData, vec::Vec}; @@ -157,7 +157,10 @@ impl Diff { /// In case `None` is passed for `info` only charges are calculated. This is because refunds /// are calculated pro rata of the existing storage within a contract and hence need extract /// this information from the passed `info`. - pub fn update_contract(&self, info: Option<&mut ContractInfo>) -> DepositOf { + pub fn update_contract(&self, info: Option<&mut ContractInfo>) -> DepositOf + where + BalanceOf: FixedPointOperand, + { let per_byte = T::DepositPerByte::get(); let per_item = T::DepositPerItem::get(); let bytes_added = self.bytes_added.saturating_sub(self.bytes_removed); @@ -252,7 +255,10 @@ enum Contribution { impl Contribution { /// See [`Diff::update_contract`]. - fn update_contract(&self, info: Option<&mut ContractInfo>) -> DepositOf { + fn update_contract(&self, info: Option<&mut ContractInfo>) -> DepositOf + where + BalanceOf: FixedPointOperand, + { match self { Self::Alive(diff) => diff.update_contract::(info), Self::Terminated(deposit) | Self::Checked(deposit) => deposit.clone(), @@ -311,7 +317,9 @@ where absorbed: RawMeter, deposit_account: DepositAccount, info: Option<&mut ContractInfo>, - ) { + ) where + BalanceOf: FixedPointOperand, + { let own_deposit = absorbed.own_contribution.update_contract(info); self.total_deposit = self .total_deposit From a103057293ecf16f8595d1d4f86d6b50ea3d63bd Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 6 Jun 2023 12:30:08 +0200 Subject: [PATCH 022/105] added FixedPointOperand to Balance trait --- frame/contracts/src/exec.rs | 34 +++++-------------------- frame/contracts/src/migration/v10.rs | 8 +++--- frame/contracts/src/storage/meter.rs | 16 +++--------- frame/support/src/traits/tokens/misc.rs | 17 ++++++++++--- 4 files changed, 29 insertions(+), 46 deletions(-) diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 450954cffb64b..15bc96bc58def 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -43,10 +43,7 @@ use sp_core::{ sr25519::{Public as SR25519Public, Signature as SR25519Signature}, }; use sp_io::{crypto::secp256k1_ecdsa_recover_compressed, hashing::blake2_256}; -use sp_runtime::{ - traits::{Convert, Hash, Zero}, - FixedPointOperand, -}; +use sp_runtime::traits::{Convert, Hash, Zero}; use sp_std::{marker::PhantomData, mem, prelude::*, vec::Vec}; pub type AccountIdOf = ::AccountId; @@ -148,9 +145,7 @@ pub trait Ext: sealing::Sealed { value: BalanceOf, input_data: Vec, allows_reentry: bool, - ) -> Result - where - BalanceOf: FixedPointOperand; + ) -> Result; /// Execute code in the current frame. /// @@ -636,10 +631,7 @@ where input_data: Vec, debug_message: Option<&'a mut DebugBufferVec>, determinism: Determinism, - ) -> Result - where - BalanceOf: FixedPointOperand, - { + ) -> Result { let (mut stack, executable) = Self::new( FrameArgs::Call { dest, cached_info: None, delegated_call: None }, origin, @@ -673,10 +665,7 @@ where input_data: Vec, salt: &[u8], debug_message: Option<&'a mut DebugBufferVec>, - ) -> Result<(T::AccountId, ExecReturnValue), ExecError> - where - BalanceOf: FixedPointOperand, - { + ) -> Result<(T::AccountId, ExecReturnValue), ExecError> { let (mut stack, executable) = Self::new( FrameArgs::Instantiate { sender: origin.clone(), @@ -853,10 +842,7 @@ where /// Run the current (top) frame. /// /// This can be either a call or an instantiate. - fn run(&mut self, executable: E, input_data: Vec) -> Result - where - BalanceOf: FixedPointOperand, - { + fn run(&mut self, executable: E, input_data: Vec) -> Result { let frame = self.top_frame(); let entry_point = frame.entry_point; let delegated_code_hash = @@ -980,10 +966,7 @@ where /// /// This is called after running the current frame. It commits cached values to storage /// and invalidates all stale references to it that might exist further down the call stack. - fn pop_frame(&mut self, persist: bool) - where - BalanceOf: FixedPointOperand, - { + fn pop_frame(&mut self, persist: bool) { // Revert changes to the nonce in case of a failed instantiation. if !persist && self.top_frame().entry_point == ExportedFunction::Constructor { self.nonce.as_mut().map(|c| *c = c.wrapping_sub(1)); @@ -1170,10 +1153,7 @@ where value: BalanceOf, input_data: Vec, allows_reentry: bool, - ) -> Result - where - BalanceOf: FixedPointOperand, - { + ) -> Result { // Before pushing the new frame: Protect the caller contract against reentrancy attacks. // It is important to do this before calling `allows_reentry` so that a direct recursion // is caught by it. diff --git a/frame/contracts/src/migration/v10.rs b/frame/contracts/src/migration/v10.rs index 3f4177334de40..24e27e78998e2 100644 --- a/frame/contracts/src/migration/v10.rs +++ b/frame/contracts/src/migration/v10.rs @@ -46,9 +46,9 @@ use sp_std::{marker::PhantomData, ops::Deref, prelude::*}; mod old { use super::*; - pub type BalanceOf> = ::AccountId, - >>::Balance; + pub type BalanceOf = ::AccountId, + >>::Balance; /// Old Currency type traits /// @@ -137,7 +137,7 @@ type ContractInfoOf> = StorageMap< ContractInfo, >; -impl> Migrate for Migration { +impl + 'static> Migrate for Migration { const VERSION: u16 = 10; fn max_step_weight() -> Weight { diff --git a/frame/contracts/src/storage/meter.rs b/frame/contracts/src/storage/meter.rs index 0d80e59c04c71..8687c698e3813 100644 --- a/frame/contracts/src/storage/meter.rs +++ b/frame/contracts/src/storage/meter.rs @@ -35,7 +35,7 @@ use frame_support::{ use pallet_contracts_primitives::StorageDeposit as Deposit; use sp_runtime::{ traits::{Saturating, Zero}, - FixedPointNumber, FixedPointOperand, FixedU128, + FixedPointNumber, FixedU128, }; use sp_std::{marker::PhantomData, vec::Vec}; @@ -157,10 +157,7 @@ impl Diff { /// In case `None` is passed for `info` only charges are calculated. This is because refunds /// are calculated pro rata of the existing storage within a contract and hence need extract /// this information from the passed `info`. - pub fn update_contract(&self, info: Option<&mut ContractInfo>) -> DepositOf - where - BalanceOf: FixedPointOperand, - { + pub fn update_contract(&self, info: Option<&mut ContractInfo>) -> DepositOf { let per_byte = T::DepositPerByte::get(); let per_item = T::DepositPerItem::get(); let bytes_added = self.bytes_added.saturating_sub(self.bytes_removed); @@ -255,10 +252,7 @@ enum Contribution { impl Contribution { /// See [`Diff::update_contract`]. - fn update_contract(&self, info: Option<&mut ContractInfo>) -> DepositOf - where - BalanceOf: FixedPointOperand, - { + fn update_contract(&self, info: Option<&mut ContractInfo>) -> DepositOf { match self { Self::Alive(diff) => diff.update_contract::(info), Self::Terminated(deposit) | Self::Checked(deposit) => deposit.clone(), @@ -317,9 +311,7 @@ where absorbed: RawMeter, deposit_account: DepositAccount, info: Option<&mut ContractInfo>, - ) where - BalanceOf: FixedPointOperand, - { + ) { let own_deposit = absorbed.own_contribution.update_contract(info); self.total_deposit = self .total_deposit diff --git a/frame/support/src/traits/tokens/misc.rs b/frame/support/src/traits/tokens/misc.rs index baf3fd5f35464..3bbe0a1d52ee0 100644 --- a/frame/support/src/traits/tokens/misc.rs +++ b/frame/support/src/traits/tokens/misc.rs @@ -18,7 +18,10 @@ //! Miscellaneous types. use codec::{Decode, Encode, FullCodec, MaxEncodedLen}; -use sp_arithmetic::traits::{AtLeast32BitUnsigned, Zero}; +use sp_arithmetic::{ + traits::{AtLeast32BitUnsigned, Zero}, + FixedPointOperand, +}; use sp_core::RuntimeDebug; use sp_runtime::{traits::Convert, ArithmeticError, DispatchError, TokenError}; use sp_std::fmt::Debug; @@ -231,7 +234,14 @@ impl Balance for T { } From 5c1452917a195413ce28137ef9176937865e72da Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 6 Jun 2023 13:13:05 +0200 Subject: [PATCH 023/105] move migrate sequence to config --- bin/node/runtime/src/lib.rs | 4 +++- frame/contracts/src/benchmarking/mod.rs | 10 ++++----- frame/contracts/src/lib.rs | 29 ++++++++++++++----------- frame/contracts/src/migration.rs | 25 +++++++-------------- frame/contracts/src/tests.rs | 5 +++-- 5 files changed, 35 insertions(+), 38 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 6dc9841f6b44f..33ffe6d4f32cc 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -55,6 +55,7 @@ use frame_system::{ pub use node_primitives::{AccountId, Signature}; use node_primitives::{AccountIndex, Balance, BlockNumber, Hash, Index, Moment}; use pallet_asset_conversion::{NativeOrAssetId, NativeOrAssetIdConverter}; +use pallet_contracts::migration::{v10, v11, v9}; use pallet_election_provider_multi_phase::SolutionAccuracyOf; use pallet_im_online::sr25519::AuthorityId as ImOnlineId; use pallet_nfts::PalletFeatures; @@ -1240,6 +1241,7 @@ impl pallet_contracts::Config for Runtime { type MaxStorageKeyLen = ConstU32<128>; type UnsafeUnstableInterface = ConstBool; type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>; + type Migrations = (v9::Migration, v10::Migration, v11::Migration); } impl pallet_sudo::Config for Runtime { @@ -1981,7 +1983,7 @@ pub type Executive = frame_executive::Executive< type Migrations = ( pallet_nomination_pools::migration::v2::MigrateToV2, pallet_alliance::migration::Migration, - pallet_contracts::Migration, + pallet_contracts::Migration::Migrations>, ); type EventRecord = frame_system::EventRecord< diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index b98c05f2503c2..27b9aadeed675 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -272,7 +272,7 @@ benchmarks! { migration_noop { assert_eq!(StorageVersion::get::>(), 2); }: { - Migration::::migrate(Weight::MAX) + Migration::::migrate(Weight::MAX) } verify { assert_eq!(StorageVersion::get::>(), 2); } @@ -281,7 +281,7 @@ benchmarks! { #[pov_mode = Measured] migrate { StorageVersion::new(0).put::>(); - as frame_support::traits::OnRuntimeUpgrade>::on_runtime_upgrade(); + as frame_support::traits::OnRuntimeUpgrade>::on_runtime_upgrade(); let origin: RawOrigin<::AccountId> = RawOrigin::Signed(whitelisted_caller()); }: { >::migrate(origin.into(), Weight::MAX).unwrap() @@ -294,7 +294,7 @@ benchmarks! { on_runtime_upgrade_noop { assert_eq!(StorageVersion::get::>(), 2); }: { - as frame_support::traits::OnRuntimeUpgrade>::on_runtime_upgrade() + as frame_support::traits::OnRuntimeUpgrade>::on_runtime_upgrade() } verify { assert!(MigrationInProgress::::get().is_none()); } @@ -306,7 +306,7 @@ benchmarks! { let v = vec![42u8].try_into().ok(); MigrationInProgress::::set(v.clone()); }: { - as frame_support::traits::OnRuntimeUpgrade>::on_runtime_upgrade() + as frame_support::traits::OnRuntimeUpgrade>::on_runtime_upgrade() } verify { assert!(MigrationInProgress::::get().is_some()); assert_eq!(MigrationInProgress::::get(), v); @@ -317,7 +317,7 @@ benchmarks! { on_runtime_upgrade { StorageVersion::new(0).put::>(); }: { - as frame_support::traits::OnRuntimeUpgrade>::on_runtime_upgrade() + as frame_support::traits::OnRuntimeUpgrade>::on_runtime_upgrade() } verify { assert!(MigrationInProgress::::get().is_some()); } diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 779b713795b64..fa0a95d2ffebb 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -87,12 +87,12 @@ mod address; mod benchmarking; mod exec; mod gas; -mod migration; mod schedule; mod storage; mod wasm; pub mod chain_extension; +pub mod migration; pub mod weights; #[cfg(test)] @@ -319,6 +319,9 @@ pub mod pallet { /// The maximum length of the debug buffer in bytes. #[pallet::constant] type MaxDebugBufferLen: Get; + + /// The sequence of migrations applied. + type Migrations: MigrateSequence; } #[pallet::hooks] @@ -326,7 +329,7 @@ pub mod pallet { fn on_idle(_block: T::BlockNumber, remaining_weight: Weight) -> Weight { use migration::MigrateResult::*; - let (result, weight) = Migration::::migrate(remaining_weight); + let (result, weight) = Migration::::migrate(remaining_weight); let remaining_weight = remaining_weight.saturating_sub(weight); if !matches!(result, Completed | NoMigrationInProgress) { @@ -338,7 +341,7 @@ pub mod pallet { } fn integrity_test() { - Migration::::integrity_test(); + Migration::::integrity_test(); // Total runtime memory limit let max_runtime_mem: u32 = T::Schedule::get().limits.runtime_memory; @@ -518,7 +521,7 @@ pub mod pallet { storage_deposit_limit: Option< as codec::HasCompact>::Type>, determinism: Determinism, ) -> DispatchResult { - Migration::::ensure_migrated()?; + Migration::::ensure_migrated()?; let origin = ensure_signed(origin)?; Self::bare_upload_code(origin, code, storage_deposit_limit.map(Into::into), determinism) .map(|_| ()) @@ -534,7 +537,7 @@ pub mod pallet { origin: OriginFor, code_hash: CodeHash, ) -> DispatchResultWithPostInfo { - Migration::::ensure_migrated()?; + Migration::::ensure_migrated()?; let origin = ensure_signed(origin)?; >::remove(&origin, code_hash)?; // we waive the fee because removing unused code is beneficial @@ -558,7 +561,7 @@ pub mod pallet { dest: AccountIdLookupOf, code_hash: CodeHash, ) -> DispatchResult { - Migration::::ensure_migrated()?; + Migration::::ensure_migrated()?; ensure_root(origin)?; let dest = T::Lookup::lookup(dest)?; >::try_mutate(&dest, |contract| { @@ -608,7 +611,7 @@ pub mod pallet { storage_deposit_limit: Option< as codec::HasCompact>::Type>, data: Vec, ) -> DispatchResultWithPostInfo { - Migration::::ensure_migrated()?; + Migration::::ensure_migrated()?; let common = CommonInput { origin: Origin::from_runtime_origin(origin)?, value, @@ -668,7 +671,7 @@ pub mod pallet { data: Vec, salt: Vec, ) -> DispatchResultWithPostInfo { - Migration::::ensure_migrated()?; + Migration::::ensure_migrated()?; let code_len = code.len() as u32; let data_len = data.len() as u32; let salt_len = salt.len() as u32; @@ -711,7 +714,7 @@ pub mod pallet { data: Vec, salt: Vec, ) -> DispatchResultWithPostInfo { - Migration::::ensure_migrated()?; + Migration::::ensure_migrated()?; let data_len = data.len() as u32; let salt_len = salt.len() as u32; let common = CommonInput { @@ -746,7 +749,7 @@ pub mod pallet { ensure_signed(origin)?; let weight_limit = weight_limit.saturating_add(T::WeightInfo::migrate()); - let (result, weight) = Migration::::migrate(weight_limit); + let (result, weight) = Migration::::migrate(weight_limit); match result { Completed => @@ -1272,7 +1275,7 @@ impl Invokable for InstantiateInput { macro_rules! ensure_no_migration_in_progress { () => { - if Migration::::in_progress() { + if Migration::::in_progress() { return ContractResult { gas_consumed: Zero::zero(), gas_required: Zero::zero(), @@ -1412,7 +1415,7 @@ impl Pallet { storage_deposit_limit: Option>, determinism: Determinism, ) -> CodeUploadResult, BalanceOf> { - Migration::::ensure_migrated()?; + Migration::::ensure_migrated()?; let schedule = T::Schedule::get(); let module = PrefabWasmModule::from_code( code, @@ -1433,7 +1436,7 @@ impl Pallet { /// Query storage of a specified contract under a specified key. pub fn get_storage(address: T::AccountId, key: Vec) -> GetStorageResult { - if Migration::::in_progress() { + if Migration::::in_progress() { return Err(ContractAccessError::MigrationInProgress) } let contract_info = diff --git a/frame/contracts/src/migration.rs b/frame/contracts/src/migration.rs index a75d5cc1a1f4d..c13c5f4681f50 100644 --- a/frame/contracts/src/migration.rs +++ b/frame/contracts/src/migration.rs @@ -18,15 +18,10 @@ //! Migration framework for pallets. /// Macro to include all migration modules. -/// We only want to make these modules public when `runtime-benchmarks` is -/// enabled, so we can access migration code in benchmarks. macro_rules! use_modules { ($($module:ident),*) => { $( - #[cfg(feature = "runtime-benchmarks")] pub mod $module; - #[cfg(not(feature = "runtime-benchmarks"))] - mod $module; )* }; } @@ -58,10 +53,6 @@ fn invalid_version(version: StorageVersion) -> ! { /// The cursor used to store the state of the current migration step. pub type Cursor = BoundedVec>; -// In benchmark and tests we use noop migrations, to test and bench the migration framework itself. -#[cfg(not(any(feature = "runtime-benchmarks", test)))] -type Migrations = (v9::Migration, v10::Migration, v11::Migration); - /// IsFinished describes whether a migration is finished or not. pub enum IsFinished { Yes, @@ -206,14 +197,14 @@ pub trait MigrateSequence: private::Sealed { } /// Performs all necessary migrations based on `StorageVersion`. -#[cfg(not(any(feature = "runtime-benchmarks", test)))] -pub struct Migration>(PhantomData<(T, M)>); - -/// Custom migration for running runtime-benchmarks and tests. -#[cfg(any(feature = "runtime-benchmarks", test))] -pub struct Migration, NoopMigration<2>)>( - PhantomData<(T, M)>, -); +// #[cfg(not(any(feature = "runtime-benchmarks", test)))] +pub struct Migration(PhantomData<(T, M)>); + +// /// Custom migration for running runtime-benchmarks and tests. +// #[cfg(any(feature = "runtime-benchmarks", test))] +// pub struct Migration, NoopMigration<2>)>( +// PhantomData<(T, M)>, +// ); #[cfg(feature = "try-runtime")] impl Migration { diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index d23a238dcd158..9425f25adf4b8 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -28,8 +28,8 @@ use crate::{ wasm::{Determinism, PrefabWasmModule, ReturnCode as RuntimeReturnCode}, weights::WeightInfo, BalanceOf, Code, CodeStorage, CollectEvents, Config, ContractInfo, ContractInfoOf, DebugInfo, - DefaultAddressGenerator, DeletionQueueCounter, Error, MigrationInProgress, Origin, Pallet, - Schedule, + DefaultAddressGenerator, DeletionQueueCounter, Error, MigrationInProgress, NoopMigration, + Origin, Pallet, Schedule, }; use assert_matches::assert_matches; use codec::Encode; @@ -428,6 +428,7 @@ impl Config for Test { type MaxStorageKeyLen = ConstU32<128>; type UnsafeUnstableInterface = UnstableInterface; type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>; + type Migrations = (NoopMigration<1>, NoopMigration<2>); } pub const ALICE: AccountId32 = AccountId32::new([1u8; 32]); From e8c493cecdef218476a5a6ce78ce678140996132 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 6 Jun 2023 13:19:31 +0200 Subject: [PATCH 024/105] remove commented out code --- frame/contracts/src/migration.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/frame/contracts/src/migration.rs b/frame/contracts/src/migration.rs index c13c5f4681f50..ec8a67c755c48 100644 --- a/frame/contracts/src/migration.rs +++ b/frame/contracts/src/migration.rs @@ -197,15 +197,8 @@ pub trait MigrateSequence: private::Sealed { } /// Performs all necessary migrations based on `StorageVersion`. -// #[cfg(not(any(feature = "runtime-benchmarks", test)))] pub struct Migration(PhantomData<(T, M)>); -// /// Custom migration for running runtime-benchmarks and tests. -// #[cfg(any(feature = "runtime-benchmarks", test))] -// pub struct Migration, NoopMigration<2>)>( -// PhantomData<(T, M)>, -// ); - #[cfg(feature = "try-runtime")] impl Migration { fn run_all_steps() -> Result<(), TryRuntimeError> { From 0e629301500114775c71e7e01cf039ed0c5ebb2e Mon Sep 17 00:00:00 2001 From: Juan Date: Tue, 6 Jun 2023 13:41:50 +0200 Subject: [PATCH 025/105] Update frame/contracts/src/lib.rs Co-authored-by: PG Herveou --- 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 fa0a95d2ffebb..118ccca94206c 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -320,7 +320,7 @@ pub mod pallet { #[pallet::constant] type MaxDebugBufferLen: Get; - /// The sequence of migrations applied. + /// The sequence of migration steps that will be applied during a migration. type Migrations: MigrateSequence; } From 14a71755cfb5546c4e78f5fdd6cf54ac1134d9b7 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 6 Jun 2023 14:01:59 +0200 Subject: [PATCH 026/105] remove Migrations generic --- bin/node/runtime/src/lib.rs | 2 +- frame/contracts/src/benchmarking/mod.rs | 10 +- frame/contracts/src/lib.rs | 24 ++--- frame/contracts/src/migration.rs | 118 ++++++++++++------------ 4 files changed, 79 insertions(+), 75 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 33ffe6d4f32cc..dd2accb086a43 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1983,7 +1983,7 @@ pub type Executive = frame_executive::Executive< type Migrations = ( pallet_nomination_pools::migration::v2::MigrateToV2, pallet_alliance::migration::Migration, - pallet_contracts::Migration::Migrations>, + pallet_contracts::Migration, ); type EventRecord = frame_system::EventRecord< diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 27b9aadeed675..b98c05f2503c2 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -272,7 +272,7 @@ benchmarks! { migration_noop { assert_eq!(StorageVersion::get::>(), 2); }: { - Migration::::migrate(Weight::MAX) + Migration::::migrate(Weight::MAX) } verify { assert_eq!(StorageVersion::get::>(), 2); } @@ -281,7 +281,7 @@ benchmarks! { #[pov_mode = Measured] migrate { StorageVersion::new(0).put::>(); - as frame_support::traits::OnRuntimeUpgrade>::on_runtime_upgrade(); + as frame_support::traits::OnRuntimeUpgrade>::on_runtime_upgrade(); let origin: RawOrigin<::AccountId> = RawOrigin::Signed(whitelisted_caller()); }: { >::migrate(origin.into(), Weight::MAX).unwrap() @@ -294,7 +294,7 @@ benchmarks! { on_runtime_upgrade_noop { assert_eq!(StorageVersion::get::>(), 2); }: { - as frame_support::traits::OnRuntimeUpgrade>::on_runtime_upgrade() + as frame_support::traits::OnRuntimeUpgrade>::on_runtime_upgrade() } verify { assert!(MigrationInProgress::::get().is_none()); } @@ -306,7 +306,7 @@ benchmarks! { let v = vec![42u8].try_into().ok(); MigrationInProgress::::set(v.clone()); }: { - as frame_support::traits::OnRuntimeUpgrade>::on_runtime_upgrade() + as frame_support::traits::OnRuntimeUpgrade>::on_runtime_upgrade() } verify { assert!(MigrationInProgress::::get().is_some()); assert_eq!(MigrationInProgress::::get(), v); @@ -317,7 +317,7 @@ benchmarks! { on_runtime_upgrade { StorageVersion::new(0).put::>(); }: { - as frame_support::traits::OnRuntimeUpgrade>::on_runtime_upgrade() + as frame_support::traits::OnRuntimeUpgrade>::on_runtime_upgrade() } verify { assert!(MigrationInProgress::::get().is_some()); } diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 118ccca94206c..59c9ea23ed38b 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -329,7 +329,7 @@ pub mod pallet { fn on_idle(_block: T::BlockNumber, remaining_weight: Weight) -> Weight { use migration::MigrateResult::*; - let (result, weight) = Migration::::migrate(remaining_weight); + let (result, weight) = Migration::::migrate(remaining_weight); let remaining_weight = remaining_weight.saturating_sub(weight); if !matches!(result, Completed | NoMigrationInProgress) { @@ -341,7 +341,7 @@ pub mod pallet { } fn integrity_test() { - Migration::::integrity_test(); + Migration::::integrity_test(); // Total runtime memory limit let max_runtime_mem: u32 = T::Schedule::get().limits.runtime_memory; @@ -521,7 +521,7 @@ pub mod pallet { storage_deposit_limit: Option< as codec::HasCompact>::Type>, determinism: Determinism, ) -> DispatchResult { - Migration::::ensure_migrated()?; + Migration::::ensure_migrated()?; let origin = ensure_signed(origin)?; Self::bare_upload_code(origin, code, storage_deposit_limit.map(Into::into), determinism) .map(|_| ()) @@ -537,7 +537,7 @@ pub mod pallet { origin: OriginFor, code_hash: CodeHash, ) -> DispatchResultWithPostInfo { - Migration::::ensure_migrated()?; + Migration::::ensure_migrated()?; let origin = ensure_signed(origin)?; >::remove(&origin, code_hash)?; // we waive the fee because removing unused code is beneficial @@ -561,7 +561,7 @@ pub mod pallet { dest: AccountIdLookupOf, code_hash: CodeHash, ) -> DispatchResult { - Migration::::ensure_migrated()?; + Migration::::ensure_migrated()?; ensure_root(origin)?; let dest = T::Lookup::lookup(dest)?; >::try_mutate(&dest, |contract| { @@ -611,7 +611,7 @@ pub mod pallet { storage_deposit_limit: Option< as codec::HasCompact>::Type>, data: Vec, ) -> DispatchResultWithPostInfo { - Migration::::ensure_migrated()?; + Migration::::ensure_migrated()?; let common = CommonInput { origin: Origin::from_runtime_origin(origin)?, value, @@ -671,7 +671,7 @@ pub mod pallet { data: Vec, salt: Vec, ) -> DispatchResultWithPostInfo { - Migration::::ensure_migrated()?; + Migration::::ensure_migrated()?; let code_len = code.len() as u32; let data_len = data.len() as u32; let salt_len = salt.len() as u32; @@ -714,7 +714,7 @@ pub mod pallet { data: Vec, salt: Vec, ) -> DispatchResultWithPostInfo { - Migration::::ensure_migrated()?; + Migration::::ensure_migrated()?; let data_len = data.len() as u32; let salt_len = salt.len() as u32; let common = CommonInput { @@ -749,7 +749,7 @@ pub mod pallet { ensure_signed(origin)?; let weight_limit = weight_limit.saturating_add(T::WeightInfo::migrate()); - let (result, weight) = Migration::::migrate(weight_limit); + let (result, weight) = Migration::::migrate(weight_limit); match result { Completed => @@ -1275,7 +1275,7 @@ impl Invokable for InstantiateInput { macro_rules! ensure_no_migration_in_progress { () => { - if Migration::::in_progress() { + if Migration::::in_progress() { return ContractResult { gas_consumed: Zero::zero(), gas_required: Zero::zero(), @@ -1415,7 +1415,7 @@ impl Pallet { storage_deposit_limit: Option>, determinism: Determinism, ) -> CodeUploadResult, BalanceOf> { - Migration::::ensure_migrated()?; + Migration::::ensure_migrated()?; let schedule = T::Schedule::get(); let module = PrefabWasmModule::from_code( code, @@ -1436,7 +1436,7 @@ impl Pallet { /// Query storage of a specified contract under a specified key. pub fn get_storage(address: T::AccountId, key: Vec) -> GetStorageResult { - if Migration::::in_progress() { + if Migration::::in_progress() { return Err(ContractAccessError::MigrationInProgress) } let contract_info = diff --git a/frame/contracts/src/migration.rs b/frame/contracts/src/migration.rs index ec8a67c755c48..ad85da0477148 100644 --- a/frame/contracts/src/migration.rs +++ b/frame/contracts/src/migration.rs @@ -17,16 +17,10 @@ //! Migration framework for pallets. -/// Macro to include all migration modules. -macro_rules! use_modules { - ($($module:ident),*) => { - $( - pub mod $module; - )* - }; -} +pub mod v10; +pub mod v11; +pub mod v9; -use_modules!(v9, v10, v11); use crate::{weights::WeightInfo, Config, Error, MigrationInProgress, Pallet, Weight, LOG_TARGET}; use codec::{Codec, Decode}; use frame_support::{ @@ -197,16 +191,16 @@ pub trait MigrateSequence: private::Sealed { } /// Performs all necessary migrations based on `StorageVersion`. -pub struct Migration(PhantomData<(T, M)>); +pub struct Migration(PhantomData); #[cfg(feature = "try-runtime")] -impl Migration { +impl Migration { fn run_all_steps() -> Result<(), TryRuntimeError> { let mut weight = Weight::zero(); let name = >::name(); loop { let in_progress_version = >::on_chain_storage_version() + 1; - let state = M::pre_upgrade_step(in_progress_version)?; + let state = T::Migrations::pre_upgrade_step(in_progress_version)?; let (status, w) = Self::migrate(Weight::MAX); weight.saturating_accrue(w); log::info!( @@ -215,7 +209,7 @@ impl Migration { in_progress_version, weight ); - M::post_upgrade_step(in_progress_version, state)?; + T::Migrations::post_upgrade_step(in_progress_version, state)?; if matches!(status, MigrateResult::Completed) { break } @@ -227,7 +221,7 @@ impl Migration { } } -impl OnRuntimeUpgrade for Migration { +impl OnRuntimeUpgrade for Migration { fn on_runtime_upgrade() -> Weight { let name = >::name(); let latest_version = >::current_storage_version(); @@ -258,7 +252,7 @@ impl OnRuntimeUpgrade for Migration { "{name}: Upgrading storage from {storage_version:?} to {latest_version:?}.", ); - let cursor = M::new(storage_version + 1); + let cursor = T::Migrations::new(storage_version + 1); MigrationInProgress::::set(Some(cursor)); #[cfg(feature = "try-runtime")] @@ -279,11 +273,14 @@ impl OnRuntimeUpgrade for Migration { target: LOG_TARGET, "{}: Range supported {:?}, range requested {:?}", >::name(), - M::VERSION_RANGE, + T::Migrations::VERSION_RANGE, (storage_version, target_version) ); - ensure!(M::is_upgrade_supported(storage_version, target_version), "Unsupported upgrade"); + ensure!( + T::Migrations::is_upgrade_supported(storage_version, target_version), + "Unsupported upgrade" + ); Ok(Default::default()) } } @@ -308,11 +305,11 @@ pub enum StepResult { Completed { steps_done: u32 }, } -impl Migration { - /// Verify that each migration's step of the MigrateSequence fits into `Cursor`. +impl Migration { + /// Verify that each migration's step of the [`T::Migrations`] sequence fits into `Cursor`. pub(crate) fn integrity_test() { let max_weight = ::BlockWeights::get().max_block; - M::integrity_test(max_weight) + T::Migrations::integrity_test(max_weight) } /// Migrate @@ -341,33 +338,36 @@ impl Migration { in_progress_version, ); - let result = - match M::steps(in_progress_version, cursor_before.as_ref(), &mut weight_left) { - StepResult::InProgress { cursor, steps_done } => { - *progress = Some(cursor); + let result = match T::Migrations::steps( + in_progress_version, + cursor_before.as_ref(), + &mut weight_left, + ) { + StepResult::InProgress { cursor, steps_done } => { + *progress = Some(cursor); + MigrateResult::InProgress { steps_done } + }, + StepResult::Completed { steps_done } => { + in_progress_version.put::>(); + if >::current_storage_version() != in_progress_version { + log::info!( + target: LOG_TARGET, + "{name}: Next migration is {:?},", + in_progress_version + 1 + ); + *progress = Some(T::Migrations::new(in_progress_version + 1)); MigrateResult::InProgress { steps_done } - }, - StepResult::Completed { steps_done } => { - in_progress_version.put::>(); - if >::current_storage_version() != in_progress_version { - log::info!( - target: LOG_TARGET, - "{name}: Next migration is {:?},", - in_progress_version + 1 - ); - *progress = Some(M::new(in_progress_version + 1)); - MigrateResult::InProgress { steps_done } - } else { - log::info!( - target: LOG_TARGET, - "{name}: All migrations done. At version {:?},", - in_progress_version - ); - *progress = None; - MigrateResult::Completed - } - }, - }; + } else { + log::info!( + target: LOG_TARGET, + "{name}: All migrations done. At version {:?},", + in_progress_version + ); + *progress = None; + MigrateResult::Completed + } + }, + }; (result, weight_limit.saturating_sub(weight_left)) }) @@ -511,11 +511,14 @@ mod test { #[test] fn is_upgrade_supported_works() { - type M = (MockMigration<9>, MockMigration<10>, MockMigration<11>); + type Migrations = (MockMigration<9>, MockMigration<10>, MockMigration<11>); [(1, 1), (8, 11), (9, 11)].into_iter().for_each(|(from, to)| { assert!( - M::is_upgrade_supported(StorageVersion::new(from), StorageVersion::new(to)), + Migrations::is_upgrade_supported( + StorageVersion::new(from), + StorageVersion::new(to) + ), "{} -> {} is supported", from, to @@ -524,7 +527,10 @@ mod test { [(1, 0), (0, 3), (7, 11), (8, 10)].into_iter().for_each(|(from, to)| { assert!( - !M::is_upgrade_supported(StorageVersion::new(from), StorageVersion::new(to)), + !Migrations::is_upgrade_supported( + StorageVersion::new(from), + StorageVersion::new(to) + ), "{} -> {} is not supported", from, to @@ -534,27 +540,26 @@ mod test { #[test] fn steps_works() { - type M = (MockMigration<2>, MockMigration<3>); + type Migrations = (MockMigration<2>, MockMigration<3>); let version = StorageVersion::new(2); - let mut cursor = M::new(version); + let mut cursor = Migrations::new(version); let mut weight = Weight::from_all(2); - let result = M::steps(version, &cursor, &mut weight); + let result = Migrations::steps(version, &cursor, &mut weight); cursor = vec![1u8, 0].try_into().unwrap(); assert_eq!(result, StepResult::InProgress { cursor: cursor.clone(), steps_done: 1 }); assert_eq!(weight, Weight::from_all(1)); let mut weight = Weight::from_all(2); assert_eq!( - M::steps(version, &cursor, &mut weight), + Migrations::steps(version, &cursor, &mut weight), StepResult::Completed { steps_done: 1 } ); } #[test] fn no_migration_in_progress_works() { - type M = (MockMigration<1>, MockMigration<2>); - type TestMigration = Migration; + type TestMigration = Migration; ExtBuilder::default().build().execute_with(|| { assert_eq!(StorageVersion::get::>(), 2); @@ -564,8 +569,7 @@ mod test { #[test] fn migration_works() { - type M = (MockMigration<1>, MockMigration<2>); - type TestMigration = Migration; + type TestMigration = Migration; ExtBuilder::default().set_storage_version(0).build().execute_with(|| { assert_eq!(StorageVersion::get::>(), 0); From 2601d79a37c70fde3d81e891957d9b5d0f946a1c Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 6 Jun 2023 17:11:59 +0200 Subject: [PATCH 027/105] make runtime use noop migrations --- bin/node/runtime/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index dd2accb086a43..dd4b14b1889b5 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -55,7 +55,7 @@ use frame_system::{ pub use node_primitives::{AccountId, Signature}; use node_primitives::{AccountIndex, Balance, BlockNumber, Hash, Index, Moment}; use pallet_asset_conversion::{NativeOrAssetId, NativeOrAssetIdConverter}; -use pallet_contracts::migration::{v10, v11, v9}; +use pallet_contracts::NoopMigration; use pallet_election_provider_multi_phase::SolutionAccuracyOf; use pallet_im_online::sr25519::AuthorityId as ImOnlineId; use pallet_nfts::PalletFeatures; @@ -1241,7 +1241,7 @@ impl pallet_contracts::Config for Runtime { type MaxStorageKeyLen = ConstU32<128>; type UnsafeUnstableInterface = ConstBool; type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>; - type Migrations = (v9::Migration, v10::Migration, v11::Migration); + type Migrations = (NoopMigration<1>, NoopMigration<2>); } impl pallet_sudo::Config for Runtime { From e88854a39dbbd133b647b0b5ca9ede0a525b0bbe Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 6 Jun 2023 17:30:01 +0200 Subject: [PATCH 028/105] restrict is_upgrade_supported --- frame/contracts/src/migration.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frame/contracts/src/migration.rs b/frame/contracts/src/migration.rs index ad85da0477148..ce0e018f0ac3d 100644 --- a/frame/contracts/src/migration.rs +++ b/frame/contracts/src/migration.rs @@ -186,7 +186,7 @@ pub trait MigrateSequence: private::Sealed { return false }; - in_storage >= first_supported && target == high + in_storage == first_supported && target == high } } @@ -513,7 +513,7 @@ mod test { fn is_upgrade_supported_works() { type Migrations = (MockMigration<9>, MockMigration<10>, MockMigration<11>); - [(1, 1), (8, 11), (9, 11)].into_iter().for_each(|(from, to)| { + [(1, 1), (8, 11)].into_iter().for_each(|(from, to)| { assert!( Migrations::is_upgrade_supported( StorageVersion::new(from), @@ -525,7 +525,7 @@ mod test { ) }); - [(1, 0), (0, 3), (7, 11), (8, 10)].into_iter().for_each(|(from, to)| { + [(1, 0), (0, 3), (7, 11), (8, 10), (9, 11)].into_iter().for_each(|(from, to)| { assert!( !Migrations::is_upgrade_supported( StorageVersion::new(from), From 1400ab05eb3452b534d5999e82dd8f4fc528913b Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Wed, 7 Jun 2023 11:51:57 +0200 Subject: [PATCH 029/105] undo is_upgrade_supported change --- frame/contracts/src/migration.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frame/contracts/src/migration.rs b/frame/contracts/src/migration.rs index ce0e018f0ac3d..ad85da0477148 100644 --- a/frame/contracts/src/migration.rs +++ b/frame/contracts/src/migration.rs @@ -186,7 +186,7 @@ pub trait MigrateSequence: private::Sealed { return false }; - in_storage == first_supported && target == high + in_storage >= first_supported && target == high } } @@ -513,7 +513,7 @@ mod test { fn is_upgrade_supported_works() { type Migrations = (MockMigration<9>, MockMigration<10>, MockMigration<11>); - [(1, 1), (8, 11)].into_iter().for_each(|(from, to)| { + [(1, 1), (8, 11), (9, 11)].into_iter().for_each(|(from, to)| { assert!( Migrations::is_upgrade_supported( StorageVersion::new(from), @@ -525,7 +525,7 @@ mod test { ) }); - [(1, 0), (0, 3), (7, 11), (8, 10), (9, 11)].into_iter().for_each(|(from, to)| { + [(1, 0), (0, 3), (7, 11), (8, 10)].into_iter().for_each(|(from, to)| { assert!( !Migrations::is_upgrade_supported( StorageVersion::new(from), From cc7609c9275d1fa03fde4d5b139100777bc4b96b Mon Sep 17 00:00:00 2001 From: Juan Date: Wed, 7 Jun 2023 14:14:43 +0200 Subject: [PATCH 030/105] Update bin/node/runtime/src/lib.rs Co-authored-by: PG Herveou --- bin/node/runtime/src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index dd4b14b1889b5..a5fe7465a3818 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1241,6 +1241,9 @@ impl pallet_contracts::Config for Runtime { type MaxStorageKeyLen = ConstU32<128>; type UnsafeUnstableInterface = ConstBool; type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>; + #[cfg(not(feature = "runtime-benchmarks"))] + type Migrations = (); + #[cfg(feature = "runtime-benchmarks")] type Migrations = (NoopMigration<1>, NoopMigration<2>); } From c173ad7e2751099212aa18c49d7d6794c451e224 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Wed, 7 Jun 2023 15:38:06 +0200 Subject: [PATCH 031/105] add rust doc example for `Migrations` --- frame/contracts/src/lib.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 59c9ea23ed38b..d3bb0aa866a0a 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -321,6 +321,13 @@ pub mod pallet { type MaxDebugBufferLen: Get; /// The sequence of migration steps that will be applied during a migration. + /// + /// # Examples + /// ```ignore + /// impl pallet_contracts::Config for Runtime { + /// // ... + /// type Migrations = (v9::Migration, v10::Migration, v11::Migration); + /// ``` type Migrations: MigrateSequence; } From c9cf9c682be7056c718e524caea6a10424cb98a3 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Wed, 7 Jun 2023 15:58:16 +0200 Subject: [PATCH 032/105] feature gate NoopMigration --- bin/node/runtime/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index a5fe7465a3818..aad86b28de32f 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -55,6 +55,7 @@ use frame_system::{ pub use node_primitives::{AccountId, Signature}; use node_primitives::{AccountIndex, Balance, BlockNumber, Hash, Index, Moment}; use pallet_asset_conversion::{NativeOrAssetId, NativeOrAssetIdConverter}; +#[cfg(feature = "runtime-benchmarks")] use pallet_contracts::NoopMigration; use pallet_election_provider_multi_phase::SolutionAccuracyOf; use pallet_im_online::sr25519::AuthorityId as ImOnlineId; @@ -1241,9 +1242,9 @@ impl pallet_contracts::Config for Runtime { type MaxStorageKeyLen = ConstU32<128>; type UnsafeUnstableInterface = ConstBool; type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>; - #[cfg(not(feature = "runtime-benchmarks"))] + #[cfg(not(feature = "runtime-benchmarks"))] type Migrations = (); - #[cfg(feature = "runtime-benchmarks")] + #[cfg(feature = "runtime-benchmarks")] type Migrations = (NoopMigration<1>, NoopMigration<2>); } From de545a3b9ecdd17a191ead0950087ffe8c28554f Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Wed, 7 Jun 2023 16:17:49 +0200 Subject: [PATCH 033/105] fix example code --- frame/contracts/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index d3bb0aa866a0a..3a30b3ce1eeb7 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -327,6 +327,8 @@ pub mod pallet { /// impl pallet_contracts::Config for Runtime { /// // ... /// type Migrations = (v9::Migration, v10::Migration, v11::Migration); + /// // ... + /// } /// ``` type Migrations: MigrateSequence; } From 62bec961fdf9ee09e59d8b481ba9df0fb0df46f3 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 8 Jun 2023 09:36:50 +0200 Subject: [PATCH 034/105] improve example --- frame/contracts/src/lib.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 3a30b3ce1eeb7..42691d4b01dc7 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -323,12 +323,10 @@ pub mod pallet { /// The sequence of migration steps that will be applied during a migration. /// /// # Examples - /// ```ignore - /// impl pallet_contracts::Config for Runtime { - /// // ... - /// type Migrations = (v9::Migration, v10::Migration, v11::Migration); - /// // ... - /// } + /// ``` + /// use pallet_contracts::migration::{v9, v10, v11}; + /// # struct Runtime {}; + /// type Migrations = (v9::Migration, v10::Migration, v11::Migration); /// ``` type Migrations: MigrateSequence; } From f446edced72cf56dc6df89a43eb1d6ad08915192 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 8 Jun 2023 20:04:43 +0200 Subject: [PATCH 035/105] wip --- frame/contracts/src/migration.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/frame/contracts/src/migration.rs b/frame/contracts/src/migration.rs index 6c527ee5c5fca..697529bbc5622 100644 --- a/frame/contracts/src/migration.rs +++ b/frame/contracts/src/migration.rs @@ -58,10 +58,6 @@ fn invalid_version(version: StorageVersion) -> ! { /// The cursor used to store the state of the current migration step. pub type Cursor = BoundedVec>; -// // In benchmark and tests we use noop migrations, to test and bench the migration framework -// itself. #[cfg(not(any(feature = "runtime-benchmarks", test)))] -// type Migrations = (v9::Migration, v10::Migration, v11::Migration); - /// IsFinished describes whether a migration is finished or not. pub enum IsFinished { Yes, From a1b9d71d63f1235a3214dfcdeb0f51e49431d76f Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 9 Jun 2023 10:58:02 +0200 Subject: [PATCH 036/105] remove FixedPointOperand from trait --- frame/contracts/src/lib.rs | 21 +++++++++++---------- frame/support/src/traits/tokens/misc.rs | 17 +++-------------- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 90e793a74a795..eafce1d6f82c9 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -97,6 +97,14 @@ pub mod weights; #[cfg(test)] mod tests; +pub use crate::{ + address::{AddressGenerator, DefaultAddressGenerator}, + exec::Frame, + migration::{MigrateSequence, Migration, NoopMigration}, + pallet::*, + schedule::{HostFnWeights, InstructionWeights, Limits, Schedule}, + wasm::Determinism, +}; use crate::{ exec::{AccountIdOf, ErrorOrigin, ExecError, Executable, Key, Stack as ExecStack}, gas::GasMeter, @@ -115,6 +123,7 @@ use frame_support::{ error::BadOrigin, traits::{ fungible::{Inspect, InspectHold, Mutate, MutateHold}, + tokens::Balance, ConstU32, Contains, Get, Randomness, Time, }, weights::Weight, @@ -131,15 +140,6 @@ use smallvec::Array; use sp_runtime::traits::{Convert, Hash, Saturating, StaticLookup, Zero}; use sp_std::{fmt::Debug, marker::PhantomData, prelude::*}; -pub use crate::{ - address::{AddressGenerator, DefaultAddressGenerator}, - exec::Frame, - migration::{MigrateSequence, Migration, NoopMigration}, - pallet::*, - schedule::{HostFnWeights, InstructionWeights, Limits, Schedule}, - wasm::Determinism, -}; - #[cfg(doc)] pub use crate::wasm::api_doc; @@ -331,7 +331,8 @@ pub mod pallet { /// ``` /// use pallet_contracts::migration::{v9, v10, v11}; /// # struct Runtime {}; - /// type Migrations = (v9::Migration, v10::Migration, v11::Migration); + /// # struct Currency {}; + /// type Migrations = (v9::Migration, v10::Migration, v11::Migration); /// ``` type Migrations: MigrateSequence; } diff --git a/frame/support/src/traits/tokens/misc.rs b/frame/support/src/traits/tokens/misc.rs index 3bbe0a1d52ee0..baf3fd5f35464 100644 --- a/frame/support/src/traits/tokens/misc.rs +++ b/frame/support/src/traits/tokens/misc.rs @@ -18,10 +18,7 @@ //! Miscellaneous types. use codec::{Decode, Encode, FullCodec, MaxEncodedLen}; -use sp_arithmetic::{ - traits::{AtLeast32BitUnsigned, Zero}, - FixedPointOperand, -}; +use sp_arithmetic::traits::{AtLeast32BitUnsigned, Zero}; use sp_core::RuntimeDebug; use sp_runtime::{traits::Convert, ArithmeticError, DispatchError, TokenError}; use sp_std::fmt::Debug; @@ -234,14 +231,7 @@ impl Balance for T { } From c68288ff777b0a7cdf9f58bfdf41b73ccf198f2b Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 13 Jun 2023 13:16:07 +0200 Subject: [PATCH 037/105] trait bound BalanceOf --- frame/contracts/src/exec.rs | 52 ++++++++++++++++++++++------ frame/contracts/src/lib.rs | 46 ++++++++++++++++++------ frame/contracts/src/storage/meter.rs | 34 ++++++++++++------ frame/contracts/src/wasm/mod.rs | 17 ++++++--- frame/contracts/src/wasm/prepare.rs | 5 +-- frame/contracts/src/wasm/runtime.rs | 15 ++++++-- 6 files changed, 129 insertions(+), 40 deletions(-) diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 15bc96bc58def..d7801a0364c36 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -43,7 +43,10 @@ use sp_core::{ sr25519::{Public as SR25519Public, Signature as SR25519Signature}, }; use sp_io::{crypto::secp256k1_ecdsa_recover_compressed, hashing::blake2_256}; -use sp_runtime::traits::{Convert, Hash, Zero}; +use sp_runtime::{ + traits::{Convert, Hash, Zero}, + FixedPointOperand, +}; use sp_std::{marker::PhantomData, mem, prelude::*, vec::Vec}; pub type AccountIdOf = ::AccountId; @@ -145,7 +148,9 @@ pub trait Ext: sealing::Sealed { value: BalanceOf, input_data: Vec, allows_reentry: bool, - ) -> Result; + ) -> Result + where + BalanceOf: FixedPointOperand; /// Execute code in the current frame. /// @@ -154,7 +159,9 @@ pub trait Ext: sealing::Sealed { &mut self, code: CodeHash, input_data: Vec, - ) -> Result; + ) -> Result + where + BalanceOf: FixedPointOperand; /// Instantiate a contract from the given code. /// @@ -169,7 +176,9 @@ pub trait Ext: sealing::Sealed { value: BalanceOf, input_data: Vec, salt: &[u8], - ) -> Result<(AccountIdOf, ExecReturnValue), ExecError>; + ) -> Result<(AccountIdOf, ExecReturnValue), ExecError> + where + BalanceOf: FixedPointOperand; /// Transfer all funds to `beneficiary` and delete the contract. /// @@ -631,7 +640,10 @@ where input_data: Vec, debug_message: Option<&'a mut DebugBufferVec>, determinism: Determinism, - ) -> Result { + ) -> Result + where + BalanceOf: FixedPointOperand, + { let (mut stack, executable) = Self::new( FrameArgs::Call { dest, cached_info: None, delegated_call: None }, origin, @@ -665,7 +677,10 @@ where input_data: Vec, salt: &[u8], debug_message: Option<&'a mut DebugBufferVec>, - ) -> Result<(T::AccountId, ExecReturnValue), ExecError> { + ) -> Result<(T::AccountId, ExecReturnValue), ExecError> + where + BalanceOf: FixedPointOperand, + { let (mut stack, executable) = Self::new( FrameArgs::Instantiate { sender: origin.clone(), @@ -842,7 +857,10 @@ where /// Run the current (top) frame. /// /// This can be either a call or an instantiate. - fn run(&mut self, executable: E, input_data: Vec) -> Result { + fn run(&mut self, executable: E, input_data: Vec) -> Result + where + BalanceOf: FixedPointOperand, + { let frame = self.top_frame(); let entry_point = frame.entry_point; let delegated_code_hash = @@ -966,7 +984,10 @@ where /// /// This is called after running the current frame. It commits cached values to storage /// and invalidates all stale references to it that might exist further down the call stack. - fn pop_frame(&mut self, persist: bool) { + fn pop_frame(&mut self, persist: bool) + where + BalanceOf: FixedPointOperand, + { // Revert changes to the nonce in case of a failed instantiation. if !persist && self.top_frame().entry_point == ExportedFunction::Constructor { self.nonce.as_mut().map(|c| *c = c.wrapping_sub(1)); @@ -1153,7 +1174,10 @@ where value: BalanceOf, input_data: Vec, allows_reentry: bool, - ) -> Result { + ) -> Result + where + BalanceOf: FixedPointOperand, + { // Before pushing the new frame: Protect the caller contract against reentrancy attacks. // It is important to do this before calling `allows_reentry` so that a direct recursion // is caught by it. @@ -1195,7 +1219,10 @@ where &mut self, code_hash: CodeHash, input_data: Vec, - ) -> Result { + ) -> Result + where + BalanceOf: FixedPointOperand, + { let executable = E::from_storage(code_hash, self.schedule, self.gas_meter())?; let top_frame = self.top_frame_mut(); let contract_info = top_frame.contract_info().clone(); @@ -1222,7 +1249,10 @@ where value: BalanceOf, input_data: Vec, salt: &[u8], - ) -> Result<(AccountIdOf, ExecReturnValue), ExecError> { + ) -> Result<(AccountIdOf, ExecReturnValue), ExecError> + where + BalanceOf: FixedPointOperand, + { let executable = E::from_storage(code_hash, self.schedule, self.gas_meter())?; let nonce = self.next_nonce(); let executable = self.push_frame( diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index eafce1d6f82c9..d0d9a0ac17e88 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -123,7 +123,6 @@ use frame_support::{ error::BadOrigin, traits::{ fungible::{Inspect, InspectHold, Mutate, MutateHold}, - tokens::Balance, ConstU32, Contains, Get, Randomness, Time, }, weights::Weight, @@ -137,7 +136,10 @@ use pallet_contracts_primitives::{ }; use scale_info::TypeInfo; use smallvec::Array; -use sp_runtime::traits::{Convert, Hash, Saturating, StaticLookup, Zero}; +use sp_runtime::{ + traits::{Convert, Hash, Saturating, StaticLookup, Zero}, + FixedPointOperand, +}; use sp_std::{fmt::Debug, marker::PhantomData, prelude::*}; #[cfg(doc)] @@ -425,6 +427,7 @@ pub mod pallet { impl Pallet where as HasCompact>::Type: Clone + Eq + PartialEq + Debug + TypeInfo + Encode, + BalanceOf: FixedPointOperand, { /// Deprecated version if [`Self::call`] for use in an in-storage `Call`. #[pallet::call_index(0)] @@ -533,7 +536,10 @@ pub mod pallet { code: Vec, storage_deposit_limit: Option< as codec::HasCompact>::Type>, determinism: Determinism, - ) -> DispatchResult { + ) -> DispatchResult + where + BalanceOf: FixedPointOperand, + { Migration::::ensure_migrated()?; let origin = ensure_signed(origin)?; Self::bare_upload_code(origin, code, storage_deposit_limit.map(Into::into), determinism) @@ -1116,7 +1122,10 @@ trait Invokable { /// /// We enforce a re-entrancy guard here by initializing and checking a boolean flag through a /// global reference. - fn run_guarded(&self, common: CommonInput) -> InternalOutput { + fn run_guarded(&self, common: CommonInput) -> InternalOutput + where + BalanceOf: FixedPointOperand, + { // Set up a global reference to the boolean flag used for the re-entrancy guard. environmental!(executing_contract: bool); @@ -1168,7 +1177,9 @@ trait Invokable { &self, common: CommonInput, gas_meter: GasMeter, - ) -> InternalOutput; + ) -> InternalOutput + where + BalanceOf: FixedPointOperand; /// This method ensures that the given `origin` is allowed to invoke the current `Invokable`. /// @@ -1183,7 +1194,10 @@ impl Invokable for CallInput { &self, common: CommonInput, mut gas_meter: GasMeter, - ) -> InternalOutput { + ) -> InternalOutput + where + BalanceOf: FixedPointOperand, + { let CallInput { dest, determinism } = self; let CommonInput { origin, value, data, debug_message, .. } = common; let mut storage_meter = @@ -1231,7 +1245,10 @@ impl Invokable for InstantiateInput { &self, mut common: CommonInput, mut gas_meter: GasMeter, - ) -> InternalOutput { + ) -> InternalOutput + where + BalanceOf: FixedPointOperand, + { let mut storage_deposit = Default::default(); let try_exec = || { let schedule = T::Schedule::get(); @@ -1338,7 +1355,10 @@ impl Pallet { debug: DebugInfo, collect_events: CollectEvents, determinism: Determinism, - ) -> ContractExecResult, EventRecordOf> { + ) -> ContractExecResult, EventRecordOf> + where + BalanceOf: FixedPointOperand, + { ensure_no_migration_in_progress!(); let mut debug_message = if matches!(debug, DebugInfo::UnsafeDebug) { @@ -1396,7 +1416,10 @@ impl Pallet { salt: Vec, debug: DebugInfo, collect_events: CollectEvents, - ) -> ContractInstantiateResult, EventRecordOf> { + ) -> ContractInstantiateResult, EventRecordOf> + where + BalanceOf: FixedPointOperand, + { ensure_no_migration_in_progress!(); let mut debug_message = if debug == DebugInfo::UnsafeDebug { @@ -1441,7 +1464,10 @@ impl Pallet { code: Vec, storage_deposit_limit: Option>, determinism: Determinism, - ) -> CodeUploadResult, BalanceOf> { + ) -> CodeUploadResult, BalanceOf> + where + BalanceOf: FixedPointOperand, + { Migration::::ensure_migrated()?; let schedule = T::Schedule::get(); let module = PrefabWasmModule::from_code( diff --git a/frame/contracts/src/storage/meter.rs b/frame/contracts/src/storage/meter.rs index 8687c698e3813..dea21ae346916 100644 --- a/frame/contracts/src/storage/meter.rs +++ b/frame/contracts/src/storage/meter.rs @@ -35,7 +35,7 @@ use frame_support::{ use pallet_contracts_primitives::StorageDeposit as Deposit; use sp_runtime::{ traits::{Saturating, Zero}, - FixedPointNumber, FixedU128, + FixedPointNumber, FixedPointOperand, FixedU128, }; use sp_std::{marker::PhantomData, vec::Vec}; @@ -157,7 +157,10 @@ impl Diff { /// In case `None` is passed for `info` only charges are calculated. This is because refunds /// are calculated pro rata of the existing storage within a contract and hence need extract /// this information from the passed `info`. - pub fn update_contract(&self, info: Option<&mut ContractInfo>) -> DepositOf { + pub fn update_contract(&self, info: Option<&mut ContractInfo>) -> DepositOf + where + BalanceOf: FixedPointOperand, + { let per_byte = T::DepositPerByte::get(); let per_item = T::DepositPerItem::get(); let bytes_added = self.bytes_added.saturating_sub(self.bytes_removed); @@ -252,7 +255,10 @@ enum Contribution { impl Contribution { /// See [`Diff::update_contract`]. - fn update_contract(&self, info: Option<&mut ContractInfo>) -> DepositOf { + fn update_contract(&self, info: Option<&mut ContractInfo>) -> DepositOf + where + BalanceOf: FixedPointOperand, + { match self { Self::Alive(diff) => diff.update_contract::(info), Self::Terminated(deposit) | Self::Checked(deposit) => deposit.clone(), @@ -311,7 +317,9 @@ where absorbed: RawMeter, deposit_account: DepositAccount, info: Option<&mut ContractInfo>, - ) { + ) where + BalanceOf: FixedPointOperand, + { let own_deposit = absorbed.own_contribution.update_contract(info); self.total_deposit = self .total_deposit @@ -415,7 +423,10 @@ where origin: &T::AccountId, contract: &T::AccountId, info: &mut ContractInfo, - ) -> Result, DispatchError> { + ) -> Result, DispatchError> + where + BalanceOf: FixedPointOperand, + { debug_assert!(self.is_alive()); let ed = Pallet::::min_balance(); @@ -473,10 +484,10 @@ where /// call. However, if a dedicated limit is specified for a sub-call, this needs to be called /// once the sub-call has returned. For this, the [`Self::enforce_subcall_limit`] wrapper is /// used. - pub fn enforce_limit( - &mut self, - info: Option<&mut ContractInfo>, - ) -> Result<(), DispatchError> { + pub fn enforce_limit(&mut self, info: Option<&mut ContractInfo>) -> Result<(), DispatchError> + where + BalanceOf: FixedPointOperand, + { let deposit = self.own_contribution.update_contract(info); let total_deposit = self.total_deposit.saturating_add(&deposit); // We don't want to override a `Terminated` with a `Checked`. @@ -496,7 +507,10 @@ where pub fn enforce_subcall_limit( &mut self, info: Option<&mut ContractInfo>, - ) -> Result<(), DispatchError> { + ) -> Result<(), DispatchError> + where + BalanceOf: FixedPointOperand, + { match self.nested { Nested::OwnLimit => self.enforce_limit(info), Nested::DerivedLimit => Ok(()), diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index 224c116946aa4..698d1a3ba69d4 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -48,7 +48,7 @@ use crate::{ use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::dispatch::{DispatchError, DispatchResult}; use sp_core::Get; -use sp_runtime::RuntimeDebug; +use sp_runtime::{FixedPointOperand, RuntimeDebug}; use sp_std::prelude::*; use wasmi::{ Config as WasmiConfig, Engine, Instance, Linker, Memory, MemoryType, Module, StackLimits, Store, @@ -160,7 +160,10 @@ impl PrefabWasmModule { owner: AccountIdOf, determinism: Determinism, try_instantiate: TryInstantiate, - ) -> Result { + ) -> Result + where + BalanceOf: FixedPointOperand, + { let module = prepare::prepare::( original_code.try_into().map_err(|_| (>::CodeTooLarge.into(), ""))?, schedule, @@ -477,7 +480,10 @@ mod tests { value: u64, data: Vec, allows_reentry: bool, - ) -> Result { + ) -> Result + where + BalanceOf: FixedPointOperand, + { self.calls.push(CallEntry { to, value, data, allows_reentry }); Ok(ExecReturnValue { flags: ReturnFlags::empty(), data: call_return_data() }) } @@ -497,7 +503,10 @@ mod tests { value: u64, data: Vec, salt: &[u8], - ) -> Result<(AccountIdOf, ExecReturnValue), ExecError> { + ) -> Result<(AccountIdOf, ExecReturnValue), ExecError> + where + BalanceOf: FixedPointOperand, + { self.instantiates.push(InstantiateEntry { code_hash, value, diff --git a/frame/contracts/src/wasm/prepare.rs b/frame/contracts/src/wasm/prepare.rs index 14fec834733eb..41bca2a41b827 100644 --- a/frame/contracts/src/wasm/prepare.rs +++ b/frame/contracts/src/wasm/prepare.rs @@ -25,10 +25,10 @@ use crate::{ wasm::{ runtime::AllowDeprecatedInterface, Determinism, Environment, OwnerInfo, PrefabWasmModule, }, - AccountIdOf, CodeVec, Config, Error, Schedule, LOG_TARGET, + AccountIdOf, BalanceOf, CodeVec, Config, Error, Schedule, LOG_TARGET, }; use codec::{Encode, MaxEncodedLen}; -use sp_runtime::{traits::Hash, DispatchError}; +use sp_runtime::{traits::Hash, DispatchError, FixedPointOperand}; use sp_std::prelude::*; use wasm_instrument::{ gas_metering, @@ -455,6 +455,7 @@ pub fn prepare( where E: Environment<()>, T: Config, + BalanceOf: FixedPointOperand, { let (code, (initial, maximum)) = instrument::( original_code.as_ref(), diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index ae02e5badbf39..c9f9ba915eb77 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -30,7 +30,10 @@ use frame_support::{dispatch::DispatchError, ensure, traits::Get, weights::Weigh use pallet_contracts_primitives::{ExecReturnValue, ReturnFlags}; use pallet_contracts_proc_macro::define_env; use sp_io::hashing::{blake2_128, blake2_256, keccak_256, sha2_256}; -use sp_runtime::traits::{Bounded, Zero}; +use sp_runtime::{ + traits::{Bounded, Zero}, + FixedPointOperand, +}; use sp_std::{fmt, prelude::*}; use wasmi::{core::HostError, errors::LinkerError, Linker, Memory, Store}; @@ -862,7 +865,10 @@ impl<'a, E: Ext + 'a> Runtime<'a, E> { input_data_len: u32, output_ptr: u32, output_len_ptr: u32, - ) -> Result { + ) -> Result + where + BalanceOf<::T>: FixedPointOperand, + { self.charge_gas(call_type.cost())?; let input_data = if flags.contains(CallFlags::CLONE_INPUT) { let input = self.input_data.as_ref().ok_or(Error::::InputForwarded)?; @@ -946,7 +952,10 @@ impl<'a, E: Ext + 'a> Runtime<'a, E> { output_len_ptr: u32, salt_ptr: u32, salt_len: u32, - ) -> Result { + ) -> Result + where + BalanceOf<::T>: FixedPointOperand, + { self.charge_gas(RuntimeCosts::InstantiateBase { input_data_len, salt_len })?; let deposit_limit: BalanceOf<::T> = if deposit_ptr == SENTINEL { BalanceOf::<::T>::zero() From 9a813efe09fddb2c446409d119e2e1071df5d7d1 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 13 Jun 2023 17:02:31 +0200 Subject: [PATCH 038/105] more trait bound BalanceOf --- frame/contracts/proc-macro/src/lib.rs | 2 +- frame/contracts/src/chain_extension.rs | 40 +++++++++++++++----------- frame/contracts/src/exec.rs | 2 +- frame/contracts/src/wasm/mod.rs | 2 +- frame/contracts/src/wasm/runtime.rs | 6 ++-- 5 files changed, 30 insertions(+), 22 deletions(-) diff --git a/frame/contracts/proc-macro/src/lib.rs b/frame/contracts/proc-macro/src/lib.rs index a6a8187bc8aaa..22726c34a3de8 100644 --- a/frame/contracts/proc-macro/src/lib.rs +++ b/frame/contracts/proc-macro/src/lib.rs @@ -564,7 +564,7 @@ fn expand_impls(def: &EnvDef) -> TokenStream2 { let dummy_impls = expand_functions(def, false, quote! { () }); quote! { - impl<'a, E: Ext> crate::wasm::Environment> for Env + impl<'a, E: Ext> crate::wasm::Environment> for Env where BalanceOf: FixedPointOperand { fn define( store: &mut ::wasmi::Store>, diff --git a/frame/contracts/src/chain_extension.rs b/frame/contracts/src/chain_extension.rs index 6d1f3df90f23e..d4b52942046a6 100644 --- a/frame/contracts/src/chain_extension.rs +++ b/frame/contracts/src/chain_extension.rs @@ -70,18 +70,17 @@ //! [end-to-end example](https://github.com/paritytech/ink-examples/tree/main/rand-extension) //! on how to use a chain extension in order to provide new features to ink! contracts. +pub use crate::{exec::Ext, gas::ChargedAmount, Config}; use crate::{ wasm::{Runtime, RuntimeCosts}, - Error, + BalanceOf, Error, }; use codec::{Decode, MaxEncodedLen}; use frame_support::weights::Weight; -use sp_runtime::DispatchError; -use sp_std::{marker::PhantomData, vec::Vec}; - -pub use crate::{exec::Ext, gas::ChargedAmount, Config}; pub use frame_system::Config as SysConfig; pub use pallet_contracts_primitives::ReturnFlags; +use sp_runtime::{DispatchError, FixedPointOperand}; +use sp_std::{marker::PhantomData, vec::Vec}; /// Result that returns a [`DispatchError`] on error. pub type Result = sp_std::result::Result; @@ -112,7 +111,7 @@ pub trait ChainExtension { /// In case of `Err` the contract execution is immediately suspended and the passed error /// is returned to the caller. Otherwise the value of [`RetVal`] determines the exit /// behaviour. - fn call>(&mut self, env: Environment) -> Result; + fn call>(&mut self, env: Environment) -> Result where BalanceOf: FixedPointOperand; /// Determines whether chain extensions are enabled for this chain. /// @@ -148,7 +147,7 @@ pub trait RegisteredChainExtension: ChainExtension { #[impl_trait_for_tuples::impl_for_tuples(10)] #[tuple_types_custom_trait_bound(RegisteredChainExtension)] impl ChainExtension for Tuple { - fn call>(&mut self, mut env: Environment) -> Result { + fn call>(&mut self, mut env: Environment) -> Result where BalanceOf: FixedPointOperand { for_tuples!( #( if (Tuple::ID == env.ext_id()) && Tuple::enabled() { @@ -188,7 +187,10 @@ pub enum RetVal { /// /// It uses [typestate programming](https://docs.rust-embedded.org/book/static-guarantees/typestate-programming.html) /// to enforce the correct usage of the parameters passed to the chain extension. -pub struct Environment<'a, 'b, E: Ext, S: State> { +pub struct Environment<'a, 'b, E: Ext, S: State> +where + BalanceOf: FixedPointOperand, +{ /// The actual data of this type. inner: Inner<'a, 'b, E>, /// `S` is only used in the type system but never as value. @@ -196,7 +198,7 @@ pub struct Environment<'a, 'b, E: Ext, S: State> { } /// Functions that are available in every state of this type. -impl<'a, 'b, E: Ext, S: State> Environment<'a, 'b, E, S> { +impl<'a, 'b, E: Ext, S: State> Environment<'a, 'b, E, S> where BalanceOf: FixedPointOperand{ /// The function id within the `id` passed by a contract. /// /// It returns the two least significant bytes of the `id` passed by a contract as the other @@ -251,7 +253,7 @@ impl<'a, 'b, E: Ext, S: State> Environment<'a, 'b, E, S> { /// /// Those are the functions that determine how the arguments to the chain extensions /// should be consumed. -impl<'a, 'b, E: Ext> Environment<'a, 'b, E, InitState> { +impl<'a, 'b, E: Ext> Environment<'a, 'b, E, InitState> where BalanceOf: FixedPointOperand { /// Creates a new environment for consumption by a chain extension. /// /// It is only available to this crate because only the wasm runtime module needs to @@ -264,7 +266,10 @@ impl<'a, 'b, E: Ext> Environment<'a, 'b, E, InitState> { input_len: u32, output_ptr: u32, output_len_ptr: u32, - ) -> Self { + ) -> Self + where + BalanceOf: FixedPointOperand, + { Environment { inner: Inner { runtime, memory, id, input_ptr, input_len, output_ptr, output_len_ptr }, phantom: PhantomData, @@ -288,7 +293,7 @@ impl<'a, 'b, E: Ext> Environment<'a, 'b, E, InitState> { } /// Functions to use the input arguments as integers. -impl<'a, 'b, E: Ext, S: PrimIn> Environment<'a, 'b, E, S> { +impl<'a, 'b, E: Ext, S: PrimIn> Environment<'a, 'b, E, S> where BalanceOf: FixedPointOperand{ /// The `input_ptr` argument. pub fn val0(&self) -> u32 { self.inner.input_ptr @@ -301,7 +306,7 @@ impl<'a, 'b, E: Ext, S: PrimIn> Environment<'a, 'b, E, S> { } /// Functions to use the output arguments as integers. -impl<'a, 'b, E: Ext, S: PrimOut> Environment<'a, 'b, E, S> { +impl<'a, 'b, E: Ext, S: PrimOut> Environment<'a, 'b, E, S> where BalanceOf: FixedPointOperand{ /// The `output_ptr` argument. pub fn val2(&self) -> u32 { self.inner.output_ptr @@ -314,7 +319,7 @@ impl<'a, 'b, E: Ext, S: PrimOut> Environment<'a, 'b, E, S> { } /// Functions to use the input arguments as pointer to a buffer. -impl<'a, 'b, E: Ext, S: BufIn> Environment<'a, 'b, E, S> { +impl<'a, 'b, E: Ext, S: BufIn> Environment<'a, 'b, E, S> where BalanceOf: FixedPointOperand{ /// Reads `min(max_len, in_len)` from contract memory. /// /// This does **not** charge any weight. The caller must make sure that the an @@ -386,7 +391,7 @@ impl<'a, 'b, E: Ext, S: BufIn> Environment<'a, 'b, E, S> { } /// Functions to use the output arguments as pointer to a buffer. -impl<'a, 'b, E: Ext, S: BufOut> Environment<'a, 'b, E, S> { +impl<'a, 'b, E: Ext, S: BufOut> Environment<'a, 'b, E, S> where BalanceOf: FixedPointOperand{ /// Write the supplied buffer to contract memory. /// /// If the contract supplied buffer is smaller than the passed `buffer` an `Err` is returned. @@ -418,7 +423,10 @@ impl<'a, 'b, E: Ext, S: BufOut> Environment<'a, 'b, E, S> { /// All data is put into this struct to easily pass it around as part of the typestate /// pattern. Also it creates the opportunity to box this struct in the future in case it /// gets too large. -struct Inner<'a, 'b, E: Ext> { +struct Inner<'a, 'b, E: Ext> +where + BalanceOf: FixedPointOperand, +{ /// The runtime contains all necessary functions to interact with the running contract. runtime: &'a mut Runtime<'b, E>, /// Reference to the contracts memory. diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index d7801a0364c36..7cb7c88a21b31 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -368,7 +368,7 @@ pub trait Executable: Sized { ext: &mut E, function: &ExportedFunction, input_data: Vec, - ) -> ExecResult; + ) -> ExecResult where BalanceOf: FixedPointOperand; /// The code hash of the executable. fn code_hash(&self) -> &CodeHash; diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index 698d1a3ba69d4..acbbc536e6e98 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -316,7 +316,7 @@ impl Executable for PrefabWasmModule { ext: &mut E, function: &ExportedFunction, input_data: Vec, - ) -> ExecResult { + ) -> ExecResult where BalanceOf: FixedPointOperand{ let runtime = Runtime::new(ext, input_data); let (mut store, memory, instance) = Self::instantiate::( self.code.as_slice(), diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index c9f9ba915eb77..6751b13915160 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -461,14 +461,14 @@ fn already_charged(_: u32) -> Option { } /// Can only be used for one call. -pub struct Runtime<'a, E: Ext + 'a> { +pub struct Runtime<'a, E: Ext + 'a> where BalanceOf: FixedPointOperand { ext: &'a mut E, input_data: Option>, memory: Option, chain_extension: Option::ChainExtension>>, } -impl<'a, E: Ext + 'a> Runtime<'a, E> { +impl<'a, E: Ext + 'a> Runtime<'a, E> where BalanceOf: FixedPointOperand { pub fn new(ext: &'a mut E, input_data: Vec) -> Self { Runtime { ext, @@ -1012,7 +1012,7 @@ impl<'a, E: Ext + 'a> Runtime<'a, E> { // data passed to the supervisor will lead to a trap. This is not documented explicitly // for every function. #[define_env(doc)] -pub mod env { +pub mod env{ /// Account for used gas. Traps if gas used is greater than gas limit. /// /// NOTE: This is a implementation defined call and is NOT a part of the public API. From 11308f5eead1e8dd9c1fbebe79ffdc1757cb160f Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 16 Jun 2023 10:32:12 +0200 Subject: [PATCH 039/105] update to use RuntimeHoldReason --- bin/node/runtime/src/lib.rs | 8 ++++++- frame/contracts/src/lib.rs | 10 ++++----- frame/contracts/src/tests.rs | 29 +++++++++----------------- frame/contracts/src/wasm/code_cache.rs | 8 +++---- 4 files changed, 25 insertions(+), 30 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index f59d1c96b8da1..e77468dd514e8 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1210,17 +1210,22 @@ impl pallet_tips::Config for Runtime { type WeightInfo = pallet_tips::weights::SubstrateWeight; } +pub enum HoldIdentifier { + StorageDepositReserve, +} + parameter_types! { pub const DepositPerItem: Balance = deposit(1, 0); pub const DepositPerByte: Balance = deposit(0, 1); pub const DefaultDepositLimit: Balance = deposit(1024, 1024 * 1024); pub Schedule: pallet_contracts::Schedule = Default::default(); + pub const HoldReason: RuntimeHoldReason = HoldIdentifier::StorageDepositReserve; } impl pallet_contracts::Config for Runtime { type Time = Timestamp; type Randomness = RandomnessCollectiveFlip; - type Currency = Balances; + type Fungible = Balances; type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; /// The safest default is to allow no calls at all. @@ -1243,6 +1248,7 @@ impl pallet_contracts::Config for Runtime { type MaxStorageKeyLen = ConstU32<128>; type UnsafeUnstableInterface = ConstBool; type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>; + type HoldReason = HoldReason; #[cfg(not(feature = "runtime-benchmarks"))] type Migrations = (); #[cfg(feature = "runtime-benchmarks")] diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 71413ecb843a2..de6962b33c8e7 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -121,7 +121,7 @@ use frame_support::{ ensure, error::BadOrigin, traits::{ - fungible::{Inspect, InspectHold, Mutate, MutateHold}, + fungible::{Inspect, Mutate, MutateHold}, ConstU32, Contains, Get, Randomness, Time, }, weights::Weight, @@ -213,7 +213,7 @@ pub mod pallet { /// The fungible in which fees are paid and contract balances are held. type Fungible: Inspect + Mutate - + MutateHold; + + MutateHold; /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; @@ -323,9 +323,8 @@ pub mod pallet { #[pallet::constant] type MaxDebugBufferLen: Get; - /// The identifier of the hold reason. - #[pallet::constant] - type HoldReason: Get<>::Reason>; + /// Overarching hold reason. + type RuntimeHoldReason: From; /// The sequence of migration steps that will be applied during a migration. /// @@ -951,7 +950,6 @@ pub mod pallet { #[pallet::composite_enum] pub enum HoldReason { /// The Pallet has reserved it for storage deposit. - #[codec(index = 0)] StorageDepositReserve, } diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 92bd620f03303..36c347dc16fba 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -28,11 +28,11 @@ use crate::{ wasm::{Determinism, PrefabWasmModule, ReturnCode as RuntimeReturnCode}, weights::WeightInfo, BalanceOf, Code, CodeStorage, CollectEvents, Config, ContractInfo, ContractInfoOf, DebugInfo, - DefaultAddressGenerator, DeletionQueueCounter, Error, MigrationInProgress, NoopMigration, - Origin, Pallet, Schedule, + DefaultAddressGenerator, DeletionQueueCounter, Error, HoldReason, MigrationInProgress, + NoopMigration, Origin, Pallet, Schedule, }; use assert_matches::assert_matches; -use codec::{Decode, Encode, MaxEncodedLen}; +use codec::Encode; use frame_support::{ assert_err, assert_err_ignore_postinfo, assert_err_with_weight, assert_noop, assert_ok, dispatch::{DispatchError, DispatchErrorWithPostInfo, PostDispatchInfo}, @@ -47,7 +47,6 @@ use frame_support::{ }; use frame_system::{EventRecord, Phase}; use pretty_assertions::{assert_eq, assert_ne}; -use scale_info::TypeInfo; use sp_core::ByteArray; use sp_io::hashing::blake2_256; use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; @@ -72,7 +71,7 @@ frame_support::construct_runtime!( Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, Randomness: pallet_insecure_randomness_collective_flip::{Pallet, Storage}, Utility: pallet_utility::{Pallet, Call, Storage, Event}, - Contracts: pallet_contracts::{Pallet, Call, Storage, Event}, + Contracts: pallet_contracts::{Pallet, Call, Storage, Event, HoldReason}, Proxy: pallet_proxy::{Pallet, Call, Storage, Event}, } ); @@ -325,7 +324,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type RuntimeHoldReason = HoldIdentifier; + type RuntimeHoldReason = RuntimeHoldReason; type MaxHolds = ConstU32<1>; } @@ -389,13 +388,6 @@ impl Default for Filters { } } -#[derive( - Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, MaxEncodedLen, Debug, TypeInfo, -)] -pub enum HoldIdentifier { - StorageDepositReserve, -} - parameter_types! { static CallFilter: Filters = Default::default(); } @@ -414,7 +406,6 @@ impl Contains for TestFilter { parameter_types! { pub static UnstableInterface: bool = true; - pub const HoldReason: HoldIdentifier = HoldIdentifier::StorageDepositReserve; } impl Config for Test { @@ -438,7 +429,7 @@ impl Config for Test { type MaxStorageKeyLen = ConstU32<128>; type UnsafeUnstableInterface = UnstableInterface; type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>; - type HoldReason = HoldReason; + type RuntimeHoldReason = RuntimeHoldReason; type Migrations = (NoopMigration<1>, NoopMigration<2>); } @@ -4164,9 +4155,9 @@ fn slash_cannot_kill_account() { initialize_block(2); // We need to hold some balances in order to have something to slash. As slashing can only - // affect balances held under certain HoldIdentifier. + // affect balances held under certain HoldReason. ::Fungible::hold( - &HoldIdentifier::StorageDepositReserve, + &HoldReason::StorageDepositReserve.into(), &addr, balance_held, ) @@ -4178,7 +4169,7 @@ fn slash_cannot_kill_account() { // The account does not get destroyed because of the consumer reference. // Slashing can for example happen if the contract takes part in staking. let _ = ::Fungible::slash( - &HoldIdentifier::StorageDepositReserve, + &HoldReason::StorageDepositReserve.into(), &addr, ::Fungible::total_balance(&addr), ); @@ -4875,7 +4866,7 @@ fn deposit_limit_honors_liquidity_restrictions() { // check that the hold is honored ::Fungible::hold( - &HoldIdentifier::StorageDepositReserve, + &HoldReason::StorageDepositReserve.into(), &BOB, bobs_balance - ED, ) diff --git a/frame/contracts/src/wasm/code_cache.rs b/frame/contracts/src/wasm/code_cache.rs index 5a3fce4d6c6f9..d5beb95ea0e6f 100644 --- a/frame/contracts/src/wasm/code_cache.rs +++ b/frame/contracts/src/wasm/code_cache.rs @@ -32,8 +32,8 @@ use crate::{ gas::{GasMeter, Token}, wasm::{prepare, PrefabWasmModule}, weights::WeightInfo, - CodeHash, CodeStorage, Config, Error, Event, OwnerInfoOf, Pallet, PristineCode, Schedule, - Weight, + CodeHash, CodeStorage, Config, Error, Event, HoldReason, OwnerInfoOf, Pallet, PristineCode, + Schedule, Weight, }; use frame_support::{ dispatch::{DispatchError, DispatchResult}, @@ -97,7 +97,7 @@ pub fn store(mut module: PrefabWasmModule, instantiated: bool) -> // This `None` case happens only in freshly uploaded modules. This means that // the `owner` is always the origin of the current transaction. T::Fungible::hold( - &T::HoldReason::get(), + &HoldReason::StorageDepositReserve.into(), &new_owner_info.owner, new_owner_info.deposit, ) @@ -164,7 +164,7 @@ pub fn try_remove(origin: &T::AccountId, code_hash: CodeHash) -> D ensure!(owner_info.refcount == 0, >::CodeInUse); ensure!(&owner_info.owner == origin, BadOrigin); T::Fungible::release( - &T::HoldReason::get(), + &HoldReason::StorageDepositReserve.into(), &owner_info.owner, owner_info.deposit, BestEffort, From f4e1e5391c74f3dfa7f0ef5d581893c37fb20c0a Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 16 Jun 2023 11:55:02 +0200 Subject: [PATCH 040/105] replace Fungible for Currency --- frame/contracts/src/benchmarking/mod.rs | 58 ++--- frame/contracts/src/exec.rs | 52 ++-- frame/contracts/src/lib.rs | 8 +- frame/contracts/src/migration/v10.rs | 4 +- frame/contracts/src/storage/meter.rs | 10 +- frame/contracts/src/tests.rs | 322 ++++++++++++------------ frame/contracts/src/wasm/code_cache.rs | 4 +- 7 files changed, 230 insertions(+), 228 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 75c6d3e5bcac0..3e8fc9d378110 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -91,7 +91,7 @@ where data: Vec, ) -> Result, &'static str> { let value = Pallet::::min_balance(); - T::Fungible::make_free_balance_be(&caller, caller_funding::()); + T::Currency::make_free_balance_be(&caller, caller_funding::()); let salt = vec![0xff]; let addr = Contracts::::contract_address(&caller, &module.hash, &data, &salt); @@ -157,7 +157,7 @@ where /// Set the balance of the contract to the supplied amount. fn set_balance(&self, balance: BalanceOf) { - T::Fungible::make_free_balance_be(&self.account_id, balance); + T::Currency::make_free_balance_be(&self.account_id, balance); } /// Returns `true` iff all storage entries related to code storage exist. @@ -362,22 +362,22 @@ benchmarks! { let salt = vec![42u8; s as usize]; let value = Pallet::::min_balance(); let caller = whitelisted_caller(); - T::Fungible::make_free_balance_be(&caller, caller_funding::()); + T::Currency::make_free_balance_be(&caller, caller_funding::()); let WasmModule { code, hash, .. } = WasmModule::::sized(c, Location::Call); let origin = RawOrigin::Signed(caller.clone()); let addr = Contracts::::contract_address(&caller, &hash, &input, &salt); }: _(origin, value, Weight::MAX, None, code, input, salt) verify { let deposit_account = Contract::::address_info(&addr)?.deposit_account().clone(); - let deposit = T::Fungible::free_balance(&deposit_account); + let deposit = T::Currency::free_balance(&deposit_account); // uploading the code reserves some balance in the callers account - let code_deposit = T::Fungible::reserved_balance(&caller); + let code_deposit = T::Currency::reserved_balance(&caller); assert_eq!( - T::Fungible::free_balance(&caller), + T::Currency::free_balance(&caller), caller_funding::() - value - deposit - code_deposit - Pallet::::min_balance(), ); // contract has the full value - assert_eq!(T::Fungible::free_balance(&addr), value + Pallet::::min_balance()); + assert_eq!(T::Currency::free_balance(&addr), value + Pallet::::min_balance()); } // Instantiate uses a dummy contract constructor to measure the overhead of the instantiate. @@ -391,7 +391,7 @@ benchmarks! { let salt = vec![42u8; s as usize]; let value = Pallet::::min_balance(); let caller = whitelisted_caller(); - T::Fungible::make_free_balance_be(&caller, caller_funding::()); + T::Currency::make_free_balance_be(&caller, caller_funding::()); let WasmModule { code, hash, .. } = WasmModule::::dummy(); let origin = RawOrigin::Signed(caller.clone()); let addr = Contracts::::contract_address(&caller, &hash, &input, &salt); @@ -399,14 +399,14 @@ benchmarks! { }: _(origin, value, Weight::MAX, None, hash, input, salt) verify { let deposit_account = Contract::::address_info(&addr)?.deposit_account().clone(); - let deposit = T::Fungible::free_balance(&deposit_account); + let deposit = T::Currency::free_balance(&deposit_account); // value was removed from the caller assert_eq!( - T::Fungible::free_balance(&caller), + T::Currency::free_balance(&caller), caller_funding::() - value - deposit - Pallet::::min_balance(), ); // contract has the full value - assert_eq!(T::Fungible::free_balance(&addr), value + Pallet::::min_balance()); + assert_eq!(T::Currency::free_balance(&addr), value + Pallet::::min_balance()); } // We just call a dummy contract to measure the overhead of the call extrinsic. @@ -426,18 +426,18 @@ benchmarks! { let value = Pallet::::min_balance(); let origin = RawOrigin::Signed(instance.caller.clone()); let callee = instance.addr.clone(); - let before = T::Fungible::free_balance(&instance.account_id); - let before_deposit = T::Fungible::free_balance(&deposit_account); + let before = T::Currency::free_balance(&instance.account_id); + let before_deposit = T::Currency::free_balance(&deposit_account); }: _(origin, callee, value, Weight::MAX, None, data) verify { - let deposit = T::Fungible::free_balance(&deposit_account); + let deposit = T::Currency::free_balance(&deposit_account); // value and value transferred via call should be removed from the caller assert_eq!( - T::Fungible::free_balance(&instance.caller), + T::Currency::free_balance(&instance.caller), caller_funding::() - instance.value - value - deposit - Pallet::::min_balance(), ); // contract should have received the value - assert_eq!(T::Fungible::free_balance(&instance.account_id), before + value); + assert_eq!(T::Currency::free_balance(&instance.account_id), before + value); // contract should still exist instance.info()?; } @@ -454,13 +454,13 @@ benchmarks! { upload_code { let c in 0 .. Perbill::from_percent(49).mul_ceil(T::MaxCodeLen::get()); let caller = whitelisted_caller(); - T::Fungible::make_free_balance_be(&caller, caller_funding::()); + T::Currency::make_free_balance_be(&caller, caller_funding::()); let WasmModule { code, hash, .. } = WasmModule::::sized(c, Location::Call); let origin = RawOrigin::Signed(caller.clone()); }: _(origin, code, None, Determinism::Enforced) verify { // uploading the code reserves some balance in the callers account - assert!(T::Fungible::reserved_balance(&caller) > 0u32.into()); + assert!(T::Currency::reserved_balance(&caller) > 0u32.into()); assert!(>::code_exists(&hash)); } @@ -470,17 +470,17 @@ benchmarks! { #[pov_mode = Measured] remove_code { let caller = whitelisted_caller(); - T::Fungible::make_free_balance_be(&caller, caller_funding::()); + T::Currency::make_free_balance_be(&caller, caller_funding::()); let WasmModule { code, hash, .. } = WasmModule::::dummy(); let origin = RawOrigin::Signed(caller.clone()); let uploaded = >::bare_upload_code(caller.clone(), code, None, Determinism::Enforced)?; assert_eq!(uploaded.code_hash, hash); - assert_eq!(uploaded.deposit, T::Fungible::reserved_balance(&caller)); + assert_eq!(uploaded.deposit, T::Currency::reserved_balance(&caller)); assert!(>::code_exists(&hash)); }: _(origin, hash) verify { // removing the code should have unreserved the deposit - assert_eq!(T::Fungible::reserved_balance(&caller), 0u32.into()); + assert_eq!(T::Currency::reserved_balance(&caller), 0u32.into()); assert!(>::code_removed(&hash)); } @@ -897,15 +897,15 @@ benchmarks! { let instance = Contract::::new(code, vec![])?; let origin = RawOrigin::Signed(instance.caller.clone()); let deposit_account = instance.info()?.deposit_account().clone(); - assert_eq!(>::total_balance(&beneficiary), 0u32.into()); - assert_eq!(T::Fungible::free_balance(&instance.account_id), Pallet::::min_balance() * 2u32.into()); - assert_ne!(T::Fungible::free_balance(&deposit_account), 0u32.into()); + assert_eq!(>::total_balance(&beneficiary), 0u32.into()); + assert_eq!(T::Currency::free_balance(&instance.account_id), Pallet::::min_balance() * 2u32.into()); + assert_ne!(T::Currency::free_balance(&deposit_account), 0u32.into()); }: call(origin, instance.addr.clone(), 0u32.into(), Weight::MAX, None, vec![]) verify { if r > 0 { - assert_eq!(>::total_balance(&instance.account_id), 0u32.into()); - assert_eq!(>::total_balance(&deposit_account), 0u32.into()); - assert_eq!(>::total_balance(&beneficiary), Pallet::::min_balance() * 2u32.into()); + assert_eq!(>::total_balance(&instance.account_id), 0u32.into()); + assert_eq!(>::total_balance(&deposit_account), 0u32.into()); + assert_eq!(>::total_balance(&beneficiary), Pallet::::min_balance() * 2u32.into()); } } @@ -1674,12 +1674,12 @@ benchmarks! { instance.set_balance(value * (r + 1).into()); let origin = RawOrigin::Signed(instance.caller.clone()); for account in &accounts { - assert_eq!(>::total_balance(account), 0u32.into()); + assert_eq!(>::total_balance(account), 0u32.into()); } }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) verify { for account in &accounts { - assert_eq!(>::total_balance(account), value); + assert_eq!(>::total_balance(account), value); } } diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 7cb7c88a21b31..8dc2be38f263b 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -368,7 +368,9 @@ pub trait Executable: Sized { ext: &mut E, function: &ExportedFunction, input_data: Vec, - ) -> ExecResult where BalanceOf: FixedPointOperand; + ) -> ExecResult + where + BalanceOf: FixedPointOperand; /// The code hash of the executable. fn code_hash(&self) -> &CodeHash; @@ -1089,7 +1091,7 @@ where value: BalanceOf, ) -> DispatchResult { if !value.is_zero() && from != to { - T::Fungible::transfer(from, to, value, preservation) + T::Currency::transfer(from, to, value, preservation) .map_err(|_| Error::::TransferFailed)?; } Ok(()) @@ -1283,7 +1285,7 @@ where Preservation::Expendable, &frame.account_id, beneficiary, - T::Fungible::reducible_balance(&frame.account_id, Preservation::Expendable, Polite), + T::Currency::reducible_balance(&frame.account_id, Preservation::Expendable, Polite), )?; info.queue_trie_for_deletion(); ContractInfoOf::::remove(&frame.account_id); @@ -1362,7 +1364,7 @@ where } fn balance(&self) -> BalanceOf { - T::Fungible::balance(&self.top_frame().account_id) + T::Currency::balance(&self.top_frame().account_id) } fn value_transferred(&self) -> BalanceOf { @@ -1378,7 +1380,7 @@ where } fn minimum_balance(&self) -> BalanceOf { - T::Fungible::minimum_balance() + T::Currency::minimum_balance() } fn deposit_event(&mut self, topics: Vec, data: Vec) { @@ -1982,7 +1984,7 @@ mod tests { // This one tests passing the input data into a contract via instantiate. ExtBuilder::default().build().execute_with(|| { let schedule = ::Schedule::get(); - let min_balance = ::Fungible::minimum_balance(); + let min_balance = ::Currency::minimum_balance(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); let executable = MockExecutable::from_storage(input_data_ch, &schedule, &mut gas_meter).unwrap(); @@ -2429,7 +2431,7 @@ mod tests { ExtBuilder::default().existential_deposit(15).build().execute_with(|| { let schedule = ::Schedule::get(); - let min_balance = ::Fungible::minimum_balance(); + let min_balance = ::Currency::minimum_balance(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); let executable = MockExecutable::from_storage(dummy_ch, &schedule, &mut gas_meter).unwrap(); @@ -2475,7 +2477,7 @@ mod tests { ExtBuilder::default().existential_deposit(15).build().execute_with(|| { let schedule = ::Schedule::get(); - let min_balance = ::Fungible::minimum_balance(); + let min_balance = ::Currency::minimum_balance(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); let executable = MockExecutable::from_storage(dummy_ch, &schedule, &mut gas_meter).unwrap(); @@ -2520,7 +2522,7 @@ mod tests { Weight::zero(), BalanceOf::::zero(), dummy_ch, - ::Fungible::minimum_balance(), + ::Currency::minimum_balance(), vec![], &[48, 49, 50], ) @@ -2533,7 +2535,7 @@ mod tests { ExtBuilder::default().existential_deposit(15).build().execute_with(|| { let schedule = ::Schedule::get(); - let min_balance = ::Fungible::minimum_balance(); + let min_balance = ::Currency::minimum_balance(); set_balance(&ALICE, min_balance * 100); place_contract(&BOB, instantiator_ch); let contract_origin = Origin::from_account_id(ALICE); @@ -2589,7 +2591,7 @@ mod tests { Weight::zero(), BalanceOf::::zero(), dummy_ch, - ::Fungible::minimum_balance(), + ::Currency::minimum_balance(), vec![], &[], ), @@ -2747,7 +2749,7 @@ mod tests { // This one tests passing the input data into a contract via instantiate. ExtBuilder::default().build().execute_with(|| { let schedule = ::Schedule::get(); - let min_balance = ::Fungible::minimum_balance(); + let min_balance = ::Currency::minimum_balance(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); let executable = MockExecutable::from_storage(code, &schedule, &mut gas_meter).unwrap(); set_balance(&ALICE, min_balance * 10_000); @@ -2781,7 +2783,7 @@ mod tests { let mut debug_buffer = DebugBufferVec::::try_from(Vec::new()).unwrap(); ExtBuilder::default().build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); + let min_balance = ::Currency::minimum_balance(); let schedule = ::Schedule::get(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); set_balance(&ALICE, min_balance * 10); @@ -2817,7 +2819,7 @@ mod tests { let mut debug_buffer = DebugBufferVec::::try_from(Vec::new()).unwrap(); ExtBuilder::default().build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); + let min_balance = ::Currency::minimum_balance(); let schedule = ::Schedule::get(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); set_balance(&ALICE, min_balance * 10); @@ -2857,7 +2859,7 @@ mod tests { ExtBuilder::default().build().execute_with(|| { let schedule: Schedule = ::Schedule::get(); - let min_balance = ::Fungible::minimum_balance(); + let min_balance = ::Currency::minimum_balance(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); set_balance(&ALICE, min_balance * 10); place_contract(&BOB, code_hash); @@ -2984,7 +2986,7 @@ mod tests { }); ExtBuilder::default().build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); + let min_balance = ::Currency::minimum_balance(); let schedule = ::Schedule::get(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); set_balance(&ALICE, min_balance * 10); @@ -3071,7 +3073,7 @@ mod tests { }); ExtBuilder::default().build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); + let min_balance = ::Currency::minimum_balance(); let schedule = ::Schedule::get(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); set_balance(&ALICE, min_balance * 10); @@ -3171,7 +3173,7 @@ mod tests { ExtBuilder::default().build().execute_with(|| { let schedule = ::Schedule::get(); - let min_balance = ::Fungible::minimum_balance(); + let min_balance = ::Currency::minimum_balance(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); let fail_executable = MockExecutable::from_storage(fail_code, &schedule, &mut gas_meter).unwrap(); @@ -3288,7 +3290,7 @@ mod tests { }); ExtBuilder::default().build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); + let min_balance = ::Currency::minimum_balance(); let schedule = ::Schedule::get(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); set_balance(&ALICE, min_balance * 1000); @@ -3416,7 +3418,7 @@ mod tests { }); ExtBuilder::default().build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); + let min_balance = ::Currency::minimum_balance(); let schedule = ::Schedule::get(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); set_balance(&ALICE, min_balance * 1000); @@ -3456,7 +3458,7 @@ mod tests { }); ExtBuilder::default().build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); + let min_balance = ::Currency::minimum_balance(); let schedule = ::Schedule::get(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); set_balance(&ALICE, min_balance * 1000); @@ -3496,7 +3498,7 @@ mod tests { }); ExtBuilder::default().build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); + let min_balance = ::Currency::minimum_balance(); let schedule = ::Schedule::get(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); set_balance(&ALICE, min_balance * 1000); @@ -3553,7 +3555,7 @@ mod tests { }); ExtBuilder::default().build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); + let min_balance = ::Currency::minimum_balance(); let schedule = ::Schedule::get(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); set_balance(&ALICE, min_balance * 1000); @@ -3610,7 +3612,7 @@ mod tests { }); ExtBuilder::default().build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); + let min_balance = ::Currency::minimum_balance(); let schedule = ::Schedule::get(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); set_balance(&ALICE, min_balance * 1000); @@ -3707,7 +3709,7 @@ mod tests { }); ExtBuilder::default().build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); + let min_balance = ::Currency::minimum_balance(); let schedule = ::Schedule::get(); let mut gas_meter = GasMeter::::new(GAS_LIMIT); set_balance(&ALICE, min_balance * 1000); diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index de6962b33c8e7..24f695cb8f5f7 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -148,7 +148,7 @@ pub use crate::wasm::api_doc; type CodeHash = ::Hash; type TrieId = BoundedVec>; type BalanceOf = - <::Fungible as Inspect<::AccountId>>::Balance; + <::Currency as Inspect<::AccountId>>::Balance; type CodeVec = BoundedVec::MaxCodeLen>; type RelaxedCodeVec = WeakBoundedVec::MaxCodeLen>; type AccountIdLookupOf = <::Lookup as StaticLookup>::Source; @@ -211,7 +211,7 @@ pub mod pallet { type Randomness: Randomness; /// The fungible in which fees are paid and contract balances are held. - type Fungible: Inspect + type Currency: Inspect + Mutate + MutateHold; @@ -1547,9 +1547,9 @@ impl Pallet { ) } - /// Return the existential deposit of [`Config::Fungible`]. + /// Return the existential deposit of [`Config::Currency`]. fn min_balance() -> BalanceOf { - >>::minimum_balance() + >>::minimum_balance() } /// Convert gas_limit from 1D Weight to a 2D Weight. diff --git a/frame/contracts/src/migration/v10.rs b/frame/contracts/src/migration/v10.rs index 24e27e78998e2..38e79613c3a92 100644 --- a/frame/contracts/src/migration/v10.rs +++ b/frame/contracts/src/migration/v10.rs @@ -52,8 +52,8 @@ mod old { /// Old Currency type traits /// - /// This trait holds what the old [`T::Currency`] type required before is was replaced by - /// [`T::Fungible`] + /// This trait holds what the old [`T::Currency`] type required before is was replaced by the + /// `fungible` traits. pub trait CurrencyOf: ReservableCurrency<::AccountId> + Inspect<::AccountId, Balance = BalanceOf> diff --git a/frame/contracts/src/storage/meter.rs b/frame/contracts/src/storage/meter.rs index dea21ae346916..22d7755fec43d 100644 --- a/frame/contracts/src/storage/meter.rs +++ b/frame/contracts/src/storage/meter.rs @@ -460,7 +460,7 @@ where System::::inc_consumers(info.deposit_account())?; // We also need to make sure that the contract's account itself exists. - T::Fungible::transfer(origin, contract, ed, Preservation::Protect)?; + T::Currency::transfer(origin, contract, ed, Preservation::Protect)?; System::::inc_consumers(contract)?; Ok(deposit) @@ -527,14 +527,14 @@ impl Ext for ReservingExt { // We are sending the `min_leftover` and the `min_balance` from the origin // account as part of a contract call. Hence origin needs to have those left over // as free balance after accounting for all deposits. - let max = T::Fungible::reducible_balance(origin, Preservation::Protect, Polite) + let max = T::Currency::reducible_balance(origin, Preservation::Protect, Polite) .saturating_sub(min_leftover) .saturating_sub(Pallet::::min_balance()); let default = max.min(T::DefaultDepositLimit::get()); let limit = limit.unwrap_or(default); ensure!( limit <= max && - matches!(T::Fungible::can_withdraw(origin, limit), WithdrawConsequence::Success), + matches!(T::Currency::can_withdraw(origin, limit), WithdrawConsequence::Success), >::StorageDepositNotEnoughFunds, ); Ok(limit) @@ -548,14 +548,14 @@ impl Ext for ReservingExt { ) -> Result<(), DispatchError> { match amount { Deposit::Charge(amount) => { - T::Fungible::transfer(origin, deposit_account, *amount, Preservation::Protect)?; + T::Currency::transfer(origin, deposit_account, *amount, Preservation::Protect)?; Ok(()) }, Deposit::Refund(amount) => { if terminated { System::::dec_consumers(&deposit_account); } - T::Fungible::transfer( + T::Currency::transfer( deposit_account, origin, *amount, diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 36c347dc16fba..cf89e96b8e659 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -100,16 +100,16 @@ pub mod test_utils { *counter += 1; *counter }); - set_balance(address, ::Fungible::minimum_balance() * 10); + set_balance(address, ::Currency::minimum_balance() * 10); let contract = >::new(&address, nonce, code_hash).unwrap(); >::insert(address, contract); } pub fn set_balance(who: &AccountIdOf, amount: u64) { - let imbalance = ::Fungible::set_balance(who, amount); + let imbalance = ::Currency::set_balance(who, amount); drop(imbalance); } pub fn get_balance(who: &AccountIdOf) -> u64 { - ::Fungible::free_balance(who) + ::Currency::free_balance(who) } pub fn get_contract(addr: &AccountIdOf) -> ContractInfo { get_contract_checked(addr).unwrap() @@ -411,7 +411,7 @@ parameter_types! { impl Config for Test { type Time = Timestamp; type Randomness = Randomness; - type Fungible = Balances; + type Currency = Balances; type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; type CallFilter = TestFilter; @@ -545,7 +545,7 @@ impl Default for Origin { #[test] fn calling_plain_account_fails() { ExtBuilder::default().build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 100_000_000); + let _ = ::Currency::set_balance(&ALICE, 100_000_000); let base_cost = <::WeightInfo as WeightInfo>::call(); assert_eq!( @@ -566,7 +566,7 @@ fn migration_in_progress_works() { let (wasm, code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(1).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); MigrationInProgress::::set(Some(Default::default())); assert_err!( @@ -622,8 +622,8 @@ fn instantiate_and_call_and_deposit_event() { let (wasm, code_hash) = compile_module::("event_and_return_on_deploy").unwrap(); ExtBuilder::default().existential_deposit(1).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); - let min_balance = ::Fungible::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); + let min_balance = ::Currency::minimum_balance(); let value = 100; // We determine the storage deposit limit after uploading because it depends on ALICEs free @@ -745,7 +745,7 @@ fn deposit_event_max_value_limit() { ExtBuilder::default().existential_deposit(50).build().execute_with(|| { // Create - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, 30_000, @@ -790,8 +790,8 @@ fn deposit_event_max_value_limit() { fn run_out_of_gas() { let (wasm, _code_hash) = compile_module::("run_out_of_gas").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let min_balance = ::Currency::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, @@ -831,7 +831,7 @@ fn instantiate_unique_trie_id() { let (wasm, code_hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(500).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); Contracts::upload_code(RuntimeOrigin::signed(ALICE), wasm, None, Determinism::Enforced) .unwrap(); @@ -898,7 +898,7 @@ fn storage_max_value_limit() { ExtBuilder::default().existential_deposit(50).build().execute_with(|| { // Create - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, 30_000, @@ -946,10 +946,10 @@ fn deploy_and_call_other_contract() { let (callee_wasm, callee_code_hash) = compile_module::("return_with_data").unwrap(); ExtBuilder::default().existential_deposit(1).build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); + let min_balance = ::Currency::minimum_balance(); // Create - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); let caller_addr = Contracts::bare_instantiate( ALICE, 100_000, @@ -1097,7 +1097,7 @@ fn delegate_call() { let (callee_wasm, callee_code_hash) = compile_module::("delegate_call_lib").unwrap(); ExtBuilder::default().existential_deposit(500).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); // Instantiate the 'caller' let caller_addr = Contracts::bare_instantiate( @@ -1137,7 +1137,7 @@ fn delegate_call() { fn transfer_allow_death_cannot_kill_account() { let (wasm, _code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -1158,10 +1158,10 @@ fn transfer_allow_death_cannot_kill_account() { // Check that the BOB contract has been instantiated. get_contract(&addr); - let total_balance = ::Fungible::total_balance(&addr); + let total_balance = ::Currency::total_balance(&addr); assert_err!( - <::Fungible as Mutate>::transfer( + <::Currency as Mutate>::transfer( &addr, &ALICE, total_balance, @@ -1170,7 +1170,7 @@ fn transfer_allow_death_cannot_kill_account() { TokenError::Frozen, ); - assert_eq!(::Fungible::total_balance(&addr), total_balance); + assert_eq!(::Currency::total_balance(&addr), total_balance); }); } @@ -1178,7 +1178,7 @@ fn transfer_allow_death_cannot_kill_account() { fn cannot_self_destruct_through_draning() { let (wasm, _code_hash) = compile_module::("drain").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -1212,8 +1212,8 @@ fn cannot_self_destruct_through_draning() { // Make sure the account wasn't remove by sending all free balance away. assert_eq!( - ::Fungible::total_balance(&addr), - 1_000 + ::Fungible::minimum_balance(), + ::Currency::total_balance(&addr), + 1_000 + ::Currency::minimum_balance(), ); }); } @@ -1222,8 +1222,8 @@ fn cannot_self_destruct_through_draning() { fn cannot_self_destruct_through_storage_refund_after_price_change() { let (wasm, _code_hash) = compile_module::("store_call").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); - let min_balance = ::Fungible::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); + let min_balance = ::Currency::minimum_balance(); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -1244,7 +1244,7 @@ fn cannot_self_destruct_through_storage_refund_after_price_change() { // Check that the BOB contract has been instantiated and has the minimum balance assert_eq!(get_contract(&addr).total_deposit(), min_balance); assert_eq!(get_contract(&addr).extra_deposit(), 0); - assert_eq!(::Fungible::total_balance(&addr), min_balance); + assert_eq!(::Currency::total_balance(&addr), min_balance); // Create 100 bytes of storage with a price of per byte and a single storage item of price 2 assert_ok!(Contracts::call( @@ -1271,7 +1271,7 @@ fn cannot_self_destruct_through_storage_refund_after_price_change() { // Make sure the account wasn't removed by the refund assert_eq!( - ::Fungible::total_balance(get_contract(&addr).deposit_account()), + ::Currency::total_balance(get_contract(&addr).deposit_account()), get_contract(&addr).total_deposit(), ); assert_eq!(get_contract(&addr).extra_deposit(), 2); @@ -1282,7 +1282,7 @@ fn cannot_self_destruct_through_storage_refund_after_price_change() { fn cannot_self_destruct_while_live() { let (wasm, _code_hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -1326,8 +1326,8 @@ fn cannot_self_destruct_while_live() { fn self_destruct_works() { let (wasm, code_hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(1_000).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); - let _ = ::Fungible::set_balance(&DJANGO, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&DJANGO, 1_000_000); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -1362,11 +1362,11 @@ fn self_destruct_works() { // Check that account is gone assert!(get_contract_checked(&addr).is_none()); - assert_eq!(::Fungible::total_balance(&addr), 0); + assert_eq!(::Currency::total_balance(&addr), 0); // check that the beneficiary (django) got remaining balance - let ed = ::Fungible::minimum_balance(); - assert_eq!(::Fungible::free_balance(DJANGO), 1_000_000 + 100_000 + ed); + let ed = ::Currency::minimum_balance(); + assert_eq!(::Currency::free_balance(DJANGO), 1_000_000 + 100_000 + ed); pretty_assertions::assert_eq!( System::events(), @@ -1433,7 +1433,7 @@ fn destroy_contract_and_transfer_funds() { ExtBuilder::default().existential_deposit(50).build().execute_with(|| { // Create code hash for bob to instantiate - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); Contracts::bare_upload_code(ALICE, callee_wasm, None, Determinism::Enforced).unwrap(); // This deploys the BOB contract, which in turn deploys the CHARLIE contract during @@ -1477,7 +1477,7 @@ fn destroy_contract_and_transfer_funds() { fn cannot_self_destruct_in_constructor() { let (wasm, _) = compile_module::("self_destructing_constructor").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); // Fail to instantiate the BOB because the contructor calls seal_terminate. assert_err_ignore_postinfo!( @@ -1500,7 +1500,7 @@ fn crypto_hashes() { let (wasm, _code_hash) = compile_module::("crypto_hashes").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); // Instantiate the CRYPTO_HASHES contract. let addr = Contracts::bare_instantiate( @@ -1562,8 +1562,8 @@ fn crypto_hashes() { fn transfer_return_code() { let (wasm, _code_hash) = compile_module::("transfer_return_code").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); - let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Currency::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, @@ -1581,7 +1581,7 @@ fn transfer_return_code() { .account_id; // Contract has only the minimal balance so any transfer will fail. - ::Fungible::set_balance(&addr, min_balance); + ::Currency::set_balance(&addr, min_balance); let result = Contracts::bare_call( ALICE, addr.clone(), @@ -1604,9 +1604,9 @@ fn call_return_code() { let (caller_code, _caller_hash) = compile_module::("call_return_code").unwrap(); let (callee_code, _callee_hash) = compile_module::("ok_trap_revert").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); - let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); - let _ = ::Fungible::set_balance(&CHARLIE, 1000 * min_balance); + let min_balance = ::Currency::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); + let _ = ::Currency::set_balance(&CHARLIE, 1000 * min_balance); let addr_bob = Contracts::bare_instantiate( ALICE, @@ -1622,7 +1622,7 @@ fn call_return_code() { .result .unwrap() .account_id; - ::Fungible::set_balance(&addr_bob, min_balance); + ::Currency::set_balance(&addr_bob, min_balance); // Contract calls into Django which is no valid contract let result = Contracts::bare_call( @@ -1654,7 +1654,7 @@ fn call_return_code() { .result .unwrap() .account_id; - ::Fungible::set_balance(&addr_django, min_balance); + ::Currency::set_balance(&addr_django, min_balance); // Contract has only the minimal balance so any transfer will fail. let result = Contracts::bare_call( @@ -1677,7 +1677,7 @@ fn call_return_code() { assert_return_code!(result, RuntimeReturnCode::TransferFailed); // Contract has enough balance but callee reverts because "1" is passed. - ::Fungible::set_balance(&addr_bob, min_balance + 1000); + ::Currency::set_balance(&addr_bob, min_balance + 1000); let result = Contracts::bare_call( ALICE, addr_bob.clone(), @@ -1724,9 +1724,9 @@ fn instantiate_return_code() { let (caller_code, _caller_hash) = compile_module::("instantiate_return_code").unwrap(); let (callee_code, callee_hash) = compile_module::("ok_trap_revert").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); - let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); - let _ = ::Fungible::set_balance(&CHARLIE, 1000 * min_balance); + let min_balance = ::Currency::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); + let _ = ::Currency::set_balance(&CHARLIE, 1000 * min_balance); let callee_hash = callee_hash.as_ref().to_vec(); assert_ok!(Contracts::instantiate_with_code( @@ -1755,7 +1755,7 @@ fn instantiate_return_code() { .account_id; // Contract has only the minimal balance so any transfer will fail. - ::Fungible::set_balance(&addr, min_balance); + ::Currency::set_balance(&addr, min_balance); let result = Contracts::bare_call( ALICE, addr.clone(), @@ -1772,7 +1772,7 @@ fn instantiate_return_code() { assert_return_code!(result, RuntimeReturnCode::TransferFailed); // Contract has enough balance but the passed code hash is invalid - ::Fungible::set_balance(&addr, min_balance + 10_000); + ::Currency::set_balance(&addr, min_balance + 10_000); let result = Contracts::bare_call( ALICE, addr.clone(), @@ -1826,8 +1826,8 @@ fn instantiate_return_code() { fn disabled_chain_extension_wont_deploy() { let (code, _hash) = compile_module::("chain_extension").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); - let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Currency::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); TestExtension::disable(); assert_err_ignore_postinfo!( Contracts::instantiate_with_code( @@ -1848,8 +1848,8 @@ fn disabled_chain_extension_wont_deploy() { fn disabled_chain_extension_errors_on_call() { let (code, _hash) = compile_module::("chain_extension").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); - let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Currency::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, min_balance * 100, @@ -1876,8 +1876,8 @@ fn disabled_chain_extension_errors_on_call() { fn chain_extension_works() { let (code, _hash) = compile_module::("chain_extension").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); - let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Currency::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, min_balance * 100, @@ -2023,8 +2023,8 @@ fn chain_extension_works() { fn chain_extension_temp_storage_works() { let (code, _hash) = compile_module::("chain_extension_temp_storage").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); - let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Currency::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, min_balance * 100, @@ -2070,8 +2070,8 @@ fn chain_extension_temp_storage_works() { fn lazy_removal_works() { let (code, _hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); - let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Currency::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, @@ -2122,8 +2122,8 @@ fn lazy_removal_works() { fn lazy_batch_removal_works() { let (code, _hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); - let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Currency::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let mut tries: Vec = vec![]; for i in 0..3u8 { @@ -2190,8 +2190,8 @@ fn lazy_removal_partial_remove_works() { let mut ext = ExtBuilder::default().existential_deposit(50).build(); let trie = ext.execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); - let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Currency::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, @@ -2272,8 +2272,8 @@ fn lazy_removal_partial_remove_works() { fn lazy_removal_does_no_run_on_low_remaining_weight() { let (code, _hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); - let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Currency::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, @@ -2344,8 +2344,8 @@ fn lazy_removal_does_not_use_all_weight() { let mut ext = ExtBuilder::default().existential_deposit(50).build(); let (trie, vals, weight_per_key) = ext.execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); - let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Currency::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, @@ -2432,8 +2432,8 @@ fn deletion_queue_ring_buffer_overflow() { ext.commit_all().unwrap(); ext.execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); - let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Currency::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let mut tries: Vec = vec![]; // add 3 contracts to the deletion queue @@ -2492,8 +2492,8 @@ fn deletion_queue_ring_buffer_overflow() { fn refcounter() { let (wasm, code_hash) = compile_module::("self_destruct").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); - let min_balance = ::Fungible::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); + let min_balance = ::Currency::minimum_balance(); // Create two contracts with the same code and check that they do in fact share it. let addr0 = Contracts::bare_instantiate( @@ -2589,8 +2589,8 @@ fn refcounter() { fn reinstrument_does_charge() { let (wasm, code_hash) = compile_module::("return_with_data").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); - let min_balance = ::Fungible::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); + let min_balance = ::Currency::minimum_balance(); let zero = 0u32.to_le_bytes().encode(); let code_len = wasm.len() as u32; @@ -2673,7 +2673,7 @@ fn debug_message_works() { let (wasm, _code_hash) = compile_module::("debug_message_works").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, 30_000, @@ -2710,7 +2710,7 @@ fn debug_message_logging_disabled() { let (wasm, _code_hash) = compile_module::("debug_message_logging_disabled").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, 30_000, @@ -2749,7 +2749,7 @@ fn debug_message_invalid_utf8() { let (wasm, _code_hash) = compile_module::("debug_message_invalid_utf8").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, 30_000, @@ -2785,8 +2785,8 @@ fn gas_estimation_nested_call_fixed_limit() { let (caller_code, _caller_hash) = compile_module::("call_with_limit").unwrap(); let (callee_code, _callee_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); - let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Currency::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let addr_caller = Contracts::bare_instantiate( ALICE, @@ -2881,9 +2881,9 @@ fn gas_estimation_call_runtime() { let (caller_code, _caller_hash) = compile_module::("call_runtime").unwrap(); let (callee_code, _callee_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); - let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); - let _ = ::Fungible::set_balance(&CHARLIE, 1000 * min_balance); + let min_balance = ::Currency::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); + let _ = ::Currency::set_balance(&CHARLIE, 1000 * min_balance); let addr_caller = Contracts::bare_instantiate( ALICE, @@ -2960,9 +2960,9 @@ fn call_runtime_reentrancy_guarded() { let (caller_code, _caller_hash) = compile_module::("call_runtime").unwrap(); let (callee_code, _callee_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); - let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); - let _ = ::Fungible::set_balance(&CHARLIE, 1000 * min_balance); + let min_balance = ::Currency::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); + let _ = ::Currency::set_balance(&CHARLIE, 1000 * min_balance); let addr_caller = Contracts::bare_instantiate( ALICE, @@ -3028,7 +3028,7 @@ fn ecdsa_recover() { let (wasm, _code_hash) = compile_module::("ecdsa_recover").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); // Instantiate the ecdsa_recover contract. let addr = Contracts::bare_instantiate( @@ -3091,8 +3091,8 @@ fn ecdsa_recover() { fn bare_instantiate_returns_events() { let (wasm, _code_hash) = compile_module::("transfer_return_code").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); - let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Currency::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let result = Contracts::bare_instantiate( ALICE, @@ -3116,8 +3116,8 @@ fn bare_instantiate_returns_events() { fn bare_instantiate_does_not_return_events() { let (wasm, _code_hash) = compile_module::("transfer_return_code").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); - let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Currency::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let result = Contracts::bare_instantiate( ALICE, @@ -3141,8 +3141,8 @@ fn bare_instantiate_does_not_return_events() { fn bare_call_returns_events() { let (wasm, _code_hash) = compile_module::("transfer_return_code").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); - let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Currency::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, @@ -3182,8 +3182,8 @@ fn bare_call_returns_events() { fn bare_call_does_not_return_events() { let (wasm, _code_hash) = compile_module::("transfer_return_code").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let min_balance = ::Fungible::minimum_balance(); - let _ = ::Fungible::set_balance(&ALICE, 1000 * min_balance); + let min_balance = ::Currency::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1000 * min_balance); let addr = Contracts::bare_instantiate( ALICE, @@ -3224,7 +3224,7 @@ fn sr25519_verify() { let (wasm, _code_hash) = compile_module::("sr25519_verify").unwrap(); ExtBuilder::default().existential_deposit(50).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); // Instantiate the sr25519_verify contract. let addr = Contracts::bare_instantiate( @@ -3295,7 +3295,7 @@ fn failed_deposit_charge_should_roll_back_call() { let execute = || { ExtBuilder::default().existential_deposit(ED).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); // Instantiate both contracts. let addr_caller = Contracts::bare_instantiate( @@ -3374,7 +3374,7 @@ fn upload_code_works() { let (wasm, code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); // Drop previous events initialize_block(2); @@ -3416,7 +3416,7 @@ fn upload_code_limit_too_low() { let (wasm, _code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); // Drop previous events initialize_block(2); @@ -3440,7 +3440,7 @@ fn upload_code_not_enough_balance() { let (wasm, _code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 150); + let _ = ::Currency::set_balance(&ALICE, 150); // Drop previous events initialize_block(2); @@ -3464,7 +3464,7 @@ fn remove_code_works() { let (wasm, code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); // Drop previous events initialize_block(2); @@ -3523,7 +3523,7 @@ fn remove_code_wrong_origin() { let (wasm, code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); // Drop previous events initialize_block(2); @@ -3568,7 +3568,7 @@ fn remove_code_in_use() { let (wasm, code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); assert_ok!(Contracts::instantiate_with_code( RuntimeOrigin::signed(ALICE), @@ -3597,7 +3597,7 @@ fn remove_code_not_found() { let (_wasm, code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); // Drop previous events initialize_block(2); @@ -3615,8 +3615,8 @@ fn remove_code_not_found() { fn instantiate_with_zero_balance_works() { let (wasm, code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); - let min_balance = ::Fungible::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); + let min_balance = ::Currency::minimum_balance(); // Drop previous events initialize_block(2); @@ -3644,8 +3644,8 @@ fn instantiate_with_zero_balance_works() { let deposit_account = contract.deposit_account().deref(); // Make sure the account exists even though no free balance was send - assert_eq!(::Fungible::free_balance(&addr), min_balance); - assert_eq!(::Fungible::total_balance(&addr), min_balance,); + assert_eq!(::Currency::free_balance(&addr), min_balance); + assert_eq!(::Currency::total_balance(&addr), min_balance,); assert_eq!( System::events(), @@ -3728,8 +3728,8 @@ fn instantiate_with_zero_balance_works() { fn instantiate_with_below_existential_deposit_works() { let (wasm, code_hash) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); - let min_balance = ::Fungible::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); + let min_balance = ::Currency::minimum_balance(); // Drop previous events initialize_block(2); @@ -3757,8 +3757,8 @@ fn instantiate_with_below_existential_deposit_works() { let deposit_account = contract.deposit_account().deref(); // Make sure the account exists even though not enough free balance was send - assert_eq!(::Fungible::free_balance(&addr), min_balance + 50); - assert_eq!(::Fungible::total_balance(&addr), min_balance + 50); + assert_eq!(::Currency::free_balance(&addr), min_balance + 50); + assert_eq!(::Currency::total_balance(&addr), min_balance + 50); assert_eq!( System::events(), @@ -3850,8 +3850,8 @@ fn instantiate_with_below_existential_deposit_works() { fn storage_deposit_works() { let (wasm, _code_hash) = compile_module::("multi_store").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); - let mut deposit = ::Fungible::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); + let mut deposit = ::Currency::minimum_balance(); let addr = Contracts::bare_instantiate( ALICE, @@ -3989,7 +3989,7 @@ fn storage_deposit_callee_works() { let (wasm_callee, _code_hash_callee) = compile_module::("store_call").unwrap(); const ED: u64 = 200; ExtBuilder::default().existential_deposit(ED).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); // Create both contracts: Constructors do nothing. let addr_caller = Contracts::bare_instantiate( @@ -4046,7 +4046,7 @@ fn set_code_extrinsic() { assert_ne!(code_hash, new_code_hash); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, @@ -4134,7 +4134,7 @@ fn slash_cannot_kill_account() { ExtBuilder::default().existential_deposit(ED).build().execute_with(|| { let value = 700; let balance_held = 500; - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, @@ -4156,26 +4156,26 @@ fn slash_cannot_kill_account() { // We need to hold some balances in order to have something to slash. As slashing can only // affect balances held under certain HoldReason. - ::Fungible::hold( + ::Currency::hold( &HoldReason::StorageDepositReserve.into(), &addr, balance_held, ) .unwrap(); - assert_eq!(::Fungible::total_balance_on_hold(&addr), balance_held); + assert_eq!(::Currency::total_balance_on_hold(&addr), balance_held); // Try to destroy the account of the contract by slashing the total balance. // The account does not get destroyed because of the consumer reference. // Slashing can for example happen if the contract takes part in staking. - let _ = ::Fungible::slash( + let _ = ::Currency::slash( &HoldReason::StorageDepositReserve.into(), &addr, - ::Fungible::total_balance(&addr), + ::Currency::total_balance(&addr), ); // Slashing only removed the balance held. - assert_eq!(::Fungible::total_balance(&addr), value + ED - balance_held,); + assert_eq!(::Currency::total_balance(&addr), value + ED - balance_held,); }); } @@ -4184,7 +4184,7 @@ fn contract_reverted() { let (wasm, code_hash) = compile_module::("return_with_data").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); let flags = ReturnFlags::REVERT; let buffer = [4u8, 8, 15, 16, 23, 42]; let input = (flags.bits(), buffer).encode(); @@ -4297,7 +4297,7 @@ fn contract_reverted() { #[test] fn code_rejected_error_works() { ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); let (wasm, _) = compile_module::("invalid_module").unwrap(); assert_noop!( @@ -4362,7 +4362,7 @@ fn set_code_hash() { let (new_wasm, new_code_hash) = compile_module::("new_set_code_hash_contract").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); // Instantiate the 'caller' let contract_addr = Contracts::bare_instantiate( @@ -4465,8 +4465,8 @@ fn set_code_hash() { fn storage_deposit_limit_is_enforced() { let (wasm, _code_hash) = compile_module::("store_call").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); - let min_balance = ::Fungible::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); + let min_balance = ::Currency::minimum_balance(); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -4486,7 +4486,7 @@ fn storage_deposit_limit_is_enforced() { // Check that the BOB contract has been instantiated and has the minimum balance assert_eq!(get_contract(&addr).total_deposit(), min_balance); - assert_eq!(::Fungible::total_balance(&addr), min_balance); + assert_eq!(::Currency::total_balance(&addr), min_balance); // Create 1 byte of storage with a price of per byte, // setting insufficient deposit limit, as it requires 3 Balance: @@ -4541,7 +4541,7 @@ fn deposit_limit_in_nested_calls() { compile_module::("create_storage_and_call").unwrap(); let (wasm_callee, _code_hash_callee) = compile_module::("store_call").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); // Create both contracts: Constructors do nothing. let addr_caller = Contracts::bare_instantiate( @@ -4650,7 +4650,7 @@ fn deposit_limit_in_nested_calls() { >::StorageDepositLimitExhausted, ); - let _ = ::Fungible::set_balance(&ALICE, 1_000); + let _ = ::Currency::set_balance(&ALICE, 1_000); // Require more than the sender's balance. // We don't set a special limit for the nested call. @@ -4687,8 +4687,8 @@ fn deposit_limit_in_nested_instantiate() { let (wasm_callee, code_hash_callee) = compile_module::("store_deploy").unwrap(); const ED: u64 = 5; ExtBuilder::default().existential_deposit(ED).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); - let _ = ::Fungible::set_balance(&BOB, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&BOB, 1_000_000); // Create caller contract let addr_caller = Contracts::bare_instantiate( ALICE, @@ -4745,7 +4745,7 @@ fn deposit_limit_in_nested_instantiate() { >::StorageDepositLimitExhausted, ); // The charges made on instantiation should be rolled back. - assert_eq!(::Fungible::free_balance(&BOB), 1_000_000); + assert_eq!(::Currency::free_balance(&BOB), 1_000_000); // Now we give enough limit for the instantiation itself, but require for 1 more storage // byte in the constructor. Hence +1 Balance to the limit is needed. This should fail on the @@ -4762,7 +4762,7 @@ fn deposit_limit_in_nested_instantiate() { >::StorageDepositLimitExhausted, ); // The charges made on the instantiation should be rolled back. - assert_eq!(::Fungible::free_balance(&BOB), 1_000_000); + assert_eq!(::Currency::free_balance(&BOB), 1_000_000); // Now we set enough limit in parent call, but an insufficient limit for child instantiate. // This should fail during the charging for the instantiation in @@ -4779,7 +4779,7 @@ fn deposit_limit_in_nested_instantiate() { >::StorageDepositLimitExhausted, ); // The charges made on the instantiation should be rolled back. - assert_eq!(::Fungible::free_balance(&BOB), 1_000_000); + assert_eq!(::Currency::free_balance(&BOB), 1_000_000); // Same as above but requires for single added storage // item of 1 byte to be covered by the limit, which implies 3 more Balance. @@ -4797,7 +4797,7 @@ fn deposit_limit_in_nested_instantiate() { >::StorageDepositLimitExhausted, ); // The charges made on the instantiation should be rolled back. - assert_eq!(::Fungible::free_balance(&BOB), 1_000_000); + assert_eq!(::Currency::free_balance(&BOB), 1_000_000); // Set enough deposit limit for the child instantiate. This should succeed. let result = Contracts::bare_call( @@ -4815,18 +4815,18 @@ fn deposit_limit_in_nested_instantiate() { let returned = result.result.unwrap(); // All balance of the caller except ED has been transferred to the callee. // No deposit has been taken from it. - assert_eq!(::Fungible::free_balance(&addr_caller), ED); + assert_eq!(::Currency::free_balance(&addr_caller), ED); // Get address of the deployed contract. let addr_callee = AccountId32::from_slice(&returned.data[0..32]).unwrap(); // 10_000 should be sent to callee from the caller contract, plus ED to be sent from the // origin. - assert_eq!(::Fungible::free_balance(&addr_callee), 10_000 + ED); + assert_eq!(::Currency::free_balance(&addr_callee), 10_000 + ED); // The origin should be charged with: // - callee instantiation deposit = (callee_info_len + 2) // - callee account ED // - for writing an item of 1 byte to storage = 3 Balance assert_eq!( - ::Fungible::free_balance(&BOB), + ::Currency::free_balance(&BOB), 1_000_000 - (callee_info_len + 2 + ED + 3) ); // Check that deposit due to be charged still includes these 3 Balance @@ -4840,9 +4840,9 @@ fn deposit_limit_honors_liquidity_restrictions() { const ED: u64 = 200; ExtBuilder::default().existential_deposit(ED).build().execute_with(|| { let bobs_balance = 1_000; - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); - let _ = ::Fungible::set_balance(&BOB, bobs_balance); - let min_balance = ::Fungible::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&BOB, bobs_balance); + let min_balance = ::Currency::minimum_balance(); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -4862,10 +4862,10 @@ fn deposit_limit_honors_liquidity_restrictions() { // Check that the contract has been instantiated and has the minimum balance assert_eq!(get_contract(&addr).total_deposit(), min_balance); - assert_eq!(::Fungible::total_balance(&addr), min_balance); + assert_eq!(::Currency::total_balance(&addr), min_balance); // check that the hold is honored - ::Fungible::hold( + ::Currency::hold( &HoldReason::StorageDepositReserve.into(), &BOB, bobs_balance - ED, @@ -4882,7 +4882,7 @@ fn deposit_limit_honors_liquidity_restrictions() { ), >::StorageDepositNotEnoughFunds, ); - assert_eq!(::Fungible::free_balance(&BOB), ED); + assert_eq!(::Currency::free_balance(&BOB), ED); }); } @@ -4890,9 +4890,9 @@ fn deposit_limit_honors_liquidity_restrictions() { fn deposit_limit_honors_existential_deposit() { let (wasm, _code_hash) = compile_module::("store_call").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); - let _ = ::Fungible::set_balance(&BOB, 1_000); - let min_balance = ::Fungible::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&BOB, 1_000); + let min_balance = ::Currency::minimum_balance(); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -4912,7 +4912,7 @@ fn deposit_limit_honors_existential_deposit() { // Check that the contract has been instantiated and has the minimum balance assert_eq!(get_contract(&addr).total_deposit(), min_balance); - assert_eq!(::Fungible::total_balance(&addr), min_balance); + assert_eq!(::Currency::total_balance(&addr), min_balance); // check that the deposit can't bring the account below the existential deposit assert_err_ignore_postinfo!( @@ -4926,7 +4926,7 @@ fn deposit_limit_honors_existential_deposit() { ), >::StorageDepositNotEnoughFunds, ); - assert_eq!(::Fungible::free_balance(&BOB), 1_000); + assert_eq!(::Currency::free_balance(&BOB), 1_000); }); } @@ -4934,9 +4934,9 @@ fn deposit_limit_honors_existential_deposit() { fn deposit_limit_honors_min_leftover() { let (wasm, _code_hash) = compile_module::("store_call").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); - let _ = ::Fungible::set_balance(&BOB, 1_000); - let min_balance = ::Fungible::minimum_balance(); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&BOB, 1_000); + let min_balance = ::Currency::minimum_balance(); // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( @@ -4956,7 +4956,7 @@ fn deposit_limit_honors_min_leftover() { // Check that the contract has been instantiated and has the minimum balance assert_eq!(get_contract(&addr).total_deposit(), min_balance); - assert_eq!(::Fungible::total_balance(&addr), min_balance); + assert_eq!(::Currency::total_balance(&addr), min_balance); // check that the minimum leftover (value send) is considered assert_err_ignore_postinfo!( @@ -4970,7 +4970,7 @@ fn deposit_limit_honors_min_leftover() { ), >::StorageDepositNotEnoughFunds, ); - assert_eq!(::Fungible::free_balance(&BOB), 1_000); + assert_eq!(::Currency::free_balance(&BOB), 1_000); }); } @@ -4979,7 +4979,7 @@ fn cannot_instantiate_indeterministic_code() { let (wasm, code_hash) = compile_module::("float_instruction").unwrap(); let (caller_wasm, _) = compile_module::("instantiate_return_code").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); // Try to instantiate directly from code assert_err_ignore_postinfo!( @@ -5113,7 +5113,7 @@ fn cannot_set_code_indeterministic_code() { let (wasm, code_hash) = compile_module::("float_instruction").unwrap(); let (caller_wasm, _) = compile_module::("set_code_hash").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); // Put the non deterministic contract on-chain assert_ok!(Contracts::upload_code( @@ -5163,7 +5163,7 @@ fn delegate_call_indeterministic_code() { let (wasm, code_hash) = compile_module::("float_instruction").unwrap(); let (caller_wasm, _) = compile_module::("delegate_call_simple").unwrap(); ExtBuilder::default().existential_deposit(200).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); // Put the non deterministic contract on-chain assert_ok!(Contracts::upload_code( @@ -5229,7 +5229,7 @@ fn reentrance_count_works_with_call() { let (wasm, _code_hash) = compile_module::("reentrance_count_call").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); let contract_addr = Contracts::bare_instantiate( ALICE, @@ -5270,7 +5270,7 @@ fn reentrance_count_works_with_delegated_call() { let (wasm, code_hash) = compile_module::("reentrance_count_delegated_call").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); let contract_addr = Contracts::bare_instantiate( ALICE, @@ -5313,7 +5313,7 @@ fn account_reentrance_count_works() { compile_module::("reentrance_count_call").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); let contract_addr = Contracts::bare_instantiate( ALICE, @@ -5429,7 +5429,7 @@ fn root_can_call() { let (wasm, _) = compile_module::("dummy").unwrap(); ExtBuilder::default().existential_deposit(100).build().execute_with(|| { - let _ = ::Fungible::set_balance(&ALICE, 1_000_000); + let _ = ::Currency::set_balance(&ALICE, 1_000_000); let addr = Contracts::bare_instantiate( ALICE, diff --git a/frame/contracts/src/wasm/code_cache.rs b/frame/contracts/src/wasm/code_cache.rs index d5beb95ea0e6f..14acce3f92513 100644 --- a/frame/contracts/src/wasm/code_cache.rs +++ b/frame/contracts/src/wasm/code_cache.rs @@ -96,7 +96,7 @@ pub fn store(mut module: PrefabWasmModule, instantiated: bool) -> ); // This `None` case happens only in freshly uploaded modules. This means that // the `owner` is always the origin of the current transaction. - T::Fungible::hold( + T::Currency::hold( &HoldReason::StorageDepositReserve.into(), &new_owner_info.owner, new_owner_info.deposit, @@ -163,7 +163,7 @@ pub fn try_remove(origin: &T::AccountId, code_hash: CodeHash) -> D if let Some(owner_info) = existing { ensure!(owner_info.refcount == 0, >::CodeInUse); ensure!(&owner_info.owner == origin, BadOrigin); - T::Fungible::release( + T::Currency::release( &HoldReason::StorageDepositReserve.into(), &owner_info.owner, owner_info.deposit, From 4da6b172a5c11ae697ca3ab6d40a47993675145c Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 16 Jun 2023 12:21:10 +0200 Subject: [PATCH 041/105] update runtime --- bin/node/runtime/src/lib.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index e77468dd514e8..b8185854bf10f 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1210,22 +1210,17 @@ impl pallet_tips::Config for Runtime { type WeightInfo = pallet_tips::weights::SubstrateWeight; } -pub enum HoldIdentifier { - StorageDepositReserve, -} - parameter_types! { pub const DepositPerItem: Balance = deposit(1, 0); pub const DepositPerByte: Balance = deposit(0, 1); pub const DefaultDepositLimit: Balance = deposit(1024, 1024 * 1024); pub Schedule: pallet_contracts::Schedule = Default::default(); - pub const HoldReason: RuntimeHoldReason = HoldIdentifier::StorageDepositReserve; } impl pallet_contracts::Config for Runtime { type Time = Timestamp; type Randomness = RandomnessCollectiveFlip; - type Fungible = Balances; + type Currency = Balances; type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; /// The safest default is to allow no calls at all. @@ -1248,7 +1243,7 @@ impl pallet_contracts::Config for Runtime { type MaxStorageKeyLen = ConstU32<128>; type UnsafeUnstableInterface = ConstBool; type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>; - type HoldReason = HoldReason; + type RuntimeHoldReason = RuntimeHoldReason; #[cfg(not(feature = "runtime-benchmarks"))] type Migrations = (); #[cfg(feature = "runtime-benchmarks")] From 790a8d225614dd3960ff25eaeba44e90bc822a52 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 27 Jun 2023 13:12:07 +0200 Subject: [PATCH 042/105] WIP --- frame/contracts/src/benchmarking/mod.rs | 64 +++++++++++++------------ frame/contracts/src/migration/v10.rs | 4 +- 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 3e8fc9d378110..ecfcddd8f9907 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -36,7 +36,9 @@ use crate::{ }; use codec::{Encode, MaxEncodedLen}; use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; -use frame_support::{pallet_prelude::StorageVersion, weights::Weight}; +use frame_support::{ + pallet_prelude::StorageVersion, traits::fungible::InspectHold, weights::Weight, +}; use frame_system::RawOrigin; use sp_runtime::{ traits::{Bounded, Hash}, @@ -69,6 +71,7 @@ struct Contract { impl Contract where as HasCompact>::Type: Clone + Eq + PartialEq + Debug + TypeInfo + Encode, + BalanceOf: FixedPointOperand, { /// Create new contract and use a default account id as instantiator. fn new(module: WasmModule, data: Vec) -> Result, &'static str> { @@ -91,7 +94,7 @@ where data: Vec, ) -> Result, &'static str> { let value = Pallet::::min_balance(); - T::Currency::make_free_balance_be(&caller, caller_funding::()); + T::Currency::set_balance(&caller, caller_funding::()); let salt = vec![0xff]; let addr = Contracts::::contract_address(&caller, &module.hash, &data, &salt); @@ -157,7 +160,7 @@ where /// Set the balance of the contract to the supplied amount. fn set_balance(&self, balance: BalanceOf) { - T::Currency::make_free_balance_be(&self.account_id, balance); + T::Currency::set_balance(&self.account_id, balance); } /// Returns `true` iff all storage entries related to code storage exist. @@ -201,6 +204,7 @@ macro_rules! load_benchmark { benchmarks! { where_clause { where as codec::HasCompact>::Type: Clone + Eq + PartialEq + sp_std::fmt::Debug + scale_info::TypeInfo + codec::Encode, + BalanceOf: FixedPointOperand, } // The base weight consumed on processing contracts deletion queue. @@ -362,22 +366,22 @@ benchmarks! { let salt = vec![42u8; s as usize]; let value = Pallet::::min_balance(); let caller = whitelisted_caller(); - T::Currency::make_free_balance_be(&caller, caller_funding::()); + T::Currency::set_balance(&caller, caller_funding::()); let WasmModule { code, hash, .. } = WasmModule::::sized(c, Location::Call); let origin = RawOrigin::Signed(caller.clone()); let addr = Contracts::::contract_address(&caller, &hash, &input, &salt); }: _(origin, value, Weight::MAX, None, code, input, salt) verify { let deposit_account = Contract::::address_info(&addr)?.deposit_account().clone(); - let deposit = T::Currency::free_balance(&deposit_account); + let deposit = T::Currency::balance(&deposit_account); // uploading the code reserves some balance in the callers account - let code_deposit = T::Currency::reserved_balance(&caller); + let code_deposit = T::Currency::total_balance_on_hold(&caller); assert_eq!( - T::Currency::free_balance(&caller), + T::Currency::balance(&caller), caller_funding::() - value - deposit - code_deposit - Pallet::::min_balance(), ); // contract has the full value - assert_eq!(T::Currency::free_balance(&addr), value + Pallet::::min_balance()); + assert_eq!(T::Currency::balance(&addr), value + Pallet::::min_balance()); } // Instantiate uses a dummy contract constructor to measure the overhead of the instantiate. @@ -391,7 +395,7 @@ benchmarks! { let salt = vec![42u8; s as usize]; let value = Pallet::::min_balance(); let caller = whitelisted_caller(); - T::Currency::make_free_balance_be(&caller, caller_funding::()); + T::Currency::set_balance(&caller, caller_funding::()); let WasmModule { code, hash, .. } = WasmModule::::dummy(); let origin = RawOrigin::Signed(caller.clone()); let addr = Contracts::::contract_address(&caller, &hash, &input, &salt); @@ -399,14 +403,14 @@ benchmarks! { }: _(origin, value, Weight::MAX, None, hash, input, salt) verify { let deposit_account = Contract::::address_info(&addr)?.deposit_account().clone(); - let deposit = T::Currency::free_balance(&deposit_account); + let deposit = T::Currency::balance(&deposit_account); // value was removed from the caller assert_eq!( - T::Currency::free_balance(&caller), + T::Currency::balance(&caller), caller_funding::() - value - deposit - Pallet::::min_balance(), ); // contract has the full value - assert_eq!(T::Currency::free_balance(&addr), value + Pallet::::min_balance()); + assert_eq!(T::Currency::balance(&addr), value + Pallet::::min_balance()); } // We just call a dummy contract to measure the overhead of the call extrinsic. @@ -426,18 +430,18 @@ benchmarks! { let value = Pallet::::min_balance(); let origin = RawOrigin::Signed(instance.caller.clone()); let callee = instance.addr.clone(); - let before = T::Currency::free_balance(&instance.account_id); - let before_deposit = T::Currency::free_balance(&deposit_account); + let before = T::Currency::balance(&instance.account_id); + let before_deposit = T::Currency::balance(&deposit_account); }: _(origin, callee, value, Weight::MAX, None, data) verify { - let deposit = T::Currency::free_balance(&deposit_account); + let deposit = T::Currency::balance(&deposit_account); // value and value transferred via call should be removed from the caller assert_eq!( - T::Currency::free_balance(&instance.caller), + T::Currency::balance(&instance.caller), caller_funding::() - instance.value - value - deposit - Pallet::::min_balance(), ); // contract should have received the value - assert_eq!(T::Currency::free_balance(&instance.account_id), before + value); + assert_eq!(T::Currency::balance(&instance.account_id), before + value); // contract should still exist instance.info()?; } @@ -454,13 +458,13 @@ benchmarks! { upload_code { let c in 0 .. Perbill::from_percent(49).mul_ceil(T::MaxCodeLen::get()); let caller = whitelisted_caller(); - T::Currency::make_free_balance_be(&caller, caller_funding::()); + T::Currency::set_balance(&caller, caller_funding::()); let WasmModule { code, hash, .. } = WasmModule::::sized(c, Location::Call); let origin = RawOrigin::Signed(caller.clone()); }: _(origin, code, None, Determinism::Enforced) verify { // uploading the code reserves some balance in the callers account - assert!(T::Currency::reserved_balance(&caller) > 0u32.into()); + assert!(T::Currency::total_balance_on_hold(&caller) > 0u32.into()); assert!(>::code_exists(&hash)); } @@ -470,17 +474,17 @@ benchmarks! { #[pov_mode = Measured] remove_code { let caller = whitelisted_caller(); - T::Currency::make_free_balance_be(&caller, caller_funding::()); + T::Currency::set_balance(&caller, caller_funding::()); let WasmModule { code, hash, .. } = WasmModule::::dummy(); let origin = RawOrigin::Signed(caller.clone()); let uploaded = >::bare_upload_code(caller.clone(), code, None, Determinism::Enforced)?; assert_eq!(uploaded.code_hash, hash); - assert_eq!(uploaded.deposit, T::Currency::reserved_balance(&caller)); + assert_eq!(uploaded.deposit, T::Currency::total_balance_on_hold(&caller)); assert!(>::code_exists(&hash)); }: _(origin, hash) verify { // removing the code should have unreserved the deposit - assert_eq!(T::Currency::reserved_balance(&caller), 0u32.into()); + assert_eq!(T::Currency::total_balance_on_hold(&caller), 0u32.into()); assert!(>::code_removed(&hash)); } @@ -897,15 +901,15 @@ benchmarks! { let instance = Contract::::new(code, vec![])?; let origin = RawOrigin::Signed(instance.caller.clone()); let deposit_account = instance.info()?.deposit_account().clone(); - assert_eq!(>::total_balance(&beneficiary), 0u32.into()); - assert_eq!(T::Currency::free_balance(&instance.account_id), Pallet::::min_balance() * 2u32.into()); - assert_ne!(T::Currency::free_balance(&deposit_account), 0u32.into()); + assert_eq!(T::Currency::total_balance(&beneficiary), 0u32.into()); + assert_eq!(T::Currency::balance(&instance.account_id), Pallet::::min_balance() * 2u32.into()); + assert_ne!(T::Currency::balance(&deposit_account), 0u32.into()); }: call(origin, instance.addr.clone(), 0u32.into(), Weight::MAX, None, vec![]) verify { if r > 0 { - assert_eq!(>::total_balance(&instance.account_id), 0u32.into()); - assert_eq!(>::total_balance(&deposit_account), 0u32.into()); - assert_eq!(>::total_balance(&beneficiary), Pallet::::min_balance() * 2u32.into()); + assert_eq!(T::Currency::total_balance(&instance.account_id), 0u32.into()); + assert_eq!(T::Currency::total_balance(&deposit_account), 0u32.into()); + assert_eq!(T::Currency::total_balance(&beneficiary), Pallet::::min_balance() * 2u32.into()); } } @@ -1674,12 +1678,12 @@ benchmarks! { instance.set_balance(value * (r + 1).into()); let origin = RawOrigin::Signed(instance.caller.clone()); for account in &accounts { - assert_eq!(>::total_balance(account), 0u32.into()); + assert_eq!(T::Currency::total_balance(account), 0u32.into()); } }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) verify { for account in &accounts { - assert_eq!(>::total_balance(account), value); + assert_eq!(T::Currency::total_balance(account), value); } } diff --git a/frame/contracts/src/migration/v10.rs b/frame/contracts/src/migration/v10.rs index 38e79613c3a92..bb40733422196 100644 --- a/frame/contracts/src/migration/v10.rs +++ b/frame/contracts/src/migration/v10.rs @@ -43,7 +43,7 @@ use sp_runtime::TryRuntimeError; use sp_runtime::{traits::Zero, Perbill, Saturating}; use sp_std::{marker::PhantomData, ops::Deref, prelude::*}; -mod old { +pub mod old { use super::*; pub type BalanceOf = >( account: T::AccountId, - info: crate::ContractInfo, + info: crate::ContractInfo, ) { let info = old::ContractInfo { trie_id: info.trie_id, From 1922bfe0ecede4b362af7b9e7d828f34ee4f08d5 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Mon, 3 Jul 2023 11:21:13 +0200 Subject: [PATCH 043/105] make v10 benchmark generic over currency --- frame/contracts/Cargo.toml | 5 ++- frame/contracts/src/benchmarking/mod.rs | 11 +++--- frame/contracts/src/migration/v10.rs | 46 +++++++++++++++---------- 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/frame/contracts/Cargo.toml b/frame/contracts/Cargo.toml index cb47b24884288..aadfd2207847c 100644 --- a/frame/contracts/Cargo.toml +++ b/frame/contracts/Cargo.toml @@ -39,6 +39,7 @@ environmental = { version = "1.1.4", default-features = false } frame-benchmarking = { version = "4.0.0-dev", default-features = false, path = "../benchmarking", optional = true } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" } +pallet-balances = { version = "4.0.0-dev", path = "../balances", optional = true, default-features = false } pallet-contracts-primitives = { version = "24.0.0", default-features = false, path = "primitives" } pallet-contracts-proc-macro = { version = "4.0.0-dev", path = "proc-macro" } sp-api = { version = "4.0.0-dev", default-features = false, path = "../../primitives/api" } @@ -55,8 +56,8 @@ pretty_assertions = "1" wat = "1" # Substrate Dependencies -pallet-balances = { version = "4.0.0-dev", path = "../balances" } pallet-timestamp = { version = "4.0.0-dev", path = "../timestamp" } +pallet-balances = { version = "4.0.0-dev", path = "../balances" } pallet-insecure-randomness-collective-flip = { version = "4.0.0-dev", path = "../insecure-randomness-collective-flip" } pallet-utility = { version = "4.0.0-dev", path = "../utility" } pallet-proxy = { version = "4.0.0-dev", path = "../proxy" } @@ -83,10 +84,12 @@ std = [ "rand/std", "wasmparser/std", "environmental/std", + "pallet-balances/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "rand", "rand_pcg", + "pallet-balances", ] try-runtime = ["frame-support/try-runtime"] diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index ecfcddd8f9907..4af126623c693 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -37,9 +37,10 @@ use crate::{ use codec::{Encode, MaxEncodedLen}; use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; use frame_support::{ - pallet_prelude::StorageVersion, traits::fungible::InspectHold, weights::Weight, + self, pallet_prelude::StorageVersion, traits::fungible::InspectHold, weights::Weight, }; use frame_system::RawOrigin; +use pallet_balances; use sp_runtime::{ traits::{Bounded, Hash}, Perbill, @@ -68,8 +69,9 @@ struct Contract { value: BalanceOf, } -impl Contract +impl Contract where + T: Config + pallet_balances::Config, as HasCompact>::Type: Clone + Eq + PartialEq + Debug + TypeInfo + Encode, BalanceOf: FixedPointOperand, { @@ -205,6 +207,7 @@ benchmarks! { where_clause { where as codec::HasCompact>::Type: Clone + Eq + PartialEq + sp_std::fmt::Debug + scale_info::TypeInfo + codec::Encode, BalanceOf: FixedPointOperand, + T: Config + pallet_balances::Config, } // The base weight consumed on processing contracts deletion queue. @@ -255,8 +258,8 @@ benchmarks! { whitelisted_caller(), WasmModule::dummy(), vec![], )?; - v10::store_old_contract_info::(contract.account_id.clone(), contract.info()?); - let mut m = v10::Migration::::default(); + v10::store_old_contract_info::>(contract.account_id.clone(), contract.info()?); + let mut m = v10::Migration::>::default(); }: { m.step(); } diff --git a/frame/contracts/src/migration/v10.rs b/frame/contracts/src/migration/v10.rs index bb40733422196..c3bf3cd916525 100644 --- a/frame/contracts/src/migration/v10.rs +++ b/frame/contracts/src/migration/v10.rs @@ -43,26 +43,20 @@ use sp_runtime::TryRuntimeError; use sp_runtime::{traits::Zero, Perbill, Saturating}; use sp_std::{marker::PhantomData, ops::Deref, prelude::*}; -pub mod old { +mod old { use super::*; pub type BalanceOf = ::AccountId, >>::Balance; - /// Old Currency type traits - /// - /// This trait holds what the old [`T::Currency`] type required before is was replaced by the - /// `fungible` traits. - pub trait CurrencyOf: - ReservableCurrency<::AccountId> - + Inspect<::AccountId, Balance = BalanceOf> - { - } - #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)] #[scale_info(skip_type_params(T))] - pub struct ContractInfo> { + pub struct ContractInfo + where + Currency: ReservableCurrency<::AccountId> + + Inspect<::AccountId, Balance = old::BalanceOf>, + { pub trie_id: TrieId, pub code_hash: CodeHash, pub storage_bytes: u32, @@ -73,7 +67,7 @@ pub mod old { } #[storage_alias] - pub type ContractInfoOf> = StorageMap< + pub type ContractInfoOf = StorageMap< Pallet, Twox64Concat, ::AccountId, @@ -82,10 +76,14 @@ pub mod old { } #[cfg(feature = "runtime-benchmarks")] -pub fn store_old_contract_info>( +pub fn store_old_contract_info( account: T::AccountId, info: crate::ContractInfo, -) { +) where + Currency: ReservableCurrency<::AccountId> + + Inspect<::AccountId, Balance = old::BalanceOf> + + 'static, +{ let info = old::ContractInfo { trie_id: info.trie_id, code_hash: info.code_hash, @@ -112,7 +110,11 @@ impl Deref for DepositAccount { #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)] #[scale_info(skip_type_params(T))] -pub struct ContractInfo> { +pub struct ContractInfo +where + Currency: ReservableCurrency<::AccountId> + + Inspect<::AccountId, Balance = old::BalanceOf>, +{ pub trie_id: TrieId, deposit_account: DepositAccount, pub code_hash: CodeHash, @@ -124,7 +126,11 @@ pub struct ContractInfo> { } #[derive(Encode, Decode, MaxEncodedLen, DefaultNoBound)] -pub struct Migration> { +pub struct Migration +where + Currency: ReservableCurrency<::AccountId> + + Inspect<::AccountId, Balance = old::BalanceOf>, +{ last_key: Option>>, _phantom: PhantomData<(T, Currency)>, } @@ -137,7 +143,11 @@ type ContractInfoOf> = StorageMap< ContractInfo, >; -impl + 'static> Migrate for Migration { +impl Migrate for Migration +where + Currency: ReservableCurrency<::AccountId> + + Inspect<::AccountId, Balance = old::BalanceOf>, +{ const VERSION: u16 = 10; fn max_step_weight() -> Weight { From d3ea9e2fe6dd4e969cb14c6f80fff15ba90092a3 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 4 Jul 2023 14:36:38 +0200 Subject: [PATCH 044/105] solve merge conflicts --- frame/contracts/src/migration/v10.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frame/contracts/src/migration/v10.rs b/frame/contracts/src/migration/v10.rs index 044c7ee2f1b76..af086a91c6277 100644 --- a/frame/contracts/src/migration/v10.rs +++ b/frame/contracts/src/migration/v10.rs @@ -156,9 +156,9 @@ where fn step(&mut self) -> (IsFinished, Weight) { let mut iter = if let Some(last_account) = self.last_account.take() { - old::ContractInfoOf::::iter_from(old::ContractInfoOf::::hashed_key_for( - last_account, - )) + old::ContractInfoOf::::iter_from( + old::ContractInfoOf::::hashed_key_for(last_account), + ) } else { old::ContractInfoOf::::iter() }; From e6201c14d8f5819288bd647281be12327e9dc738 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 6 Jul 2023 16:21:39 +0200 Subject: [PATCH 045/105] make v12 migration benchmarking generic over DepositPerItem and DepositPerByte --- frame/contracts/src/benchmarking/mod.rs | 24 +++++++++++---- frame/contracts/src/chain_extension.rs | 39 ++++++++++++++++++++----- frame/contracts/src/migration/v11.rs | 4 ++- frame/contracts/src/migration/v12.rs | 5 ++-- 4 files changed, 55 insertions(+), 17 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 85d448ca80db1..804349665e28a 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -39,15 +39,12 @@ use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; use frame_support::{ self, pallet_prelude::StorageVersion, - traits::{fungible::InspectHold, ConstU64}, + traits::{fungible::InspectHold, ReservableCurrency}, weights::Weight, }; use frame_system::RawOrigin; use pallet_balances; -use sp_runtime::{ - traits::{Bounded, Hash}, - Perbill, -}; +use sp_runtime::traits::{Bounded, Hash}; use sp_std::prelude::*; use wasm_instrument::parity_wasm::elements::{BlockType, Instruction, ValueType}; @@ -265,7 +262,22 @@ benchmarks! { v12_migration_step { let c in 0 .. T::MaxCodeLen::get(); v12::store_old_dummy_code::>(c as usize, account::("account", 0, 0)); - let mut m = v12::Migration::, BalanceOf, BalanceOf>::default(); + + struct OldDepositPerItem(PhantomData<(T,Currency)>); + + type OldDepositPerByte = OldDepositPerItem; + + impl Get> for OldDepositPerItem + where + T: Config, + Currency: ReservableCurrency<::AccountId>, + { + fn get() -> v12::old::BalanceOf { + v12::old::BalanceOf::::default() + } + } + + let mut m = v12::Migration::, OldDepositPerItem>, OldDepositPerByte>>::default(); }: { m.step(); } diff --git a/frame/contracts/src/chain_extension.rs b/frame/contracts/src/chain_extension.rs index d4b52942046a6..ad261011ed40e 100644 --- a/frame/contracts/src/chain_extension.rs +++ b/frame/contracts/src/chain_extension.rs @@ -111,7 +111,9 @@ pub trait ChainExtension { /// In case of `Err` the contract execution is immediately suspended and the passed error /// is returned to the caller. Otherwise the value of [`RetVal`] determines the exit /// behaviour. - fn call>(&mut self, env: Environment) -> Result where BalanceOf: FixedPointOperand; + fn call>(&mut self, env: Environment) -> Result + where + BalanceOf: FixedPointOperand; /// Determines whether chain extensions are enabled for this chain. /// @@ -147,7 +149,10 @@ pub trait RegisteredChainExtension: ChainExtension { #[impl_trait_for_tuples::impl_for_tuples(10)] #[tuple_types_custom_trait_bound(RegisteredChainExtension)] impl ChainExtension for Tuple { - fn call>(&mut self, mut env: Environment) -> Result where BalanceOf: FixedPointOperand { + fn call>(&mut self, mut env: Environment) -> Result + where + BalanceOf: FixedPointOperand, + { for_tuples!( #( if (Tuple::ID == env.ext_id()) && Tuple::enabled() { @@ -198,7 +203,10 @@ where } /// Functions that are available in every state of this type. -impl<'a, 'b, E: Ext, S: State> Environment<'a, 'b, E, S> where BalanceOf: FixedPointOperand{ +impl<'a, 'b, E: Ext, S: State> Environment<'a, 'b, E, S> +where + BalanceOf: FixedPointOperand, +{ /// The function id within the `id` passed by a contract. /// /// It returns the two least significant bytes of the `id` passed by a contract as the other @@ -253,7 +261,10 @@ impl<'a, 'b, E: Ext, S: State> Environment<'a, 'b, E, S> where BalanceOf: /// /// Those are the functions that determine how the arguments to the chain extensions /// should be consumed. -impl<'a, 'b, E: Ext> Environment<'a, 'b, E, InitState> where BalanceOf: FixedPointOperand { +impl<'a, 'b, E: Ext> Environment<'a, 'b, E, InitState> +where + BalanceOf: FixedPointOperand, +{ /// Creates a new environment for consumption by a chain extension. /// /// It is only available to this crate because only the wasm runtime module needs to @@ -293,7 +304,10 @@ impl<'a, 'b, E: Ext> Environment<'a, 'b, E, InitState> where BalanceOf: Fi } /// Functions to use the input arguments as integers. -impl<'a, 'b, E: Ext, S: PrimIn> Environment<'a, 'b, E, S> where BalanceOf: FixedPointOperand{ +impl<'a, 'b, E: Ext, S: PrimIn> Environment<'a, 'b, E, S> +where + BalanceOf: FixedPointOperand, +{ /// The `input_ptr` argument. pub fn val0(&self) -> u32 { self.inner.input_ptr @@ -306,7 +320,10 @@ impl<'a, 'b, E: Ext, S: PrimIn> Environment<'a, 'b, E, S> where BalanceOf: } /// Functions to use the output arguments as integers. -impl<'a, 'b, E: Ext, S: PrimOut> Environment<'a, 'b, E, S> where BalanceOf: FixedPointOperand{ +impl<'a, 'b, E: Ext, S: PrimOut> Environment<'a, 'b, E, S> +where + BalanceOf: FixedPointOperand, +{ /// The `output_ptr` argument. pub fn val2(&self) -> u32 { self.inner.output_ptr @@ -319,7 +336,10 @@ impl<'a, 'b, E: Ext, S: PrimOut> Environment<'a, 'b, E, S> where BalanceOf } /// Functions to use the input arguments as pointer to a buffer. -impl<'a, 'b, E: Ext, S: BufIn> Environment<'a, 'b, E, S> where BalanceOf: FixedPointOperand{ +impl<'a, 'b, E: Ext, S: BufIn> Environment<'a, 'b, E, S> +where + BalanceOf: FixedPointOperand, +{ /// Reads `min(max_len, in_len)` from contract memory. /// /// This does **not** charge any weight. The caller must make sure that the an @@ -391,7 +411,10 @@ impl<'a, 'b, E: Ext, S: BufIn> Environment<'a, 'b, E, S> where BalanceOf: } /// Functions to use the output arguments as pointer to a buffer. -impl<'a, 'b, E: Ext, S: BufOut> Environment<'a, 'b, E, S> where BalanceOf: FixedPointOperand{ +impl<'a, 'b, E: Ext, S: BufOut> Environment<'a, 'b, E, S> +where + BalanceOf: FixedPointOperand, +{ /// Write the supplied buffer to contract memory. /// /// If the contract supplied buffer is smaller than the passed `buffer` an `Err` is returned. diff --git a/frame/contracts/src/migration/v11.rs b/frame/contracts/src/migration/v11.rs index 67740cfaf6c80..8123d73aee560 100644 --- a/frame/contracts/src/migration/v11.rs +++ b/frame/contracts/src/migration/v11.rs @@ -80,7 +80,9 @@ impl MigrationStep for Migration { } fn step(&mut self) -> (IsFinished, Weight) { - let Some(old_queue) = old::DeletionQueue::::take() else { return (IsFinished::Yes, Weight::zero()) }; + let Some(old_queue) = old::DeletionQueue::::take() else { + return (IsFinished::Yes, Weight::zero()) + }; let len = old_queue.len(); log::debug!( diff --git a/frame/contracts/src/migration/v12.rs b/frame/contracts/src/migration/v12.rs index 6d140b4a010a3..ba49c1dca4240 100644 --- a/frame/contracts/src/migration/v12.rs +++ b/frame/contracts/src/migration/v12.rs @@ -38,7 +38,7 @@ use sp_runtime::TryRuntimeError; use sp_runtime::{traits::Zero, FixedPointNumber, FixedU128, Saturating}; use sp_std::prelude::*; -mod old { +pub mod old { use super::*; pub type BalanceOf = = StorageMap, Identity, CodeHash, pub fn store_old_dummy_code(len: usize, account: T::AccountId) where Currency: ReservableCurrency<::AccountId> - + Inspect<::AccountId, Balance = old::BalanceOf>, + + Inspect<::AccountId, Balance = old::BalanceOf> + + 'static, { use sp_runtime::traits::Hash; From 22fd92457a8c867e69abde80ea06ba24cc263d85 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 6 Jul 2023 16:43:41 +0200 Subject: [PATCH 046/105] give some format --- frame/contracts/src/benchmarking/mod.rs | 12 ++++++++++-- frame/contracts/src/wasm/mod.rs | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 804349665e28a..c07cf39605b20 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -261,7 +261,10 @@ benchmarks! { #[pov_mode = Measured] v12_migration_step { let c in 0 .. T::MaxCodeLen::get(); - v12::store_old_dummy_code::>(c as usize, account::("account", 0, 0)); + v12::store_old_dummy_code::< + T, + pallet_balances::Pallet + >(c as usize, account::("account", 0, 0)); struct OldDepositPerItem(PhantomData<(T,Currency)>); @@ -277,7 +280,12 @@ benchmarks! { } } - let mut m = v12::Migration::, OldDepositPerItem>, OldDepositPerByte>>::default(); + let mut m = v12::Migration::< + T, + pallet_balances::Pallet, + OldDepositPerItem>, + OldDepositPerByte> + >::default(); }: { m.step(); } diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index b042c43ae0541..8e59da3794202 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -302,7 +302,7 @@ impl WasmBlob { ) } if maximum > schedule.limits.memory_pages { - return Err("Maximum number of memory pages should not exceed the maximum configured in the Schedule.") + return Err("Maximum number of memory pages should not exceed the maximum configured in the Schedule."); } Ok((initial, maximum)) } From f8da1e0cf5fff2c0f96f64927c12a97f08fd601d Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 7 Jul 2023 12:18:43 +0200 Subject: [PATCH 047/105] fix tests and old migrations --- frame/contracts/src/migration.rs | 3 +- frame/contracts/src/migration/v10.rs | 90 ++++++++++++++-------------- frame/contracts/src/migration/v12.rs | 18 +++--- frame/contracts/src/tests.rs | 20 ++----- frame/contracts/src/wasm/mod.rs | 18 ++++++ 5 files changed, 81 insertions(+), 68 deletions(-) diff --git a/frame/contracts/src/migration.rs b/frame/contracts/src/migration.rs index 827135e081223..1736562261c66 100644 --- a/frame/contracts/src/migration.rs +++ b/frame/contracts/src/migration.rs @@ -33,7 +33,8 @@ //! ``` //! use pallet_contracts::migration::{v9, v10, v11}; //! # pub enum Runtime {}; -//! type Migrations = (v9::Migration, v10::Migration, v11::Migration); +//! # struct OldCurrency; +//! type Migrations = (v9::Migration, v10::Migration, v11::Migration); //! ``` //! //! ## Notes: diff --git a/frame/contracts/src/migration/v10.rs b/frame/contracts/src/migration/v10.rs index af086a91c6277..b730c653f3d24 100644 --- a/frame/contracts/src/migration/v10.rs +++ b/frame/contracts/src/migration/v10.rs @@ -46,42 +46,45 @@ use sp_std::{ops::Deref, prelude::*}; mod old { use super::*; - pub type BalanceOf = = ::AccountId, >>::Balance; #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)] #[scale_info(skip_type_params(T))] - pub struct ContractInfo + pub struct ContractInfo where - Currency: ReservableCurrency<::AccountId> - + Inspect<::AccountId, Balance = old::BalanceOf>, + OldCurrency: ReservableCurrency<::AccountId> + + Inspect< + ::AccountId, + Balance = old::BalanceOf, + >, { pub trie_id: TrieId, pub code_hash: CodeHash, pub storage_bytes: u32, pub storage_items: u32, - pub storage_byte_deposit: BalanceOf, - pub storage_item_deposit: BalanceOf, - pub storage_base_deposit: BalanceOf, + pub storage_byte_deposit: BalanceOf, + pub storage_item_deposit: BalanceOf, + pub storage_base_deposit: BalanceOf, } #[storage_alias] - pub type ContractInfoOf = StorageMap< + pub type ContractInfoOf = StorageMap< Pallet, Twox64Concat, ::AccountId, - ContractInfo, + ContractInfo, >; } #[cfg(feature = "runtime-benchmarks")] -pub fn store_old_contract_info( +pub fn store_old_contract_info( account: T::AccountId, info: crate::ContractInfo, ) where - Currency: ReservableCurrency<::AccountId> - + Inspect<::AccountId, Balance = old::BalanceOf> + OldCurrency: ReservableCurrency<::AccountId> + + Inspect<::AccountId, Balance = old::BalanceOf> + 'static, { let info = old::ContractInfo { @@ -93,7 +96,7 @@ pub fn store_old_contract_info( storage_item_deposit: Default::default(), storage_base_deposit: Default::default(), }; - old::ContractInfoOf::::insert(account, info); + old::ContractInfoOf::::insert(account, info); } #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebugNoBound, TypeInfo, MaxEncodedLen)] @@ -110,43 +113,43 @@ impl Deref for DepositAccount { #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)] #[scale_info(skip_type_params(T))] -pub struct ContractInfo +pub struct ContractInfo where - Currency: ReservableCurrency<::AccountId> - + Inspect<::AccountId, Balance = old::BalanceOf>, + OldCurrency: ReservableCurrency<::AccountId> + + Inspect<::AccountId, Balance = old::BalanceOf>, { pub trie_id: TrieId, deposit_account: DepositAccount, pub code_hash: CodeHash, storage_bytes: u32, storage_items: u32, - pub storage_byte_deposit: old::BalanceOf, - storage_item_deposit: old::BalanceOf, - storage_base_deposit: old::BalanceOf, + pub storage_byte_deposit: old::BalanceOf, + storage_item_deposit: old::BalanceOf, + storage_base_deposit: old::BalanceOf, } #[derive(Encode, Decode, MaxEncodedLen, DefaultNoBound)] -pub struct Migration +pub struct Migration where - Currency: ReservableCurrency<::AccountId> - + Inspect<::AccountId, Balance = old::BalanceOf>, + OldCurrency: ReservableCurrency<::AccountId> + + Inspect<::AccountId, Balance = old::BalanceOf>, { last_account: Option, - _phantom: PhantomData<(T, Currency)>, + _phantom: PhantomData<(T, OldCurrency)>, } #[storage_alias] -type ContractInfoOf> = StorageMap< +type ContractInfoOf> = StorageMap< Pallet, Twox64Concat, ::AccountId, - ContractInfo, + ContractInfo, >; -impl MigrationStep for Migration +impl MigrationStep for Migration where - Currency: ReservableCurrency<::AccountId> - + Inspect<::AccountId, Balance = old::BalanceOf>, + OldCurrency: ReservableCurrency<::AccountId> + + Inspect<::AccountId, Balance = old::BalanceOf>, { const VERSION: u16 = 10; @@ -156,15 +159,15 @@ where fn step(&mut self) -> (IsFinished, Weight) { let mut iter = if let Some(last_account) = self.last_account.take() { - old::ContractInfoOf::::iter_from( - old::ContractInfoOf::::hashed_key_for(last_account), + old::ContractInfoOf::::iter_from( + old::ContractInfoOf::::hashed_key_for(last_account), ) } else { - old::ContractInfoOf::::iter() + old::ContractInfoOf::::iter() }; if let Some((account, contract)) = iter.next() { - let min_balance = ::AccountId, >>::minimum_balance(); log::debug!(target: LOG_TARGET, "Account: 0x{} ", HexDisplay::from(&account.encode())); @@ -181,7 +184,7 @@ where // Unreserve the existing deposit // Note we can't use repatriate_reserve, because it only works with existing accounts - let remaining = Currency::unreserve(&account, old_deposit); + let remaining = OldCurrency::unreserve(&account, old_deposit); if !remaining.is_zero() { log::warn!( target: LOG_TARGET, @@ -194,9 +197,9 @@ where // Attempt to transfer the old deposit to the deposit account. let amount = old_deposit .saturating_sub(min_balance) - .min(Currency::reducible_balance(&account, Preserve, Polite)); + .min(OldCurrency::reducible_balance(&account, Preserve, Polite)); - let new_deposit = Currency::transfer( + let new_deposit = OldCurrency::transfer( &account, &deposit_account, amount, @@ -217,7 +220,7 @@ where "Failed to transfer the base deposit, reason: {:?}", err ); - Currency::deposit_creating(&deposit_account, min_balance); + OldCurrency::deposit_creating(&deposit_account, min_balance); min_balance }); @@ -257,7 +260,7 @@ where storage_base_deposit, }; - ContractInfoOf::::insert(&account, new_contract_info); + ContractInfoOf::::insert(&account, new_contract_info); // Store last key for next migration step self.last_account = Some(account); @@ -271,7 +274,7 @@ where #[cfg(feature = "try-runtime")] fn pre_upgrade_step() -> Result, TryRuntimeError> { - let sample: Vec<_> = old::ContractInfoOf::::iter().take(10).collect(); + let sample: Vec<_> = old::ContractInfoOf::::iter().take(10).collect(); log::debug!(target: LOG_TARGET, "Taking sample of {} contracts", sample.len()); Ok(sample.encode()) @@ -279,7 +282,7 @@ where #[cfg(feature = "try-runtime")] fn post_upgrade_step(state: Vec) -> Result<(), TryRuntimeError> { - let sample = )> as Decode>::decode( + let sample = )> as Decode>::decode( &mut &state[..], ) .expect("pre_upgrade_step provides a valid state; qed"); @@ -288,16 +291,15 @@ where for (account, old_contract) in sample { log::debug!(target: LOG_TARGET, "==="); log::debug!(target: LOG_TARGET, "Account: 0x{} ", HexDisplay::from(&account.encode())); - let contract = ContractInfoOf::::get(&account).unwrap(); + let contract = ContractInfoOf::::get(&account).unwrap(); ensure!(old_contract.trie_id == contract.trie_id, "invalid trie_id"); ensure!(old_contract.code_hash == contract.code_hash, "invalid code_hash"); ensure!(old_contract.storage_bytes == contract.storage_bytes, "invalid storage_bytes"); ensure!(old_contract.storage_items == contract.storage_items, "invalid storage_items"); - let deposit = - <::Currency as frame_support::traits::Currency<_>>::total_balance( - &contract.deposit_account, - ); + let deposit = >::total_balance( + &contract.deposit_account, + ); ensure!( deposit == contract diff --git a/frame/contracts/src/migration/v12.rs b/frame/contracts/src/migration/v12.rs index ba49c1dca4240..b9b0ba3648371 100644 --- a/frame/contracts/src/migration/v12.rs +++ b/frame/contracts/src/migration/v12.rs @@ -253,12 +253,12 @@ where fn pre_upgrade_step() -> Result, TryRuntimeError> { let len = 100; log::debug!(target: LOG_TARGET, "Taking sample of {} OwnerInfo(s)", len); - let sample: Vec<_> = old::OwnerInfoOf::::iter() + let sample: Vec<_> = old::OwnerInfoOf::::iter() .take(len) .map(|(k, v)| { let module = old::CodeStorage::::get(k) .expect("No PrefabWasmModule found for code_hash: {:?}"); - let info: CodeInfo = CodeInfo { + let info: CodeInfo = CodeInfo { determinism: module.determinism, deposit: v.deposit, refcount: v.refcount, @@ -270,22 +270,22 @@ where let storage: u32 = old::CodeStorage::::iter().map(|(_k, v)| v.encoded_size() as u32).sum(); - let mut deposit: BalanceOf = Default::default(); - old::OwnerInfoOf::::iter().for_each(|(_k, v)| deposit += v.deposit); + let mut deposit: old::BalanceOf = Default::default(); + old::OwnerInfoOf::::iter().for_each(|(_k, v)| deposit += v.deposit); Ok((sample, deposit, storage).encode()) } #[cfg(feature = "try-runtime")] fn post_upgrade_step(state: Vec) -> Result<(), TryRuntimeError> { - let state = <(Vec<(CodeHash, CodeInfo)>, BalanceOf, u32) as Decode>::decode( + let state = <(Vec<(CodeHash, CodeInfo)>, old::BalanceOf, u32) as Decode>::decode( &mut &state[..], ) .unwrap(); log::debug!(target: LOG_TARGET, "Validating state of {} Codeinfo(s)", state.0.len()); for (hash, old) in state.0 { - let info = CodeInfoOf::::get(&hash) + let info = CodeInfoOf::::get(&hash) .expect(format!("CodeInfo for code_hash {:?} not found!", hash).as_str()); ensure!(info.determinism == old.determinism, "invalid determinism"); ensure!(info.owner == old.owner, "invalid owner"); @@ -301,7 +301,7 @@ where } else { log::debug!(target: LOG_TARGET, "CodeStorage is empty."); } - if let Some((k, _)) = old::OwnerInfoOf::::iter().next() { + if let Some((k, _)) = old::OwnerInfoOf::::iter().next() { log::warn!( target: LOG_TARGET, "OwnerInfoOf is still NOT empty, found code_hash: {:?}", @@ -311,10 +311,10 @@ where log::debug!(target: LOG_TARGET, "OwnerInfoOf is empty."); } - let mut deposit: BalanceOf = Default::default(); + let mut deposit: old::BalanceOf = Default::default(); let mut items = 0u32; let mut storage_info = 0u32; - CodeInfoOf::::iter().for_each(|(_k, v)| { + CodeInfoOf::::iter().for_each(|(_k, v)| { deposit += v.deposit; items += 1; storage_info += v.encoded_size() as u32; diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 30263d965e3f3..7180f6b23c341 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -3506,7 +3506,7 @@ fn upload_code_works() { who: ALICE, amount: deposit_expected, }), - topics: vec![hash(&ALICE), hash(&deposit_expected)], + topics: vec![hash(&ALICE)], }, EventRecord { phase: Phase::Initialization, @@ -3580,8 +3580,6 @@ fn remove_code_works() { // Drop previous events initialize_block(2); - let deposit_amount = 173; - assert_ok!(Contracts::upload_code( RuntimeOrigin::signed(ALICE), wasm, @@ -3601,7 +3599,7 @@ fn remove_code_works() { who: ALICE, amount: deposit_expected, }), - topics: vec![hash(&ALICE), hash(&deposit_amount)], + topics: vec![hash(&ALICE)], }, EventRecord { phase: Phase::Initialization, @@ -3616,7 +3614,7 @@ fn remove_code_works() { amount: deposit_expected, } ), - topics: vec![hash(&ALICE), hash(&deposit_expected)], + topics: vec![hash(&ALICE)], }, EventRecord { phase: Phase::Initialization, @@ -3638,8 +3636,6 @@ fn remove_code_wrong_origin() { // Drop previous events initialize_block(2); - let deposit_amount = 173; - assert_ok!(Contracts::upload_code( RuntimeOrigin::signed(ALICE), wasm, @@ -3663,7 +3659,7 @@ fn remove_code_wrong_origin() { who: ALICE, amount: deposit_expected, }), - topics: vec![hash(&ALICE), hash(&deposit_amount)], + topics: vec![hash(&ALICE)], }, EventRecord { phase: Phase::Initialization, @@ -3733,8 +3729,6 @@ fn instantiate_with_zero_balance_works() { // Drop previous events initialize_block(2); - let deposit_amount = 173; - // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( ALICE, @@ -3818,7 +3812,7 @@ fn instantiate_with_zero_balance_works() { who: ALICE, amount: deposit_expected, }), - topics: vec![hash(&ALICE), hash(&deposit_amount)], + topics: vec![hash(&ALICE)], }, EventRecord { phase: Phase::Initialization, @@ -3848,8 +3842,6 @@ fn instantiate_with_below_existential_deposit_works() { // Drop previous events initialize_block(2); - let deposit_amount = 173; - // Instantiate the BOB contract. let addr = Contracts::bare_instantiate( ALICE, @@ -3941,7 +3933,7 @@ fn instantiate_with_below_existential_deposit_works() { who: ALICE, amount: deposit_expected, }), - topics: vec![hash(&ALICE), hash(&deposit_amount)], + topics: vec![hash(&ALICE)], }, EventRecord { phase: Phase::Initialization, diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index 67a8fee416510..bcd86bb382486 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -49,6 +49,7 @@ use frame_support::{ ensure, traits::{fungible::MutateHold, tokens::Precision::BestEffort}, }; +use sp_api::HashT; use sp_core::Get; use sp_runtime::{FixedPointOperand, RuntimeDebug, TokenError}; use sp_std::prelude::*; @@ -298,6 +299,14 @@ impl WasmBlob { _ => e, })?; + >::deposit_event( + vec![T::Hashing::hash_of(&module.code_info.owner)], + Event::StorageDepositHeld { + who: module.code_info.owner.clone(), + amount: module.code_info.deposit, + }, + ); + module.code_info.refcount = if instantiated { 1 } else { 0 }; >::insert(code_hash, module.code); *stored_code_info = Some(module.code_info); @@ -323,6 +332,15 @@ impl WasmBlob { code_info.deposit, BestEffort, ); + + >::deposit_event( + vec![T::Hashing::hash_of(&code_info.owner)], + Event::StorageDepositReleased { + who: code_info.owner.clone(), + amount: code_info.deposit, + }, + ); + *existing = None; >::remove(&code_hash); >::deposit_event(vec![code_hash], Event::CodeRemoved { code_hash }); From e29f2d4d944419430360d81e21b38945591a2c81 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 11 Jul 2023 11:16:30 +0200 Subject: [PATCH 048/105] add migration v13 placholder --- frame/contracts/src/migration/v13.rs | 44 ++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 frame/contracts/src/migration/v13.rs diff --git a/frame/contracts/src/migration/v13.rs b/frame/contracts/src/migration/v13.rs new file mode 100644 index 0000000000000..4bfcc9206be6b --- /dev/null +++ b/frame/contracts/src/migration/v13.rs @@ -0,0 +1,44 @@ +// 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. + +//! Move contracts' _reserved_ balance to be _held_ instead. Since +//! [`Currency`](frame_support::traits::Currency) has been deprecated [here](https://github.com/paritytech/substrate/pull/12951), +//! we need the storage deposit to be handled by the [fungible +//! traits](frame_support::traits::fungibles) instead. + +pub struct Migration +where + OldCurrency: ReservableCurrency<::AccountId> + + Inspect<::AccountId, Balance = old::BalanceOf>, +{ + last_account: Option, + _phantom: PhantomData<(T, OldCurrency)>, +} + +impl MigrationStep for Migration +where + OldCurrency: ReservableCurrency<::AccountId> + + Inspect<::AccountId, Balance = old::BalanceOf>, +{ + const VERSION: u16 = 10; + + fn max_step_weight() -> Weight { + T::WeightInfo::v10_migration_step() + } + + fn step(&mut self) -> (IsFinished, Weight) {} +} From 6df91bd7ac92b639805eb79fde68d151c7f20cd6 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 11 Jul 2023 16:19:09 +0200 Subject: [PATCH 049/105] wip --- frame/contracts/src/migration/v10.rs | 6 +- frame/contracts/src/migration/v12.rs | 109 ++++++++++++++------------- frame/contracts/src/migration/v13.rs | 36 ++++++++- 3 files changed, 94 insertions(+), 57 deletions(-) diff --git a/frame/contracts/src/migration/v10.rs b/frame/contracts/src/migration/v10.rs index b730c653f3d24..fb8d5b926810c 100644 --- a/frame/contracts/src/migration/v10.rs +++ b/frame/contracts/src/migration/v10.rs @@ -51,7 +51,7 @@ mod old { >>::Balance; #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)] - #[scale_info(skip_type_params(T))] + #[scale_info(skip_type_params(T, OldCurrency))] pub struct ContractInfo where OldCurrency: ReservableCurrency<::AccountId> @@ -112,7 +112,7 @@ impl Deref for DepositAccount { } #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)] -#[scale_info(skip_type_params(T))] +#[scale_info(skip_type_params(T, OldCurrency))] pub struct ContractInfo where OldCurrency: ReservableCurrency<::AccountId> @@ -139,7 +139,7 @@ where } #[storage_alias] -type ContractInfoOf> = StorageMap< +type ContractInfoOf = StorageMap< Pallet, Twox64Concat, ::AccountId, diff --git a/frame/contracts/src/migration/v12.rs b/frame/contracts/src/migration/v12.rs index b9b0ba3648371..eb55f60f853e2 100644 --- a/frame/contracts/src/migration/v12.rs +++ b/frame/contracts/src/migration/v12.rs @@ -41,21 +41,24 @@ use sp_std::prelude::*; pub mod old { use super::*; - pub type BalanceOf = = ::AccountId, >>::Balance; #[derive(Encode, Decode, scale_info::TypeInfo, MaxEncodedLen)] #[codec(mel_bound())] - #[scale_info(skip_type_params(T))] - pub struct OwnerInfo + #[scale_info(skip_type_params(T, OldCurrency))] + pub struct OwnerInfo where - Currency: ReservableCurrency<::AccountId> - + Inspect<::AccountId, Balance = old::BalanceOf>, + OldCurrency: ReservableCurrency<::AccountId> + + Inspect< + ::AccountId, + Balance = old::BalanceOf, + >, { pub owner: AccountIdOf, #[codec(compact)] - pub deposit: BalanceOf, + pub deposit: BalanceOf, #[codec(compact)] pub refcount: u64, } @@ -75,8 +78,8 @@ pub mod old { } #[storage_alias] - pub type OwnerInfoOf = - StorageMap, Identity, CodeHash, OwnerInfo>; + pub type OwnerInfoOf = + StorageMap, Identity, CodeHash, OwnerInfo>; #[storage_alias] pub type CodeStorage = @@ -85,32 +88,32 @@ pub mod old { #[derive(Encode, Decode, scale_info::TypeInfo, MaxEncodedLen)] #[codec(mel_bound())] -#[scale_info(skip_type_params(T))] -pub struct CodeInfo +#[scale_info(skip_type_params(T, OldCurrency))] +pub struct CodeInfo where - Currency: ReservableCurrency<::AccountId> - + Inspect<::AccountId, Balance = old::BalanceOf>, + OldCurrency: ReservableCurrency<::AccountId> + + Inspect<::AccountId, Balance = old::BalanceOf>, { owner: AccountIdOf, #[codec(compact)] - deposit: old::BalanceOf, + deposit: old::BalanceOf, #[codec(compact)] refcount: u64, determinism: Determinism, } #[storage_alias] -pub type CodeInfoOf = - StorageMap, Twox64Concat, CodeHash, CodeInfo>; +pub type CodeInfoOf = + StorageMap, Twox64Concat, CodeHash, CodeInfo>; #[storage_alias] pub type PristineCode = StorageMap, Identity, CodeHash, Vec>; #[cfg(feature = "runtime-benchmarks")] -pub fn store_old_dummy_code(len: usize, account: T::AccountId) +pub fn store_old_dummy_code(len: usize, account: T::AccountId) where - Currency: ReservableCurrency<::AccountId> - + Inspect<::AccountId, Balance = old::BalanceOf> + OldCurrency: ReservableCurrency<::AccountId> + + Inspect<::AccountId, Balance = old::BalanceOf> + 'static, { use sp_runtime::traits::Hash; @@ -129,29 +132,29 @@ where old::CodeStorage::::insert(hash, module); let info = old::OwnerInfo { owner: account, deposit: u32::MAX.into(), refcount: u64::MAX }; - old::OwnerInfoOf::::insert(hash, info); + old::OwnerInfoOf::::insert(hash, info); } #[derive(Encode, Decode, MaxEncodedLen, DefaultNoBound)] -pub struct Migration +pub struct Migration where - Currency: ReservableCurrency<::AccountId> - + Inspect<::AccountId, Balance = old::BalanceOf>, - DepositPerByte: Get>, - DepositPerItem: Get>, + OldCurrency: ReservableCurrency<::AccountId> + + Inspect<::AccountId, Balance = old::BalanceOf>, + OldDepositPerByte: Get>, + OldDepositPerItem: Get>, { last_code_hash: Option>, - _phantom: PhantomData<(Currency, DepositPerByte, DepositPerItem)>, + _phantom: PhantomData<(OldCurrency, OldDepositPerByte, OldDepositPerItem)>, } -impl MigrationStep - for Migration +impl MigrationStep + for Migration where - Currency: ReservableCurrency<::AccountId> - + Inspect<::AccountId, Balance = old::BalanceOf> + OldCurrency: ReservableCurrency<::AccountId> + + Inspect<::AccountId, Balance = old::BalanceOf> + 'static, - DepositPerByte: Get>, - DepositPerItem: Get>, + OldDepositPerByte: Get>, + OldDepositPerItem: Get>, { const VERSION: u16 = 12; @@ -161,11 +164,11 @@ where fn step(&mut self) -> (IsFinished, Weight) { let mut iter = if let Some(last_key) = self.last_code_hash.take() { - old::OwnerInfoOf::::iter_from( - old::OwnerInfoOf::::hashed_key_for(last_key), + old::OwnerInfoOf::::iter_from( + old::OwnerInfoOf::::hashed_key_for(last_key), ) } else { - old::OwnerInfoOf::::iter() + old::OwnerInfoOf::::iter() }; if let Some((hash, old_info)) = iter.next() { log::debug!(target: LOG_TARGET, "Migrating OwnerInfo for code_hash {:?}", hash); @@ -192,12 +195,12 @@ where // 3. Calculate the deposit amount for storage after the migration, given current // prices. // 4. Calculate real deposit amount to be reserved after the migration. - let price_per_byte = DepositPerByte::get(); - let price_per_item = DepositPerItem::get(); + let price_per_byte = OldDepositPerByte::get(); + let price_per_item = OldDepositPerItem::get(); let bytes_before = module .encoded_size() .saturating_add(code_len) - .saturating_add(old::OwnerInfo::::max_encoded_len()) + .saturating_add(old::OwnerInfo::::max_encoded_len()) as u32; let items_before = 3u32; let deposit_expected_before = price_per_byte @@ -207,14 +210,14 @@ where .unwrap_or_default() .min(FixedU128::from_u32(1)); let bytes_after = - code_len.saturating_add(CodeInfo::::max_encoded_len()) as u32; + code_len.saturating_add(CodeInfo::::max_encoded_len()) as u32; let items_after = 2u32; let deposit_expected_after = price_per_byte .saturating_mul(bytes_after.into()) .saturating_add(price_per_item.saturating_mul(items_after.into())); let deposit = ratio.saturating_mul_int(deposit_expected_after); - let info = CodeInfo:: { + let info = CodeInfo:: { determinism: module.determinism, owner: old_info.owner, deposit, @@ -223,7 +226,7 @@ where let amount = old_info.deposit.saturating_sub(info.deposit); if !amount.is_zero() { - Currency::unreserve(&info.owner, amount); + OldCurrency::unreserve(&info.owner, amount); log::debug!( target: LOG_TARGET, "Deposit refunded: {:?} Balance, to: {:?}", @@ -238,7 +241,7 @@ where &old_info.deposit ); } - CodeInfoOf::::insert(hash, info); + CodeInfoOf::::insert(hash, info); self.last_code_hash = Some(hash); @@ -253,12 +256,12 @@ where fn pre_upgrade_step() -> Result, TryRuntimeError> { let len = 100; log::debug!(target: LOG_TARGET, "Taking sample of {} OwnerInfo(s)", len); - let sample: Vec<_> = old::OwnerInfoOf::::iter() + let sample: Vec<_> = old::OwnerInfoOf::::iter() .take(len) .map(|(k, v)| { let module = old::CodeStorage::::get(k) .expect("No PrefabWasmModule found for code_hash: {:?}"); - let info: CodeInfo = CodeInfo { + let info: CodeInfo = CodeInfo { determinism: module.determinism, deposit: v.deposit, refcount: v.refcount, @@ -270,22 +273,24 @@ where let storage: u32 = old::CodeStorage::::iter().map(|(_k, v)| v.encoded_size() as u32).sum(); - let mut deposit: old::BalanceOf = Default::default(); - old::OwnerInfoOf::::iter().for_each(|(_k, v)| deposit += v.deposit); + let mut deposit: old::BalanceOf = Default::default(); + old::OwnerInfoOf::::iter().for_each(|(_k, v)| deposit += v.deposit); Ok((sample, deposit, storage).encode()) } #[cfg(feature = "try-runtime")] fn post_upgrade_step(state: Vec) -> Result<(), TryRuntimeError> { - let state = <(Vec<(CodeHash, CodeInfo)>, old::BalanceOf, u32) as Decode>::decode( - &mut &state[..], - ) + let state = <( + Vec<(CodeHash, CodeInfo)>, + old::BalanceOf, + u32, + ) as Decode>::decode(&mut &state[..]) .unwrap(); log::debug!(target: LOG_TARGET, "Validating state of {} Codeinfo(s)", state.0.len()); for (hash, old) in state.0 { - let info = CodeInfoOf::::get(&hash) + let info = CodeInfoOf::::get(&hash) .expect(format!("CodeInfo for code_hash {:?} not found!", hash).as_str()); ensure!(info.determinism == old.determinism, "invalid determinism"); ensure!(info.owner == old.owner, "invalid owner"); @@ -301,7 +306,7 @@ where } else { log::debug!(target: LOG_TARGET, "CodeStorage is empty."); } - if let Some((k, _)) = old::OwnerInfoOf::::iter().next() { + if let Some((k, _)) = old::OwnerInfoOf::::iter().next() { log::warn!( target: LOG_TARGET, "OwnerInfoOf is still NOT empty, found code_hash: {:?}", @@ -311,10 +316,10 @@ where log::debug!(target: LOG_TARGET, "OwnerInfoOf is empty."); } - let mut deposit: old::BalanceOf = Default::default(); + let mut deposit: old::BalanceOf = Default::default(); let mut items = 0u32; let mut storage_info = 0u32; - CodeInfoOf::::iter().for_each(|(_k, v)| { + CodeInfoOf::::iter().for_each(|(_k, v)| { deposit += v.deposit; items += 1; storage_info += v.encoded_size() as u32; diff --git a/frame/contracts/src/migration/v13.rs b/frame/contracts/src/migration/v13.rs index 4bfcc9206be6b..35449af392fa9 100644 --- a/frame/contracts/src/migration/v13.rs +++ b/frame/contracts/src/migration/v13.rs @@ -20,6 +20,33 @@ //! we need the storage deposit to be handled by the [fungible //! traits](frame_support::traits::fungibles) instead. +mod old { + use super::*; + + pub type BalanceOf = ::AccountId, + >>::Balance; + + #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)] + #[scale_info(skip_type_params(T, OldCurrency))] + pub struct ContractInfo + where + OldCurrency: ReservableCurrency<::AccountId> + + Inspect< + ::AccountId, + Balance = old::BalanceOf, + >, + { + pub trie_id: TrieId, + pub deposit_account: DepositAccount, + pub code_hash: CodeHash, + pub storage_bytes: u32, + pub storage_items: u32, + pub storage_byte_deposit: BalanceOf, + pub storage_item_deposit: BalanceOf, + pub storage_base_deposit: BalanceOf, + } +} pub struct Migration where OldCurrency: ReservableCurrency<::AccountId> @@ -34,11 +61,16 @@ where OldCurrency: ReservableCurrency<::AccountId> + Inspect<::AccountId, Balance = old::BalanceOf>, { - const VERSION: u16 = 10; + const VERSION: u16 = 13; fn max_step_weight() -> Weight { T::WeightInfo::v10_migration_step() } - fn step(&mut self) -> (IsFinished, Weight) {} + fn step(&mut self) -> (IsFinished, Weight) { + // Move balance reserved from the deposit account back to the contract account. + // Let the deposit account be killed. + + // Hold the reserved balance. + } } From eb9c56ade6dd39d7682e878883050bbbec30e9dd Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Wed, 12 Jul 2023 14:54:26 +0200 Subject: [PATCH 050/105] wip --- frame/contracts/src/benchmarking/mod.rs | 8 + frame/contracts/src/migration.rs | 1 + frame/contracts/src/migration/v13.rs | 197 +++++++++++++++++++----- 3 files changed, 164 insertions(+), 42 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index c07cf39605b20..e0bad34c1494c 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -290,6 +290,14 @@ benchmarks! { m.step(); } + // This benchmarks the v13 migration step (Move contracts' reserved balance to be held instead). + #[pov_mode = Measured] + v13_migration_step { + let mut m = v13::Migration::::default(); + }: { + m.step(); + } + // This benchmarks the weight of executing Migration::migrate to execute a noop migration. #[pov_mode = Measured] migration_noop { diff --git a/frame/contracts/src/migration.rs b/frame/contracts/src/migration.rs index 1736562261c66..e14fcd1f3e877 100644 --- a/frame/contracts/src/migration.rs +++ b/frame/contracts/src/migration.rs @@ -60,6 +60,7 @@ pub mod v10; pub mod v11; pub mod v12; +pub mod v13; pub mod v9; use crate::{weights::WeightInfo, Config, Error, MigrationInProgress, Pallet, Weight, LOG_TARGET}; diff --git a/frame/contracts/src/migration/v13.rs b/frame/contracts/src/migration/v13.rs index 35449af392fa9..eca0e46ac175d 100644 --- a/frame/contracts/src/migration/v13.rs +++ b/frame/contracts/src/migration/v13.rs @@ -20,57 +20,170 @@ //! we need the storage deposit to be handled by the [fungible //! traits](frame_support::traits::fungibles) instead. -mod old { - use super::*; - - pub type BalanceOf = ::AccountId, - >>::Balance; - - #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)] - #[scale_info(skip_type_params(T, OldCurrency))] - pub struct ContractInfo - where - OldCurrency: ReservableCurrency<::AccountId> - + Inspect< - ::AccountId, - Balance = old::BalanceOf, - >, - { - pub trie_id: TrieId, - pub deposit_account: DepositAccount, - pub code_hash: CodeHash, - pub storage_bytes: u32, - pub storage_items: u32, - pub storage_byte_deposit: BalanceOf, - pub storage_item_deposit: BalanceOf, - pub storage_base_deposit: BalanceOf, - } -} -pub struct Migration -where - OldCurrency: ReservableCurrency<::AccountId> - + Inspect<::AccountId, Balance = old::BalanceOf>, -{ +use crate::{ + migration::{IsFinished, MigrationStep}, + weights::WeightInfo, + Config, ContractInfoOf, HoldReason, Weight, LOG_TARGET, +}; +use frame_support::{ + pallet_prelude::*, + traits::{ + fungible::{Mutate, MutateHold}, + tokens::{fungible::Inspect, Fortitude, Preservation}, + }, + DefaultNoBound, +}; +#[cfg(feature = "try-runtime")] +use sp_runtime::TryRuntimeError; +use sp_runtime::{traits::Zero, Saturating}; +use sp_std::ops::Deref; + +#[derive(Encode, Decode, MaxEncodedLen, DefaultNoBound)] +pub struct Migration { last_account: Option, - _phantom: PhantomData<(T, OldCurrency)>, } -impl MigrationStep for Migration -where - OldCurrency: ReservableCurrency<::AccountId> - + Inspect<::AccountId, Balance = old::BalanceOf>, -{ +impl MigrationStep for Migration { const VERSION: u16 = 13; fn max_step_weight() -> Weight { - T::WeightInfo::v10_migration_step() + // T::WeightInfo::v13_migration_step() + todo!() } fn step(&mut self) -> (IsFinished, Weight) { - // Move balance reserved from the deposit account back to the contract account. - // Let the deposit account be killed. + let mut iter = if let Some(last_account) = self.last_account.take() { + ContractInfoOf::::iter_from(ContractInfoOf::::hashed_key_for(last_account)) + } else { + ContractInfoOf::::iter() + }; + + if let Some((account, contract)) = iter.next() { + // Get the deposit balance to transfer. + let total_deposit_balance = + T::Currency::total_balance(contract.deposit_account().deref()); + let reducible_deposit_balance = T::Currency::reducible_balance( + &contract.deposit_account().deref(), + Preservation::Expendable, + Fortitude::Force, + ); + + if total_deposit_balance > reducible_deposit_balance { + // This should never happen, as by design all balance in the deposit account should + // be reducible. + log::warn!( + target: LOG_TARGET, + "Deposit account {:?} for contract {:?} has some non-reducible balance {:?} that will remain in there.", + contract.deposit_account(), + account, + total_deposit_balance.saturating_sub(reducible_deposit_balance) + ); + } + + // Move balance reserved from the deposit account back to the contract account. + // Let the deposit account die. + let reducible_deposit_balance = T::Currency::transfer( + &contract.deposit_account(), + &account, + reducible_deposit_balance, + Preservation::Expendable, + ) + .map(|_| { + log::debug!( + target: LOG_TARGET, + "{:?} transferred from the deposit account {:?} to the contract {:?}.", + reducible_deposit_balance, + contract.deposit_account(), + account + ); + reducible_deposit_balance + }) + .unwrap_or_else(|err| { + log::error!( + target: LOG_TARGET, + "Failed to transfer {:?} from the deposit account {:?} to the contract {:?}, reason: {:?}.", + reducible_deposit_balance, + contract.deposit_account(), + account, + err + ); + Zero::zero() + }); + + // Hold the reserved balance. + if reducible_deposit_balance == Zero::zero() { + log::warn!( + target: LOG_TARGET, + "No balance to hold as storage deposit on the contract {:?}.", + account + ); + } else { + T::Currency::hold( + &HoldReason::StorageDepositReserve.into(), + &account, + reducible_deposit_balance, + ) + .map(|_| { + log::debug!( + target: LOG_TARGET, + "Successfully held {:?} as storage deposit on the contract {:?}.", + reducible_deposit_balance, + account + ); + }) + .unwrap_or_else(|err| { + log::error!( + target: LOG_TARGET, + "Failed to hold {:?} as storage deposit on the contract {:?}, reason: {:?}.", + reducible_deposit_balance, + account, + err + ); + }); + } + (IsFinished::No, T::WeightInfo::v10_migration_step()) // TODO + } else { + log::info!(target: LOG_TARGET, "Done Migrating Storage Deposits."); + (IsFinished::Yes, T::WeightInfo::v10_migration_step()) // TODO + } + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade_step() -> Result, TryRuntimeError> { + let sample: Vec<_> = ContractInfoOf::::iter().take(100).collect(); + + log::debug!(target: LOG_TARGET, "Taking sample of {} contracts", sample.len()); + Ok(sample.encode()) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade_step(state: Vec) -> Result<(), TryRuntimeError> { + let sample = )> as Decode>::decode(&mut &state[..]) + .expect("pre_upgrade_step provides a valid state; qed"); + + log::debug!(target: LOG_TARGET, "Validating sample of {} contracts", sample.len()); + for (account, old_contract) in sample { + log::debug!(target: LOG_TARGET, "==="); + log::debug!(target: LOG_TARGET, "Account: 0x{} ", HexDisplay::from(&account.encode())); + let contract = ContractInfoOf::::get(&account).unwrap(); + ensure!(old_contract.trie_id == contract.trie_id, "invalid trie_id"); + ensure!(old_contract.code_hash == contract.code_hash, "invalid code_hash"); + ensure!(old_contract.storage_bytes == contract.storage_bytes, "invalid storage_bytes"); + ensure!(old_contract.storage_items == contract.storage_items, "invalid storage_items"); + + let deposit = >::total_balance( + &contract.deposit_account, + ); + ensure!( + deposit == + contract + .storage_base_deposit + .saturating_add(contract.storage_item_deposit) + .saturating_add(contract.storage_byte_deposit), + "deposit mismatch" + ); + } - // Hold the reserved balance. + Ok(()) } } From ab1af0422d3e7dd0597ba0c781f7682545c5cba9 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Wed, 12 Jul 2023 17:47:53 +0200 Subject: [PATCH 051/105] add benchmarking --- frame/contracts/src/benchmarking/mod.rs | 3 + frame/contracts/src/migration/v13.rs | 194 ++++++++++-------------- 2 files changed, 87 insertions(+), 110 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 8682da5bb2542..628180a9c4c01 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -293,6 +293,9 @@ benchmarks! { // This benchmarks the v13 migration step (Move contracts' reserved balance to be held instead). #[pov_mode = Measured] v13_migration_step { + >::with_caller( + whitelisted_caller(), WasmModule::dummy(), vec![], + )?; let mut m = v13::Migration::::default(); }: { m.step(); diff --git a/frame/contracts/src/migration/v13.rs b/frame/contracts/src/migration/v13.rs index eca0e46ac175d..4e0a1cdc33933 100644 --- a/frame/contracts/src/migration/v13.rs +++ b/frame/contracts/src/migration/v13.rs @@ -23,7 +23,7 @@ use crate::{ migration::{IsFinished, MigrationStep}, weights::WeightInfo, - Config, ContractInfoOf, HoldReason, Weight, LOG_TARGET, + Config, ContractInfo, ContractInfoOf, HoldReason, Weight, LOG_TARGET, }; use frame_support::{ pallet_prelude::*, @@ -59,88 +59,7 @@ impl MigrationStep for Migration { }; if let Some((account, contract)) = iter.next() { - // Get the deposit balance to transfer. - let total_deposit_balance = - T::Currency::total_balance(contract.deposit_account().deref()); - let reducible_deposit_balance = T::Currency::reducible_balance( - &contract.deposit_account().deref(), - Preservation::Expendable, - Fortitude::Force, - ); - - if total_deposit_balance > reducible_deposit_balance { - // This should never happen, as by design all balance in the deposit account should - // be reducible. - log::warn!( - target: LOG_TARGET, - "Deposit account {:?} for contract {:?} has some non-reducible balance {:?} that will remain in there.", - contract.deposit_account(), - account, - total_deposit_balance.saturating_sub(reducible_deposit_balance) - ); - } - - // Move balance reserved from the deposit account back to the contract account. - // Let the deposit account die. - let reducible_deposit_balance = T::Currency::transfer( - &contract.deposit_account(), - &account, - reducible_deposit_balance, - Preservation::Expendable, - ) - .map(|_| { - log::debug!( - target: LOG_TARGET, - "{:?} transferred from the deposit account {:?} to the contract {:?}.", - reducible_deposit_balance, - contract.deposit_account(), - account - ); - reducible_deposit_balance - }) - .unwrap_or_else(|err| { - log::error!( - target: LOG_TARGET, - "Failed to transfer {:?} from the deposit account {:?} to the contract {:?}, reason: {:?}.", - reducible_deposit_balance, - contract.deposit_account(), - account, - err - ); - Zero::zero() - }); - - // Hold the reserved balance. - if reducible_deposit_balance == Zero::zero() { - log::warn!( - target: LOG_TARGET, - "No balance to hold as storage deposit on the contract {:?}.", - account - ); - } else { - T::Currency::hold( - &HoldReason::StorageDepositReserve.into(), - &account, - reducible_deposit_balance, - ) - .map(|_| { - log::debug!( - target: LOG_TARGET, - "Successfully held {:?} as storage deposit on the contract {:?}.", - reducible_deposit_balance, - account - ); - }) - .unwrap_or_else(|err| { - log::error!( - target: LOG_TARGET, - "Failed to hold {:?} as storage deposit on the contract {:?}, reason: {:?}.", - reducible_deposit_balance, - account, - err - ); - }); - } + do_step(contract, account); (IsFinished::No, T::WeightInfo::v10_migration_step()) // TODO } else { log::info!(target: LOG_TARGET, "Done Migrating Storage Deposits."); @@ -150,40 +69,95 @@ impl MigrationStep for Migration { #[cfg(feature = "try-runtime")] fn pre_upgrade_step() -> Result, TryRuntimeError> { - let sample: Vec<_> = ContractInfoOf::::iter().take(100).collect(); - - log::debug!(target: LOG_TARGET, "Taking sample of {} contracts", sample.len()); - Ok(sample.encode()) + todo!() } #[cfg(feature = "try-runtime")] fn post_upgrade_step(state: Vec) -> Result<(), TryRuntimeError> { - let sample = )> as Decode>::decode(&mut &state[..]) - .expect("pre_upgrade_step provides a valid state; qed"); + todo!() + } +} - log::debug!(target: LOG_TARGET, "Validating sample of {} contracts", sample.len()); - for (account, old_contract) in sample { - log::debug!(target: LOG_TARGET, "==="); - log::debug!(target: LOG_TARGET, "Account: 0x{} ", HexDisplay::from(&account.encode())); - let contract = ContractInfoOf::::get(&account).unwrap(); - ensure!(old_contract.trie_id == contract.trie_id, "invalid trie_id"); - ensure!(old_contract.code_hash == contract.code_hash, "invalid code_hash"); - ensure!(old_contract.storage_bytes == contract.storage_bytes, "invalid storage_bytes"); - ensure!(old_contract.storage_items == contract.storage_items, "invalid storage_items"); +fn do_step(contract: ContractInfo, account: ::AccountId) { + // Get the deposit balance to transfer. + let total_deposit_balance = T::Currency::total_balance(contract.deposit_account().deref()); + let reducible_deposit_balance = T::Currency::reducible_balance( + &contract.deposit_account().deref(), + Preservation::Expendable, + Fortitude::Force, + ); + + if total_deposit_balance > reducible_deposit_balance { + // This should never happen, as by design all balance in the deposit account should + // be reducible. + log::warn!( + target: LOG_TARGET, + "Deposit account {:?} for contract {:?} has some non-reducible balance {:?} that will remain in there.", + contract.deposit_account(), + account, + total_deposit_balance.saturating_sub(reducible_deposit_balance) + ); + } - let deposit = >::total_balance( - &contract.deposit_account, + // Move balance reserved from the deposit account back to the contract account. + // Let the deposit account die. + let reducible_deposit_balance = T::Currency::transfer( + &contract.deposit_account(), + &account, + reducible_deposit_balance, + Preservation::Expendable, + ) + .map(|_| { + log::debug!( + target: LOG_TARGET, + "{:?} transferred from the deposit account {:?} to the contract {:?}.", + reducible_deposit_balance, + contract.deposit_account(), + account + ); + reducible_deposit_balance + }) + .unwrap_or_else(|err| { + log::error!( + target: LOG_TARGET, + "Failed to transfer {:?} from the deposit account {:?} to the contract {:?}, reason: {:?}.", + reducible_deposit_balance, + contract.deposit_account(), + account, + err + ); + Zero::zero() + }); + + // Hold the reserved balance. + if reducible_deposit_balance == Zero::zero() { + log::warn!( + target: LOG_TARGET, + "No balance to hold as storage deposit on the contract {:?}.", + account + ); + } else { + T::Currency::hold( + &HoldReason::StorageDepositReserve.into(), + &account, + reducible_deposit_balance, + ) + .map(|_| { + log::debug!( + target: LOG_TARGET, + "Successfully held {:?} as storage deposit on the contract {:?}.", + reducible_deposit_balance, + account ); - ensure!( - deposit == - contract - .storage_base_deposit - .saturating_add(contract.storage_item_deposit) - .saturating_add(contract.storage_byte_deposit), - "deposit mismatch" + }) + .unwrap_or_else(|err| { + log::error!( + target: LOG_TARGET, + "Failed to hold {:?} as storage deposit on the contract {:?}, reason: {:?}.", + reducible_deposit_balance, + account, + err ); - } - - Ok(()) + }); } } From 316ab3698a2c4fb0066f31a31f839558ac3de8cf Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 13 Jul 2023 12:30:10 +0200 Subject: [PATCH 052/105] add weights --- frame/contracts/src/benchmarking/mod.rs | 2 +- frame/contracts/src/migration/v13.rs | 182 ++++++++++++------------ frame/contracts/src/weights.rs | 32 +++++ 3 files changed, 125 insertions(+), 91 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 628180a9c4c01..9a17c28a81662 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -30,7 +30,7 @@ use self::{ }; use crate::{ exec::{AccountIdOf, Key}, - migration::{v09, v10, v11, v12, MigrationStep}, + migration::{v09, v10, v11, v12, v13, MigrationStep}, wasm::CallFlags, Pallet as Contracts, *, }; diff --git a/frame/contracts/src/migration/v13.rs b/frame/contracts/src/migration/v13.rs index 4e0a1cdc33933..6754ce9fbad41 100644 --- a/frame/contracts/src/migration/v13.rs +++ b/frame/contracts/src/migration/v13.rs @@ -23,7 +23,7 @@ use crate::{ migration::{IsFinished, MigrationStep}, weights::WeightInfo, - Config, ContractInfo, ContractInfoOf, HoldReason, Weight, LOG_TARGET, + Config, ContractInfoOf, HoldReason, Weight, LOG_TARGET, }; use frame_support::{ pallet_prelude::*, @@ -33,6 +33,8 @@ use frame_support::{ }, DefaultNoBound, }; +use frame_system::Pallet as System; +use sp_core::hexdisplay::HexDisplay; #[cfg(feature = "try-runtime")] use sp_runtime::TryRuntimeError; use sp_runtime::{traits::Zero, Saturating}; @@ -47,8 +49,7 @@ impl MigrationStep for Migration { const VERSION: u16 = 13; fn max_step_weight() -> Weight { - // T::WeightInfo::v13_migration_step() - todo!() + T::WeightInfo::v13_migration_step() } fn step(&mut self) -> (IsFinished, Weight) { @@ -59,11 +60,96 @@ impl MigrationStep for Migration { }; if let Some((account, contract)) = iter.next() { - do_step(contract, account); - (IsFinished::No, T::WeightInfo::v10_migration_step()) // TODO + let deposit_account = contract.deposit_account().deref(); + System::::dec_consumers(&deposit_account); + // Get the deposit balance to transfer. + let total_deposit_balance = T::Currency::total_balance(deposit_account); + let reducible_deposit_balance = T::Currency::reducible_balance( + &deposit_account, + Preservation::Expendable, + Fortitude::Force, + ); + + if total_deposit_balance > reducible_deposit_balance { + // This should never happen, as by design all balance in the deposit account should + // be reducible. + log::warn!( + target: LOG_TARGET, + "Deposit account 0x{:?} for contract 0x{:?} has some non-reducible balance {:?} from a total of {:?} that will remain in there.", + HexDisplay::from(&deposit_account.encode()), + HexDisplay::from(&account.encode()), + total_deposit_balance.saturating_sub(reducible_deposit_balance), + total_deposit_balance + ); + } + + // Move balance reserved from the deposit account back to the contract account. + // Let the deposit account die. + let transferred_deposit_balance = T::Currency::transfer( + &contract.deposit_account(), + &account, + reducible_deposit_balance, + Preservation::Expendable, + ) + .map(|_| { + log::debug!( + target: LOG_TARGET, + "{:?} transferred from the deposit account 0x{:?} to the contract 0x{:?}.", + reducible_deposit_balance, + HexDisplay::from(&deposit_account.encode()), + HexDisplay::from(&account.encode()) + ); + reducible_deposit_balance + }) + .unwrap_or_else(|err| { + log::error!( + target: LOG_TARGET, + "Failed to transfer {:?} from the deposit account 0x{:?} to the contract 0x{:?}, reason: {:?}.", + reducible_deposit_balance, + HexDisplay::from(&deposit_account.encode()), + HexDisplay::from(&account.encode()), + err + ); + Zero::zero() + }); + + // Hold the reserved balance. + if transferred_deposit_balance == Zero::zero() { + log::warn!( + target: LOG_TARGET, + "No balance to hold as storage deposit on the contract 0x{:?}.", + HexDisplay::from(&account.encode()) + ); + } else { + T::Currency::hold( + &HoldReason::StorageDepositReserve.into(), + &account, + transferred_deposit_balance, + ) + .map(|_| { + log::info!( + target: LOG_TARGET, + "Successfully held {:?} as storage deposit on the contract 0x{:?}.", + transferred_deposit_balance, + HexDisplay::from(&account.encode()) + ); + }) + .unwrap_or_else(|err| { + log::error!( + target: LOG_TARGET, + "Failed to hold {:?} as storage deposit on the contract 0x{:?}, reason: {:?}.", + transferred_deposit_balance, + HexDisplay::from(&account.encode()), + err + ); + }); + } + + log::debug!(target: LOG_TARGET, "==="); + (IsFinished::No, T::WeightInfo::v13_migration_step()) } else { log::info!(target: LOG_TARGET, "Done Migrating Storage Deposits."); - (IsFinished::Yes, T::WeightInfo::v10_migration_step()) // TODO + (IsFinished::Yes, T::WeightInfo::v13_migration_step()) } } @@ -77,87 +163,3 @@ impl MigrationStep for Migration { todo!() } } - -fn do_step(contract: ContractInfo, account: ::AccountId) { - // Get the deposit balance to transfer. - let total_deposit_balance = T::Currency::total_balance(contract.deposit_account().deref()); - let reducible_deposit_balance = T::Currency::reducible_balance( - &contract.deposit_account().deref(), - Preservation::Expendable, - Fortitude::Force, - ); - - if total_deposit_balance > reducible_deposit_balance { - // This should never happen, as by design all balance in the deposit account should - // be reducible. - log::warn!( - target: LOG_TARGET, - "Deposit account {:?} for contract {:?} has some non-reducible balance {:?} that will remain in there.", - contract.deposit_account(), - account, - total_deposit_balance.saturating_sub(reducible_deposit_balance) - ); - } - - // Move balance reserved from the deposit account back to the contract account. - // Let the deposit account die. - let reducible_deposit_balance = T::Currency::transfer( - &contract.deposit_account(), - &account, - reducible_deposit_balance, - Preservation::Expendable, - ) - .map(|_| { - log::debug!( - target: LOG_TARGET, - "{:?} transferred from the deposit account {:?} to the contract {:?}.", - reducible_deposit_balance, - contract.deposit_account(), - account - ); - reducible_deposit_balance - }) - .unwrap_or_else(|err| { - log::error!( - target: LOG_TARGET, - "Failed to transfer {:?} from the deposit account {:?} to the contract {:?}, reason: {:?}.", - reducible_deposit_balance, - contract.deposit_account(), - account, - err - ); - Zero::zero() - }); - - // Hold the reserved balance. - if reducible_deposit_balance == Zero::zero() { - log::warn!( - target: LOG_TARGET, - "No balance to hold as storage deposit on the contract {:?}.", - account - ); - } else { - T::Currency::hold( - &HoldReason::StorageDepositReserve.into(), - &account, - reducible_deposit_balance, - ) - .map(|_| { - log::debug!( - target: LOG_TARGET, - "Successfully held {:?} as storage deposit on the contract {:?}.", - reducible_deposit_balance, - account - ); - }) - .unwrap_or_else(|err| { - log::error!( - target: LOG_TARGET, - "Failed to hold {:?} as storage deposit on the contract {:?}, reason: {:?}.", - reducible_deposit_balance, - account, - err - ); - }); - } -} diff --git a/frame/contracts/src/weights.rs b/frame/contracts/src/weights.rs index 754a28fc22926..58b087417dc01 100644 --- a/frame/contracts/src/weights.rs +++ b/frame/contracts/src/weights.rs @@ -56,6 +56,7 @@ pub trait WeightInfo { fn v10_migration_step() -> Weight; fn v11_migration_step(k: u32, ) -> Weight; fn v12_migration_step(c: u32, ) -> Weight; + fn v13_migration_step() -> Weight; fn migration_noop() -> Weight; fn migrate() -> Weight; fn on_runtime_upgrade_noop() -> Weight; @@ -225,6 +226,21 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) } + /// Storage: `Contracts::ContractInfoOf` (r:2 w:0) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) + fn v13_migration_step() -> Weight { + // Proof Size summary in bytes: + // Measured: `682` + // Estimated: `6622` + // Minimum execution time: 135_000_000 picoseconds. + Weight::from_parts(135_000_000, 6622) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } /// Storage: Contracts MigrationInProgress (r:1 w:1) /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) fn migration_noop() -> Weight { @@ -2008,6 +2024,22 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) } + + /// Storage: `Contracts::ContractInfoOf` (r:2 w:0) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) + fn v13_migration_step() -> Weight { + // Proof Size summary in bytes: + // Measured: `682` + // Estimated: `6622` + // Minimum execution time: 135_000_000 picoseconds. + Weight::from_parts(135_000_000, 6622) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } /// Storage: Contracts MigrationInProgress (r:1 w:1) /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) fn migration_noop() -> Weight { From 5209d016bf6b647fa38955cf1cf0cd61d9a43ae4 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 13 Jul 2023 13:55:50 +0200 Subject: [PATCH 053/105] wip --- frame/contracts/src/migration/v13.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frame/contracts/src/migration/v13.rs b/frame/contracts/src/migration/v13.rs index 6754ce9fbad41..7e01fffa33e55 100644 --- a/frame/contracts/src/migration/v13.rs +++ b/frame/contracts/src/migration/v13.rs @@ -62,6 +62,7 @@ impl MigrationStep for Migration { if let Some((account, contract)) = iter.next() { let deposit_account = contract.deposit_account().deref(); System::::dec_consumers(&deposit_account); + // Get the deposit balance to transfer. let total_deposit_balance = T::Currency::total_balance(deposit_account); let reducible_deposit_balance = T::Currency::reducible_balance( @@ -71,8 +72,9 @@ impl MigrationStep for Migration { ); if total_deposit_balance > reducible_deposit_balance { - // This should never happen, as by design all balance in the deposit account should - // be reducible. + // This should never happen, as by design all balance in the deposit account is + // storage deposit and therefore reducible after decrementing the consumer + // reference. log::warn!( target: LOG_TARGET, "Deposit account 0x{:?} for contract 0x{:?} has some non-reducible balance {:?} from a total of {:?} that will remain in there.", From 0cd0830dd93e70513f455b9bb9df2a559e23d194 Mon Sep 17 00:00:00 2001 From: Toufeeq Pasha <47236805+ToufeeqP@users.noreply.github.com> Date: Wed, 12 Jul 2023 21:31:08 +0530 Subject: [PATCH 054/105] [pallet_collective] Enforce prime is a valid member of collective in set_members extrinsic (#14354) * Updated set_members extrinsic to enforce prime is valid member of collective * Added additional tests for set_members extrinsic * applied the code review suggestions --- frame/collective/src/lib.rs | 5 +++++ frame/collective/src/tests.rs | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index 30c4ad09291ff..6d6958666664e 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -346,6 +346,8 @@ pub mod pallet { WrongProposalWeight, /// The given length bound for the proposal was too low. WrongProposalLength, + /// Prime account is not a member + PrimeAccountNotMember, } #[pallet::hooks] @@ -417,6 +419,9 @@ pub mod pallet { old.len(), ); } + if let Some(p) = &prime { + ensure!(new_members.contains(p), Error::::PrimeAccountNotMember); + } let mut new_members = new_members; new_members.sort(); >::set_members_sorted(&new_members, &old); diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index a4ec55856e49c..bf169316491b0 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -236,6 +236,25 @@ fn initialize_members_sorts_members() { }); } +#[test] +fn set_members_with_prime_works() { + ExtBuilder::default().build_and_execute(|| { + let members = vec![1, 2, 3]; + assert_ok!(Collective::set_members( + RuntimeOrigin::root(), + members.clone(), + Some(3), + MaxMembers::get() + )); + assert_eq!(Collective::members(), members.clone()); + assert_eq!(Collective::prime(), Some(3)); + assert_noop!( + Collective::set_members(RuntimeOrigin::root(), members, Some(4), MaxMembers::get()), + Error::::PrimeAccountNotMember + ); + }); +} + #[test] fn proposal_weight_limit_works() { ExtBuilder::default().build_and_execute(|| { From de849d2e559f54f4b9fb10d9e695880226ac4ca6 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Thu, 13 Jul 2023 05:05:04 -0400 Subject: [PATCH 055/105] update to docify 0.2.0 / crate-relative embed paths (#14570) --- Cargo.lock | 11 +++++------ frame/fast-unstake/Cargo.toml | 2 +- frame/fast-unstake/src/lib.rs | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0b3258defb2a1..b975b4c32b034 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2133,23 +2133,22 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" [[package]] name = "docify" -version = "0.1.14" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15aa210b350ff62db3149ac5d0b2a0287c01ee91354e16290de344082b2b3ff6" +checksum = "f6491709f76fb7ceb951244daf624d480198b427556084391d6e3c33d3ae74b9" dependencies = [ "docify_macros", ] [[package]] name = "docify_macros" -version = "0.1.14" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bf3504ed030133996c59a9954669a7a4f869f93a7e74389e16149843db16f57" +checksum = "ffc5338a9f72ce29a81377d9039798fcc926fb471b2004666caf48e446dffbbf" dependencies = [ "common-path", "derive-syn-parse", - "lazy_static", - "prettyplease 0.2.6", + "once_cell", "proc-macro2", "quote", "regex", diff --git a/frame/fast-unstake/Cargo.toml b/frame/fast-unstake/Cargo.toml index bac64925ea35c..c628da7123f2e 100644 --- a/frame/fast-unstake/Cargo.toml +++ b/frame/fast-unstake/Cargo.toml @@ -27,7 +27,7 @@ frame-election-provider-support = { default-features = false, path = "../electio frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } -docify = "0.1.13" +docify = "0.2.0" [dev-dependencies] pallet-staking-reward-curve = { version = "4.0.0-dev", path = "../staking/reward-curve" } diff --git a/frame/fast-unstake/src/lib.rs b/frame/fast-unstake/src/lib.rs index 9be5878f2e199..99742dbb75ae5 100644 --- a/frame/fast-unstake/src/lib.rs +++ b/frame/fast-unstake/src/lib.rs @@ -71,10 +71,10 @@ //! ### Example //! //! 1. Fast-unstake with multiple participants in the queue. -#![doc = docify::embed!("frame/fast-unstake/src/tests.rs", successful_multi_queue)] +#![doc = docify::embed!("src/tests.rs", successful_multi_queue)] //! //! 2. Fast unstake failing because a nominator is exposed. -#![doc = docify::embed!("frame/fast-unstake/src/tests.rs", exposed_nominator_cannot_unstake)] +#![doc = docify::embed!("src/tests.rs", exposed_nominator_cannot_unstake)] //! //! ## Pallet API //! From adba2c937084718c53627f25e8cc386eecfe030c Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Thu, 13 Jul 2023 20:08:45 +1000 Subject: [PATCH 056/105] Fix Society v2 migration (#14421) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix society v2 migration * Update frame/society/src/migrations.rs * Update frame/society/src/migrations.rs Co-authored-by: Bastian Köcher * Update frame/society/src/migrations.rs Co-authored-by: Bastian Köcher * update for versioned upgrade * fix society v2 migration * remove references to members being sorted from commnets * fix type * fix can_migrate check * add sanity log * fix sanity check * kick ci * kick ci * run tests with --experimental flag * versioned migration cleanup * revert pipeline change * use defensive! * semicolons * defensive and doc comment * address pr comment * feature gate the versioned migration * defensive_unwrap_or * fix test * fix doc comment * change defensive to a log warning * remove can_migrate anti-pattern * Update frame/society/Cargo.toml Co-authored-by: Bastian Köcher * add experimental feature warning to doc comment * update doc comment * bump ci * kick ci * kick ci * kick ci --------- Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Bastian Köcher --- frame/society/Cargo.toml | 4 ++ frame/society/src/lib.rs | 14 +++--- frame/society/src/migrations.rs | 79 ++++++++++++++++++++++----------- frame/society/src/tests.rs | 2 +- frame/support/src/migrations.rs | 36 ++++++++------- 5 files changed, 85 insertions(+), 50 deletions(-) diff --git a/frame/society/Cargo.toml b/frame/society/Cargo.toml index 2ef5dfad78c6e..7f3e55e339fe0 100644 --- a/frame/society/Cargo.toml +++ b/frame/society/Cargo.toml @@ -35,6 +35,10 @@ sp-io = { version = "23.0.0", path = "../../primitives/io" } [features] default = ["std"] +# Enable `VersionedRuntimeUpgrade` for the migrations that is currently still experimental. +experimental = [ + "frame-support/experimental" +] std = [ "codec/std", "frame-benchmarking?/std", diff --git a/frame/society/src/lib.rs b/frame/society/src/lib.rs index 63d90a0703c4d..3d4b9323246d8 100644 --- a/frame/society/src/lib.rs +++ b/frame/society/src/lib.rs @@ -466,12 +466,12 @@ pub struct GroupParams { pub type GroupParamsFor = GroupParams>; +pub(crate) const STORAGE_VERSION: StorageVersion = StorageVersion::new(2); + #[frame_support::pallet] pub mod pallet { use super::*; - const STORAGE_VERSION: StorageVersion = StorageVersion::new(2); - #[pallet::pallet] #[pallet::storage_version(STORAGE_VERSION)] #[pallet::without_storage_info] @@ -1681,8 +1681,8 @@ impl, I: 'static> Pallet { bids.iter().any(|bid| bid.who == *who) } - /// Add a member to the sorted members list. If the user is already a member, do nothing. - /// Can fail when `MaxMember` limit is reached, but in that case it has no side-effects. + /// Add a member to the members list. If the user is already a member, do nothing. Can fail when + /// `MaxMember` limit is reached, but in that case it has no side-effects. /// /// Set the `payouts` for the member. NOTE: This *WILL NOT RESERVE THE FUNDS TO MAKE THE /// PAYOUT*. Only set this to be non-empty if you already have the funds reserved in the Payouts @@ -1703,7 +1703,7 @@ impl, I: 'static> Pallet { Ok(()) } - /// Add a member back to the sorted members list, setting their `rank` and `payouts`. + /// Add a member back to the members list, setting their `rank` and `payouts`. /// /// Can fail when `MaxMember` limit is reached, but in that case it has no side-effects. /// @@ -1713,8 +1713,8 @@ impl, I: 'static> Pallet { Self::insert_member(who, rank) } - /// Add a member to the sorted members list. If the user is already a member, do nothing. - /// Can fail when `MaxMember` limit is reached, but in that case it has no side-effects. + /// Add a member to the members list. If the user is already a member, do nothing. Can fail when + /// `MaxMember` limit is reached, but in that case it has no side-effects. fn add_new_member(who: &T::AccountId, rank: Rank) -> DispatchResult { Self::insert_member(who, rank) } diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index bd590f9b18770..404b1e5fd2cb9 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -19,7 +19,7 @@ use super::*; use codec::{Decode, Encode}; -use frame_support::traits::{Instance, OnRuntimeUpgrade}; +use frame_support::traits::{Defensive, DefensiveOption, Instance, OnRuntimeUpgrade}; #[cfg(feature = "try-runtime")] use sp_runtime::TryRuntimeError; @@ -28,7 +28,7 @@ use sp_runtime::TryRuntimeError; const TARGET: &'static str = "runtime::society::migration"; /// This migration moves all the state to v2 of Society. -pub struct MigrateToV2, I: 'static, PastPayouts>( +pub struct VersionUncheckedMigrateToV2, I: 'static, PastPayouts>( sp_std::marker::PhantomData<(T, I, PastPayouts)>, ); @@ -36,12 +36,10 @@ impl< T: Config, I: Instance + 'static, PastPayouts: Get::AccountId, BalanceOf)>>, - > OnRuntimeUpgrade for MigrateToV2 + > OnRuntimeUpgrade for VersionUncheckedMigrateToV2 { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, TryRuntimeError> { - ensure!(can_migrate::(), "pallet_society: already upgraded"); - let current = Pallet::::current_storage_version(); let onchain = Pallet::::on_chain_storage_version(); ensure!(onchain == 0 && current == 2, "pallet_society: invalid version"); @@ -50,16 +48,16 @@ impl< } fn on_runtime_upgrade() -> Weight { - let current = Pallet::::current_storage_version(); let onchain = Pallet::::on_chain_storage_version(); - if current == 2 && onchain == 0 { - from_original::(&mut PastPayouts::get()) - } else { + if onchain < 2 { log::info!( - "Running migration with current storage version {:?} / onchain {:?}", - current, + target: TARGET, + "Running migration against onchain version {:?}", onchain ); + from_original::(&mut PastPayouts::get()).defensive_unwrap_or(Weight::MAX) + } else { + log::warn!("Unexpected onchain version: {:?} (expected 0)", onchain); T::DbWeight::get().reads(1) } } @@ -95,6 +93,19 @@ impl< } } +/// [`VersionUncheckedMigrateToV2`] wrapped in a +/// [`frame_support::migrations::VersionedRuntimeUpgrade`], ensuring the migration is only performed +/// when on-chain version is 0. +#[cfg(feature = "experimental")] +pub type VersionCheckedMigrateToV2 = + frame_support::migrations::VersionedRuntimeUpgrade< + 0, + 2, + VersionUncheckedMigrateToV2, + crate::pallet::Pallet, + ::DbWeight, + >; + pub(crate) mod old { use super::*; use frame_support::storage_alias; @@ -180,10 +191,6 @@ pub(crate) mod old { StorageMap, Twox64Concat, ::AccountId, Vote>; } -pub fn can_migrate, I: Instance + 'static>() -> bool { - old::Members::::exists() -} - /// Will panic if there are any inconsistencies in the pallet's state or old keys remaining. pub fn assert_internal_consistency, I: Instance + 'static>() { // Check all members are valid data. @@ -235,15 +242,7 @@ pub fn assert_internal_consistency, I: Instance + 'static>() { pub fn from_original, I: Instance + 'static>( past_payouts: &mut [(::AccountId, BalanceOf)], -) -> Weight { - // First check that this is the original state layout. This is easy since the original layout - // contained the Members value, and this value no longer exists in the new layout. - if !old::Members::::exists() { - log::warn!(target: TARGET, "Skipping MigrateToV2 migration since it appears unapplicable"); - // Already migrated or no data to migrate: Bail. - return T::DbWeight::get().reads(1) - } - +) -> Result { // Migrate Bids from old::Bids (just a trunctation). Bids::::put(BoundedVec::<_, T::MaxBids>::truncate_from(old::Bids::::take())); @@ -281,6 +280,36 @@ pub fn from_original, I: Instance + 'static>( let record = MemberRecord { index: member_count, rank: 0, strikes, vouching }; Members::::insert(&member, record); MemberByIndex::::insert(member_count, &member); + + // The founder must be the first member in Society V2. If we find the founder not in index + // zero, we swap it with the first member. + if member == Founder::::get().defensive_ok_or("founder must always be set")? && + member_count > 0 + { + let member_to_swap = MemberByIndex::::get(0) + .defensive_ok_or("member_count > 0, we must have at least 1 member")?; + // Swap the founder with the first member in MemberByIndex. + MemberByIndex::::swap(0, member_count); + // Update the indicies of the swapped member MemberRecords. + Members::::mutate(&member, |m| { + if let Some(member) = m { + member.index = 0; + } else { + frame_support::defensive!( + "Member somehow disapeared from storage after it was inserted" + ); + } + }); + Members::::mutate(&member_to_swap, |m| { + if let Some(member) = m { + member.index = member_count; + } else { + frame_support::defensive!( + "Member somehow disapeared from storage after it was queried" + ); + } + }); + } member_count.saturating_inc(); } MemberCount::::put(member_count); @@ -317,7 +346,7 @@ pub fn from_original, I: Instance + 'static>( old::Defender::::kill(); let _ = old::DefenderVotes::::clear(u32::MAX, None); - T::BlockWeights::get().max_block + Ok(T::BlockWeights::get().max_block) } pub fn from_raw_past_payouts, I: Instance + 'static>( diff --git a/frame/society/src/tests.rs b/frame/society/src/tests.rs index 4a90ad52112d8..ea2afef3b32b5 100644 --- a/frame/society/src/tests.rs +++ b/frame/society/src/tests.rs @@ -77,7 +77,7 @@ fn migration_works() { .collect::>(); old::Bids::::put(bids); - migrations::from_original::(&mut [][..]); + migrations::from_original::(&mut [][..]).expect("migration failed"); migrations::assert_internal_consistency::(); assert_eq!( diff --git a/frame/support/src/migrations.rs b/frame/support/src/migrations.rs index 889439907efd2..9ba22d3e15404 100644 --- a/frame/support/src/migrations.rs +++ b/frame/support/src/migrations.rs @@ -24,12 +24,8 @@ use sp_core::Get; use sp_io::{hashing::twox_128, storage::clear_prefix, KillStorageResult}; use sp_std::marker::PhantomData; -#[cfg(feature = "try-runtime")] -use sp_std::vec::Vec; - -#[cfg(feature = "experimental")] -use crate::traits::OnRuntimeUpgrade; - +/// EXPERIMENTAL: The API of this feature may change. +/// /// Make it easier to write versioned runtime upgrades. /// /// [`VersionedRuntimeUpgrade`] allows developers to write migrations without worrying about @@ -57,13 +53,19 @@ use crate::traits::OnRuntimeUpgrade; /// // OnRuntimeUpgrade implementation... /// } /// -/// pub type VersionCheckedMigrateV5ToV6 = -/// VersionedRuntimeUpgrade<5, 6, VersionUncheckedMigrateV5ToV6, Pallet, DbWeight>; +/// pub type VersionCheckedMigrateV5ToV6 = +/// VersionedRuntimeUpgrade< +/// 5, +/// 6, +/// VersionUncheckedMigrateV5ToV6, +/// crate::pallet::Pallet, +/// ::DbWeight +/// >; /// /// // Migrations tuple to pass to the Executive pallet: /// pub type Migrations = ( /// // other migrations... -/// VersionCheckedMigrateV5ToV6, +/// VersionCheckedMigrateV5ToV6, /// // other migrations... /// ); /// ``` @@ -78,7 +80,7 @@ pub struct VersionedRuntimeUpgrade), + MigrationExecuted(sp_std::vec::Vec), /// This migration is a noop, do not run post_upgrade checks. Noop, } @@ -93,16 +95,16 @@ pub enum VersionedPostUpgradeData { impl< const FROM: u16, const TO: u16, - Inner: OnRuntimeUpgrade, + Inner: crate::traits::OnRuntimeUpgrade, Pallet: GetStorageVersion + PalletInfoAccess, DbWeight: Get, - > OnRuntimeUpgrade for VersionedRuntimeUpgrade + > crate::traits::OnRuntimeUpgrade for VersionedRuntimeUpgrade { /// Executes pre_upgrade if the migration will run, and wraps the pre_upgrade bytes in /// [`VersionedPostUpgradeData`] before passing them to post_upgrade, so it knows whether the /// migration ran or not. #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { use codec::Encode; let on_chain_version = Pallet::on_chain_storage_version(); if on_chain_version == FROM { @@ -152,7 +154,7 @@ impl< /// the migration ran, and [`VersionedPostUpgradeData::Noop`] otherwise. #[cfg(feature = "try-runtime")] fn post_upgrade( - versioned_post_upgrade_data_bytes: Vec, + versioned_post_upgrade_data_bytes: sp_std::vec::Vec, ) -> Result<(), sp_runtime::TryRuntimeError> { use codec::DecodeAll; match ::decode_all(&mut &versioned_post_upgrade_data_bytes[..]) @@ -321,7 +323,7 @@ impl, DbWeight: Get> frame_support::traits } #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { use crate::storage::unhashed::contains_prefixed_key; let hashed_prefix = twox_128(P::get().as_bytes()); @@ -332,11 +334,11 @@ impl, DbWeight: Get> frame_support::traits P::get() ), }; - Ok(Vec::new()) + Ok(sp_std::vec::Vec::new()) } #[cfg(feature = "try-runtime")] - fn post_upgrade(_state: Vec) -> Result<(), sp_runtime::TryRuntimeError> { + fn post_upgrade(_state: sp_std::vec::Vec) -> Result<(), sp_runtime::TryRuntimeError> { use crate::storage::unhashed::contains_prefixed_key; let hashed_prefix = twox_128(P::get().as_bytes()); From 9a42019d9f9560ea4dffe0f1616cdde7cebb1e89 Mon Sep 17 00:00:00 2001 From: gupnik <17176722+gupnik@users.noreply.github.com> Date: Thu, 13 Jul 2023 17:31:34 +0530 Subject: [PATCH 057/105] Moves `Block` to `frame_system` instead of `construct_runtime` and removes `Header` and `BlockNumber` (#14437) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Initial setup * Adds node block * Uses UncheckedExtrinsic and removes Where section * Updates frame_system to use Block * Adds deprecation warning * Fixes pallet-timestamp * Removes Header and BlockNumber * Addresses review comments * Addresses review comments * Adds comment about compiler bug * Removes where clause * Refactors code * Fixes errors in cargo check * Fixes errors in cargo check * Fixes warnings in cargo check * Formatting * Fixes construct_runtime tests * Uses import instead of full path for BlockNumber * Uses import instead of full path for Header * Formatting * Fixes construct_runtime tests * Fixes imports in benchmarks * Formatting * Fixes construct_runtime tests * Formatting * Minor updates * Fixes construct_runtime ui tests * Fixes construct_runtime ui tests with 1.70 * Fixes docs * Fixes docs * Adds u128 mock block type * Fixes split example * fixes for cumulus * ".git/.scripts/commands/fmt/fmt.sh" * Updates new tests * Fixes fully-qualified path in few places * Formatting * Update frame/examples/default-config/src/lib.rs Co-authored-by: Juan * Update frame/support/procedural/src/construct_runtime/mod.rs Co-authored-by: Juan * ".git/.scripts/commands/fmt/fmt.sh" * Addresses some review comments * Fixes build * ".git/.scripts/commands/fmt/fmt.sh" * Update frame/democracy/src/lib.rs Co-authored-by: Oliver Tale-Yazdi * Update frame/democracy/src/lib.rs Co-authored-by: Oliver Tale-Yazdi * Update frame/support/procedural/src/construct_runtime/mod.rs Co-authored-by: Oliver Tale-Yazdi * Update frame/support/procedural/src/construct_runtime/mod.rs Co-authored-by: Oliver Tale-Yazdi * Addresses review comments * Updates trait bounds * Minor fix * ".git/.scripts/commands/fmt/fmt.sh" * Removes unnecessary bound * ".git/.scripts/commands/fmt/fmt.sh" * Updates test * Fixes build * Adds a bound for header * ".git/.scripts/commands/fmt/fmt.sh" * Removes where block * Minor fix * Minor fix * Fixes tests * ".git/.scripts/commands/update-ui/update-ui.sh" 1.70 * Updates test * Update primitives/runtime/src/traits.rs Co-authored-by: Bastian Köcher * Update primitives/runtime/src/traits.rs Co-authored-by: Bastian Köcher * Updates doc * Updates doc --------- Co-authored-by: command-bot <> Co-authored-by: Juan Co-authored-by: Oliver Tale-Yazdi Co-authored-by: Bastian Köcher --- .../pallets/template/src/mock.rs | 10 +- bin/node-template/runtime/src/lib.rs | 13 +- bin/node/runtime/src/lib.rs | 8 +- frame/alliance/src/benchmarking.rs | 6 +- frame/alliance/src/lib.rs | 4 +- frame/alliance/src/mock.rs | 10 +- frame/asset-conversion/src/lib.rs | 7 +- frame/asset-conversion/src/mock.rs | 10 +- frame/asset-rate/src/mock.rs | 10 +- frame/assets/src/mock.rs | 10 +- frame/atomic-swap/src/lib.rs | 5 +- frame/atomic-swap/src/tests.rs | 10 +- frame/aura/src/lib.rs | 4 +- frame/aura/src/mock.rs | 15 +- frame/authority-discovery/src/lib.rs | 11 +- frame/authorship/src/lib.rs | 15 +- frame/babe/src/equivocation.rs | 9 +- frame/babe/src/lib.rs | 49 +- frame/babe/src/mock.rs | 9 +- frame/babe/src/randomness.rs | 17 +- frame/bags-list/src/mock.rs | 9 +- frame/balances/README.md | 2 +- frame/balances/src/impl_currency.rs | 3 +- frame/balances/src/lib.rs | 4 +- frame/balances/src/tests/mod.rs | 10 +- frame/beefy-mmr/src/lib.rs | 3 +- frame/beefy-mmr/src/mock.rs | 12 +- frame/beefy/src/equivocation.rs | 5 +- frame/beefy/src/mock.rs | 11 +- frame/benchmarking/pov/src/benchmarking.rs | 10 +- frame/benchmarking/pov/src/tests.rs | 9 +- frame/benchmarking/src/baseline.rs | 10 +- frame/benchmarking/src/tests.rs | 11 +- frame/benchmarking/src/tests_instance.rs | 11 +- frame/bounties/src/benchmarking.rs | 18 +- frame/bounties/src/lib.rs | 6 +- frame/bounties/src/tests.rs | 10 +- frame/child-bounties/src/benchmarking.rs | 8 +- frame/child-bounties/src/lib.rs | 4 +- frame/child-bounties/src/tests.rs | 10 +- frame/collective/src/benchmarking.rs | 10 +- frame/collective/src/lib.rs | 4 +- frame/collective/src/tests.rs | 8 +- frame/contracts/src/exec.rs | 13 +- frame/contracts/src/lib.rs | 4 +- frame/contracts/src/tests.rs | 11 +- frame/contracts/src/wasm/mod.rs | 5 +- frame/contracts/src/wasm/runtime.rs | 2 +- frame/conviction-voting/src/lib.rs | 16 +- frame/conviction-voting/src/tests.rs | 10 +- frame/core-fellowship/src/benchmarking.rs | 6 +- frame/core-fellowship/src/lib.rs | 5 +- frame/core-fellowship/src/tests.rs | 10 +- frame/democracy/src/benchmarking.rs | 10 +- frame/democracy/src/lib.rs | 73 +-- frame/democracy/src/migrations/v1.rs | 9 +- frame/democracy/src/tests.rs | 10 +- .../src/benchmarking.rs | 2 +- .../election-provider-multi-phase/src/lib.rs | 34 +- .../election-provider-multi-phase/src/mock.rs | 12 +- .../src/signed.rs | 9 +- .../src/unsigned.rs | 6 +- .../test-staking-e2e/src/mock.rs | 10 +- .../election-provider-support/src/onchain.rs | 12 +- frame/elections-phragmen/src/lib.rs | 16 +- frame/examples/basic/src/lib.rs | 6 +- frame/examples/basic/src/tests.rs | 10 +- frame/examples/default-config/src/lib.rs | 13 +- frame/examples/dev-mode/src/tests.rs | 10 +- frame/examples/kitchensink/src/lib.rs | 14 +- frame/examples/kitchensink/src/tests.rs | 8 +- frame/examples/offchain-worker/src/lib.rs | 52 ++- frame/examples/offchain-worker/src/tests.rs | 15 +- frame/examples/split/src/mock.rs | 9 +- frame/executive/src/lib.rs | 100 ++-- frame/fast-unstake/src/lib.rs | 6 +- frame/fast-unstake/src/mock.rs | 12 +- frame/glutton/src/mock.rs | 10 +- frame/grandpa/src/equivocation.rs | 9 +- frame/grandpa/src/lib.rs | 37 +- frame/grandpa/src/mock.rs | 11 +- frame/identity/src/tests.rs | 10 +- frame/im-online/src/benchmarking.rs | 7 +- frame/im-online/src/lib.rs | 18 +- frame/im-online/src/mock.rs | 11 +- frame/indices/src/mock.rs | 11 +- .../src/lib.rs | 20 +- frame/lottery/src/lib.rs | 10 +- frame/lottery/src/mock.rs | 10 +- frame/membership/src/lib.rs | 10 +- frame/merkle-mountain-range/src/lib.rs | 24 +- frame/merkle-mountain-range/src/mock.rs | 14 +- frame/merkle-mountain-range/src/tests.rs | 2 +- frame/message-queue/src/integration_test.rs | 14 +- frame/message-queue/src/mock.rs | 12 +- frame/multisig/src/lib.rs | 20 +- frame/multisig/src/tests.rs | 10 +- .../nft-fractionalization/src/benchmarking.rs | 13 +- frame/nft-fractionalization/src/mock.rs | 10 +- frame/nfts/src/benchmarking.rs | 8 +- frame/nfts/src/features/approvals.rs | 2 +- frame/nfts/src/features/atomic_swap.rs | 2 +- frame/nfts/src/features/settings.rs | 2 +- frame/nfts/src/lib.rs | 22 +- frame/nfts/src/mock.rs | 10 +- frame/nfts/src/types.rs | 14 +- frame/nicks/src/lib.rs | 10 +- frame/nis/src/lib.rs | 23 +- frame/nis/src/mock.rs | 10 +- frame/node-authorization/src/lib.rs | 2 +- frame/node-authorization/src/mock.rs | 10 +- .../nomination-pools/benchmarking/src/mock.rs | 10 +- frame/nomination-pools/src/lib.rs | 13 +- frame/nomination-pools/src/mock.rs | 9 +- .../nomination-pools/test-staking/src/mock.rs | 9 +- frame/offences/benchmarking/src/mock.rs | 9 +- frame/offences/src/mock.rs | 10 +- frame/preimage/src/mock.rs | 10 +- frame/proxy/src/benchmarking.rs | 14 +- frame/proxy/src/lib.rs | 35 +- frame/proxy/src/tests.rs | 10 +- frame/ranked-collective/src/lib.rs | 2 +- frame/ranked-collective/src/tests.rs | 10 +- frame/recovery/src/lib.rs | 6 +- frame/recovery/src/mock.rs | 10 +- frame/referenda/src/benchmarking.rs | 4 +- frame/referenda/src/lib.rs | 51 +- frame/referenda/src/migration.rs | 2 +- frame/referenda/src/mock.rs | 10 +- frame/referenda/src/types.rs | 17 +- frame/remark/src/mock.rs | 10 +- frame/root-offences/src/mock.rs | 11 +- frame/salary/src/lib.rs | 11 +- frame/salary/src/tests.rs | 10 +- frame/scheduler/src/benchmarking.rs | 13 +- frame/scheduler/src/lib.rs | 149 +++--- frame/scheduler/src/migration.rs | 37 +- frame/scheduler/src/mock.rs | 10 +- frame/scored-pool/src/lib.rs | 4 +- frame/scored-pool/src/mock.rs | 10 +- frame/session/benchmarking/src/lib.rs | 8 +- frame/session/benchmarking/src/mock.rs | 10 +- frame/session/src/lib.rs | 13 +- frame/session/src/mock.rs | 16 +- frame/society/src/lib.rs | 31 +- frame/society/src/migrations.rs | 2 +- frame/society/src/mock.rs | 10 +- frame/staking/src/mock.rs | 11 +- frame/staking/src/pallet/impls.rs | 6 +- frame/staking/src/pallet/mod.rs | 8 +- frame/state-trie-migration/src/lib.rs | 17 +- frame/statement/src/mock.rs | 10 +- frame/sudo/src/mock.rs | 10 +- .../src/construct_runtime/expand/inherent.rs | 6 +- .../src/construct_runtime/expand/metadata.rs | 4 +- .../procedural/src/construct_runtime/mod.rs | 35 +- .../procedural/src/construct_runtime/parse.rs | 10 +- frame/support/procedural/src/lib.rs | 6 +- .../procedural/src/pallet/expand/hooks.rs | 40 +- frame/support/src/dispatch.rs | 266 +---------- frame/support/src/error.rs | 45 -- frame/support/src/lib.rs | 49 +- frame/support/src/migrations.rs | 7 +- frame/support/src/storage/generator/mod.rs | 13 +- frame/support/test/compile_pass/src/lib.rs | 10 +- frame/support/test/src/lib.rs | 7 +- frame/support/test/tests/construct_runtime.rs | 129 +++-- .../both_use_and_excluded_parts.rs | 7 +- .../both_use_and_excluded_parts.stderr | 4 +- .../conflicting_module_name.rs | 5 +- .../conflicting_module_name.stderr | 16 +- .../deprecated_where_block.rs | 13 + .../deprecated_where_block.stderr | 442 ++++++++++++++++++ .../double_module_parts.rs | 5 +- .../double_module_parts.stderr | 8 +- .../construct_runtime_ui/empty_pallet_path.rs | 5 +- .../empty_pallet_path.stderr | 4 +- .../exclude_undefined_part.rs | 7 +- .../exclude_undefined_part.stderr | 4 +- .../feature_gated_system_pallet.rs | 5 +- .../feature_gated_system_pallet.stderr | 8 +- .../generics_in_invalid_module.rs | 5 +- .../generics_in_invalid_module.stderr | 8 +- .../invalid_meta_literal.rs | 5 +- .../invalid_meta_literal.stderr | 8 +- .../invalid_module_details.rs | 5 +- .../invalid_module_details.stderr | 4 +- .../invalid_module_details_keyword.rs | 5 +- .../invalid_module_details_keyword.stderr | 4 +- .../invalid_module_entry.rs | 5 +- .../invalid_module_entry.stderr | 8 +- .../invalid_token_after_module.rs | 5 +- .../invalid_token_after_module.stderr | 4 +- .../invalid_token_after_name.rs | 5 +- .../invalid_token_after_name.stderr | 4 +- ...g_event_generic_on_module_with_instance.rs | 5 +- ...ent_generic_on_module_with_instance.stderr | 8 +- .../missing_module_instance.rs | 5 +- .../missing_module_instance.stderr | 4 +- ..._origin_generic_on_module_with_instance.rs | 5 +- ...gin_generic_on_module_with_instance.stderr | 8 +- .../missing_system_module.rs | 5 +- .../missing_system_module.stderr | 8 +- .../missing_where_block.rs | 7 - .../missing_where_block.stderr | 5 - .../number_of_pallets_exceeds_tuple_size.rs | 8 +- ...umber_of_pallets_exceeds_tuple_size.stderr | 18 +- .../pallet_error_too_large.rs | 8 +- .../pallet_error_too_large.stderr | 18 +- .../undefined_call_part.rs | 8 +- .../undefined_call_part.stderr | 14 +- .../undefined_event_part.rs | 8 +- .../undefined_event_part.stderr | 30 +- .../undefined_genesis_config_part.rs | 8 +- .../undefined_genesis_config_part.stderr | 30 +- .../undefined_inherent_part.rs | 8 +- .../undefined_inherent_part.stderr | 94 ++-- .../undefined_origin_part.rs | 8 +- .../undefined_origin_part.stderr | 30 +- .../undefined_validate_unsigned_part.rs | 8 +- .../undefined_validate_unsigned_part.stderr | 60 ++- .../unsupported_meta_structure.rs | 5 +- .../unsupported_meta_structure.stderr | 8 +- .../unsupported_pallet_attr.rs | 5 +- .../unsupported_pallet_attr.stderr | 8 +- .../use_undefined_part.rs | 7 +- .../use_undefined_part.stderr | 4 +- frame/support/test/tests/final_keys.rs | 40 +- frame/support/test/tests/genesisconfig.rs | 25 +- frame/support/test/tests/instance.rs | 31 +- frame/support/test/tests/issue2219.rs | 47 +- frame/support/test/tests/origin.rs | 28 +- frame/support/test/tests/pallet.rs | 8 +- frame/support/test/tests/pallet_instance.rs | 8 +- .../test/tests/pallet_outer_enums_explicit.rs | 28 +- .../test/tests/pallet_outer_enums_implicit.rs | 28 +- .../tests/pallet_ui/pass/dev_mode_valid.rs | 8 +- .../pallet_ui/pass/no_std_genesis_config.rs | 8 +- frame/support/test/tests/runtime_metadata.rs | 8 +- frame/support/test/tests/storage_layers.rs | 10 +- .../support/test/tests/storage_transaction.rs | 23 +- .../test/tests/versioned_runtime_upgrade.rs | 9 +- frame/system/benches/bench.rs | 10 +- frame/system/benchmarking/src/mock.rs | 10 +- frame/system/src/extensions/check_genesis.rs | 4 +- .../system/src/extensions/check_mortality.rs | 4 +- frame/system/src/lib.rs | 70 ++- frame/system/src/mock.rs | 10 +- frame/system/src/mocking.rs | 15 +- frame/timestamp/src/lib.rs | 2 +- frame/timestamp/src/mock.rs | 10 +- frame/tips/src/benchmarking.rs | 2 +- frame/tips/src/lib.rs | 11 +- frame/tips/src/tests.rs | 10 +- .../asset-conversion-tx-payment/src/mock.rs | 10 +- .../asset-tx-payment/src/mock.rs | 16 +- frame/transaction-payment/src/lib.rs | 2 +- frame/transaction-payment/src/mock.rs | 14 +- frame/transaction-storage/src/benchmarking.rs | 8 +- frame/transaction-storage/src/lib.rs | 14 +- frame/transaction-storage/src/mock.rs | 10 +- frame/treasury/src/benchmarking.rs | 2 +- frame/treasury/src/lib.rs | 4 +- frame/treasury/src/tests.rs | 10 +- frame/uniques/src/mock.rs | 10 +- frame/utility/src/tests.rs | 10 +- frame/vesting/src/benchmarking.rs | 10 +- frame/vesting/src/lib.rs | 43 +- frame/vesting/src/migrations.rs | 4 +- frame/vesting/src/mock.rs | 10 +- frame/whitelist/src/mock.rs | 10 +- primitives/runtime/src/generic/block.rs | 16 +- primitives/runtime/src/generic/header.rs | 9 +- primitives/runtime/src/testing.rs | 6 +- primitives/runtime/src/traits.rs | 50 +- test-utils/runtime/src/lib.rs | 8 +- utils/frame/rpc/support/src/lib.rs | 8 +- 277 files changed, 2017 insertions(+), 2450 deletions(-) create mode 100644 frame/support/test/tests/construct_runtime_ui/deprecated_where_block.rs create mode 100644 frame/support/test/tests/construct_runtime_ui/deprecated_where_block.stderr delete mode 100644 frame/support/test/tests/construct_runtime_ui/missing_where_block.rs delete mode 100644 frame/support/test/tests/construct_runtime_ui/missing_where_block.stderr diff --git a/bin/node-template/pallets/template/src/mock.rs b/bin/node-template/pallets/template/src/mock.rs index 487e076feef95..65fe3fa94327b 100644 --- a/bin/node-template/pallets/template/src/mock.rs +++ b/bin/node-template/pallets/template/src/mock.rs @@ -2,20 +2,15 @@ use crate as pallet_template; use frame_support::traits::{ConstU16, ConstU64}; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, TemplateModule: pallet_template, @@ -30,12 +25,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index 22fb01b62d0f0..90de167e41ea7 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -155,6 +155,8 @@ parameter_types! { impl frame_system::Config for Runtime { /// The basic call filter to use in dispatchable. type BaseCallFilter = frame_support::traits::Everything; + /// The block type for the runtime. + type Block = Block; /// Block & extrinsics weights: base values and limits. type BlockWeights = BlockWeights; /// The maximum length of a block (in bytes). @@ -167,14 +169,10 @@ impl frame_system::Config for Runtime { type Lookup = AccountIdLookup; /// The index type for storing how many extrinsics an account has signed. type Index = Index; - /// The index type for blocks. - type BlockNumber = BlockNumber; /// The type for hashing blocks and tries. type Hash = Hash; /// The hashing algorithm used. type Hashing = BlakeTwo256; - /// The header type. - type Header = generic::Header; /// The ubiquitous event type. type RuntimeEvent = RuntimeEvent; /// The ubiquitous origin type. @@ -278,12 +276,7 @@ impl pallet_template::Config for Runtime { // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( - pub struct Runtime - where - Block = Block, - NodeBlock = opaque::Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { + pub struct Runtime { System: frame_system, Timestamp: pallet_timestamp, Aura: pallet_aura, diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 813f3c58b08cc..eb801e263f920 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -227,12 +227,11 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = Index; - type BlockNumber = BlockNumber; type Hash = Hash; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = Indices; - type Header = generic::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = Version; @@ -1869,10 +1868,7 @@ impl pallet_statement::Config for Runtime { } construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = node_primitives::Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system, Utility: pallet_utility, diff --git a/frame/alliance/src/benchmarking.rs b/frame/alliance/src/benchmarking.rs index 92bf1ae4468df..eb32c6c466c91 100644 --- a/frame/alliance/src/benchmarking.rs +++ b/frame/alliance/src/benchmarking.rs @@ -27,7 +27,7 @@ use sp_std::{ use frame_benchmarking::v1::{account, benchmarks_instance_pallet, BenchmarkError}; use frame_support::traits::{EnsureOrigin, Get, UnfilteredDispatchable}; -use frame_system::{Pallet as System, RawOrigin as SystemOrigin}; +use frame_system::{pallet_prelude::BlockNumberFor, Pallet as System, RawOrigin as SystemOrigin}; use super::{Call as AllianceCall, Pallet as Alliance, *}; @@ -432,7 +432,7 @@ benchmarks_instance_pallet! { false, )?; - System::::set_block_number(T::BlockNumber::max_value()); + System::::set_block_number(BlockNumberFor::::max_value()); }: close(SystemOrigin::Signed(voter), last_hash.clone(), index, Weight::MAX, bytes_in_storage) verify { @@ -504,7 +504,7 @@ benchmarks_instance_pallet! { } // caller is prime, prime already votes aye by creating the proposal - System::::set_block_number(T::BlockNumber::max_value()); + System::::set_block_number(BlockNumberFor::::max_value()); }: close(SystemOrigin::Signed(voter), last_hash.clone(), index, Weight::MAX, bytes_in_storage) verify { diff --git a/frame/alliance/src/lib.rs b/frame/alliance/src/lib.rs index 6dec6543babd1..c103f975f23be 100644 --- a/frame/alliance/src/lib.rs +++ b/frame/alliance/src/lib.rs @@ -309,7 +309,7 @@ pub mod pallet { /// The number of blocks a member must wait between giving a retirement notice and retiring. /// Supposed to be greater than time required to `kick_member`. - type RetirementPeriod: Get; + type RetirementPeriod: Get>; } #[pallet::error] @@ -477,7 +477,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn retiring_members)] pub type RetiringMembers, I: 'static = ()> = - StorageMap<_, Blake2_128Concat, T::AccountId, T::BlockNumber, OptionQuery>; + StorageMap<_, Blake2_128Concat, T::AccountId, BlockNumberFor, OptionQuery>; /// The current list of accounts deemed unscrupulous. These accounts non grata cannot submit /// candidacy. diff --git a/frame/alliance/src/mock.rs b/frame/alliance/src/mock.rs index ea6f4e58b1536..f141ead43ca8b 100644 --- a/frame/alliance/src/mock.rs +++ b/frame/alliance/src/mock.rs @@ -20,7 +20,6 @@ pub use sp_core::H256; use sp_runtime::traits::Hash; pub use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; @@ -53,12 +52,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = BlockNumber; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type DbWeight = (); @@ -238,14 +236,10 @@ impl Config for Test { type RetirementPeriod = RetirementPeriod; } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Balances: pallet_balances, diff --git a/frame/asset-conversion/src/lib.rs b/frame/asset-conversion/src/lib.rs index 68a0210b40058..5887295f973c3 100644 --- a/frame/asset-conversion/src/lib.rs +++ b/frame/asset-conversion/src/lib.rs @@ -72,7 +72,10 @@ use frame_support::{ ensure, traits::tokens::{AssetId, Balance}, }; -use frame_system::{ensure_signed, pallet_prelude::OriginFor}; +use frame_system::{ + ensure_signed, + pallet_prelude::{BlockNumberFor, OriginFor}, +}; pub use pallet::*; use sp_arithmetic::traits::Unsigned; use sp_runtime::{ @@ -357,7 +360,7 @@ pub mod pallet { } #[pallet::hooks] - impl Hooks for Pallet { + impl Hooks> for Pallet { fn integrity_test() { assert!( T::MaxSwapPathLength::get() > 1, diff --git a/frame/asset-conversion/src/mock.rs b/frame/asset-conversion/src/mock.rs index 35c10a22cf454..022f9d6337580 100644 --- a/frame/asset-conversion/src/mock.rs +++ b/frame/asset-conversion/src/mock.rs @@ -31,18 +31,13 @@ use frame_system::{EnsureSigned, EnsureSignedBy}; use sp_arithmetic::Permill; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{AccountIdConversion, BlakeTwo256, IdentityLookup}, BuildStorage, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Balances: pallet_balances, @@ -59,12 +54,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); diff --git a/frame/asset-rate/src/mock.rs b/frame/asset-rate/src/mock.rs index 56d52d708d57f..966eb7fad8ae5 100644 --- a/frame/asset-rate/src/mock.rs +++ b/frame/asset-rate/src/mock.rs @@ -21,19 +21,14 @@ use crate as pallet_asset_rate; use frame_support::traits::{ConstU16, ConstU64}; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, AssetRate: pallet_asset_rate, @@ -49,12 +44,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/assets/src/mock.rs b/frame/assets/src/mock.rs index 7c93e5210015a..5a7b244754c8a 100644 --- a/frame/assets/src/mock.rs +++ b/frame/assets/src/mock.rs @@ -28,19 +28,14 @@ use frame_support::{ use sp_core::H256; use sp_io::storage; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -58,12 +53,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); diff --git a/frame/atomic-swap/src/lib.rs b/frame/atomic-swap/src/lib.rs index 2d93887b82596..8094c06030120 100644 --- a/frame/atomic-swap/src/lib.rs +++ b/frame/atomic-swap/src/lib.rs @@ -50,6 +50,7 @@ use frame_support::{ weights::Weight, RuntimeDebugNoBound, }; +use frame_system::pallet_prelude::BlockNumberFor; use scale_info::TypeInfo; use sp_io::hashing::blake2_256; use sp_runtime::RuntimeDebug; @@ -69,7 +70,7 @@ pub struct PendingSwap { /// Action of this swap. pub action: T::SwapAction, /// End block of the lock. - pub end_block: T::BlockNumber, + pub end_block: BlockNumberFor, } /// Hashed proof type. @@ -249,7 +250,7 @@ pub mod pallet { target: T::AccountId, hashed_proof: HashedProof, action: T::SwapAction, - duration: T::BlockNumber, + duration: BlockNumberFor, ) -> DispatchResult { let source = ensure_signed(origin)?; ensure!( diff --git a/frame/atomic-swap/src/tests.rs b/frame/atomic-swap/src/tests.rs index 7e4d8e97319e7..eaba60c41bbc0 100644 --- a/frame/atomic-swap/src/tests.rs +++ b/frame/atomic-swap/src/tests.rs @@ -6,19 +6,14 @@ use crate as pallet_atomic_swap; use frame_support::traits::{ConstU32, ConstU64}; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -33,13 +28,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/aura/src/lib.rs b/frame/aura/src/lib.rs index 58c85166476f0..7a1969d905fcc 100644 --- a/frame/aura/src/lib.rs +++ b/frame/aura/src/lib.rs @@ -102,7 +102,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(_: T::BlockNumber) -> Weight { + fn on_initialize(_: BlockNumberFor) -> Weight { if let Some(new_slot) = Self::current_slot_from_digests() { let current_slot = CurrentSlot::::get(); @@ -134,7 +134,7 @@ pub mod pallet { } #[cfg(feature = "try-runtime")] - fn try_state(_: T::BlockNumber) -> Result<(), sp_runtime::TryRuntimeError> { + fn try_state(_: BlockNumberFor) -> Result<(), sp_runtime::TryRuntimeError> { Self::do_try_state() } } diff --git a/frame/aura/src/mock.rs b/frame/aura/src/mock.rs index 3fa3bec669593..eb6c08d17566a 100644 --- a/frame/aura/src/mock.rs +++ b/frame/aura/src/mock.rs @@ -26,20 +26,12 @@ use frame_support::{ }; use sp_consensus_aura::{ed25519::AuthorityId, AuthorityIndex}; use sp_core::H256; -use sp_runtime::{ - testing::{Header, UintAuthorityId}, - traits::IdentityLookup, - BuildStorage, -}; +use sp_runtime::{testing::UintAuthorityId, traits::IdentityLookup, BuildStorage}; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, @@ -54,13 +46,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/authority-discovery/src/lib.rs b/frame/authority-discovery/src/lib.rs index 2b0c27740c3e6..80a35071d1e35 100644 --- a/frame/authority-discovery/src/lib.rs +++ b/frame/authority-discovery/src/lib.rs @@ -177,19 +177,15 @@ mod tests { use sp_core::{crypto::key_types, H256}; use sp_io::TestExternalities; use sp_runtime::{ - testing::{Header, UintAuthorityId}, + testing::UintAuthorityId, traits::{ConvertInto, IdentityLookup, OpaqueKeys}, BuildStorage, KeyTypeId, Perbill, }; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Session: pallet_session::{Pallet, Call, Storage, Event, Config}, @@ -236,13 +232,12 @@ mod tests { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = BlockNumber; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AuthorityId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index 73c631c36f96e..2065439439b7b 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -45,7 +45,7 @@ pub mod pallet { /// Find the author of a block. type FindAuthor: FindAuthor; /// An event handler for authored blocks. - type EventHandler: EventHandler; + type EventHandler: EventHandler>; } #[pallet::pallet] @@ -53,7 +53,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(_: T::BlockNumber) -> Weight { + fn on_initialize(_: BlockNumberFor) -> Weight { if let Some(author) = Self::author() { T::EventHandler::note_author(author); } @@ -61,7 +61,7 @@ pub mod pallet { Weight::zero() } - fn on_finalize(_: T::BlockNumber) { + fn on_finalize(_: BlockNumberFor) { // ensure we never go to trie with these values. >::kill(); } @@ -109,14 +109,10 @@ mod tests { BuildStorage, }; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Authorship: pallet_authorship::{Pallet, Storage}, @@ -130,13 +126,12 @@ mod tests { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/babe/src/equivocation.rs b/frame/babe/src/equivocation.rs index be38beb6e1682..ed1df640583b2 100644 --- a/frame/babe/src/equivocation.rs +++ b/frame/babe/src/equivocation.rs @@ -34,6 +34,7 @@ //! definition. use frame_support::traits::{Get, KeyOwnerProofSystem}; +use frame_system::pallet_prelude::HeaderFor; use log::{error, info}; use sp_consensus_babe::{AuthorityId, EquivocationProof, Slot, KEY_TYPE}; @@ -106,7 +107,7 @@ impl Offence for EquivocationOffence { pub struct EquivocationReportSystem(sp_std::marker::PhantomData<(T, R, P, L)>); impl - OffenceReportSystem, (EquivocationProof, T::KeyOwnerProof)> + OffenceReportSystem, (EquivocationProof>, T::KeyOwnerProof)> for EquivocationReportSystem where T: Config + pallet_authorship::Config + frame_system::offchain::SendTransactionTypes>, @@ -122,7 +123,7 @@ where type Longevity = L; fn publish_evidence( - evidence: (EquivocationProof, T::KeyOwnerProof), + evidence: (EquivocationProof>, T::KeyOwnerProof), ) -> Result<(), ()> { use frame_system::offchain::SubmitTransaction; let (equivocation_proof, key_owner_proof) = evidence; @@ -140,7 +141,7 @@ where } fn check_evidence( - evidence: (EquivocationProof, T::KeyOwnerProof), + evidence: (EquivocationProof>, T::KeyOwnerProof), ) -> Result<(), TransactionValidityError> { let (equivocation_proof, key_owner_proof) = evidence; @@ -159,7 +160,7 @@ where fn process_evidence( reporter: Option, - evidence: (EquivocationProof, T::KeyOwnerProof), + evidence: (EquivocationProof>, T::KeyOwnerProof), ) -> Result<(), DispatchError> { let (equivocation_proof, key_owner_proof) = evidence; let reporter = reporter.or_else(|| >::author()); diff --git a/frame/babe/src/lib.rs b/frame/babe/src/lib.rs index de9fca3b75dd7..eff56515a38d0 100644 --- a/frame/babe/src/lib.rs +++ b/frame/babe/src/lib.rs @@ -29,6 +29,7 @@ use frame_support::{ weights::Weight, BoundedVec, WeakBoundedVec, }; +use frame_system::pallet_prelude::{BlockNumberFor, HeaderFor}; use sp_consensus_babe::{ digests::{NextConfigDescriptor, NextEpochDescriptor, PreDigest}, AllowedSlots, BabeAuthorityWeight, BabeEpochConfiguration, ConsensusLog, Epoch, @@ -78,7 +79,7 @@ pub trait WeightInfo { pub trait EpochChangeTrigger { /// Trigger an epoch change, if any should take place. This should be called /// during every block, after initialization is done. - fn trigger(now: T::BlockNumber); + fn trigger(now: BlockNumberFor); } /// A type signifying to BABE that an external trigger @@ -86,7 +87,7 @@ pub trait EpochChangeTrigger { pub struct ExternalTrigger; impl EpochChangeTrigger for ExternalTrigger { - fn trigger(_: T::BlockNumber) {} // nothing - trigger is external. + fn trigger(_: BlockNumberFor) {} // nothing - trigger is external. } /// A type signifying to BABE that it should perform epoch changes @@ -94,7 +95,7 @@ impl EpochChangeTrigger for ExternalTrigger { pub struct SameAuthoritiesForever; impl EpochChangeTrigger for SameAuthoritiesForever { - fn trigger(now: T::BlockNumber) { + fn trigger(now: BlockNumberFor) { if >::should_epoch_change(now) { let authorities = >::authorities(); let next_authorities = authorities.clone(); @@ -162,7 +163,7 @@ pub mod pallet { /// (from an offchain context). type EquivocationReportSystem: OffenceReportSystem< Option, - (EquivocationProof, Self::KeyOwnerProof), + (EquivocationProof>, Self::KeyOwnerProof), >; } @@ -279,7 +280,7 @@ pub mod pallet { /// slots, which may be skipped, the block numbers may not line up with the slot numbers. #[pallet::storage] pub(super) type EpochStart = - StorageValue<_, (T::BlockNumber, T::BlockNumber), ValueQuery>; + StorageValue<_, (BlockNumberFor, BlockNumberFor), ValueQuery>; /// How late the current block is compared to its parent. /// @@ -288,7 +289,7 @@ pub mod pallet { /// execution context should always yield zero. #[pallet::storage] #[pallet::getter(fn lateness)] - pub(super) type Lateness = StorageValue<_, T::BlockNumber, ValueQuery>; + pub(super) type Lateness = StorageValue<_, BlockNumberFor, ValueQuery>; /// The configuration for the current epoch. Should never be `None` as it is initialized in /// genesis. @@ -409,7 +410,7 @@ pub mod pallet { ))] pub fn report_equivocation( origin: OriginFor, - equivocation_proof: Box>, + equivocation_proof: Box>>, key_owner_proof: T::KeyOwnerProof, ) -> DispatchResultWithPostInfo { let reporter = ensure_signed(origin)?; @@ -435,7 +436,7 @@ pub mod pallet { ))] pub fn report_equivocation_unsigned( origin: OriginFor, - equivocation_proof: Box>, + equivocation_proof: Box>>, key_owner_proof: T::KeyOwnerProof, ) -> DispatchResultWithPostInfo { ensure_none(origin)?; @@ -505,8 +506,8 @@ impl IsMember for Pallet { } } -impl pallet_session::ShouldEndSession for Pallet { - fn should_end_session(now: T::BlockNumber) -> bool { +impl pallet_session::ShouldEndSession> for Pallet { + fn should_end_session(now: BlockNumberFor) -> bool { // it might be (and it is in current implementation) that session module is calling // `should_end_session` from it's own `on_initialize` handler, in which case it's // possible that babe's own `on_initialize` has not run yet, so let's ensure that we @@ -526,7 +527,7 @@ impl Pallet { /// Determine whether an epoch change should take place at this block. /// Assumes that initialization has already taken place. - pub fn should_epoch_change(now: T::BlockNumber) -> bool { + pub fn should_epoch_change(now: BlockNumberFor) -> bool { // The epoch has technically ended during the passage of time // between this block and the last, but we have to "end" the epoch now, // since there is no earlier possible block we could have done it. @@ -556,11 +557,11 @@ impl Pallet { // // WEIGHT NOTE: This function is tied to the weight of `EstimateNextSessionRotation`. If you // update this function, you must also update the corresponding weight. - pub fn next_expected_epoch_change(now: T::BlockNumber) -> Option { + pub fn next_expected_epoch_change(now: BlockNumberFor) -> Option> { let next_slot = Self::current_epoch_start().saturating_add(T::EpochDuration::get()); next_slot.checked_sub(*CurrentSlot::::get()).map(|slots_remaining| { // This is a best effort guess. Drifts in the slot/block ratio will cause errors here. - let blocks_remaining: T::BlockNumber = slots_remaining.saturated_into(); + let blocks_remaining: BlockNumberFor = slots_remaining.saturated_into(); now.saturating_add(blocks_remaining) }) } @@ -778,7 +779,7 @@ impl Pallet { Self::deposit_consensus(ConsensusLog::NextEpochData(next)); } - fn initialize(now: T::BlockNumber) { + fn initialize(now: BlockNumberFor) { // since `initialize` can be called twice (e.g. if session module is present) // let's ensure that we only do the initialization once per block let initialized = Self::initialized().is_some(); @@ -813,7 +814,7 @@ impl Pallet { // how many slots were skipped between current and last block let lateness = current_slot.saturating_sub(CurrentSlot::::get() + 1); - let lateness = T::BlockNumber::from(*lateness as u32); + let lateness = BlockNumberFor::::from(*lateness as u32); Lateness::::put(lateness); CurrentSlot::::put(current_slot); @@ -879,7 +880,7 @@ impl Pallet { /// will push the transaction to the pool. Only useful in an offchain /// context. pub fn submit_unsigned_equivocation_report( - equivocation_proof: EquivocationProof, + equivocation_proof: EquivocationProof>, key_owner_proof: T::KeyOwnerProof, ) -> Option<()> { T::EquivocationReportSystem::publish_evidence((equivocation_proof, key_owner_proof)).ok() @@ -901,12 +902,14 @@ impl OnTimestampSet for Pallet { } } -impl frame_support::traits::EstimateNextSessionRotation for Pallet { - fn average_session_length() -> T::BlockNumber { +impl frame_support::traits::EstimateNextSessionRotation> + for Pallet +{ + fn average_session_length() -> BlockNumberFor { T::EpochDuration::get().saturated_into() } - fn estimate_current_session_progress(_now: T::BlockNumber) -> (Option, Weight) { + fn estimate_current_session_progress(_now: BlockNumberFor) -> (Option, Weight) { let elapsed = CurrentSlot::::get().saturating_sub(Self::current_epoch_start()) + 1; ( @@ -916,7 +919,9 @@ impl frame_support::traits::EstimateNextSessionRotation (Option, Weight) { + fn estimate_next_session_rotation( + now: BlockNumberFor, + ) -> (Option>, Weight) { ( Self::next_expected_epoch_change(now), // Read: Current Slot, Epoch Index, Genesis Slot @@ -925,8 +930,8 @@ impl frame_support::traits::EstimateNextSessionRotation frame_support::traits::Lateness for Pallet { - fn lateness(&self) -> T::BlockNumber { +impl frame_support::traits::Lateness> for Pallet { + fn lateness(&self) -> BlockNumberFor { Self::lateness() } } diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index 96f9ce4ff8e8d..2b1c62d20622a 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -42,14 +42,10 @@ use sp_staking::{EraIndex, SessionIndex}; type DummyValidatorId = u64; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Authorship: pallet_authorship, @@ -70,14 +66,13 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Version = (); type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = DummyValidatorId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type PalletInfo = PalletInfo; diff --git a/frame/babe/src/randomness.rs b/frame/babe/src/randomness.rs index b9b24786b7a74..d3d1bea2292da 100644 --- a/frame/babe/src/randomness.rs +++ b/frame/babe/src/randomness.rs @@ -22,6 +22,7 @@ use super::{ AuthorVrfRandomness, Config, EpochStart, NextRandomness, Randomness, RANDOMNESS_LENGTH, }; use frame_support::traits::Randomness as RandomnessT; +use frame_system::pallet_prelude::BlockNumberFor; use sp_runtime::traits::{Hash, One, Saturating}; /// Randomness usable by consensus protocols that **depend** upon finality and take action @@ -129,8 +130,8 @@ pub struct ParentBlockRandomness(sp_std::marker::PhantomData); Please use `ParentBlockRandomness` instead.")] pub struct CurrentBlockRandomness(sp_std::marker::PhantomData); -impl RandomnessT for RandomnessFromTwoEpochsAgo { - fn random(subject: &[u8]) -> (T::Hash, T::BlockNumber) { +impl RandomnessT> for RandomnessFromTwoEpochsAgo { + fn random(subject: &[u8]) -> (T::Hash, BlockNumberFor) { let mut subject = subject.to_vec(); subject.reserve(RANDOMNESS_LENGTH); subject.extend_from_slice(&Randomness::::get()[..]); @@ -139,8 +140,8 @@ impl RandomnessT for RandomnessFromTwoEpochs } } -impl RandomnessT for RandomnessFromOneEpochAgo { - fn random(subject: &[u8]) -> (T::Hash, T::BlockNumber) { +impl RandomnessT> for RandomnessFromOneEpochAgo { + fn random(subject: &[u8]) -> (T::Hash, BlockNumberFor) { let mut subject = subject.to_vec(); subject.reserve(RANDOMNESS_LENGTH); subject.extend_from_slice(&NextRandomness::::get()[..]); @@ -149,8 +150,8 @@ impl RandomnessT for RandomnessFromOneEpochA } } -impl RandomnessT, T::BlockNumber> for ParentBlockRandomness { - fn random(subject: &[u8]) -> (Option, T::BlockNumber) { +impl RandomnessT, BlockNumberFor> for ParentBlockRandomness { + fn random(subject: &[u8]) -> (Option, BlockNumberFor) { let random = AuthorVrfRandomness::::get().map(|random| { let mut subject = subject.to_vec(); subject.reserve(RANDOMNESS_LENGTH); @@ -164,8 +165,8 @@ impl RandomnessT, T::BlockNumber> for ParentBlockRand } #[allow(deprecated)] -impl RandomnessT, T::BlockNumber> for CurrentBlockRandomness { - fn random(subject: &[u8]) -> (Option, T::BlockNumber) { +impl RandomnessT, BlockNumberFor> for CurrentBlockRandomness { + fn random(subject: &[u8]) -> (Option, BlockNumberFor) { let (random, _) = ParentBlockRandomness::::random(subject); (random, >::block_number()) } diff --git a/frame/bags-list/src/mock.rs b/frame/bags-list/src/mock.rs index f4f29ec35912d..860a07eb7f05c 100644 --- a/frame/bags-list/src/mock.rs +++ b/frame/bags-list/src/mock.rs @@ -53,13 +53,12 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type DbWeight = (); @@ -87,13 +86,9 @@ impl bags_list::Config for Runtime { type Score = VoteWeight; } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub struct Runtime { System: frame_system::{Pallet, Call, Storage, Event, Config}, BagsList: bags_list::{Pallet, Call, Storage, Event}, diff --git a/frame/balances/README.md b/frame/balances/README.md index dd56ab3fadfb5..fa1ee622d48ce 100644 --- a/frame/balances/README.md +++ b/frame/balances/README.md @@ -94,7 +94,7 @@ The Staking module uses the `LockableCurrency` trait to lock a stash account's f use frame_support::traits::{WithdrawReasons, LockableCurrency}; use sp_runtime::traits::Bounded; pub trait Config: frame_system::Config { - type Currency: LockableCurrency; + type Currency: LockableCurrency>; } fn update_ledger( diff --git a/frame/balances/src/impl_currency.rs b/frame/balances/src/impl_currency.rs index baa153c119b20..2cbe776c51297 100644 --- a/frame/balances/src/impl_currency.rs +++ b/frame/balances/src/impl_currency.rs @@ -32,6 +32,7 @@ use frame_support::{ ReservableCurrency, SignedImbalance, TryDrop, WithdrawReasons, }, }; +use frame_system::pallet_prelude::BlockNumberFor; pub use imbalances::{NegativeImbalance, PositiveImbalance}; // wrapping these imbalances in a private module is necessary to ensure absolute privacy @@ -842,7 +843,7 @@ impl, I: 'static> LockableCurrency for Pallet where T::Balance: MaybeSerializeDeserialize + Debug, { - type Moment = T::BlockNumber; + type Moment = BlockNumberFor; type MaxLocks = T::MaxLocks; diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index 206ee371e0737..e77b0f5e5d956 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -120,7 +120,7 @@ //! use frame_support::traits::{WithdrawReasons, LockableCurrency}; //! use sp_runtime::traits::Bounded; //! pub trait Config: frame_system::Config { -//! type Currency: LockableCurrency; +//! type Currency: LockableCurrency>; //! } //! # struct StakingLedger { //! # stash: ::AccountId, @@ -498,7 +498,7 @@ pub mod pallet { } #[pallet::hooks] - impl, I: 'static> Hooks for Pallet { + impl, I: 'static> Hooks> for Pallet { #[cfg(not(feature = "insecure_zero_ed"))] fn integrity_test() { assert!( diff --git a/frame/balances/src/tests/mod.rs b/frame/balances/src/tests/mod.rs index 6d9b9217ba0b0..60ea7b9eeefc5 100644 --- a/frame/balances/src/tests/mod.rs +++ b/frame/balances/src/tests/mod.rs @@ -38,7 +38,6 @@ use scale_info::TypeInfo; use sp_core::{hexdisplay::HexDisplay, H256}; use sp_io; use sp_runtime::{ - testing::Header, traits::{BadOrigin, IdentityLookup, SignedExtension, Zero}, ArithmeticError, BuildStorage, DispatchError, DispatchResult, FixedPointNumber, TokenError, }; @@ -50,7 +49,6 @@ mod fungible_conformance_tests; mod fungible_tests; mod reentrancy_tests; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; #[derive( @@ -73,10 +71,7 @@ pub enum TestId { } frame_support::construct_runtime!( - pub struct Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub struct Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -98,13 +93,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/beefy-mmr/src/lib.rs b/frame/beefy-mmr/src/lib.rs index ba416922e2563..ec1519ac41bd3 100644 --- a/frame/beefy-mmr/src/lib.rs +++ b/frame/beefy-mmr/src/lib.rs @@ -43,6 +43,7 @@ use sp_consensus_beefy::{ }; use frame_support::{crypto::ecdsa::ECDSAExt, traits::Get}; +use frame_system::pallet_prelude::BlockNumberFor; pub use pallet::*; @@ -139,7 +140,7 @@ pub mod pallet { impl LeafDataProvider for Pallet { type LeafData = MmrLeaf< - ::BlockNumber, + BlockNumberFor, ::Hash, MerkleRootOf, T::LeafExtra, diff --git a/frame/beefy-mmr/src/mock.rs b/frame/beefy-mmr/src/mock.rs index 8cb20703c63e9..af73c6a9a4966 100644 --- a/frame/beefy-mmr/src/mock.rs +++ b/frame/beefy-mmr/src/mock.rs @@ -29,7 +29,6 @@ use sp_core::H256; use sp_runtime::{ app_crypto::ecdsa::Public, impl_opaque_keys, - testing::Header, traits::{BlakeTwo256, ConvertInto, IdentityLookup, Keccak256, OpaqueKeys}, BuildStorage, }; @@ -46,14 +45,10 @@ impl_opaque_keys! { } } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Session: pallet_session::{Pallet, Call, Storage, Event, Config}, @@ -70,13 +65,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); @@ -103,7 +97,7 @@ impl pallet_session::Config for Test { } pub type MmrLeaf = sp_consensus_beefy::mmr::MmrLeaf< - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, ::Hash, crate::MerkleRootOf, Vec, diff --git a/frame/beefy/src/equivocation.rs b/frame/beefy/src/equivocation.rs index 96446cf1b8277..acbd3a2532d78 100644 --- a/frame/beefy/src/equivocation.rs +++ b/frame/beefy/src/equivocation.rs @@ -39,6 +39,7 @@ use frame_support::{ log, traits::{Get, KeyOwnerProofSystem}, }; +use frame_system::pallet_prelude::BlockNumberFor; use log::{error, info}; use sp_consensus_beefy::{EquivocationProof, ValidatorSetId, KEY_TYPE}; use sp_runtime::{ @@ -126,7 +127,7 @@ pub struct EquivocationReportSystem(sp_std::marker::PhantomData<(T, /// Equivocation evidence convenience alias. pub type EquivocationEvidenceFor = ( EquivocationProof< - ::BlockNumber, + BlockNumberFor, ::BeefyId, <::BeefyId as RuntimeAppPublic>::Signature, >, @@ -140,7 +141,7 @@ where R: ReportOffence< T::AccountId, P::IdentificationTuple, - EquivocationOffence, + EquivocationOffence>, >, P: KeyOwnerProofSystem<(KeyTypeId, T::BeefyId), Proof = T::KeyOwnerProof>, P::IdentificationTuple: Clone, diff --git a/frame/beefy/src/mock.rs b/frame/beefy/src/mock.rs index 5ec3bdb7e5593..1d7052a62d2c9 100644 --- a/frame/beefy/src/mock.rs +++ b/frame/beefy/src/mock.rs @@ -30,7 +30,7 @@ use sp_runtime::{ app_crypto::ecdsa::Public, curve::PiecewiseLinear, impl_opaque_keys, - testing::{Header, TestXt}, + testing::TestXt, traits::{BlakeTwo256, IdentityLookup, OpaqueKeys}, BuildStorage, Perbill, }; @@ -49,14 +49,10 @@ impl_opaque_keys! { } } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Authorship: pallet_authorship, @@ -77,13 +73,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/benchmarking/pov/src/benchmarking.rs b/frame/benchmarking/pov/src/benchmarking.rs index 1112045d9cacc..1ed446d972136 100644 --- a/frame/benchmarking/pov/src/benchmarking.rs +++ b/frame/benchmarking/pov/src/benchmarking.rs @@ -343,16 +343,11 @@ mod mock { type AccountId = u64; type AccountIndex = u32; - type BlockNumber = u64; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Baseline: crate::{Pallet, Call, Storage, Event}, @@ -366,13 +361,12 @@ mod mock { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = AccountIndex; - type BlockNumber = BlockNumber; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); diff --git a/frame/benchmarking/pov/src/tests.rs b/frame/benchmarking/pov/src/tests.rs index 2136dc50b9e6f..a6101a72e9c98 100644 --- a/frame/benchmarking/pov/src/tests.rs +++ b/frame/benchmarking/pov/src/tests.rs @@ -164,14 +164,10 @@ fn noop_is_free() { mod mock { use sp_runtime::testing::H256; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Baseline: crate::{Pallet, Call, Storage, Event}, @@ -185,13 +181,12 @@ mod mock { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u32; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = u32; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); diff --git a/frame/benchmarking/src/baseline.rs b/frame/benchmarking/src/baseline.rs index a6a9fada9b2aa..6940947471e20 100644 --- a/frame/benchmarking/src/baseline.rs +++ b/frame/benchmarking/src/baseline.rs @@ -115,16 +115,11 @@ pub mod mock { type AccountId = u64; type AccountIndex = u32; - type BlockNumber = u64; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, } @@ -137,13 +132,12 @@ pub mod mock { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = AccountIndex; - type BlockNumber = BlockNumber; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); diff --git a/frame/benchmarking/src/tests.rs b/frame/benchmarking/src/tests.rs index 0f22360a9431e..d4abb437a360c 100644 --- a/frame/benchmarking/src/tests.rs +++ b/frame/benchmarking/src/tests.rs @@ -22,7 +22,7 @@ use super::*; use frame_support::{parameter_types, traits::ConstU32}; use sp_runtime::{ - testing::{Header, H256}, + testing::H256, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; @@ -66,14 +66,10 @@ mod pallet_test { } } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, TestPallet: pallet_test::{Pallet, Call, Storage}, @@ -87,13 +83,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); diff --git a/frame/benchmarking/src/tests_instance.rs b/frame/benchmarking/src/tests_instance.rs index 1741142b17b63..2ccad38a8b746 100644 --- a/frame/benchmarking/src/tests_instance.rs +++ b/frame/benchmarking/src/tests_instance.rs @@ -22,7 +22,7 @@ use super::*; use frame_support::traits::ConstU32; use sp_runtime::{ - testing::{Header, H256}, + testing::H256, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; @@ -76,14 +76,10 @@ mod pallet_test { } } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, TestPallet: pallet_test::{Pallet, Call, Storage, Event}, @@ -97,12 +93,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type DbWeight = (); diff --git a/frame/bounties/src/benchmarking.rs b/frame/bounties/src/benchmarking.rs index 0675328c3d3c2..6fff337cba450 100644 --- a/frame/bounties/src/benchmarking.rs +++ b/frame/bounties/src/benchmarking.rs @@ -24,7 +24,7 @@ use super::*; use frame_benchmarking::v1::{ account, benchmarks_instance_pallet, whitelisted_caller, BenchmarkError, }; -use frame_system::RawOrigin; +use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use sp_runtime::traits::Bounded; use crate::Pallet as Bounties; @@ -77,7 +77,7 @@ fn create_bounty, I: 'static>( let approve_origin = T::SpendOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; Bounties::::approve_bounty(approve_origin.clone(), bounty_id)?; - Treasury::::on_initialize(T::BlockNumber::zero()); + Treasury::::on_initialize(BlockNumberFor::::zero()); Bounties::::propose_curator(approve_origin, bounty_id, curator_lookup.clone(), fee)?; Bounties::::accept_curator(RawOrigin::Signed(curator).into(), bounty_id)?; Ok((curator_lookup, bounty_id)) @@ -115,14 +115,14 @@ benchmarks_instance_pallet! { let bounty_id = BountyCount::::get() - 1; let approve_origin = T::SpendOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; Bounties::::approve_bounty(approve_origin.clone(), bounty_id)?; - Treasury::::on_initialize(T::BlockNumber::zero()); + Treasury::::on_initialize(BlockNumberFor::::zero()); }: _(approve_origin, bounty_id, curator_lookup, fee) // Worst case when curator is inactive and any sender unassigns the curator. unassign_curator { setup_pot_account::(); let (curator_lookup, bounty_id) = create_bounty::()?; - Treasury::::on_initialize(T::BlockNumber::zero()); + Treasury::::on_initialize(BlockNumberFor::::zero()); let bounty_id = BountyCount::::get() - 1; frame_system::Pallet::::set_block_number(T::BountyUpdatePeriod::get() + 2u32.into()); let caller = whitelisted_caller(); @@ -136,14 +136,14 @@ benchmarks_instance_pallet! { let bounty_id = BountyCount::::get() - 1; let approve_origin = T::SpendOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; Bounties::::approve_bounty(approve_origin.clone(), bounty_id)?; - Treasury::::on_initialize(T::BlockNumber::zero()); + Treasury::::on_initialize(BlockNumberFor::::zero()); Bounties::::propose_curator(approve_origin, bounty_id, curator_lookup, fee)?; }: _(RawOrigin::Signed(curator), bounty_id) award_bounty { setup_pot_account::(); let (curator_lookup, bounty_id) = create_bounty::()?; - Treasury::::on_initialize(T::BlockNumber::zero()); + Treasury::::on_initialize(BlockNumberFor::::zero()); let bounty_id = BountyCount::::get() - 1; let curator = T::Lookup::lookup(curator_lookup).map_err(<&str>::from)?; @@ -154,7 +154,7 @@ benchmarks_instance_pallet! { claim_bounty { setup_pot_account::(); let (curator_lookup, bounty_id) = create_bounty::()?; - Treasury::::on_initialize(T::BlockNumber::zero()); + Treasury::::on_initialize(BlockNumberFor::::zero()); let bounty_id = BountyCount::::get() - 1; let curator = T::Lookup::lookup(curator_lookup).map_err(<&str>::from)?; @@ -183,7 +183,7 @@ benchmarks_instance_pallet! { close_bounty_active { setup_pot_account::(); let (curator_lookup, bounty_id) = create_bounty::()?; - Treasury::::on_initialize(T::BlockNumber::zero()); + Treasury::::on_initialize(BlockNumberFor::::zero()); let bounty_id = BountyCount::::get() - 1; let approve_origin = T::ApproveOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; @@ -195,7 +195,7 @@ benchmarks_instance_pallet! { extend_bounty_expiry { setup_pot_account::(); let (curator_lookup, bounty_id) = create_bounty::()?; - Treasury::::on_initialize(T::BlockNumber::zero()); + Treasury::::on_initialize(BlockNumberFor::::zero()); let bounty_id = BountyCount::::get() - 1; let curator = T::Lookup::lookup(curator_lookup).map_err(<&str>::from)?; diff --git a/frame/bounties/src/lib.rs b/frame/bounties/src/lib.rs index 07ac23a9d8010..c64a35672c7f7 100644 --- a/frame/bounties/src/lib.rs +++ b/frame/bounties/src/lib.rs @@ -201,11 +201,11 @@ pub mod pallet { /// The delay period for which a bounty beneficiary need to wait before claim the payout. #[pallet::constant] - type BountyDepositPayoutDelay: Get; + type BountyDepositPayoutDelay: Get>; /// Bounty duration in blocks. #[pallet::constant] - type BountyUpdatePeriod: Get; + type BountyUpdatePeriod: Get>; /// The curator deposit is calculated as a percentage of the curator fee. /// @@ -305,7 +305,7 @@ pub mod pallet { _, Twox64Concat, BountyIndex, - Bounty, T::BlockNumber>, + Bounty, BlockNumberFor>, >; /// The description of each bounty. diff --git a/frame/bounties/src/tests.rs b/frame/bounties/src/tests.rs index 5d47b285f647b..f02c9cbffdbff 100644 --- a/frame/bounties/src/tests.rs +++ b/frame/bounties/src/tests.rs @@ -30,21 +30,16 @@ use frame_support::{ use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BadOrigin, BlakeTwo256, IdentityLookup}, BuildStorage, Perbill, Storage, }; use super::Event as BountiesEvent; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -68,13 +63,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/child-bounties/src/benchmarking.rs b/frame/child-bounties/src/benchmarking.rs index e49d9c836125d..1973564d0dc1d 100644 --- a/frame/child-bounties/src/benchmarking.rs +++ b/frame/child-bounties/src/benchmarking.rs @@ -22,7 +22,7 @@ use super::*; use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller, BenchmarkError}; -use frame_system::RawOrigin; +use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use crate::Pallet as ChildBounties; use pallet_bounties::Pallet as Bounties; @@ -114,7 +114,7 @@ fn activate_bounty( let approve_origin = T::SpendOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; Bounties::::approve_bounty(approve_origin, child_bounty_setup.bounty_id)?; - Treasury::::on_initialize(T::BlockNumber::zero()); + Treasury::::on_initialize(BlockNumberFor::::zero()); Bounties::::propose_curator( RawOrigin::Root.into(), child_bounty_setup.bounty_id, @@ -229,7 +229,7 @@ benchmarks! { unassign_curator { setup_pot_account::(); let bounty_setup = activate_child_bounty::(0, T::MaximumReasonLength::get())?; - Treasury::::on_initialize(T::BlockNumber::zero()); + Treasury::::on_initialize(BlockNumberFor::::zero()); frame_system::Pallet::::set_block_number(T::BountyUpdatePeriod::get() + 1u32.into()); let caller = whitelisted_caller(); }: _(RawOrigin::Signed(caller), bounty_setup.bounty_id, @@ -303,7 +303,7 @@ benchmarks! { close_child_bounty_active { setup_pot_account::(); let bounty_setup = activate_child_bounty::(0, T::MaximumReasonLength::get())?; - Treasury::::on_initialize(T::BlockNumber::zero()); + Treasury::::on_initialize(BlockNumberFor::::zero()); }: close_child_bounty(RawOrigin::Root, bounty_setup.bounty_id, bounty_setup.child_bounty_id) verify { assert_last_event::(Event::Canceled { diff --git a/frame/child-bounties/src/lib.rs b/frame/child-bounties/src/lib.rs index 14c1907af2c46..1eedeaa5a1ae3 100644 --- a/frame/child-bounties/src/lib.rs +++ b/frame/child-bounties/src/lib.rs @@ -200,7 +200,7 @@ pub mod pallet { BountyIndex, Twox64Concat, BountyIndex, - ChildBounty, T::BlockNumber>, + ChildBounty, BlockNumberFor>, >; /// The description of each child-bounty. @@ -816,7 +816,7 @@ impl Pallet { fn ensure_bounty_active( bounty_id: BountyIndex, - ) -> Result<(T::AccountId, T::BlockNumber), DispatchError> { + ) -> Result<(T::AccountId, BlockNumberFor), DispatchError> { let parent_bounty = pallet_bounties::Pallet::::bounties(bounty_id) .ok_or(BountiesError::::InvalidIndex)?; if let BountyStatus::Active { curator, update_due } = parent_bounty.get_status() { diff --git a/frame/child-bounties/src/tests.rs b/frame/child-bounties/src/tests.rs index 2a430b30163de..60161c88f510a 100644 --- a/frame/child-bounties/src/tests.rs +++ b/frame/child-bounties/src/tests.rs @@ -31,22 +31,17 @@ use frame_support::{ use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BadOrigin, BlakeTwo256, IdentityLookup}, BuildStorage, Perbill, Permill, TokenError, }; use super::Event as ChildBountiesEvent; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; type BountiesError = pallet_bounties::Error; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -71,13 +66,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/collective/src/benchmarking.rs b/frame/collective/src/benchmarking.rs index 8a4495ef4095b..503d725105309 100644 --- a/frame/collective/src/benchmarking.rs +++ b/frame/collective/src/benchmarking.rs @@ -24,7 +24,9 @@ use sp_runtime::traits::Bounded; use sp_std::mem::size_of; use frame_benchmarking::v1::{account, benchmarks_instance_pallet, whitelisted_caller}; -use frame_system::{Call as SystemCall, Pallet as System, RawOrigin as SystemOrigin}; +use frame_system::{ + pallet_prelude::BlockNumberFor, Call as SystemCall, Pallet as System, RawOrigin as SystemOrigin, +}; const SEED: u32 = 0; @@ -516,7 +518,7 @@ benchmarks_instance_pallet! { false, )?; - System::::set_block_number(T::BlockNumber::max_value()); + System::::set_block_number(BlockNumberFor::::max_value()); assert_eq!(Collective::::proposals().len(), p as usize); // Prime nay will close it as disapproved @@ -588,7 +590,7 @@ benchmarks_instance_pallet! { } // caller is prime, prime already votes aye by creating the proposal - System::::set_block_number(T::BlockNumber::max_value()); + System::::set_block_number(BlockNumberFor::::max_value()); assert_eq!(Collective::::proposals().len(), p as usize); // Prime aye will close it as approved @@ -637,7 +639,7 @@ benchmarks_instance_pallet! { last_hash = T::Hashing::hash_of(&proposal); } - System::::set_block_number(T::BlockNumber::max_value()); + System::::set_block_number(BlockNumberFor::::max_value()); assert_eq!(Collective::::proposals().len(), p as usize); }: _(SystemOrigin::Root, last_hash) diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index 6d6958666664e..1084091173934 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -201,7 +201,7 @@ pub mod pallet { + IsType<::RuntimeEvent>; /// The time-out for council motions. - type MotionDuration: Get; + type MotionDuration: Get>; /// Maximum number of proposals allowed to be active in parallel. type MaxProposals: Get; @@ -274,7 +274,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn voting)] pub type Voting, I: 'static = ()> = - StorageMap<_, Identity, T::Hash, Votes, OptionQuery>; + StorageMap<_, Identity, T::Hash, Votes>, OptionQuery>; /// Proposals so far. #[pallet::storage] diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index bf169316491b0..d67747a2b78f5 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -36,10 +36,7 @@ pub type Block = sp_runtime::generic::Block; pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub enum Test { System: frame_system::{Pallet, Call, Event}, Collective: pallet_collective::::{Pallet, Call, Event, Origin, Config}, @@ -100,13 +97,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index c067ba651c5ae..63482cca10c53 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -35,7 +35,7 @@ use frame_support::{ weights::Weight, Blake2_128Concat, BoundedVec, StorageHasher, }; -use frame_system::RawOrigin; +use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use pallet_contracts_primitives::ExecReturnValue; use smallvec::{Array, SmallVec}; use sp_core::{ @@ -52,7 +52,6 @@ use sp_std::{marker::PhantomData, mem, prelude::*, vec::Vec}; pub type AccountIdOf = ::AccountId; pub type MomentOf = <::Time as Time>::Moment; pub type SeedOf = ::Hash; -pub type BlockNumberOf = ::BlockNumber; pub type ExecResult = Result; /// A type that represents a topic of an event. At the moment a hash is used. @@ -254,7 +253,7 @@ pub trait Ext: sealing::Sealed { fn minimum_balance(&self) -> BalanceOf; /// Returns a random number for the current block with the given subject. - fn random(&self, subject: &[u8]) -> (SeedOf, BlockNumberOf); + fn random(&self, subject: &[u8]) -> (SeedOf, BlockNumberFor); /// Deposit an event with the given topics. /// @@ -262,7 +261,7 @@ pub trait Ext: sealing::Sealed { fn deposit_event(&mut self, topics: Vec>, data: Vec); /// Returns the current block number. - fn block_number(&self) -> BlockNumberOf; + fn block_number(&self) -> BlockNumberFor; /// Returns the maximum allowed size of a storage item. fn max_value_size(&self) -> u32; @@ -412,7 +411,7 @@ pub struct Stack<'a, T: Config, E> { /// The timestamp at the point of call stack instantiation. timestamp: MomentOf, /// The block number at the time of call stack instantiation. - block_number: T::BlockNumber, + block_number: BlockNumberFor, /// The nonce is cached here when accessed. It is written back when the call stack /// finishes executing. Please refer to [`Nonce`] to a description of /// the nonce itself. @@ -1376,7 +1375,7 @@ where self.top_frame().value_transferred } - fn random(&self, subject: &[u8]) -> (SeedOf, BlockNumberOf) { + fn random(&self, subject: &[u8]) -> (SeedOf, BlockNumberFor) { T::Randomness::random(subject) } @@ -1395,7 +1394,7 @@ where ); } - fn block_number(&self) -> T::BlockNumber { + fn block_number(&self) -> BlockNumberFor { self.block_number } diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index e0760f8d078c3..e570bc7c95af5 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -211,7 +211,7 @@ pub mod pallet { /// be instantiated from existing codes that use this deprecated functionality. It will /// be removed eventually. Hence for new `pallet-contracts` deployments it is okay /// to supply a dummy implementation for this type (because it is never used). - type Randomness: Randomness; + type Randomness: Randomness>; /// The fungible in which fees are paid and contract balances are held. type Currency: Inspect @@ -349,7 +349,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_idle(_block: T::BlockNumber, mut remaining_weight: Weight) -> Weight { + fn on_idle(_block: BlockNumberFor, mut remaining_weight: Weight) -> Weight { use migration::MigrateResult::*; loop { diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 90582b60c466a..79a5f4723a19d 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -51,20 +51,16 @@ use sp_core::ByteArray; use sp_io::hashing::blake2_256; use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; use sp_runtime::{ - testing::{Header, H256}, + testing::H256, traits::{BlakeTwo256, Convert, Hash, IdentityLookup}, AccountId32, BuildStorage, TokenError, }; use std::ops::Deref; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -316,13 +312,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = AccountId32; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index 49f2643498c7b..53f8201331451 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -453,7 +453,7 @@ impl Executable for WasmBlob { mod tests { use super::*; use crate::{ - exec::{AccountIdOf, BlockNumberOf, ErrorOrigin, ExecError, Executable, Ext, Key, SeedOf}, + exec::{AccountIdOf, ErrorOrigin, ExecError, Executable, Ext, Key, SeedOf}, gas::GasMeter, storage::WriteOutcome, tests::{RuntimeCall, Test, ALICE, BOB}, @@ -463,6 +463,7 @@ mod tests { use frame_support::{ assert_err, assert_ok, dispatch::DispatchResultWithPostInfo, weights::Weight, }; + use frame_system::pallet_prelude::BlockNumberFor; use pallet_contracts_primitives::{ExecReturnValue, ReturnFlags}; use pretty_assertions::assert_eq; use sp_core::H256; @@ -674,7 +675,7 @@ mod tests { fn minimum_balance(&self) -> u64 { 666 } - fn random(&self, subject: &[u8]) -> (SeedOf, BlockNumberOf) { + fn random(&self, subject: &[u8]) -> (SeedOf, BlockNumberFor) { (H256::from_slice(subject), 42) } fn deposit_event(&mut self, topics: Vec, data: Vec) { diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index 4b7d642be48ec..37340789ea3ac 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -2106,7 +2106,7 @@ pub mod env { /// `out_ptr`. This call overwrites it with the size of the value. If the available /// space at `out_ptr` is less than the size of the value a trap is triggered. /// - /// The data is encoded as (T::Hash, T::BlockNumber). + /// The data is encoded as (T::Hash, frame_system::pallet_prelude::BlockNumberFor::). /// /// # Changes from v0 /// diff --git a/frame/conviction-voting/src/lib.rs b/frame/conviction-voting/src/lib.rs index 3ad81486ed26d..9c2993fc5cae1 100644 --- a/frame/conviction-voting/src/lib.rs +++ b/frame/conviction-voting/src/lib.rs @@ -35,6 +35,7 @@ use frame_support::{ ReservableCurrency, WithdrawReasons, }, }; +use frame_system::pallet_prelude::BlockNumberFor; use sp_runtime::{ traits::{AtLeast32BitUnsigned, Saturating, StaticLookup, Zero}, ArithmeticError, Perbill, @@ -68,16 +69,13 @@ type BalanceOf = type VotingOf = Voting< BalanceOf, ::AccountId, - ::BlockNumber, + BlockNumberFor, PollIndexOf, >::MaxVotes, >; #[allow(dead_code)] -type DelegatingOf = Delegating< - BalanceOf, - ::AccountId, - ::BlockNumber, ->; +type DelegatingOf = + Delegating, ::AccountId, BlockNumberFor>; pub type TallyOf = Tally, >::MaxTurnout>; pub type VotesOf = BalanceOf; type PollIndexOf = <>::Polls as Polling>>::Index; @@ -103,14 +101,14 @@ pub mod pallet { type WeightInfo: WeightInfo; /// Currency type with which voting happens. type Currency: ReservableCurrency - + LockableCurrency + + LockableCurrency> + fungible::Inspect; /// The implementation of the logic which conducts polls. type Polls: Polling< TallyOf, Votes = BalanceOf, - Moment = Self::BlockNumber, + Moment = BlockNumberFor, >; /// The maximum amount of tokens which may be used for voting. May just be @@ -130,7 +128,7 @@ pub mod pallet { /// It should be no shorter than enactment period to ensure that in the case of an approval, /// those successful voters are locked into the consequences that their votes entail. #[pallet::constant] - type VoteLockingPeriod: Get; + type VoteLockingPeriod: Get>; } /// All voting for a particular voter in a particular voting class. We store the balance for the diff --git a/frame/conviction-voting/src/tests.rs b/frame/conviction-voting/src/tests.rs index 8f3451e28b87f..b0b692446d5d2 100644 --- a/frame/conviction-voting/src/tests.rs +++ b/frame/conviction-voting/src/tests.rs @@ -25,7 +25,6 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; @@ -33,14 +32,10 @@ use sp_runtime::{ use super::*; use crate as pallet_conviction_voting; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -63,13 +58,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/core-fellowship/src/benchmarking.rs b/frame/core-fellowship/src/benchmarking.rs index c49f50d4cc115..ea0b5c6d4495f 100644 --- a/frame/core-fellowship/src/benchmarking.rs +++ b/frame/core-fellowship/src/benchmarking.rs @@ -23,7 +23,7 @@ use super::*; use crate::Pallet as CoreFellowship; use frame_benchmarking::v2::*; -use frame_system::RawOrigin; +use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use sp_arithmetic::traits::Bounded; const SEED: u32 = 0; @@ -75,7 +75,7 @@ mod benchmarks { let member = make_member::(0)?; // Set it to the max value to ensure that any possible auto-demotion period has passed. - frame_system::Pallet::::set_block_number(T::BlockNumber::max_value()); + frame_system::Pallet::::set_block_number(BlockNumberFor::::max_value()); ensure_evidence::(&member)?; assert!(Member::::contains_key(&member)); @@ -92,7 +92,7 @@ mod benchmarks { let member = make_member::(2)?; // Set it to the max value to ensure that any possible auto-demotion period has passed. - frame_system::Pallet::::set_block_number(T::BlockNumber::max_value()); + frame_system::Pallet::::set_block_number(BlockNumberFor::::max_value()); ensure_evidence::(&member)?; assert!(Member::::contains_key(&member)); assert_eq!(T::Members::rank_of(&member), Some(2)); diff --git a/frame/core-fellowship/src/lib.rs b/frame/core-fellowship/src/lib.rs index ba02627ec11b9..8f3d9633fcf22 100644 --- a/frame/core-fellowship/src/lib.rs +++ b/frame/core-fellowship/src/lib.rs @@ -193,9 +193,8 @@ pub mod pallet { type EvidenceSize: Get; } - pub type ParamsOf = - ParamsType<>::Balance, ::BlockNumber, RANK_COUNT>; - pub type MemberStatusOf = MemberStatus<::BlockNumber>; + pub type ParamsOf = ParamsType<>::Balance, BlockNumberFor, RANK_COUNT>; + pub type MemberStatusOf = MemberStatus>; pub type RankOf = <>::Members as RankedMembers>::Rank; /// The overall status of the system. diff --git a/frame/core-fellowship/src/tests.rs b/frame/core-fellowship/src/tests.rs index ded343d997bdf..7e984c1efed34 100644 --- a/frame/core-fellowship/src/tests.rs +++ b/frame/core-fellowship/src/tests.rs @@ -28,7 +28,6 @@ use frame_support::{ use frame_system::EnsureSignedBy; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup, TryMorphInto}, BuildStorage, DispatchError, DispatchResult, }; @@ -37,14 +36,10 @@ use sp_std::cell::RefCell; use super::*; use crate as pallet_core_fellowship; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, CoreFellowship: pallet_core_fellowship::{Pallet, Call, Storage, Event}, @@ -62,13 +57,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/democracy/src/benchmarking.rs b/frame/democracy/src/benchmarking.rs index 9a67ba698a662..e4a21a4e1d9b8 100644 --- a/frame/democracy/src/benchmarking.rs +++ b/frame/democracy/src/benchmarking.rs @@ -24,7 +24,7 @@ use frame_support::{ assert_noop, assert_ok, traits::{Currency, EnsureOrigin, Get, OnInitialize, UnfilteredDispatchable}, }; -use frame_system::RawOrigin; +use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use sp_core::H256; use sp_runtime::{traits::Bounded, BoundedVec}; @@ -258,7 +258,7 @@ benchmarks! { .collect::>() .try_into() .unwrap(); - Blacklist::::insert(proposal.hash(), (T::BlockNumber::zero(), addresses)); + Blacklist::::insert(proposal.hash(), (BlockNumberFor::::zero(), addresses)); }: _(origin, proposal) verify { // External proposal created @@ -332,7 +332,7 @@ benchmarks! { vetoers.try_push(account::("vetoer", i, SEED)).unwrap(); } vetoers.sort(); - Blacklist::::insert(proposal_hash, (T::BlockNumber::zero(), vetoers)); + Blacklist::::insert(proposal_hash, (BlockNumberFor::::zero(), vetoers)); let origin = T::VetoOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; ensure!(NextExternal::::get().is_some(), "no external proposal"); @@ -816,7 +816,7 @@ benchmarks! { // create not ongoing referendum. ReferendumInfoOf::::insert( 0, - ReferendumInfo::Finished { end: T::BlockNumber::zero(), approved: true }, + ReferendumInfo::Finished { end: BlockNumberFor::::zero(), approved: true }, ); let owner = MetadataOwner::Referendum(0); let caller = funded_account::("caller", 0); @@ -833,7 +833,7 @@ benchmarks! { // create not ongoing referendum. ReferendumInfoOf::::insert( 0, - ReferendumInfo::Finished { end: T::BlockNumber::zero(), approved: true }, + ReferendumInfo::Finished { end: BlockNumberFor::::zero(), approved: true }, ); let owner = MetadataOwner::Referendum(0); let hash = note_preimage::(); diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 690224cc87217..e538d31c6ad03 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -165,7 +165,7 @@ use frame_support::{ }, weights::Weight, }; -use frame_system::pallet_prelude::OriginFor; +use frame_system::pallet_prelude::{BlockNumberFor, OriginFor}; use sp_runtime::{ traits::{Bounded as ArithBounded, One, Saturating, StaticLookup, Zero}, ArithmeticError, DispatchError, DispatchResult, @@ -226,14 +226,14 @@ pub mod pallet { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The Scheduler. - type Scheduler: ScheduleNamed, Self::PalletsOrigin>; + type Scheduler: ScheduleNamed, CallOf, Self::PalletsOrigin>; /// The Preimage provider. type Preimages: QueryPreimage + StorePreimage; /// Currency type for this pallet. type Currency: ReservableCurrency - + LockableCurrency; + + LockableCurrency>; /// The period between a proposal being approved and enacted. /// @@ -241,22 +241,22 @@ pub mod pallet { /// voting stakers have an opportunity to remove themselves from the system in the case /// where they are on the losing side of a vote. #[pallet::constant] - type EnactmentPeriod: Get; + type EnactmentPeriod: Get>; /// How often (in blocks) new public referenda are launched. #[pallet::constant] - type LaunchPeriod: Get; + type LaunchPeriod: Get>; /// How often (in blocks) to check for new votes. #[pallet::constant] - type VotingPeriod: Get; + type VotingPeriod: Get>; /// The minimum period of vote locking. /// /// It should be no shorter than enactment period to ensure that in the case of an approval, /// those successful voters are locked into the consequences that their votes entail. #[pallet::constant] - type VoteLockingPeriod: Get; + type VoteLockingPeriod: Get>; /// The minimum amount to be used as a deposit for a public referendum proposal. #[pallet::constant] @@ -270,11 +270,11 @@ pub mod pallet { /// Minimum voting period allowed for a fast-track referendum. #[pallet::constant] - type FastTrackVotingPeriod: Get; + type FastTrackVotingPeriod: Get>; /// Period in blocks where an external proposal may not be re-submitted after being vetoed. #[pallet::constant] - type CooloffPeriod: Get; + type CooloffPeriod: Get>; /// The maximum number of votes for an account. /// @@ -387,7 +387,7 @@ pub mod pallet { _, Twox64Concat, ReferendumIndex, - ReferendumInfo, BalanceOf>, + ReferendumInfo, BoundedCallOf, BalanceOf>, >; /// All votes for a particular voter. We store the balance for the number of votes that we @@ -399,7 +399,7 @@ pub mod pallet { _, Twox64Concat, T::AccountId, - Voting, T::AccountId, T::BlockNumber, T::MaxVotes>, + Voting, T::AccountId, BlockNumberFor, T::MaxVotes>, ValueQuery, >; @@ -422,7 +422,7 @@ pub mod pallet { _, Identity, H256, - (T::BlockNumber, BoundedVec), + (BlockNumberFor, BoundedVec), >; /// Record of all proposals that have been subject to emergency cancellation. @@ -476,7 +476,7 @@ pub mod pallet { /// An account has cancelled a previous delegation operation. Undelegated { account: T::AccountId }, /// An external proposal has been vetoed. - Vetoed { who: T::AccountId, proposal_hash: H256, until: T::BlockNumber }, + Vetoed { who: T::AccountId, proposal_hash: H256, until: BlockNumberFor }, /// A proposal_hash has been blacklisted permanently. Blacklisted { proposal_hash: H256 }, /// An account has voted in a referendum @@ -566,7 +566,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { /// Weight: see `begin_block` - fn on_initialize(n: T::BlockNumber) -> Weight { + fn on_initialize(n: BlockNumberFor) -> Weight { Self::begin_block(n) } } @@ -776,8 +776,8 @@ pub mod pallet { pub fn fast_track( origin: OriginFor, proposal_hash: H256, - voting_period: T::BlockNumber, - delay: T::BlockNumber, + voting_period: BlockNumberFor, + delay: BlockNumberFor, ) -> DispatchResult { // Rather complicated bit of code to ensure that either: // - `voting_period` is at least `FastTrackVotingPeriod` and `origin` is @@ -795,7 +795,7 @@ pub mod pallet { ensure!(T::InstantAllowed::get(), Error::::InstantNotAllowed); } - ensure!(voting_period > T::BlockNumber::zero(), Error::::VotingPeriodLow); + ensure!(voting_period > Zero::zero(), Error::::VotingPeriodLow); let (ext_proposal, threshold) = >::get().ok_or(Error::::ProposalMissing)?; ensure!( @@ -1048,7 +1048,8 @@ pub mod pallet { T::BlacklistOrigin::ensure_origin(origin)?; // Insert the proposal into the blacklist. - let permanent = (T::BlockNumber::max_value(), BoundedVec::::default()); + let permanent = + (BlockNumberFor::::max_value(), BoundedVec::::default()); Blacklist::::insert(&proposal_hash, permanent); // Remove the queued proposal, if it's there. @@ -1201,17 +1202,19 @@ impl Pallet { /// Get all referenda ready for tally at block `n`. pub fn maturing_referenda_at( - n: T::BlockNumber, - ) -> Vec<(ReferendumIndex, ReferendumStatus, BalanceOf>)> { + n: BlockNumberFor, + ) -> Vec<(ReferendumIndex, ReferendumStatus, BoundedCallOf, BalanceOf>)> + { let next = Self::lowest_unbaked(); let last = Self::referendum_count(); Self::maturing_referenda_at_inner(n, next..last) } fn maturing_referenda_at_inner( - n: T::BlockNumber, + n: BlockNumberFor, range: core::ops::Range, - ) -> Vec<(ReferendumIndex, ReferendumStatus, BalanceOf>)> { + ) -> Vec<(ReferendumIndex, ReferendumStatus, BoundedCallOf, BalanceOf>)> + { range .into_iter() .map(|i| (i, Self::referendum_info(i))) @@ -1229,7 +1232,7 @@ impl Pallet { pub fn internal_start_referendum( proposal: BoundedCallOf, threshold: VoteThreshold, - delay: T::BlockNumber, + delay: BlockNumberFor, ) -> ReferendumIndex { >::inject_referendum( >::block_number().saturating_add(T::VotingPeriod::get()), @@ -1250,8 +1253,9 @@ impl Pallet { /// Ok if the given referendum is active, Err otherwise fn ensure_ongoing( - r: ReferendumInfo, BalanceOf>, - ) -> Result, BalanceOf>, DispatchError> { + r: ReferendumInfo, BoundedCallOf, BalanceOf>, + ) -> Result, BoundedCallOf, BalanceOf>, DispatchError> + { match r { ReferendumInfo::Ongoing(s) => Ok(s), _ => Err(Error::::ReferendumInvalid.into()), @@ -1260,7 +1264,8 @@ impl Pallet { fn referendum_status( ref_index: ReferendumIndex, - ) -> Result, BalanceOf>, DispatchError> { + ) -> Result, BoundedCallOf, BalanceOf>, DispatchError> + { let info = ReferendumInfoOf::::get(ref_index).ok_or(Error::::ReferendumInvalid)?; Self::ensure_ongoing(info) } @@ -1515,10 +1520,10 @@ impl Pallet { /// Start a referendum fn inject_referendum( - end: T::BlockNumber, + end: BlockNumberFor, proposal: BoundedCallOf, threshold: VoteThreshold, - delay: T::BlockNumber, + delay: BlockNumberFor, ) -> ReferendumIndex { let ref_index = Self::referendum_count(); ReferendumCount::::put(ref_index + 1); @@ -1531,7 +1536,7 @@ impl Pallet { } /// Table the next waiting proposal for a vote. - fn launch_next(now: T::BlockNumber) -> DispatchResult { + fn launch_next(now: BlockNumberFor) -> DispatchResult { if LastTabledWasExternal::::take() { Self::launch_public(now).or_else(|_| Self::launch_external(now)) } else { @@ -1541,7 +1546,7 @@ impl Pallet { } /// Table the waiting external proposal for a vote, if there is one. - fn launch_external(now: T::BlockNumber) -> DispatchResult { + fn launch_external(now: BlockNumberFor) -> DispatchResult { if let Some((proposal, threshold)) = >::take() { LastTabledWasExternal::::put(true); Self::deposit_event(Event::::ExternalTabled); @@ -1559,7 +1564,7 @@ impl Pallet { } /// Table the waiting public proposal with the highest backing for a vote. - fn launch_public(now: T::BlockNumber) -> DispatchResult { + fn launch_public(now: BlockNumberFor) -> DispatchResult { let mut public_props = Self::public_props(); if let Some((winner_index, _)) = public_props.iter().enumerate().max_by_key( // defensive only: All current public proposals have an amount locked @@ -1592,9 +1597,9 @@ impl Pallet { } fn bake_referendum( - now: T::BlockNumber, + now: BlockNumberFor, index: ReferendumIndex, - status: ReferendumStatus, BalanceOf>, + status: ReferendumStatus, BoundedCallOf, BalanceOf>, ) -> bool { let total_issuance = T::Currency::total_issuance(); let approved = status.threshold.approved(status.tally, total_issuance); @@ -1629,7 +1634,7 @@ impl Pallet { /// ## Complexity: /// If a referendum is launched or maturing, this will take full block weight if queue is not /// empty. Otherwise, `O(R)` where `R` is the number of unbaked referenda. - fn begin_block(now: T::BlockNumber) -> Weight { + fn begin_block(now: BlockNumberFor) -> Weight { let max_block_weight = T::BlockWeights::get().max_block; let mut weight = Weight::zero(); diff --git a/frame/democracy/src/migrations/v1.rs b/frame/democracy/src/migrations/v1.rs index f3d29511ff659..27a500a615cff 100644 --- a/frame/democracy/src/migrations/v1.rs +++ b/frame/democracy/src/migrations/v1.rs @@ -19,6 +19,7 @@ use crate::*; use frame_support::{pallet_prelude::*, storage_alias, traits::OnRuntimeUpgrade, BoundedVec}; +use frame_system::pallet_prelude::BlockNumberFor; use sp_core::H256; /// The log target. @@ -45,11 +46,7 @@ mod v0 { Pallet, frame_support::Twox64Concat, ReferendumIndex, - ReferendumInfo< - ::BlockNumber, - ::Hash, - BalanceOf, - >, + ReferendumInfo, ::Hash, BalanceOf>, >; } @@ -87,7 +84,7 @@ pub mod v1 { } ReferendumInfoOf::::translate( - |index, old: ReferendumInfo>| { + |index, old: ReferendumInfo, T::Hash, BalanceOf>| { weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1)); log::info!(target: TARGET, "migrating referendum #{:?}", &index); Some(match old { diff --git a/frame/democracy/src/tests.rs b/frame/democracy/src/tests.rs index dedd13dd33227..0339b46d03a9f 100644 --- a/frame/democracy/src/tests.rs +++ b/frame/democracy/src/tests.rs @@ -31,7 +31,6 @@ use frame_system::{EnsureRoot, EnsureSigned, EnsureSignedBy}; use pallet_balances::{BalanceLock, Error as BalancesError}; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BadOrigin, BlakeTwo256, Hash, IdentityLookup}, BuildStorage, Perbill, }; @@ -51,14 +50,10 @@ const NAY: Vote = Vote { aye: false, conviction: Conviction::None }; const BIG_AYE: Vote = Vote { aye: true, conviction: Conviction::Locked1x }; const BIG_NAY: Vote = Vote { aye: false, conviction: Conviction::Locked1x }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -89,13 +84,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/election-provider-multi-phase/src/benchmarking.rs b/frame/election-provider-multi-phase/src/benchmarking.rs index a5946c6a1d3c1..1284d0b873ea6 100644 --- a/frame/election-provider-multi-phase/src/benchmarking.rs +++ b/frame/election-provider-multi-phase/src/benchmarking.rs @@ -313,7 +313,7 @@ frame_benchmarking::benchmarks! { assert!(>::get().is_none()); assert!(>::get().is_none()); assert!(>::get().is_none()); - assert_eq!(>::get(), >::Off); + assert_eq!(>::get(), >>::Off); } submit { diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index 1960c458b983e..03ab5574a2180 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -241,7 +241,7 @@ use frame_support::{ weights::Weight, DefaultNoBound, EqNoBound, PartialEqNoBound, }; -use frame_system::{ensure_none, offchain::SendTransactionTypes}; +use frame_system::{ensure_none, offchain::SendTransactionTypes, pallet_prelude::BlockNumberFor}; use scale_info::TypeInfo; use sp_arithmetic::{ traits::{CheckedAdd, Zero}, @@ -585,10 +585,10 @@ pub mod pallet { /// Duration of the unsigned phase. #[pallet::constant] - type UnsignedPhase: Get; + type UnsignedPhase: Get>; /// Duration of the signed phase. #[pallet::constant] - type SignedPhase: Get; + type SignedPhase: Get>; /// The minimum amount of improvement to the solution score that defines a solution as /// "better" in the Signed phase. @@ -605,7 +605,7 @@ pub mod pallet { /// For example, if it is 5, that means that at least 5 blocks will elapse between attempts /// to submit the worker's solution. #[pallet::constant] - type OffchainRepeat: Get; + type OffchainRepeat: Get>; /// The priority of the unsigned transaction submitted in the unsigned-phase #[pallet::constant] @@ -685,13 +685,13 @@ pub mod pallet { /// Something that will provide the election data. type DataProvider: ElectionDataProvider< AccountId = Self::AccountId, - BlockNumber = Self::BlockNumber, + BlockNumber = BlockNumberFor, >; /// Configuration for the fallback. type Fallback: InstantElectionProvider< AccountId = Self::AccountId, - BlockNumber = Self::BlockNumber, + BlockNumber = BlockNumberFor, DataProvider = Self::DataProvider, MaxWinners = Self::MaxWinners, >; @@ -702,7 +702,7 @@ pub mod pallet { /// BoundedExecution<_>` if the test-net is not expected to have thousands of nominators. type GovernanceFallback: InstantElectionProvider< AccountId = Self::AccountId, - BlockNumber = Self::BlockNumber, + BlockNumber = BlockNumberFor, DataProvider = Self::DataProvider, MaxWinners = Self::MaxWinners, >; @@ -747,7 +747,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(now: T::BlockNumber) -> Weight { + fn on_initialize(now: BlockNumberFor) -> Weight { let next_election = T::DataProvider::next_election_prediction(now).max(now); let signed_deadline = T::SignedPhase::get() + T::UnsignedPhase::get(); @@ -824,7 +824,7 @@ pub mod pallet { } } - fn offchain_worker(now: T::BlockNumber) { + fn offchain_worker(now: BlockNumberFor) { use sp_runtime::offchain::storage_lock::{BlockAndTime, StorageLock}; // Create a lock with the maximum deadline of number of blocks in the unsigned phase. @@ -886,7 +886,7 @@ pub mod pallet { } #[cfg(feature = "try-runtime")] - fn try_state(_n: T::BlockNumber) -> Result<(), TryRuntimeError> { + fn try_state(_n: BlockNumberFor) -> Result<(), TryRuntimeError> { Self::do_try_state() } } @@ -1155,7 +1155,11 @@ pub mod pallet { /// An account has been slashed for submitting an invalid signed submission. Slashed { account: ::AccountId, value: BalanceOf }, /// There was a phase transition in a given round. - PhaseTransitioned { from: Phase, to: Phase, round: u32 }, + PhaseTransitioned { + from: Phase>, + to: Phase>, + round: u32, + }, } /// Error of the pallet that can be returned in response to dispatches. @@ -1257,7 +1261,7 @@ pub mod pallet { /// Current phase. #[pallet::storage] #[pallet::getter(fn current_phase)] - pub type CurrentPhase = StorageValue<_, Phase, ValueQuery>; + pub type CurrentPhase = StorageValue<_, Phase>, ValueQuery>; /// Current best solution, signed or unsigned, queued to be returned upon `elect`. /// @@ -1349,7 +1353,7 @@ pub mod pallet { impl Pallet { /// Internal logic of the offchain worker, to be executed only when the offchain lock is /// acquired with success. - fn do_synchronized_offchain_worker(now: T::BlockNumber) { + fn do_synchronized_offchain_worker(now: BlockNumberFor) { let current_phase = Self::current_phase(); log!(trace, "lock for offchain worker acquired. Phase = {:?}", current_phase); match current_phase { @@ -1375,7 +1379,7 @@ impl Pallet { } /// Phase transition helper. - pub(crate) fn phase_transition(to: Phase) { + pub(crate) fn phase_transition(to: Phase>) { log!(info, "Starting phase {:?}, round {}.", to, Self::round()); Self::deposit_event(Event::PhaseTransitioned { from: >::get(), @@ -1672,7 +1676,7 @@ impl Pallet { impl ElectionProviderBase for Pallet { type AccountId = T::AccountId; - type BlockNumber = T::BlockNumber; + type BlockNumber = BlockNumberFor; type Error = ElectionError; type MaxWinners = T::MaxWinners; type DataProvider = T::DataProvider; diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 6a02e26b27ab3..5dfb7f7744f4f 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -54,10 +54,7 @@ pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system::{Pallet, Call, Event, Config}, Balances: pallet_balances::{Pallet, Call, Event, Config}, @@ -212,13 +209,12 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = BlockNumber; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type DbWeight = (); @@ -322,8 +318,8 @@ impl onchain::Config for OnChainSeqPhragmen { pub struct MockFallback; impl ElectionProviderBase for MockFallback { + type BlockNumber = BlockNumber; type AccountId = AccountId; - type BlockNumber = u64; type Error = &'static str; type DataProvider = StakingMock; type MaxWinners = MaxWinners; @@ -436,8 +432,8 @@ pub struct ExtBuilder {} pub struct StakingMock; impl ElectionDataProvider for StakingMock { + type BlockNumber = BlockNumber; type AccountId = AccountId; - type BlockNumber = u64; type MaxVotesPerVoter = MaxNominations; fn electable_targets(maybe_max_len: Option) -> data_provider::Result> { diff --git a/frame/election-provider-multi-phase/src/signed.rs b/frame/election-provider-multi-phase/src/signed.rs index bde985518d53e..226404e4afc1a 100644 --- a/frame/election-provider-multi-phase/src/signed.rs +++ b/frame/election-provider-multi-phase/src/signed.rs @@ -27,6 +27,7 @@ use frame_election_provider_support::NposSolution; use frame_support::traits::{ defensive_prelude::*, Currency, Get, OnUnbalanced, ReservableCurrency, }; +use frame_system::pallet_prelude::BlockNumberFor; use sp_arithmetic::traits::SaturatedConversion; use sp_core::bounded::BoundedVec; use sp_npos_elections::ElectionScore; @@ -100,10 +101,8 @@ pub type SignedSubmissionOf = SignedSubmission< /// Always sorted vector of a score, submitted at the given block number, which can be found at the /// given index (`u32`) of the `SignedSubmissionsMap`. -pub type SubmissionIndicesOf = BoundedVec< - (ElectionScore, ::BlockNumber, u32), - ::SignedMaxSubmissions, ->; +pub type SubmissionIndicesOf = + BoundedVec<(ElectionScore, BlockNumberFor, u32), ::SignedMaxSubmissions>; /// Outcome of [`SignedSubmissions::insert`]. pub enum InsertResult { @@ -216,7 +215,7 @@ impl SignedSubmissions { fn swap_out_submission( &mut self, remove_pos: usize, - insert: Option<(ElectionScore, T::BlockNumber, u32)>, + insert: Option<(ElectionScore, BlockNumberFor, u32)>, ) -> Option> { if remove_pos >= self.indices.len() { return None diff --git a/frame/election-provider-multi-phase/src/unsigned.rs b/frame/election-provider-multi-phase/src/unsigned.rs index 9c09cb48c7c05..e21e6c5e6d229 100644 --- a/frame/election-provider-multi-phase/src/unsigned.rs +++ b/frame/election-provider-multi-phase/src/unsigned.rs @@ -29,7 +29,7 @@ use frame_support::{ traits::{DefensiveResult, Get}, BoundedVec, }; -use frame_system::offchain::SubmitTransaction; +use frame_system::{offchain::SubmitTransaction, pallet_prelude::BlockNumberFor}; use scale_info::TypeInfo; use sp_npos_elections::{ assignment_ratio_to_staked_normalized, assignment_staked_to_ratio_normalized, ElectionResult, @@ -298,12 +298,12 @@ impl Pallet { /// /// Returns `Ok(())` if offchain worker limit is respected, `Err(reason)` otherwise. If `Ok()` /// is returned, `now` is written in storage and will be used in further calls as the baseline. - pub fn ensure_offchain_repeat_frequency(now: T::BlockNumber) -> Result<(), MinerError> { + pub fn ensure_offchain_repeat_frequency(now: BlockNumberFor) -> Result<(), MinerError> { let threshold = T::OffchainRepeat::get(); let last_block = StorageValueRef::persistent(OFFCHAIN_LAST_BLOCK); let mutate_stat = last_block.mutate::<_, &'static str, _>( - |maybe_head: Result, _>| { + |maybe_head: Result>, _>| { match maybe_head { Ok(Some(head)) if now < head => Err("fork."), Ok(Some(head)) if now >= head && now <= head + threshold => diff --git a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs index f41f8babd607c..85fafa25c4c8b 100644 --- a/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs +++ b/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs @@ -46,14 +46,11 @@ pub const INIT_TIMESTAMP: u64 = 30_000; pub const BLOCK_TIME: u64 = 1000; type Block = frame_system::mocking::MockBlock; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Extrinsic = testing::TestXt; frame_support::construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub enum Runtime { System: frame_system, ElectionProviderMultiPhase: pallet_election_provider_multi_phase, @@ -81,13 +78,12 @@ impl frame_system::Config for Runtime { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = AccountIndex; - type BlockNumber = BlockNumber; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); diff --git a/frame/election-provider-support/src/onchain.rs b/frame/election-provider-support/src/onchain.rs index a312562d4944c..4adcf99b3345a 100644 --- a/frame/election-provider-support/src/onchain.rs +++ b/frame/election-provider-support/src/onchain.rs @@ -73,7 +73,7 @@ pub trait Config { /// Something that provides the data for election. type DataProvider: ElectionDataProvider< AccountId = ::AccountId, - BlockNumber = ::BlockNumber, + BlockNumber = frame_system::pallet_prelude::BlockNumberFor, >; /// Weight information for extrinsics in this pallet. @@ -151,7 +151,7 @@ fn elect_with_input_bounds( impl ElectionProviderBase for OnChainExecution { type AccountId = ::AccountId; - type BlockNumber = ::BlockNumber; + type BlockNumber = frame_system::pallet_prelude::BlockNumberFor; type Error = Error; type MaxWinners = T::MaxWinners; type DataProvider = T::DataProvider; @@ -197,10 +197,7 @@ mod tests { pub type Block = sp_runtime::generic::Block; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system::{Pallet, Call, Event}, } @@ -211,13 +208,12 @@ mod tests { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = AccountId; - type BlockNumber = BlockNumber; type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = (); type BlockHashCount = (); type DbWeight = (); diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 501e50c6a7acc..55c16dfda995d 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -204,7 +204,7 @@ pub mod pallet { type PalletId: Get; /// The currency that people are electing with. - type Currency: LockableCurrency + type Currency: LockableCurrency> + ReservableCurrency; /// What to do when the members change. @@ -250,7 +250,7 @@ pub mod pallet { /// round will happen. If set to zero, no elections are ever triggered and the module will /// be in passive mode. #[pallet::constant] - type TermDuration: Get; + type TermDuration: Get>; /// The maximum number of candidates in a phragmen election. /// @@ -286,7 +286,7 @@ pub mod pallet { /// What to do at the end of each block. /// /// Checks if an election needs to happen or not. - fn on_initialize(n: T::BlockNumber) -> Weight { + fn on_initialize(n: BlockNumberFor) -> Weight { let term_duration = T::TermDuration::get(); if !term_duration.is_zero() && (n % term_duration).is_zero() { Self::do_phragmen() @@ -331,7 +331,7 @@ pub mod pallet { } #[cfg(feature = "try-runtime")] - fn try_state(_n: T::BlockNumber) -> Result<(), TryRuntimeError> { + fn try_state(_n: BlockNumberFor) -> Result<(), TryRuntimeError> { Self::do_try_state() } } @@ -1324,13 +1324,12 @@ mod tests { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); @@ -1447,10 +1446,7 @@ mod tests { sp_runtime::generic::UncheckedExtrinsic; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub enum Test { System: frame_system::{Pallet, Call, Event}, Balances: pallet_balances::{Pallet, Call, Event, Config}, diff --git a/frame/examples/basic/src/lib.rs b/frame/examples/basic/src/lib.rs index adb8e99c6d6a8..426e9b7ec648c 100644 --- a/frame/examples/basic/src/lib.rs +++ b/frame/examples/basic/src/lib.rs @@ -388,21 +388,21 @@ pub mod pallet { // dispatched. // // This function must return the weight consumed by `on_initialize` and `on_finalize`. - fn on_initialize(_n: T::BlockNumber) -> Weight { + fn on_initialize(_n: BlockNumberFor) -> Weight { // Anything that needs to be done at the start of the block. // We don't do anything here. Weight::zero() } // `on_finalize` is executed at the end of block after all extrinsic are dispatched. - fn on_finalize(_n: T::BlockNumber) { + fn on_finalize(_n: BlockNumberFor) { // Perform necessary data/state clean up here. } // A runtime code run after every block and have access to extended set of APIs. // // For instance you can generate extrinsics for the upcoming produced block. - fn offchain_worker(_n: T::BlockNumber) { + fn offchain_worker(_n: BlockNumberFor) { // We don't do anything here. // but we could dispatch extrinsic (transaction/unsigned/inherent) using // sp_io::submit_extrinsic. diff --git a/frame/examples/basic/src/tests.rs b/frame/examples/basic/src/tests.rs index ae985151e6665..14f4d64d5c68c 100644 --- a/frame/examples/basic/src/tests.rs +++ b/frame/examples/basic/src/tests.rs @@ -27,22 +27,17 @@ use sp_core::H256; // The testing primitives are very useful for avoiding having to work with signatures // or public keys. `u64` is used as the `AccountId` and no `Signature`s are required. use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; // Reexport crate as its pallet name for construct_runtime. use crate as pallet_example_basic; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; // For testing the pallet, we construct a mock runtime. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -57,13 +52,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/examples/default-config/src/lib.rs b/frame/examples/default-config/src/lib.rs index 5112f3d72d59e..a2c11e168fe27 100644 --- a/frame/examples/default-config/src/lib.rs +++ b/frame/examples/default-config/src/lib.rs @@ -107,17 +107,14 @@ pub mod pallet { pub mod tests { use super::*; use frame_support::derive_impl; + use sp_runtime::traits::ConstU64; use super::pallet as pallet_default_config_example; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, DefaultPallet: pallet_default_config_example, @@ -129,6 +126,8 @@ pub mod tests { // these items are defined by frame-system as `no_default`, so we must specify them here. // Note that these are types that actually rely on the outer runtime, and can't sensibly // have an _independent_ default. + type Block = Block; + type BlockHashCount = ConstU64<10>; type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; @@ -140,7 +139,9 @@ pub mod tests { // type Index = u32; // type BlockNumber = u32; - // type Header = sp_runtime::generic::Header; + // type Header = + // sp_runtime::generic::Header, + // Self::Hashing>; // type Hash = sp_core::hash::H256; // type Hashing = sp_runtime::traits::BlakeTwo256; // type AccountId = u64; diff --git a/frame/examples/dev-mode/src/tests.rs b/frame/examples/dev-mode/src/tests.rs index 95e02134eecc5..83f66f0031b83 100644 --- a/frame/examples/dev-mode/src/tests.rs +++ b/frame/examples/dev-mode/src/tests.rs @@ -21,22 +21,17 @@ use crate::*; use frame_support::{assert_ok, traits::ConstU64}; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; // Reexport crate as its pallet name for construct_runtime. use crate as pallet_dev_mode; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; // For testing the pallet, we construct a mock runtime. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -51,13 +46,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/examples/kitchensink/src/lib.rs b/frame/examples/kitchensink/src/lib.rs index c42c7b2ec62e8..0fbffc971da62 100644 --- a/frame/examples/kitchensink/src/lib.rs +++ b/frame/examples/kitchensink/src/lib.rs @@ -183,7 +183,7 @@ pub mod pallet { #[pallet::genesis_config] pub struct GenesisConfig { pub foo: u32, - pub bar: T::BlockNumber, + pub bar: BlockNumberFor, } impl Default for GenesisConfig { @@ -249,22 +249,22 @@ pub mod pallet { /// All the possible hooks that a pallet can have. See [`frame_support::traits::Hooks`] for more /// info. #[pallet::hooks] - impl Hooks for Pallet { + impl Hooks> for Pallet { fn integrity_test() {} - fn offchain_worker(_n: T::BlockNumber) { + fn offchain_worker(_n: BlockNumberFor) { unimplemented!() } - fn on_initialize(_n: T::BlockNumber) -> Weight { + fn on_initialize(_n: BlockNumberFor) -> Weight { unimplemented!() } - fn on_finalize(_n: T::BlockNumber) { + fn on_finalize(_n: BlockNumberFor) { unimplemented!() } - fn on_idle(_n: T::BlockNumber, _remaining_weight: Weight) -> Weight { + fn on_idle(_n: BlockNumberFor, _remaining_weight: Weight) -> Weight { unimplemented!() } @@ -283,7 +283,7 @@ pub mod pallet { } #[cfg(feature = "try-runtime")] - fn try_state(_n: T::BlockNumber) -> Result<(), TryRuntimeError> { + fn try_state(_n: BlockNumberFor) -> Result<(), TryRuntimeError> { unimplemented!() } } diff --git a/frame/examples/kitchensink/src/tests.rs b/frame/examples/kitchensink/src/tests.rs index a1af5bc6c5f1a..b2af7c8983f56 100644 --- a/frame/examples/kitchensink/src/tests.rs +++ b/frame/examples/kitchensink/src/tests.rs @@ -23,15 +23,11 @@ use sp_runtime::BuildStorage; // Reexport crate as its pallet name for construct_runtime. use crate as pallet_example_kitchensink; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; // For testing the pallet, we construct a mock runtime. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -44,6 +40,8 @@ frame_support::construct_runtime!( #[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; + type BlockHashCount = ConstU64<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; diff --git a/frame/examples/offchain-worker/src/lib.rs b/frame/examples/offchain-worker/src/lib.rs index 6ce8524174200..6c1fa6ea8ec42 100644 --- a/frame/examples/offchain-worker/src/lib.rs +++ b/frame/examples/offchain-worker/src/lib.rs @@ -53,6 +53,7 @@ use frame_system::{ AppCrypto, CreateSignedTransaction, SendSignedTransaction, SendUnsignedTransaction, SignedPayload, Signer, SigningTypes, SubmitTransaction, }, + pallet_prelude::BlockNumberFor, }; use lite_json::json::JsonValue; use sp_core::crypto::KeyTypeId; @@ -136,14 +137,14 @@ pub mod pallet { /// every `GRACE_PERIOD` blocks. We use Local Storage to coordinate /// sending between distinct runs of this offchain worker. #[pallet::constant] - type GracePeriod: Get; + type GracePeriod: Get>; /// Number of blocks of cooldown after unsigned transaction is included. /// /// This ensures that we only accept unsigned transactions once, every `UnsignedInterval` /// blocks. #[pallet::constant] - type UnsignedInterval: Get; + type UnsignedInterval: Get>; /// A configuration for base priority of unsigned transactions. /// @@ -171,7 +172,7 @@ pub mod pallet { /// be cases where some blocks are skipped, or for some the worker runs twice (re-orgs), /// so the code should be able to handle that. /// You can use `Local Storage` API to coordinate runs of the worker. - fn offchain_worker(block_number: T::BlockNumber) { + fn offchain_worker(block_number: BlockNumberFor) { // Note that having logs compiled to WASM may cause the size of the blob to increase // significantly. You can use `RuntimeDebug` custom derive to hide details of the types // in WASM. The `sp-api` crate also provides a feature `disable-logging` to disable @@ -258,7 +259,7 @@ pub mod pallet { #[pallet::weight({0})] pub fn submit_price_unsigned( origin: OriginFor, - _block_number: T::BlockNumber, + _block_number: BlockNumberFor, price: u32, ) -> DispatchResultWithPostInfo { // This ensures that the function can only be called via unsigned transaction. @@ -275,7 +276,7 @@ pub mod pallet { #[pallet::weight({0})] pub fn submit_price_unsigned_with_signed_payload( origin: OriginFor, - price_payload: PricePayload, + price_payload: PricePayload>, _signature: T::Signature, ) -> DispatchResultWithPostInfo { // This ensures that the function can only be called via unsigned transaction. @@ -341,7 +342,7 @@ pub mod pallet { /// This storage entry defines when new transaction is going to be accepted. #[pallet::storage] #[pallet::getter(fn next_unsigned_at)] - pub(super) type NextUnsignedAt = StorageValue<_, T::BlockNumber, ValueQuery>; + pub(super) type NextUnsignedAt = StorageValue<_, BlockNumberFor, ValueQuery>; } /// Payload used by this example crate to hold price @@ -353,7 +354,7 @@ pub struct PricePayload { public: Public, } -impl SignedPayload for PricePayload { +impl SignedPayload for PricePayload> { fn public(&self) -> T::Public { self.public.clone() } @@ -374,7 +375,7 @@ impl Pallet { /// and local storage usage. /// /// Returns a type of transaction that should be produced in current run. - fn choose_transaction_type(block_number: T::BlockNumber) -> TransactionType { + fn choose_transaction_type(block_number: BlockNumberFor) -> TransactionType { /// A friendlier name for the error that is going to be returned in case we are in the grace /// period. const RECENTLY_SENT: () = (); @@ -389,16 +390,17 @@ impl Pallet { // low-level method of local storage API, which means that only one worker // will be able to "acquire a lock" and send a transaction if multiple workers // happen to be executed concurrently. - let res = val.mutate(|last_send: Result, StorageRetrievalError>| { - match last_send { - // If we already have a value in storage and the block number is recent enough - // we avoid sending another transaction at this time. - Ok(Some(block)) if block_number < block + T::GracePeriod::get() => - Err(RECENTLY_SENT), - // In every other case we attempt to acquire the lock and send a transaction. - _ => Ok(block_number), - } - }); + let res = + val.mutate(|last_send: Result>, StorageRetrievalError>| { + match last_send { + // If we already have a value in storage and the block number is recent enough + // we avoid sending another transaction at this time. + Ok(Some(block)) if block_number < block + T::GracePeriod::get() => + Err(RECENTLY_SENT), + // In every other case we attempt to acquire the lock and send a transaction. + _ => Ok(block_number), + } + }); // The result of `mutate` call will give us a nested `Result` type. // The first one matches the return of the closure passed to `mutate`, i.e. @@ -419,9 +421,9 @@ impl Pallet { let transaction_type = block_number % 4u32.into(); if transaction_type == Zero::zero() { TransactionType::Signed - } else if transaction_type == T::BlockNumber::from(1u32) { + } else if transaction_type == BlockNumberFor::::from(1u32) { TransactionType::UnsignedForAny - } else if transaction_type == T::BlockNumber::from(2u32) { + } else if transaction_type == BlockNumberFor::::from(2u32) { TransactionType::UnsignedForAll } else { TransactionType::Raw @@ -472,7 +474,9 @@ impl Pallet { } /// A helper function to fetch the price and send a raw unsigned transaction. - fn fetch_price_and_send_raw_unsigned(block_number: T::BlockNumber) -> Result<(), &'static str> { + fn fetch_price_and_send_raw_unsigned( + block_number: BlockNumberFor, + ) -> Result<(), &'static str> { // Make sure we don't fetch the price if unsigned transaction is going to be rejected // anyway. let next_unsigned_at = >::get(); @@ -505,7 +509,7 @@ impl Pallet { /// A helper function to fetch the price, sign payload and send an unsigned transaction fn fetch_price_and_send_unsigned_for_any_account( - block_number: T::BlockNumber, + block_number: BlockNumberFor, ) -> Result<(), &'static str> { // Make sure we don't fetch the price if unsigned transaction is going to be rejected // anyway. @@ -535,7 +539,7 @@ impl Pallet { /// A helper function to fetch the price, sign payload and send an unsigned transaction fn fetch_price_and_send_unsigned_for_all_accounts( - block_number: T::BlockNumber, + block_number: BlockNumberFor, ) -> Result<(), &'static str> { // Make sure we don't fetch the price if unsigned transaction is going to be rejected // anyway. @@ -669,7 +673,7 @@ impl Pallet { } fn validate_transaction_parameters( - block_number: &T::BlockNumber, + block_number: &BlockNumberFor, new_price: &u32, ) -> TransactionValidity { // Now let's check if the transaction has any chance to succeed. diff --git a/frame/examples/offchain-worker/src/tests.rs b/frame/examples/offchain-worker/src/tests.rs index c0ff46bafcdcc..84d9c3f972891 100644 --- a/frame/examples/offchain-worker/src/tests.rs +++ b/frame/examples/offchain-worker/src/tests.rs @@ -30,20 +30,16 @@ use sp_core::{ use sp_keystore::{testing::MemoryKeystore, Keystore, KeystoreExt}; use sp_runtime::{ - testing::{Header, TestXt}, + testing::TestXt, traits::{BlakeTwo256, Extrinsic as ExtrinsicT, IdentifyAccount, IdentityLookup, Verify}, RuntimeAppPublic, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; // For testing the module, we construct a mock runtime. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Example: example_offchain_worker::{Pallet, Call, Storage, Event, ValidateUnsigned}, @@ -58,12 +54,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = sp_core::sr25519::Public; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); @@ -274,7 +269,7 @@ fn should_submit_unsigned_transaction_on_chain_for_any_account() { let signature_valid = ::Public, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, > as SignedPayload>::verify::(&price_payload, signature); assert!(signature_valid); @@ -328,7 +323,7 @@ fn should_submit_unsigned_transaction_on_chain_for_all_accounts() { let signature_valid = ::Public, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, > as SignedPayload>::verify::(&price_payload, signature); assert!(signature_valid); diff --git a/frame/examples/split/src/mock.rs b/frame/examples/split/src/mock.rs index 2e117977c1418..bee3633ef68f2 100644 --- a/frame/examples/split/src/mock.rs +++ b/frame/examples/split/src/mock.rs @@ -17,16 +17,13 @@ use crate as pallet_template; use frame_support::{derive_impl, sp_runtime::BuildStorage}; +use sp_core::ConstU64; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, TemplatePallet: pallet_template, @@ -37,6 +34,8 @@ frame_support::construct_runtime!( /// details. #[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] impl frame_system::Config for Test { + type Block = Block; + type BlockHashCount = ConstU64<10>; type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 61daed626b040..f758cfc841d61 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -126,6 +126,7 @@ use frame_support::{ }, weights::Weight, }; +use frame_system::pallet_prelude::BlockNumberFor; use sp_runtime::{ generic::Digest, traits::{ @@ -178,14 +179,17 @@ pub struct Executive< impl< System: frame_system::Config + EnsureInherentsAreFirst, - Block: traits::Block
, + Block: traits::Block< + Header = frame_system::pallet_prelude::HeaderFor, + Hash = System::Hash, + >, Context: Default, UnsignedValidator, AllPalletsWithSystem: OnRuntimeUpgrade - + OnInitialize - + OnIdle - + OnFinalize - + OffchainWorker, + + OnInitialize> + + OnIdle> + + OnFinalize> + + OffchainWorker>, COnRuntimeUpgrade: OnRuntimeUpgrade, > ExecuteBlock for Executive @@ -212,15 +216,18 @@ where #[cfg(feature = "try-runtime")] impl< System: frame_system::Config + EnsureInherentsAreFirst, - Block: traits::Block
, + Block: traits::Block< + Header = frame_system::pallet_prelude::HeaderFor, + Hash = System::Hash, + >, Context: Default, UnsignedValidator, AllPalletsWithSystem: OnRuntimeUpgrade - + OnInitialize - + OnIdle - + OnFinalize - + OffchainWorker - + frame_support::traits::TryState, + + OnInitialize> + + OnIdle> + + OnFinalize> + + OffchainWorker> + + frame_support::traits::TryState>, COnRuntimeUpgrade: OnRuntimeUpgrade, > Executive where @@ -297,10 +304,9 @@ where // run the try-state checks of all pallets, ensuring they don't alter any state. let _guard = frame_support::StorageNoopGuard::default(); - >::try_state( - *header.number(), - select, - ) + , + >>::try_state(*header.number(), select) .map_err(|e| { frame_support::log::error!(target: LOG_TARGET, "failure: {:?}", e); e @@ -350,7 +356,9 @@ where ) -> Result { if checks.try_state() { let _guard = frame_support::StorageNoopGuard::default(); - >::try_state( + , + >>::try_state( frame_system::Pallet::::block_number(), frame_try_runtime::TryStateSelect::All, )?; @@ -363,7 +371,9 @@ where if checks.try_state() { let _guard = frame_support::StorageNoopGuard::default(); - >::try_state( + , + >>::try_state( frame_system::Pallet::::block_number(), frame_try_runtime::TryStateSelect::All, )?; @@ -375,14 +385,17 @@ where impl< System: frame_system::Config + EnsureInherentsAreFirst, - Block: traits::Block
, + Block: traits::Block< + Header = frame_system::pallet_prelude::HeaderFor, + Hash = System::Hash, + >, Context: Default, UnsignedValidator, AllPalletsWithSystem: OnRuntimeUpgrade - + OnInitialize - + OnIdle - + OnFinalize - + OffchainWorker, + + OnInitialize> + + OnIdle> + + OnFinalize> + + OffchainWorker>, COnRuntimeUpgrade: OnRuntimeUpgrade, > Executive where @@ -399,14 +412,14 @@ where } /// Start the execution of a particular block. - pub fn initialize_block(header: &System::Header) { + pub fn initialize_block(header: &frame_system::pallet_prelude::HeaderFor) { sp_io::init_tracing(); sp_tracing::enter_span!(sp_tracing::Level::TRACE, "init_block"); let digests = Self::extract_pre_digest(header); Self::initialize_block_impl(header.number(), header.parent_hash(), &digests); } - fn extract_pre_digest(header: &System::Header) -> Digest { + fn extract_pre_digest(header: &frame_system::pallet_prelude::HeaderFor) -> Digest { let mut digest = ::default(); header.digest().logs().iter().for_each(|d| { if d.as_pre_runtime().is_some() { @@ -417,7 +430,7 @@ where } fn initialize_block_impl( - block_number: &System::BlockNumber, + block_number: &BlockNumberFor, parent_hash: &System::Hash, digest: &Digest, ) { @@ -432,7 +445,7 @@ where } >::initialize(block_number, parent_hash, digest); weight = weight.saturating_add(, >>::on_initialize(*block_number)); weight = weight.saturating_add( >::get().base_block, @@ -467,8 +480,8 @@ where // Check that `parent_hash` is correct. let n = *header.number(); assert!( - n > System::BlockNumber::zero() && - >::block_hash(n - System::BlockNumber::one()) == + n > BlockNumberFor::::zero() && + >::block_hash(n - BlockNumberFor::::one()) == *header.parent_hash(), "Parent hash should be valid.", ); @@ -518,7 +531,7 @@ where /// Finalize the block - it is up the caller to ensure that all header fields are valid /// except state-root. - pub fn finalize_block() -> System::Header { + pub fn finalize_block() -> frame_system::pallet_prelude::HeaderFor { sp_io::init_tracing(); sp_tracing::enter_span!(sp_tracing::Level::TRACE, "finalize_block"); >::note_finished_extrinsics(); @@ -535,7 +548,7 @@ where let remaining_weight = max_weight.saturating_sub(weight.total()); if remaining_weight.all_gt(Weight::zero()) { - let used_weight = >::on_idle( + let used_weight = >>::on_idle( block_number, remaining_weight, ); @@ -545,7 +558,7 @@ where ); } - >::on_finalize(block_number); + >>::on_finalize(block_number); } /// Apply extrinsic outside of the block execution function. @@ -585,7 +598,7 @@ where Ok(r.map(|_| ()).map_err(|e| e.error)) } - fn final_checks(header: &System::Header) { + fn final_checks(header: &frame_system::pallet_prelude::HeaderFor) { sp_tracing::enter_span!(sp_tracing::Level::TRACE, "final_checks"); // remove temporaries let new_header = >::finalize(); @@ -657,7 +670,7 @@ where } /// Start an offchain worker and generate extrinsics. - pub fn offchain_worker(header: &System::Header) { + pub fn offchain_worker(header: &frame_system::pallet_prelude::HeaderFor) { sp_io::init_tracing(); // We need to keep events available for offchain workers, // hence we initialize the block manually. @@ -671,7 +684,7 @@ where // as well. frame_system::BlockHash::::insert(header.number(), header.hash()); - >::offchain_worker( + >>::offchain_worker( *header.number(), ) } @@ -718,17 +731,17 @@ mod tests { impl Hooks> for Pallet { // module hooks. // one with block number arg and one without - fn on_initialize(n: T::BlockNumber) -> Weight { + fn on_initialize(n: BlockNumberFor) -> Weight { println!("on_initialize({})", n); Weight::from_parts(175, 0) } - fn on_idle(n: T::BlockNumber, remaining_weight: Weight) -> Weight { + fn on_idle(n: BlockNumberFor, remaining_weight: Weight) -> Weight { println!("on_idle{}, {})", n, remaining_weight); Weight::from_parts(175, 0) } - fn on_finalize(n: T::BlockNumber) { + fn on_finalize(n: BlockNumberFor) { println!("on_finalize({})", n); } @@ -737,8 +750,8 @@ mod tests { Weight::from_parts(200, 0) } - fn offchain_worker(n: T::BlockNumber) { - assert_eq!(T::BlockNumber::from(1u32), n); + fn offchain_worker(n: BlockNumberFor) { + assert_eq!(BlockNumberFor::::from(1u32), n); } } @@ -828,10 +841,7 @@ mod tests { } frame_support::construct_runtime!( - pub struct Runtime where - Block = TestBlock, - NodeBlock = TestBlock, - UncheckedExtrinsic = TestUncheckedExtrinsic + pub struct Runtime { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -860,12 +870,11 @@ mod tests { type RuntimeOrigin = RuntimeOrigin; type Index = u64; type RuntimeCall = RuntimeCall; - type BlockNumber = u64; type Hash = sp_core::H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = TestBlock; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = RuntimeVersion; @@ -929,7 +938,6 @@ mod tests { ); type TestXt = sp_runtime::testing::TestXt; type TestBlock = Block; - type TestUncheckedExtrinsic = TestXt; // Will contain `true` when the custom runtime logic was called. const CUSTOM_ON_RUNTIME_KEY: &[u8] = b":custom:on_runtime"; diff --git a/frame/fast-unstake/src/lib.rs b/frame/fast-unstake/src/lib.rs index 99742dbb75ae5..7620b61111cdb 100644 --- a/frame/fast-unstake/src/lib.rs +++ b/frame/fast-unstake/src/lib.rs @@ -272,8 +272,8 @@ pub mod pallet { } #[pallet::hooks] - impl Hooks for Pallet { - fn on_idle(_: T::BlockNumber, remaining_weight: Weight) -> Weight { + impl Hooks> for Pallet { + fn on_idle(_: BlockNumberFor, remaining_weight: Weight) -> Weight { if remaining_weight.any_lt(T::DbWeight::get().reads(2)) { return Weight::from_parts(0, 0) } @@ -295,7 +295,7 @@ pub mod pallet { } #[cfg(feature = "try-runtime")] - fn try_state(_n: T::BlockNumber) -> Result<(), TryRuntimeError> { + fn try_state(_n: BlockNumberFor) -> Result<(), TryRuntimeError> { // ensure that the value of `ErasToCheckPerBlock` is less than // `T::MaxErasToCheckPerBlock`. ensure!( diff --git a/frame/fast-unstake/src/mock.rs b/frame/fast-unstake/src/mock.rs index 881f3f0645571..b78d0e84dad29 100644 --- a/frame/fast-unstake/src/mock.rs +++ b/frame/fast-unstake/src/mock.rs @@ -51,13 +51,12 @@ impl frame_system::Config for Runtime { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = AccountIndex; - type BlockNumber = BlockNumber; type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); @@ -198,14 +197,9 @@ impl fast_unstake::Config for Runtime { } type Block = frame_system::mocking::MockBlock; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + frame_support::construct_runtime!( - pub struct Runtime - where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { + pub struct Runtime { System: frame_system, Timestamp: pallet_timestamp, Balances: pallet_balances, diff --git a/frame/glutton/src/mock.rs b/frame/glutton/src/mock.rs index 01fdc1e46a252..b05d25ab62a3e 100644 --- a/frame/glutton/src/mock.rs +++ b/frame/glutton/src/mock.rs @@ -24,19 +24,14 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Glutton: pallet_glutton::{Pallet, Event}, @@ -50,13 +45,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/grandpa/src/equivocation.rs b/frame/grandpa/src/equivocation.rs index 5cc5cd9bd3d70..16727f79a58d5 100644 --- a/frame/grandpa/src/equivocation.rs +++ b/frame/grandpa/src/equivocation.rs @@ -37,6 +37,7 @@ use codec::{self as codec, Decode, Encode}; use frame_support::traits::{Get, KeyOwnerProofSystem}; +use frame_system::pallet_prelude::BlockNumberFor; use log::{error, info}; use sp_consensus_grandpa::{AuthorityId, EquivocationProof, RoundNumber, SetId, KEY_TYPE}; use sp_runtime::{ @@ -118,7 +119,7 @@ pub struct EquivocationReportSystem(sp_std::marker::PhantomData<(T, impl OffenceReportSystem< Option, - (EquivocationProof, T::KeyOwnerProof), + (EquivocationProof>, T::KeyOwnerProof), > for EquivocationReportSystem where T: Config + pallet_authorship::Config + frame_system::offchain::SendTransactionTypes>, @@ -134,7 +135,7 @@ where type Longevity = L; fn publish_evidence( - evidence: (EquivocationProof, T::KeyOwnerProof), + evidence: (EquivocationProof>, T::KeyOwnerProof), ) -> Result<(), ()> { use frame_system::offchain::SubmitTransaction; let (equivocation_proof, key_owner_proof) = evidence; @@ -152,7 +153,7 @@ where } fn check_evidence( - evidence: (EquivocationProof, T::KeyOwnerProof), + evidence: (EquivocationProof>, T::KeyOwnerProof), ) -> Result<(), TransactionValidityError> { let (equivocation_proof, key_owner_proof) = evidence; @@ -172,7 +173,7 @@ where fn process_evidence( reporter: Option, - evidence: (EquivocationProof, T::KeyOwnerProof), + evidence: (EquivocationProof>, T::KeyOwnerProof), ) -> Result<(), DispatchError> { let (equivocation_proof, key_owner_proof) = evidence; let reporter = reporter.or_else(|| >::author()); diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index 3348fcce2ca80..204bcfa826b77 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -42,6 +42,7 @@ use frame_support::{ weights::Weight, WeakBoundedVec, }; +use frame_system::pallet_prelude::BlockNumberFor; use scale_info::TypeInfo; use sp_consensus_grandpa::{ ConsensusLog, EquivocationProof, ScheduledChange, SetId, GRANDPA_AUTHORITIES_KEY, @@ -113,13 +114,13 @@ pub mod pallet { /// (from an offchain context). type EquivocationReportSystem: OffenceReportSystem< Option, - (EquivocationProof, Self::KeyOwnerProof), + (EquivocationProof>, Self::KeyOwnerProof), >; } #[pallet::hooks] impl Hooks> for Pallet { - fn on_finalize(block_number: T::BlockNumber) { + fn on_finalize(block_number: BlockNumberFor) { // check for scheduled pending authority set changes if let Some(pending_change) = >::get() { // emit signal if we're at the block that scheduled the change @@ -191,7 +192,7 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::report_equivocation(key_owner_proof.validator_count()))] pub fn report_equivocation( origin: OriginFor, - equivocation_proof: Box>, + equivocation_proof: Box>>, key_owner_proof: T::KeyOwnerProof, ) -> DispatchResultWithPostInfo { let reporter = ensure_signed(origin)?; @@ -217,7 +218,7 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::report_equivocation(key_owner_proof.validator_count()))] pub fn report_equivocation_unsigned( origin: OriginFor, - equivocation_proof: Box>, + equivocation_proof: Box>>, key_owner_proof: T::KeyOwnerProof, ) -> DispatchResultWithPostInfo { ensure_none(origin)?; @@ -245,8 +246,8 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::note_stalled())] pub fn note_stalled( origin: OriginFor, - delay: T::BlockNumber, - best_finalized_block_number: T::BlockNumber, + delay: BlockNumberFor, + best_finalized_block_number: BlockNumberFor, ) -> DispatchResult { ensure_root(origin)?; @@ -287,7 +288,7 @@ pub mod pallet { } #[pallet::type_value] - pub(super) fn DefaultForState() -> StoredState { + pub(super) fn DefaultForState() -> StoredState> { StoredState::Live } @@ -295,23 +296,23 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn state)] pub(super) type State = - StorageValue<_, StoredState, ValueQuery, DefaultForState>; + StorageValue<_, StoredState>, ValueQuery, DefaultForState>; /// Pending change: (signaled at, scheduled change). #[pallet::storage] #[pallet::getter(fn pending_change)] pub(super) type PendingChange = - StorageValue<_, StoredPendingChange>; + StorageValue<_, StoredPendingChange, T::MaxAuthorities>>; /// next block number where we can force a change. #[pallet::storage] #[pallet::getter(fn next_forced)] - pub(super) type NextForced = StorageValue<_, T::BlockNumber>; + pub(super) type NextForced = StorageValue<_, BlockNumberFor>; /// `true` if we are currently stalled. #[pallet::storage] #[pallet::getter(fn stalled)] - pub(super) type Stalled = StorageValue<_, (T::BlockNumber, T::BlockNumber)>; + pub(super) type Stalled = StorageValue<_, (BlockNumberFor, BlockNumberFor)>; /// The number of changes (both in terms of keys and underlying economic responsibilities) /// in the "set" of Grandpa validators from genesis. @@ -429,7 +430,7 @@ impl Pallet { /// Schedule GRANDPA to pause starting in the given number of blocks. /// Cannot be done when already paused. - pub fn schedule_pause(in_blocks: T::BlockNumber) -> DispatchResult { + pub fn schedule_pause(in_blocks: BlockNumberFor) -> DispatchResult { if let StoredState::Live = >::get() { let scheduled_at = >::block_number(); >::put(StoredState::PendingPause { delay: in_blocks, scheduled_at }); @@ -441,7 +442,7 @@ impl Pallet { } /// Schedule a resume of GRANDPA after pausing. - pub fn schedule_resume(in_blocks: T::BlockNumber) -> DispatchResult { + pub fn schedule_resume(in_blocks: BlockNumberFor) -> DispatchResult { if let StoredState::Paused = >::get() { let scheduled_at = >::block_number(); >::put(StoredState::PendingResume { delay: in_blocks, scheduled_at }); @@ -468,8 +469,8 @@ impl Pallet { /// an error if a change is already pending. pub fn schedule_change( next_authorities: AuthorityList, - in_blocks: T::BlockNumber, - forced: Option, + in_blocks: BlockNumberFor, + forced: Option>, ) -> DispatchResult { if !>::exists() { let scheduled_at = >::block_number(); @@ -506,7 +507,7 @@ impl Pallet { } /// Deposit one of this module's logs. - fn deposit_log(log: ConsensusLog) { + fn deposit_log(log: ConsensusLog>) { let log = DigestItem::Consensus(GRANDPA_ENGINE_ID, log.encode()); >::deposit_log(log); } @@ -530,13 +531,13 @@ impl Pallet { /// will push the transaction to the pool. Only useful in an offchain /// context. pub fn submit_unsigned_equivocation_report( - equivocation_proof: EquivocationProof, + equivocation_proof: EquivocationProof>, key_owner_proof: T::KeyOwnerProof, ) -> Option<()> { T::EquivocationReportSystem::publish_evidence((equivocation_proof, key_owner_proof)).ok() } - fn on_stalled(further_wait: T::BlockNumber, median: T::BlockNumber) { + fn on_stalled(further_wait: BlockNumberFor, median: BlockNumberFor) { // when we record old authority sets we could try to figure out _who_ // failed. until then, we can't meaningfully guard against // `next == last` the way that normal session changes do. diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index d5a54a9fcfd51..47d07c73904b8 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -34,20 +34,16 @@ use sp_keyring::Ed25519Keyring; use sp_runtime::{ curve::PiecewiseLinear, impl_opaque_keys, - testing::{Header, TestXt, UintAuthorityId}, + testing::{TestXt, UintAuthorityId}, traits::{IdentityLookup, OpaqueKeys}, BuildStorage, DigestItem, Perbill, }; use sp_staking::{EraIndex, SessionIndex}; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Authorship: pallet_authorship, @@ -74,13 +70,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/identity/src/tests.rs b/frame/identity/src/tests.rs index 2c0352ac1cea5..57b372ef57912 100644 --- a/frame/identity/src/tests.rs +++ b/frame/identity/src/tests.rs @@ -29,19 +29,14 @@ use frame_support::{ use frame_system::{EnsureRoot, EnsureSignedBy}; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BadOrigin, BlakeTwo256, IdentityLookup}, BuildStorage, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -55,13 +50,12 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); diff --git a/frame/im-online/src/benchmarking.rs b/frame/im-online/src/benchmarking.rs index 4766e5edaadcf..d8170d4817e3e 100644 --- a/frame/im-online/src/benchmarking.rs +++ b/frame/im-online/src/benchmarking.rs @@ -36,7 +36,10 @@ const MAX_KEYS: u32 = 1000; pub fn create_heartbeat( k: u32, ) -> Result< - (crate::Heartbeat, ::Signature), + ( + crate::Heartbeat>, + ::Signature, + ), &'static str, > { let mut keys = Vec::new(); @@ -48,7 +51,7 @@ pub fn create_heartbeat( Keys::::put(bounded_keys); let input_heartbeat = Heartbeat { - block_number: T::BlockNumber::zero(), + block_number: frame_system::pallet_prelude::BlockNumberFor::::zero(), session_index: 0, authority_index: k - 1, validators_len: keys.len() as u32, diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index 23785c7b540c6..1de89dd00c812 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -245,7 +245,7 @@ pub type IdentificationTuple = ( >>::Identification, ); -type OffchainResult = Result::BlockNumber>>; +type OffchainResult = Result>>; #[frame_support::pallet] pub mod pallet { @@ -287,7 +287,7 @@ pub mod pallet { /// rough time when we should start considering sending heartbeats, since the workers /// avoids sending them at the very beginning of the session, assuming there is a /// chance the authority will produce a block and they won't be necessary. - type NextSessionRotation: EstimateNextSessionRotation; + type NextSessionRotation: EstimateNextSessionRotation>; /// A type that gives us the ability to submit unresponsiveness offence reports. type ReportUnresponsiveness: ReportOffence< @@ -339,7 +339,7 @@ pub mod pallet { /// more accurate then the value we calculate for `HeartbeatAfter`. #[pallet::storage] #[pallet::getter(fn heartbeat_after)] - pub(super) type HeartbeatAfter = StorageValue<_, T::BlockNumber, ValueQuery>; + pub(super) type HeartbeatAfter = StorageValue<_, BlockNumberFor, ValueQuery>; /// The current set of keys that may issue a heartbeat. #[pallet::storage] @@ -393,7 +393,7 @@ pub mod pallet { ))] pub fn heartbeat( origin: OriginFor, - heartbeat: Heartbeat, + heartbeat: Heartbeat>, // since signature verification is done in `validate_unsigned` // we can skip doing it here again. _signature: ::Signature, @@ -505,7 +505,7 @@ pub mod pallet { /// Keep track of number of authored blocks per authority, uncles are counted as /// well since they're a valid proof of being online. impl - pallet_authorship::EventHandler, T::BlockNumber> for Pallet + pallet_authorship::EventHandler, BlockNumberFor> for Pallet { fn note_author(author: ValidatorId) { Self::note_authorship(author); @@ -551,7 +551,7 @@ impl Pallet { } pub(crate) fn send_heartbeats( - block_number: T::BlockNumber, + block_number: BlockNumberFor, ) -> OffchainResult>> { const START_HEARTBEAT_RANDOM_PERIOD: Permill = Permill::from_percent(10); const START_HEARTBEAT_FINAL_PERIOD: Permill = Permill::from_percent(80); @@ -614,7 +614,7 @@ impl Pallet { authority_index: u32, key: T::AuthorityId, session_index: SessionIndex, - block_number: T::BlockNumber, + block_number: BlockNumberFor, validators_len: u32, ) -> OffchainResult { // A helper function to prepare heartbeat call. @@ -677,7 +677,7 @@ impl Pallet { fn with_heartbeat_lock( authority_index: u32, session_index: SessionIndex, - now: T::BlockNumber, + now: BlockNumberFor, f: impl FnOnce() -> OffchainResult, ) -> OffchainResult { let key = { @@ -687,7 +687,7 @@ impl Pallet { }; let storage = StorageValueRef::persistent(&key); let res = storage.mutate( - |status: Result>, StorageRetrievalError>| { + |status: Result>>, StorageRetrievalError>| { // Check if there is already a lock for that particular block. // This means that the heartbeat has already been sent, and we are just waiting // for it to be included. However if it doesn't get included for INCLUDE_THRESHOLD diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index 141df6569b2ec..6cc134c98ac6e 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -27,7 +27,7 @@ use frame_support::{ use pallet_session::historical as pallet_session_historical; use sp_core::H256; use sp_runtime::{ - testing::{Header, TestXt, UintAuthorityId}, + testing::{TestXt, UintAuthorityId}, traits::{BlakeTwo256, ConvertInto, IdentityLookup}, BuildStorage, Permill, }; @@ -39,14 +39,10 @@ use sp_staking::{ use crate as imonline; use crate::Config; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub struct Runtime { System: frame_system::{Pallet, Call, Config, Storage, Event}, Session: pallet_session::{Pallet, Call, Storage, Event, Config}, @@ -124,13 +120,12 @@ impl frame_system::Config for Runtime { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/indices/src/mock.rs b/frame/indices/src/mock.rs index c7784092cae4a..3e7d6240b1087 100644 --- a/frame/indices/src/mock.rs +++ b/frame/indices/src/mock.rs @@ -22,16 +22,12 @@ use crate::{self as pallet_indices, Config}; use frame_support::traits::{ConstU32, ConstU64}; use sp_core::H256; -use sp_runtime::{testing::Header, BuildStorage}; +use sp_runtime::BuildStorage; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -47,12 +43,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = Indices; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/insecure-randomness-collective-flip/src/lib.rs b/frame/insecure-randomness-collective-flip/src/lib.rs index 883c546f441c2..13dff14da7b9b 100644 --- a/frame/insecure-randomness-collective-flip/src/lib.rs +++ b/frame/insecure-randomness-collective-flip/src/lib.rs @@ -74,11 +74,12 @@ use safe_mix::TripletMix; use codec::Encode; use frame_support::{pallet_prelude::Weight, traits::Randomness}; +use frame_system::pallet_prelude::BlockNumberFor; use sp_runtime::traits::{Hash, Saturating}; const RANDOM_MATERIAL_LEN: u32 = 81; -fn block_number_to_index(block_number: T::BlockNumber) -> usize { +fn block_number_to_index(block_number: BlockNumberFor) -> usize { // on_initialize is called on the first block after genesis let index = (block_number - 1u32.into()) % RANDOM_MATERIAL_LEN.into(); index.try_into().ok().expect("Something % 81 is always smaller than usize; qed") @@ -90,7 +91,6 @@ pub use pallet::*; pub mod pallet { use super::*; use frame_support::pallet_prelude::*; - use frame_system::pallet_prelude::*; #[pallet::pallet] pub struct Pallet(_); @@ -100,7 +100,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(block_number: T::BlockNumber) -> Weight { + fn on_initialize(block_number: BlockNumberFor) -> Weight { let parent_hash = >::parent_hash(); >::mutate(|ref mut values| { @@ -123,7 +123,7 @@ pub mod pallet { StorageValue<_, BoundedVec>, ValueQuery>; } -impl Randomness for Pallet { +impl Randomness> for Pallet { /// This randomness uses a low-influence function, drawing upon the block hashes from the /// previous 81 blocks. Its result for any given subject will be known far in advance by anyone /// observing the chain. Any block producer has significant influence over their block hashes @@ -134,7 +134,7 @@ impl Randomness for Pallet { /// WARNING: Hashing the result of this function will remove any low-influence properties it has /// and mean that all bits of the resulting value are entirely manipulatable by the author of /// the parent block, who can determine the value of `parent_hash`. - fn random(subject: &[u8]) -> (T::Hash, T::BlockNumber) { + fn random(subject: &[u8]) -> (T::Hash, BlockNumberFor) { let block_number = >::block_number(); let index = block_number_to_index::(block_number); @@ -164,7 +164,6 @@ mod tests { use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, Header as _, IdentityLookup}, BuildStorage, }; @@ -175,14 +174,10 @@ mod tests { }; use frame_system::limits; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, CollectiveFlip: pallet_insecure_randomness_collective_flip::{Pallet, Storage}, @@ -201,13 +196,12 @@ mod tests { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/lottery/src/lib.rs b/frame/lottery/src/lib.rs index 178f221a8946f..a6a94b4ab19af 100644 --- a/frame/lottery/src/lib.rs +++ b/frame/lottery/src/lib.rs @@ -142,7 +142,7 @@ pub mod pallet { type Currency: ReservableCurrency; /// Something that provides randomness in the runtime. - type Randomness: Randomness; + type Randomness: Randomness>; /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; @@ -208,7 +208,7 @@ pub mod pallet { /// The configuration for the current lottery. #[pallet::storage] pub(crate) type Lottery = - StorageValue<_, LotteryConfig>>; + StorageValue<_, LotteryConfig, BalanceOf>>; /// Users who have purchased a ticket. (Lottery Index, Tickets Purchased) #[pallet::storage] @@ -239,7 +239,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(n: T::BlockNumber) -> Weight { + fn on_initialize(n: BlockNumberFor) -> Weight { Lottery::::mutate(|mut lottery| -> Weight { if let Some(config) = &mut lottery { let payout_block = @@ -350,8 +350,8 @@ pub mod pallet { pub fn start_lottery( origin: OriginFor, price: BalanceOf, - length: T::BlockNumber, - delay: T::BlockNumber, + length: BlockNumberFor, + delay: BlockNumberFor, repeat: bool, ) -> DispatchResult { T::ManagerOrigin::ensure_origin(origin)?; diff --git a/frame/lottery/src/mock.rs b/frame/lottery/src/mock.rs index b0a0d9b916512..5578c0add1d1e 100644 --- a/frame/lottery/src/mock.rs +++ b/frame/lottery/src/mock.rs @@ -28,19 +28,14 @@ use frame_support_test::TestRandomness; use frame_system::EnsureRoot; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, Perbill, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -60,12 +55,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type Index = u64; type RuntimeCall = RuntimeCall; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index fd1fe7424f974..4f4bc9fdda982 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -525,7 +525,6 @@ mod tests { use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BadOrigin, BlakeTwo256, IdentityLookup}, BuildStorage, }; @@ -536,14 +535,10 @@ mod tests { }; use frame_system::EnsureSignedBy; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Membership: pallet_membership::{Pallet, Call, Storage, Config, Event}, @@ -562,13 +557,12 @@ mod tests { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/merkle-mountain-range/src/lib.rs b/frame/merkle-mountain-range/src/lib.rs index 3adad1e955481..2edef9a35d57a 100644 --- a/frame/merkle-mountain-range/src/lib.rs +++ b/frame/merkle-mountain-range/src/lib.rs @@ -57,6 +57,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use frame_support::{log, weights::Weight}; +use frame_system::pallet_prelude::{BlockNumberFor, HeaderFor}; use sp_mmr_primitives::utils; use sp_runtime::{ traits::{self, One, Saturating}, @@ -91,7 +92,7 @@ pub struct ParentNumberAndHash { } impl LeafDataProvider for ParentNumberAndHash { - type LeafData = (::BlockNumber, ::Hash); + type LeafData = (BlockNumberFor, ::Hash); fn leaf_data() -> Self::LeafData { ( @@ -120,7 +121,6 @@ pub(crate) type HashOf = <>::Hashing as traits::Hash>::Outp pub mod pallet { use super::*; use frame_support::pallet_prelude::*; - use frame_system::pallet_prelude::*; #[pallet::pallet] pub struct Pallet(PhantomData<(T, I)>); @@ -201,7 +201,7 @@ pub mod pallet { #[pallet::hooks] impl, I: 'static> Hooks> for Pallet { - fn on_initialize(_n: T::BlockNumber) -> Weight { + fn on_initialize(_n: BlockNumberFor) -> Weight { use primitives::LeafDataProvider; let leaves = Self::mmr_leaves(); let peaks_before = sp_mmr_primitives::utils::NodesUtils::new(leaves).number_of_peaks(); @@ -266,11 +266,7 @@ impl, I: 'static> Pallet { pos: NodeIndex, parent_hash: ::Hash, ) -> sp_std::prelude::Vec { - NodesUtils::node_temp_offchain_key::<::Header>( - &T::INDEXING_PREFIX, - pos, - parent_hash, - ) + NodesUtils::node_temp_offchain_key::>(&T::INDEXING_PREFIX, pos, parent_hash) } /// Build canonical offchain key for node `pos` in MMR. @@ -286,7 +282,7 @@ impl, I: 'static> Pallet { fn leaf_index_to_parent_block_num( leaf_index: LeafIndex, leaves_count: LeafIndex, - ) -> ::BlockNumber { + ) -> BlockNumberFor { // leaves are zero-indexed and were added one per block since pallet activation, // while block numbers are one-indexed, so block number that added `leaf_idx` is: // `block_num = block_num_when_pallet_activated + leaf_idx + 1` @@ -298,16 +294,16 @@ impl, I: 'static> Pallet { } /// Convert a block number into a leaf index. - fn block_num_to_leaf_index(block_num: T::BlockNumber) -> Result + fn block_num_to_leaf_index(block_num: BlockNumberFor) -> Result where T: frame_system::Config, { - let first_mmr_block = utils::first_mmr_block_num::( + let first_mmr_block = utils::first_mmr_block_num::>( >::block_number(), Self::mmr_leaves(), )?; - utils::block_num_to_leaf_index::(block_num, first_mmr_block) + utils::block_num_to_leaf_index::>(block_num, first_mmr_block) } /// Generate an MMR proof for the given `block_numbers`. @@ -320,8 +316,8 @@ impl, I: 'static> Pallet { /// all the leaves to be present. /// It may return an error or panic if used incorrectly. pub fn generate_proof( - block_numbers: Vec, - best_known_block_number: Option, + block_numbers: Vec>, + best_known_block_number: Option>, ) -> Result<(Vec>, primitives::Proof>), primitives::Error> { // check whether best_known_block_number provided, else use current best block let best_known_block_number = diff --git a/frame/merkle-mountain-range/src/mock.rs b/frame/merkle-mountain-range/src/mock.rs index 2c7b422c62ee3..286b0b2084a6d 100644 --- a/frame/merkle-mountain-range/src/mock.rs +++ b/frame/merkle-mountain-range/src/mock.rs @@ -25,19 +25,12 @@ use frame_support::{ }; use sp_core::H256; use sp_mmr_primitives::{Compact, LeafDataProvider}; -use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup, Keccak256}, -}; +use sp_runtime::traits::{BlakeTwo256, IdentityLookup, Keccak256}; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, MMR: pallet_mmr::{Pallet, Storage}, @@ -49,12 +42,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = sp_core::sr25519::Public; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); diff --git a/frame/merkle-mountain-range/src/tests.rs b/frame/merkle-mountain-range/src/tests.rs index 2f02fc09150f6..429df75182eee 100644 --- a/frame/merkle-mountain-range/src/tests.rs +++ b/frame/merkle-mountain-range/src/tests.rs @@ -54,7 +54,7 @@ pub(crate) fn hex(s: &str) -> H256 { s.parse().unwrap() } -type BlockNumber = ::BlockNumber; +type BlockNumber = frame_system::pallet_prelude::BlockNumberFor; fn decode_node( v: Vec, diff --git a/frame/message-queue/src/integration_test.rs b/frame/message-queue/src/integration_test.rs index 3716597731eca..2b9e9a0a7878c 100644 --- a/frame/message-queue/src/integration_test.rs +++ b/frame/message-queue/src/integration_test.rs @@ -37,20 +37,13 @@ use frame_support::{ use rand::{rngs::StdRng, Rng, SeedableRng}; use rand_distr::Pareto; use sp_core::H256; -use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, -}; +use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; use std::collections::{BTreeMap, BTreeSet}; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, MessageQueue: pallet_message_queue::{Pallet, Call, Storage, Event}, @@ -64,13 +57,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/message-queue/src/mock.rs b/frame/message-queue/src/mock.rs index f2a0ca1b494c3..8c2ba8805aaad 100644 --- a/frame/message-queue/src/mock.rs +++ b/frame/message-queue/src/mock.rs @@ -29,20 +29,15 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; use sp_std::collections::btree_map::BTreeMap; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, MessageQueue: pallet_message_queue::{Pallet, Call, Storage, Event}, @@ -55,13 +50,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); @@ -289,7 +283,7 @@ impl QueuePausedQuery for MockedQueuePauser { /// Is generic since it is used by the unit test, integration tests and benchmarks. pub fn new_test_ext() -> sp_io::TestExternalities where - ::BlockNumber: From, + frame_system::pallet_prelude::BlockNumberFor: From, { sp_tracing::try_init_simple(); WeightForCall::take(); diff --git a/frame/multisig/src/lib.rs b/frame/multisig/src/lib.rs index 64058be9c8fbf..ab117315f8985 100644 --- a/frame/multisig/src/lib.rs +++ b/frame/multisig/src/lib.rs @@ -59,7 +59,7 @@ use frame_support::{ weights::Weight, BoundedVec, RuntimeDebug, }; -use frame_system::{self as system, RawOrigin}; +use frame_system::{self as system, pallet_prelude::BlockNumberFor, RawOrigin}; use scale_info::TypeInfo; use sp_io::hashing::blake2_256; use sp_runtime::{ @@ -183,7 +183,7 @@ pub mod pallet { T::AccountId, Blake2_128Concat, [u8; 32], - Multisig, T::AccountId, T::MaxSignatories>, + Multisig, BalanceOf, T::AccountId, T::MaxSignatories>, >; #[pallet::error] @@ -226,14 +226,14 @@ pub mod pallet { /// A multisig operation has been approved by someone. MultisigApproval { approving: T::AccountId, - timepoint: Timepoint, + timepoint: Timepoint>, multisig: T::AccountId, call_hash: CallHash, }, /// A multisig operation has been executed. MultisigExecuted { approving: T::AccountId, - timepoint: Timepoint, + timepoint: Timepoint>, multisig: T::AccountId, call_hash: CallHash, result: DispatchResult, @@ -241,7 +241,7 @@ pub mod pallet { /// A multisig operation has been cancelled. MultisigCancelled { cancelling: T::AccountId, - timepoint: Timepoint, + timepoint: Timepoint>, multisig: T::AccountId, call_hash: CallHash, }, @@ -366,7 +366,7 @@ pub mod pallet { origin: OriginFor, threshold: u16, other_signatories: Vec, - maybe_timepoint: Option>, + maybe_timepoint: Option>>, call: Box<::RuntimeCall>, max_weight: Weight, ) -> DispatchResultWithPostInfo { @@ -423,7 +423,7 @@ pub mod pallet { origin: OriginFor, threshold: u16, other_signatories: Vec, - maybe_timepoint: Option>, + maybe_timepoint: Option>>, call_hash: [u8; 32], max_weight: Weight, ) -> DispatchResultWithPostInfo { @@ -465,7 +465,7 @@ pub mod pallet { origin: OriginFor, threshold: u16, other_signatories: Vec, - timepoint: Timepoint, + timepoint: Timepoint>, call_hash: [u8; 32], ) -> DispatchResult { let who = ensure_signed(origin)?; @@ -511,7 +511,7 @@ impl Pallet { who: T::AccountId, threshold: u16, other_signatories: Vec, - maybe_timepoint: Option>, + maybe_timepoint: Option>>, call_or_hash: CallOrHash, max_weight: Weight, ) -> DispatchResultWithPostInfo { @@ -637,7 +637,7 @@ impl Pallet { } /// The current `Timepoint`. - pub fn timepoint() -> Timepoint { + pub fn timepoint() -> Timepoint> { Timepoint { height: >::block_number(), index: >::extrinsic_index().unwrap_or_default(), diff --git a/frame/multisig/src/tests.rs b/frame/multisig/src/tests.rs index e024da22810fc..e3cdd086fb757 100644 --- a/frame/multisig/src/tests.rs +++ b/frame/multisig/src/tests.rs @@ -28,19 +28,14 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, TokenError, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -55,13 +50,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/nft-fractionalization/src/benchmarking.rs b/frame/nft-fractionalization/src/benchmarking.rs index 50bb6039eb6ec..0b54acdab49ea 100644 --- a/frame/nft-fractionalization/src/benchmarking.rs +++ b/frame/nft-fractionalization/src/benchmarking.rs @@ -29,7 +29,7 @@ use frame_support::{ Get, }, }; -use frame_system::RawOrigin as SystemOrigin; +use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin as SystemOrigin}; use pallet_nfts::{CollectionConfig, CollectionSettings, ItemConfig, MintSettings}; use sp_runtime::traits::StaticLookup; use sp_std::prelude::*; @@ -39,11 +39,8 @@ use crate::Pallet as NftFractionalization; type BalanceOf = <::Currency as InspectFungible<::AccountId>>::Balance; -type CollectionConfigOf = CollectionConfig< - BalanceOf, - ::BlockNumber, - ::NftCollectionId, ->; +type CollectionConfigOf = + CollectionConfig, BlockNumberFor, ::NftCollectionId>; fn default_collection_config() -> CollectionConfigOf where @@ -58,7 +55,7 @@ where fn mint_nft(nft_id: T::NftId) -> (T::AccountId, AccountIdLookupOf) where - T::Nfts: Create, T::BlockNumber, T::NftCollectionId>> + T::Nfts: Create, BlockNumberFor, T::NftCollectionId>> + Mutate, { let caller: T::AccountId = whitelisted_caller(); @@ -84,7 +81,7 @@ fn assert_last_event(generic_event: ::RuntimeEvent) { benchmarks! { where_clause { where - T::Nfts: Create, T::BlockNumber, T::NftCollectionId>> + T::Nfts: Create, frame_system::pallet_prelude::BlockNumberFor::, T::NftCollectionId>> + Mutate, } diff --git a/frame/nft-fractionalization/src/mock.rs b/frame/nft-fractionalization/src/mock.rs index c5142c8695b98..569429552d268 100644 --- a/frame/nft-fractionalization/src/mock.rs +++ b/frame/nft-fractionalization/src/mock.rs @@ -29,12 +29,10 @@ use frame_system::EnsureSigned; use pallet_nfts::PalletFeatures; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}, BuildStorage, MultiSignature, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; type Signature = MultiSignature; type AccountPublic = ::Signer; @@ -42,10 +40,7 @@ type AccountId = ::AccountId; // Configure a mock runtime to test the pallet. construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, NftFractionalization: pallet_nft_fractionalization, @@ -61,12 +56,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); diff --git a/frame/nfts/src/benchmarking.rs b/frame/nfts/src/benchmarking.rs index 45390bf032bd6..67ba29266245a 100644 --- a/frame/nfts/src/benchmarking.rs +++ b/frame/nfts/src/benchmarking.rs @@ -30,7 +30,7 @@ use frame_support::{ traits::{EnsureOrigin, Get}, BoundedVec, }; -use frame_system::RawOrigin as SystemOrigin; +use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin as SystemOrigin}; use sp_io::crypto::{sr25519_generate, sr25519_sign}; use sp_runtime::{ traits::{Bounded, IdentifyAccount, One}, @@ -589,7 +589,7 @@ benchmarks_instance_pallet! { let (item, ..) = mint_item::(0); let delegate: T::AccountId = account("delegate", 0, SEED); let delegate_lookup = T::Lookup::unlookup(delegate.clone()); - let deadline = T::BlockNumber::max_value(); + let deadline = BlockNumberFor::::max_value(); }: _(SystemOrigin::Signed(caller.clone()), collection, item, delegate_lookup, Some(deadline)) verify { assert_last_event::(Event::TransferApproved { collection, item, owner: caller, delegate, deadline: Some(deadline) }.into()); @@ -601,7 +601,7 @@ benchmarks_instance_pallet! { let delegate: T::AccountId = account("delegate", 0, SEED); let delegate_lookup = T::Lookup::unlookup(delegate.clone()); let origin = SystemOrigin::Signed(caller.clone()).into(); - let deadline = T::BlockNumber::max_value(); + let deadline = BlockNumberFor::::max_value(); Nfts::::approve_transfer(origin, collection, item, delegate_lookup.clone(), Some(deadline))?; }: _(SystemOrigin::Signed(caller.clone()), collection, item, delegate_lookup) verify { @@ -614,7 +614,7 @@ benchmarks_instance_pallet! { let delegate: T::AccountId = account("delegate", 0, SEED); let delegate_lookup = T::Lookup::unlookup(delegate.clone()); let origin = SystemOrigin::Signed(caller.clone()).into(); - let deadline = T::BlockNumber::max_value(); + let deadline = BlockNumberFor::::max_value(); Nfts::::approve_transfer(origin, collection, item, delegate_lookup.clone(), Some(deadline))?; }: _(SystemOrigin::Signed(caller.clone()), collection, item) verify { diff --git a/frame/nfts/src/features/approvals.rs b/frame/nfts/src/features/approvals.rs index 634436a8562d8..c78dd2d96b089 100644 --- a/frame/nfts/src/features/approvals.rs +++ b/frame/nfts/src/features/approvals.rs @@ -24,7 +24,7 @@ impl, I: 'static> Pallet { collection: T::CollectionId, item: T::ItemId, delegate: T::AccountId, - maybe_deadline: Option<::BlockNumber>, + maybe_deadline: Option>, ) -> DispatchResult { ensure!( Self::is_pallet_feature_enabled(PalletFeature::Approvals), diff --git a/frame/nfts/src/features/atomic_swap.rs b/frame/nfts/src/features/atomic_swap.rs index 505056be95353..5b0096d72a3d6 100644 --- a/frame/nfts/src/features/atomic_swap.rs +++ b/frame/nfts/src/features/atomic_swap.rs @@ -29,7 +29,7 @@ impl, I: 'static> Pallet { desired_collection_id: T::CollectionId, maybe_desired_item_id: Option, maybe_price: Option>>, - duration: ::BlockNumber, + duration: frame_system::pallet_prelude::BlockNumberFor, ) -> DispatchResult { ensure!( Self::is_pallet_feature_enabled(PalletFeature::Swaps), diff --git a/frame/nfts/src/features/settings.rs b/frame/nfts/src/features/settings.rs index 080d7b97f13b1..3d96a411ae708 100644 --- a/frame/nfts/src/features/settings.rs +++ b/frame/nfts/src/features/settings.rs @@ -61,7 +61,7 @@ impl, I: 'static> Pallet { collection: T::CollectionId, mint_settings: MintSettings< BalanceOf, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, T::CollectionId, >, ) -> DispatchResult { diff --git a/frame/nfts/src/lib.rs b/frame/nfts/src/lib.rs index f2812674a5408..8124c71682451 100644 --- a/frame/nfts/src/lib.rs +++ b/frame/nfts/src/lib.rs @@ -171,7 +171,7 @@ pub mod pallet { /// The max duration in blocks for deadlines. #[pallet::constant] - type MaxDeadlineDuration: Get<::BlockNumber>; + type MaxDeadlineDuration: Get>; /// The max number of attributes a user could set per call. #[pallet::constant] @@ -343,7 +343,7 @@ pub mod pallet { T::CollectionId, T::ItemId, PriceWithDirection>, - ::BlockNumber, + BlockNumberFor, >, OptionQuery, >; @@ -414,7 +414,7 @@ pub mod pallet { item: T::ItemId, owner: T::AccountId, delegate: T::AccountId, - deadline: Option<::BlockNumber>, + deadline: Option>, }, /// An approval for a `delegate` account to transfer the `item` of an item /// `collection` was cancelled by its `owner`. @@ -509,7 +509,7 @@ pub mod pallet { desired_collection: T::CollectionId, desired_item: Option, price: Option>>, - deadline: ::BlockNumber, + deadline: BlockNumberFor, }, /// The swap was cancelled. SwapCancelled { @@ -518,7 +518,7 @@ pub mod pallet { desired_collection: T::CollectionId, desired_item: Option, price: Option>>, - deadline: ::BlockNumber, + deadline: BlockNumberFor, }, /// The swap has been claimed. SwapClaimed { @@ -529,7 +529,7 @@ pub mod pallet { received_item: T::ItemId, received_item_owner: T::AccountId, price: Option>>, - deadline: ::BlockNumber, + deadline: BlockNumberFor, }, /// New attributes have been set for an `item` of the `collection`. PreSignedAttributesSet { @@ -1236,7 +1236,7 @@ pub mod pallet { collection: T::CollectionId, item: T::ItemId, delegate: AccountIdLookupOf, - maybe_deadline: Option<::BlockNumber>, + maybe_deadline: Option>, ) -> DispatchResult { let maybe_check_origin = T::ForceOrigin::try_origin(origin) .map(|_| None) @@ -1659,11 +1659,7 @@ pub mod pallet { pub fn update_mint_settings( origin: OriginFor, collection: T::CollectionId, - mint_settings: MintSettings< - BalanceOf, - ::BlockNumber, - T::CollectionId, - >, + mint_settings: MintSettings, BlockNumberFor, T::CollectionId>, ) -> DispatchResult { let maybe_check_origin = T::ForceOrigin::try_origin(origin) .map(|_| None) @@ -1759,7 +1755,7 @@ pub mod pallet { desired_collection: T::CollectionId, maybe_desired_item: Option, maybe_price: Option>>, - duration: ::BlockNumber, + duration: BlockNumberFor, ) -> DispatchResult { let origin = ensure_signed(origin)?; Self::do_create_swap( diff --git a/frame/nfts/src/mock.rs b/frame/nfts/src/mock.rs index 8b8c7c6a0fd70..e791c85b67f3f 100644 --- a/frame/nfts/src/mock.rs +++ b/frame/nfts/src/mock.rs @@ -27,19 +27,14 @@ use frame_support::{ use sp_core::H256; use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}, BuildStorage, MultiSignature, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -58,12 +53,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); diff --git a/frame/nfts/src/types.rs b/frame/nfts/src/types.rs index ab966f0d73828..e4e6165774627 100644 --- a/frame/nfts/src/types.rs +++ b/frame/nfts/src/types.rs @@ -26,6 +26,7 @@ use frame_support::{ traits::Get, BoundedBTreeMap, BoundedBTreeSet, }; +use frame_system::pallet_prelude::BlockNumberFor; use scale_info::{build::Fields, meta_type, Path, Type, TypeInfo, TypeParameter}; pub(super) type DepositBalanceOf = @@ -34,7 +35,7 @@ pub(super) type CollectionDetailsFor = CollectionDetails<::AccountId, DepositBalanceOf>; pub(super) type ApprovalsOf = BoundedBTreeMap< ::AccountId, - Option<::BlockNumber>, + Option>, >::ApprovalsLimit, >; pub(super) type ItemAttributesApprovals = @@ -56,23 +57,20 @@ pub(super) type ItemTipOf = ItemTip< ::AccountId, BalanceOf, >; -pub(super) type CollectionConfigFor = CollectionConfig< - BalanceOf, - ::BlockNumber, - >::CollectionId, ->; +pub(super) type CollectionConfigFor = + CollectionConfig, BlockNumberFor, >::CollectionId>; pub(super) type PreSignedMintOf = PreSignedMint< >::CollectionId, >::ItemId, ::AccountId, - ::BlockNumber, + BlockNumberFor, BalanceOf, >; pub(super) type PreSignedAttributesOf = PreSignedAttributes< >::CollectionId, >::ItemId, ::AccountId, - ::BlockNumber, + BlockNumberFor, >; /// Information about a collection. diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index 9fa7595bdf3f3..a0dd3125db75d 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -239,19 +239,14 @@ mod tests { use frame_system::EnsureSignedBy; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BadOrigin, BlakeTwo256, IdentityLookup}, BuildStorage, }; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Balances: pallet_balances, @@ -266,13 +261,12 @@ mod tests { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/nis/src/lib.rs b/frame/nis/src/lib.rs index 48d322545a635..1bf052a39d1ed 100644 --- a/frame/nis/src/lib.rs +++ b/frame/nis/src/lib.rs @@ -186,13 +186,10 @@ pub mod pallet { <::Currency as FunInspect<::AccountId>>::Balance; type DebtOf = fungible::Debt<::AccountId, ::Currency>; - type ReceiptRecordOf = ReceiptRecord< - ::AccountId, - ::BlockNumber, - BalanceOf, - >; + type ReceiptRecordOf = + ReceiptRecord<::AccountId, BlockNumberFor, BalanceOf>; type IssuanceInfoOf = IssuanceInfo>; - type SummaryRecordOf = SummaryRecord<::BlockNumber, BalanceOf>; + type SummaryRecordOf = SummaryRecord, BalanceOf>; type BidOf = Bid, ::AccountId>; type QueueTotalsTypeOf = BoundedVec<(u32, BalanceOf), ::QueueCount>; @@ -275,7 +272,7 @@ pub mod pallet { /// The base period for the duration queues. This is the common multiple across all /// supported freezing durations that can be bid upon. #[pallet::constant] - type BasePeriod: Get; + type BasePeriod: Get>; /// The minimum amount of funds that may be placed in a bid. Note that this /// does not actually limit the amount which may be represented in a receipt since bids may @@ -296,7 +293,7 @@ pub mod pallet { /// A larger value results in fewer storage hits each block, but a slower period to get to /// the target. #[pallet::constant] - type IntakePeriod: Get; + type IntakePeriod: Get>; /// The maximum amount of bids that can consolidated into receipts in a single intake. A /// larger value here means less of the block available for transactions should there be a @@ -306,7 +303,7 @@ pub mod pallet { /// The maximum proportion which may be thawed and the period over which it is reset. #[pallet::constant] - type ThawThrottle: Get<(Perquintill, Self::BlockNumber)>; + type ThawThrottle: Get<(Perquintill, BlockNumberFor)>; } #[pallet::pallet] @@ -413,7 +410,7 @@ pub mod pallet { /// The identity of the receipt. index: ReceiptIndex, /// The block number at which the receipt may be thawed. - expiry: T::BlockNumber, + expiry: BlockNumberFor, /// The owner of the receipt. who: T::AccountId, /// The proportion of the effective total issuance which the receipt represents. @@ -508,7 +505,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(n: T::BlockNumber) -> Weight { + fn on_initialize(n: BlockNumberFor) -> Weight { let mut weight_counter = WeightCounter { used: Weight::zero(), limit: T::MaxIntakeWeight::get() }; if T::IntakePeriod::get().is_zero() || (n % T::IntakePeriod::get()).is_zero() { @@ -1062,7 +1059,7 @@ pub mod pallet { pub(crate) fn process_queue( duration: u32, - now: T::BlockNumber, + now: BlockNumberFor, our_account: &T::AccountId, issuance: &IssuanceInfo>, max_bids: u32, @@ -1106,7 +1103,7 @@ pub mod pallet { pub(crate) fn process_bid( mut bid: BidOf, - expiry: T::BlockNumber, + expiry: BlockNumberFor, _our_account: &T::AccountId, issuance: &IssuanceInfo>, remaining: &mut BalanceOf, diff --git a/frame/nis/src/mock.rs b/frame/nis/src/mock.rs index 0146acabf9fde..4fb51ed324e22 100644 --- a/frame/nis/src/mock.rs +++ b/frame/nis/src/mock.rs @@ -31,22 +31,17 @@ use frame_support::{ use pallet_balances::{Instance1, Instance2}; use sp_core::{ConstU128, H256}; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; pub type Balance = u64; // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Balances: pallet_balances::, @@ -62,12 +57,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); diff --git a/frame/node-authorization/src/lib.rs b/frame/node-authorization/src/lib.rs index dec05d0c37058..8a823d29f2355 100644 --- a/frame/node-authorization/src/lib.rs +++ b/frame/node-authorization/src/lib.rs @@ -169,7 +169,7 @@ pub mod pallet { impl Hooks> for Pallet { /// Set reserved node every block. It may not be enabled depends on the offchain /// worker settings when starting the node. - fn offchain_worker(now: T::BlockNumber) { + fn offchain_worker(now: frame_system::pallet_prelude::BlockNumberFor) { let network_state = sp_io::offchain::network_state(); match network_state { Err(_) => log::error!( diff --git a/frame/node-authorization/src/mock.rs b/frame/node-authorization/src/mock.rs index c0594f1d94424..0733016b82cb9 100644 --- a/frame/node-authorization/src/mock.rs +++ b/frame/node-authorization/src/mock.rs @@ -27,19 +27,14 @@ use frame_support::{ use frame_system::EnsureSignedBy; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, NodeAuthorization: pallet_node_authorization::{ @@ -55,13 +50,12 @@ impl frame_system::Config for Test { type BlockLength = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/nomination-pools/benchmarking/src/mock.rs b/frame/nomination-pools/benchmarking/src/mock.rs index 5666e7b450acb..60ca5166abb87 100644 --- a/frame/nomination-pools/benchmarking/src/mock.rs +++ b/frame/nomination-pools/benchmarking/src/mock.rs @@ -35,13 +35,12 @@ impl frame_system::Config for Runtime { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = AccountIndex; - type BlockNumber = BlockNumber; type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); @@ -175,12 +174,9 @@ impl pallet_nomination_pools::Config for Runtime { impl crate::Config for Runtime {} type Block = frame_system::mocking::MockBlock; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system::{Pallet, Call, Event}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, diff --git a/frame/nomination-pools/src/lib.rs b/frame/nomination-pools/src/lib.rs index 587fe1b9e8d2a..c4bebc5a1d030 100644 --- a/frame/nomination-pools/src/lib.rs +++ b/frame/nomination-pools/src/lib.rs @@ -362,6 +362,7 @@ use frame_support::{ }, DefaultNoBound, PalletError, }; +use frame_system::pallet_prelude::BlockNumberFor; use scale_info::TypeInfo; use sp_core::U256; use sp_runtime::{ @@ -672,10 +673,10 @@ pub struct Commission { pub max: Option, /// Optional configuration around how often commission can be updated, and when the last /// commission update took place. - pub change_rate: Option>, + pub change_rate: Option>>, /// The block from where throttling should be checked from. This value will be updated on all /// commission updates and when setting an initial `change_rate`. - pub throttle_from: Option, + pub throttle_from: Option>, } impl Commission { @@ -817,7 +818,7 @@ impl Commission { /// throttling can be checked from this block. fn try_update_change_rate( &mut self, - change_rate: CommissionChangeRate, + change_rate: CommissionChangeRate>, ) -> DispatchResult { ensure!(!&self.less_restrictive(&change_rate), Error::::CommissionChangeRateNotAllowed); @@ -837,7 +838,7 @@ impl Commission { /// /// No change rate will always be less restrictive than some change rate, so where no /// `change_rate` is currently set, `false` is returned. - fn less_restrictive(&self, new: &CommissionChangeRate) -> bool { + fn less_restrictive(&self, new: &CommissionChangeRate>) -> bool { self.change_rate .as_ref() .map(|c| new.max_increase > c.max_increase || new.min_delay < c.min_delay) @@ -1765,7 +1766,7 @@ pub mod pallet { /// A pool's commission `change_rate` has been changed. PoolCommissionChangeRateUpdated { pool_id: PoolId, - change_rate: CommissionChangeRate, + change_rate: CommissionChangeRate>, }, /// Pool commission has been claimed. PoolCommissionClaimed { pool_id: PoolId, commission: BalanceOf }, @@ -2603,7 +2604,7 @@ pub mod pallet { pub fn set_commission_change_rate( origin: OriginFor, pool_id: PoolId, - change_rate: CommissionChangeRate, + change_rate: CommissionChangeRate>, ) -> DispatchResult { let who = ensure_signed(origin)?; let mut bonded_pool = BondedPool::::get(pool_id).ok_or(Error::::PoolNotFound)?; diff --git a/frame/nomination-pools/src/mock.rs b/frame/nomination-pools/src/mock.rs index ef1240b666101..fd8514bfc8bfe 100644 --- a/frame/nomination-pools/src/mock.rs +++ b/frame/nomination-pools/src/mock.rs @@ -169,13 +169,12 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = BlockNumber; type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type DbWeight = (); @@ -246,13 +245,9 @@ impl pools::Config for Runtime { type MaxPointsToBalance = frame_support::traits::ConstU8<10>; } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub struct Runtime { System: frame_system::{Pallet, Call, Storage, Event, Config}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/nomination-pools/test-staking/src/mock.rs b/frame/nomination-pools/test-staking/src/mock.rs index f7697d534fd57..8c8618913d518 100644 --- a/frame/nomination-pools/test-staking/src/mock.rs +++ b/frame/nomination-pools/test-staking/src/mock.rs @@ -45,13 +45,12 @@ impl frame_system::Config for Runtime { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = AccountIndex; - type BlockNumber = BlockNumber; type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); @@ -187,13 +186,9 @@ impl pallet_nomination_pools::Config for Runtime { } type Block = frame_system::mocking::MockBlock; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system::{Pallet, Call, Event}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index ec64ce13632e3..6089025dcb2b2 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -35,7 +35,6 @@ use sp_runtime::{ type AccountId = u64; type AccountIndex = u32; -type BlockNumber = u64; type Balance = u64; impl frame_system::Config for Test { @@ -45,13 +44,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = AccountIndex; - type BlockNumber = BlockNumber; type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); @@ -220,10 +218,7 @@ pub type Block = sp_runtime::generic::Block; pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub enum Test { System: system::{Pallet, Call, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/offences/src/mock.rs b/frame/offences/src/mock.rs index f719fe6cdd7d2..150ab3665269d 100644 --- a/frame/offences/src/mock.rs +++ b/frame/offences/src/mock.rs @@ -29,7 +29,6 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, Perbill, }; @@ -66,14 +65,10 @@ pub fn with_on_offence_fractions) -> R>(f: F) -> OnOffencePerbill::mutate(|fractions| f(fractions)) } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub struct Runtime { System: frame_system::{Pallet, Call, Config, Storage, Event}, Offences: offences::{Pallet, Storage, Event}, @@ -87,13 +82,12 @@ impl frame_system::Config for Runtime { type DbWeight = RocksDbWeight; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/preimage/src/mock.rs b/frame/preimage/src/mock.rs index d3d891c1d0dc9..f196a18acae36 100644 --- a/frame/preimage/src/mock.rs +++ b/frame/preimage/src/mock.rs @@ -28,19 +28,14 @@ use frame_support::{ use frame_system::EnsureSignedBy; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Balances: pallet_balances, @@ -56,12 +51,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/proxy/src/benchmarking.rs b/frame/proxy/src/benchmarking.rs index 7244dd5f17472..e0d14163d21b2 100644 --- a/frame/proxy/src/benchmarking.rs +++ b/frame/proxy/src/benchmarking.rs @@ -22,7 +22,7 @@ use super::*; use crate::Pallet as Proxy; use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; -use frame_system::RawOrigin; +use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use sp_runtime::traits::Bounded; const SEED: u32 = 0; @@ -41,7 +41,7 @@ fn add_proxies(n: u32, maybe_who: Option) -> Result<(), RawOrigin::Signed(caller.clone()).into(), real, T::ProxyType::default(), - T::BlockNumber::zero(), + BlockNumberFor::::zero(), )?; } Ok(()) @@ -64,7 +64,7 @@ fn add_announcements( RawOrigin::Signed(real.clone()).into(), caller_lookup, T::ProxyType::default(), - T::BlockNumber::zero(), + BlockNumberFor::::zero(), )?; real }; @@ -187,7 +187,7 @@ benchmarks! { RawOrigin::Signed(caller.clone()), real, T::ProxyType::default(), - T::BlockNumber::zero() + BlockNumberFor::::zero() ) verify { let (proxies, _) = Proxies::::get(caller); @@ -202,7 +202,7 @@ benchmarks! { RawOrigin::Signed(caller.clone()), delegate, T::ProxyType::default(), - T::BlockNumber::zero() + BlockNumberFor::::zero() ) verify { let (proxies, _) = Proxies::::get(caller); @@ -224,7 +224,7 @@ benchmarks! { }: _( RawOrigin::Signed(caller.clone()), T::ProxyType::default(), - T::BlockNumber::zero(), + BlockNumberFor::::zero(), 0 ) verify { @@ -246,7 +246,7 @@ benchmarks! { Pallet::::create_pure( RawOrigin::Signed(whitelisted_caller()).into(), T::ProxyType::default(), - T::BlockNumber::zero(), + BlockNumberFor::::zero(), 0 )?; let height = system::Pallet::::block_number(); diff --git a/frame/proxy/src/lib.rs b/frame/proxy/src/lib.rs index 76ff2662bd0f4..33e9fcfade35a 100644 --- a/frame/proxy/src/lib.rs +++ b/frame/proxy/src/lib.rs @@ -40,7 +40,7 @@ use frame_support::{ traits::{Currency, Get, InstanceFilter, IsSubType, IsType, OriginTrait, ReservableCurrency}, RuntimeDebug, }; -use frame_system::{self as system, ensure_signed}; +use frame_system::{self as system, ensure_signed, pallet_prelude::BlockNumberFor}; pub use pallet::*; use scale_info::TypeInfo; use sp_io::hashing::blake2_256; @@ -227,7 +227,7 @@ pub mod pallet { origin: OriginFor, delegate: AccountIdLookupOf, proxy_type: T::ProxyType, - delay: T::BlockNumber, + delay: BlockNumberFor, ) -> DispatchResult { let who = ensure_signed(origin)?; let delegate = T::Lookup::lookup(delegate)?; @@ -247,7 +247,7 @@ pub mod pallet { origin: OriginFor, delegate: AccountIdLookupOf, proxy_type: T::ProxyType, - delay: T::BlockNumber, + delay: BlockNumberFor, ) -> DispatchResult { let who = ensure_signed(origin)?; let delegate = T::Lookup::lookup(delegate)?; @@ -291,7 +291,7 @@ pub mod pallet { pub fn create_pure( origin: OriginFor, proxy_type: T::ProxyType, - delay: T::BlockNumber, + delay: BlockNumberFor, index: u16, ) -> DispatchResult { let who = ensure_signed(origin)?; @@ -341,7 +341,7 @@ pub mod pallet { spawner: AccountIdLookupOf, proxy_type: T::ProxyType, index: u16, - #[pallet::compact] height: T::BlockNumber, + #[pallet::compact] height: BlockNumberFor, #[pallet::compact] ext_index: u32, ) -> DispatchResult { let who = ensure_signed(origin)?; @@ -535,14 +535,14 @@ pub mod pallet { delegator: T::AccountId, delegatee: T::AccountId, proxy_type: T::ProxyType, - delay: T::BlockNumber, + delay: BlockNumberFor, }, /// A proxy was removed. ProxyRemoved { delegator: T::AccountId, delegatee: T::AccountId, proxy_type: T::ProxyType, - delay: T::BlockNumber, + delay: BlockNumberFor, }, } @@ -575,7 +575,10 @@ pub mod pallet { Twox64Concat, T::AccountId, ( - BoundedVec, T::MaxProxies>, + BoundedVec< + ProxyDefinition>, + T::MaxProxies, + >, BalanceOf, ), ValueQuery, @@ -589,7 +592,7 @@ pub mod pallet { Twox64Concat, T::AccountId, ( - BoundedVec, T::BlockNumber>, T::MaxPending>, + BoundedVec, BlockNumberFor>, T::MaxPending>, BalanceOf, ), ValueQuery, @@ -612,7 +615,7 @@ impl Pallet { who: &T::AccountId, proxy_type: &T::ProxyType, index: u16, - maybe_when: Option<(T::BlockNumber, u32)>, + maybe_when: Option<(BlockNumberFor, u32)>, ) -> T::AccountId { let (height, ext_index) = maybe_when.unwrap_or_else(|| { ( @@ -638,7 +641,7 @@ impl Pallet { delegator: &T::AccountId, delegatee: T::AccountId, proxy_type: T::ProxyType, - delay: T::BlockNumber, + delay: BlockNumberFor, ) -> DispatchResult { ensure!(delegator != &delegatee, Error::::NoSelfProxy); Proxies::::try_mutate(delegator, |(ref mut proxies, ref mut deposit)| { @@ -678,7 +681,7 @@ impl Pallet { delegator: &T::AccountId, delegatee: T::AccountId, proxy_type: T::ProxyType, - delay: T::BlockNumber, + delay: BlockNumberFor, ) -> DispatchResult { Proxies::::try_mutate_exists(delegator, |x| { let (mut proxies, old_deposit) = x.take().ok_or(Error::::NotFound)?; @@ -734,7 +737,7 @@ impl Pallet { } fn edit_announcements< - F: FnMut(&Announcement, T::BlockNumber>) -> bool, + F: FnMut(&Announcement, BlockNumberFor>) -> bool, >( delegate: &T::AccountId, f: F, @@ -760,8 +763,8 @@ impl Pallet { real: &T::AccountId, delegate: &T::AccountId, force_proxy_type: Option, - ) -> Result, DispatchError> { - let f = |x: &ProxyDefinition| -> bool { + ) -> Result>, DispatchError> { + let f = |x: &ProxyDefinition>| -> bool { &x.delegate == delegate && force_proxy_type.as_ref().map_or(true, |y| &x.proxy_type == y) }; @@ -769,7 +772,7 @@ impl Pallet { } fn do_proxy( - def: ProxyDefinition, + def: ProxyDefinition>, real: T::AccountId, call: ::RuntimeCall, ) { diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index ccfeed8cd5693..54466e5d5bbce 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -31,19 +31,14 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -59,13 +54,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/ranked-collective/src/lib.rs b/frame/ranked-collective/src/lib.rs index 6fe9fc221a7df..fe1308cd034f4 100644 --- a/frame/ranked-collective/src/lib.rs +++ b/frame/ranked-collective/src/lib.rs @@ -391,7 +391,7 @@ pub mod pallet { type DemoteOrigin: EnsureOrigin; /// The polling system used for our voting. - type Polls: Polling, Votes = Votes, Moment = Self::BlockNumber>; + type Polls: Polling, Votes = Votes, Moment = BlockNumberFor>; /// Convert the tally class into the minimum rank required to vote on the poll. If /// `Polls::Class` is the same type as `Rank`, then `Identity` can be used here to mean diff --git a/frame/ranked-collective/src/tests.rs b/frame/ranked-collective/src/tests.rs index fb8dc00e76551..7f3cd27705e97 100644 --- a/frame/ranked-collective/src/tests.rs +++ b/frame/ranked-collective/src/tests.rs @@ -27,7 +27,6 @@ use frame_support::{ }; use sp_core::{Get, H256}; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup, ReduceBy}, BuildStorage, }; @@ -35,15 +34,11 @@ use sp_runtime::{ use super::*; use crate as pallet_ranked_collective; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; type Class = Rank; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Club: pallet_ranked_collective::{Pallet, Call, Storage, Event}, @@ -57,13 +52,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/recovery/src/lib.rs b/frame/recovery/src/lib.rs index 8f70ebfe5ec67..9c01d25d4f76b 100644 --- a/frame/recovery/src/lib.rs +++ b/frame/recovery/src/lib.rs @@ -334,7 +334,7 @@ pub mod pallet { _, Twox64Concat, T::AccountId, - RecoveryConfig, FriendsOf>, + RecoveryConfig, BalanceOf, FriendsOf>, >; /// Active recovery attempts. @@ -349,7 +349,7 @@ pub mod pallet { T::AccountId, Twox64Concat, T::AccountId, - ActiveRecovery, FriendsOf>, + ActiveRecovery, BalanceOf, FriendsOf>, >; /// The list of allowed proxy accounts. @@ -440,7 +440,7 @@ pub mod pallet { origin: OriginFor, friends: Vec, threshold: u16, - delay_period: T::BlockNumber, + delay_period: BlockNumberFor, ) -> DispatchResult { let who = ensure_signed(origin)?; // Check account is not already set up for recovery diff --git a/frame/recovery/src/mock.rs b/frame/recovery/src/mock.rs index 75e5168f13aaa..16de531867c24 100644 --- a/frame/recovery/src/mock.rs +++ b/frame/recovery/src/mock.rs @@ -26,19 +26,14 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -54,12 +49,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/referenda/src/benchmarking.rs b/frame/referenda/src/benchmarking.rs index 4c332a3048d0b..d4b273c0307a3 100644 --- a/frame/referenda/src/benchmarking.rs +++ b/frame/referenda/src/benchmarking.rs @@ -172,7 +172,9 @@ fn skip_timeout_period, I: 'static>(index: ReferendumIndex) { frame_system::Pallet::::set_block_number(timeout_period_over); } -fn alarm_time, I: 'static>(index: ReferendumIndex) -> T::BlockNumber { +fn alarm_time, I: 'static>( + index: ReferendumIndex, +) -> frame_system::pallet_prelude::BlockNumberFor { let status = Referenda::::ensure_ongoing(index).unwrap(); status.alarm.unwrap().0 } diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index 3756257c33fe5..8ff754dc0db8e 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -77,6 +77,7 @@ use frame_support::{ }, BoundedVec, }; +use frame_system::pallet_prelude::BlockNumberFor; use scale_info::TypeInfo; use sp_runtime::{ traits::{AtLeast32BitUnsigned, Bounded, Dispatchable, One, Saturating, Zero}, @@ -161,8 +162,8 @@ pub mod pallet { /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; /// The Scheduler. - type Scheduler: ScheduleAnon, PalletsOriginOf> - + ScheduleNamed, PalletsOriginOf>; + type Scheduler: ScheduleAnon, CallOf, PalletsOriginOf> + + ScheduleNamed, CallOf, PalletsOriginOf>; /// Currency type for this pallet. type Currency: ReservableCurrency; // Origins and unbalances. @@ -201,25 +202,25 @@ pub mod pallet { /// The number of blocks after submission that a referendum must begin being decided by. /// Once this passes, then anyone may cancel the referendum. #[pallet::constant] - type UndecidingTimeout: Get; + type UndecidingTimeout: Get>; /// Quantization level for the referendum wakeup scheduler. A higher number will result in /// fewer storage reads/writes needed for smaller voters, but also result in delays to the /// automatic referendum status changes. Explicit servicing instructions are unaffected. #[pallet::constant] - type AlarmInterval: Get; + type AlarmInterval: Get>; // The other stuff. /// Information concerning the different referendum tracks. #[pallet::constant] type Tracks: Get< Vec<( - , Self::BlockNumber>>::Id, - TrackInfo, Self::BlockNumber>, + , BlockNumberFor>>::Id, + TrackInfo, BlockNumberFor>, )>, > + TracksInfo< BalanceOf, - Self::BlockNumber, + BlockNumberFor, RuntimeOrigin = ::PalletsOrigin, >; @@ -432,7 +433,7 @@ pub mod pallet { origin: OriginFor, proposal_origin: Box>, proposal: BoundedCallOf, - enactment_moment: DispatchTime, + enactment_moment: DispatchTime>, ) -> DispatchResult { let proposal_origin = *proposal_origin; let who = T::SubmitOrigin::ensure_origin(origin, &proposal_origin)?; @@ -704,7 +705,7 @@ pub mod pallet { impl, I: 'static> Polling for Pallet { type Index = ReferendumIndex; type Votes = VotesOf; - type Moment = T::BlockNumber; + type Moment = BlockNumberFor; type Class = TrackIdOf; fn classes() -> Vec { @@ -713,7 +714,7 @@ impl, I: 'static> Polling for Pallet { fn access_poll( index: Self::Index, - f: impl FnOnce(PollStatus<&mut T::Tally, T::BlockNumber, TrackIdOf>) -> R, + f: impl FnOnce(PollStatus<&mut T::Tally, BlockNumberFor, TrackIdOf>) -> R, ) -> R { match ReferendumInfoFor::::get(index) { Some(ReferendumInfo::Ongoing(mut status)) => { @@ -732,7 +733,7 @@ impl, I: 'static> Polling for Pallet { fn try_access_poll( index: Self::Index, f: impl FnOnce( - PollStatus<&mut T::Tally, T::BlockNumber, TrackIdOf>, + PollStatus<&mut T::Tally, BlockNumberFor, TrackIdOf>, ) -> Result, ) -> Result { match ReferendumInfoFor::::get(index) { @@ -849,7 +850,7 @@ impl, I: 'static> Pallet { fn schedule_enactment( index: ReferendumIndex, track: &TrackInfoOf, - desired: DispatchTime, + desired: DispatchTime>, origin: PalletsOriginOf, call: BoundedCallOf, ) { @@ -871,8 +872,8 @@ impl, I: 'static> Pallet { /// Set an alarm to dispatch `call` at block number `when`. fn set_alarm( call: BoundedCallOf, - when: T::BlockNumber, - ) -> Option<(T::BlockNumber, ScheduleAddressOf)> { + when: BlockNumberFor, + ) -> Option<(BlockNumberFor, ScheduleAddressOf)> { let alarm_interval = T::AlarmInterval::get().max(One::one()); // Alarm must go off no earlier than `when`. // This rounds `when` upwards to the next multiple of `alarm_interval`. @@ -905,9 +906,9 @@ impl, I: 'static> Pallet { fn begin_deciding( status: &mut ReferendumStatusOf, index: ReferendumIndex, - now: T::BlockNumber, + now: BlockNumberFor, track: &TrackInfoOf, - ) -> (Option, BeginDecidingBranch) { + ) -> (Option>, BeginDecidingBranch) { let is_passing = Self::is_passing( &status.tally, Zero::zero(), @@ -943,11 +944,11 @@ impl, I: 'static> Pallet { /// /// If `None`, then it is queued and should be nudged automatically as the queue gets drained. fn ready_for_deciding( - now: T::BlockNumber, + now: BlockNumberFor, track: &TrackInfoOf, index: ReferendumIndex, status: &mut ReferendumStatusOf, - ) -> (Option, ServiceBranch) { + ) -> (Option>, ServiceBranch) { let deciding_count = DecidingCount::::get(status.track); if deciding_count < track.max_deciding { // Begin deciding. @@ -1004,7 +1005,7 @@ impl, I: 'static> Pallet { fn ensure_alarm_at( status: &mut ReferendumStatusOf, index: ReferendumIndex, - alarm: T::BlockNumber, + alarm: BlockNumberFor, ) -> bool { if status.alarm.as_ref().map_or(true, |&(when, _)| when != alarm) { // Either no alarm or one that was different @@ -1049,7 +1050,7 @@ impl, I: 'static> Pallet { /// `TrackQueue`. Basically this happens when a referendum is in the deciding queue and receives /// a vote, or when it moves into the deciding queue. fn service_referendum( - now: T::BlockNumber, + now: BlockNumberFor, index: ReferendumIndex, mut status: ReferendumStatusOf, ) -> (ReferendumInfoOf, bool, ServiceBranch) { @@ -1061,7 +1062,7 @@ impl, I: 'static> Pallet { }; // Default the alarm to the end of the world. let timeout = status.submitted + T::UndecidingTimeout::get(); - let mut alarm = T::BlockNumber::max_value(); + let mut alarm = BlockNumberFor::::max_value(); let branch; match &mut status.deciding { None => { @@ -1192,7 +1193,7 @@ impl, I: 'static> Pallet { }, } - let dirty_alarm = if alarm < T::BlockNumber::max_value() { + let dirty_alarm = if alarm < BlockNumberFor::::max_value() { Self::ensure_alarm_at(&mut status, index, alarm) } else { Self::ensure_no_alarm(&mut status) @@ -1207,7 +1208,7 @@ impl, I: 'static> Pallet { tally: &T::Tally, track_id: TrackIdOf, track: &TrackInfoOf, - ) -> T::BlockNumber { + ) -> BlockNumberFor { deciding.confirming.unwrap_or_else(|| { // Set alarm to the point where the current voting would make it pass. let approval = tally.approval(track_id); @@ -1266,8 +1267,8 @@ impl, I: 'static> Pallet { /// `approval_needed`. fn is_passing( tally: &T::Tally, - elapsed: T::BlockNumber, - period: T::BlockNumber, + elapsed: BlockNumberFor, + period: BlockNumberFor, support_needed: &Curve, approval_needed: &Curve, id: TrackIdOf, diff --git a/frame/referenda/src/migration.rs b/frame/referenda/src/migration.rs index 6f796ca40d9be..6f5e42cd49657 100644 --- a/frame/referenda/src/migration.rs +++ b/frame/referenda/src/migration.rs @@ -37,7 +37,7 @@ pub mod v0 { pub type ReferendumInfoOf = ReferendumInfo< TrackIdOf, PalletsOriginOf, - ::BlockNumber, + frame_system::pallet_prelude::BlockNumberFor, BoundedCallOf, BalanceOf, TallyOf, diff --git a/frame/referenda/src/mock.rs b/frame/referenda/src/mock.rs index b6b5905709d0d..f42df260f4759 100644 --- a/frame/referenda/src/mock.rs +++ b/frame/referenda/src/mock.rs @@ -31,19 +31,14 @@ use frame_support::{ use frame_system::{EnsureRoot, EnsureSignedBy}; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, Hash, IdentityLookup}, BuildStorage, DispatchResult, Perbill, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Balances: pallet_balances, @@ -71,13 +66,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/referenda/src/types.rs b/frame/referenda/src/types.rs index d61b8955443c2..ba89383888a7d 100644 --- a/frame/referenda/src/types.rs +++ b/frame/referenda/src/types.rs @@ -42,7 +42,7 @@ pub type PalletsOriginOf = pub type ReferendumInfoOf = ReferendumInfo< TrackIdOf, PalletsOriginOf, - ::BlockNumber, + BlockNumberFor, BoundedCallOf, BalanceOf, TallyOf, @@ -52,22 +52,19 @@ pub type ReferendumInfoOf = ReferendumInfo< pub type ReferendumStatusOf = ReferendumStatus< TrackIdOf, PalletsOriginOf, - ::BlockNumber, + BlockNumberFor, BoundedCallOf, BalanceOf, TallyOf, ::AccountId, ScheduleAddressOf, >; -pub type DecidingStatusOf = DecidingStatus<::BlockNumber>; -pub type TrackInfoOf = - TrackInfo, ::BlockNumber>; -pub type TrackIdOf = <>::Tracks as TracksInfo< - BalanceOf, - ::BlockNumber, ->>::Id; +pub type DecidingStatusOf = DecidingStatus>; +pub type TrackInfoOf = TrackInfo, BlockNumberFor>; +pub type TrackIdOf = + <>::Tracks as TracksInfo, BlockNumberFor>>::Id; pub type ScheduleAddressOf = <>::Scheduler as Anon< - ::BlockNumber, + BlockNumberFor, CallOf, PalletsOriginOf, >>::Address; diff --git a/frame/remark/src/mock.rs b/frame/remark/src/mock.rs index 13f20557c6ceb..45b30dad5c161 100644 --- a/frame/remark/src/mock.rs +++ b/frame/remark/src/mock.rs @@ -21,20 +21,15 @@ use crate as pallet_remark; use frame_support::traits::{ConstU16, ConstU32, ConstU64}; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; pub type Block = frame_system::mocking::MockBlock; // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Remark: pallet_remark::{ Pallet, Call, Event }, @@ -48,12 +43,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); diff --git a/frame/root-offences/src/mock.rs b/frame/root-offences/src/mock.rs index d8a8e597da484..0f9df833a4c7f 100644 --- a/frame/root-offences/src/mock.rs +++ b/frame/root-offences/src/mock.rs @@ -27,14 +27,13 @@ use pallet_staking::StakerStatus; use sp_core::H256; use sp_runtime::{ curve::PiecewiseLinear, - testing::{Header, UintAuthorityId}, + testing::UintAuthorityId, traits::{BlakeTwo256, IdentityLookup, Zero}, BuildStorage, }; use sp_staking::{EraIndex, SessionIndex}; use sp_std::collections::btree_map::BTreeMap; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; type AccountId = u64; type Balance = u64; @@ -44,10 +43,7 @@ pub const INIT_TIMESTAMP: u64 = 30_000; pub const BLOCK_TIME: u64 = 1000; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, @@ -92,13 +88,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/salary/src/lib.rs b/frame/salary/src/lib.rs index 1279a30717752..53dd7224909a8 100644 --- a/frame/salary/src/lib.rs +++ b/frame/salary/src/lib.rs @@ -126,14 +126,14 @@ pub mod pallet { /// The number of blocks between sequential payout cycles is the sum of this and /// `PayoutPeriod`. #[pallet::constant] - type RegistrationPeriod: Get; + type RegistrationPeriod: Get>; /// The number of blocks within a cycle which accounts have to claim the payout. /// /// The number of blocks between sequential payout cycles is the sum of this and /// `RegistrationPeriod`. #[pallet::constant] - type PayoutPeriod: Get; + type PayoutPeriod: Get>; /// The total budget per cycle. /// @@ -142,11 +142,10 @@ pub mod pallet { type Budget: Get>; } - pub type CycleIndexOf = ::BlockNumber; + pub type CycleIndexOf = BlockNumberFor; pub type BalanceOf = <>::Paymaster as Pay>::Balance; pub type IdOf = <>::Paymaster as Pay>::Id; - pub type StatusOf = - StatusType, ::BlockNumber, BalanceOf>; + pub type StatusOf = StatusType, BlockNumberFor, BalanceOf>; pub type ClaimantStatusOf = ClaimantStatus, BalanceOf, IdOf>; /// The overall status of the system. @@ -389,7 +388,7 @@ pub mod pallet { pub fn last_active(who: &T::AccountId) -> Result, DispatchError> { Ok(Claimant::::get(&who).ok_or(Error::::NotInducted)?.last_active) } - pub fn cycle_period() -> T::BlockNumber { + pub fn cycle_period() -> BlockNumberFor { T::RegistrationPeriod::get() + T::PayoutPeriod::get() } fn do_payout(who: T::AccountId, beneficiary: T::AccountId) -> DispatchResult { diff --git a/frame/salary/src/tests.rs b/frame/salary/src/tests.rs index 7ffa819724ba1..9f63fb173214a 100644 --- a/frame/salary/src/tests.rs +++ b/frame/salary/src/tests.rs @@ -27,7 +27,6 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, Identity, IdentityLookup}, BuildStorage, DispatchResult, }; @@ -36,14 +35,10 @@ use sp_std::cell::RefCell; use super::*; use crate as pallet_salary; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Salary: pallet_salary::{Pallet, Call, Storage, Event}, @@ -61,13 +56,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/scheduler/src/benchmarking.rs b/frame/scheduler/src/benchmarking.rs index d56e007ec9a2a..b41cea449654c 100644 --- a/frame/scheduler/src/benchmarking.rs +++ b/frame/scheduler/src/benchmarking.rs @@ -23,7 +23,7 @@ use frame_support::{ ensure, traits::{schedule::Priority, BoundedInline}, }; -use frame_system::RawOrigin; +use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use sp_std::{prelude::*, vec}; use crate::Pallet as Scheduler; @@ -42,7 +42,10 @@ type SystemOrigin = ::RuntimeOrigin; /// - `None`: aborted (hash without preimage) /// - `Some(true)`: hash resolves into call if possible, plain call otherwise /// - `Some(false)`: plain call -fn fill_schedule(when: T::BlockNumber, n: u32) -> Result<(), &'static str> { +fn fill_schedule( + when: frame_system::pallet_prelude::BlockNumberFor, + n: u32, +) -> Result<(), &'static str> { let t = DispatchTime::At(when); let origin: ::PalletsOrigin = frame_system::RawOrigin::Root.into(); for i in 0..n { @@ -125,7 +128,7 @@ fn make_origin(signed: bool) -> ::PalletsOrigin { benchmarks! { // `service_agendas` when no work is done. service_agendas_base { - let now = T::BlockNumber::from(BLOCK_NUMBER); + let now = BlockNumberFor::::from(BLOCK_NUMBER); IncompleteSince::::put(now - One::one()); }: { Scheduler::::service_agendas(&mut WeightMeter::max_limit(), now, 0); @@ -224,7 +227,7 @@ benchmarks! { schedule { let s in 0 .. (T::MaxScheduledPerBlock::get() - 1); let when = BLOCK_NUMBER.into(); - let periodic = Some((T::BlockNumber::one(), 100)); + let periodic = Some((BlockNumberFor::::one(), 100)); let priority = 0; // Essentially a no-op call. let call = Box::new(SystemCall::set_storage { items: vec![] }.into()); @@ -267,7 +270,7 @@ benchmarks! { let s in 0 .. (T::MaxScheduledPerBlock::get() - 1); let id = u32_to_name(s); let when = BLOCK_NUMBER.into(); - let periodic = Some((T::BlockNumber::one(), 100)); + let periodic = Some((BlockNumberFor::::one(), 100)); let priority = 0; // Essentially a no-op call. let call = Box::new(SystemCall::set_storage { items: vec![] }.into()); diff --git a/frame/scheduler/src/lib.rs b/frame/scheduler/src/lib.rs index 8194f286c8323..4e12e0332f422 100644 --- a/frame/scheduler/src/lib.rs +++ b/frame/scheduler/src/lib.rs @@ -72,7 +72,10 @@ use frame_support::{ }, weights::{Weight, WeightMeter}, }; -use frame_system::{self as system}; +use frame_system::{ + pallet_prelude::BlockNumberFor, + {self as system}, +}; use scale_info::TypeInfo; use sp_io::hashing::blake2_256; use sp_runtime::{ @@ -123,7 +126,7 @@ use crate::{Scheduled as ScheduledV3, Scheduled as ScheduledV2}; pub type ScheduledV2Of = ScheduledV2< Vec, ::RuntimeCall, - ::BlockNumber, + BlockNumberFor, ::PalletsOrigin, ::AccountId, >; @@ -131,7 +134,7 @@ pub type ScheduledV2Of = ScheduledV2< pub type ScheduledV3Of = ScheduledV3< Vec, CallOrHashOf, - ::BlockNumber, + BlockNumberFor, ::PalletsOrigin, ::AccountId, >; @@ -139,7 +142,7 @@ pub type ScheduledV3Of = ScheduledV3< pub type ScheduledOf = Scheduled< TaskName, Bounded<::RuntimeCall>, - ::BlockNumber, + BlockNumberFor, ::PalletsOrigin, ::AccountId, >; @@ -231,14 +234,14 @@ pub mod pallet { } #[pallet::storage] - pub type IncompleteSince = StorageValue<_, T::BlockNumber>; + pub type IncompleteSince = StorageValue<_, BlockNumberFor>; /// Items to be executed, indexed by the block number that they should be executed on. #[pallet::storage] pub type Agenda = StorageMap< _, Twox64Concat, - T::BlockNumber, + BlockNumberFor, BoundedVec>, T::MaxScheduledPerBlock>, ValueQuery, >; @@ -249,28 +252,28 @@ pub mod pallet { /// identities. #[pallet::storage] pub(crate) type Lookup = - StorageMap<_, Twox64Concat, TaskName, TaskAddress>; + StorageMap<_, Twox64Concat, TaskName, TaskAddress>>; /// Events type. #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { /// Scheduled some task. - Scheduled { when: T::BlockNumber, index: u32 }, + Scheduled { when: BlockNumberFor, index: u32 }, /// Canceled some task. - Canceled { when: T::BlockNumber, index: u32 }, + Canceled { when: BlockNumberFor, index: u32 }, /// Dispatched some task. Dispatched { - task: TaskAddress, + task: TaskAddress>, id: Option, result: DispatchResult, }, /// The call for the provided hash was not found so the task has been aborted. - CallUnavailable { task: TaskAddress, id: Option }, + CallUnavailable { task: TaskAddress>, id: Option }, /// The given task was unable to be renewed since the agenda is full at that block. - PeriodicFailed { task: TaskAddress, id: Option }, + PeriodicFailed { task: TaskAddress>, id: Option }, /// The given task can never be executed since it is overweight. - PermanentlyOverweight { task: TaskAddress, id: Option }, + PermanentlyOverweight { task: TaskAddress>, id: Option }, } #[pallet::error] @@ -290,7 +293,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { /// Execute the scheduled calls - fn on_initialize(now: T::BlockNumber) -> Weight { + fn on_initialize(now: BlockNumberFor) -> Weight { let mut weight_counter = WeightMeter::from_limit(T::MaximumWeight::get()); Self::service_agendas(&mut weight_counter, now, u32::max_value()); weight_counter.consumed @@ -304,8 +307,8 @@ pub mod pallet { #[pallet::weight(::WeightInfo::schedule(T::MaxScheduledPerBlock::get()))] pub fn schedule( origin: OriginFor, - when: T::BlockNumber, - maybe_periodic: Option>, + when: BlockNumberFor, + maybe_periodic: Option>>, priority: schedule::Priority, call: Box<::RuntimeCall>, ) -> DispatchResult { @@ -324,7 +327,7 @@ pub mod pallet { /// Cancel an anonymously scheduled task. #[pallet::call_index(1)] #[pallet::weight(::WeightInfo::cancel(T::MaxScheduledPerBlock::get()))] - pub fn cancel(origin: OriginFor, when: T::BlockNumber, index: u32) -> DispatchResult { + pub fn cancel(origin: OriginFor, when: BlockNumberFor, index: u32) -> DispatchResult { T::ScheduleOrigin::ensure_origin(origin.clone())?; let origin = ::RuntimeOrigin::from(origin); Self::do_cancel(Some(origin.caller().clone()), (when, index))?; @@ -337,8 +340,8 @@ pub mod pallet { pub fn schedule_named( origin: OriginFor, id: TaskName, - when: T::BlockNumber, - maybe_periodic: Option>, + when: BlockNumberFor, + maybe_periodic: Option>>, priority: schedule::Priority, call: Box<::RuntimeCall>, ) -> DispatchResult { @@ -370,8 +373,8 @@ pub mod pallet { #[pallet::weight(::WeightInfo::schedule(T::MaxScheduledPerBlock::get()))] pub fn schedule_after( origin: OriginFor, - after: T::BlockNumber, - maybe_periodic: Option>, + after: BlockNumberFor, + maybe_periodic: Option>>, priority: schedule::Priority, call: Box<::RuntimeCall>, ) -> DispatchResult { @@ -393,8 +396,8 @@ pub mod pallet { pub fn schedule_named_after( origin: OriginFor, id: TaskName, - after: T::BlockNumber, - maybe_periodic: Option>, + after: BlockNumberFor, + maybe_periodic: Option>>, priority: schedule::Priority, call: Box<::RuntimeCall>, ) -> DispatchResult { @@ -434,7 +437,7 @@ impl> Pallet { } Agenda::::translate::< - Vec::RuntimeCall, T::BlockNumber>>>, + Vec::RuntimeCall, BlockNumberFor>>>, _, >(|_, agenda| { Some(BoundedVec::truncate_from( @@ -669,7 +672,7 @@ impl Pallet { Scheduled< TaskName, Bounded<::RuntimeCall>, - T::BlockNumber, + BlockNumberFor, OldOrigin, T::AccountId, >, @@ -695,7 +698,9 @@ impl Pallet { }); } - fn resolve_time(when: DispatchTime) -> Result { + fn resolve_time( + when: DispatchTime>, + ) -> Result, DispatchError> { let now = frame_system::Pallet::::block_number(); let when = match when { @@ -713,9 +718,9 @@ impl Pallet { } fn place_task( - when: T::BlockNumber, + when: BlockNumberFor, what: ScheduledOf, - ) -> Result, (DispatchError, ScheduledOf)> { + ) -> Result>, (DispatchError, ScheduledOf)> { let maybe_name = what.maybe_id; let index = Self::push_to_agenda(when, what)?; let address = (when, index); @@ -727,7 +732,7 @@ impl Pallet { } fn push_to_agenda( - when: T::BlockNumber, + when: BlockNumberFor, what: ScheduledOf, ) -> Result)> { let mut agenda = Agenda::::get(when); @@ -749,7 +754,7 @@ impl Pallet { /// Remove trailing `None` items of an agenda at `when`. If all items are `None` remove the /// agenda record entirely. - fn cleanup_agenda(when: T::BlockNumber) { + fn cleanup_agenda(when: BlockNumberFor) { let mut agenda = Agenda::::get(when); match agenda.iter().rposition(|i| i.is_some()) { Some(i) if agenda.len() > i + 1 => { @@ -764,12 +769,12 @@ impl Pallet { } fn do_schedule( - when: DispatchTime, - maybe_periodic: Option>, + when: DispatchTime>, + maybe_periodic: Option>>, priority: schedule::Priority, origin: T::PalletsOrigin, call: Bounded<::RuntimeCall>, - ) -> Result, DispatchError> { + ) -> Result>, DispatchError> { let when = Self::resolve_time(when)?; let lookup_hash = call.lookup_hash(); @@ -799,7 +804,7 @@ impl Pallet { fn do_cancel( origin: Option, - (when, index): TaskAddress, + (when, index): TaskAddress>, ) -> Result<(), DispatchError> { let scheduled = Agenda::::try_mutate(when, |agenda| { agenda.get_mut(index as usize).map_or( @@ -831,9 +836,9 @@ impl Pallet { } fn do_reschedule( - (when, index): TaskAddress, - new_time: DispatchTime, - ) -> Result, DispatchError> { + (when, index): TaskAddress>, + new_time: DispatchTime>, + ) -> Result>, DispatchError> { let new_time = Self::resolve_time(new_time)?; if new_time == when { @@ -853,12 +858,12 @@ impl Pallet { fn do_schedule_named( id: TaskName, - when: DispatchTime, - maybe_periodic: Option>, + when: DispatchTime>, + maybe_periodic: Option>>, priority: schedule::Priority, origin: T::PalletsOrigin, call: Bounded<::RuntimeCall>, - ) -> Result, DispatchError> { + ) -> Result>, DispatchError> { // ensure id it is unique if Lookup::::contains_key(&id) { return Err(Error::::FailedToSchedule.into()) @@ -922,8 +927,8 @@ impl Pallet { fn do_reschedule_named( id: TaskName, - new_time: DispatchTime, - ) -> Result, DispatchError> { + new_time: DispatchTime>, + ) -> Result>, DispatchError> { let new_time = Self::resolve_time(new_time)?; let lookup = Lookup::::get(id); @@ -953,7 +958,7 @@ use ServiceTaskError::*; impl Pallet { /// Service up to `max` agendas queue starting from earliest incompletely executed agenda. - fn service_agendas(weight: &mut WeightMeter, now: T::BlockNumber, max: u32) { + fn service_agendas(weight: &mut WeightMeter, now: BlockNumberFor, max: u32) { if !weight.check_accrue(T::WeightInfo::service_agendas_base()) { return } @@ -983,8 +988,8 @@ impl Pallet { fn service_agenda( weight: &mut WeightMeter, executed: &mut u32, - now: T::BlockNumber, - when: T::BlockNumber, + now: BlockNumberFor, + when: BlockNumberFor, max: u32, ) -> bool { let mut agenda = Agenda::::get(when); @@ -1052,8 +1057,8 @@ impl Pallet { /// - Rescheduling the task for execution in a later agenda if periodic. fn service_task( weight: &mut WeightMeter, - now: T::BlockNumber, - when: T::BlockNumber, + now: BlockNumberFor, + when: BlockNumberFor, agenda_index: u32, is_first: bool, mut task: ScheduledOf, @@ -1161,14 +1166,14 @@ impl Pallet { } impl> - schedule::v2::Anon::RuntimeCall, T::PalletsOrigin> for Pallet + schedule::v2::Anon, ::RuntimeCall, T::PalletsOrigin> for Pallet { - type Address = TaskAddress; + type Address = TaskAddress>; type Hash = T::Hash; fn schedule( - when: DispatchTime, - maybe_periodic: Option>, + when: DispatchTime>, + maybe_periodic: Option>>, priority: schedule::Priority, origin: T::PalletsOrigin, call: CallOrHashOf, @@ -1184,26 +1189,26 @@ impl> fn reschedule( address: Self::Address, - when: DispatchTime, + when: DispatchTime>, ) -> Result { Self::do_reschedule(address, when) } - fn next_dispatch_time((when, index): Self::Address) -> Result { + fn next_dispatch_time((when, index): Self::Address) -> Result, ()> { Agenda::::get(when).get(index as usize).ok_or(()).map(|_| when) } } impl> - schedule::v2::Named::RuntimeCall, T::PalletsOrigin> for Pallet + schedule::v2::Named, ::RuntimeCall, T::PalletsOrigin> for Pallet { - type Address = TaskAddress; + type Address = TaskAddress>; type Hash = T::Hash; fn schedule_named( id: Vec, - when: DispatchTime, - maybe_periodic: Option>, + when: DispatchTime>, + maybe_periodic: Option>>, priority: schedule::Priority, origin: T::PalletsOrigin, call: CallOrHashOf, @@ -1221,13 +1226,13 @@ impl> fn reschedule_named( id: Vec, - when: DispatchTime, + when: DispatchTime>, ) -> Result { let name = blake2_256(&id[..]); Self::do_reschedule_named(name, when) } - fn next_dispatch_time(id: Vec) -> Result { + fn next_dispatch_time(id: Vec) -> Result, ()> { let name = blake2_256(&id[..]); Lookup::::get(name) .and_then(|(when, index)| Agenda::::get(when).get(index as usize).map(|_| when)) @@ -1235,14 +1240,14 @@ impl> } } -impl schedule::v3::Anon::RuntimeCall, T::PalletsOrigin> +impl schedule::v3::Anon, ::RuntimeCall, T::PalletsOrigin> for Pallet { - type Address = TaskAddress; + type Address = TaskAddress>; fn schedule( - when: DispatchTime, - maybe_periodic: Option>, + when: DispatchTime>, + maybe_periodic: Option>>, priority: schedule::Priority, origin: T::PalletsOrigin, call: Bounded<::RuntimeCall>, @@ -1256,12 +1261,14 @@ impl schedule::v3::Anon::RuntimeCall, T fn reschedule( address: Self::Address, - when: DispatchTime, + when: DispatchTime>, ) -> Result { Self::do_reschedule(address, when).map_err(map_err_to_v3_err::) } - fn next_dispatch_time((when, index): Self::Address) -> Result { + fn next_dispatch_time( + (when, index): Self::Address, + ) -> Result, DispatchError> { Agenda::::get(when) .get(index as usize) .ok_or(DispatchError::Unavailable) @@ -1271,15 +1278,15 @@ impl schedule::v3::Anon::RuntimeCall, T use schedule::v3::TaskName; -impl schedule::v3::Named::RuntimeCall, T::PalletsOrigin> +impl schedule::v3::Named, ::RuntimeCall, T::PalletsOrigin> for Pallet { - type Address = TaskAddress; + type Address = TaskAddress>; fn schedule_named( id: TaskName, - when: DispatchTime, - maybe_periodic: Option>, + when: DispatchTime>, + maybe_periodic: Option>>, priority: schedule::Priority, origin: T::PalletsOrigin, call: Bounded<::RuntimeCall>, @@ -1293,12 +1300,12 @@ impl schedule::v3::Named::RuntimeCall, fn reschedule_named( id: TaskName, - when: DispatchTime, + when: DispatchTime>, ) -> Result { Self::do_reschedule_named(id, when).map_err(map_err_to_v3_err::) } - fn next_dispatch_time(id: TaskName) -> Result { + fn next_dispatch_time(id: TaskName) -> Result, DispatchError> { Lookup::::get(id) .and_then(|(when, index)| Agenda::::get(when).get(index as usize).map(|_| when)) .ok_or(DispatchError::Unavailable) diff --git a/frame/scheduler/src/migration.rs b/frame/scheduler/src/migration.rs index 78313fda66412..06259768f0aa1 100644 --- a/frame/scheduler/src/migration.rs +++ b/frame/scheduler/src/migration.rs @@ -19,6 +19,7 @@ use super::*; use frame_support::traits::OnRuntimeUpgrade; +use frame_system::pallet_prelude::BlockNumberFor; #[cfg(feature = "try-runtime")] use sp_runtime::TryRuntimeError; @@ -34,22 +35,14 @@ pub mod v1 { pub(crate) type Agenda = StorageMap< Pallet, Twox64Concat, - ::BlockNumber, - Vec< - Option< - ScheduledV1<::RuntimeCall, ::BlockNumber>, - >, - >, + BlockNumberFor, + Vec::RuntimeCall, BlockNumberFor>>>, ValueQuery, >; #[frame_support::storage_alias] - pub(crate) type Lookup = StorageMap< - Pallet, - Twox64Concat, - Vec, - TaskAddress<::BlockNumber>, - >; + pub(crate) type Lookup = + StorageMap, Twox64Concat, Vec, TaskAddress>>; } pub mod v2 { @@ -60,18 +53,14 @@ pub mod v2 { pub(crate) type Agenda = StorageMap< Pallet, Twox64Concat, - ::BlockNumber, + BlockNumberFor, Vec>>, ValueQuery, >; #[frame_support::storage_alias] - pub(crate) type Lookup = StorageMap< - Pallet, - Twox64Concat, - Vec, - TaskAddress<::BlockNumber>, - >; + pub(crate) type Lookup = + StorageMap, Twox64Concat, Vec, TaskAddress>>; } pub mod v3 { @@ -82,18 +71,14 @@ pub mod v3 { pub(crate) type Agenda = StorageMap< Pallet, Twox64Concat, - ::BlockNumber, + BlockNumberFor, Vec>>, ValueQuery, >; #[frame_support::storage_alias] - pub(crate) type Lookup = StorageMap< - Pallet, - Twox64Concat, - Vec, - TaskAddress<::BlockNumber>, - >; + pub(crate) type Lookup = + StorageMap, Twox64Concat, Vec, TaskAddress>>; /// Migrate the scheduler pallet from V3 to V4. pub struct MigrateToV4(sp_std::marker::PhantomData); diff --git a/frame/scheduler/src/mock.rs b/frame/scheduler/src/mock.rs index 7a98d8e0db1c6..f6dd554866be8 100644 --- a/frame/scheduler/src/mock.rs +++ b/frame/scheduler/src/mock.rs @@ -30,7 +30,6 @@ use frame_support::{ use frame_system::{EnsureRoot, EnsureSignedBy}; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, Perbill, }; @@ -93,14 +92,10 @@ pub mod logger { } } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Logger: logger::{Pallet, Call, Event}, @@ -131,12 +126,11 @@ impl system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/scored-pool/src/lib.rs b/frame/scored-pool/src/lib.rs index 6aa64ea64abf0..2bf70cbc574c8 100644 --- a/frame/scored-pool/src/lib.rs +++ b/frame/scored-pool/src/lib.rs @@ -170,7 +170,7 @@ pub mod pallet { /// Every `Period` blocks the `Members` are filled with the highest scoring /// members in the `Pool`. #[pallet::constant] - type Period: Get; + type Period: Get>; /// The receiver of the signal for when the membership has been initialized. /// This happens pre-genesis and will usually be the same as `MembershipChanged`. @@ -282,7 +282,7 @@ pub mod pallet { impl, I: 'static> Hooks> for Pallet { /// Every `Period` blocks the `Members` set is refreshed from the /// highest scoring members in the pool. - fn on_initialize(n: T::BlockNumber) -> Weight { + fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { if n % T::Period::get() == Zero::zero() { let pool = >::get(); >::refresh_members(pool, ChangeReceiver::MembershipChanged); diff --git a/frame/scored-pool/src/mock.rs b/frame/scored-pool/src/mock.rs index e6cfea1bfb281..8cbb0eae4b613 100644 --- a/frame/scored-pool/src/mock.rs +++ b/frame/scored-pool/src/mock.rs @@ -27,19 +27,14 @@ use frame_support::{ use frame_system::EnsureSignedBy; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -62,13 +57,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/session/benchmarking/src/lib.rs b/frame/session/benchmarking/src/lib.rs index a7e326fb27ac3..f27136e820d41 100644 --- a/frame/session/benchmarking/src/lib.rs +++ b/frame/session/benchmarking/src/lib.rs @@ -31,7 +31,7 @@ use frame_support::{ codec::Decode, traits::{Get, KeyOwnerProofSystem, OnInitialize}, }; -use frame_system::RawOrigin; +use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use pallet_session::{historical::Pallet as Historical, Pallet as Session, *}; use pallet_staking::{ benchmarking::create_validator_with_nominators, testing_utils::create_validators, @@ -46,8 +46,8 @@ pub trait Config: { } -impl OnInitialize for Pallet { - fn on_initialize(n: T::BlockNumber) -> frame_support::weights::Weight { +impl OnInitialize> for Pallet { + fn on_initialize(n: BlockNumberFor) -> frame_support::weights::Weight { pallet_session::Pallet::::on_initialize(n) } } @@ -156,7 +156,7 @@ fn check_membership_proof_setup( Session::::set_keys(RawOrigin::Signed(controller).into(), keys, proof).unwrap(); } - Pallet::::on_initialize(T::BlockNumber::one()); + Pallet::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::one()); // skip sessions until the new validator set is enacted while Session::::validators().len() < n as usize { diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index 67c1d95f4707d..d8bc4ba9c27ab 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -28,17 +28,12 @@ use sp_runtime::{traits::IdentityLookup, BuildStorage}; type AccountId = u64; type AccountIndex = u32; -type BlockNumber = u64; type Balance = u64; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -54,13 +49,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = AccountIndex; - type BlockNumber = BlockNumber; type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); diff --git a/frame/session/src/lib.rs b/frame/session/src/lib.rs index d1d6296e65730..d2b1c2b744674 100644 --- a/frame/session/src/lib.rs +++ b/frame/session/src/lib.rs @@ -126,6 +126,7 @@ use frame_support::{ weights::Weight, Parameter, }; +use frame_system::pallet_prelude::BlockNumberFor; use sp_runtime::{ traits::{AtLeast32BitUnsigned, Convert, Member, One, OpaqueKeys, Zero}, ConsensusEngineId, KeyTypeId, Permill, RuntimeAppPublic, @@ -393,12 +394,12 @@ pub mod pallet { type ValidatorIdOf: Convert>; /// Indicator for when to end the session. - type ShouldEndSession: ShouldEndSession; + type ShouldEndSession: ShouldEndSession>; /// Something that can predict the next session rotation. This should typically come from /// the same logical unit that provides [`ShouldEndSession`], yet, it gives a best effort /// estimate. It is helpful to implement [`EstimateNextNewSession`]. - type NextSessionRotation: EstimateNextSessionRotation; + type NextSessionRotation: EstimateNextSessionRotation>; /// Handler for managing new session. type SessionManager: SessionManager; @@ -559,7 +560,7 @@ pub mod pallet { impl Hooks> for Pallet { /// Called when a block is initialized. Will rotate session if it is the last /// block of the current session. - fn on_initialize(n: T::BlockNumber) -> Weight { + fn on_initialize(n: BlockNumberFor) -> Weight { if T::ShouldEndSession::should_end_session(n) { Self::rotate_session(); T::BlockWeights::get().max_block @@ -901,14 +902,14 @@ impl ValidatorSet for Pallet { } } -impl EstimateNextNewSession for Pallet { - fn average_session_length() -> T::BlockNumber { +impl EstimateNextNewSession> for Pallet { + fn average_session_length() -> BlockNumberFor { T::NextSessionRotation::average_session_length() } /// This session pallet always calls new_session and next_session at the same time, hence we /// do a simple proxy and pass the function to next rotation. - fn estimate_next_new_session(now: T::BlockNumber) -> (Option, Weight) { + fn estimate_next_new_session(now: BlockNumberFor) -> (Option>, Weight) { T::NextSessionRotation::estimate_next_session_rotation(now) } } diff --git a/frame/session/src/mock.rs b/frame/session/src/mock.rs index 3d74c32dcdb25..58d1d30a050ac 100644 --- a/frame/session/src/mock.rs +++ b/frame/session/src/mock.rs @@ -27,7 +27,7 @@ use std::collections::BTreeMap; use sp_core::{crypto::key_types::DUMMY, H256}; use sp_runtime::{ impl_opaque_keys, - testing::{Header, UintAuthorityId}, + testing::UintAuthorityId, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; @@ -76,15 +76,11 @@ impl OpaqueKeys for PreUpgradeMockSessionKeys { } } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; #[cfg(feature = "historical")] frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Session: pallet_session::{Pallet, Call, Storage, Event, Config}, @@ -94,10 +90,7 @@ frame_support::construct_runtime!( #[cfg(not(feature = "historical"))] frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Session: pallet_session::{Pallet, Call, Storage, Event, Config}, @@ -246,13 +239,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/society/src/lib.rs b/frame/society/src/lib.rs index 3d4b9323246d8..ca8d96e193c84 100644 --- a/frame/society/src/lib.rs +++ b/frame/society/src/lib.rs @@ -416,10 +416,8 @@ impl BidKind { } } -pub type PayoutsFor = BoundedVec< - (::BlockNumber, BalanceOf), - >::MaxPayouts, ->; +pub type PayoutsFor = + BoundedVec<(BlockNumberFor, BalanceOf), >::MaxPayouts>; /// Information concerning a member. #[derive(Encode, Decode, Copy, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)] @@ -439,10 +437,7 @@ pub struct PayoutRecord { pub type PayoutRecordFor = PayoutRecord< BalanceOf, - BoundedVec< - (::BlockNumber, BalanceOf), - >::MaxPayouts, - >, + BoundedVec<(BlockNumberFor, BalanceOf), >::MaxPayouts>, >; /// Record for an individual new member who was elevated from a candidate recently. @@ -491,7 +486,7 @@ pub mod pallet { type Currency: ReservableCurrency; /// Something that provides randomness in the runtime. - type Randomness: Randomness; + type Randomness: Randomness>; /// The maximum number of strikes before a member gets funds slashed. #[pallet::constant] @@ -504,23 +499,23 @@ pub mod pallet { /// The number of blocks on which new candidates should be voted on. Together with /// `ClaimPeriod`, this sums to the number of blocks between candidate intake periods. #[pallet::constant] - type VotingPeriod: Get; + type VotingPeriod: Get>; /// The number of blocks on which new candidates can claim their membership and be the /// named head. #[pallet::constant] - type ClaimPeriod: Get; + type ClaimPeriod: Get>; /// The maximum duration of the payout lock. #[pallet::constant] - type MaxLockDuration: Get; + type MaxLockDuration: Get>; /// The origin that is allowed to call `found`. type FounderSetOrigin: EnsureOrigin; /// The number of blocks between membership challenges. #[pallet::constant] - type ChallengePeriod: Get; + type ChallengePeriod: Get>; /// The maximum number of payouts a member may have waiting unclaimed. #[pallet::constant] @@ -758,7 +753,7 @@ pub mod pallet { #[pallet::hooks] impl, I: 'static> Hooks> for Pallet { - fn on_initialize(n: T::BlockNumber) -> Weight { + fn on_initialize(n: BlockNumberFor) -> Weight { let mut weight = Weight::zero(); let weights = T::BlockWeights::get(); @@ -1409,7 +1404,7 @@ pub enum Period { impl, I: 'static> Pallet { /// Get the period we are currently in. - fn period() -> Period { + fn period() -> Period> { let claim_period = T::ClaimPeriod::get(); let voting_period = T::VotingPeriod::get(); let rotation_period = voting_period + claim_period; @@ -1902,7 +1897,7 @@ impl, I: 'static> Pallet { candidate: &T::AccountId, value: BalanceOf, kind: BidKind>, - maturity: T::BlockNumber, + maturity: BlockNumberFor, ) { let value = match kind { BidKind::Deposit(deposit) => { @@ -1939,7 +1934,7 @@ impl, I: 'static> Pallet { /// /// It is the caller's duty to ensure that `who` is already a member. This does nothing if `who` /// is not a member or if `value` is zero. - fn bump_payout(who: &T::AccountId, when: T::BlockNumber, value: BalanceOf) { + fn bump_payout(who: &T::AccountId, when: BlockNumberFor, value: BalanceOf) { if value.is_zero() { return } @@ -2022,7 +2017,7 @@ impl, I: 'static> Pallet { /// /// This is a rather opaque calculation based on the formula here: /// https://www.desmos.com/calculator/9itkal1tce - fn lock_duration(x: u32) -> T::BlockNumber { + fn lock_duration(x: u32) -> BlockNumberFor { let lock_pc = 100 - 50_000 / (x + 500); Percent::from_percent(lock_pc as u8) * T::MaxLockDuration::get() } diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index 404b1e5fd2cb9..4685167dcbcfd 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -172,7 +172,7 @@ pub(crate) mod old { Pallet, Twox64Concat, ::AccountId, - Vec<(::BlockNumber, BalanceOf)>, + Vec<(frame_system::pallet_prelude::BlockNumberFor, BalanceOf)>, ValueQuery, >; #[storage_alias] diff --git a/frame/society/src/mock.rs b/frame/society/src/mock.rs index 1b215febac6c0..b9a283ead3c66 100644 --- a/frame/society/src/mock.rs +++ b/frame/society/src/mock.rs @@ -28,21 +28,16 @@ use frame_support_test::TestRandomness; use frame_system::EnsureSignedBy; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; use RuntimeOrigin as Origin; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -70,13 +65,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u128; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 2a5edd6e00e56..025c5c61fcbb7 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -32,7 +32,7 @@ use sp_core::H256; use sp_io; use sp_runtime::{ curve::PiecewiseLinear, - testing::{Header, UintAuthorityId}, + testing::UintAuthorityId, traits::{IdentityLookup, Zero}, BuildStorage, }; @@ -83,14 +83,10 @@ pub fn is_disabled(controller: AccountId) -> bool { Session::disabled_validators().contains(&validator_index) } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Authorship: pallet_authorship, @@ -129,13 +125,12 @@ impl frame_system::Config for Test { type DbWeight = RocksDbWeight; type RuntimeOrigin = RuntimeOrigin; type Index = AccountIndex; - type BlockNumber = BlockNumber; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU64<250>; type Version = (); diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 5166608a97aab..f2aa48e3316da 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -1022,7 +1022,7 @@ impl ElectionDataProvider for Pallet { Ok(Self::get_npos_targets(None)) } - fn next_election_prediction(now: T::BlockNumber) -> T::BlockNumber { + fn next_election_prediction(now: BlockNumberFor) -> BlockNumberFor { let current_era = Self::current_era().unwrap_or(0); let current_session = Self::current_planned_session(); let current_era_start_session_index = @@ -1039,7 +1039,7 @@ impl ElectionDataProvider for Pallet { let session_length = T::NextNewSession::average_session_length(); - let sessions_left: T::BlockNumber = match ForceEra::::get() { + let sessions_left: BlockNumberFor = match ForceEra::::get() { Forcing::ForceNone => Bounded::max_value(), Forcing::ForceNew | Forcing::ForceAlways => Zero::zero(), Forcing::NotForcing if era_progress >= T::SessionsPerEra::get() => Zero::zero(), @@ -1238,7 +1238,7 @@ impl historical::SessionManager pallet_authorship::EventHandler for Pallet +impl pallet_authorship::EventHandler> for Pallet where T: Config + pallet_authorship::Config + pallet_session::Config, { diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index 41b8d4b415e1a..dfca6fec3a8f5 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -87,7 +87,7 @@ pub mod pallet { /// The staking balance. type Currency: LockableCurrency< Self::AccountId, - Moment = Self::BlockNumber, + Moment = BlockNumberFor, Balance = Self::CurrencyBalance, >; /// Just the `Currency::Balance` type; we have this item to allow us to constrain it to @@ -118,14 +118,14 @@ pub mod pallet { /// Something that provides the election functionality. type ElectionProvider: ElectionProvider< AccountId = Self::AccountId, - BlockNumber = Self::BlockNumber, + BlockNumber = BlockNumberFor, // we only accept an election provider that has staking as data provider. DataProvider = Pallet, >; /// Something that provides the election functionality at genesis. type GenesisElectionProvider: ElectionProvider< AccountId = Self::AccountId, - BlockNumber = Self::BlockNumber, + BlockNumber = BlockNumberFor, DataProvider = Pallet, >; @@ -200,7 +200,7 @@ pub mod pallet { /// Something that can estimate the next session change, accurately or as a best effort /// guess. - type NextNewSession: EstimateNextNewSession; + type NextNewSession: EstimateNextNewSession>; /// The maximum number of nominators rewarded for each validator. /// diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index c7d4924de1fb9..40783482ad52e 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -1065,15 +1065,11 @@ mod mock { BuildStorage, StorageChild, }; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; - type Block = frame_system::mocking::MockBlock; + type Block = frame_system::mocking::MockBlockU32; // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Config, Storage, Event}, @@ -1092,12 +1088,11 @@ mod mock { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u32; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = sp_runtime::generic::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU32<250>; type DbWeight = (); @@ -1619,7 +1614,7 @@ pub(crate) mod remote_tests { traits::{Get, Hooks}, weights::Weight, }; - use frame_system::Pallet as System; + use frame_system::{pallet_prelude::BlockNumberFor, Pallet as System}; use remote_externalities::Mode; use sp_core::H256; use sp_runtime::{ @@ -1630,7 +1625,7 @@ pub(crate) mod remote_tests { #[allow(dead_code)] fn run_to_block>( - n: ::BlockNumber, + n: BlockNumberFor, ) -> (H256, Weight) { let mut root = Default::default(); let mut weight_sum = Weight::zero(); @@ -1670,7 +1665,7 @@ pub(crate) mod remote_tests { frame_system::Pallet::::block_number() }); - let mut duration: ::BlockNumber = Zero::zero(); + let mut duration: BlockNumberFor = Zero::zero(); // set the version to 1, as if the upgrade happened. ext.state_version = sp_core::storage::StateVersion::V1; diff --git a/frame/statement/src/mock.rs b/frame/statement/src/mock.rs index f2e81b7719021..bea06a68c0d38 100644 --- a/frame/statement/src/mock.rs +++ b/frame/statement/src/mock.rs @@ -27,12 +27,10 @@ use frame_support::{ }; use sp_core::{Pair, H256}; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, AccountId32, BuildStorage, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; pub const MIN_ALLOWED_STATEMENTS: u32 = 4; @@ -41,10 +39,7 @@ pub const MIN_ALLOWED_BYTES: u32 = 1024; pub const MAX_ALLOWED_BYTES: u32 = 4096; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Balances: pallet_balances, @@ -60,12 +55,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId32; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/sudo/src/mock.rs b/frame/sudo/src/mock.rs index 4854b006e19d8..5423f99599c03 100644 --- a/frame/sudo/src/mock.rs +++ b/frame/sudo/src/mock.rs @@ -23,7 +23,6 @@ use frame_support::traits::{ConstU32, ConstU64, Contains}; use sp_core::H256; use sp_io; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; @@ -91,14 +90,10 @@ pub mod logger { pub(super) type I32Log = StorageValue<_, BoundedVec>, ValueQuery>; } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Sudo: sudo::{Pallet, Call, Config, Storage, Event}, @@ -121,12 +116,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/support/procedural/src/construct_runtime/expand/inherent.rs b/frame/support/procedural/src/construct_runtime/expand/inherent.rs index 8218f3746e2c3..1dc51d9cd2bc4 100644 --- a/frame/support/procedural/src/construct_runtime/expand/inherent.rs +++ b/frame/support/procedural/src/construct_runtime/expand/inherent.rs @@ -19,12 +19,12 @@ use crate::construct_runtime::Pallet; use proc_macro2::TokenStream; use quote::quote; use std::str::FromStr; -use syn::{Ident, TypePath}; +use syn::Ident; pub fn expand_outer_inherent( runtime: &Ident, - block: &TypePath, - unchecked_extrinsic: &TypePath, + block: &TokenStream, + unchecked_extrinsic: &TokenStream, pallet_decls: &[Pallet], scrate: &TokenStream, ) -> TokenStream { diff --git a/frame/support/procedural/src/construct_runtime/expand/metadata.rs b/frame/support/procedural/src/construct_runtime/expand/metadata.rs index 3f88d8c6d1353..0975fedb35d5b 100644 --- a/frame/support/procedural/src/construct_runtime/expand/metadata.rs +++ b/frame/support/procedural/src/construct_runtime/expand/metadata.rs @@ -19,13 +19,13 @@ use crate::construct_runtime::{parse::PalletPath, Pallet}; use proc_macro2::TokenStream; use quote::quote; use std::str::FromStr; -use syn::{Ident, TypePath}; +use syn::Ident; pub fn expand_runtime_metadata( runtime: &Ident, pallet_declarations: &[Pallet], scrate: &TokenStream, - extrinsic: &TypePath, + extrinsic: &TokenStream, system_path: &PalletPath, ) -> TokenStream { let pallets = pallet_declarations diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index 203d43ab3cc39..efc2244154479 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -216,10 +216,7 @@ use frame_support_procedural_tools::{ generate_crate_access, generate_crate_access_2018, generate_hidden_includes, }; use itertools::Itertools; -use parse::{ - ExplicitRuntimeDeclaration, ImplicitRuntimeDeclaration, Pallet, RuntimeDeclaration, - WhereSection, -}; +use parse::{ExplicitRuntimeDeclaration, ImplicitRuntimeDeclaration, Pallet, RuntimeDeclaration}; use proc_macro::TokenStream; use proc_macro2::TokenStream as TokenStream2; use quote::quote; @@ -337,19 +334,14 @@ fn construct_runtime_explicit_to_explicit_expanded( fn construct_runtime_final_expansion( definition: ExplicitRuntimeDeclaration, ) -> Result { - let ExplicitRuntimeDeclaration { - name, - where_section: WhereSection { block, node_block, unchecked_extrinsic }, - pallets, - pallets_token, - } = definition; + let ExplicitRuntimeDeclaration { name, pallets, pallets_token, where_section } = definition; let system_pallet = pallets.iter().find(|decl| decl.name == SYSTEM_PALLET_NAME).ok_or_else(|| { syn::Error::new( pallets_token.span.join(), "`System` pallet declaration is missing. \ - Please add this line: `System: frame_system::{Pallet, Call, Storage, Config, Event},`", + Please add this line: `System: frame_system::{Pallet, Call, Storage, Config, Event},`", ) })?; if !system_pallet.cfg_pattern.is_empty() { @@ -379,6 +371,10 @@ fn construct_runtime_final_expansion( let scrate = generate_crate_access(hidden_crate_name, "frame-support"); let scrate_decl = generate_hidden_includes(hidden_crate_name, "frame-support"); + let frame_system = generate_crate_access_2018("frame-system")?; + let block = quote!(<#name as #frame_system::Config>::Block); + let unchecked_extrinsic = quote!(<#block as #scrate::sp_runtime::traits::Block>::Extrinsic); + let outer_event = expand::expand_outer_enum(&name, &pallets, &scrate, expand::OuterEnumType::Event)?; let outer_error = @@ -407,7 +403,21 @@ fn construct_runtime_final_expansion( let integrity_test = decl_integrity_test(&scrate); let static_assertions = decl_static_assertions(&name, &pallets, &scrate); + let warning = + where_section.map_or(None, |where_section| { + Some(proc_macro_warning::Warning::new_deprecated("WhereSection") + .old("use a `where` clause in `construct_runtime`") + .new("use `frame_system::Config` to set the `Block` type and delete this clause. + It is planned to be removed in December 2023") + .help_links(&["https://github.com/paritytech/substrate/pull/14437"]) + .span(where_section.span) + .build(), + ) + }); + let res = quote!( + #warning + #scrate_decl // Prevent UncheckedExtrinsic to print unused warning. @@ -421,9 +431,6 @@ fn construct_runtime_final_expansion( #scrate::scale_info::TypeInfo )] pub struct #name; - impl #scrate::sp_runtime::traits::GetNodeBlockType for #name { - type NodeBlock = #node_block; - } impl #scrate::sp_runtime::traits::GetRuntimeBlockType for #name { type RuntimeBlock = #block; } diff --git a/frame/support/procedural/src/construct_runtime/parse.rs b/frame/support/procedural/src/construct_runtime/parse.rs index b731bb0c83e27..9b08e16469754 100644 --- a/frame/support/procedural/src/construct_runtime/parse.rs +++ b/frame/support/procedural/src/construct_runtime/parse.rs @@ -65,7 +65,7 @@ pub enum RuntimeDeclaration { #[derive(Debug)] pub struct ImplicitRuntimeDeclaration { pub name: Ident, - pub where_section: WhereSection, + pub where_section: Option, pub pallets: Vec, } @@ -73,7 +73,7 @@ pub struct ImplicitRuntimeDeclaration { #[derive(Debug)] pub struct ExplicitRuntimeDeclaration { pub name: Ident, - pub where_section: WhereSection, + pub where_section: Option, pub pallets: Vec, pub pallets_token: token::Brace, } @@ -90,7 +90,7 @@ impl Parse for RuntimeDeclaration { } let name = input.parse::()?; - let where_section = input.parse()?; + let where_section = if input.peek(token::Where) { Some(input.parse()?) } else { None }; let pallets = input.parse::>>()?; let pallets_token = pallets.token; @@ -122,6 +122,7 @@ impl Parse for RuntimeDeclaration { #[derive(Debug)] pub struct WhereSection { + pub span: Span, pub block: syn::TypePath, pub node_block: syn::TypePath, pub unchecked_extrinsic: syn::TypePath, @@ -130,6 +131,7 @@ pub struct WhereSection { impl Parse for WhereSection { fn parse(input: ParseStream) -> Result { input.parse::()?; + let mut definitions = Vec::new(); while !input.peek(token::Brace) { let definition: WhereDefinition = input.parse()?; @@ -153,7 +155,7 @@ impl Parse for WhereSection { ); return Err(Error::new(*kind_span, msg)) } - Ok(Self { block, node_block, unchecked_extrinsic }) + Ok(Self { span: input.span(), block, node_block, unchecked_extrinsic }) } } diff --git a/frame/support/procedural/src/lib.rs b/frame/support/procedural/src/lib.rs index ca82a7971aca0..570f079db82f4 100644 --- a/frame/support/procedural/src/lib.rs +++ b/frame/support/procedural/src/lib.rs @@ -856,7 +856,7 @@ pub fn storage_alias(_: TokenStream, input: TokenStream) -> TokenStream { /// type RuntimeOrigin = RuntimeOrigin; /// type OnSetCode = (); /// type PalletInfo = PalletInfo; -/// type Header = Header; +/// type Block = Block; /// // We decide to override this one. /// type AccountData = pallet_balances::AccountData; /// } @@ -902,7 +902,7 @@ pub fn storage_alias(_: TokenStream, input: TokenStream) -> TokenStream { /// type RuntimeOrigin = RuntimeOrigin; /// type OnSetCode = (); /// type PalletInfo = PalletInfo; -/// type Header = Header; +/// type Block = Block; /// type AccountData = pallet_balances::AccountData; /// type Version = ::Version; /// type BlockWeights = ::BlockWeights; @@ -1559,7 +1559,7 @@ pub fn unbounded(_: TokenStream, _: TokenStream) -> TokenStream { /// ```ignore /// #[pallet::storage] /// #[pallet::whitelist_storage] -/// pub(super) type Number = StorageValue<_, T::BlockNumber, ValueQuery>; +/// pub(super) type Number = StorageValue<_, frame_system::pallet_prelude::BlockNumberFor::, ValueQuery>; /// ``` /// /// NOTE: As with all `pallet::*` attributes, this one _must_ be written as diff --git a/frame/support/procedural/src/pallet/expand/hooks.rs b/frame/support/procedural/src/pallet/expand/hooks.rs index ef22f5a3af5be..76e1fe76116b2 100644 --- a/frame/support/procedural/src/pallet/expand/hooks.rs +++ b/frame/support/procedural/src/pallet/expand/hooks.rs @@ -75,7 +75,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { let frame_system = &def.frame_system; quote::quote! { impl<#type_impl_gen> - #frame_support::traits::Hooks<::BlockNumber> + #frame_support::traits::Hooks<#frame_system::pallet_prelude::BlockNumberFor::> for #pallet_ident<#type_use_gen> #where_clause {} } } else { @@ -137,50 +137,50 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { #hooks_impl impl<#type_impl_gen> - #frame_support::traits::OnFinalize<::BlockNumber> + #frame_support::traits::OnFinalize<#frame_system::pallet_prelude::BlockNumberFor::> for #pallet_ident<#type_use_gen> #where_clause { - fn on_finalize(n: ::BlockNumber) { + fn on_finalize(n: #frame_system::pallet_prelude::BlockNumberFor::) { #frame_support::sp_tracing::enter_span!( #frame_support::sp_tracing::trace_span!("on_finalize") ); < Self as #frame_support::traits::Hooks< - ::BlockNumber + #frame_system::pallet_prelude::BlockNumberFor:: > >::on_finalize(n) } } impl<#type_impl_gen> - #frame_support::traits::OnIdle<::BlockNumber> + #frame_support::traits::OnIdle<#frame_system::pallet_prelude::BlockNumberFor::> for #pallet_ident<#type_use_gen> #where_clause { fn on_idle( - n: ::BlockNumber, + n: #frame_system::pallet_prelude::BlockNumberFor::, remaining_weight: #frame_support::weights::Weight ) -> #frame_support::weights::Weight { < Self as #frame_support::traits::Hooks< - ::BlockNumber + #frame_system::pallet_prelude::BlockNumberFor:: > >::on_idle(n, remaining_weight) } } impl<#type_impl_gen> - #frame_support::traits::OnInitialize<::BlockNumber> + #frame_support::traits::OnInitialize<#frame_system::pallet_prelude::BlockNumberFor::> for #pallet_ident<#type_use_gen> #where_clause { fn on_initialize( - n: ::BlockNumber + n: #frame_system::pallet_prelude::BlockNumberFor:: ) -> #frame_support::weights::Weight { #frame_support::sp_tracing::enter_span!( #frame_support::sp_tracing::trace_span!("on_initialize") ); < Self as #frame_support::traits::Hooks< - ::BlockNumber + #frame_system::pallet_prelude::BlockNumberFor:: > >::on_initialize(n) } @@ -205,7 +205,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { < Self as #frame_support::traits::Hooks< - ::BlockNumber + #frame_system::pallet_prelude::BlockNumberFor:: > >::on_runtime_upgrade() } @@ -215,7 +215,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { < Self as - #frame_support::traits::Hooks<::BlockNumber> + #frame_support::traits::Hooks<#frame_system::pallet_prelude::BlockNumberFor::> >::pre_upgrade() } @@ -226,19 +226,19 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { < Self as - #frame_support::traits::Hooks<::BlockNumber> + #frame_support::traits::Hooks<#frame_system::pallet_prelude::BlockNumberFor::> >::post_upgrade(state) } } impl<#type_impl_gen> - #frame_support::traits::OffchainWorker<::BlockNumber> + #frame_support::traits::OffchainWorker<#frame_system::pallet_prelude::BlockNumberFor::> for #pallet_ident<#type_use_gen> #where_clause { - fn offchain_worker(n: ::BlockNumber) { + fn offchain_worker(n: #frame_system::pallet_prelude::BlockNumberFor::) { < Self as #frame_support::traits::Hooks< - ::BlockNumber + #frame_system::pallet_prelude::BlockNumberFor:: > >::offchain_worker(n) } @@ -253,7 +253,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { fn integrity_test() { < Self as #frame_support::traits::Hooks< - ::BlockNumber + #frame_system::pallet_prelude::BlockNumberFor:: > >::integrity_test() } @@ -262,17 +262,17 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { #[cfg(feature = "try-runtime")] impl<#type_impl_gen> - #frame_support::traits::TryState<::BlockNumber> + #frame_support::traits::TryState<#frame_system::pallet_prelude::BlockNumberFor::> for #pallet_ident<#type_use_gen> #where_clause { fn try_state( - n: ::BlockNumber, + n: #frame_system::pallet_prelude::BlockNumberFor::, _s: #frame_support::traits::TryStateSelect ) -> Result<(), #frame_support::sp_runtime::TryRuntimeError> { #log_try_state < Self as #frame_support::traits::Hooks< - ::BlockNumber + #frame_system::pallet_prelude::BlockNumberFor:: > >::try_state(n) } diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index 9981e5ad65b78..7dfac19c9407d 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -645,259 +645,6 @@ impl PaysFee for (u64, Pays) { // END TODO /// Declares a `Module` struct and a `Call` enum, which implements the dispatch logic. -/// -/// ## Declaration -/// -/// ``` -/// # #[macro_use] -/// # extern crate frame_support; -/// # use frame_support::dispatch; -/// # use frame_system::{Config, ensure_signed}; -/// decl_module! { -/// pub struct Module for enum Call where origin: T::RuntimeOrigin { -/// -/// // Private functions are dispatchable, but not available to other -/// // FRAME pallets. -/// #[weight = 0] -/// fn my_function(origin, var: u64) -> dispatch::DispatchResult { -/// // Your implementation -/// Ok(()) -/// } -/// -/// // Public functions are both dispatchable and available to other -/// // FRAME pallets. -/// #[weight = 0] -/// pub fn my_public_function(origin) -> dispatch::DispatchResult { -/// // Your implementation -/// Ok(()) -/// } -/// } -/// } -/// # fn main() {} -/// ``` -/// -/// The declaration is set with the header where: -/// -/// * `Module`: The struct generated by the macro, with type `Config`. -/// * `Call`: The enum generated for every pallet, which implements -/// [`Callable`](./dispatch/trait.Callable.html). -/// * `origin`: Alias of `T::RuntimeOrigin`. -/// * `Result`: The expected return type from pallet functions. -/// -/// The first parameter of dispatchable functions must always be `origin`. -/// -/// ### Shorthand Example -/// -/// The macro automatically expands a shorthand function declaration to return the -/// [`DispatchResult`] type. These functions are the same: -/// -/// ``` -/// # #[macro_use] -/// # extern crate frame_support; -/// # use frame_support::dispatch; -/// # use frame_system::{Config, ensure_signed}; -/// decl_module! { -/// pub struct Module for enum Call where origin: T::RuntimeOrigin { -/// #[weight = 0] -/// fn my_long_function(origin) -> dispatch::DispatchResult { -/// // Your implementation -/// Ok(()) -/// } -/// -/// #[weight = 0] -/// fn my_short_function(origin) { -/// // Your implementation -/// } -/// } -/// } -/// # fn main() {} -/// ``` -/// -/// ### Consuming only portions of the annotated static weight -/// -/// Per default a callable function consumes all of its static weight as declared via -/// the #\[weight\] attribute. However, there are use cases where only a portion of this -/// weight should be consumed. In that case the static weight is charged pre dispatch and -/// the difference is refunded post dispatch. -/// -/// In order to make use of this feature the function must return `DispatchResultWithPostInfo` -/// in place of the default `DispatchResult`. Then the actually consumed weight can be returned. -/// To consume a non default weight while returning an error -/// [`WithPostDispatchInfo::with_weight`](./weight/trait.WithPostDispatchInfo.html) can be used -/// to augment any error with custom weight information. -/// -/// ``` -/// # #[macro_use] -/// # extern crate frame_support; -/// # use frame_support::{weights::Weight, dispatch::{DispatchResultWithPostInfo, WithPostDispatchInfo, PostDispatchInfo}}; -/// # use frame_system::{Config, ensure_signed}; -/// decl_module! { -/// pub struct Module for enum Call where origin: T::RuntimeOrigin { -/// #[weight = 1_000_000] -/// fn my_long_function(origin, do_expensive_calc: bool) -> DispatchResultWithPostInfo { -/// ensure_signed(origin).map_err(|e| e.with_weight(Weight::from_parts(100_000, 0)))?; -/// if do_expensive_calc { -/// // do the expensive calculation -/// // ... -/// // return None to indicate that we are using all weight (the default) -/// return Ok(None::.into()); -/// } -/// // expensive calculation not executed: use only a portion of the weight -/// Ok(PostDispatchInfo { actual_weight: Some(Weight::from_parts(100_000, 0)), ..Default::default() }) -/// } -/// } -/// } -/// # fn main() {} -/// ``` -/// -/// ### Transactional Function Example -/// -/// Transactional function discards all changes to storage if it returns `Err`, or commits if -/// `Ok`, via the #\[transactional\] attribute. Note the attribute must be after #\[weight\]. -/// The #\[transactional\] attribute is deprecated since it is the default behaviour. -/// -/// ``` -/// # #[macro_use] -/// # extern crate frame_support; -/// # use frame_support::transactional; -/// # use frame_system::Config; -/// decl_module! { -/// pub struct Module for enum Call where origin: T::RuntimeOrigin { -/// #[weight = 0] -/// #[transactional] -/// fn my_short_function(origin) { -/// // Your implementation -/// } -/// } -/// } -/// # fn main() {} -/// ``` -/// -/// ### Privileged Function Example -/// -/// A privileged function checks that the origin of the call is `ROOT`. -/// -/// ``` -/// # #[macro_use] -/// # extern crate frame_support; -/// # use frame_support::dispatch; -/// # use frame_system::{Config, ensure_signed, ensure_root}; -/// decl_module! { -/// pub struct Module for enum Call where origin: T::RuntimeOrigin { -/// #[weight = 0] -/// fn my_privileged_function(origin) -> dispatch::DispatchResult { -/// ensure_root(origin)?; -/// // Your implementation -/// Ok(()) -/// } -/// } -/// } -/// # fn main() {} -/// ``` -/// -/// ### Attributes on Functions -/// -/// Attributes on functions are supported, but must be in the order of: -/// 1. Optional #\[doc\] attribute. -/// 2. #\[weight\] attribute. -/// 3. Optional function attributes, for instance #\[transactional\]. Those function attributes will -/// be written only on the dispatchable functions implemented on `Module`, not on the `Call` enum -/// variant. -/// -/// ## Multiple Module Instances Example -/// -/// A Substrate module can be built such that multiple instances of the same module can be used -/// within a single runtime. For example, the [Balances module](../pallet_balances/index.html) can -/// be added multiple times to your runtime in order to support multiple, independent currencies for -/// your blockchain. Here is an example of how you would declare such a module using the -/// `decl_module!` macro: -/// -/// ``` -/// # #[macro_use] -/// # extern crate frame_support; -/// # use frame_support::dispatch; -/// # use frame_system::ensure_signed; -/// # pub struct DefaultInstance; -/// # pub trait Instance: 'static {} -/// # impl Instance for DefaultInstance {} -/// pub trait Config: frame_system::Config {} -/// -/// decl_module! { -/// pub struct Module, I: Instance = DefaultInstance> for enum Call where origin: T::RuntimeOrigin { -/// // Your implementation -/// } -/// } -/// # fn main() {} -/// ``` -/// -/// Note: `decl_storage` must be called to generate `Instance` trait and optionally -/// `DefaultInstance` type. -/// -/// ## Where clause -/// -/// Besides the default `origin: T::RuntimeOrigin`, you can also pass other bounds to the module -/// declaration. This where bound will be replicated to all types generated by this macro. The -/// chaining of multiple trait bounds with `+` is not supported. If multiple bounds for one type are -/// required, it needs to be split up into multiple bounds. -/// -/// ``` -/// # #[macro_use] -/// # extern crate frame_support; -/// # use frame_support::dispatch; -/// # use frame_system::{self as system, ensure_signed}; -/// pub trait Config: system::Config where Self::AccountId: From {} -/// -/// decl_module! { -/// pub struct Module for enum Call where origin: T::RuntimeOrigin, T::AccountId: From { -/// // Your implementation -/// } -/// } -/// # fn main() {} -/// ``` -/// -/// ## Reserved Functions -/// -/// The following are reserved function signatures: -/// -/// * `deposit_event`: Helper function for depositing an [event](https://docs.substrate.io/main-docs/build/events-errors/). -/// The default behavior is to call `deposit_event` from the [System -/// module](../frame_system/index.html). However, you can write your own implementation for events -/// in your runtime. To use the default behavior, add `fn deposit_event() = default;` to your -/// `Module`. -/// -/// The following reserved functions also take the block number (with type `T::BlockNumber`) as an -/// optional input: -/// -/// * `on_runtime_upgrade`: Executes at the beginning of a block prior to on_initialize when there -/// is a runtime upgrade. This allows each module to upgrade its storage before the storage items -/// are used. As such, **calling other modules must be avoided**!! Using this function will -/// implement the [`OnRuntimeUpgrade`](../sp_runtime/traits/trait.OnRuntimeUpgrade.html) trait. -/// Function signature must be `fn on_runtime_upgrade() -> frame_support::weights::Weight`. -/// -/// * `on_initialize`: Executes at the beginning of a block. Using this function will -/// implement the [`OnInitialize`](./trait.OnInitialize.html) trait. -/// Function signature can be either: -/// * `fn on_initialize(n: BlockNumber) -> frame_support::weights::Weight` or -/// * `fn on_initialize() -> frame_support::weights::Weight` -/// -/// * `on_idle`: Executes at the end of a block. Passes a remaining weight to provide a threshold -/// for when to execute non vital functions. Using this function will implement the -/// [`OnIdle`](./traits/trait.OnIdle.html) trait. -/// Function signature is: -/// * `fn on_idle(n: BlockNumber, remaining_weight: Weight) -> frame_support::weights::Weight` -/// -/// * `on_finalize`: Executes at the end of a block. Using this function will -/// implement the [`OnFinalize`](./traits/trait.OnFinalize.html) trait. -/// Function signature can be either: -/// * `fn on_finalize(n: BlockNumber) -> frame_support::weights::Weight` or -/// * `fn on_finalize() -> frame_support::weights::Weight` -/// -/// * `offchain_worker`: Executes at the beginning of a block and produces extrinsics for a future -/// block upon completion. Using this function will implement the -/// [`OffchainWorker`](./traits/trait.OffchainWorker.html) trait. -/// * `integrity_test`: Executes in a test generated by `construct_runtime`, note it doesn't execute -/// in an externalities-provided environment. Implement -/// [`IntegrityTest`](./trait.IntegrityTest.html) trait. #[macro_export] #[deprecated(note = "Will be removed after July 2023; use the attribute `#[pallet]` macro instead. For more info, see: ")] @@ -3587,7 +3334,7 @@ mod weight_tests { #[pallet::config] #[pallet::disable_frame_system_supertrait_check] pub trait Config: 'static { - type BlockNumber: Parameter + Default + MaxEncodedLen; + type Block: Parameter + sp_runtime::traits::Block; type AccountId; type Balance; type BaseCallFilter: crate::traits::Contains; @@ -3653,6 +3400,11 @@ mod weight_tests { pub mod pallet_prelude { pub type OriginFor = ::RuntimeOrigin; + + pub type HeaderFor = + <::Block as sp_runtime::traits::HeaderProvider>::HeaderT; + + pub type BlockNumberFor = as sp_runtime::traits::Header>::Number; } } @@ -3665,10 +3417,6 @@ mod weight_tests { crate::construct_runtime!( pub enum Runtime - where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, { System: self::frame_system, } @@ -3682,7 +3430,7 @@ mod weight_tests { } impl Config for Runtime { - type BlockNumber = BlockNumber; + type Block = Block; type AccountId = AccountId; type Balance = Balance; type BaseCallFilter = crate::traits::Everything; diff --git a/frame/support/src/error.rs b/frame/support/src/error.rs index 14dc16d4dd5c2..5a7dd73f481ec 100644 --- a/frame/support/src/error.rs +++ b/frame/support/src/error.rs @@ -21,51 +21,6 @@ pub use sp_runtime::traits::{BadOrigin, LookupError}; /// Declare an error type for a runtime module. -/// -/// `decl_error!` supports only variants that do not hold any data. The dispatchable -/// functions return [`DispatchResult`](sp_runtime::DispatchResult). The error type -/// implements `From for DispatchResult` to make the error type usable as error -/// in the dispatchable functions. -/// -/// It is required that the error type is registered in `decl_module!` to make the error -/// exported in the metadata. -/// -/// # Usage -/// -/// ``` -/// # use frame_support::{decl_error, decl_module}; -/// # -/// decl_error! { -/// /// Errors that can occur in my module. -/// pub enum MyError for Module { -/// /// Hey this is an error message that indicates bla. -/// MyCoolErrorMessage, -/// /// You are just not cool enough for my module! -/// YouAreNotCoolEnough, -/// } -/// } -/// -/// # use frame_system::Config; -/// -/// // You need to register the error type in `decl_module!` as well to make the error -/// // exported in the metadata. -/// -/// decl_module! { -/// pub struct Module for enum Call where origin: T::RuntimeOrigin { -/// type Error = MyError; -/// -/// #[weight = 0] -/// fn do_something(origin) -> frame_support::dispatch::DispatchResult { -/// Err(MyError::::YouAreNotCoolEnough.into()) -/// } -/// } -/// } -/// -/// # fn main() {} -/// ``` -/// -/// For instantiable modules you also need to give the instance generic type and bound to the -/// error declaration. #[macro_export] #[deprecated(note = "Will be removed after July 2023; use the attribute `#[pallet]` macro instead. For more info, see: ")] diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 250f15bb36461..51477ee384c79 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -834,7 +834,7 @@ pub mod tests { use sp_runtime::{generic, traits::BlakeTwo256, BuildStorage}; use sp_std::result; - pub use self::frame_system::{Config, Pallet}; + pub use self::frame_system::{pallet_prelude::*, Config, Pallet}; #[pallet] pub mod frame_system { @@ -849,7 +849,7 @@ pub mod tests { #[pallet::config] #[pallet::disable_frame_system_supertrait_check] pub trait Config: 'static { - type BlockNumber: Parameter + Default + MaxEncodedLen; + type Block: Parameter + sp_runtime::traits::Block; type AccountId; type BaseCallFilter: crate::traits::Contains; type RuntimeOrigin; @@ -879,12 +879,12 @@ pub mod tests { #[pallet::storage] #[pallet::getter(fn generic_data)] pub type GenericData = - StorageMap<_, Identity, T::BlockNumber, T::BlockNumber, ValueQuery>; + StorageMap<_, Identity, BlockNumberFor, BlockNumberFor, ValueQuery>; #[pallet::storage] #[pallet::getter(fn generic_data2)] pub type GenericData2 = - StorageMap<_, Blake2_128Concat, T::BlockNumber, T::BlockNumber, OptionQuery>; + StorageMap<_, Blake2_128Concat, BlockNumberFor, BlockNumberFor, OptionQuery>; #[pallet::storage] pub type DataDM = @@ -894,10 +894,10 @@ pub mod tests { pub type GenericDataDM = StorageDoubleMap< _, Blake2_128Concat, - T::BlockNumber, + BlockNumberFor, Identity, - T::BlockNumber, - T::BlockNumber, + BlockNumberFor, + BlockNumberFor, ValueQuery, >; @@ -905,10 +905,10 @@ pub mod tests { pub type GenericData2DM = StorageDoubleMap< _, Blake2_128Concat, - T::BlockNumber, + BlockNumberFor, Twox64Concat, - T::BlockNumber, - T::BlockNumber, + BlockNumberFor, + BlockNumberFor, OptionQuery, >; @@ -919,7 +919,7 @@ pub mod tests { Blake2_128Concat, u32, Blake2_128Concat, - T::BlockNumber, + BlockNumberFor, Vec, ValueQuery, >; @@ -956,6 +956,11 @@ pub mod tests { pub mod pallet_prelude { pub type OriginFor = ::RuntimeOrigin; + + pub type HeaderFor = + <::Block as sp_runtime::traits::HeaderProvider>::HeaderT; + + pub type BlockNumberFor = as sp_runtime::traits::Header>::Number; } } @@ -967,17 +972,13 @@ pub mod tests { crate::construct_runtime!( pub enum Runtime - where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, { System: self::frame_system, } ); impl Config for Runtime { - type BlockNumber = BlockNumber; + type Block = Block; type AccountId = AccountId; type BaseCallFilter = crate::traits::Everything; type RuntimeOrigin = RuntimeOrigin; @@ -1005,12 +1006,8 @@ pub mod tests { fn storage_alias_works() { new_test_ext().execute_with(|| { #[crate::storage_alias] - type GenericData2 = StorageMap< - System, - Blake2_128Concat, - ::BlockNumber, - ::BlockNumber, - >; + type GenericData2 = + StorageMap, BlockNumberFor>; assert_eq!(Pallet::::generic_data2(5), None); GenericData2::::insert(5, 5); @@ -1018,12 +1015,8 @@ pub mod tests { /// Some random docs that ensure that docs are accepted #[crate::storage_alias] - pub type GenericData = StorageMap< - Test2, - Blake2_128Concat, - ::BlockNumber, - ::BlockNumber, - >; + pub type GenericData = + StorageMap, BlockNumberFor>; }); } diff --git a/frame/support/src/migrations.rs b/frame/support/src/migrations.rs index 9ba22d3e15404..19eec194a76ad 100644 --- a/frame/support/src/migrations.rs +++ b/frame/support/src/migrations.rs @@ -257,12 +257,9 @@ pub fn migrate_from_pallet_version_to_storage_version< /// # Examples: /// ```ignore /// construct_runtime! { -/// pub enum Runtime where -/// Block = Block, -/// NodeBlock = primitives::Block, -/// UncheckedExtrinsic = UncheckedExtrinsic +/// pub enum Runtime /// { -/// System: frame_system::{Pallet, Call, Storage, Config, Event} = 0, +/// System: frame_system::{Pallet, Call, Storage, Config, Event} = 0, /// /// SomePalletToRemove: pallet_something::{Pallet, Call, Storage, Event} = 1, /// AnotherPalletToRemove: pallet_something_else::{Pallet, Call, Storage, Event} = 2, diff --git a/frame/support/src/storage/generator/mod.rs b/frame/support/src/storage/generator/mod.rs index 349f5de3ef3bc..bac9f642e37d6 100644 --- a/frame/support/src/storage/generator/mod.rs +++ b/frame/support/src/storage/generator/mod.rs @@ -58,7 +58,7 @@ mod tests { #[pallet::config] #[pallet::disable_frame_system_supertrait_check] pub trait Config: 'static { - type BlockNumber; + type Block: sp_runtime::traits::Block; type AccountId; type BaseCallFilter: crate::traits::Contains; type RuntimeOrigin; @@ -102,6 +102,11 @@ mod tests { pub mod pallet_prelude { pub type OriginFor = ::RuntimeOrigin; + + pub type HeaderFor = + <::Block as sp_runtime::traits::HeaderProvider>::HeaderT; + + pub type BlockNumberFor = as sp_runtime::traits::Header>::Number; } } @@ -113,18 +118,14 @@ mod tests { crate::construct_runtime!( pub enum Runtime - where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, { System: self::frame_system, } ); impl self::frame_system::Config for Runtime { - type BlockNumber = BlockNumber; type AccountId = AccountId; + type Block = Block; type BaseCallFilter = crate::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; diff --git a/frame/support/test/compile_pass/src/lib.rs b/frame/support/test/compile_pass/src/lib.rs index 4eaa657b1e486..75911d7569f80 100644 --- a/frame/support/test/compile_pass/src/lib.rs +++ b/frame/support/test/compile_pass/src/lib.rs @@ -58,13 +58,12 @@ impl frame_system::Config for Runtime { type Index = u128; type Hash = H256; type Hashing = BlakeTwo256; - type Header = Header; + type Block = Block; type Lookup = IdentityLookup; type BlockHashCount = ConstU64<2400>; type Version = Version; type AccountData = (); type RuntimeOrigin = RuntimeOrigin; - type BlockNumber = BlockNumber; type AccountId = AccountId; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; @@ -83,12 +82,7 @@ pub type Block = generic::Block; pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; construct_runtime!( - pub struct Runtime - where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { + pub struct Runtime { System: frame_system, } ); diff --git a/frame/support/test/src/lib.rs b/frame/support/test/src/lib.rs index 2a3cf13d4dac7..6b38d42d33d0d 100644 --- a/frame/support/test/src/lib.rs +++ b/frame/support/test/src/lib.rs @@ -22,6 +22,7 @@ #![deny(warnings)] pub use frame_support::dispatch::RawOrigin; +use frame_system::pallet_prelude::BlockNumberFor; pub use self::pallet::*; @@ -126,12 +127,12 @@ pub mod pallet_prelude { /// tests! pub struct TestRandomness(sp_std::marker::PhantomData); -impl frame_support::traits::Randomness - for TestRandomness +impl + frame_support::traits::Randomness> for TestRandomness where T: frame_system::Config, { - fn random(subject: &[u8]) -> (Output, T::BlockNumber) { + fn random(subject: &[u8]) -> (Output, BlockNumberFor) { use sp_runtime::traits::TrailingZeroInput; ( diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index acdaef190b330..ff207ddf977c6 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -22,9 +22,13 @@ #![recursion_limit = "128"] use codec::MaxEncodedLen; -use frame_support::{parameter_types, traits::PalletInfo as _}; +use frame_support::{ + derive_impl, parameter_types, traits::PalletInfo as _, weights::RuntimeDbWeight, +}; +use frame_system::limits::{BlockLength, BlockWeights}; use scale_info::TypeInfo; -use sp_core::sr25519; +use sp_api::RuntimeVersion; +use sp_core::{sr25519, ConstU64}; use sp_runtime::{ generic, traits::{BlakeTwo256, Verify}, @@ -37,9 +41,8 @@ parameter_types! { #[frame_support::pallet(dev_mode)] mod module1 { - use self::frame_system::pallet_prelude::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; + use frame_system::pallet_prelude::*; #[pallet::pallet] pub struct Pallet(_); @@ -75,10 +78,9 @@ mod module1 { #[frame_support::pallet(dev_mode)] mod module2 { - use self::frame_system::pallet_prelude::*; use super::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; + use frame_system::pallet_prelude::*; #[pallet::pallet] pub struct Pallet(_); @@ -122,10 +124,9 @@ mod nested { #[frame_support::pallet(dev_mode)] pub mod module3 { - use self::frame_system::pallet_prelude::*; use super::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; + use frame_system::pallet_prelude::*; #[pallet::pallet] pub struct Pallet(_); @@ -180,10 +181,9 @@ mod nested { #[frame_support::pallet(dev_mode)] pub mod module3 { - use self::frame_system::pallet_prelude::*; use super::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; + use frame_system::pallet_prelude::*; #[pallet::pallet] pub struct Pallet(_); @@ -256,15 +256,10 @@ pub type Header = generic::Header; pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; pub type Block = generic::Block; -use frame_support_test as system; - frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { - System: system::{Pallet, Call, Event, Origin} = 30, + System: frame_system::{Pallet, Call, Event, Origin} = 30, Module1_1: module1::::{Pallet, Call, Storage, Event, Origin}, Module2: module2::{Pallet, Call, Storage, Event, Origin}, Module1_2: module1::::{Pallet, Call, Storage, Event, Origin}, @@ -280,15 +275,18 @@ frame_support::construct_runtime!( } ); -impl frame_support_test::Config for Runtime { - type BlockNumber = BlockNumber; +#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] +impl frame_system::Config for Runtime { type AccountId = AccountId; + type Lookup = sp_runtime::traits::IdentityLookup; type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; - type DbWeight = (); + type OnSetCode = (); + type Block = Block; + type BlockHashCount = ConstU64<10>; } impl module1::Config for Runtime { @@ -336,7 +334,7 @@ fn test_pub() -> AccountId { fn check_modules_error_type() { sp_io::TestExternalities::default().execute_with(|| { assert_eq!( - Module1_1::fail(system::Origin::::Root.into()), + Module1_1::fail(frame_system::Origin::::Root.into()), Err(DispatchError::Module(ModuleError { index: 31, error: [0; 4], @@ -344,7 +342,7 @@ fn check_modules_error_type() { })), ); assert_eq!( - Module2::fail(system::Origin::::Root.into()), + Module2::fail(frame_system::Origin::::Root.into()), Err(DispatchError::Module(ModuleError { index: 32, error: [0; 4], @@ -352,7 +350,7 @@ fn check_modules_error_type() { })), ); assert_eq!( - Module1_2::fail(system::Origin::::Root.into()), + Module1_2::fail(frame_system::Origin::::Root.into()), Err(DispatchError::Module(ModuleError { index: 33, error: [0; 4], @@ -360,7 +358,7 @@ fn check_modules_error_type() { })), ); assert_eq!( - NestedModule3::fail(system::Origin::::Root.into()), + NestedModule3::fail(frame_system::Origin::::Root.into()), Err(DispatchError::Module(ModuleError { index: 34, error: [0; 4], @@ -368,7 +366,7 @@ fn check_modules_error_type() { })), ); assert_eq!( - Module1_3::fail(system::Origin::::Root.into()), + Module1_3::fail(frame_system::Origin::::Root.into()), Err(DispatchError::Module(ModuleError { index: 6, error: [0; 4], @@ -376,7 +374,7 @@ fn check_modules_error_type() { })), ); assert_eq!( - Module1_4::fail(system::Origin::::Root.into()), + Module1_4::fail(frame_system::Origin::::Root.into()), Err(DispatchError::Module(ModuleError { index: 3, error: [0; 4], @@ -384,7 +382,7 @@ fn check_modules_error_type() { })), ); assert_eq!( - Module1_5::fail(system::Origin::::Root.into()), + Module1_5::fail(frame_system::Origin::::Root.into()), Err(DispatchError::Module(ModuleError { index: 4, error: [0; 4], @@ -392,7 +390,7 @@ fn check_modules_error_type() { })), ); assert_eq!( - Module1_6::fail(system::Origin::::Root.into()), + Module1_6::fail(frame_system::Origin::::Root.into()), Err(DispatchError::Module(ModuleError { index: 1, error: [0; 4], @@ -400,7 +398,7 @@ fn check_modules_error_type() { })), ); assert_eq!( - Module1_7::fail(system::Origin::::Root.into()), + Module1_7::fail(frame_system::Origin::::Root.into()), Err(DispatchError::Module(ModuleError { index: 2, error: [0; 4], @@ -408,7 +406,7 @@ fn check_modules_error_type() { })), ); assert_eq!( - Module1_8::fail(system::Origin::::Root.into()), + Module1_8::fail(frame_system::Origin::::Root.into()), Err(DispatchError::Module(ModuleError { index: 12, error: [0; 4], @@ -416,7 +414,7 @@ fn check_modules_error_type() { })), ); assert_eq!( - Module1_9::fail(system::Origin::::Root.into()), + Module1_9::fail(frame_system::Origin::::Root.into()), Err(DispatchError::Module(ModuleError { index: 13, error: [0; 4], @@ -436,7 +434,7 @@ fn integrity_test_works() { fn origin_codec() { use codec::Encode; - let origin = OriginCaller::system(system::RawOrigin::None); + let origin = OriginCaller::system(frame_system::RawOrigin::None); assert_eq!(origin.encode()[0], 30); let origin = OriginCaller::Module1_1(module1::Origin(Default::default())); @@ -471,7 +469,8 @@ fn origin_codec() { fn event_codec() { use codec::Encode; - let event = system::Event::::ExtrinsicSuccess; + let event = + frame_system::Event::::ExtrinsicSuccess { dispatch_info: Default::default() }; assert_eq!(RuntimeEvent::from(event).encode()[0], 30); let event = module1::Event::::A(test_pub()); @@ -508,7 +507,7 @@ fn event_codec() { #[test] fn call_codec() { use codec::Encode; - assert_eq!(RuntimeCall::System(system::Call::noop {}).encode()[0], 30); + assert_eq!(RuntimeCall::System(frame_system::Call::remark { remark: vec![1] }).encode()[0], 30); assert_eq!(RuntimeCall::Module1_1(module1::Call::fail {}).encode()[0], 31); assert_eq!(RuntimeCall::Module2(module2::Call::fail {}).encode()[0], 32); assert_eq!(RuntimeCall::Module1_2(module1::Call::fail {}).encode()[0], 33); @@ -639,15 +638,67 @@ fn call_subtype_conversion() { fn test_metadata() { use frame_support::metadata::{v14::*, *}; use scale_info::meta_type; + use sp_core::Encode; + + fn maybe_docs(doc: Vec<&'static str>) -> Vec<&'static str> { + if cfg!(feature = "no-metadata-docs") { + vec![] + } else { + doc + } + } let pallets = vec![ PalletMetadata { name: "System", storage: None, - calls: Some(meta_type::>().into()), - event: Some(meta_type::>().into()), - constants: vec![], - error: Some(meta_type::>().into()), + calls: Some(meta_type::>().into()), + event: Some(meta_type::>().into()), + constants: vec![ + PalletConstantMetadata { + name: "BlockWeights", + ty: meta_type::(), + value: BlockWeights::default().encode(), + docs: maybe_docs(vec![" Block & extrinsics weights: base values and limits."]), + }, + PalletConstantMetadata { + name: "BlockLength", + ty: meta_type::(), + value: BlockLength::default().encode(), + docs: maybe_docs(vec![" The maximum length of a block (in bytes)."]), + }, + PalletConstantMetadata { + name: "BlockHashCount", + ty: meta_type::(), + value: 10u64.encode(), + docs: maybe_docs(vec![" Maximum number of block number to block hash mappings to keep (oldest pruned first)."]), + }, + PalletConstantMetadata { + name: "DbWeight", + ty: meta_type::(), + value: RuntimeDbWeight::default().encode(), + docs: maybe_docs(vec![" The weight of runtime database operations the runtime can invoke.",]), + }, + PalletConstantMetadata { + name: "Version", + ty: meta_type::(), + value: RuntimeVersion::default().encode(), + docs: maybe_docs(vec![ " Get the chain's current version."]), + }, + PalletConstantMetadata { + name: "SS58Prefix", + ty: meta_type::(), + value: 0u16.encode(), + docs: maybe_docs(vec![ + " The designated SS58 prefix of this chain.", + "", + " This replaces the \"ss58Format\" property declared in the chain spec. Reason is", + " that the runtime should know about the prefix in order to make use of it as", + " an identifier of the chain.", + ]), + }, + ], + error: Some(meta_type::>().into()), index: 30, }, PalletMetadata { @@ -781,7 +832,7 @@ fn test_metadata() { fn pallet_in_runtime_is_correct() { assert_eq!(PalletInfo::index::().unwrap(), 30); assert_eq!(PalletInfo::name::().unwrap(), "System"); - assert_eq!(PalletInfo::module_name::().unwrap(), "system"); + assert_eq!(PalletInfo::module_name::().unwrap(), "frame_system"); assert!(PalletInfo::crate_version::().is_some()); assert_eq!(PalletInfo::index::().unwrap(), 31); diff --git a/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.rs b/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.rs index ea468d6de13ee..4cb249714650e 100644 --- a/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.rs +++ b/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.rs @@ -20,12 +20,9 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic}, + System: system::{Pallet, Call, Storage, Config, Event}, Pallet: pallet exclude_parts { Pallet } use_parts { Pallet }, } } diff --git a/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.stderr b/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.stderr index b1c1879aa56ad..1ea62b7d6fd65 100644 --- a/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.stderr +++ b/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.stderr @@ -1,7 +1,7 @@ error: Unexpected tokens, expected one of `=`, `,` - --> tests/construct_runtime_ui/both_use_and_excluded_parts.rs:29:43 + --> tests/construct_runtime_ui/both_use_and_excluded_parts.rs:26:43 | -29 | Pallet: pallet exclude_parts { Pallet } use_parts { Pallet }, +26 | Pallet: pallet exclude_parts { Pallet } use_parts { Pallet }, | ^^^^^^^^^ error[E0412]: cannot find type `RuntimeCall` in this scope diff --git a/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.rs b/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.rs index dd8340daa0233..513fbcfb51354 100644 --- a/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.rs +++ b/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: system::{Pallet}, Balance: balances::{Pallet}, diff --git a/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.stderr b/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.stderr index 27c5644e0d736..6fb983f03a961 100644 --- a/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.stderr +++ b/frame/support/test/tests/construct_runtime_ui/conflicting_module_name.stderr @@ -1,11 +1,11 @@ error: Two pallets with the same name! - --> $DIR/conflicting_module_name.rs:10:3 - | -10 | Balance: balances::{Pallet}, - | ^^^^^^^ + --> tests/construct_runtime_ui/conflicting_module_name.rs:7:3 + | +7 | Balance: balances::{Pallet}, + | ^^^^^^^ error: Two pallets with the same name! - --> $DIR/conflicting_module_name.rs:11:3 - | -11 | Balance: balances::{Pallet}, - | ^^^^^^^ + --> tests/construct_runtime_ui/conflicting_module_name.rs:8:3 + | +8 | Balance: balances::{Pallet}, + | ^^^^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.rs b/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.rs new file mode 100644 index 0000000000000..c0e325085b5e5 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.rs @@ -0,0 +1,13 @@ +use frame_support::construct_runtime; + +construct_runtime! { + pub struct Runtime where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = Uxt, + { + System: frame_system::{Pallet, Call, Storage, Config, Event}, + } +} + +fn main() {} diff --git a/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.stderr b/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.stderr new file mode 100644 index 0000000000000..946277e9068e3 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/deprecated_where_block.stderr @@ -0,0 +1,442 @@ +error: use of deprecated constant `WhereSection::_w`: + It is deprecated to use a `where` clause in `construct_runtime`. + Please instead use `frame_system::Config` to set the `Block` type and delete this clause. + It is planned to be removed in December 2023. + + For more info see: + + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | / construct_runtime! { +4 | | pub struct Runtime where +5 | | Block = Block, +6 | | NodeBlock = Block, +... | +10 | | } +11 | | } + | |_^ + | + = note: `-D deprecated` implied by `-D warnings` + = note: this error originates in the macro `frame_support::match_and_insert` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `Runtime: Config` is not satisfied + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | +note: required by a bound in `frame_system::Event` + --> $WORKSPACE/frame/system/src/lib.rs + | + | pub enum Event { + | ^^^^^^ required by this bound in `Event` + = note: this error originates in the macro `frame_support::construct_runtime` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `Runtime: Config` is not satisfied in `RuntimeEvent` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | +note: required because it appears within the type `RuntimeEvent` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | +note: required by a bound in `Clone` + --> $RUST/core/src/clone.rs + | + | pub trait Clone: Sized { + | ^^^^^ required by this bound in `Clone` + = note: this error originates in the derive macro `Clone` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `Runtime: Config` is not satisfied in `RuntimeEvent` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | +note: required because it appears within the type `RuntimeEvent` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | +note: required by a bound in `EncodeLike` + --> $CARGO/parity-scale-codec-3.6.1/src/encode_like.rs + | + | pub trait EncodeLike: Sized + Encode {} + | ^^^^^ required by this bound in `EncodeLike` + = note: this error originates in the macro `frame_support::construct_runtime` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `Runtime: Config` is not satisfied in `RuntimeEvent` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | +note: required because it appears within the type `RuntimeEvent` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | +note: required by a bound in `Decode` + --> $CARGO/parity-scale-codec-3.6.1/src/codec.rs + | + | pub trait Decode: Sized { + | ^^^^^ required by this bound in `Decode` + = note: this error originates in the macro `frame_support::construct_runtime` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `Runtime: Config` is not satisfied in `frame_system::Event` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | + = note: required because it appears within the type `Event` +note: required by a bound in `From` + --> $RUST/core/src/convert/mod.rs + | + | pub trait From: Sized { + | ^ required by this bound in `From` + = note: this error originates in the macro `frame_support::construct_runtime` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `Runtime: Config` is not satisfied in `frame_system::Event` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | + = note: required because it appears within the type `Event` +note: required by a bound in `TryInto` + --> $RUST/core/src/convert/mod.rs + | + | pub trait TryInto: Sized { + | ^ required by this bound in `TryInto` + = note: this error originates in the macro `frame_support::construct_runtime` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `Runtime: Config` is not satisfied + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | + = note: this error originates in the macro `frame_support::construct_runtime` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `Runtime: Config` is not satisfied + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | construct_runtime! { + | ^ the trait `Config` is not implemented for `Runtime` + | + = note: this error originates in the macro `frame_support::construct_runtime` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `RawOrigin<_>: TryFrom` is not satisfied + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | + = help: the trait `TryFrom` is implemented for `RawOrigin<::AccountId>` + = note: this error originates in the macro `frame_support::construct_runtime` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `Runtime: Config` is not satisfied + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | + = help: the trait `Callable` is implemented for `Pallet` + = note: required for `Pallet` to implement `Callable` + = note: this error originates in the macro `frame_support::construct_runtime` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `Runtime: Config` is not satisfied + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | + = note: required for `Pallet` to implement `Callable` +note: required because it appears within the type `RuntimeCall` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | +note: required by a bound in `Clone` + --> $RUST/core/src/clone.rs + | + | pub trait Clone: Sized { + | ^^^^^ required by this bound in `Clone` + = note: this error originates in the derive macro `Clone` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `Runtime: Config` is not satisfied + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | + = note: required for `Pallet` to implement `Callable` +note: required because it appears within the type `RuntimeCall` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | +note: required by a bound in `EncodeLike` + --> $CARGO/parity-scale-codec-3.6.1/src/encode_like.rs + | + | pub trait EncodeLike: Sized + Encode {} + | ^^^^^ required by this bound in `EncodeLike` + = note: this error originates in the macro `frame_support::construct_runtime` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `Runtime: Config` is not satisfied + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | + = note: required for `Pallet` to implement `Callable` +note: required because it appears within the type `RuntimeCall` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | +note: required by a bound in `Decode` + --> $CARGO/parity-scale-codec-3.6.1/src/codec.rs + | + | pub trait Decode: Sized { + | ^^^^^ required by this bound in `Decode` + = note: this error originates in the macro `frame_support::construct_runtime` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `Runtime: Config` is not satisfied + --> tests/construct_runtime_ui/deprecated_where_block.rs:9:3 + | +9 | System: frame_system::{Pallet, Call, Storage, Config, Event}, + | ^^^^^^ the trait `Config` is not implemented for `Runtime` + | +note: required by a bound in `frame_system::GenesisConfig` + --> $WORKSPACE/frame/system/src/lib.rs + | + | pub struct GenesisConfig { + | ^^^^^^ required by this bound in `GenesisConfig` + +error[E0277]: the trait bound `Runtime: Config` is not satisfied in `RuntimeEvent` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | +note: required because it appears within the type `RuntimeEvent` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | +note: required by a bound in `Result` + --> $RUST/core/src/result.rs + | + | pub enum Result { + | ^ required by this bound in `Result` + = note: this error originates in the derive macro `self::sp_api_hidden_includes_construct_runtime::hidden_include::codec::Decode` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `Runtime: Config` is not satisfied in `RuntimeEvent` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | +note: required because it appears within the type `RuntimeEvent` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | +note: required by a bound in `TryInto` + --> $RUST/core/src/convert/mod.rs + | + | pub trait TryInto: Sized { + | ^^^^^ required by this bound in `TryInto` + = note: this error originates in the macro `frame_support::construct_runtime` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the trait bound `Runtime: Config` is not satisfied + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | + | + = note: required for `Pallet` to implement `Callable` +note: required because it appears within the type `RuntimeCall` + --> tests/construct_runtime_ui/deprecated_where_block.rs:3:1 + | +3 | // construct_runtime! { +4 | || pub struct Runtime where +5 | || Block = Block, +6 | || NodeBlock = Block, +... || +10 | || } +11 | || } + | ||_- in this macro invocation +... | +note: required by a bound in `Result` + --> $RUST/core/src/result.rs + | + | pub enum Result { + | ^ required by this bound in `Result` + = note: this error originates in the derive macro `self::sp_api_hidden_includes_construct_runtime::hidden_include::codec::Decode` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/frame/support/test/tests/construct_runtime_ui/double_module_parts.rs b/frame/support/test/tests/construct_runtime_ui/double_module_parts.rs index 3269d22434fdf..68a2523d3bcb2 100644 --- a/frame/support/test/tests/construct_runtime_ui/double_module_parts.rs +++ b/frame/support/test/tests/construct_runtime_ui/double_module_parts.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: system::{Pallet}, Balance: balances::{Config, Call, Config, Origin}, diff --git a/frame/support/test/tests/construct_runtime_ui/double_module_parts.stderr b/frame/support/test/tests/construct_runtime_ui/double_module_parts.stderr index 9d10474ce85ab..e3f694781441f 100644 --- a/frame/support/test/tests/construct_runtime_ui/double_module_parts.stderr +++ b/frame/support/test/tests/construct_runtime_ui/double_module_parts.stderr @@ -1,5 +1,5 @@ error: `Config` was already declared before. Please remove the duplicate declaration - --> $DIR/double_module_parts.rs:10:37 - | -10 | Balance: balances::{Config, Call, Config, Origin}, - | ^^^^^^ + --> tests/construct_runtime_ui/double_module_parts.rs:7:37 + | +7 | Balance: balances::{Config, Call, Config, Origin}, + | ^^^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/empty_pallet_path.rs b/frame/support/test/tests/construct_runtime_ui/empty_pallet_path.rs index 44b7fd0ba25f7..23badd76276e2 100644 --- a/frame/support/test/tests/construct_runtime_ui/empty_pallet_path.rs +++ b/frame/support/test/tests/construct_runtime_ui/empty_pallet_path.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { system: , } diff --git a/frame/support/test/tests/construct_runtime_ui/empty_pallet_path.stderr b/frame/support/test/tests/construct_runtime_ui/empty_pallet_path.stderr index 7102076e5acb0..f0c0f17779d67 100644 --- a/frame/support/test/tests/construct_runtime_ui/empty_pallet_path.stderr +++ b/frame/support/test/tests/construct_runtime_ui/empty_pallet_path.stderr @@ -1,5 +1,5 @@ error: expected one of: `crate`, `self`, `super`, identifier - --> $DIR/empty_pallet_path.rs:9:11 + --> tests/construct_runtime_ui/empty_pallet_path.rs:6:11 | -9 | system: , +6 | system: , | ^ diff --git a/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.rs b/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.rs index 83a166fc00552..10cda7b4e7e8a 100644 --- a/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.rs @@ -25,12 +25,9 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic}, + System: system::{Pallet, Call, Storage, Config, Event}, Pallet: pallet exclude_parts { Call }, } } diff --git a/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.stderr b/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.stderr index 66098898bb877..4b85613838ab5 100644 --- a/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.stderr @@ -1,7 +1,7 @@ error: Invalid pallet part specified, the pallet `Pallet` doesn't have the `Call` part. Available parts are: `Pallet`, `Storage`. - --> tests/construct_runtime_ui/exclude_undefined_part.rs:34:34 + --> tests/construct_runtime_ui/exclude_undefined_part.rs:31:34 | -34 | Pallet: pallet exclude_parts { Call }, +31 | Pallet: pallet exclude_parts { Call }, | ^^^^ error[E0412]: cannot find type `RuntimeCall` in this scope diff --git a/frame/support/test/tests/construct_runtime_ui/feature_gated_system_pallet.rs b/frame/support/test/tests/construct_runtime_ui/feature_gated_system_pallet.rs index e566f7d458233..35d49a4d8a23b 100644 --- a/frame/support/test/tests/construct_runtime_ui/feature_gated_system_pallet.rs +++ b/frame/support/test/tests/construct_runtime_ui/feature_gated_system_pallet.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { #[cfg(test)] System: frame_system::{Pallet, Call, Storage, Config, Event}, diff --git a/frame/support/test/tests/construct_runtime_ui/feature_gated_system_pallet.stderr b/frame/support/test/tests/construct_runtime_ui/feature_gated_system_pallet.stderr index 31ae4c987bbe3..6a6c4b4158889 100644 --- a/frame/support/test/tests/construct_runtime_ui/feature_gated_system_pallet.stderr +++ b/frame/support/test/tests/construct_runtime_ui/feature_gated_system_pallet.stderr @@ -1,5 +1,5 @@ error: `System` pallet declaration is feature gated, please remove any `#[cfg]` attributes - --> tests/construct_runtime_ui/feature_gated_system_pallet.rs:10:3 - | -10 | System: frame_system::{Pallet, Call, Storage, Config, Event}, - | ^^^^^^ + --> tests/construct_runtime_ui/feature_gated_system_pallet.rs:7:3 + | +7 | System: frame_system::{Pallet, Call, Storage, Config, Event}, + | ^^^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.rs b/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.rs index 0912ffc98d54b..1ad1f8e0b1d5f 100644 --- a/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.rs +++ b/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: system::{Pallet}, Balance: balances::::{Call, Origin}, diff --git a/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.stderr b/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.stderr index ca2bb998e06d3..a6adb37d04949 100644 --- a/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.stderr +++ b/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.stderr @@ -1,5 +1,5 @@ error: `Call` is not allowed to have generics. Only the following pallets are allowed to have generics: `Event`, `Error`, `Origin`, `Config`. - --> $DIR/generics_in_invalid_module.rs:10:36 - | -10 | Balance: balances::::{Call, Origin}, - | ^^^^ + --> tests/construct_runtime_ui/generics_in_invalid_module.rs:7:36 + | +7 | Balance: balances::::{Call, Origin}, + | ^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_meta_literal.rs b/frame/support/test/tests/construct_runtime_ui/invalid_meta_literal.rs index c253444ee31db..bce87c51336eb 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_meta_literal.rs +++ b/frame/support/test/tests/construct_runtime_ui/invalid_meta_literal.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: system::{Pallet}, #[cfg(feature = 1)] diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_meta_literal.stderr b/frame/support/test/tests/construct_runtime_ui/invalid_meta_literal.stderr index 68366a3410bf1..bfee2910cd2a4 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_meta_literal.stderr +++ b/frame/support/test/tests/construct_runtime_ui/invalid_meta_literal.stderr @@ -1,6 +1,6 @@ error: feature = 1 ^ expected one of ``, `all`, `any`, `not` here - --> tests/construct_runtime_ui/invalid_meta_literal.rs:10:3 - | -10 | #[cfg(feature = 1)] - | ^ + --> tests/construct_runtime_ui/invalid_meta_literal.rs:7:3 + | +7 | #[cfg(feature = 1)] + | ^ diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_module_details.rs b/frame/support/test/tests/construct_runtime_ui/invalid_module_details.rs index 9fb3169e1df77..bf6919f5a58ef 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_module_details.rs +++ b/frame/support/test/tests/construct_runtime_ui/invalid_module_details.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { system: System::(), } diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_module_details.stderr b/frame/support/test/tests/construct_runtime_ui/invalid_module_details.stderr index 0a20cf4e39a88..1f9277c3f0a8e 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_module_details.stderr +++ b/frame/support/test/tests/construct_runtime_ui/invalid_module_details.stderr @@ -1,5 +1,5 @@ error: Unexpected tokens, expected one of `::$ident` `::{`, `exclude_parts`, `use_parts`, `=`, `,` - --> tests/construct_runtime_ui/invalid_module_details.rs:9:17 + --> tests/construct_runtime_ui/invalid_module_details.rs:6:17 | -9 | system: System::(), +6 | system: System::(), | ^ diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.rs b/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.rs index 6ba268b73eea6..51f14e6883e4a 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.rs +++ b/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { system: System::{enum}, } diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.stderr b/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.stderr index f1c3929fff25f..dfcc9b8be42c6 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.stderr +++ b/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.stderr @@ -1,5 +1,5 @@ error: expected one of: `Pallet`, `Call`, `Storage`, `Event`, `Error`, `Config`, `Origin`, `Inherent`, `ValidateUnsigned`, `FreezeReason`, `HoldReason`, `LockId`, `SlashReason` - --> $DIR/invalid_module_details_keyword.rs:9:20 + --> tests/construct_runtime_ui/invalid_module_details_keyword.rs:6:20 | -9 | system: System::{enum}, +6 | system: System::{enum}, | ^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_module_entry.rs b/frame/support/test/tests/construct_runtime_ui/invalid_module_entry.rs index 173916f2ff6eb..607741d7823d4 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_module_entry.rs +++ b/frame/support/test/tests/construct_runtime_ui/invalid_module_entry.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: system::{Pallet}, Balance: balances::{Unexpected}, diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_module_entry.stderr b/frame/support/test/tests/construct_runtime_ui/invalid_module_entry.stderr index 2d5eeb5108fb9..9dd849ff0412e 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_module_entry.stderr +++ b/frame/support/test/tests/construct_runtime_ui/invalid_module_entry.stderr @@ -1,5 +1,5 @@ error: expected one of: `Pallet`, `Call`, `Storage`, `Event`, `Error`, `Config`, `Origin`, `Inherent`, `ValidateUnsigned`, `FreezeReason`, `HoldReason`, `LockId`, `SlashReason` - --> $DIR/invalid_module_entry.rs:10:23 - | -10 | Balance: balances::{Unexpected}, - | ^^^^^^^^^^ + --> tests/construct_runtime_ui/invalid_module_entry.rs:7:23 + | +7 | Balance: balances::{Unexpected}, + | ^^^^^^^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.rs b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.rs index 09c316e6ebaed..c132fa01b2297 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.rs +++ b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { system: System ? } diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.stderr b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.stderr index 6025de82bd206..80be1b8dd42fd 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.stderr +++ b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.stderr @@ -1,5 +1,5 @@ error: Unexpected tokens, expected one of `::$ident` `::{`, `exclude_parts`, `use_parts`, `=`, `,` - --> $DIR/invalid_token_after_module.rs:9:18 + --> tests/construct_runtime_ui/invalid_token_after_module.rs:6:18 | -9 | system: System ? +6 | system: System ? | ^ diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.rs b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.rs index 18d367d102d3a..42e7759f87f2b 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.rs +++ b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { system ? } diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.stderr b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.stderr index eaae082c8460c..8988f8a35b0a4 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.stderr +++ b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.stderr @@ -1,5 +1,5 @@ error: expected `:` - --> $DIR/invalid_token_after_name.rs:9:10 + --> tests/construct_runtime_ui/invalid_token_after_name.rs:6:10 | -9 | system ? +6 | system ? | ^ diff --git a/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.rs b/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.rs index d3018f02f89e3..bc2039c4e8180 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.rs +++ b/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: system expanded::{}::{Pallet}, Balance: balances:: expanded::{}::{Event}, diff --git a/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.stderr b/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.stderr index 97968df36a482..30fcba4c710d0 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.stderr +++ b/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.stderr @@ -1,5 +1,5 @@ error: Instantiable pallet with no generic `Event` cannot be constructed: pallet `Balance` must have generic `Event` - --> $DIR/missing_event_generic_on_module_with_instance.rs:10:3 - | -10 | Balance: balances:: expanded::{}::{Event}, - | ^^^^^^^ + --> tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.rs:7:3 + | +7 | Balance: balances:: expanded::{}::{Event}, + | ^^^^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/missing_module_instance.rs b/frame/support/test/tests/construct_runtime_ui/missing_module_instance.rs index 24e4ee979bd76..afd96a04854f2 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_module_instance.rs +++ b/frame/support/test/tests/construct_runtime_ui/missing_module_instance.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { system: System::<>, } diff --git a/frame/support/test/tests/construct_runtime_ui/missing_module_instance.stderr b/frame/support/test/tests/construct_runtime_ui/missing_module_instance.stderr index 6303c74e42e5c..5072f718db12e 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_module_instance.stderr +++ b/frame/support/test/tests/construct_runtime_ui/missing_module_instance.stderr @@ -1,5 +1,5 @@ error: expected identifier - --> $DIR/missing_module_instance.rs:9:20 + --> tests/construct_runtime_ui/missing_module_instance.rs:6:20 | -9 | system: System::<>, +6 | system: System::<>, | ^ diff --git a/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.rs b/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.rs index 5fc238067f287..42db63ae90a3a 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.rs +++ b/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: system expanded::{}::{Pallet}, Balance: balances:: expanded::{}::{Origin}, diff --git a/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.stderr b/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.stderr index f7df25d4c363f..6c076d7b49fc0 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.stderr +++ b/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.stderr @@ -1,5 +1,5 @@ error: Instantiable pallet with no generic `Origin` cannot be constructed: pallet `Balance` must have generic `Origin` - --> $DIR/missing_origin_generic_on_module_with_instance.rs:10:3 - | -10 | Balance: balances:: expanded::{}::{Origin}, - | ^^^^^^^ + --> tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.rs:7:3 + | +7 | Balance: balances:: expanded::{}::{Origin}, + | ^^^^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/missing_system_module.rs b/frame/support/test/tests/construct_runtime_ui/missing_system_module.rs index 7ab902c3aadd8..685f9059b1be2 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_system_module.rs +++ b/frame/support/test/tests/construct_runtime_ui/missing_system_module.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { } } diff --git a/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr b/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr index 7648f5c1bfb33..c8631f44051ca 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr +++ b/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr @@ -1,6 +1,6 @@ -error: `System` pallet declaration is missing. Please add this line: `System: frame_system::{Pallet, Call, Storage, Config, Event},` - --> $DIR/missing_system_module.rs:8:2 +error: `System` pallet declaration is missing. Please add this line: `System: frame_system::{Pallet, Call, Storage, Config, Event},` + --> tests/construct_runtime_ui/missing_system_module.rs:5:2 | -8 | / { -9 | | } +5 | / { +6 | | } | |_____^ diff --git a/frame/support/test/tests/construct_runtime_ui/missing_where_block.rs b/frame/support/test/tests/construct_runtime_ui/missing_where_block.rs deleted file mode 100644 index 303df6b03d72e..0000000000000 --- a/frame/support/test/tests/construct_runtime_ui/missing_where_block.rs +++ /dev/null @@ -1,7 +0,0 @@ -use frame_support::construct_runtime; - -construct_runtime! { - pub struct Runtime {} -} - -fn main() {} diff --git a/frame/support/test/tests/construct_runtime_ui/missing_where_block.stderr b/frame/support/test/tests/construct_runtime_ui/missing_where_block.stderr deleted file mode 100644 index d2a66f95101f4..0000000000000 --- a/frame/support/test/tests/construct_runtime_ui/missing_where_block.stderr +++ /dev/null @@ -1,5 +0,0 @@ -error: expected `where` - --> tests/construct_runtime_ui/missing_where_block.rs:4:21 - | -4 | pub struct Runtime {} - | ^ diff --git a/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs b/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs index 577dbf4091048..738ff0df3a07f 100644 --- a/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs +++ b/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs @@ -23,13 +23,12 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); @@ -47,10 +46,7 @@ impl frame_system::Config for Runtime { } construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system::{Pallet, Call, Storage, Config, Event}, Pallet1: pallet::{Pallet}, diff --git a/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.stderr b/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.stderr index 19a9a7bd08e32..55cef6704ee3f 100644 --- a/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.stderr +++ b/frame/support/test/tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.stderr @@ -1,7 +1,7 @@ error: The number of pallets exceeds the maximum number of tuple elements. To increase this limit, enable the tuples-96 feature of [frame_support]. - --> tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs:50:2 + --> tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs:49:2 | -50 | pub struct Runtime where +49 | pub struct Runtime | ^^^ error[E0412]: cannot find type `RuntimeCall` in this scope @@ -34,26 +34,26 @@ error[E0412]: cannot find type `RuntimeOrigin` in this scope | ^^^^^^^^^^^^^ help: you might have meant to use the associated type: `Self::RuntimeOrigin` error[E0412]: cannot find type `RuntimeCall` in this scope - --> tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs:27:21 + --> tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs:26:21 | -27 | type RuntimeCall = RuntimeCall; +26 | type RuntimeCall = RuntimeCall; | ^^^^^^^^^^^ help: you might have meant to use the associated type: `Self::RuntimeCall` error[E0412]: cannot find type `RuntimeEvent` in this scope - --> tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs:33:22 + --> tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs:32:22 | -33 | type RuntimeEvent = RuntimeEvent; +32 | type RuntimeEvent = RuntimeEvent; | ^^^^^^^^^^^^ help: you might have meant to use the associated type: `Self::RuntimeEvent` error[E0412]: cannot find type `PalletInfo` in this scope - --> tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs:39:20 + --> tests/construct_runtime_ui/number_of_pallets_exceeds_tuple_size.rs:38:20 | -39 | type PalletInfo = PalletInfo; +38 | type PalletInfo = PalletInfo; | ^^^^^^^^^^ | help: you might have meant to use the associated type | -39 | type PalletInfo = Self::PalletInfo; +38 | type PalletInfo = Self::PalletInfo; | ~~~~~~~~~~~~~~~~ help: consider importing this trait | diff --git a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs index 3b5773f2c9386..e21ddf65921a1 100644 --- a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs +++ b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs @@ -48,13 +48,12 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); @@ -72,10 +71,7 @@ impl frame_system::Config for Runtime { } construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system::{Pallet, Call, Storage, Config, Event}, Pallet: pallet::{Pallet}, diff --git a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.stderr b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.stderr index b9cec02a2b092..47504573515a2 100644 --- a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.stderr +++ b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.stderr @@ -1,13 +1,13 @@ error[E0080]: evaluation of constant value failed - --> tests/construct_runtime_ui/pallet_error_too_large.rs:74:1 + --> tests/construct_runtime_ui/pallet_error_too_large.rs:73:1 | -74 | / construct_runtime! { -75 | | pub struct Runtime where -76 | | Block = Block, -77 | | NodeBlock = Block, -... | -82 | | } -83 | | } - | |_^ the evaluated program panicked at 'The maximum encoded size of the error type in the `Pallet` pallet exceeds `MAX_MODULE_ERROR_ENCODED_SIZE`', $DIR/tests/construct_runtime_ui/pallet_error_too_large.rs:74:1 +73 | / construct_runtime! { +74 | | pub struct Runtime +75 | | { +76 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, +77 | | Pallet: pallet::{Pallet}, +78 | | } +79 | | } + | |_^ the evaluated program panicked at 'The maximum encoded size of the error type in the `Pallet` pallet exceeds `MAX_MODULE_ERROR_ENCODED_SIZE`', $DIR/tests/construct_runtime_ui/pallet_error_too_large.rs:73:1 | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs index a65acf43584c7..c57272c2caa33 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs @@ -23,13 +23,12 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); @@ -47,10 +46,7 @@ impl frame_system::Config for Runtime { } construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system::{Pallet, Call, Storage, Config, Event}, Pallet: pallet::{Pallet, Call}, diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.stderr index c2092edea05b5..f3f29e4c69554 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.stderr @@ -4,13 +4,13 @@ error: `Pallet` does not have #[pallet::call] defined, perhaps you should remove 5 | #[frame_support::pallet] | ^^^^^^^^^^^^^^^^^^^^^^^^ ... -49 | / construct_runtime! { -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +48 | / construct_runtime! { +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet::{Pallet, Call}, +53 | | } +54 | | } | |_- in this macro invocation | = note: this error originates in the macro `pallet::__substrate_call_check::is_call_part_defined` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs index fdc8a44930666..6fa4389b98ddf 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs @@ -23,13 +23,12 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); @@ -47,10 +46,7 @@ impl frame_system::Config for Runtime { } construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, Pallet: pallet expanded::{}::{Pallet, Event}, diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr index eb667fe04a39e..81e42cec3b97a 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr @@ -4,27 +4,27 @@ error: `Pallet` does not have #[pallet::event] defined, perhaps you should remov 5 | #[frame_support::pallet] | ^^^^^^^^^^^^^^^^^^^^^^^^ ... -49 | / construct_runtime! { -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +48 | / construct_runtime! { +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet expanded::{}::{Pallet, Event}, +53 | | } +54 | | } | |_- in this macro invocation | = note: this error originates in the macro `pallet::__substrate_event_check::is_event_part_defined` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0412]: cannot find type `Event` in module `pallet` - --> tests/construct_runtime_ui/undefined_event_part.rs:49:1 + --> tests/construct_runtime_ui/undefined_event_part.rs:48:1 | -49 | / construct_runtime! { -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +48 | / construct_runtime! { +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet expanded::{}::{Pallet, Event}, +53 | | } +54 | | } | |_^ not found in `pallet` | = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs index c245f65119776..8470ae3a78a7e 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs @@ -23,13 +23,12 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); @@ -47,10 +46,7 @@ impl frame_system::Config for Runtime { } construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, Pallet: pallet expanded::{}::{Pallet, Config}, diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.stderr index cdab7d3afa18c..920785fc96291 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.stderr @@ -4,27 +4,27 @@ error: `Pallet` does not have #[pallet::genesis_config] defined, perhaps you sho 5 | #[frame_support::pallet] | ^^^^^^^^^^^^^^^^^^^^^^^^ ... -49 | / construct_runtime! { -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +48 | / construct_runtime! { +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet expanded::{}::{Pallet, Config}, +53 | | } +54 | | } | |_- in this macro invocation | = note: this error originates in the macro `pallet::__substrate_genesis_config_check::is_genesis_config_defined` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0412]: cannot find type `GenesisConfig` in module `pallet` - --> tests/construct_runtime_ui/undefined_genesis_config_part.rs:49:1 + --> tests/construct_runtime_ui/undefined_genesis_config_part.rs:48:1 | -49 | / construct_runtime! { -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +48 | / construct_runtime! { +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet expanded::{}::{Pallet, Config}, +53 | | } +54 | | } | |_^ not found in `pallet` | = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs index 966d2d119baab..0ebee2b980e17 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs @@ -23,13 +23,12 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); @@ -47,10 +46,7 @@ impl frame_system::Config for Runtime { } construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, Pallet: pallet expanded::{}::{Pallet, Inherent}, diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.stderr index a068cab4cb1ab..659d43b151006 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.stderr @@ -4,31 +4,31 @@ error: `Pallet` does not have #[pallet::inherent] defined, perhaps you should re 5 | #[frame_support::pallet] | ^^^^^^^^^^^^^^^^^^^^^^^^ ... -49 | / construct_runtime! { -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +48 | / construct_runtime! { +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet expanded::{}::{Pallet, Inherent}, +53 | | } +54 | | } | |_- in this macro invocation | = note: this error originates in the macro `pallet::__substrate_inherent_check::is_inherent_part_defined` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0599]: no function or associated item named `create_inherent` found for struct `pallet::Pallet` in the current scope - --> tests/construct_runtime_ui/undefined_inherent_part.rs:49:1 + --> tests/construct_runtime_ui/undefined_inherent_part.rs:48:1 | 11 | pub struct Pallet(_); | -------------------- function or associated item `create_inherent` not found for this struct ... -49 | construct_runtime! { +48 | construct_runtime! { | _^ -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet expanded::{}::{Pallet, Inherent}, +53 | | } +54 | | } | |_^ function or associated item not found in `Pallet` | = help: items from traits can only be used if the trait is implemented and in scope @@ -37,19 +37,19 @@ error[E0599]: no function or associated item named `create_inherent` found for s = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0599]: no function or associated item named `is_inherent` found for struct `pallet::Pallet` in the current scope - --> tests/construct_runtime_ui/undefined_inherent_part.rs:49:1 + --> tests/construct_runtime_ui/undefined_inherent_part.rs:48:1 | 11 | pub struct Pallet(_); | -------------------- function or associated item `is_inherent` not found for this struct ... -49 | construct_runtime! { +48 | construct_runtime! { | _^ -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet expanded::{}::{Pallet, Inherent}, +53 | | } +54 | | } | |_^ function or associated item not found in `Pallet` | = help: items from traits can only be used if the trait is implemented and in scope @@ -58,19 +58,19 @@ error[E0599]: no function or associated item named `is_inherent` found for struc = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0599]: no function or associated item named `check_inherent` found for struct `pallet::Pallet` in the current scope - --> tests/construct_runtime_ui/undefined_inherent_part.rs:49:1 + --> tests/construct_runtime_ui/undefined_inherent_part.rs:48:1 | 11 | pub struct Pallet(_); | -------------------- function or associated item `check_inherent` not found for this struct ... -49 | construct_runtime! { +48 | construct_runtime! { | _^ -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet expanded::{}::{Pallet, Inherent}, +53 | | } +54 | | } | |_^ function or associated item not found in `Pallet` | = help: items from traits can only be used if the trait is implemented and in scope @@ -79,19 +79,19 @@ error[E0599]: no function or associated item named `check_inherent` found for st = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0599]: no associated item named `INHERENT_IDENTIFIER` found for struct `pallet::Pallet` in the current scope - --> tests/construct_runtime_ui/undefined_inherent_part.rs:49:1 + --> tests/construct_runtime_ui/undefined_inherent_part.rs:48:1 | 11 | pub struct Pallet(_); | -------------------- associated item `INHERENT_IDENTIFIER` not found for this struct ... -49 | construct_runtime! { +48 | construct_runtime! { | _^ -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet expanded::{}::{Pallet, Inherent}, +53 | | } +54 | | } | |_^ associated item not found in `Pallet` | = help: items from traits can only be used if the trait is implemented and in scope @@ -100,19 +100,19 @@ error[E0599]: no associated item named `INHERENT_IDENTIFIER` found for struct `p = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0599]: no function or associated item named `is_inherent_required` found for struct `pallet::Pallet` in the current scope - --> tests/construct_runtime_ui/undefined_inherent_part.rs:49:1 + --> tests/construct_runtime_ui/undefined_inherent_part.rs:48:1 | 11 | pub struct Pallet(_); | -------------------- function or associated item `is_inherent_required` not found for this struct ... -49 | construct_runtime! { +48 | construct_runtime! { | _^ -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet expanded::{}::{Pallet, Inherent}, +53 | | } +54 | | } | |_^ function or associated item not found in `Pallet` | = help: items from traits can only be used if the trait is implemented and in scope diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs index fb712dbf05acc..75059716f6bc4 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs @@ -23,13 +23,12 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); @@ -47,10 +46,7 @@ impl frame_system::Config for Runtime { } construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, Pallet: pallet expanded::{}::{Pallet, Origin}, diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.stderr index 0677340e25c12..c41dbe79421ea 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.stderr @@ -4,27 +4,27 @@ error: `Pallet` does not have #[pallet::origin] defined, perhaps you should remo 5 | #[frame_support::pallet] | ^^^^^^^^^^^^^^^^^^^^^^^^ ... -49 | / construct_runtime! { -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +48 | / construct_runtime! { +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet expanded::{}::{Pallet, Origin}, +53 | | } +54 | | } | |_- in this macro invocation | = note: this error originates in the macro `pallet::__substrate_origin_check::is_origin_part_defined` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0412]: cannot find type `Origin` in module `pallet` - --> tests/construct_runtime_ui/undefined_origin_part.rs:49:1 + --> tests/construct_runtime_ui/undefined_origin_part.rs:48:1 | -49 | / construct_runtime! { -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +48 | / construct_runtime! { +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system expanded::{}::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet expanded::{}::{Pallet, Origin}, +53 | | } +54 | | } | |_^ not found in `pallet` | = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs index 3fb42f9a1ee04..4ef93084835dc 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs @@ -23,13 +23,12 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); @@ -47,10 +46,7 @@ impl frame_system::Config for Runtime { } construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system::{Pallet, Call, Storage, Config, Event}, Pallet: pallet::{Pallet, ValidateUnsigned}, diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.stderr index c2205c5286084..007b77250736e 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.stderr @@ -4,48 +4,46 @@ error: `Pallet` does not have #[pallet::validate_unsigned] defined, perhaps you 5 | #[frame_support::pallet] | ^^^^^^^^^^^^^^^^^^^^^^^^ ... -49 | / construct_runtime! { -50 | | pub struct Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } +48 | / construct_runtime! { +49 | | pub struct Runtime +50 | | { +51 | | System: frame_system::{Pallet, Call, Storage, Config, Event}, +52 | | Pallet: pallet::{Pallet, ValidateUnsigned}, +53 | | } +54 | | } | |_- in this macro invocation | = note: this error originates in the macro `pallet::__substrate_validate_unsigned_check::is_validate_unsigned_part_defined` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0599]: no variant or associated item named `Pallet` found for enum `RuntimeCall` in the current scope - --> tests/construct_runtime_ui/undefined_validate_unsigned_part.rs:56:3 + --> tests/construct_runtime_ui/undefined_validate_unsigned_part.rs:52:3 | -49 | // construct_runtime! { -50 | || pub struct Runtime where -51 | || Block = Block, -52 | || NodeBlock = Block, -... || -55 | || System: frame_system::{Pallet, Call, Storage, Config, Event}, -56 | || Pallet: pallet::{Pallet, ValidateUnsigned}, +48 | // construct_runtime! { +49 | || pub struct Runtime +50 | || { +51 | || System: frame_system::{Pallet, Call, Storage, Config, Event}, +52 | || Pallet: pallet::{Pallet, ValidateUnsigned}, | || -^^^^^^ variant or associated item not found in `RuntimeCall` | ||________| | | ... | error[E0599]: no function or associated item named `pre_dispatch` found for struct `pallet::Pallet` in the current scope - --> tests/construct_runtime_ui/undefined_validate_unsigned_part.rs:49:1 + --> tests/construct_runtime_ui/undefined_validate_unsigned_part.rs:48:1 | 11 | pub struct Pallet(_); | -------------------- function or associated item `pre_dispatch` not found for this struct ... -49 | construct_runtime! { +48 | construct_runtime! { | __^ | | _| | || -50 | || pub struct Runtime where -51 | || Block = Block, -52 | || NodeBlock = Block, -... || -57 | || } -58 | || } +49 | || pub struct Runtime +50 | || { +51 | || System: frame_system::{Pallet, Call, Storage, Config, Event}, +52 | || Pallet: pallet::{Pallet, ValidateUnsigned}, +53 | || } +54 | || } | ||_- in this macro invocation ... | | @@ -56,21 +54,21 @@ error[E0599]: no function or associated item named `pre_dispatch` found for stru = note: this error originates in the macro `frame_support::construct_runtime` which comes from the expansion of the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0599]: no function or associated item named `validate_unsigned` found for struct `pallet::Pallet` in the current scope - --> tests/construct_runtime_ui/undefined_validate_unsigned_part.rs:49:1 + --> tests/construct_runtime_ui/undefined_validate_unsigned_part.rs:48:1 | 11 | pub struct Pallet(_); | -------------------- function or associated item `validate_unsigned` not found for this struct ... -49 | construct_runtime! { +48 | construct_runtime! { | __^ | | _| | || -50 | || pub struct Runtime where -51 | || Block = Block, -52 | || NodeBlock = Block, -... || -57 | || } -58 | || } +49 | || pub struct Runtime +50 | || { +51 | || System: frame_system::{Pallet, Call, Storage, Config, Event}, +52 | || Pallet: pallet::{Pallet, ValidateUnsigned}, +53 | || } +54 | || } | ||_- in this macro invocation ... | | diff --git a/frame/support/test/tests/construct_runtime_ui/unsupported_meta_structure.rs b/frame/support/test/tests/construct_runtime_ui/unsupported_meta_structure.rs index e5fd284dc8722..e4e2d3dca021e 100644 --- a/frame/support/test/tests/construct_runtime_ui/unsupported_meta_structure.rs +++ b/frame/support/test/tests/construct_runtime_ui/unsupported_meta_structure.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: system::{Pallet}, #[cfg(feature(test))] diff --git a/frame/support/test/tests/construct_runtime_ui/unsupported_meta_structure.stderr b/frame/support/test/tests/construct_runtime_ui/unsupported_meta_structure.stderr index 98d99a0d34997..34637269db617 100644 --- a/frame/support/test/tests/construct_runtime_ui/unsupported_meta_structure.stderr +++ b/frame/support/test/tests/construct_runtime_ui/unsupported_meta_structure.stderr @@ -1,6 +1,6 @@ error: feature(test) ^ expected one of `=`, `,`, `)` here - --> tests/construct_runtime_ui/unsupported_meta_structure.rs:10:3 - | -10 | #[cfg(feature(test))] - | ^ + --> tests/construct_runtime_ui/unsupported_meta_structure.rs:7:3 + | +7 | #[cfg(feature(test))] + | ^ diff --git a/frame/support/test/tests/construct_runtime_ui/unsupported_pallet_attr.rs b/frame/support/test/tests/construct_runtime_ui/unsupported_pallet_attr.rs index 03363d30a6429..491cc2c90533d 100644 --- a/frame/support/test/tests/construct_runtime_ui/unsupported_pallet_attr.rs +++ b/frame/support/test/tests/construct_runtime_ui/unsupported_pallet_attr.rs @@ -1,10 +1,7 @@ use frame_support::construct_runtime; construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: system::{Pallet}, #[attr] diff --git a/frame/support/test/tests/construct_runtime_ui/unsupported_pallet_attr.stderr b/frame/support/test/tests/construct_runtime_ui/unsupported_pallet_attr.stderr index fceb2b8a99db8..da1b61b1c3078 100644 --- a/frame/support/test/tests/construct_runtime_ui/unsupported_pallet_attr.stderr +++ b/frame/support/test/tests/construct_runtime_ui/unsupported_pallet_attr.stderr @@ -1,5 +1,5 @@ error: Unsupported attribute, only #[cfg] is supported on pallet declarations in `construct_runtime` - --> tests/construct_runtime_ui/unsupported_pallet_attr.rs:10:3 - | -10 | #[attr] - | ^ + --> tests/construct_runtime_ui/unsupported_pallet_attr.rs:7:3 + | +7 | #[attr] + | ^ diff --git a/frame/support/test/tests/construct_runtime_ui/use_undefined_part.rs b/frame/support/test/tests/construct_runtime_ui/use_undefined_part.rs index 971e2b831ae08..8563be1008cd9 100644 --- a/frame/support/test/tests/construct_runtime_ui/use_undefined_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/use_undefined_part.rs @@ -25,12 +25,9 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic}, + System: system::{Pallet, Call, Storage, Config, Event}, Pallet: pallet use_parts { Call }, } } diff --git a/frame/support/test/tests/construct_runtime_ui/use_undefined_part.stderr b/frame/support/test/tests/construct_runtime_ui/use_undefined_part.stderr index cb6b6a44d61da..4058ccab2c5d7 100644 --- a/frame/support/test/tests/construct_runtime_ui/use_undefined_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/use_undefined_part.stderr @@ -1,7 +1,7 @@ error: Invalid pallet part specified, the pallet `Pallet` doesn't have the `Call` part. Available parts are: `Pallet`, `Storage`. - --> tests/construct_runtime_ui/use_undefined_part.rs:34:30 + --> tests/construct_runtime_ui/use_undefined_part.rs:31:30 | -34 | Pallet: pallet use_parts { Call }, +31 | Pallet: pallet use_parts { Call }, | ^^^^ error[E0412]: cannot find type `RuntimeCall` in this scope diff --git a/frame/support/test/tests/final_keys.rs b/frame/support/test/tests/final_keys.rs index 164da3ff444a5..765afaf1e6604 100644 --- a/frame/support/test/tests/final_keys.rs +++ b/frame/support/test/tests/final_keys.rs @@ -16,8 +16,10 @@ // limitations under the License. use codec::Encode; -use frame_support::{storage::unhashed, StoragePrefixedMap}; -use sp_core::sr25519; +use frame_support::{derive_impl, storage::unhashed, StoragePrefixedMap}; +use frame_system::pallet_prelude::BlockNumberFor; + +use sp_core::{sr25519, ConstU32}; use sp_io::{ hashing::{blake2_128, twox_128, twox_64}, TestExternalities, @@ -31,7 +33,6 @@ use sp_runtime::{ mod no_instance { use super::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; #[pallet::pallet] pub struct Pallet(_); @@ -59,7 +60,7 @@ mod no_instance { #[pallet::storage] #[pallet::getter(fn test_generic_value)] - pub type TestGenericValue = StorageValue<_, T::BlockNumber, OptionQuery>; + pub type TestGenericValue = StorageValue<_, BlockNumberFor, OptionQuery>; #[pallet::storage] #[pallet::getter(fn foo2)] pub type TestGenericDoubleMap = StorageDoubleMap< @@ -67,7 +68,7 @@ mod no_instance { Blake2_128Concat, u32, Blake2_128Concat, - T::BlockNumber, + BlockNumberFor, u32, ValueQuery, >; @@ -75,8 +76,8 @@ mod no_instance { #[pallet::genesis_config] pub struct GenesisConfig { pub value: u32, - pub test_generic_value: T::BlockNumber, - pub test_generic_double_map: Vec<(u32, T::BlockNumber, u32)>, + pub test_generic_value: BlockNumberFor, + pub test_generic_double_map: Vec<(u32, BlockNumberFor, u32)>, } impl Default for GenesisConfig { @@ -105,7 +106,6 @@ mod no_instance { mod instance { use super::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; #[pallet::pallet] pub struct Pallet(PhantomData<(T, I)>); @@ -136,7 +136,7 @@ mod instance { #[pallet::storage] #[pallet::getter(fn test_generic_value)] pub type TestGenericValue, I: 'static = ()> = - StorageValue<_, T::BlockNumber, OptionQuery>; + StorageValue<_, BlockNumberFor, OptionQuery>; #[pallet::storage] #[pallet::getter(fn foo2)] pub type TestGenericDoubleMap, I: 'static = ()> = StorageDoubleMap< @@ -144,7 +144,7 @@ mod instance { Blake2_128Concat, u32, Blake2_128Concat, - T::BlockNumber, + BlockNumberFor, u32, ValueQuery, >; @@ -152,8 +152,8 @@ mod instance { #[pallet::genesis_config] pub struct GenesisConfig, I: 'static = ()> { pub value: u32, - pub test_generic_value: T::BlockNumber, - pub test_generic_double_map: Vec<(u32, T::BlockNumber, u32)>, + pub test_generic_value: BlockNumberFor, + pub test_generic_double_map: Vec<(u32, BlockNumberFor, u32)>, pub phantom: PhantomData, } @@ -201,27 +201,25 @@ pub type Block = generic::Block; frame_support::construct_runtime!( pub enum Runtime - where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + { - System: frame_support_test, + System: frame_system, FinalKeysNone: no_instance, FinalKeysSome: instance, Instance2FinalKeysSome: instance::, } ); -impl frame_support_test::Config for Runtime { - type BlockNumber = BlockNumber; - type AccountId = AccountId; +#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] +impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; + type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; - type DbWeight = (); + type OnSetCode = (); } impl no_instance::Config for Runtime {} diff --git a/frame/support/test/tests/genesisconfig.rs b/frame/support/test/tests/genesisconfig.rs index 8ac7bc37e2e72..c6781220692a9 100644 --- a/frame/support/test/tests/genesisconfig.rs +++ b/frame/support/test/tests/genesisconfig.rs @@ -15,7 +15,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -use sp_core::sr25519; +use frame_support::derive_impl; +use frame_system::pallet_prelude::BlockNumberFor; +use sp_core::{sr25519, ConstU32}; use sp_runtime::{ generic, traits::{BlakeTwo256, Verify}, @@ -25,7 +27,6 @@ use sp_runtime::{ pub mod pallet { use super::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; #[pallet::pallet] pub struct Pallet(_); @@ -39,11 +40,11 @@ pub mod pallet { #[pallet::storage] #[pallet::unbounded] pub type AppendableDM = - StorageDoubleMap<_, Identity, u32, Identity, T::BlockNumber, Vec>; + StorageDoubleMap<_, Identity, u32, Identity, BlockNumberFor, Vec>; #[pallet::genesis_config] pub struct GenesisConfig { - pub t: Vec<(u32, T::BlockNumber, Vec)>, + pub t: Vec<(u32, BlockNumberFor, Vec)>, } impl Default for GenesisConfig { @@ -71,25 +72,23 @@ pub type Block = generic::Block; frame_support::construct_runtime!( pub enum Test - where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + { - System: frame_support_test, + System: frame_system, MyPallet: pallet, } ); -impl frame_support_test::Config for Test { - type BlockNumber = BlockNumber; - type AccountId = AccountId; +#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] +impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; + type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; - type DbWeight = (); + type OnSetCode = (); } impl pallet::Config for Test {} diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index 8d5d49927721f..2fb6d7658d6ab 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -18,6 +18,7 @@ #![recursion_limit = "128"] use frame_support::{ + derive_impl, inherent::{InherentData, InherentIdentifier, MakeFatalError, ProvideInherent}, metadata_ir::{ PalletStorageMetadataIR, StorageEntryMetadataIR, StorageEntryModifierIR, @@ -25,6 +26,7 @@ use frame_support::{ }, traits::ConstU32, }; +use frame_system::pallet_prelude::BlockNumberFor; use sp_core::sr25519; use sp_runtime::{ generic, @@ -39,10 +41,9 @@ pub trait Currency {} // * Origin, Inherent, Event #[frame_support::pallet(dev_mode)] mod module1 { - use self::frame_system::pallet_prelude::*; use super::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; + use frame_system::pallet_prelude::*; #[pallet::pallet] pub struct Pallet(_); @@ -77,7 +78,7 @@ mod module1 { #[pallet::genesis_config] pub struct GenesisConfig, I: 'static = ()> { pub value: >::GenericType, - pub test: ::BlockNumber, + pub test: BlockNumberFor, } impl, I: 'static> Default for GenesisConfig { @@ -89,7 +90,7 @@ mod module1 { #[pallet::genesis_build] impl, I: 'static> BuildGenesisConfig for GenesisConfig where - T::BlockNumber: std::fmt::Display, + BlockNumberFor: std::fmt::Display, { fn build(&self) { >::put(self.value.clone()); @@ -123,7 +124,7 @@ mod module1 { #[pallet::inherent] impl, I: 'static> ProvideInherent for Pallet where - T::BlockNumber: From, + BlockNumberFor: From, { type Call = Call; type Error = MakeFatalError<()>; @@ -150,7 +151,6 @@ mod module1 { mod module2 { use super::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; #[pallet::pallet] pub struct Pallet(PhantomData<(T, I)>); @@ -198,7 +198,7 @@ mod module2 { #[pallet::genesis_build] impl, I: 'static> BuildGenesisConfig for GenesisConfig where - T::BlockNumber: std::fmt::Display, + BlockNumberFor: std::fmt::Display, { fn build(&self) { >::put(self.value.clone()); @@ -252,7 +252,6 @@ mod module2 { mod module3 { use super::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; #[pallet::pallet] pub struct Pallet(PhantomData<(T, I)>); @@ -277,12 +276,9 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; frame_support::construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub enum Runtime { - System: frame_support_test::{Pallet, Call, Event}, + System: frame_system::{Pallet, Call, Event}, Module1_1: module1::::{ Pallet, Call, Storage, Event, Config, Origin, Inherent }, @@ -303,15 +299,16 @@ frame_support::construct_runtime!( } ); -impl frame_support_test::Config for Runtime { - type BlockNumber = BlockNumber; - type AccountId = AccountId; +#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] +impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; + type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; - type DbWeight = (); + type OnSetCode = (); } impl module1::Config for Runtime { diff --git a/frame/support/test/tests/issue2219.rs b/frame/support/test/tests/issue2219.rs index e6230dfc71018..4016707b51a8d 100644 --- a/frame/support/test/tests/issue2219.rs +++ b/frame/support/test/tests/issue2219.rs @@ -15,6 +15,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +use frame_support::derive_impl; +use frame_system::pallet_prelude::BlockNumberFor; use sp_core::{sr25519, ConstU64}; use sp_runtime::{ generic, @@ -25,10 +27,8 @@ use sp_runtime::{ mod module { use super::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; - pub type Request = - (::AccountId, Role, ::BlockNumber); + pub type Request = (::AccountId, Role, BlockNumberFor); pub type Requests = Vec>; #[derive(Copy, Clone, Eq, PartialEq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] @@ -46,35 +46,35 @@ mod module { pub max_actors: u32, // payouts are made at this block interval - pub reward_period: T::BlockNumber, + pub reward_period: BlockNumberFor, // minimum amount of time before being able to unstake - pub bonding_period: T::BlockNumber, + pub bonding_period: BlockNumberFor, // how long tokens remain locked for after unstaking - pub unbonding_period: T::BlockNumber, + pub unbonding_period: BlockNumberFor, // minimum period required to be in service. unbonding before this time is highly penalized - pub min_service_period: T::BlockNumber, + pub min_service_period: BlockNumberFor, // "startup" time allowed for roles that need to sync their infrastructure // with other providers before they are considered in service and punishable for // not delivering required level of service. - pub startup_grace_period: T::BlockNumber, + pub startup_grace_period: BlockNumberFor, } impl Default for RoleParameters { fn default() -> Self { Self { max_actors: 10, - reward_period: T::BlockNumber::default(), - unbonding_period: T::BlockNumber::default(), + reward_period: BlockNumberFor::::default(), + unbonding_period: BlockNumberFor::::default(), // not currently used min_actors: 5, - bonding_period: T::BlockNumber::default(), - min_service_period: T::BlockNumber::default(), - startup_grace_period: T::BlockNumber::default(), + bonding_period: BlockNumberFor::::default(), + min_service_period: BlockNumberFor::::default(), + startup_grace_period: BlockNumberFor::::default(), } } } @@ -115,7 +115,7 @@ mod module { /// tokens locked until given block number #[pallet::storage] #[pallet::getter(fn bondage)] - pub type Bondage = StorageMap<_, Blake2_128Concat, T::AccountId, T::BlockNumber>; + pub type Bondage = StorageMap<_, Blake2_128Concat, T::AccountId, BlockNumberFor>; /// First step before enter a role is registering intent with a new account/key. /// This is done by sending a role_entry_request() from the new account. @@ -161,27 +161,23 @@ pub type Header = generic::Header; pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; pub type Block = generic::Block; -impl frame_support_test::Config for Runtime { - type BlockNumber = BlockNumber; - type AccountId = AccountId; +#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] +impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; + type BlockHashCount = ConstU64<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; - type DbWeight = (); + type OnSetCode = (); } impl module::Config for Runtime {} frame_support::construct_runtime!( - pub struct Runtime - where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - System: frame_support_test, + pub struct Runtime { + System: frame_system, Module: module, } ); @@ -189,6 +185,7 @@ frame_support::construct_runtime!( #[test] fn create_genesis_config() { let config = RuntimeGenesisConfig { + system: Default::default(), module: module::GenesisConfig { request_life_time: 0, enable_storage_role: true, diff --git a/frame/support/test/tests/origin.rs b/frame/support/test/tests/origin.rs index 0d9a13c1bd8bc..5682bb500c7e3 100644 --- a/frame/support/test/tests/origin.rs +++ b/frame/support/test/tests/origin.rs @@ -19,15 +19,18 @@ #![recursion_limit = "128"] -use frame_support::traits::{Contains, OriginTrait}; +use frame_support::{ + derive_impl, + traits::{Contains, OriginTrait}, +}; +use sp_core::ConstU32; use sp_runtime::{generic, traits::BlakeTwo256}; mod nested { #[frame_support::pallet(dev_mode)] pub mod module { - use self::frame_system::pallet_prelude::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; + use frame_system::pallet_prelude::*; #[pallet::pallet] pub struct Pallet(_); @@ -75,9 +78,8 @@ mod nested { #[frame_support::pallet(dev_mode)] pub mod module { - use self::frame_system::pallet_prelude::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; + use frame_system::pallet_prelude::*; #[pallet::pallet] pub struct Pallet(_); @@ -160,26 +162,24 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; frame_support::construct_runtime!( - pub enum RuntimeOriginTest where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub enum RuntimeOriginTest { - System: frame_support_test, + System: frame_system, NestedModule: nested::module, Module: module, } ); -impl frame_support_test::Config for RuntimeOriginTest { - type BlockNumber = BlockNumber; - type AccountId = AccountId; +#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] +impl frame_system::Config for RuntimeOriginTest { type BaseCallFilter = BaseCallFilter; + type Block = Block; + type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; - type DbWeight = (); + type OnSetCode = (); } impl nested::module::Config for RuntimeOriginTest { diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index e382176431b21..eddc3728612c2 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -657,13 +657,12 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU32<250>; type BlockWeights = (); @@ -709,10 +708,7 @@ pub type UncheckedExtrinsic = sp_runtime::testing::TestXt>; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { // Exclude part `Storage` in order not to check its metadata in tests. System: frame_system exclude_parts { Pallet, Storage }, diff --git a/frame/support/test/tests/pallet_instance.rs b/frame/support/test/tests/pallet_instance.rs index ed9ba048cf63c..0cd843c9bffe8 100644 --- a/frame/support/test/tests/pallet_instance.rs +++ b/frame/support/test/tests/pallet_instance.rs @@ -292,13 +292,12 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU32<250>; type BlockWeights = (); @@ -336,10 +335,7 @@ pub type Block = sp_runtime::generic::Block; pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { // Exclude part `Storage` in order not to check its metadata in tests. System: frame_system exclude_parts { Storage }, diff --git a/frame/support/test/tests/pallet_outer_enums_explicit.rs b/frame/support/test/tests/pallet_outer_enums_explicit.rs index 8c03f7ecf27aa..a8250f8b15325 100644 --- a/frame/support/test/tests/pallet_outer_enums_explicit.rs +++ b/frame/support/test/tests/pallet_outer_enums_explicit.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use frame_support::traits::ConstU32; +use frame_support::{derive_impl, traits::ConstU32}; mod common; @@ -25,31 +25,16 @@ pub type Header = sp_runtime::generic::Header; pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; +#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; + type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; - type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; - type Hash = sp_runtime::testing::H256; - type Hashing = sp_runtime::traits::BlakeTwo256; - type AccountId = u64; - type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; type RuntimeEvent = RuntimeEvent; - type BlockHashCount = ConstU32<250>; - type BlockWeights = (); - type BlockLength = (); - type DbWeight = (); - type Version = (); type PalletInfo = PalletInfo; - type AccountData = (); - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = ConstU32<16>; } impl common::outer_enums::pallet::Config for Runtime { @@ -72,10 +57,7 @@ impl common::outer_enums::pallet3::Config, Call, Event }, diff --git a/frame/support/test/tests/pallet_outer_enums_implicit.rs b/frame/support/test/tests/pallet_outer_enums_implicit.rs index 9a14538c35930..191f095f5d78d 100644 --- a/frame/support/test/tests/pallet_outer_enums_implicit.rs +++ b/frame/support/test/tests/pallet_outer_enums_implicit.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use frame_support::traits::ConstU32; +use frame_support::{derive_impl, traits::ConstU32}; mod common; @@ -25,31 +25,16 @@ pub type Header = sp_runtime::generic::Header; pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; +#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; + type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; - type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; - type Hash = sp_runtime::testing::H256; - type Hashing = sp_runtime::traits::BlakeTwo256; - type AccountId = u64; - type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; type RuntimeEvent = RuntimeEvent; - type BlockHashCount = ConstU32<250>; - type BlockWeights = (); - type BlockLength = (); - type DbWeight = (); - type Version = (); type PalletInfo = PalletInfo; - type AccountData = (); - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = ConstU32<16>; } impl common::outer_enums::pallet::Config for Runtime { @@ -72,10 +57,7 @@ impl common::outer_enums::pallet3::Config; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU32<250>; type BlockWeights = (); @@ -89,10 +88,7 @@ pub type Block = sp_runtime::generic::Block; pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { // Exclude part `Storage` in order not to check its metadata in tests. System: frame_system exclude_parts { Pallet, Storage }, diff --git a/frame/support/test/tests/pallet_ui/pass/no_std_genesis_config.rs b/frame/support/test/tests/pallet_ui/pass/no_std_genesis_config.rs index 7682caf6bf1ce..8f50d09e0f0d6 100644 --- a/frame/support/test/tests/pallet_ui/pass/no_std_genesis_config.rs +++ b/frame/support/test/tests/pallet_ui/pass/no_std_genesis_config.rs @@ -14,13 +14,12 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); @@ -38,10 +37,7 @@ impl frame_system::Config for Runtime { } construct_runtime! { - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub struct Runtime { System: frame_system::{Pallet, Call, Storage, Config, Event}, Pallet: test_pallet::{Pallet, Config}, diff --git a/frame/support/test/tests/runtime_metadata.rs b/frame/support/test/tests/runtime_metadata.rs index 70ca307d4428c..44c375a9a674f 100644 --- a/frame/support/test/tests/runtime_metadata.rs +++ b/frame/support/test/tests/runtime_metadata.rs @@ -37,13 +37,12 @@ impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU32<250>; type Version = (); @@ -58,10 +57,7 @@ impl frame_system::Config for Runtime { } frame_support::construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + pub enum Runtime { System: frame_system, } diff --git a/frame/support/test/tests/storage_layers.rs b/frame/support/test/tests/storage_layers.rs index 3e306834869bb..93a541ad91162 100644 --- a/frame/support/test/tests/storage_layers.rs +++ b/frame/support/test/tests/storage_layers.rs @@ -71,12 +71,11 @@ impl frame_system::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = Index; - type BlockNumber = BlockNumber; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU32<250>; type DbWeight = (); @@ -94,12 +93,7 @@ impl frame_system::Config for Runtime { impl Config for Runtime {} frame_support::construct_runtime!( - pub struct Runtime - where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { + pub struct Runtime { System: frame_system, MyPallet: pallet, } diff --git a/frame/support/test/tests/storage_transaction.rs b/frame/support/test/tests/storage_transaction.rs index 5fc4ba7cca6d9..c477433086098 100644 --- a/frame/support/test/tests/storage_transaction.rs +++ b/frame/support/test/tests/storage_transaction.rs @@ -19,12 +19,12 @@ #![allow(deprecated)] use frame_support::{ - assert_noop, assert_ok, assert_storage_noop, + assert_noop, assert_ok, assert_storage_noop, derive_impl, dispatch::DispatchResult, storage::{with_transaction, TransactionOutcome::*}, transactional, }; -use sp_core::sr25519; +use sp_core::{sr25519, ConstU32}; use sp_io::TestExternalities; use sp_runtime::{ generic, @@ -36,10 +36,9 @@ pub use self::pallet::*; #[frame_support::pallet] pub mod pallet { - use self::frame_system::pallet_prelude::*; use super::*; use frame_support::pallet_prelude::*; - use frame_support_test as frame_system; + use frame_system::pallet_prelude::*; #[pallet::pallet] #[pallet::generate_store(pub (super) trait Store)] @@ -82,25 +81,23 @@ pub type Block = generic::Block; frame_support::construct_runtime!( pub enum Runtime - where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + { - System: frame_support_test, + System: frame_system, MyPallet: pallet, } ); -impl frame_support_test::Config for Runtime { - type BlockNumber = BlockNumber; - type AccountId = AccountId; +#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] +impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; + type BlockHashCount = ConstU32<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; - type DbWeight = (); + type OnSetCode = (); } impl Config for Runtime {} diff --git a/frame/support/test/tests/versioned_runtime_upgrade.rs b/frame/support/test/tests/versioned_runtime_upgrade.rs index 338d0776974ad..93d87df8ca185 100644 --- a/frame/support/test/tests/versioned_runtime_upgrade.rs +++ b/frame/support/test/tests/versioned_runtime_upgrade.rs @@ -27,9 +27,9 @@ use frame_support::{ weights::constants::RocksDbWeight, }; use frame_system::Config; +use sp_core::ConstU64; use sp_runtime::BuildStorage; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; #[frame_support::pallet] @@ -64,10 +64,7 @@ mod dummy_pallet { impl dummy_pallet::Config for Test {} construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event} = 0, DummyPallet: dummy_pallet::{Pallet, Config, Storage} = 1, @@ -77,6 +74,8 @@ construct_runtime!( #[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; + type Block = Block; + type BlockHashCount = ConstU64<10>; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; diff --git a/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index f344e041a0d49..93e2c61ad5cd8 100644 --- a/frame/system/benches/bench.rs +++ b/frame/system/benches/bench.rs @@ -19,7 +19,6 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion}; use frame_support::traits::{ConstU32, ConstU64}; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, Perbill, }; @@ -42,14 +41,10 @@ mod module { } } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub struct Runtime { System: frame_system::{Pallet, Call, Config, Storage, Event}, Module: module::{Pallet, Event}, @@ -69,13 +64,12 @@ impl frame_system::Config for Runtime { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/system/benchmarking/src/mock.rs b/frame/system/benchmarking/src/mock.rs index 98f8ea6e07ebf..4201f9dcc6f97 100644 --- a/frame/system/benchmarking/src/mock.rs +++ b/frame/system/benchmarking/src/mock.rs @@ -24,16 +24,11 @@ use sp_runtime::{traits::IdentityLookup, BuildStorage}; type AccountId = u64; type AccountIndex = u32; -type BlockNumber = u64; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, } @@ -46,13 +41,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = AccountIndex; - type BlockNumber = BlockNumber; type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = sp_runtime::testing::Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); diff --git a/frame/system/src/extensions/check_genesis.rs b/frame/system/src/extensions/check_genesis.rs index 5964ec452842f..76a711a823e7d 100644 --- a/frame/system/src/extensions/check_genesis.rs +++ b/frame/system/src/extensions/check_genesis.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::{Config, Pallet}; +use crate::{pallet_prelude::BlockNumberFor, Config, Pallet}; use codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_runtime::{ @@ -60,7 +60,7 @@ impl SignedExtension for CheckGenesis { const IDENTIFIER: &'static str = "CheckGenesis"; fn additional_signed(&self) -> Result { - Ok(>::block_hash(T::BlockNumber::zero())) + Ok(>::block_hash(BlockNumberFor::::zero())) } fn pre_dispatch( diff --git a/frame/system/src/extensions/check_mortality.rs b/frame/system/src/extensions/check_mortality.rs index 23c357d481350..148dfd4aad471 100644 --- a/frame/system/src/extensions/check_mortality.rs +++ b/frame/system/src/extensions/check_mortality.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::{BlockHash, Config, Pallet}; +use crate::{pallet_prelude::BlockNumberFor, BlockHash, Config, Pallet}; use codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_runtime::{ @@ -78,7 +78,7 @@ impl SignedExtension for CheckMortality { fn additional_signed(&self) -> Result { let current_u64 = >::block_number().saturated_into::(); - let n = self.0.birth(current_u64).saturated_into::(); + let n = self.0.birth(current_u64).saturated_into::>(); if !>::contains_key(n) { Err(InvalidTransaction::AncientBirthBlock.into()) } else { diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 9fcd7c12fec4e..a4c40032c8972 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -64,6 +64,7 @@ #![cfg_attr(not(feature = "std"), no_std)] +use pallet_prelude::{BlockNumberFor, HeaderFor}; #[cfg(feature = "std")] use serde::Serialize; use sp_io::hashing::blake2_256; @@ -72,9 +73,9 @@ use sp_runtime::traits::TrailingZeroInput; use sp_runtime::{ generic, traits::{ - self, AtLeast32Bit, AtLeast32BitUnsigned, BadOrigin, BlockNumberProvider, Bounded, - CheckEqual, Dispatchable, Hash, Lookup, LookupError, MaybeDisplay, - MaybeSerializeDeserialize, Member, One, Saturating, SimpleBitOps, StaticLookup, Zero, + self, AtLeast32Bit, BadOrigin, BlockNumberProvider, Bounded, CheckEqual, Dispatchable, + Hash, Header, Lookup, LookupError, MaybeDisplay, MaybeSerializeDeserialize, Member, One, + Saturating, SimpleBitOps, StaticLookup, Zero, }, DispatchError, RuntimeDebug, }; @@ -217,13 +218,10 @@ pub mod pallet { #[frame_support::register_default_impl(TestDefaultConfig)] impl DefaultConfig for TestDefaultConfig { type Index = u32; - type BlockNumber = u32; - type Header = sp_runtime::generic::Header; type Hash = sp_core::hash::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; - type BlockHashCount = frame_support::traits::ConstU32<10>; type MaxConsumers = frame_support::traits::ConstU32<16>; type AccountData = (); type OnNewAccount = (); @@ -287,21 +285,6 @@ pub mod pallet { + Copy + MaxEncodedLen; - /// The block number type used by the runtime. - type BlockNumber: Parameter - + Member - + MaybeSerializeDeserialize - + Debug - + MaybeDisplay - + AtLeast32BitUnsigned - + Default - + Bounded - + Copy - + sp_std::hash::Hash - + sp_std::str::FromStr - + MaxEncodedLen - + TypeInfo; - /// The output of the `Hashing` function. type Hash: Parameter + Member @@ -338,12 +321,15 @@ pub mod pallet { /// functional/efficient alternatives. type Lookup: StaticLookup; - /// The block header. - type Header: Parameter + traits::Header; + /// The Block type used by the runtime. This is used by `construct_runtime` to retrieve the + /// extrinsics or other block specific data as needed. + #[pallet::no_default] + type Block: Parameter + Member + traits::Block; /// Maximum number of block number to block hash mappings to keep (oldest pruned first). #[pallet::constant] - type BlockHashCount: Get; + #[pallet::no_default] + type BlockHashCount: Get>; /// The weight of runtime database operations the runtime can invoke. #[pallet::constant] @@ -590,7 +576,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn block_hash)] pub type BlockHash = - StorageMap<_, Twox64Concat, T::BlockNumber, T::Hash, ValueQuery>; + StorageMap<_, Twox64Concat, BlockNumberFor, T::Hash, ValueQuery>; /// Extrinsics data for the current block (maps an extrinsic's index to its data). #[pallet::storage] @@ -603,7 +589,7 @@ pub mod pallet { #[pallet::storage] #[pallet::whitelist_storage] #[pallet::getter(fn block_number)] - pub(super) type Number = StorageValue<_, T::BlockNumber, ValueQuery>; + pub(super) type Number = StorageValue<_, BlockNumberFor, ValueQuery>; /// Hash of the previous block. #[pallet::storage] @@ -642,14 +628,14 @@ pub mod pallet { /// allows light-clients to leverage the changes trie storage tracking mechanism and /// in case of changes fetch the list of events of interest. /// - /// The value has the type `(T::BlockNumber, EventIndex)` because if we used only just + /// The value has the type `(BlockNumberFor, EventIndex)` because if we used only just /// the `EventIndex` then in case if the topic has the same contents on the next block /// no notification will be triggered thus the event might be lost. #[pallet::storage] #[pallet::unbounded] #[pallet::getter(fn event_topics)] pub(super) type EventTopics = - StorageMap<_, Blake2_128Concat, T::Hash, Vec<(T::BlockNumber, EventIndex)>, ValueQuery>; + StorageMap<_, Blake2_128Concat, T::Hash, Vec<(BlockNumberFor, EventIndex)>, ValueQuery>; /// Stores the `spec_version` and `spec_name` of when the last runtime upgrade happened. #[pallet::storage] @@ -682,7 +668,7 @@ pub mod pallet { #[pallet::genesis_build] impl BuildGenesisConfig for GenesisConfig { fn build(&self) { - >::insert::<_, T::Hash>(T::BlockNumber::zero(), hash69()); + >::insert::<_, T::Hash>(BlockNumberFor::::zero(), hash69()); >::put::(hash69()); >::put(LastRuntimeUpgradeInfo::from(T::Version::get())); >::put(true); @@ -1370,7 +1356,7 @@ impl Pallet { } /// Start the execution of a particular block. - pub fn initialize(number: &T::BlockNumber, parent_hash: &T::Hash, digest: &generic::Digest) { + pub fn initialize(number: &BlockNumberFor, parent_hash: &T::Hash, digest: &generic::Digest) { // populate environment ExecutionPhase::::put(Phase::Initialization); storage::unhashed::put(well_known_keys::EXTRINSIC_INDEX, &0u32); @@ -1387,7 +1373,7 @@ impl Pallet { /// Remove temporary "environment" entries in storage, compute the storage root and return the /// resulting header for this block. - pub fn finalize() -> T::Header { + pub fn finalize() -> HeaderFor { log::debug!( target: LOG_TARGET, "[{:?}] {} extrinsics, length: {} (normal {}%, op: {}%, mandatory {}%) / normal weight:\ @@ -1459,13 +1445,7 @@ impl Pallet { let storage_root = T::Hash::decode(&mut &sp_io::storage::root(version)[..]) .expect("Node is configured to use the same hash; qed"); - ::new( - number, - extrinsics_root, - storage_root, - parent_hash, - digest, - ) + HeaderFor::::new(number, extrinsics_root, storage_root, parent_hash, digest) } /// Deposits a log and ensures it matches the block's log data. @@ -1478,8 +1458,8 @@ impl Pallet { pub fn externalities() -> TestExternalities { TestExternalities::new(sp_core::storage::Storage { top: map![ - >::hashed_key_for(T::BlockNumber::zero()) => [69u8; 32].encode(), - >::hashed_key().to_vec() => T::BlockNumber::one().encode(), + >::hashed_key_for(BlockNumberFor::::zero()) => [69u8; 32].encode(), + >::hashed_key().to_vec() => BlockNumberFor::::one().encode(), >::hashed_key().to_vec() => [69u8; 32].encode() ], children_default: map![], @@ -1524,7 +1504,7 @@ impl Pallet { /// Set the block number to something in particular. Can be used as an alternative to /// `initialize` for tests that don't need to bother with the other environment entries. #[cfg(any(feature = "std", feature = "runtime-benchmarks", test))] - pub fn set_block_number(n: T::BlockNumber) { + pub fn set_block_number(n: BlockNumberFor) { >::put(n); } @@ -1742,7 +1722,7 @@ impl HandleLifetime for Consumer { } impl BlockNumberProvider for Pallet { - type BlockNumber = ::BlockNumber; + type BlockNumber = BlockNumberFor; fn current_block_number() -> Self::BlockNumber { Pallet::::block_number() @@ -1813,6 +1793,10 @@ pub mod pallet_prelude { /// Type alias for the `Origin` associated type of system config. pub type OriginFor = ::RuntimeOrigin; + /// Type alias for the `Header`. + pub type HeaderFor = + <::Block as sp_runtime::traits::HeaderProvider>::HeaderT; + /// Type alias for the `BlockNumber` associated type of system config. - pub type BlockNumberFor = ::BlockNumber; + pub type BlockNumberFor = as sp_runtime::traits::Header>::Number; } diff --git a/frame/system/src/mock.rs b/frame/system/src/mock.rs index 0325c970b8616..cb9bbcb246a10 100644 --- a/frame/system/src/mock.rs +++ b/frame/system/src/mock.rs @@ -22,19 +22,14 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, Perbill, }; -type UncheckedExtrinsic = mocking::MockUncheckedExtrinsic; type Block = mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, } @@ -97,12 +92,11 @@ impl Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<10>; type DbWeight = DbWeight; diff --git a/frame/system/src/mocking.rs b/frame/system/src/mocking.rs index 8f76c1b8e08ba..833309e05ecc9 100644 --- a/frame/system/src/mocking.rs +++ b/frame/system/src/mocking.rs @@ -29,6 +29,19 @@ pub type MockUncheckedExtrinsic = generic::Unchec /// An implementation of `sp_runtime::traits::Block` to be used in tests. pub type MockBlock = generic::Block< - generic::Header<::BlockNumber, sp_runtime::traits::BlakeTwo256>, + generic::Header, + MockUncheckedExtrinsic, +>; + +/// An implementation of `sp_runtime::traits::Block` to be used in tests with u32 BlockNumber type. +pub type MockBlockU32 = generic::Block< + generic::Header, + MockUncheckedExtrinsic, +>; + +/// An implementation of `sp_runtime::traits::Block` to be used in tests with u128 BlockNumber +/// type. +pub type MockBlockU128 = generic::Block< + generic::Header, MockUncheckedExtrinsic, >; diff --git a/frame/timestamp/src/lib.rs b/frame/timestamp/src/lib.rs index e707764beb95c..4eb95941d7828 100644 --- a/frame/timestamp/src/lib.rs +++ b/frame/timestamp/src/lib.rs @@ -130,7 +130,7 @@ pub mod pallet { type Moment: Parameter + Default + AtLeast32Bit - + Scale + + Scale, Output = Self::Moment> + Copy + MaxEncodedLen + scale_info::StaticTypeInfo; diff --git a/frame/timestamp/src/mock.rs b/frame/timestamp/src/mock.rs index 2144322e62128..00e9e0b17c720 100644 --- a/frame/timestamp/src/mock.rs +++ b/frame/timestamp/src/mock.rs @@ -27,20 +27,15 @@ use frame_support::{ use sp_core::H256; use sp_io::TestExternalities; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; type Moment = u64; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, @@ -54,13 +49,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/tips/src/benchmarking.rs b/frame/tips/src/benchmarking.rs index 613f684afdf56..4a991b11b9331 100644 --- a/frame/tips/src/benchmarking.rs +++ b/frame/tips/src/benchmarking.rs @@ -78,7 +78,7 @@ fn create_tips, I: 'static>( } Tips::::mutate(hash, |maybe_tip| { if let Some(open_tip) = maybe_tip { - open_tip.closes = Some(T::BlockNumber::zero()); + open_tip.closes = Some(frame_system::pallet_prelude::BlockNumberFor::::zero()); } }); Ok(()) diff --git a/frame/tips/src/lib.rs b/frame/tips/src/lib.rs index 970e2ac152c4b..6e8f72e0540e6 100644 --- a/frame/tips/src/lib.rs +++ b/frame/tips/src/lib.rs @@ -74,6 +74,7 @@ use frame_support::{ }, Parameter, }; +use frame_system::pallet_prelude::BlockNumberFor; pub use pallet::*; pub use weights::WeightInfo; @@ -143,7 +144,7 @@ pub mod pallet { /// The period for which a tip remains open after is has achieved threshold tippers. #[pallet::constant] - type TipCountdown: Get; + type TipCountdown: Get>; /// The percent of the final tip which goes to the original reporter of the tip. #[pallet::constant] @@ -173,7 +174,7 @@ pub mod pallet { _, Twox64Concat, T::Hash, - OpenTip, T::BlockNumber, T::Hash>, + OpenTip, BlockNumberFor, T::Hash>, OptionQuery, >; @@ -470,7 +471,7 @@ impl, I: 'static> Pallet { /// /// `O(T)` and one storage access. fn insert_tip_and_check_closing( - tip: &mut OpenTip, T::BlockNumber, T::Hash>, + tip: &mut OpenTip, BlockNumberFor, T::Hash>, tipper: T::AccountId, tip_value: BalanceOf, ) -> bool { @@ -515,7 +516,7 @@ impl, I: 'static> Pallet { /// Plus `O(T)` (`T` is Tippers length). fn payout_tip( hash: T::Hash, - tip: OpenTip, T::BlockNumber, T::Hash>, + tip: OpenTip, BlockNumberFor, T::Hash>, ) { let mut tips = tip.tips; Self::retain_active_tips(&mut tips); @@ -577,7 +578,7 @@ impl, I: 'static> Pallet { for (hash, old_tip) in storage_key_iter::< T::Hash, - OldOpenTip, T::BlockNumber, T::Hash>, + OldOpenTip, BlockNumberFor, T::Hash>, Twox64Concat, >(module, item) .drain() diff --git a/frame/tips/src/tests.rs b/frame/tips/src/tests.rs index 4026e54863a32..3abbe5428f1d8 100644 --- a/frame/tips/src/tests.rs +++ b/frame/tips/src/tests.rs @@ -21,7 +21,6 @@ use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BadOrigin, BlakeTwo256, IdentityLookup}, BuildStorage, Perbill, Permill, }; @@ -37,14 +36,10 @@ use frame_support::{ use super::*; use crate::{self as pallet_tips, Event as TipEvent}; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -65,13 +60,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/transaction-payment/asset-conversion-tx-payment/src/mock.rs b/frame/transaction-payment/asset-conversion-tx-payment/src/mock.rs index 6e05ec6163ddb..683b93ad1f3fe 100644 --- a/frame/transaction-payment/asset-conversion-tx-payment/src/mock.rs +++ b/frame/transaction-payment/asset-conversion-tx-payment/src/mock.rs @@ -33,21 +33,16 @@ use pallet_asset_conversion::{NativeOrAssetId, NativeOrAssetIdConverter}; use pallet_transaction_payment::CurrencyAdapter; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{AccountIdConversion, BlakeTwo256, IdentityLookup, SaturatedConversion}, Permill, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; type Balance = u64; type AccountId = u64; frame_support::construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Runtime { System: system, Balances: pallet_balances, @@ -90,13 +85,12 @@ impl frame_system::Config for Runtime { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/transaction-payment/asset-tx-payment/src/mock.rs b/frame/transaction-payment/asset-tx-payment/src/mock.rs index 740915023a32d..fbc70c118da7b 100644 --- a/frame/transaction-payment/asset-tx-payment/src/mock.rs +++ b/frame/transaction-payment/asset-tx-payment/src/mock.rs @@ -29,23 +29,14 @@ use frame_system as system; use frame_system::EnsureRoot; use pallet_transaction_payment::CurrencyAdapter; use sp_core::H256; -use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, ConvertInto, IdentityLookup, SaturatedConversion}, -}; +use sp_runtime::traits::{BlakeTwo256, ConvertInto, IdentityLookup, SaturatedConversion}; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; type Balance = u64; type AccountId = u64; frame_support::construct_runtime!( - pub struct Runtime - where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { + pub struct Runtime { System: system, Balances: pallet_balances, TransactionPayment: pallet_transaction_payment, @@ -86,13 +77,12 @@ impl frame_system::Config for Runtime { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index bff32456cba4a..d61be5540c3a4 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -410,7 +410,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_finalize(_: T::BlockNumber) { + fn on_finalize(_: frame_system::pallet_prelude::BlockNumberFor) { >::mutate(|fm| { *fm = T::FeeMultiplierUpdate::convert(*fm); }); diff --git a/frame/transaction-payment/src/mock.rs b/frame/transaction-payment/src/mock.rs index 448079000cab8..6d9c8c5d1d210 100644 --- a/frame/transaction-payment/src/mock.rs +++ b/frame/transaction-payment/src/mock.rs @@ -19,10 +19,7 @@ use super::*; use crate as pallet_transaction_payment; use sp_core::H256; -use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, -}; +use sp_runtime::traits::{BlakeTwo256, IdentityLookup}; use frame_support::{ dispatch::DispatchClass, @@ -33,14 +30,10 @@ use frame_support::{ use frame_system as system; use pallet_balances::Call as BalancesCall; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub struct Runtime { System: system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -83,13 +76,12 @@ impl frame_system::Config for Runtime { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/transaction-storage/src/benchmarking.rs b/frame/transaction-storage/src/benchmarking.rs index dfea3331569f9..fdbaeb1f95181 100644 --- a/frame/transaction-storage/src/benchmarking.rs +++ b/frame/transaction-storage/src/benchmarking.rs @@ -22,7 +22,7 @@ use super::*; use frame_benchmarking::v1::{benchmarks, whitelisted_caller}; use frame_support::traits::{Currency, Get, OnFinalize, OnInitialize}; -use frame_system::{EventRecord, Pallet as System, RawOrigin}; +use frame_system::{pallet_prelude::BlockNumberFor, EventRecord, Pallet as System, RawOrigin}; use sp_runtime::traits::{Bounded, One, Zero}; use sp_std::*; use sp_transaction_storage_proof::TransactionStorageProof; @@ -113,7 +113,7 @@ fn assert_last_event(generic_event: ::RuntimeEvent) { assert_eq!(event, &system_event); } -pub fn run_to_block(n: T::BlockNumber) { +pub fn run_to_block(n: frame_system::pallet_prelude::BlockNumberFor) { while frame_system::Pallet::::block_number() < n { crate::Pallet::::on_finalize(frame_system::Pallet::::block_number()); frame_system::Pallet::::on_finalize(frame_system::Pallet::::block_number()); @@ -144,7 +144,7 @@ benchmarks! { vec![0u8; T::MaxTransactionSize::get() as usize], )?; run_to_block::(1u32.into()); - }: _(RawOrigin::Signed(caller.clone()), T::BlockNumber::zero(), 0) + }: _(RawOrigin::Signed(caller.clone()), BlockNumberFor::::zero(), 0) verify { assert_last_event::(Event::Renewed { index: 0 }.into()); } @@ -159,7 +159,7 @@ benchmarks! { vec![0u8; T::MaxTransactionSize::get() as usize], )?; } - run_to_block::(StoragePeriod::::get() + T::BlockNumber::one()); + run_to_block::(StoragePeriod::::get() + BlockNumberFor::::one()); let encoded_proof = proof(); let proof = TransactionStorageProof::decode(&mut &*encoded_proof).unwrap(); }: check_proof(RawOrigin::None, proof) diff --git a/frame/transaction-storage/src/lib.rs b/frame/transaction-storage/src/lib.rs index 4004dbd0a435b..e784d20a0cfd7 100644 --- a/frame/transaction-storage/src/lib.rs +++ b/frame/transaction-storage/src/lib.rs @@ -145,7 +145,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(n: T::BlockNumber) -> Weight { + fn on_initialize(n: BlockNumberFor) -> Weight { // Drop obsolete roots. The proof for `obsolete` will be checked later // in this block, so we drop `obsolete` - 1. let period = >::get(); @@ -158,7 +158,7 @@ pub mod pallet { T::DbWeight::get().reads_writes(2, 4) } - fn on_finalize(n: T::BlockNumber) { + fn on_finalize(n: BlockNumberFor) { assert!( >::take() || { // Proof is not required for early or empty blocks. @@ -238,7 +238,7 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::renew())] pub fn renew( origin: OriginFor, - block: T::BlockNumber, + block: BlockNumberFor, index: u32, ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; @@ -342,7 +342,7 @@ pub mod pallet { pub(super) type Transactions = StorageMap< _, Blake2_128Concat, - T::BlockNumber, + BlockNumberFor, BoundedVec, OptionQuery, >; @@ -350,7 +350,7 @@ pub mod pallet { /// Count indexed chunks for each block. #[pallet::storage] pub(super) type ChunkCount = - StorageMap<_, Blake2_128Concat, T::BlockNumber, u32, ValueQuery>; + StorageMap<_, Blake2_128Concat, BlockNumberFor, u32, ValueQuery>; #[pallet::storage] #[pallet::getter(fn byte_fee)] @@ -365,7 +365,7 @@ pub mod pallet { /// Storage period for data in blocks. Should match `sp_storage_proof::DEFAULT_STORAGE_PERIOD` /// for block authoring. #[pallet::storage] - pub(super) type StoragePeriod = StorageValue<_, T::BlockNumber, ValueQuery>; + pub(super) type StoragePeriod = StorageValue<_, BlockNumberFor, ValueQuery>; // Intermediates #[pallet::storage] @@ -380,7 +380,7 @@ pub mod pallet { pub struct GenesisConfig { pub byte_fee: BalanceOf, pub entry_fee: BalanceOf, - pub storage_period: T::BlockNumber, + pub storage_period: BlockNumberFor, } impl Default for GenesisConfig { diff --git a/frame/transaction-storage/src/mock.rs b/frame/transaction-storage/src/mock.rs index efabcb97f081d..94705cd9340bd 100644 --- a/frame/transaction-storage/src/mock.rs +++ b/frame/transaction-storage/src/mock.rs @@ -24,20 +24,15 @@ use crate::{ use frame_support::traits::{ConstU16, ConstU32, ConstU64, OnFinalize, OnInitialize}; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; pub type Block = frame_system::mocking::MockBlock; // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Config, Storage, Event}, @@ -54,12 +49,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); diff --git a/frame/treasury/src/benchmarking.rs b/frame/treasury/src/benchmarking.rs index a3761083e4faa..449549d6c53b7 100644 --- a/frame/treasury/src/benchmarking.rs +++ b/frame/treasury/src/benchmarking.rs @@ -135,7 +135,7 @@ benchmarks_instance_pallet! { setup_pot_account::(); create_approved_proposals::(p)?; }: { - Treasury::::on_initialize(T::BlockNumber::zero()); + Treasury::::on_initialize(frame_system::pallet_prelude::BlockNumberFor::::zero()); } impl_benchmark_test_suite!(Treasury, crate::tests::new_test_ext(), crate::tests::Test); diff --git a/frame/treasury/src/lib.rs b/frame/treasury/src/lib.rs index 01cda66edbb25..49be4d91a4568 100644 --- a/frame/treasury/src/lib.rs +++ b/frame/treasury/src/lib.rs @@ -175,7 +175,7 @@ pub mod pallet { /// Period between successive spends. #[pallet::constant] - type SpendPeriod: Get; + type SpendPeriod: Get>; /// Percentage of spare funds (if any) that are burnt per spend period. #[pallet::constant] @@ -299,7 +299,7 @@ pub mod pallet { impl, I: 'static> Hooks> for Pallet { /// ## Complexity /// - `O(A)` where `A` is the number of approvals - fn on_initialize(n: T::BlockNumber) -> Weight { + fn on_initialize(n: frame_system::pallet_prelude::BlockNumberFor) -> Weight { let pot = Self::pot(); let deactivated = Deactivated::::get(); if pot != deactivated { diff --git a/frame/treasury/src/tests.rs b/frame/treasury/src/tests.rs index e1cbffc2f2a31..39db42a22a382 100644 --- a/frame/treasury/src/tests.rs +++ b/frame/treasury/src/tests.rs @@ -21,7 +21,6 @@ use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BadOrigin, BlakeTwo256, Dispatchable, IdentityLookup}, BuildStorage, }; @@ -35,16 +34,12 @@ use frame_support::{ use super::*; use crate as treasury; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; type UtilityCall = pallet_utility::Call; type TreasuryCall = crate::Call; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -60,13 +55,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/uniques/src/mock.rs b/frame/uniques/src/mock.rs index b975f6bac6a55..6ff7278cce8aa 100644 --- a/frame/uniques/src/mock.rs +++ b/frame/uniques/src/mock.rs @@ -26,19 +26,14 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -53,12 +48,11 @@ impl frame_system::Config for Test { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = u64; - type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index e39820ae251dd..3587b55762b7c 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -33,7 +33,6 @@ use frame_support::{ use pallet_collective::{EnsureProportionAtLeast, Instance1}; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, Hash, IdentityLookup}, BuildStorage, TokenError, }; @@ -125,14 +124,10 @@ mod mock_democracy { } } -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Timestamp: pallet_timestamp::{Call, Inherent}, @@ -156,13 +151,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/frame/vesting/src/benchmarking.rs b/frame/vesting/src/benchmarking.rs index 15be519842992..4af48f5d368db 100644 --- a/frame/vesting/src/benchmarking.rs +++ b/frame/vesting/src/benchmarking.rs @@ -21,7 +21,7 @@ use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; use frame_support::assert_ok; -use frame_system::{Pallet as System, RawOrigin}; +use frame_system::{pallet_prelude::BlockNumberFor, Pallet as System, RawOrigin}; use sp_runtime::traits::{Bounded, CheckedDiv, CheckedMul}; use super::*; @@ -55,7 +55,7 @@ fn add_vesting_schedules( let source_lookup = T::Lookup::unlookup(source.clone()); T::Currency::make_free_balance_be(&source, BalanceOf::::max_value()); - System::::set_block_number(T::BlockNumber::zero()); + System::::set_block_number(BlockNumberFor::::zero()); let mut total_locked: BalanceOf = Zero::zero(); for _ in 0..n { @@ -88,7 +88,7 @@ benchmarks! { let expected_balance = add_vesting_schedules::(caller_lookup, s)?; // At block zero, everything is vested. - assert_eq!(System::::block_number(), T::BlockNumber::zero()); + assert_eq!(System::::block_number(), BlockNumberFor::::zero()); assert_eq!( Vesting::::vesting_balance(&caller), Some(expected_balance), @@ -144,7 +144,7 @@ benchmarks! { let expected_balance = add_vesting_schedules::(other_lookup.clone(), s)?; // At block zero, everything is vested. - assert_eq!(System::::block_number(), T::BlockNumber::zero()); + assert_eq!(System::::block_number(), BlockNumberFor::::zero()); assert_eq!( Vesting::::vesting_balance(&other), Some(expected_balance), @@ -284,7 +284,7 @@ benchmarks! { let expected_balance = add_vesting_schedules::(caller_lookup, s)?; // Schedules are not vesting at block 0. - assert_eq!(System::::block_number(), T::BlockNumber::zero()); + assert_eq!(System::::block_number(), BlockNumberFor::::zero()); assert_eq!( Vesting::::vesting_balance(&caller), Some(expected_balance), diff --git a/frame/vesting/src/lib.rs b/frame/vesting/src/lib.rs index f19e38d311914..eb829121e9797 100644 --- a/frame/vesting/src/lib.rs +++ b/frame/vesting/src/lib.rs @@ -67,6 +67,7 @@ use frame_support::{ }, weights::Weight, }; +use frame_system::pallet_prelude::BlockNumberFor; use scale_info::TypeInfo; use sp_runtime::{ traits::{ @@ -127,8 +128,8 @@ impl VestingAction { /// Pick the schedules that this action dictates should continue vesting undisturbed. fn pick_schedules( &self, - schedules: Vec, T::BlockNumber>>, - ) -> impl Iterator, T::BlockNumber>> + '_ { + schedules: Vec, BlockNumberFor>>, + ) -> impl Iterator, BlockNumberFor>> + '_ { schedules.into_iter().enumerate().filter_map(move |(index, schedule)| { if self.should_remove(index) { None @@ -162,7 +163,7 @@ pub mod pallet { type Currency: LockableCurrency; /// Convert the block number into a balance. - type BlockNumberToBalance: Convert>; + type BlockNumberToBalance: Convert, BalanceOf>; /// The minimum amount transferred to call `vested_transfer`. #[pallet::constant] @@ -201,7 +202,7 @@ pub mod pallet { _, Blake2_128Concat, T::AccountId, - BoundedVec, T::BlockNumber>, MaxVestingSchedulesGet>, + BoundedVec, BlockNumberFor>, MaxVestingSchedulesGet>, >; /// Storage version of the pallet. @@ -216,7 +217,7 @@ pub mod pallet { #[pallet::genesis_config] #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { - pub vesting: Vec<(T::AccountId, T::BlockNumber, T::BlockNumber, BalanceOf)>, + pub vesting: Vec<(T::AccountId, BlockNumberFor, BlockNumberFor, BalanceOf)>, } #[pallet::genesis_build] @@ -342,7 +343,7 @@ pub mod pallet { pub fn vested_transfer( origin: OriginFor, target: AccountIdLookupOf, - schedule: VestingInfo, T::BlockNumber>, + schedule: VestingInfo, BlockNumberFor>, ) -> DispatchResult { let transactor = ensure_signed(origin)?; let transactor = ::unlookup(transactor); @@ -371,7 +372,7 @@ pub mod pallet { origin: OriginFor, source: AccountIdLookupOf, target: AccountIdLookupOf, - schedule: VestingInfo, T::BlockNumber>, + schedule: VestingInfo, BlockNumberFor>, ) -> DispatchResult { ensure_root(origin)?; Self::do_vested_transfer(source, target, schedule) @@ -433,10 +434,10 @@ impl Pallet { // Create a new `VestingInfo`, based off of two other `VestingInfo`s. // NOTE: We assume both schedules have had funds unlocked up through the current block. fn merge_vesting_info( - now: T::BlockNumber, - schedule1: VestingInfo, T::BlockNumber>, - schedule2: VestingInfo, T::BlockNumber>, - ) -> Option, T::BlockNumber>> { + now: BlockNumberFor, + schedule1: VestingInfo, BlockNumberFor>, + schedule2: VestingInfo, BlockNumberFor>, + ) -> Option, BlockNumberFor>> { let schedule1_ending_block = schedule1.ending_block_as_balance::(); let schedule2_ending_block = schedule2.ending_block_as_balance::(); let now_as_balance = T::BlockNumberToBalance::convert(now); @@ -483,7 +484,7 @@ impl Pallet { fn do_vested_transfer( source: AccountIdLookupOf, target: AccountIdLookupOf, - schedule: VestingInfo, T::BlockNumber>, + schedule: VestingInfo, BlockNumberFor>, ) -> DispatchResult { // Validate user inputs. ensure!(schedule.locked() >= T::MinVestedTransfer::get(), Error::::AmountLow); @@ -531,9 +532,9 @@ impl Pallet { /// /// NOTE: the amount locked does not include any schedules that are filtered out via `action`. fn report_schedule_updates( - schedules: Vec, T::BlockNumber>>, + schedules: Vec, BlockNumberFor>>, action: VestingAction, - ) -> (Vec, T::BlockNumber>>, BalanceOf) { + ) -> (Vec, BlockNumberFor>>, BalanceOf) { let now = >::block_number(); let mut total_locked_now: BalanceOf = Zero::zero(); @@ -570,10 +571,10 @@ impl Pallet { /// Write an accounts updated vesting schedules to storage. fn write_vesting( who: &T::AccountId, - schedules: Vec, T::BlockNumber>>, + schedules: Vec, BlockNumberFor>>, ) -> Result<(), DispatchError> { let schedules: BoundedVec< - VestingInfo, T::BlockNumber>, + VestingInfo, BlockNumberFor>, MaxVestingSchedulesGet, > = schedules.try_into().map_err(|_| Error::::AtMaxVestingSchedules)?; @@ -602,9 +603,9 @@ impl Pallet { /// Execute a `VestingAction` against the given `schedules`. Returns the updated schedules /// and locked amount. fn exec_action( - schedules: Vec, T::BlockNumber>>, + schedules: Vec, BlockNumberFor>>, action: VestingAction, - ) -> Result<(Vec, T::BlockNumber>>, BalanceOf), DispatchError> { + ) -> Result<(Vec, BlockNumberFor>>, BalanceOf), DispatchError> { let (schedules, locked_now) = match action { VestingAction::Merge { index1: idx1, index2: idx2 } => { // The schedule index is based off of the schedule ordering prior to filtering out @@ -649,7 +650,7 @@ where BalanceOf: MaybeSerializeDeserialize + Debug, { type Currency = T::Currency; - type Moment = T::BlockNumber; + type Moment = BlockNumberFor; /// Get the amount that is currently being vested and cannot be transferred out of this account. fn vesting_balance(who: &T::AccountId) -> Option> { @@ -680,7 +681,7 @@ where who: &T::AccountId, locked: BalanceOf, per_block: BalanceOf, - starting_block: T::BlockNumber, + starting_block: BlockNumberFor, ) -> DispatchResult { if locked.is_zero() { return Ok(()) @@ -713,7 +714,7 @@ where who: &T::AccountId, locked: BalanceOf, per_block: BalanceOf, - starting_block: T::BlockNumber, + starting_block: BlockNumberFor, ) -> DispatchResult { // Check for `per_block` or `locked` of 0. if !VestingInfo::new(locked, per_block, starting_block).is_valid() { diff --git a/frame/vesting/src/migrations.rs b/frame/vesting/src/migrations.rs index 69bbc97296500..cac3c90b403ab 100644 --- a/frame/vesting/src/migrations.rs +++ b/frame/vesting/src/migrations.rs @@ -40,12 +40,12 @@ pub mod v1 { pub fn migrate() -> Weight { let mut reads_writes = 0; - Vesting::::translate::, T::BlockNumber>, _>( + Vesting::::translate::, BlockNumberFor>, _>( |_key, vesting_info| { reads_writes += 1; let v: Option< BoundedVec< - VestingInfo, T::BlockNumber>, + VestingInfo, BlockNumberFor>, MaxVestingSchedulesGet, >, > = vec![vesting_info].try_into().ok(); diff --git a/frame/vesting/src/mock.rs b/frame/vesting/src/mock.rs index d0c25221cd5e9..c569ec96b99e0 100644 --- a/frame/vesting/src/mock.rs +++ b/frame/vesting/src/mock.rs @@ -21,7 +21,6 @@ use frame_support::{ }; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, Identity, IdentityLookup}, BuildStorage, }; @@ -29,14 +28,10 @@ use sp_runtime::{ use super::*; use crate as pallet_vesting; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, @@ -50,14 +45,13 @@ impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; type BlockHashCount = ConstU64<250>; type BlockLength = (); - type BlockNumber = u64; type BlockWeights = (); type RuntimeCall = RuntimeCall; type DbWeight = (); type RuntimeEvent = RuntimeEvent; type Hash = H256; type Hashing = BlakeTwo256; - type Header = Header; + type Block = Block; type Index = u64; type Lookup = IdentityLookup; type OnKilledAccount = (); diff --git a/frame/whitelist/src/mock.rs b/frame/whitelist/src/mock.rs index afb9d00861563..3b25cdd4d14ae 100644 --- a/frame/whitelist/src/mock.rs +++ b/frame/whitelist/src/mock.rs @@ -28,19 +28,14 @@ use frame_support::{ use frame_system::EnsureRoot; use sp_core::H256; use sp_runtime::{ - testing::Header, traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, + pub enum Test { System: frame_system, Balances: pallet_balances, @@ -56,13 +51,12 @@ impl frame_system::Config for Test { type DbWeight = (); type RuntimeOrigin = RuntimeOrigin; type Index = u64; - type BlockNumber = u64; type Hash = H256; type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); diff --git a/primitives/runtime/src/generic/block.rs b/primitives/runtime/src/generic/block.rs index 6261e412eb8ad..05146e880cb16 100644 --- a/primitives/runtime/src/generic/block.rs +++ b/primitives/runtime/src/generic/block.rs @@ -25,7 +25,10 @@ use serde::{Deserialize, Serialize}; use crate::{ codec::{Codec, Decode, Encode}, - traits::{self, Block as BlockT, Header as HeaderT, MaybeSerialize, Member, NumberFor}, + traits::{ + self, Block as BlockT, Header as HeaderT, MaybeSerialize, MaybeSerializeDeserialize, + Member, NumberFor, + }, Justifications, }; use sp_core::RuntimeDebug; @@ -79,16 +82,23 @@ impl fmt::Display for BlockId { #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] #[cfg_attr(feature = "serde", serde(deny_unknown_fields))] -pub struct Block { +pub struct Block { /// The block header. pub header: Header, /// The accompanying extrinsics. pub extrinsics: Vec, } -impl traits::Block for Block +impl traits::HeaderProvider for Block where Header: HeaderT, +{ + type HeaderT = Header; +} + +impl traits::Block for Block +where + Header: HeaderT + MaybeSerializeDeserialize, Extrinsic: Member + Codec + traits::Extrinsic, { type Extrinsic = Extrinsic; diff --git a/primitives/runtime/src/generic/header.rs b/primitives/runtime/src/generic/header.rs index 6fdf43ac08105..82ab9a61f96d8 100644 --- a/primitives/runtime/src/generic/header.rs +++ b/primitives/runtime/src/generic/header.rs @@ -26,6 +26,7 @@ use crate::{ MaybeSerializeDeserialize, Member, }, }; +use codec::{FullCodec, MaxEncodedLen}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use sp_core::U256; @@ -33,6 +34,7 @@ use sp_std::fmt::Debug; /// Abstraction over a block header for a substrate chain. #[derive(Encode, Decode, PartialEq, Eq, Clone, sp_core::RuntimeDebug, TypeInfo)] +#[scale_info(skip_type_params(Hash))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] #[cfg_attr(feature = "serde", serde(deny_unknown_fields))] @@ -81,13 +83,16 @@ where + MaybeSerializeDeserialize + MaybeFromStr + Debug + + Default + sp_std::hash::Hash + MaybeDisplay + AtLeast32BitUnsigned - + Codec + + FullCodec + Copy + + MaxEncodedLen + Into - + TryFrom, + + TryFrom + + TypeInfo, Hash: HashT, { type Number = Number; diff --git a/primitives/runtime/src/testing.rs b/primitives/runtime/src/testing.rs index abf4d81634691..5f94c834a8f29 100644 --- a/primitives/runtime/src/testing.rs +++ b/primitives/runtime/src/testing.rs @@ -235,7 +235,7 @@ impl Deref for ExtrinsicWrapper { } /// Testing block -#[derive(PartialEq, Eq, Clone, Serialize, Debug, Encode, Decode)] +#[derive(PartialEq, Eq, Clone, Serialize, Debug, Encode, Decode, TypeInfo)] pub struct Block { /// Block header pub header: Header, @@ -243,6 +243,10 @@ pub struct Block { pub extrinsics: Vec, } +impl traits::HeaderProvider for Block { + type HeaderT = Header; +} + impl< Xt: 'static + Codec + Sized + Send + Sync + Serialize + Clone + Eq + Debug + traits::Extrinsic, > traits::Block for Block diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index 3aa27234fbce2..51d91958ab533 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -26,7 +26,7 @@ use crate::{ }, DispatchResult, }; -use codec::{Codec, Decode, Encode, EncodeLike, MaxEncodedLen}; +use codec::{Codec, Decode, Encode, EncodeLike, FullCodec, MaxEncodedLen}; use impl_trait_for_tuples::impl_for_tuples; #[cfg(feature = "serde")] use serde::{de::DeserializeOwned, Deserialize, Serialize}; @@ -1154,7 +1154,9 @@ pub trait IsMember { /// `parent_hash`, as well as a `digest` and a block `number`. /// /// You can also create a `new` one from those fields. -pub trait Header: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 'static { +pub trait Header: + Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + TypeInfo + 'static +{ /// Header number. type Number: Member + MaybeSerializeDeserialize @@ -1164,7 +1166,10 @@ pub trait Header: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 's + Copy + MaybeDisplay + AtLeast32BitUnsigned - + Codec; + + Default + + TypeInfo + + MaxEncodedLen + + FullCodec; /// Header hash type type Hash: HashOutput; /// Hashing algorithm @@ -1210,15 +1215,50 @@ pub trait Header: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 's } } +// Something that provides the Header Type. Only for internal usage and should only be used +// via `HeaderFor` or `BlockNumberFor`. +// +// This is needed to fix the "cyclical" issue in loading Header/BlockNumber as part of a +// `pallet::call`. Essentially, `construct_runtime` aggregates all calls to create a `RuntimeCall` +// that is then used to define `UncheckedExtrinsic`. +// ```ignore +// pub type UncheckedExtrinsic = +// generic::UncheckedExtrinsic; +// ``` +// This `UncheckedExtrinsic` is supplied to the `Block`. +// ```ignore +// pub type Block = generic::Block; +// ``` +// So, if we do not create a trait outside of `Block` that doesn't have `Extrinsic`, we go into a +// recursive loop leading to a build error. +// +// Note that this is a workaround for a compiler bug and should be removed when the compiler +// bug is fixed. +#[doc(hidden)] +pub trait HeaderProvider { + /// Header type. + type HeaderT: Header; +} + /// Something which fulfills the abstract idea of a Substrate block. It has types for /// `Extrinsic` pieces of information as well as a `Header`. /// /// You can get an iterator over each of the `extrinsics` and retrieve the `header`. -pub trait Block: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 'static { +pub trait Block: + HeaderProvider::Header> + + Clone + + Send + + Sync + + Codec + + Eq + + MaybeSerialize + + Debug + + 'static +{ /// Type for extrinsics. type Extrinsic: Member + Codec + Extrinsic + MaybeSerialize; /// Header type. - type Header: Header; + type Header: Header + MaybeSerializeDeserialize; /// Block hash type. type Hash: HashOutput; diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index 8beed61d3d3d9..6ba4e9939e408 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -293,10 +293,7 @@ impl sp_runtime::traits::SignedExtension for CheckSubstrateCall { } construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = Extrinsic + pub enum Runtime { System: frame_system, Babe: pallet_babe, @@ -349,12 +346,11 @@ impl frame_system::pallet::Config for Runtime { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; type Index = Index; - type BlockNumber = BlockNumber; type Hash = H256; type Hashing = Hashing; type AccountId = AccountId; type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; + type Block = Block; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<2400>; type DbWeight = (); diff --git a/utils/frame/rpc/support/src/lib.rs b/utils/frame/rpc/support/src/lib.rs index 424d16bd14c68..29d49b44b74a3 100644 --- a/utils/frame/rpc/support/src/lib.rs +++ b/utils/frame/rpc/support/src/lib.rs @@ -40,10 +40,7 @@ use sp_storage::{StorageData, StorageKey}; /// # use sp_runtime::{traits::{BlakeTwo256, IdentityLookup}, testing::Header}; /// # /// # construct_runtime!( -/// # pub enum TestRuntime where -/// # Block = frame_system::mocking::MockBlock, -/// # NodeBlock = frame_system::mocking::MockBlock, -/// # UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic, +/// # pub enum TestRuntime /// # { /// # System: frame_system::{Pallet, Call, Config, Storage, Event}, /// # Test: pallet_test::{Pallet, Storage}, @@ -59,12 +56,11 @@ use sp_storage::{StorageData, StorageKey}; /// # type RuntimeOrigin = RuntimeOrigin; /// # type RuntimeCall = RuntimeCall; /// # type Index = u64; -/// # type BlockNumber = u64; /// # type Hash = Hash; /// # type Hashing = BlakeTwo256; /// # type AccountId = u64; /// # type Lookup = IdentityLookup; -/// # type Header = Header; +/// # type Block = frame_system::mocking::MockBlock; /// # type RuntimeEvent = RuntimeEvent; /// # type BlockHashCount = (); /// # type DbWeight = (); From 174488477976d0d8a9e43d98aaea4e6e7b78118e Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko <5252494+jsidorenko@users.noreply.github.com> Date: Thu, 13 Jul 2023 15:44:05 +0200 Subject: [PATCH 058/105] Refactor the asset-conversion-tx-payment pallet (#14558) * Code refactoring * Fix imports * Typo * Update frame/asset-conversion/src/types.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Sync docs --------- Co-authored-by: parity-processbot <> Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --- frame/asset-conversion/src/lib.rs | 234 ++++++++++-------- frame/asset-conversion/src/types.rs | 47 +++- .../src/traits/tokens/fungibles/mod.rs | 2 +- .../src/traits/tokens/fungibles/regular.rs | 37 --- .../asset-conversion-tx-payment/Cargo.toml | 3 +- .../asset-conversion-tx-payment/src/lib.rs | 12 +- .../src/payment.rs | 45 ++-- 7 files changed, 215 insertions(+), 165 deletions(-) diff --git a/frame/asset-conversion/src/lib.rs b/frame/asset-conversion/src/lib.rs index 5887295f973c3..73f193c7ff55d 100644 --- a/frame/asset-conversion/src/lib.rs +++ b/frame/asset-conversion/src/lib.rs @@ -81,11 +81,10 @@ use sp_arithmetic::traits::Unsigned; use sp_runtime::{ traits::{ CheckedAdd, CheckedDiv, CheckedMul, CheckedSub, Ensure, MaybeDisplay, TrailingZeroInput, - Zero, }, DispatchError, }; -use sp_std::vec; +use sp_std::prelude::*; pub use types::*; pub use weights::WeightInfo; @@ -111,7 +110,6 @@ pub mod pallet { traits::{IntegerSquareRoot, One, Zero}, Saturating, }; - use sp_std::prelude::*; #[pallet::pallet] pub struct Pallet(_); @@ -148,7 +146,7 @@ pub mod pallet { type AssetId: AssetId + PartialOrd; /// Type that identifies either the native currency or a token class from `Assets`. - type MultiAssetId: AssetId + Ord; + type MultiAssetId: AssetId + Ord + From; /// Type to convert an `AssetId` into `MultiAssetId`. type MultiAssetIdConverter: MultiAssetIdConverter; @@ -644,18 +642,14 @@ pub mod pallet { keep_alive: bool, ) -> DispatchResult { let sender = ensure_signed(origin)?; - - ensure!( - amount_in > Zero::zero() && amount_out_min > Zero::zero(), - Error::::ZeroAmount - ); - Self::validate_swap_path(&path)?; - - let amounts = Self::get_amounts_out(&amount_in, &path)?; - let amount_out = *amounts.last().expect("Has always more than 1 element"); - ensure!(amount_out >= amount_out_min, Error::::ProvidedMinimumNotSufficientForSwap); - - Self::do_swap(sender, &amounts, path, send_to, keep_alive)?; + Self::do_swap_exact_tokens_for_tokens( + sender, + path, + amount_in, + Some(amount_out_min), + send_to, + keep_alive, + )?; Ok(()) } @@ -676,23 +670,95 @@ pub mod pallet { keep_alive: bool, ) -> DispatchResult { let sender = ensure_signed(origin)?; + Self::do_swap_tokens_for_exact_tokens( + sender, + path, + amount_out, + Some(amount_in_max), + send_to, + keep_alive, + )?; + Ok(()) + } + } + + impl Pallet { + /// Swap exactly `amount_in` of asset `path[0]` for asset `path[1]`. + /// If an `amount_out_min` is specified, it will return an error if it is unable to acquire + /// the amount desired. + /// + /// Withdraws the `path[0]` asset from `sender`, deposits the `path[1]` asset to `send_to`, + /// respecting `keep_alive`. + /// + /// If successful, returns the amount of `path[1]` acquired for the `amount_in`. + pub fn do_swap_exact_tokens_for_tokens( + sender: T::AccountId, + path: BoundedVec, + amount_in: T::AssetBalance, + amount_out_min: Option, + send_to: T::AccountId, + keep_alive: bool, + ) -> Result { + ensure!(amount_in > Zero::zero(), Error::::ZeroAmount); + if let Some(amount_out_min) = amount_out_min { + ensure!(amount_out_min > Zero::zero(), Error::::ZeroAmount); + } + + Self::validate_swap_path(&path)?; + + let amounts = Self::get_amounts_out(&amount_in, &path)?; + let amount_out = + *amounts.last().defensive_ok_or("get_amounts_out() returned an empty result")?; + + if let Some(amount_out_min) = amount_out_min { + ensure!( + amount_out >= amount_out_min, + Error::::ProvidedMinimumNotSufficientForSwap + ); + } + + Self::do_swap(sender, &amounts, path, send_to, keep_alive)?; + Ok(amount_out) + } + + /// Take the `path[0]` asset and swap some amount for `amount_out` of the `path[1]`. If an + /// `amount_in_max` is specified, it will return an error if acquiring `amount_out` would be + /// too costly. + /// + /// Withdraws `path[0]` asset from `sender`, deposits the `path[1]` asset to `send_to`, + /// respecting `keep_alive`. + /// + /// If successful returns the amount of the `path[0]` taken to provide `path[1]`. + pub fn do_swap_tokens_for_exact_tokens( + sender: T::AccountId, + path: BoundedVec, + amount_out: T::AssetBalance, + amount_in_max: Option, + send_to: T::AccountId, + keep_alive: bool, + ) -> Result { + ensure!(amount_out > Zero::zero(), Error::::ZeroAmount); + if let Some(amount_in_max) = amount_in_max { + ensure!(amount_in_max > Zero::zero(), Error::::ZeroAmount); + } - ensure!( - amount_out > Zero::zero() && amount_in_max > Zero::zero(), - Error::::ZeroAmount - ); Self::validate_swap_path(&path)?; let amounts = Self::get_amounts_in(&amount_out, &path)?; - let amount_in = *amounts.first().expect("Always has more than one element"); - ensure!(amount_in <= amount_in_max, Error::::ProvidedMaximumNotSufficientForSwap); + let amount_in = + *amounts.first().defensive_ok_or("get_amounts_in() returned an empty result")?; + + if let Some(amount_in_max) = amount_in_max { + ensure!( + amount_in <= amount_in_max, + Error::::ProvidedMaximumNotSufficientForSwap + ); + } Self::do_swap(sender, &amounts, path, send_to, keep_alive)?; - Ok(()) + Ok(amount_in) } - } - impl Pallet { /// Transfer an `amount` of `asset_id`, respecting the `keep_alive` requirements. fn transfer( asset_id: &T::MultiAssetId, @@ -749,6 +815,13 @@ pub mod pallet { .map_err(|_| Error::::Overflow) } + /// Convert a `HigherPrecisionBalance` type to an `AssetBalance`. + pub(crate) fn convert_hpb_to_asset_balance( + amount: T::HigherPrecisionBalance, + ) -> Result> { + amount.try_into().map_err(|_| Error::::Overflow) + } + /// Swap assets along a `path`, depositing in `send_to`. pub(crate) fn do_swap( sender: T::AccountId, @@ -1123,92 +1196,47 @@ pub mod pallet { } } -impl - frame_support::traits::tokens::fungibles::SwapNative< - T::RuntimeOrigin, - T::AccountId, - T::Balance, - T::AssetBalance, - T::AssetId, - > for Pallet -where - ::Currency: - frame_support::traits::tokens::fungible::Inspect<::AccountId>, -{ - /// Take an `asset_id` and swap some amount for `amount_out` of the chain's native asset. If an - /// `amount_in_max` is specified, it will return an error if acquiring `amount_out` would be - /// too costly. - /// - /// If successful returns the amount of the `asset_id` taken to provide `amount_out`. - fn swap_tokens_for_exact_native( +impl Swap for Pallet { + fn swap_exact_tokens_for_tokens( sender: T::AccountId, - asset_id: T::AssetId, - amount_out: T::Balance, - amount_in_max: Option, + path: Vec, + amount_in: T::HigherPrecisionBalance, + amount_out_min: Option, send_to: T::AccountId, keep_alive: bool, - ) -> Result { - ensure!(amount_out > Zero::zero(), Error::::ZeroAmount); - if let Some(amount_in_max) = amount_in_max { - ensure!(amount_in_max > Zero::zero(), Error::::ZeroAmount); - } - let mut path = sp_std::vec::Vec::new(); - path.push(T::MultiAssetIdConverter::into_multiasset_id(&asset_id)); - path.push(T::MultiAssetIdConverter::get_native()); - let path = path.try_into().unwrap(); - - // convert `amount_out` from native balance type, to asset balance type - let amount_out = Self::convert_native_balance_to_asset_balance(amount_out)?; - - // calculate the amount we need to provide - let amounts = Self::get_amounts_in(&amount_out, &path)?; - let amount_in = - *amounts.first().defensive_ok_or("get_amounts_in() returned an empty result")?; - if let Some(amount_in_max) = amount_in_max { - ensure!(amount_in <= amount_in_max, Error::::ProvidedMaximumNotSufficientForSwap); - } - - Self::do_swap(sender, &amounts, path, send_to, keep_alive)?; - Ok(amount_in) + ) -> Result { + let path = path.try_into().map_err(|_| Error::::PathError)?; + let amount_out_min = amount_out_min.map(Self::convert_hpb_to_asset_balance).transpose()?; + let amount_out = Self::do_swap_exact_tokens_for_tokens( + sender, + path, + Self::convert_hpb_to_asset_balance(amount_in)?, + amount_out_min, + send_to, + keep_alive, + )?; + Ok(amount_out.into()) } - /// Take an `asset_id` and swap `amount_in` of the chain's native asset for it. If an - /// `amount_out_min` is specified, it will return an error if it is unable to acquire the amount - /// desired. - /// - /// If successful, returns the amount of `asset_id` acquired for the `amount_in`. - fn swap_exact_native_for_tokens( + fn swap_tokens_for_exact_tokens( sender: T::AccountId, - asset_id: T::AssetId, - amount_in: T::Balance, - amount_out_min: Option, + path: Vec, + amount_out: T::HigherPrecisionBalance, + amount_in_max: Option, send_to: T::AccountId, keep_alive: bool, - ) -> Result { - ensure!(amount_in > Zero::zero(), Error::::ZeroAmount); - if let Some(amount_out_min) = amount_out_min { - ensure!(amount_out_min > Zero::zero(), Error::::ZeroAmount); - } - let mut path = sp_std::vec::Vec::new(); - path.push(T::MultiAssetIdConverter::get_native()); - path.push(T::MultiAssetIdConverter::into_multiasset_id(&asset_id)); - let path = path.try_into().expect( - "`MaxSwapPathLength` is ensured by to be greater than 2; pushed only twice; qed", - ); - - // convert `amount_in` from native balance type, to asset balance type - let amount_in = Self::convert_native_balance_to_asset_balance(amount_in)?; - - // calculate the amount we should receive - let amounts = Self::get_amounts_out(&amount_in, &path)?; - let amount_out = - *amounts.last().defensive_ok_or("get_amounts_out() returned an empty result")?; - if let Some(amount_out_min) = amount_out_min { - ensure!(amount_out >= amount_out_min, Error::::ProvidedMaximumNotSufficientForSwap); - } - - Self::do_swap(sender, &amounts, path, send_to, keep_alive)?; - Ok(amount_out) + ) -> Result { + let path = path.try_into().map_err(|_| Error::::PathError)?; + let amount_in_max = amount_in_max.map(Self::convert_hpb_to_asset_balance).transpose()?; + let amount_in = Self::do_swap_tokens_for_exact_tokens( + sender, + path, + Self::convert_hpb_to_asset_balance(amount_out)?, + amount_in_max, + send_to, + keep_alive, + )?; + Ok(amount_in.into()) } } diff --git a/frame/asset-conversion/src/types.rs b/frame/asset-conversion/src/types.rs index cbe201f01c10b..0612e363f0560 100644 --- a/frame/asset-conversion/src/types.rs +++ b/frame/asset-conversion/src/types.rs @@ -33,7 +33,7 @@ pub struct PoolInfo { /// A trait that converts between a MultiAssetId and either the native currency or an AssetId. pub trait MultiAssetIdConverter { - /// Returns the MultiAssetId reperesenting the native currency of the chain. + /// Returns the MultiAssetId representing the native currency of the chain. fn get_native() -> MultiAssetId; /// Returns true if the given MultiAssetId is the native currency. @@ -42,7 +42,7 @@ pub trait MultiAssetIdConverter { /// If it's not native, returns the AssetId for the given MultiAssetId. fn try_convert(asset: &MultiAssetId) -> Result; - /// Wrapps an AssetId as a MultiAssetId. + /// Wraps an AssetId as a MultiAssetId. fn into_multiasset_id(asset: &AssetId) -> MultiAssetId; } @@ -76,6 +76,12 @@ where Asset(AssetId), } +impl From for NativeOrAssetId { + fn from(asset: AssetId) -> Self { + Self::Asset(asset) + } +} + impl Ord for NativeOrAssetId { fn cmp(&self, other: &Self) -> Ordering { match (self, other) { @@ -126,3 +132,40 @@ impl MultiAssetIdConverter, Asset NativeOrAssetId::Asset((*asset).clone()) } } + +/// Trait for providing methods to swap between the various asset classes. +pub trait Swap { + /// Swap exactly `amount_in` of asset `path[0]` for asset `path[1]`. + /// If an `amount_out_min` is specified, it will return an error if it is unable to acquire + /// the amount desired. + /// + /// Withdraws the `path[0]` asset from `sender`, deposits the `path[1]` asset to `send_to`, + /// respecting `keep_alive`. + /// + /// If successful, returns the amount of `path[1]` acquired for the `amount_in`. + fn swap_exact_tokens_for_tokens( + sender: AccountId, + path: Vec, + amount_in: Balance, + amount_out_min: Option, + send_to: AccountId, + keep_alive: bool, + ) -> Result; + + /// Take the `path[0]` asset and swap some amount for `amount_out` of the `path[1]`. If an + /// `amount_in_max` is specified, it will return an error if acquiring `amount_out` would be + /// too costly. + /// + /// Withdraws `path[0]` asset from `sender`, deposits `path[1]` asset to `send_to`, + /// respecting `keep_alive`. + /// + /// If successful returns the amount of the `path[0]` taken to provide `path[1]`. + fn swap_tokens_for_exact_tokens( + sender: AccountId, + path: Vec, + amount_out: Balance, + amount_in_max: Option, + send_to: AccountId, + keep_alive: bool, + ) -> Result; +} diff --git a/frame/support/src/traits/tokens/fungibles/mod.rs b/frame/support/src/traits/tokens/fungibles/mod.rs index 8070d916fb330..697eff39ff748 100644 --- a/frame/support/src/traits/tokens/fungibles/mod.rs +++ b/frame/support/src/traits/tokens/fungibles/mod.rs @@ -36,5 +36,5 @@ pub use hold::{ pub use imbalance::{Credit, Debt, HandleImbalanceDrop, Imbalance}; pub use lifetime::{Create, Destroy}; pub use regular::{ - Balanced, DecreaseIssuance, Dust, IncreaseIssuance, Inspect, Mutate, SwapNative, Unbalanced, + Balanced, DecreaseIssuance, Dust, IncreaseIssuance, Inspect, Mutate, Unbalanced, }; diff --git a/frame/support/src/traits/tokens/fungibles/regular.rs b/frame/support/src/traits/tokens/fungibles/regular.rs index 838466014e9d0..b6cea15284d39 100644 --- a/frame/support/src/traits/tokens/fungibles/regular.rs +++ b/frame/support/src/traits/tokens/fungibles/regular.rs @@ -584,40 +584,3 @@ pub trait Balanced: Inspect + Unbalanced { fn done_deposit(_asset: Self::AssetId, _who: &AccountId, _amount: Self::Balance) {} fn done_withdraw(_asset: Self::AssetId, _who: &AccountId, _amount: Self::Balance) {} } - -/// Trait for providing methods to swap between the chain's native token and other asset classes. -pub trait SwapNative { - /// Take an `asset_id` and swap some amount for `amount_out` of the chain's native asset. If an - /// `amount_in_max` is specified, it will return an error if acquiring `amount_out` would be - /// too costly. - /// - /// Withdraws `asset_id` from `sender`, deposits native asset to `send_to`, respecting - /// `keep_alive`. - /// - /// If successful returns the amount of the `asset_id` taken to provide `amount_out`. - fn swap_tokens_for_exact_native( - sender: AccountId, - asset_id: AssetId, - amount_out: Balance, - amount_in_max: Option, - send_to: AccountId, - keep_alive: bool, - ) -> Result; - - /// Take an `asset_id` and swap `amount_in` of the chain's native asset for it. If an - /// `amount_out_min` is specified, it will return an error if it is unable to acquire the amount - /// desired. - /// - /// Withdraws native asset from `sender`, deposits `asset_id` to `send_to`, respecting - /// `keep_alive`. - /// - /// If successful, returns the amount of `asset_id` acquired for the `amount_in`. - fn swap_exact_native_for_tokens( - sender: AccountId, - asset_id: AssetId, - amount_in: Balance, - amount_out_min: Option, - send_to: AccountId, - keep_alive: bool, - ) -> Result; -} diff --git a/frame/transaction-payment/asset-conversion-tx-payment/Cargo.toml b/frame/transaction-payment/asset-conversion-tx-payment/Cargo.toml index 8f9e1af04a76a..1555f4d91365d 100644 --- a/frame/transaction-payment/asset-conversion-tx-payment/Cargo.toml +++ b/frame/transaction-payment/asset-conversion-tx-payment/Cargo.toml @@ -18,6 +18,7 @@ sp-runtime = { version = "24.0.0", default-features = false, path = "../../../pr sp-std = { version = "8.0.0", default-features = false, path = "../../../primitives/std" } frame-support = { version = "4.0.0-dev", default-features = false, path = "../../support" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../../system" } +pallet-asset-conversion = { version = "4.0.0-dev", default-features = false, path = "../../asset-conversion" } pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, path = ".." } codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } @@ -28,7 +29,6 @@ sp-io = { version = "23.0.0", default-features = false, path = "../../../primiti sp-storage = { version = "13.0.0", default-features = false, path = "../../../primitives/storage" } pallet-assets = { version = "4.0.0-dev", path = "../../assets" } pallet-balances = { version = "4.0.0-dev", path = "../../balances" } -pallet-asset-conversion = { version = "4.0.0-dev", path = "../../asset-conversion" } [features] default = ["std"] @@ -41,6 +41,7 @@ std = [ "frame-system/std", "sp-io/std", "sp-core/std", + "pallet-asset-conversion/std", "pallet-transaction-payment/std", ] try-runtime = ["frame-support/try-runtime"] diff --git a/frame/transaction-payment/asset-conversion-tx-payment/src/lib.rs b/frame/transaction-payment/asset-conversion-tx-payment/src/lib.rs index 7f6da90dfe95f..efc7386ae8c00 100644 --- a/frame/transaction-payment/asset-conversion-tx-payment/src/lib.rs +++ b/frame/transaction-payment/asset-conversion-tx-payment/src/lib.rs @@ -69,6 +69,8 @@ mod mock; mod tests; mod payment; +use frame_support::traits::tokens::AssetId; +use pallet_asset_conversion::MultiAssetIdConverter; pub use payment::*; /// Type aliases used for interaction with `OnChargeTransaction`. @@ -116,7 +118,9 @@ pub mod pallet { use super::*; #[pallet::config] - pub trait Config: frame_system::Config + pallet_transaction_payment::Config { + pub trait Config: + frame_system::Config + pallet_transaction_payment::Config + pallet_asset_conversion::Config + { /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The fungibles instance used to pay for transactions in assets. @@ -187,12 +191,12 @@ where debug_assert!(self.tip <= fee, "tip should be included in the computed fee"); if fee.is_zero() { Ok((fee, InitialPayment::Nothing)) - } else if let Some(asset_id) = self.asset_id { + } else if let Some(asset_id) = &self.asset_id { T::OnChargeAssetTransaction::withdraw_fee( who, call, info, - asset_id, + asset_id.clone(), fee.into(), self.tip.into(), ) @@ -324,7 +328,7 @@ where tip.into(), used_for_fee.into(), received_exchanged.into(), - asset_id, + asset_id.clone(), asset_consumed.into(), )?; diff --git a/frame/transaction-payment/asset-conversion-tx-payment/src/payment.rs b/frame/transaction-payment/asset-conversion-tx-payment/src/payment.rs index 86b2c09e541ac..0d090211d0352 100644 --- a/frame/transaction-payment/asset-conversion-tx-payment/src/payment.rs +++ b/frame/transaction-payment/asset-conversion-tx-payment/src/payment.rs @@ -17,26 +17,25 @@ use super::*; use crate::Config; -use codec::FullCodec; use frame_support::{ ensure, - traits::{fungible::Inspect, fungibles::SwapNative, tokens::Balance}, + traits::{fungible::Inspect, tokens::Balance}, unsigned::TransactionValidityError, }; -use scale_info::TypeInfo; +use pallet_asset_conversion::Swap; use sp_runtime::{ - traits::{DispatchInfoOf, MaybeSerializeDeserialize, PostDispatchInfoOf, Zero}, + traits::{DispatchInfoOf, PostDispatchInfoOf, Zero}, transaction_validity::InvalidTransaction, Saturating, }; -use sp_std::{fmt::Debug, marker::PhantomData}; +use sp_std::marker::PhantomData; /// Handle withdrawing, refunding and depositing of transaction fees. pub trait OnChargeAssetTransaction { /// The underlying integer type in which fees are calculated. type Balance: Balance; /// The type used to identify the assets used for transaction payment. - type AssetId: FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default + Eq + TypeInfo; + type AssetId: AssetId; /// The type used to store the intermediate values between pre- and post-dispatch. type LiquidityInfo; @@ -74,8 +73,7 @@ pub trait OnChargeAssetTransaction { ) -> Result, TransactionValidityError>; } -/// Implements the asset transaction for a balance to asset converter (implementing -/// [`SwapNative`]). +/// Implements the asset transaction for a balance to asset converter (implementing [`Swap`]). /// /// The converter is given the complete fee in terms of the asset used for the transaction. pub struct AssetConversionAdapter(PhantomData<(C, CON)>); @@ -85,8 +83,9 @@ impl OnChargeAssetTransaction for AssetConversionAdapter where T: Config, C: Inspect<::AccountId>, - CON: SwapNative, AssetBalanceOf, AssetIdOf>, - AssetIdOf: FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default + Eq + TypeInfo, + CON: Swap, + T::HigherPrecisionBalance: From> + TryInto>, + T::MultiAssetId: From>, BalanceOf: IsType<::AccountId>>::Balance>, { type Balance = BalanceOf; @@ -115,16 +114,20 @@ where let native_asset_required = if C::balance(&who) >= ed.saturating_add(fee.into()) { fee } else { fee + ed.into() }; - let asset_consumed = CON::swap_tokens_for_exact_native( + let asset_consumed = CON::swap_tokens_for_exact_tokens( who.clone(), - asset_id, - native_asset_required, + vec![asset_id.into(), T::MultiAssetIdConverter::get_native()], + T::HigherPrecisionBalance::from(native_asset_required), None, who.clone(), true, ) .map_err(|_| TransactionValidityError::from(InvalidTransaction::Payment))?; + let asset_consumed = asset_consumed + .try_into() + .map_err(|_| TransactionValidityError::from(InvalidTransaction::Payment))?; + ensure!(asset_consumed > Zero::zero(), InvalidTransaction::Payment); // charge the fee in native currency @@ -166,17 +169,25 @@ where // If this fails, the account might have dropped below the existential balance or there // is not enough liquidity left in the pool. In that case we don't throw an error and // the account will keep the native currency. - match CON::swap_exact_native_for_tokens( + match CON::swap_exact_tokens_for_tokens( who.clone(), // we already deposited the native to `who` - asset_id, // we want asset_id back - swap_back, // amount of the native asset to convert to `asset_id` + vec![ + T::MultiAssetIdConverter::get_native(), // we provide the native + asset_id.into(), // we want asset_id back + ], + T::HigherPrecisionBalance::from(swap_back), /* amount of the native asset to + * convert to `asset_id` */ None, // no minimum amount back who.clone(), // we will refund to `who` false, // no need to keep alive ) .ok() { - Some(acquired) => asset_refund = acquired, + Some(acquired) => { + asset_refund = acquired + .try_into() + .map_err(|_| TransactionValidityError::from(InvalidTransaction::Payment))?; + }, None => { Pallet::::deposit_event(Event::::AssetRefundFailed { native_amount_kept: swap_back, From 15634c25c49b8f04a37ddc38083579fffcc1511a Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 13 Jul 2023 16:29:40 +0200 Subject: [PATCH 059/105] wip --- frame/contracts/src/migration/v13.rs | 31 +++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/frame/contracts/src/migration/v13.rs b/frame/contracts/src/migration/v13.rs index 7e01fffa33e55..5de563e4d5304 100644 --- a/frame/contracts/src/migration/v13.rs +++ b/frame/contracts/src/migration/v13.rs @@ -23,7 +23,7 @@ use crate::{ migration::{IsFinished, MigrationStep}, weights::WeightInfo, - Config, ContractInfoOf, HoldReason, Weight, LOG_TARGET, + Config, ContractInfo, ContractInfoOf, HoldReason, Weight, LOG_TARGET, }; use frame_support::{ pallet_prelude::*, @@ -157,11 +157,36 @@ impl MigrationStep for Migration { #[cfg(feature = "try-runtime")] fn pre_upgrade_step() -> Result, TryRuntimeError> { - todo!() + let sample: Vec<_> = ContractInfoOf::::iter().take(100).collect(); + + log::debug!(target: LOG_TARGET, "Taking sample of {} contracts", sample.len()); + Ok(sample.encode()) } #[cfg(feature = "try-runtime")] fn post_upgrade_step(state: Vec) -> Result<(), TryRuntimeError> { - todo!() + let sample = )> as Decode>::decode(&mut &state[..]) + .expect("pre_upgrade_step provides a valid state; qed"); + + log::debug!(target: LOG_TARGET, "Validating sample of {} contracts", sample.len()); + for (account, old_contract) in sample { + log::debug!(target: LOG_TARGET, "==="); + log::debug!(target: LOG_TARGET, "Account: 0x{} ", HexDisplay::from(&account.encode())); + let contract = ContractInfoOf::::get(&account).unwrap(); + + let deposit = T::Currency::total_balance( + &contract.deposit_account(), + ); + ensure!( + deposit == + contract + .storage_base_deposit + .saturating_add(contract.storage_item_deposit) + .saturating_add(contract.storage_byte_deposit), + "deposit mismatch" + ); + } + + Ok(()) } } From 1775efaad5179688dce8a08407c2f8bec3ea6f6b Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 14 Jul 2023 18:04:09 +0200 Subject: [PATCH 060/105] wip --- frame/contracts/src/lib.rs | 2 +- frame/contracts/src/migration/v13.rs | 53 +++++++++++++++++----------- 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index e570bc7c95af5..ab75c286e6e2b 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -188,7 +188,7 @@ pub mod pallet { /// The current storage version. #[cfg(not(any(test, feature = "runtime-benchmarks")))] - const STORAGE_VERSION: StorageVersion = StorageVersion::new(12); + const STORAGE_VERSION: StorageVersion = StorageVersion::new(13); /// Hard coded storage version for running tests that depend on the current storage version. #[cfg(any(test, feature = "runtime-benchmarks"))] diff --git a/frame/contracts/src/migration/v13.rs b/frame/contracts/src/migration/v13.rs index 5de563e4d5304..a2acf3f41d657 100644 --- a/frame/contracts/src/migration/v13.rs +++ b/frame/contracts/src/migration/v13.rs @@ -23,8 +23,12 @@ use crate::{ migration::{IsFinished, MigrationStep}, weights::WeightInfo, - Config, ContractInfo, ContractInfoOf, HoldReason, Weight, LOG_TARGET, + Config, ContractInfoOf, HoldReason, Weight, LOG_TARGET, }; +#[cfg(feature = "try-runtime")] +use crate::{BalanceOf, ContractInfo}; +#[cfg(feature = "try-runtime")] +use frame_support::dispatch::Vec; use frame_support::{ pallet_prelude::*, traits::{ @@ -38,7 +42,6 @@ use sp_core::hexdisplay::HexDisplay; #[cfg(feature = "try-runtime")] use sp_runtime::TryRuntimeError; use sp_runtime::{traits::Zero, Saturating}; -use sp_std::ops::Deref; #[derive(Encode, Decode, MaxEncodedLen, DefaultNoBound)] pub struct Migration { @@ -60,13 +63,15 @@ impl MigrationStep for Migration { }; if let Some((account, contract)) = iter.next() { - let deposit_account = contract.deposit_account().deref(); - System::::dec_consumers(&deposit_account); + let deposit_account = &contract.deposit_account(); + if System::::consumers(deposit_account) > Zero::zero() { + System::::dec_consumers(deposit_account); + } // Get the deposit balance to transfer. let total_deposit_balance = T::Currency::total_balance(deposit_account); let reducible_deposit_balance = T::Currency::reducible_balance( - &deposit_account, + deposit_account, Preservation::Expendable, Fortitude::Force, ); @@ -88,7 +93,7 @@ impl MigrationStep for Migration { // Move balance reserved from the deposit account back to the contract account. // Let the deposit account die. let transferred_deposit_balance = T::Currency::transfer( - &contract.deposit_account(), + deposit_account, &account, reducible_deposit_balance, Preservation::Expendable, @@ -148,6 +153,10 @@ impl MigrationStep for Migration { } log::debug!(target: LOG_TARGET, "==="); + + // Store last key for next migration step + self.last_account = Some(account); + (IsFinished::No, T::WeightInfo::v13_migration_step()) } else { log::info!(target: LOG_TARGET, "Done Migrating Storage Deposits."); @@ -160,30 +169,34 @@ impl MigrationStep for Migration { let sample: Vec<_> = ContractInfoOf::::iter().take(100).collect(); log::debug!(target: LOG_TARGET, "Taking sample of {} contracts", sample.len()); - Ok(sample.encode()) + + let state: Vec<(T::AccountId, ContractInfo, BalanceOf)> = sample + .iter() + .map(|(account, contract)| { + let deposit_balance = T::Currency::total_balance(&contract.deposit_account()); + let account_balance = T::Currency::total_balance(&account); + (account.clone(), contract.clone(), account_balance.saturating_add(deposit_balance)) + }) + .collect(); + + Ok(state.encode()) } #[cfg(feature = "try-runtime")] fn post_upgrade_step(state: Vec) -> Result<(), TryRuntimeError> { - let sample = )> as Decode>::decode(&mut &state[..]) - .expect("pre_upgrade_step provides a valid state; qed"); + let sample = + , BalanceOf)> as Decode>::decode(&mut &state[..]) + .expect("pre_upgrade_step provides a valid state; qed"); log::debug!(target: LOG_TARGET, "Validating sample of {} contracts", sample.len()); - for (account, old_contract) in sample { + for (account, contract, old_total_balance) in sample { log::debug!(target: LOG_TARGET, "==="); log::debug!(target: LOG_TARGET, "Account: 0x{} ", HexDisplay::from(&account.encode())); - let contract = ContractInfoOf::::get(&account).unwrap(); - let deposit = T::Currency::total_balance( - &contract.deposit_account(), - ); + ensure!(old_total_balance == T::Currency::total_balance(&account), "deposit mismatch"); ensure!( - deposit == - contract - .storage_base_deposit - .saturating_add(contract.storage_item_deposit) - .saturating_add(contract.storage_byte_deposit), - "deposit mismatch" + !System::::account_exists(&contract.deposit_account()), + "deposit account still exists" ); } From 12c522c98f1c64bb4da34d2e6d6b6f23ae77a20c Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Mon, 17 Jul 2023 11:16:00 +0200 Subject: [PATCH 061/105] wip --- frame/contracts/src/migration/v13.rs | 34 +++++++++++++++++++++------- frame/contracts/src/wasm/mod.rs | 1 + 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/frame/contracts/src/migration/v13.rs b/frame/contracts/src/migration/v13.rs index a2acf3f41d657..5620934b8233e 100644 --- a/frame/contracts/src/migration/v13.rs +++ b/frame/contracts/src/migration/v13.rs @@ -32,7 +32,7 @@ use frame_support::dispatch::Vec; use frame_support::{ pallet_prelude::*, traits::{ - fungible::{Mutate, MutateHold}, + fungible::{InspectHold, Mutate, MutateHold}, tokens::{fungible::Inspect, Fortitude, Preservation}, }, DefaultNoBound, @@ -134,7 +134,7 @@ impl MigrationStep for Migration { transferred_deposit_balance, ) .map(|_| { - log::info!( + log::debug!( target: LOG_TARGET, "Successfully held {:?} as storage deposit on the contract 0x{:?}.", transferred_deposit_balance, @@ -170,12 +170,17 @@ impl MigrationStep for Migration { log::debug!(target: LOG_TARGET, "Taking sample of {} contracts", sample.len()); - let state: Vec<(T::AccountId, ContractInfo, BalanceOf)> = sample + let state: Vec<(T::AccountId, ContractInfo, BalanceOf, BalanceOf)> = sample .iter() .map(|(account, contract)| { let deposit_balance = T::Currency::total_balance(&contract.deposit_account()); let account_balance = T::Currency::total_balance(&account); - (account.clone(), contract.clone(), account_balance.saturating_add(deposit_balance)) + ( + account.clone(), + contract.clone(), + account_balance.saturating_add(deposit_balance), + deposit_balance, + ) }) .collect(); @@ -185,15 +190,28 @@ impl MigrationStep for Migration { #[cfg(feature = "try-runtime")] fn post_upgrade_step(state: Vec) -> Result<(), TryRuntimeError> { let sample = - , BalanceOf)> as Decode>::decode(&mut &state[..]) - .expect("pre_upgrade_step provides a valid state; qed"); + , BalanceOf, BalanceOf)> as Decode>::decode( + &mut &state[..], + ) + .expect("pre_upgrade_step provides a valid state; qed"); log::debug!(target: LOG_TARGET, "Validating sample of {} contracts", sample.len()); - for (account, contract, old_total_balance) in sample { + for (account, contract, old_total_balance, deposit_balance) in sample { log::debug!(target: LOG_TARGET, "==="); log::debug!(target: LOG_TARGET, "Account: 0x{} ", HexDisplay::from(&account.encode())); - ensure!(old_total_balance == T::Currency::total_balance(&account), "deposit mismatch"); + ensure!( + old_total_balance == T::Currency::total_balance(&account), + "total balance mismatch" + ); + ensure!( + deposit_balance == + T::Currency::balance_on_hold( + &HoldReason::StorageDepositReserve.into(), + &account + ), + "deposit mismatch" + ); ensure!( !System::::account_exists(&contract.deposit_account()), "deposit account still exists" diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index 02ea08eed0bf5..08df3ace2c1db 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -248,6 +248,7 @@ impl WasmBlob { &self.code_info.owner, deposit, ) + // TODO: better error mapping .map_err(|_| >::StorageDepositNotEnoughFunds)?; >::deposit_event( From 6fb9713ffac385cea53f151246944a1c56fe6d80 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Mon, 17 Jul 2023 11:25:07 +0200 Subject: [PATCH 062/105] improve try-runtime imports --- frame/contracts/src/migration/v13.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/contracts/src/migration/v13.rs b/frame/contracts/src/migration/v13.rs index 5620934b8233e..427d23bbf0515 100644 --- a/frame/contracts/src/migration/v13.rs +++ b/frame/contracts/src/migration/v13.rs @@ -28,11 +28,11 @@ use crate::{ #[cfg(feature = "try-runtime")] use crate::{BalanceOf, ContractInfo}; #[cfg(feature = "try-runtime")] -use frame_support::dispatch::Vec; +use frame_support::{dispatch::Vec, traits::fungible::InspectHold}; use frame_support::{ pallet_prelude::*, traits::{ - fungible::{InspectHold, Mutate, MutateHold}, + fungible::{Mutate, MutateHold}, tokens::{fungible::Inspect, Fortitude, Preservation}, }, DefaultNoBound, From cdd0ca43ec46ff56b0cd8280a0a706ced8c7c76a Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 18 Jul 2023 13:02:45 +0200 Subject: [PATCH 063/105] fix benchmark test --- frame/contracts/src/migration/v13.rs | 3 ++- frame/contracts/src/wasm/mod.rs | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/frame/contracts/src/migration/v13.rs b/frame/contracts/src/migration/v13.rs index 427d23bbf0515..a536f185ca394 100644 --- a/frame/contracts/src/migration/v13.rs +++ b/frame/contracts/src/migration/v13.rs @@ -18,7 +18,8 @@ //! Move contracts' _reserved_ balance to be _held_ instead. Since //! [`Currency`](frame_support::traits::Currency) has been deprecated [here](https://github.com/paritytech/substrate/pull/12951), //! we need the storage deposit to be handled by the [fungible -//! traits](frame_support::traits::fungibles) instead. +//! traits](frame_support::traits::fungibles) instead. For this we need to transfer the balance in +//! the deposit account to the contract's account and hold it in there. use crate::{ migration::{IsFinished, MigrationStep}, diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index 08df3ace2c1db..cee83bbe0b48b 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -38,7 +38,7 @@ use crate::{ wasm::prepare::LoadedModule, weights::WeightInfo, AccountIdOf, BadOrigin, BalanceOf, CodeHash, CodeInfoOf, CodeVec, Config, Error, Event, - HoldReason, Pallet, PristineCode, Schedule, Weight, LOG_TARGET, + HoldReason, Pallet, PristineCode, Schedule, System, Weight, LOG_TARGET, }; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ @@ -241,6 +241,7 @@ impl WasmBlob { // the `owner` is always the origin of the current transaction. None => { let deposit = self.code_info.deposit; + System::::inc_providers(&self.code_info.owner); // This `None` case happens only in freshly uploaded modules. This means that // the `owner` is always the origin of the current transaction. T::Currency::hold( @@ -249,7 +250,11 @@ impl WasmBlob { deposit, ) // TODO: better error mapping - .map_err(|_| >::StorageDepositNotEnoughFunds)?; + .map_err(|_| { + let _ = System::::dec_providers(&self.code_info.owner); + + >::StorageDepositNotEnoughFunds + })?; >::deposit_event( vec![T::Hashing::hash_of(&self.code_info.owner)], @@ -282,6 +287,8 @@ impl WasmBlob { BestEffort, ); + let _ = System::::dec_providers(&code_info.owner); + >::deposit_event( vec![T::Hashing::hash_of(&code_info.owner)], Event::StorageDepositReleased { From ae4fda2d214c148f1e142efad06f418ca0698090 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 18 Jul 2023 13:18:20 +0200 Subject: [PATCH 064/105] improved rustdocs --- frame/contracts/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index ab75c286e6e2b..d2b68737838d5 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -25,10 +25,10 @@ //! //! ## Overview //! -//! This module extends accounts based on the [`fungible`] traits to have smart-contract -//! functionality. It can be used with other modules that implement accounts based on [`fungible`] -//! traits. These "smart-contract accounts" have the ability to instantiate smart-contracts and make -//! calls to other contract and non-contract accounts. +//! This module extends accounts based on the [`frame_support::traits::fungible`] traits to have +//! smart-contract functionality. It can be used with other modules that implement accounts based on +//! the [`frame_support::traits::fungible`] traits. These "smart-contract accounts" have the ability +//! to instantiate smart-contracts and make calls to other contract and non-contract accounts. //! //! The smart-contract code is stored once, and later retrievable via its hash. //! This means that multiple smart-contracts can be instantiated from the same hash, without From f5e4b20e58f104e2d721aef0e4a90f8a9fa628f2 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 18 Jul 2023 16:01:16 +0200 Subject: [PATCH 065/105] improved rustdocs --- frame/contracts/src/migration/v13.rs | 6 +++--- frame/contracts/src/storage/meter.rs | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/frame/contracts/src/migration/v13.rs b/frame/contracts/src/migration/v13.rs index a536f185ca394..f7fee00f24fe2 100644 --- a/frame/contracts/src/migration/v13.rs +++ b/frame/contracts/src/migration/v13.rs @@ -17,9 +17,9 @@ //! Move contracts' _reserved_ balance to be _held_ instead. Since //! [`Currency`](frame_support::traits::Currency) has been deprecated [here](https://github.com/paritytech/substrate/pull/12951), -//! we need the storage deposit to be handled by the [fungible -//! traits](frame_support::traits::fungibles) instead. For this we need to transfer the balance in -//! the deposit account to the contract's account and hold it in there. +//! we need the storage deposit to be handled by the [`frame_support::traits::fungible`] traits +//! instead. For this we need to transfer the balance in the deposit account to the contract's +//! account and hold it in there. use crate::{ migration::{IsFinished, MigrationStep}, diff --git a/frame/contracts/src/storage/meter.rs b/frame/contracts/src/storage/meter.rs index 45397e64caaee..d35fb3780e823 100644 --- a/frame/contracts/src/storage/meter.rs +++ b/frame/contracts/src/storage/meter.rs @@ -19,7 +19,7 @@ use crate::{ storage::{ContractInfo, DepositAccount}, - BalanceOf, Config, Error, Inspect, Origin, Pallet, System, + BalanceOf, Config, Error, Inspect, Origin, Pallet, System, LOG_TARGET, }; use codec::Encode; use frame_support::{ @@ -438,6 +438,10 @@ where // deposit account into existence. // We also add another `ed` here which goes to the contract's own account into existence. deposit = deposit.max(Deposit::Charge(ed)).saturating_add(&Deposit::Charge(ed)); + log::debug!( + target: LOG_TARGET, + "Charge instantiate: limit={:?}, deposit={:?}", self.limit, deposit,); + if deposit.charge_or_zero() > self.limit { return Err(>::StorageDepositLimitExhausted.into()) } From cb9217d9f60975886edbfb9fc789ba6464204838 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 18 Jul 2023 16:02:20 +0200 Subject: [PATCH 066/105] remove log --- frame/contracts/src/storage/meter.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/frame/contracts/src/storage/meter.rs b/frame/contracts/src/storage/meter.rs index d35fb3780e823..45397e64caaee 100644 --- a/frame/contracts/src/storage/meter.rs +++ b/frame/contracts/src/storage/meter.rs @@ -19,7 +19,7 @@ use crate::{ storage::{ContractInfo, DepositAccount}, - BalanceOf, Config, Error, Inspect, Origin, Pallet, System, LOG_TARGET, + BalanceOf, Config, Error, Inspect, Origin, Pallet, System, }; use codec::Encode; use frame_support::{ @@ -438,10 +438,6 @@ where // deposit account into existence. // We also add another `ed` here which goes to the contract's own account into existence. deposit = deposit.max(Deposit::Charge(ed)).saturating_add(&Deposit::Charge(ed)); - log::debug!( - target: LOG_TARGET, - "Charge instantiate: limit={:?}, deposit={:?}", self.limit, deposit,); - if deposit.charge_or_zero() > self.limit { return Err(>::StorageDepositLimitExhausted.into()) } From 632ef2e151204201b44cc048d8bbf3ea571ef6a8 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Wed, 19 Jul 2023 11:51:29 +0200 Subject: [PATCH 067/105] ignore variable --- 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 3b9f27a359b7f..cac91025045a3 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -107,8 +107,7 @@ pub mod test_utils { >::insert(address, contract); } pub fn set_balance(who: &AccountIdOf, amount: u64) { - let imbalance = ::Currency::set_balance(who, amount); - drop(imbalance); + let _ = ::Currency::set_balance(who, amount); } pub fn get_balance(who: &AccountIdOf) -> u64 { ::Currency::free_balance(who) From bc8efaf40f319aaa60c1d07e30ce413fd0f4e3ff Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Wed, 19 Jul 2023 15:04:54 +0200 Subject: [PATCH 068/105] reduce caller funding --- frame/contracts/src/benchmarking/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 9a17c28a81662..9ebfc44af5da0 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -178,7 +178,7 @@ where /// The funding that each account that either calls or instantiates contracts is funded with. fn caller_funding() -> BalanceOf { - BalanceOf::::max_value() / 2u32.into() + BalanceOf::::max_value() / 10_000u32.into() } /// Load the specified contract file from disk by including it into the runtime. From 7c97aaea7b3bbd535ef7aa16c3319d5a038bf630 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 21 Jul 2023 10:52:53 +0200 Subject: [PATCH 069/105] move v13 out --- frame/contracts/src/migration/v13.rs | 223 --------------------------- 1 file changed, 223 deletions(-) diff --git a/frame/contracts/src/migration/v13.rs b/frame/contracts/src/migration/v13.rs index f7fee00f24fe2..8b137891791fe 100644 --- a/frame/contracts/src/migration/v13.rs +++ b/frame/contracts/src/migration/v13.rs @@ -1,224 +1 @@ -// 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. - -//! Move contracts' _reserved_ balance to be _held_ instead. Since -//! [`Currency`](frame_support::traits::Currency) has been deprecated [here](https://github.com/paritytech/substrate/pull/12951), -//! we need the storage deposit to be handled by the [`frame_support::traits::fungible`] traits -//! instead. For this we need to transfer the balance in the deposit account to the contract's -//! account and hold it in there. - -use crate::{ - migration::{IsFinished, MigrationStep}, - weights::WeightInfo, - Config, ContractInfoOf, HoldReason, Weight, LOG_TARGET, -}; -#[cfg(feature = "try-runtime")] -use crate::{BalanceOf, ContractInfo}; -#[cfg(feature = "try-runtime")] -use frame_support::{dispatch::Vec, traits::fungible::InspectHold}; -use frame_support::{ - pallet_prelude::*, - traits::{ - fungible::{Mutate, MutateHold}, - tokens::{fungible::Inspect, Fortitude, Preservation}, - }, - DefaultNoBound, -}; -use frame_system::Pallet as System; -use sp_core::hexdisplay::HexDisplay; -#[cfg(feature = "try-runtime")] -use sp_runtime::TryRuntimeError; -use sp_runtime::{traits::Zero, Saturating}; - -#[derive(Encode, Decode, MaxEncodedLen, DefaultNoBound)] -pub struct Migration { - last_account: Option, -} - -impl MigrationStep for Migration { - const VERSION: u16 = 13; - - fn max_step_weight() -> Weight { - T::WeightInfo::v13_migration_step() - } - - fn step(&mut self) -> (IsFinished, Weight) { - let mut iter = if let Some(last_account) = self.last_account.take() { - ContractInfoOf::::iter_from(ContractInfoOf::::hashed_key_for(last_account)) - } else { - ContractInfoOf::::iter() - }; - - if let Some((account, contract)) = iter.next() { - let deposit_account = &contract.deposit_account(); - if System::::consumers(deposit_account) > Zero::zero() { - System::::dec_consumers(deposit_account); - } - - // Get the deposit balance to transfer. - let total_deposit_balance = T::Currency::total_balance(deposit_account); - let reducible_deposit_balance = T::Currency::reducible_balance( - deposit_account, - Preservation::Expendable, - Fortitude::Force, - ); - - if total_deposit_balance > reducible_deposit_balance { - // This should never happen, as by design all balance in the deposit account is - // storage deposit and therefore reducible after decrementing the consumer - // reference. - log::warn!( - target: LOG_TARGET, - "Deposit account 0x{:?} for contract 0x{:?} has some non-reducible balance {:?} from a total of {:?} that will remain in there.", - HexDisplay::from(&deposit_account.encode()), - HexDisplay::from(&account.encode()), - total_deposit_balance.saturating_sub(reducible_deposit_balance), - total_deposit_balance - ); - } - - // Move balance reserved from the deposit account back to the contract account. - // Let the deposit account die. - let transferred_deposit_balance = T::Currency::transfer( - deposit_account, - &account, - reducible_deposit_balance, - Preservation::Expendable, - ) - .map(|_| { - log::debug!( - target: LOG_TARGET, - "{:?} transferred from the deposit account 0x{:?} to the contract 0x{:?}.", - reducible_deposit_balance, - HexDisplay::from(&deposit_account.encode()), - HexDisplay::from(&account.encode()) - ); - reducible_deposit_balance - }) - .unwrap_or_else(|err| { - log::error!( - target: LOG_TARGET, - "Failed to transfer {:?} from the deposit account 0x{:?} to the contract 0x{:?}, reason: {:?}.", - reducible_deposit_balance, - HexDisplay::from(&deposit_account.encode()), - HexDisplay::from(&account.encode()), - err - ); - Zero::zero() - }); - - // Hold the reserved balance. - if transferred_deposit_balance == Zero::zero() { - log::warn!( - target: LOG_TARGET, - "No balance to hold as storage deposit on the contract 0x{:?}.", - HexDisplay::from(&account.encode()) - ); - } else { - T::Currency::hold( - &HoldReason::StorageDepositReserve.into(), - &account, - transferred_deposit_balance, - ) - .map(|_| { - log::debug!( - target: LOG_TARGET, - "Successfully held {:?} as storage deposit on the contract 0x{:?}.", - transferred_deposit_balance, - HexDisplay::from(&account.encode()) - ); - }) - .unwrap_or_else(|err| { - log::error!( - target: LOG_TARGET, - "Failed to hold {:?} as storage deposit on the contract 0x{:?}, reason: {:?}.", - transferred_deposit_balance, - HexDisplay::from(&account.encode()), - err - ); - }); - } - - log::debug!(target: LOG_TARGET, "==="); - - // Store last key for next migration step - self.last_account = Some(account); - - (IsFinished::No, T::WeightInfo::v13_migration_step()) - } else { - log::info!(target: LOG_TARGET, "Done Migrating Storage Deposits."); - (IsFinished::Yes, T::WeightInfo::v13_migration_step()) - } - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade_step() -> Result, TryRuntimeError> { - let sample: Vec<_> = ContractInfoOf::::iter().take(100).collect(); - - log::debug!(target: LOG_TARGET, "Taking sample of {} contracts", sample.len()); - - let state: Vec<(T::AccountId, ContractInfo, BalanceOf, BalanceOf)> = sample - .iter() - .map(|(account, contract)| { - let deposit_balance = T::Currency::total_balance(&contract.deposit_account()); - let account_balance = T::Currency::total_balance(&account); - ( - account.clone(), - contract.clone(), - account_balance.saturating_add(deposit_balance), - deposit_balance, - ) - }) - .collect(); - - Ok(state.encode()) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade_step(state: Vec) -> Result<(), TryRuntimeError> { - let sample = - , BalanceOf, BalanceOf)> as Decode>::decode( - &mut &state[..], - ) - .expect("pre_upgrade_step provides a valid state; qed"); - - log::debug!(target: LOG_TARGET, "Validating sample of {} contracts", sample.len()); - for (account, contract, old_total_balance, deposit_balance) in sample { - log::debug!(target: LOG_TARGET, "==="); - log::debug!(target: LOG_TARGET, "Account: 0x{} ", HexDisplay::from(&account.encode())); - - ensure!( - old_total_balance == T::Currency::total_balance(&account), - "total balance mismatch" - ); - ensure!( - deposit_balance == - T::Currency::balance_on_hold( - &HoldReason::StorageDepositReserve.into(), - &account - ), - "deposit mismatch" - ); - ensure!( - !System::::account_exists(&contract.deposit_account()), - "deposit account still exists" - ); - } - - Ok(()) - } -} From a96a50eb0861a31824f89143370ad86dac1faf1a Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 21 Jul 2023 16:11:25 +0200 Subject: [PATCH 070/105] update v13 migration --- frame/contracts/src/migration/v13.rs | 189 +++++++++++++++++++++++++++ 1 file changed, 189 insertions(+) diff --git a/frame/contracts/src/migration/v13.rs b/frame/contracts/src/migration/v13.rs index 8b137891791fe..4a374faa42633 100644 --- a/frame/contracts/src/migration/v13.rs +++ b/frame/contracts/src/migration/v13.rs @@ -1 +1,190 @@ +// 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. + +//! Update the code owner balance, make the storage deposit reserved balance to be held instead. + +use crate::{ + exec::AccountIdOf, + migration::{IsFinished, MigrationStep}, + weights::WeightInfo, + BalanceOf, CodeHash, Config, Determinism, HoldReason, Pallet, Weight, LOG_TARGET, +}; +use codec::{Decode, Encode}; +use frame_support::{ + codec, + pallet_prelude::*, + storage_alias, + traits::{fungible::MutateHold, ReservableCurrency}, + DefaultNoBound, Identity, +}; +use sp_core::hexdisplay::HexDisplay; +use sp_runtime::Saturating; + +mod old { + use super::*; + + pub type BalanceOf = ::AccountId, + >>::Balance; + + #[derive(Clone, Encode, Decode, scale_info::TypeInfo, MaxEncodedLen)] + #[codec(mel_bound())] + #[scale_info(skip_type_params(T, OldCurrency))] + pub struct CodeInfo + where + OldCurrency: ReservableCurrency<::AccountId>, + { + pub owner: AccountIdOf, + #[codec(compact)] + pub deposit: BalanceOf, + #[codec(compact)] + refcount: u64, + determinism: Determinism, + pub code_len: u32, + } + + #[storage_alias] + pub type CodeInfoOf = + StorageMap, Identity, CodeHash, CodeInfo>; +} + +#[derive(Encode, Decode, MaxEncodedLen, DefaultNoBound)] +pub struct Migration +where + OldCurrency: ReservableCurrency<::AccountId>, +{ + last_code_hash: Option>, + _phantom: PhantomData<(T, OldCurrency)>, +} + +impl MigrationStep for Migration +where + OldCurrency: ReservableCurrency<::AccountId>, + BalanceOf: From>, +{ + const VERSION: u16 = 13; + + fn max_step_weight() -> Weight { + T::WeightInfo::v9_migration_step(T::MaxCodeLen::get()) // TODO + } + + fn step(&mut self) -> (IsFinished, Weight) { + let mut iter = if let Some(last_key) = self.last_code_hash.take() { + old::CodeInfoOf::::iter_from( + old::CodeInfoOf::::hashed_key_for(last_key), + ) + } else { + old::CodeInfoOf::::iter() + }; + + if let Some((key, code_info)) = iter.next() { + log::debug!(target: LOG_TARGET, "Migrating storage deposit for {:?}", code_info.owner); + let len = code_info.code_len as u32; + let unreserved = OldCurrency::unreserve(&code_info.owner, code_info.deposit); + + if code_info.deposit > unreserved { + log::warn!( + target: LOG_TARGET, + "Code owner's account 0x{:?} for code {:?} has some non-unreservable deposit {:?} from a total of {:?} that will remain in reserved.", + HexDisplay::from(&code_info.owner.encode()), + key, + code_info.deposit.saturating_sub(unreserved), + code_info.deposit + ); + } + + T::Currency::hold( + &HoldReason::StorageDepositReserve.into(), + &code_info.owner, + unreserved.into(), + ) + .map(|_| { + log::debug!( + target: LOG_TARGET, + "{:?} held on the code owner's account 0x{:?} for code {:?}.", + unreserved, + HexDisplay::from(&code_info.owner.encode()), + key, + ); + }) + .unwrap_or_else(|err| { + log::error!( + target: LOG_TARGET, + "Failed to hold {:?} from the code owner's account 0x{:?} for code {:?}, reason: {:?}.", + unreserved, + HexDisplay::from(&code_info.owner.encode()), + key, + err + ); + }); + + self.last_code_hash = Some(key); + (IsFinished::No, T::WeightInfo::v9_migration_step(len)) // TODO + } else { + log::debug!(target: LOG_TARGET, "No more storage deposit to migrate"); + (IsFinished::Yes, T::WeightInfo::v9_migration_step(0)) // TODO + } + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade_step() -> Result, TryRuntimeError> { + let sample: Vec<_> = old::CodeInfoOf::::iter().take(100).collect(); + + log::debug!(target: LOG_TARGET, "Taking sample of {} contracts", sample.len()); + Ok(sample.encode()) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade_step(state: Vec) -> Result<(), TryRuntimeError> { + let sample = , old::CodeInfoOf)> as Decode>::decode( + &mut &state[..], + ) + .expect("pre_upgrade_step provides a valid state; qed"); + + log::debug!(target: LOG_TARGET, "Validating sample of {} contracts", sample.len()); + + // Keep the sum of the storage deposits of all codes owned by an owner. + let mut owner_storage_deposits = HashMap::>::new(); + + for (_, old_code_info) in sample { + *owner_storage_deposits + .entry(old_code_info.owner) + .or_insert(BalanceOf::::zero()) += old_code_info.deposit.into(); + } + + for (&owner, &reserved) in owner_storage_deposits { + let held = + T::Currency::balance_on_hold(&HoldReason::StorageDepositReserve.into(), &owner); + ensure!( + held == reserved, + "Held amount mismatch for owner 0x{:?}: expected {:?}, got {:?}", + HexDisplay::from(&owner.encode()), + reserved, + held + ); + ensure!( + OldCurrency::total_balance(owner).into() == T::Currency::balance(owner), + "Balance mismatch for owner 0x{:?}: old balance {:?}, new balance {:?}", + HexDisplay::from(&owner.encode()), + OldCurrency::total_balance(owner), + T::Currency::balance(owner) + ); + } + + Ok(()) + } +} From c67ea9f5b2e82c93f290c7faf2e0a9e856de11ed Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Mon, 24 Jul 2023 13:25:06 +0200 Subject: [PATCH 071/105] v13 migration --- frame/contracts/src/benchmarking/mod.rs | 2 +- frame/contracts/src/migration/v13.rs | 158 ++++++++++++++++-------- 2 files changed, 108 insertions(+), 52 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 9ebfc44af5da0..f04964ded753a 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -290,7 +290,7 @@ benchmarks! { m.step(); } - // This benchmarks the v13 migration step (Move contracts' reserved balance to be held instead). + // This benchmarks the v13 migration step (Move code owners' reserved balance to be held instead). #[pov_mode = Measured] v13_migration_step { >::with_caller( diff --git a/frame/contracts/src/migration/v13.rs b/frame/contracts/src/migration/v13.rs index 4a374faa42633..8c236e04f2db8 100644 --- a/frame/contracts/src/migration/v13.rs +++ b/frame/contracts/src/migration/v13.rs @@ -24,15 +24,25 @@ use crate::{ BalanceOf, CodeHash, Config, Determinism, HoldReason, Pallet, Weight, LOG_TARGET, }; use codec::{Decode, Encode}; +#[cfg(feature = "try-runtime")] +use environmental::Vec; +#[cfg(feature = "try-runtime")] +use frame_support::traits::fungible::Inspect; +#[cfg(feature = "try-runtime")] +use frame_support::traits::fungible::InspectHold; use frame_support::{ codec, pallet_prelude::*, storage_alias, traits::{fungible::MutateHold, ReservableCurrency}, - DefaultNoBound, Identity, + DefaultNoBound, }; use sp_core::hexdisplay::HexDisplay; -use sp_runtime::Saturating; +#[cfg(feature = "try-runtime")] +use sp_runtime::TryRuntimeError; +use sp_runtime::{traits::Zero, Saturating}; +#[cfg(feature = "try-runtime")] +use sp_std::collections::btree_map::BTreeMap; mod old { use super::*; @@ -41,39 +51,56 @@ mod old { ::AccountId, >>::Balance; - #[derive(Clone, Encode, Decode, scale_info::TypeInfo, MaxEncodedLen)] + #[derive(Encode, Decode, scale_info::TypeInfo, MaxEncodedLen)] #[codec(mel_bound())] #[scale_info(skip_type_params(T, OldCurrency))] - pub struct CodeInfo + pub struct CodeInfo where + T: Config, OldCurrency: ReservableCurrency<::AccountId>, { pub owner: AccountIdOf, #[codec(compact)] - pub deposit: BalanceOf, + pub deposit: old::BalanceOf, #[codec(compact)] refcount: u64, determinism: Determinism, - pub code_len: u32, + code_len: u32, } #[storage_alias] pub type CodeInfoOf = - StorageMap, Identity, CodeHash, CodeInfo>; + StorageMap, Twox64Concat, CodeHash, CodeInfo>; +} + +#[cfg(feature = "try-runtime")] +#[derive(Encode, Decode)] +/// Accounts for the balance allocation of a code owner. +struct BalanceAllocation +where + T: Config, + OldCurrency: ReservableCurrency<::AccountId>, +{ + /// Total reserved balance as storage deposit for the owner. + reserved: old::BalanceOf, + /// Total balance of the owner. + total: old::BalanceOf, } #[derive(Encode, Decode, MaxEncodedLen, DefaultNoBound)] -pub struct Migration +pub struct Migration where + T: Config, OldCurrency: ReservableCurrency<::AccountId>, { last_code_hash: Option>, _phantom: PhantomData<(T, OldCurrency)>, } -impl MigrationStep for Migration +impl MigrationStep for Migration where - OldCurrency: ReservableCurrency<::AccountId>, + T: Config, + OldCurrency: 'static + ReservableCurrency<::AccountId>, BalanceOf: From>, { const VERSION: u16 = 13; @@ -83,30 +110,32 @@ where } fn step(&mut self) -> (IsFinished, Weight) { - let mut iter = if let Some(last_key) = self.last_code_hash.take() { + let mut iter = if let Some(last_hash) = self.last_code_hash.take() { old::CodeInfoOf::::iter_from( - old::CodeInfoOf::::hashed_key_for(last_key), + old::CodeInfoOf::::hashed_key_for(last_hash), ) } else { old::CodeInfoOf::::iter() }; - if let Some((key, code_info)) = iter.next() { - log::debug!(target: LOG_TARGET, "Migrating storage deposit for {:?}", code_info.owner); - let len = code_info.code_len as u32; - let unreserved = OldCurrency::unreserve(&code_info.owner, code_info.deposit); + if let Some((hash, code_info)) = iter.next() { + log::debug!(target: LOG_TARGET, "Migrating storage deposit for 0x{:?}", HexDisplay::from(&code_info.owner.encode())); + + let remaining = OldCurrency::unreserve(&code_info.owner, code_info.deposit); - if code_info.deposit > unreserved { + if remaining > Zero::zero() { log::warn!( target: LOG_TARGET, "Code owner's account 0x{:?} for code {:?} has some non-unreservable deposit {:?} from a total of {:?} that will remain in reserved.", HexDisplay::from(&code_info.owner.encode()), - key, - code_info.deposit.saturating_sub(unreserved), + hash, + remaining, code_info.deposit ); } + let unreserved = code_info.deposit.saturating_sub(remaining); + T::Currency::hold( &HoldReason::StorageDepositReserve.into(), &code_info.owner, @@ -118,7 +147,7 @@ where "{:?} held on the code owner's account 0x{:?} for code {:?}.", unreserved, HexDisplay::from(&code_info.owner.encode()), - key, + hash, ); }) .unwrap_or_else(|err| { @@ -127,13 +156,13 @@ where "Failed to hold {:?} from the code owner's account 0x{:?} for code {:?}, reason: {:?}.", unreserved, HexDisplay::from(&code_info.owner.encode()), - key, + hash, err ); }); - self.last_code_hash = Some(key); - (IsFinished::No, T::WeightInfo::v9_migration_step(len)) // TODO + self.last_code_hash = Some(hash); + (IsFinished::No, T::WeightInfo::v9_migration_step(0)) // TODO } else { log::debug!(target: LOG_TARGET, "No more storage deposit to migrate"); (IsFinished::Yes, T::WeightInfo::v9_migration_step(0)) // TODO @@ -142,49 +171,76 @@ where #[cfg(feature = "try-runtime")] fn pre_upgrade_step() -> Result, TryRuntimeError> { - let sample: Vec<_> = old::CodeInfoOf::::iter().take(100).collect(); + let info: Vec<_> = old::CodeInfoOf::::iter().collect(); + + let mut owner_balance_allocation = + BTreeMap::, BalanceAllocation>::new(); + + // Calculates the balance allocation by accumulating the storage deposits of all codes owned + // by an owner. + for (_, code_info) in info { + owner_balance_allocation + .entry(code_info.owner.clone()) + .and_modify(|alloc| { + alloc.reserved = alloc.reserved.saturating_add(code_info.deposit); + }) + .or_insert(BalanceAllocation { + reserved: code_info.deposit, + total: OldCurrency::total_balance(&code_info.owner), + }); + } - log::debug!(target: LOG_TARGET, "Taking sample of {} contracts", sample.len()); - Ok(sample.encode()) + Ok(owner_balance_allocation.encode()) } #[cfg(feature = "try-runtime")] fn post_upgrade_step(state: Vec) -> Result<(), TryRuntimeError> { - let sample = , old::CodeInfoOf)> as Decode>::decode( - &mut &state[..], - ) - .expect("pre_upgrade_step provides a valid state; qed"); - - log::debug!(target: LOG_TARGET, "Validating sample of {} contracts", sample.len()); - - // Keep the sum of the storage deposits of all codes owned by an owner. - let mut owner_storage_deposits = HashMap::>::new(); - - for (_, old_code_info) in sample { - *owner_storage_deposits - .entry(old_code_info.owner) - .or_insert(BalanceOf::::zero()) += old_code_info.deposit.into(); - } + let owner_balance_allocation = + , BalanceAllocation> as Decode>::decode( + &mut &state[..], + ) + .expect("pre_upgrade_step provides a valid state; qed"); - for (&owner, &reserved) in owner_storage_deposits { + let mut total_held: BalanceOf = Zero::zero(); + let count = owner_balance_allocation.len(); + for (owner, old_balance_allocation) in owner_balance_allocation { let held = T::Currency::balance_on_hold(&HoldReason::StorageDepositReserve.into(), &owner); - ensure!( - held == reserved, - "Held amount mismatch for owner 0x{:?}: expected {:?}, got {:?}", + log::debug!( + target: LOG_TARGET, + "Validating storage deposit for owner 0x{:?}, reserved: {:?}, held: {:?}", HexDisplay::from(&owner.encode()), - reserved, + old_balance_allocation.reserved, held ); - ensure!( - OldCurrency::total_balance(owner).into() == T::Currency::balance(owner), - "Balance mismatch for owner 0x{:?}: old balance {:?}, new balance {:?}", + ensure!(held == old_balance_allocation.reserved.into(), "Held amount mismatch"); + + log::debug!( + target: LOG_TARGET, + "Validating total balance for owner 0x{:?}, new: {:?}, old: {:?}", HexDisplay::from(&owner.encode()), - OldCurrency::total_balance(owner), - T::Currency::balance(owner) + T::Currency::total_balance(&owner), + old_balance_allocation.total ); + ensure!( + T::Currency::total_balance(&owner) == old_balance_allocation.total.into(), + "Balance mismatch " + ); + total_held += held; } + log::info!( + target: LOG_TARGET, + "Code owners processed: {:?}.", + count + ); + + log::info!( + target: LOG_TARGET, + "Total held amount for storage deposit: {:?}", + total_held + ); + Ok(()) } } From ad7fa61a27a1d1d8e9ff050293938702f6fe427b Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Mon, 24 Jul 2023 17:13:26 +0200 Subject: [PATCH 072/105] benchmark v13_migration --- frame/contracts/src/benchmarking/mod.rs | 10 +-- frame/contracts/src/migration/v13.rs | 94 +++++++++++++++++-------- 2 files changed, 71 insertions(+), 33 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index f04964ded753a..2fa7a85bee2d7 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -293,10 +293,12 @@ benchmarks! { // This benchmarks the v13 migration step (Move code owners' reserved balance to be held instead). #[pov_mode = Measured] v13_migration_step { - >::with_caller( - whitelisted_caller(), WasmModule::dummy(), vec![], - )?; - let mut m = v13::Migration::::default(); + v13::store_dummy_code::< + T, + pallet_balances::Pallet + >(); + + let mut m = v13::Migration::>::default(); }: { m.step(); } diff --git a/frame/contracts/src/migration/v13.rs b/frame/contracts/src/migration/v13.rs index 8c236e04f2db8..9a863d65afa57 100644 --- a/frame/contracts/src/migration/v13.rs +++ b/frame/contracts/src/migration/v13.rs @@ -63,9 +63,9 @@ mod old { #[codec(compact)] pub deposit: old::BalanceOf, #[codec(compact)] - refcount: u64, - determinism: Determinism, - code_len: u32, + pub refcount: u64, + pub determinism: Determinism, + pub code_len: u32, } #[storage_alias] @@ -73,6 +73,29 @@ mod old { StorageMap, Twox64Concat, CodeHash, CodeInfo>; } +#[cfg(feature = "runtime-benchmarks")] +pub fn store_dummy_code() +where + T: Config, + OldCurrency: ReservableCurrency<::AccountId> + 'static, +{ + use frame_benchmarking::account; + use sp_runtime::traits::Hash; + + let len = T::MaxCodeLen::get(); + let code = vec![42u8; len as usize]; + let hash = T::Hashing::hash(&code); + + let info = old::CodeInfo { + owner: account::("account", 0, 0), + deposit: u32::MAX.into(), + refcount: u64::MAX, + determinism: Determinism::Enforced, + code_len: len, + }; + old::CodeInfoOf::::insert(hash, info); +} + #[cfg(feature = "try-runtime")] #[derive(Encode, Decode)] /// Accounts for the balance allocation of a code owner. @@ -101,12 +124,11 @@ impl MigrationStep for Migration where T: Config, OldCurrency: 'static + ReservableCurrency<::AccountId>, - BalanceOf: From>, { const VERSION: u16 = 13; fn max_step_weight() -> Weight { - T::WeightInfo::v9_migration_step(T::MaxCodeLen::get()) // TODO + T::WeightInfo::v13_migration_step() } fn step(&mut self) -> (IsFinished, Weight) { @@ -136,36 +158,44 @@ where let unreserved = code_info.deposit.saturating_sub(remaining); - T::Currency::hold( - &HoldReason::StorageDepositReserve.into(), - &code_info.owner, - unreserved.into(), - ) - .map(|_| { - log::debug!( - target: LOG_TARGET, - "{:?} held on the code owner's account 0x{:?} for code {:?}.", - unreserved, - HexDisplay::from(&code_info.owner.encode()), - hash, - ); - }) - .unwrap_or_else(|err| { + let amount = if let Ok(amount) = BalanceOf::::decode(&mut &unreserved.encode()[..]) { + amount + } else { log::error!( target: LOG_TARGET, - "Failed to hold {:?} from the code owner's account 0x{:?} for code {:?}, reason: {:?}.", + "Failed to decode unreserved amount {:?} for code {:?}.", unreserved, - HexDisplay::from(&code_info.owner.encode()), - hash, - err + hash ); - }); + Zero::zero() + }; + + T::Currency::hold(&HoldReason::StorageDepositReserve.into(), &code_info.owner, amount) + .map(|_| { + log::debug!( + target: LOG_TARGET, + "{:?} held on the code owner's account 0x{:?} for code {:?}.", + unreserved, + HexDisplay::from(&code_info.owner.encode()), + hash, + ); + }) + .unwrap_or_else(|err| { + log::error!( + target: LOG_TARGET, + "Failed to hold {:?} from the code owner's account 0x{:?} for code {:?}, reason: {:?}.", + unreserved, + HexDisplay::from(&code_info.owner.encode()), + hash, + err + ); + }); self.last_code_hash = Some(hash); - (IsFinished::No, T::WeightInfo::v9_migration_step(0)) // TODO + (IsFinished::No, T::WeightInfo::v13_migration_step()) } else { log::debug!(target: LOG_TARGET, "No more storage deposit to migrate"); - (IsFinished::Yes, T::WeightInfo::v9_migration_step(0)) // TODO + (IsFinished::Yes, T::WeightInfo::v13_migration_step()) } } @@ -213,7 +243,11 @@ where old_balance_allocation.reserved, held ); - ensure!(held == old_balance_allocation.reserved.into(), "Held amount mismatch"); + ensure!( + held == BalanceOf::::decode(&mut &old_balance_allocation.reserved.encode()[..]) + .unwrap(), + "Held amount mismatch" + ); log::debug!( target: LOG_TARGET, @@ -223,7 +257,9 @@ where old_balance_allocation.total ); ensure!( - T::Currency::total_balance(&owner) == old_balance_allocation.total.into(), + T::Currency::total_balance(&owner) == + BalanceOf::::decode(&mut &old_balance_allocation.total.encode()[..]) + .unwrap(), "Balance mismatch " ); total_held += held; From 6e6fdb31698576dabd9617a041e8625f68696826 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Mon, 24 Jul 2023 17:54:47 +0200 Subject: [PATCH 073/105] fix broken compilation --- frame/contracts/src/migration/v13.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/frame/contracts/src/migration/v13.rs b/frame/contracts/src/migration/v13.rs index 9a863d65afa57..597e659d95ef6 100644 --- a/frame/contracts/src/migration/v13.rs +++ b/frame/contracts/src/migration/v13.rs @@ -81,6 +81,7 @@ where { use frame_benchmarking::account; use sp_runtime::traits::Hash; + use sp_std::vec; let len = T::MaxCodeLen::get(); let code = vec![42u8; len as usize]; From 90de832891e3f023ea4e3f2af84d419eaf84ca0d Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Mon, 24 Jul 2023 17:46:37 +0000 Subject: [PATCH 074/105] ".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime=dev --target_dir=substrate --pallet=pallet_contracts --- frame/contracts/src/weights.rs | 4976 ++++++++++++++++---------------- 1 file changed, 2490 insertions(+), 2486 deletions(-) diff --git a/frame/contracts/src/weights.rs b/frame/contracts/src/weights.rs index 58b087417dc01..1c13fe31ed66b 100644 --- a/frame/contracts/src/weights.rs +++ b/frame/contracts/src/weights.rs @@ -15,22 +15,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! Autogenerated weights for pallet_contracts +//! Autogenerated weights for `pallet_contracts` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-07-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-07-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-xerhrdyb-project-145-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 +//! HOSTNAME: `runner-ynta1nyy-project-145-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: -// target/production/substrate +// target/production/substrate-node // benchmark // pallet // --steps=50 // --repeat=20 // --extrinsic=* -// --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 // --json-file=/builds/parity/mirrors/substrate/.git/.artifacts/bench.json @@ -48,7 +47,7 @@ use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use core::marker::PhantomData; -/// Weight functions needed for pallet_contracts. +/// Weight functions needed for `pallet_contracts`. pub trait WeightInfo { fn on_process_deletion_queue_batch() -> Weight; fn on_initialize_per_trie_key(k: u32, ) -> Weight; @@ -129,220 +128,219 @@ pub trait WeightInfo { fn instr_i64const(r: u32, ) -> Weight; } -/// Weights for pallet_contracts using the Substrate node and recommended hardware. +/// Weights for `pallet_contracts` using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - /// Storage: Contracts DeletionQueueCounter (r:1 w:0) - /// Proof: Contracts DeletionQueueCounter (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: `142` // Estimated: `1627` - // Minimum execution time: 2_519_000 picoseconds. - Weight::from_parts(2_660_000, 1627) + // Minimum execution time: 2_497_000 picoseconds. + Weight::from_parts(2_614_000, 1627) .saturating_add(T::DbWeight::get().reads(1_u64)) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `k` is `[0, 1024]`. fn on_initialize_per_trie_key(k: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `451 + k * (69 ±0)` // Estimated: `441 + k * (70 ±0)` - // Minimum execution time: 13_096_000 picoseconds. - Weight::from_parts(13_395_000, 441) - // Standard Error: 1_046 - .saturating_add(Weight::from_parts(1_246_238, 0).saturating_mul(k.into())) + // Minimum execution time: 12_942_000 picoseconds. + Weight::from_parts(13_496_000, 441) + // Standard Error: 1_214 + .saturating_add(Weight::from_parts(1_249_786, 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(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())) } - /// Storage: unknown `0x4342193e496fab7ec59d615ed0dc553022fca90611ba8b7942f8bdb3b97f6580` (r:2 w:1) - /// Proof Skipped: unknown `0x4342193e496fab7ec59d615ed0dc553022fca90611ba8b7942f8bdb3b97f6580` (r:2 w:1) + /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc553022fca90611ba8b7942f8bdb3b97f6580` (r:2 w:1) + /// Proof: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc553022fca90611ba8b7942f8bdb3b97f6580` (r:2 w:1) /// The range of component `c` is `[0, 125952]`. fn v9_migration_step(c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `211 + c * (1 ±0)` // Estimated: `6149 + c * (1 ±0)` - // Minimum execution time: 8_409_000 picoseconds. - Weight::from_parts(9_006_438, 6149) + // Minimum execution time: 8_660_000 picoseconds. + Weight::from_parts(9_087_764, 6149) // Standard Error: 1 - .saturating_add(Weight::from_parts(1_345, 0).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(1_327, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) } - /// Storage: Contracts ContractInfoOf (r:2 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) + /// Storage: `Contracts::ContractInfoOf` (r:2 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) fn v10_migration_step() -> Weight { // Proof Size summary in bytes: // Measured: `510` // Estimated: `6450` - // Minimum execution time: 16_962_000 picoseconds. - Weight::from_parts(17_716_000, 6450) + // Minimum execution time: 17_158_000 picoseconds. + Weight::from_parts(18_170_000, 6450) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: Contracts DeletionQueue (r:1 w:1025) - /// Proof: Contracts DeletionQueue (max_values: None, max_size: Some(142), added: 2617, mode: Measured) - /// Storage: Contracts DeletionQueueCounter (r:0 w:1) - /// Proof: Contracts DeletionQueueCounter (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) + /// Storage: `Contracts::DeletionQueue` (r:1 w:1025) + /// Proof: `Contracts::DeletionQueue` (`max_values`: None, `max_size`: Some(142), added: 2617, mode: `Measured`) + /// Storage: `Contracts::DeletionQueueCounter` (r:0 w:1) + /// Proof: `Contracts::DeletionQueueCounter` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) /// The range of component `k` is `[0, 1024]`. fn v11_migration_step(k: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `171 + k * (1 ±0)` // Estimated: `3635 + k * (1 ±0)` - // Minimum execution time: 3_763_000 picoseconds. - Weight::from_parts(2_401_625, 3635) - // Standard Error: 2_827 - .saturating_add(Weight::from_parts(1_201_671, 0).saturating_mul(k.into())) + // Minimum execution time: 3_857_000 picoseconds. + Weight::from_parts(3_943_000, 3635) + // Standard Error: 665 + .saturating_add(Weight::from_parts(1_155_661, 0).saturating_mul(k.into())) .saturating_add(T::DbWeight::get().reads(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, 1).saturating_mul(k.into())) } - /// Storage: unknown `0x4342193e496fab7ec59d615ed0dc553053f13fd319a03c211337c76e0fe776df` (r:2 w:0) - /// Proof Skipped: unknown `0x4342193e496fab7ec59d615ed0dc553053f13fd319a03c211337c76e0fe776df` (r:2 w:0) - /// Storage: unknown `0x4342193e496fab7ec59d615ed0dc553022fca90611ba8b7942f8bdb3b97f6580` (r:1 w:1) - /// Proof Skipped: unknown `0x4342193e496fab7ec59d615ed0dc553022fca90611ba8b7942f8bdb3b97f6580` (r:1 w:1) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:0 w:1) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, mode: Measured) + /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc553053f13fd319a03c211337c76e0fe776df` (r:2 w:0) + /// Proof: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc553053f13fd319a03c211337c76e0fe776df` (r:2 w:0) + /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc553022fca90611ba8b7942f8bdb3b97f6580` (r:1 w:1) + /// Proof: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc553022fca90611ba8b7942f8bdb3b97f6580` (r:1 w:1) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:0 w:1) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// The range of component `c` is `[0, 125952]`. fn v12_migration_step(c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `325 + c * (1 ±0)` // Estimated: `6263 + c * (1 ±0)` - // Minimum execution time: 17_490_000 picoseconds. - Weight::from_parts(17_712_278, 6263) - // Standard Error: 0 - .saturating_add(Weight::from_parts(427, 0).saturating_mul(c.into())) + // Minimum execution time: 17_216_000 picoseconds. + Weight::from_parts(17_412_155, 6263) + // Standard Error: 1 + .saturating_add(Weight::from_parts(390, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) } - /// Storage: `Contracts::ContractInfoOf` (r:2 w:0) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) - /// Storage: `System::Account` (r:2 w:2) + /// Storage: `Contracts::CodeInfoOf` (r:2 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) fn v13_migration_step() -> Weight { // Proof Size summary in bytes: - // Measured: `682` - // Estimated: `6622` - // Minimum execution time: 135_000_000 picoseconds. - Weight::from_parts(135_000_000, 6622) - .saturating_add(T::DbWeight::get().reads(5_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `260` + // Estimated: `6200` + // Minimum execution time: 27_995_000 picoseconds. + Weight::from_parts(28_661_000, 6200) + .saturating_add(T::DbWeight::get().reads(3_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:1) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:1) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) fn migration_noop() -> Weight { // Proof Size summary in bytes: // Measured: `142` // Estimated: `1627` - // Minimum execution time: 3_282_000 picoseconds. - Weight::from_parts(3_536_000, 1627) + // Minimum execution time: 3_338_000 picoseconds. + Weight::from_parts(3_534_000, 1627) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:1) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: unknown `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:1) - /// Proof Skipped: unknown `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:1) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:1) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:1) + /// Proof: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:1) fn migrate() -> Weight { // Proof Size summary in bytes: // Measured: `166` // Estimated: `3631` - // Minimum execution time: 12_973_000 picoseconds. - Weight::from_parts(13_366_000, 3631) + // Minimum execution time: 12_774_000 picoseconds. + Weight::from_parts(13_255_000, 3631) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } - /// Storage: unknown `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) - /// Proof Skipped: unknown `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) + /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) + /// Proof: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) fn on_runtime_upgrade_noop() -> Weight { // Proof Size summary in bytes: // Measured: `142` // Estimated: `3607` - // Minimum execution time: 4_764_000 picoseconds. - Weight::from_parts(5_000_000, 3607) + // Minimum execution time: 4_903_000 picoseconds. + Weight::from_parts(5_102_000, 3607) .saturating_add(T::DbWeight::get().reads(1_u64)) } - /// Storage: unknown `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) - /// Proof Skipped: unknown `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) + /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) + /// Proof: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) fn on_runtime_upgrade_in_progress() -> Weight { // Proof Size summary in bytes: // Measured: `167` // Estimated: `3632` - // Minimum execution time: 6_616_000 picoseconds. - Weight::from_parts(6_935_000, 3632) + // Minimum execution time: 6_684_000 picoseconds. + Weight::from_parts(7_060_000, 3632) .saturating_add(T::DbWeight::get().reads(2_u64)) } - /// Storage: unknown `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) - /// Proof Skipped: unknown `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) - /// Storage: Contracts MigrationInProgress (r:1 w:1) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) + /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) + /// Proof: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:1) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) fn on_runtime_upgrade() -> Weight { // Proof Size summary in bytes: // Measured: `142` // Estimated: `3607` - // Minimum execution time: 6_953_000 picoseconds. - Weight::from_parts(7_440_000, 3607) + // Minimum execution time: 7_703_000 picoseconds. + Weight::from_parts(8_706_000, 3607) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `c` is `[0, 125952]`. fn call_with_code_per_byte(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `786` - // Estimated: `6735 + c * (1 ±0)` - // Minimum execution time: 302_714_000 picoseconds. - Weight::from_parts(271_320_595, 6735) - // Standard Error: 72 - .saturating_add(Weight::from_parts(38_474, 0).saturating_mul(c.into())) + // Measured: `790` + // Estimated: `6739 + c * (1 ±0)` + // Minimum execution time: 295_971_000 picoseconds. + Weight::from_parts(255_999_332, 6739) + // Standard Error: 92 + .saturating_add(Weight::from_parts(39_291, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:1) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, mode: Measured) - /// Storage: System EventTopics (r:3 w:3) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// Storage: Contracts Nonce (r:1 w:1) - /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, 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: System Account (r:2 w:2) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts PristineCode (r:0 w:1) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:1) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) + /// Storage: `System::EventTopics` (r:3 w:3) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Contracts::Nonce` (r:1 w:1) + /// Proof: `Contracts::Nonce` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, 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: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:0 w:1) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, mode: `Measured`) /// The range of component `c` is `[0, 125952]`. /// The range of component `i` is `[0, 1048576]`. /// The range of component `s` is `[0, 1048576]`. @@ -350,1568 +348,1572 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `303` // Estimated: `8745` - // Minimum execution time: 4_506_957_000 picoseconds. - Weight::from_parts(643_316_921, 8745) - // Standard Error: 278 - .saturating_add(Weight::from_parts(112_835, 0).saturating_mul(c.into())) - // Standard Error: 33 - .saturating_add(Weight::from_parts(1_830, 0).saturating_mul(i.into())) - // Standard Error: 33 - .saturating_add(Weight::from_parts(2_022, 0).saturating_mul(s.into())) - .saturating_add(T::DbWeight::get().reads(10_u64)) - .saturating_add(T::DbWeight::get().writes(9_u64)) - } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:1) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, mode: Measured) - /// Storage: Contracts Nonce (r:1 w:1) - /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, 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: System Account (r:2 w:2) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + // Minimum execution time: 4_437_080_000 picoseconds. + Weight::from_parts(686_397_680, 8745) + // Standard Error: 261 + .saturating_add(Weight::from_parts(113_664, 0).saturating_mul(c.into())) + // Standard Error: 31 + .saturating_add(Weight::from_parts(1_889, 0).saturating_mul(i.into())) + // Standard Error: 31 + .saturating_add(Weight::from_parts(1_864, 0).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(11_u64)) + .saturating_add(T::DbWeight::get().writes(10_u64)) + } + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:1) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, mode: `Measured`) + /// Storage: `Contracts::Nonce` (r:1 w:1) + /// Proof: `Contracts::Nonce` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, 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: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `i` is `[0, 1048576]`. /// The range of component `s` is `[0, 1048576]`. fn instantiate(i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `523` - // Estimated: `6513` - // Minimum execution time: 2_103_482_000 picoseconds. - Weight::from_parts(316_666_183, 6513) - // Standard Error: 7 - .saturating_add(Weight::from_parts(1_933, 0).saturating_mul(i.into())) - // Standard Error: 7 - .saturating_add(Weight::from_parts(1_803, 0).saturating_mul(s.into())) + // Measured: `527` + // Estimated: `6517` + // Minimum execution time: 2_091_373_000 picoseconds. + Weight::from_parts(292_404_977, 6517) + // Standard Error: 11 + .saturating_add(Weight::from_parts(1_928, 0).saturating_mul(i.into())) + // Standard Error: 11 + .saturating_add(Weight::from_parts(1_808, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(10_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) fn call() -> Weight { // Proof Size summary in bytes: - // Measured: `820` - // Estimated: `6760` - // Minimum execution time: 207_530_000 picoseconds. - Weight::from_parts(217_243_000, 6760) + // Measured: `824` + // Estimated: `6764` + // Minimum execution time: 205_364_000 picoseconds. + Weight::from_parts(215_990_000, 6764) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:1) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, mode: Measured) - /// Storage: System EventTopics (r:1 w:1) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// Storage: Contracts PristineCode (r:0 w:1) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:1) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) + /// Storage: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:0 w:1) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, mode: `Measured`) /// The range of component `c` is `[0, 125952]`. fn upload_code(c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `142` - // Estimated: `3607` - // Minimum execution time: 246_381_000 picoseconds. - Weight::from_parts(242_933_576, 3607) - // Standard Error: 100 - .saturating_add(Weight::from_parts(74_645, 0).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Estimated: `6082` + // Minimum execution time: 274_786_000 picoseconds. + Weight::from_parts(266_067_385, 6082) + // Standard Error: 94 + .saturating_add(Weight::from_parts(74_709, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:1) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, mode: Measured) - /// Storage: System EventTopics (r:1 w:1) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// Storage: Contracts PristineCode (r:0 w:1) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:1) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) + /// Storage: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:0 w:1) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, mode: `Measured`) fn remove_code() -> Weight { // Proof Size summary in bytes: - // Measured: `255` - // Estimated: `3720` - // Minimum execution time: 35_519_000 picoseconds. - Weight::from_parts(36_813_000, 3720) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `315` + // Estimated: `6255` + // Minimum execution time: 57_719_000 picoseconds. + Weight::from_parts(59_435_000, 6255) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:2 w:2) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, mode: Measured) - /// Storage: System EventTopics (r:3 w:3) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:2 w:2) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `System::EventTopics` (r:3 w:3) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) fn set_code() -> Weight { // Proof Size summary in bytes: - // Measured: `575` - // Estimated: `8990` - // Minimum execution time: 37_769_000 picoseconds. - Weight::from_parts(39_349_000, 8990) + // Measured: `583` + // Estimated: `8998` + // Minimum execution time: 37_684_000 picoseconds. + Weight::from_parts(39_090_000, 8998) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_caller(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `860 + r * (6 ±0)` - // Estimated: `6801 + r * (6 ±0)` - // Minimum execution time: 273_355_000 picoseconds. - Weight::from_parts(280_115_308, 6801) - // Standard Error: 662 - .saturating_add(Weight::from_parts(351_066, 0).saturating_mul(r.into())) + // Measured: `864 + r * (6 ±0)` + // Estimated: `6805 + r * (6 ±0)` + // Minimum execution time: 272_112_000 picoseconds. + Weight::from_parts(282_158_814, 6805) + // Standard Error: 781 + .saturating_add(Weight::from_parts(341_216, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1601 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1601 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_is_contract(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `918 + r * (240 ±0)` - // Estimated: `6822 + r * (2715 ±0)` - // Minimum execution time: 264_066_000 picoseconds. - Weight::from_parts(103_474_597, 6822) - // Standard Error: 7_010 - .saturating_add(Weight::from_parts(3_917_988, 0).saturating_mul(r.into())) + // Measured: `922 + r * (240 ±0)` + // Estimated: `6826 + r * (2715 ±0)` + // Minimum execution time: 268_314_000 picoseconds. + Weight::from_parts(126_904_914, 6826) + // Standard Error: 7_046 + .saturating_add(Weight::from_parts(3_892_238, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 2715).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1601 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1601 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `910 + r * (244 ±0)` - // Estimated: `6826 + r * (2719 ±0)` - // Minimum execution time: 275_726_000 picoseconds. - Weight::from_parts(111_512_451, 6826) - // Standard Error: 6_673 - .saturating_add(Weight::from_parts(4_626_511, 0).saturating_mul(r.into())) + // Measured: `914 + r * (244 ±0)` + // Estimated: `6830 + r * (2719 ±0)` + // Minimum execution time: 263_130_000 picoseconds. + Weight::from_parts(96_194_720, 6830) + // Standard Error: 10_058 + .saturating_add(Weight::from_parts(4_771_989, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 2719).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_own_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `867 + r * (6 ±0)` - // Estimated: `6809 + r * (6 ±0)` - // Minimum execution time: 274_377_000 picoseconds. - Weight::from_parts(286_299_699, 6809) - // Standard Error: 521 - .saturating_add(Weight::from_parts(419_417, 0).saturating_mul(r.into())) + // Measured: `871 + r * (6 ±0)` + // Estimated: `6813 + r * (6 ±0)` + // Minimum execution time: 271_664_000 picoseconds. + Weight::from_parts(277_275_309, 6813) + // Standard Error: 637 + .saturating_add(Weight::from_parts(436_077, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_caller_is_origin(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `857 + r * (3 ±0)` - // Estimated: `6802 + r * (3 ±0)` - // Minimum execution time: 265_297_000 picoseconds. - Weight::from_parts(283_474_927, 6802) - // Standard Error: 376 - .saturating_add(Weight::from_parts(186_214, 0).saturating_mul(r.into())) + // Measured: `861 + r * (3 ±0)` + // Estimated: `6806 + r * (3 ±0)` + // Minimum execution time: 268_589_000 picoseconds. + Weight::from_parts(281_768_995, 6806) + // Standard Error: 471 + .saturating_add(Weight::from_parts(188_536, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 3).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_caller_is_root(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `747 + r * (3 ±0)` - // Estimated: `6687 + r * (3 ±0)` - // Minimum execution time: 258_385_000 picoseconds. - Weight::from_parts(269_869_790, 6687) - // Standard Error: 334 - .saturating_add(Weight::from_parts(164_806, 0).saturating_mul(r.into())) + // Measured: `751 + r * (3 ±0)` + // Estimated: `6691 + r * (3 ±0)` + // Minimum execution time: 245_450_000 picoseconds. + Weight::from_parts(271_656_556, 6691) + // Standard Error: 384 + .saturating_add(Weight::from_parts(164_196, 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, 3).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_address(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `861 + r * (6 ±0)` - // Estimated: `6803 + r * (6 ±0)` - // Minimum execution time: 271_351_000 picoseconds. - Weight::from_parts(286_390_305, 6803) - // Standard Error: 628 - .saturating_add(Weight::from_parts(339_374, 0).saturating_mul(r.into())) + // Measured: `865 + r * (6 ±0)` + // Estimated: `6807 + r * (6 ±0)` + // Minimum execution time: 256_868_000 picoseconds. + Weight::from_parts(279_745_554, 6807) + // Standard Error: 679 + .saturating_add(Weight::from_parts(343_814, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_gas_left(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `857 + r * (6 ±0)` - // Estimated: `6798 + r * (6 ±0)` - // Minimum execution time: 273_060_000 picoseconds. - Weight::from_parts(285_959_049, 6798) - // Standard Error: 813 - .saturating_add(Weight::from_parts(544_941, 0).saturating_mul(r.into())) + // Measured: `861 + r * (6 ±0)` + // Estimated: `6802 + r * (6 ±0)` + // Minimum execution time: 270_057_000 picoseconds. + Weight::from_parts(281_336_735, 6802) + // Standard Error: 2_627 + .saturating_add(Weight::from_parts(560_174, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:2 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:2 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_balance(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1001 + r * (6 ±0)` - // Estimated: `6925 + r * (6 ±0)` - // Minimum execution time: 273_717_000 picoseconds. - Weight::from_parts(301_053_119, 6925) - // Standard Error: 3_314 - .saturating_add(Weight::from_parts(1_645_480, 0).saturating_mul(r.into())) + // Measured: `1005 + r * (6 ±0)` + // Estimated: `6929 + r * (6 ±0)` + // Minimum execution time: 268_359_000 picoseconds. + Weight::from_parts(290_915_805, 6929) + // Standard Error: 995 + .saturating_add(Weight::from_parts(1_670_565, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_value_transferred(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `871 + r * (6 ±0)` - // Estimated: `6820 + r * (6 ±0)` - // Minimum execution time: 273_480_000 picoseconds. - Weight::from_parts(284_751_212, 6820) - // Standard Error: 501 - .saturating_add(Weight::from_parts(334_063, 0).saturating_mul(r.into())) + // Measured: `875 + r * (6 ±0)` + // Estimated: `6824 + r * (6 ±0)` + // Minimum execution time: 260_771_000 picoseconds. + Weight::from_parts(288_312_316, 6824) + // Standard Error: 1_249 + .saturating_add(Weight::from_parts(334_930, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_minimum_balance(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `869 + r * (6 ±0)` - // Estimated: `6818 + r * (6 ±0)` - // Minimum execution time: 278_938_000 picoseconds. - Weight::from_parts(284_829_302, 6818) - // Standard Error: 488 - .saturating_add(Weight::from_parts(338_782, 0).saturating_mul(r.into())) + // Measured: `873 + r * (6 ±0)` + // Estimated: `6822 + r * (6 ±0)` + // Minimum execution time: 271_683_000 picoseconds. + Weight::from_parts(283_675_986, 6822) + // Standard Error: 973 + .saturating_add(Weight::from_parts(337_330, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_block_number(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `866 + r * (6 ±0)` - // Estimated: `6816 + r * (6 ±0)` - // Minimum execution time: 276_799_000 picoseconds. - Weight::from_parts(290_353_700, 6816) - // Standard Error: 675 - .saturating_add(Weight::from_parts(323_565, 0).saturating_mul(r.into())) + // Measured: `870 + r * (6 ±0)` + // Estimated: `6820 + r * (6 ±0)` + // Minimum execution time: 271_723_000 picoseconds. + Weight::from_parts(280_863_470, 6820) + // Standard Error: 1_086 + .saturating_add(Weight::from_parts(329_905, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_now(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `857 + r * (6 ±0)` - // Estimated: `6802 + r * (6 ±0)` - // Minimum execution time: 267_740_000 picoseconds. - Weight::from_parts(287_560_339, 6802) - // Standard Error: 479 - .saturating_add(Weight::from_parts(329_276, 0).saturating_mul(r.into())) + // Measured: `861 + r * (6 ±0)` + // Estimated: `6806 + r * (6 ±0)` + // Minimum execution time: 271_822_000 picoseconds. + Weight::from_parts(282_139_073, 6806) + // Standard Error: 667 + .saturating_add(Weight::from_parts(330_614, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: TransactionPayment NextFeeMultiplier (r:1 w:0) - /// Proof: TransactionPayment NextFeeMultiplier (max_values: Some(1), max_size: Some(16), added: 511, mode: Measured) - /// Storage: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `TransactionPayment::NextFeeMultiplier` (r:1 w:0) + /// Proof: `TransactionPayment::NextFeeMultiplier` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `Measured`) + /// Storage: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_weight_to_fee(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `931 + r * (14 ±0)` - // Estimated: `6864 + r * (14 ±0)` - // Minimum execution time: 275_471_000 picoseconds. - Weight::from_parts(297_332_107, 6864) - // Standard Error: 2_230 - .saturating_add(Weight::from_parts(1_484_476, 0).saturating_mul(r.into())) + // Measured: `935 + r * (14 ±0)` + // Estimated: `6868 + r * (14 ±0)` + // Minimum execution time: 278_670_000 picoseconds. + Weight::from_parts(299_683_202, 6868) + // Standard Error: 1_061 + .saturating_add(Weight::from_parts(1_388_677, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 14).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_input(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `859 + r * (6 ±0)` - // Estimated: `6803 + r * (6 ±0)` - // Minimum execution time: 255_279_000 picoseconds. - Weight::from_parts(282_649_020, 6803) - // Standard Error: 429 - .saturating_add(Weight::from_parts(290_527, 0).saturating_mul(r.into())) + // Measured: `863 + r * (6 ±0)` + // Estimated: `6807 + r * (6 ±0)` + // Minimum execution time: 255_982_000 picoseconds. + Weight::from_parts(280_566_090, 6807) + // Standard Error: 562 + .saturating_add(Weight::from_parts(293_398, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 1048576]`. fn seal_input_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `863` - // Estimated: `6803` - // Minimum execution time: 268_029_000 picoseconds. - Weight::from_parts(231_474_232, 6803) + // Measured: `867` + // Estimated: `6807` + // Minimum execution time: 277_805_000 picoseconds. + Weight::from_parts(226_812_344, 6807) // Standard Error: 23 - .saturating_add(Weight::from_parts(1_050, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_013, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1]`. fn seal_return(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `847 + r * (45 ±0)` - // Estimated: `6787 + r * (45 ±0)` - // Minimum execution time: 252_126_000 picoseconds. - Weight::from_parts(277_677_710, 6787) - // Standard Error: 770_704 - .saturating_add(Weight::from_parts(2_678_989, 0).saturating_mul(r.into())) + // Measured: `851 + r * (45 ±0)` + // Estimated: `6791 + r * (45 ±0)` + // Minimum execution time: 252_203_000 picoseconds. + Weight::from_parts(277_335_489, 6791) + // Standard Error: 893_885 + .saturating_add(Weight::from_parts(681_110, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 45).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 1048576]`. fn seal_return_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `857` - // Estimated: `6810` - // Minimum execution time: 271_967_000 picoseconds. - Weight::from_parts(282_988_484, 6810) - // Standard Error: 0 - .saturating_add(Weight::from_parts(387, 0).saturating_mul(n.into())) + // Measured: `861` + // Estimated: `6814` + // Minimum execution time: 265_214_000 picoseconds. + Weight::from_parts(279_705_994, 6814) + // Standard Error: 1 + .saturating_add(Weight::from_parts(327, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:4 w:4) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:1) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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 DeletionQueueCounter (r:1 w:1) - /// Proof: Contracts DeletionQueueCounter (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: System EventTopics (r:3 w:3) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// Storage: Contracts DeletionQueue (r:0 w:1) - /// Proof: Contracts DeletionQueue (max_values: None, max_size: Some(142), added: 2617, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:4 w:4) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:1) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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::DeletionQueueCounter` (r:1 w:1) + /// Proof: `Contracts::DeletionQueueCounter` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) + /// Storage: `System::EventTopics` (r:3 w:3) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, 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: - // Measured: `889 + r * (300 ±0)` - // Estimated: `6829 + r * (7725 ±0)` - // Minimum execution time: 257_246_000 picoseconds. - Weight::from_parts(280_196_561, 6829) - // Standard Error: 815_845 - .saturating_add(Weight::from_parts(127_831_338, 0).saturating_mul(r.into())) + // Measured: `893 + r * (300 ±0)` + // Estimated: `6833 + r * (7725 ±0)` + // Minimum execution time: 256_416_000 picoseconds. + Weight::from_parts(279_758_997, 6833) + // Standard Error: 842_665 + .saturating_add(Weight::from_parts(134_807_902, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((8_u64).saturating_mul(r.into()))) .saturating_add(Weight::from_parts(0, 7725).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) - /// Proof: RandomnessCollectiveFlip RandomMaterial (max_values: Some(1), max_size: Some(2594), added: 3089, mode: Measured) - /// Storage: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `RandomnessCollectiveFlip::RandomMaterial` (r:1 w:0) + /// Proof: `RandomnessCollectiveFlip::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `Measured`) + /// Storage: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_random(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `938 + r * (10 ±0)` - // Estimated: `6879 + r * (10 ±0)` - // Minimum execution time: 270_074_000 picoseconds. - Weight::from_parts(292_298_331, 6879) - // Standard Error: 2_123 - .saturating_add(Weight::from_parts(2_089_487, 0).saturating_mul(r.into())) + // Measured: `942 + r * (10 ±0)` + // Estimated: `6883 + r * (10 ±0)` + // Minimum execution time: 269_693_000 picoseconds. + Weight::from_parts(294_618_859, 6883) + // Standard Error: 1_519 + .saturating_add(Weight::from_parts(1_937_907, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 10).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_deposit_event(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `857 + r * (10 ±0)` - // Estimated: `6802 + r * (10 ±0)` - // Minimum execution time: 267_080_000 picoseconds. - Weight::from_parts(298_470_496, 6802) - // Standard Error: 3_004 - .saturating_add(Weight::from_parts(3_898_460, 0).saturating_mul(r.into())) + // Measured: `861 + r * (10 ±0)` + // Estimated: `6806 + r * (10 ±0)` + // Minimum execution time: 254_826_000 picoseconds. + Weight::from_parts(291_600_221, 6806) + // Standard Error: 5_448 + .saturating_add(Weight::from_parts(3_783_146, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 10).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:6 w:6) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:6 w:6) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `t` is `[0, 4]`. /// The range of component `n` is `[0, 16384]`. fn seal_deposit_event_per_topic_and_byte(t: u32, n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `876 + t * (32 ±0)` - // Estimated: `6823 + t * (2508 ±0)` - // Minimum execution time: 277_152_000 picoseconds. - Weight::from_parts(290_745_178, 6823) - // Standard Error: 88_577 - .saturating_add(Weight::from_parts(2_476_405, 0).saturating_mul(t.into())) - // Standard Error: 24 - .saturating_add(Weight::from_parts(702, 0).saturating_mul(n.into())) + // Measured: `880 + t * (32 ±0)` + // Estimated: `6827 + t * (2508 ±0)` + // Minimum execution time: 278_275_000 picoseconds. + Weight::from_parts(294_178_600, 6827) + // Standard Error: 117_436 + .saturating_add(Weight::from_parts(2_066_248, 0).saturating_mul(t.into())) + // Standard Error: 32 + .saturating_add(Weight::from_parts(523, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(t.into()))) .saturating_add(Weight::from_parts(0, 2508).saturating_mul(t.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_debug_message(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `856 + r * (7 ±0)` - // Estimated: `6800 + r * (7 ±0)` - // Minimum execution time: 168_782_000 picoseconds. - Weight::from_parts(179_694_331, 6800) - // Standard Error: 338 - .saturating_add(Weight::from_parts(246_541, 0).saturating_mul(r.into())) + // Measured: `860 + r * (7 ±0)` + // Estimated: `6804 + r * (7 ±0)` + // Minimum execution time: 166_097_000 picoseconds. + Weight::from_parts(177_410_600, 6804) + // Standard Error: 358 + .saturating_add(Weight::from_parts(243_007, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 7).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: MaxEncodedLen) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: MaxEncodedLen) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `MaxEncodedLen`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `MaxEncodedLen`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `i` is `[0, 1048576]`. fn seal_debug_message_per_byte(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `125807` - // Estimated: `131749` - // Minimum execution time: 428_673_000 picoseconds. - Weight::from_parts(398_928_494, 131749) + // Measured: `125811` + // Estimated: `131753` + // Minimum execution time: 412_545_000 picoseconds. + Weight::from_parts(383_974_601, 131753) // Standard Error: 12 - .saturating_add(Weight::from_parts(1_106, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(1_061, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 800]`. fn seal_set_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `924 + r * (292 ±0)` - // Estimated: `922 + r * (293 ±0)` - // Minimum execution time: 271_384_000 picoseconds. - Weight::from_parts(147_677_611, 922) - // Standard Error: 13_371 - .saturating_add(Weight::from_parts(7_085_478, 0).saturating_mul(r.into())) + // Measured: `928 + r * (292 ±0)` + // Estimated: `926 + r * (293 ±0)` + // Minimum execution time: 265_218_000 picoseconds. + Weight::from_parts(146_643_084, 926) + // Standard Error: 15_110 + .saturating_add(Weight::from_parts(7_184_127, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) .saturating_add(Weight::from_parts(0, 293).saturating_mul(r.into())) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 16384]`. fn seal_set_storage_per_new_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1383` - // Estimated: `1359` - // Minimum execution time: 279_587_000 picoseconds. - Weight::from_parts(335_690_918, 1359) - // Standard Error: 57 - .saturating_add(Weight::from_parts(708, 0).saturating_mul(n.into())) + // Measured: `1387` + // Estimated: `1363` + // Minimum execution time: 277_854_000 picoseconds. + Weight::from_parts(336_305_967, 1363) + // Standard Error: 58 + .saturating_add(Weight::from_parts(618, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(10_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 16384]`. fn seal_set_storage_per_old_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1246 + n * (1 ±0)` - // Estimated: `1246 + n * (1 ±0)` - // Minimum execution time: 275_572_000 picoseconds. - Weight::from_parts(300_309_544, 1246) - // Standard Error: 35 - .saturating_add(Weight::from_parts(299, 0).saturating_mul(n.into())) + // Measured: `1250 + n * (1 ±0)` + // Estimated: `1250 + n * (1 ±0)` + // Minimum execution time: 272_361_000 picoseconds. + Weight::from_parts(296_852_347, 1250) + // Standard Error: 32 + .saturating_add(Weight::from_parts(286, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 800]`. fn seal_clear_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `920 + r * (288 ±0)` - // Estimated: `924 + r * (289 ±0)` - // Minimum execution time: 271_875_000 picoseconds. - Weight::from_parts(153_680_437, 924) - // Standard Error: 13_050 - .saturating_add(Weight::from_parts(6_892_925, 0).saturating_mul(r.into())) + // Measured: `924 + r * (288 ±0)` + // Estimated: `928 + r * (289 ±0)` + // Minimum execution time: 272_862_000 picoseconds. + Weight::from_parts(177_356_718, 928) + // Standard Error: 11_611 + .saturating_add(Weight::from_parts(6_992_298, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) .saturating_add(Weight::from_parts(0, 289).saturating_mul(r.into())) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 16384]`. fn seal_clear_storage_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1242 + n * (1 ±0)` - // Estimated: `1242 + n * (1 ±0)` - // Minimum execution time: 272_682_000 picoseconds. - Weight::from_parts(301_025_128, 1242) + // Measured: `1246 + n * (1 ±0)` + // Estimated: `1246 + n * (1 ±0)` + // Minimum execution time: 271_433_000 picoseconds. + Weight::from_parts(295_605_496, 1246) + // Standard Error: 33 + .saturating_add(Weight::from_parts(253, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 800]`. fn seal_get_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `914 + r * (296 ±0)` - // Estimated: `919 + r * (297 ±0)` - // Minimum execution time: 271_796_000 picoseconds. - Weight::from_parts(183_856_480, 919) - // Standard Error: 10_064 - .saturating_add(Weight::from_parts(5_660_636, 0).saturating_mul(r.into())) + // Measured: `918 + r * (296 ±0)` + // Estimated: `923 + r * (297 ±0)` + // Minimum execution time: 269_367_000 picoseconds. + Weight::from_parts(171_586_915, 923) + // Standard Error: 12_119 + .saturating_add(Weight::from_parts(5_786_433, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 297).saturating_mul(r.into())) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 16384]`. fn seal_get_storage_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1258 + n * (1 ±0)` - // Estimated: `1258 + n * (1 ±0)` - // Minimum execution time: 273_102_000 picoseconds. - Weight::from_parts(297_455_692, 1258) + // Measured: `1262 + n * (1 ±0)` + // Estimated: `1262 + n * (1 ±0)` + // Minimum execution time: 269_226_000 picoseconds. + Weight::from_parts(296_274_209, 1262) // Standard Error: 35 - .saturating_add(Weight::from_parts(868, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(624, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 800]`. fn seal_contains_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `935 + r * (288 ±0)` - // Estimated: `936 + r * (289 ±0)` - // Minimum execution time: 271_323_000 picoseconds. - Weight::from_parts(190_080_834, 936) - // Standard Error: 9_143 - .saturating_add(Weight::from_parts(5_488_362, 0).saturating_mul(r.into())) + // Measured: `939 + r * (288 ±0)` + // Estimated: `940 + r * (289 ±0)` + // Minimum execution time: 268_457_000 picoseconds. + Weight::from_parts(182_423_487, 940) + // Standard Error: 11_806 + .saturating_add(Weight::from_parts(5_587_320, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 289).saturating_mul(r.into())) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 16384]`. fn seal_contains_storage_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1245 + n * (1 ±0)` - // Estimated: `1245 + n * (1 ±0)` - // Minimum execution time: 270_399_000 picoseconds. - Weight::from_parts(296_679_410, 1245) - // Standard Error: 34 - .saturating_add(Weight::from_parts(161, 0).saturating_mul(n.into())) + // Measured: `1249 + n * (1 ±0)` + // Estimated: `1249 + n * (1 ±0)` + // Minimum execution time: 268_850_000 picoseconds. + Weight::from_parts(297_040_414, 1249) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 800]`. fn seal_take_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `908 + r * (296 ±0)` - // Estimated: `915 + r * (297 ±0)` - // Minimum execution time: 271_645_000 picoseconds. - Weight::from_parts(147_320_521, 915) - // Standard Error: 13_502 - .saturating_add(Weight::from_parts(7_074_778, 0).saturating_mul(r.into())) + // Measured: `912 + r * (296 ±0)` + // Estimated: `919 + r * (297 ±0)` + // Minimum execution time: 270_450_000 picoseconds. + Weight::from_parts(146_102_173, 919) + // Standard Error: 18_029 + .saturating_add(Weight::from_parts(7_211_483, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) .saturating_add(Weight::from_parts(0, 297).saturating_mul(r.into())) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 16384]`. fn seal_take_storage_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1259 + n * (1 ±0)` - // Estimated: `1259 + n * (1 ±0)` - // Minimum execution time: 280_680_000 picoseconds. - Weight::from_parts(304_043_474, 1259) - // Standard Error: 29 - .saturating_add(Weight::from_parts(644, 0).saturating_mul(n.into())) + // Measured: `1263 + n * (1 ±0)` + // Estimated: `1263 + n * (1 ±0)` + // Minimum execution time: 276_137_000 picoseconds. + Weight::from_parts(297_746_629, 1263) + // Standard Error: 34 + .saturating_add(Weight::from_parts(1_069, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1602 w:1601) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1602 w:1601) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_transfer(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1452 + r * (45 ±0)` - // Estimated: `7349 + r * (2520 ±0)` - // Minimum execution time: 274_928_000 picoseconds. - Weight::from_parts(192_111_339, 7349) - // Standard Error: 42_436 - .saturating_add(Weight::from_parts(40_323_660, 0).saturating_mul(r.into())) + // Measured: `1456 + r * (45 ±0)` + // Estimated: `7353 + r * (2520 ±0)` + // Minimum execution time: 270_088_000 picoseconds. + Weight::from_parts(265_367_984, 7353) + // Standard Error: 21_456 + .saturating_add(Weight::from_parts(41_278_150, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) .saturating_add(Weight::from_parts(0, 2520).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:801 w:801) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:2 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:2 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:803 w:803) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:801 w:801) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:2 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:2 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:803 w:803) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 800]`. fn seal_call(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1296 + r * (276 ±0)` - // Estimated: `9481 + r * (2752 ±0)` - // Minimum execution time: 275_293_000 picoseconds. - Weight::from_parts(278_243_000, 9481) - // Standard Error: 119_869 - .saturating_add(Weight::from_parts(245_114_905, 0).saturating_mul(r.into())) + // Measured: `1305 + r * (276 ±0)` + // Estimated: `9484 + r * (2752 ±0)` + // Minimum execution time: 265_246_000 picoseconds. + Weight::from_parts(280_488_000, 9484) + // Standard Error: 108_640 + .saturating_add(Weight::from_parts(243_995_043, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(11_u64)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(r.into()))) .saturating_add(Weight::from_parts(0, 2752).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:736 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:736 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:737 w:737) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:736 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:736 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:737 w:737) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 800]`. fn seal_delegate_call(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + r * (572 ±0)` - // Estimated: `6806 + r * (2633 ±3)` - // Minimum execution time: 271_857_000 picoseconds. - Weight::from_parts(278_276_000, 6806) - // Standard Error: 152_056 - .saturating_add(Weight::from_parts(243_744_830, 0).saturating_mul(r.into())) + // Measured: `0 + r * (576 ±0)` + // Estimated: `6810 + r * (2637 ±3)` + // Minimum execution time: 254_632_000 picoseconds. + Weight::from_parts(271_610_000, 6810) + // Standard Error: 141_373 + .saturating_add(Weight::from_parts(243_236_279, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 2633).saturating_mul(r.into())) - } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:3 w:2) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:2 w:2) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:2 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:2 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:4 w:4) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + .saturating_add(Weight::from_parts(0, 2637).saturating_mul(r.into())) + } + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:3 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:2 w:2) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:2 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:2 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:4 w:4) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `t` is `[0, 1]`. /// The range of component `c` is `[0, 1048576]`. fn seal_call_per_transfer_clone_byte(t: u32, c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1328 + t * (310 ±0)` - // Estimated: `12218 + t * (5260 ±0)` - // Minimum execution time: 463_865_000 picoseconds. - Weight::from_parts(70_396_050, 12218) - // Standard Error: 11_489_598 - .saturating_add(Weight::from_parts(359_195_747, 0).saturating_mul(t.into())) - // Standard Error: 16 - .saturating_add(Weight::from_parts(1_090, 0).saturating_mul(c.into())) + // Measured: `1336 + t * (310 ±0)` + // Estimated: `12226 + t * (5260 ±0)` + // Minimum execution time: 468_675_000 picoseconds. + Weight::from_parts(33_677_392, 12226) + // Standard Error: 11_951_296 + .saturating_add(Weight::from_parts(386_644_559, 0).saturating_mul(t.into())) + // Standard Error: 17 + .saturating_add(Weight::from_parts(1_080, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(13_u64)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(t.into()))) .saturating_add(T::DbWeight::get().writes(6_u64)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(t.into()))) .saturating_add(Weight::from_parts(0, 5260).saturating_mul(t.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1602 w:1602) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:801 w:801) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:801 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:801 w:800) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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 Nonce (r:1 w:1) - /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: System EventTopics (r:802 w:802) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1602 w:1602) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:801 w:801) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:801 w:800) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:801 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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::Nonce` (r:1 w:1) + /// Proof: `Contracts::Nonce` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) + /// Storage: `System::EventTopics` (r:802 w:802) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[1, 800]`. fn seal_instantiate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1383 + r * (251 ±0)` - // Estimated: `7207 + r * (5202 ±0)` - // Minimum execution time: 660_947_000 picoseconds. - Weight::from_parts(668_346_000, 7207) - // Standard Error: 357_950 - .saturating_add(Weight::from_parts(397_202_020, 0).saturating_mul(r.into())) + // Measured: `1401 + r * (255 ±0)` + // Estimated: `7234 + r * (5206 ±0)` + // Minimum execution time: 671_411_000 picoseconds. + Weight::from_parts(682_502_000, 7234) + // Standard Error: 358_458 + .saturating_add(Weight::from_parts(403_141_393, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(10_u64)) .saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(6_u64)) .saturating_add(T::DbWeight::get().writes((5_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 5202).saturating_mul(r.into())) - } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:4 w:4) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:2 w:2) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:2 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:2 w:1) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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 Nonce (r:1 w:1) - /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: System EventTopics (r:3 w:3) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + .saturating_add(Weight::from_parts(0, 5206).saturating_mul(r.into())) + } + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:4 w:4) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:2 w:2) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:2 w:1) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:2 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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::Nonce` (r:1 w:1) + /// Proof: `Contracts::Nonce` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) + /// Storage: `System::EventTopics` (r:3 w:3) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `t` is `[0, 1]`. /// The range of component `i` is `[0, 983040]`. /// The range of component `s` is `[0, 983040]`. fn seal_instantiate_per_transfer_input_salt_byte(t: u32, i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1232 + t * (156 ±0)` - // Estimated: `9662 + t * (2578 ±2)` - // Minimum execution time: 2_419_720_000 picoseconds. - Weight::from_parts(1_328_224_119, 9662) - // Standard Error: 17 - .saturating_add(Weight::from_parts(1_171, 0).saturating_mul(i.into())) - // Standard Error: 17 - .saturating_add(Weight::from_parts(1_263, 0).saturating_mul(s.into())) + // Measured: `1242 + t * (156 ±0)` + // Estimated: `9672 + t * (2578 ±2)` + // Minimum execution time: 2_396_346_000 picoseconds. + Weight::from_parts(1_391_208_964, 9672) + // Standard Error: 19 + .saturating_add(Weight::from_parts(1_110, 0).saturating_mul(i.into())) + // Standard Error: 19 + .saturating_add(Weight::from_parts(1_206, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(15_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(T::DbWeight::get().writes(10_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(t.into()))) .saturating_add(Weight::from_parts(0, 2578).saturating_mul(t.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_hash_sha2_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `856 + r * (8 ±0)` - // Estimated: `6797 + r * (8 ±0)` - // Minimum execution time: 263_620_000 picoseconds. - Weight::from_parts(285_686_431, 6797) - // Standard Error: 605 - .saturating_add(Weight::from_parts(393_863, 0).saturating_mul(r.into())) + // Measured: `860 + r * (8 ±0)` + // Estimated: `6801 + r * (8 ±0)` + // Minimum execution time: 258_627_000 picoseconds. + Weight::from_parts(279_826_907, 6801) + // Standard Error: 634 + .saturating_add(Weight::from_parts(402_011, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 8).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 1048576]`. fn seal_hash_sha2_256_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `864` - // Estimated: `6804` - // Minimum execution time: 271_378_000 picoseconds. - Weight::from_parts(266_737_832, 6804) + // Measured: `868` + // Estimated: `6808` + // Minimum execution time: 270_980_000 picoseconds. + Weight::from_parts(269_821_038, 6808) // Standard Error: 1 - .saturating_add(Weight::from_parts(1_124, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_093, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_hash_keccak_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `858 + r * (8 ±0)` - // Estimated: `6800 + r * (8 ±0)` - // Minimum execution time: 269_277_000 picoseconds. - Weight::from_parts(282_723_951, 6800) - // Standard Error: 577 - .saturating_add(Weight::from_parts(808_522, 0).saturating_mul(r.into())) + // Measured: `862 + r * (8 ±0)` + // Estimated: `6804 + r * (8 ±0)` + // Minimum execution time: 265_045_000 picoseconds. + Weight::from_parts(276_465_886, 6804) + // Standard Error: 717 + .saturating_add(Weight::from_parts(799_550, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 8).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 1048576]`. fn seal_hash_keccak_256_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `866` - // Estimated: `6808` - // Minimum execution time: 254_252_000 picoseconds. - Weight::from_parts(277_589_498, 6808) - // Standard Error: 1 - .saturating_add(Weight::from_parts(3_394, 0).saturating_mul(n.into())) + // Measured: `870` + // Estimated: `6812` + // Minimum execution time: 267_818_000 picoseconds. + Weight::from_parts(274_565_508, 6812) + // Standard Error: 2 + .saturating_add(Weight::from_parts(3_399, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_hash_blake2_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `858 + r * (8 ±0)` - // Estimated: `6803 + r * (8 ±0)` - // Minimum execution time: 254_411_000 picoseconds. - Weight::from_parts(283_572_987, 6803) - // Standard Error: 549 - .saturating_add(Weight::from_parts(455_436, 0).saturating_mul(r.into())) + // Measured: `862 + r * (8 ±0)` + // Estimated: `6807 + r * (8 ±0)` + // Minimum execution time: 268_071_000 picoseconds. + Weight::from_parts(280_629_875, 6807) + // Standard Error: 603 + .saturating_add(Weight::from_parts(461_392, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 8).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 1048576]`. fn seal_hash_blake2_256_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `866` - // Estimated: `6812` - // Minimum execution time: 264_371_000 picoseconds. - Weight::from_parts(269_330_603, 6812) - // Standard Error: 0 - .saturating_add(Weight::from_parts(1_249, 0).saturating_mul(n.into())) + // Measured: `870` + // Estimated: `6816` + // Minimum execution time: 255_606_000 picoseconds. + Weight::from_parts(264_796_539, 6816) + // Standard Error: 1 + .saturating_add(Weight::from_parts(1_232, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_hash_blake2_128(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `858 + r * (8 ±0)` - // Estimated: `6804 + r * (8 ±0)` - // Minimum execution time: 257_896_000 picoseconds. - Weight::from_parts(286_738_151, 6804) - // Standard Error: 680 - .saturating_add(Weight::from_parts(459_525, 0).saturating_mul(r.into())) + // Measured: `862 + r * (8 ±0)` + // Estimated: `6808 + r * (8 ±0)` + // Minimum execution time: 269_830_000 picoseconds. + Weight::from_parts(285_437_600, 6808) + // Standard Error: 553 + .saturating_add(Weight::from_parts(449_486, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 8).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 1048576]`. fn seal_hash_blake2_128_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `866` - // Estimated: `6806` - // Minimum execution time: 272_952_000 picoseconds. - Weight::from_parts(271_516_361, 6806) - // Standard Error: 0 - .saturating_add(Weight::from_parts(1_242, 0).saturating_mul(n.into())) + // Measured: `870` + // Estimated: `6810` + // Minimum execution time: 269_208_000 picoseconds. + Weight::from_parts(261_433_983, 6810) + // Standard Error: 2 + .saturating_add(Weight::from_parts(1_230, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 125697]`. fn seal_sr25519_verify_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `991 + n * (1 ±0)` - // Estimated: `6928 + n * (1 ±0)` - // Minimum execution time: 351_363_000 picoseconds. - Weight::from_parts(356_558_856, 6928) - // Standard Error: 10 - .saturating_add(Weight::from_parts(6_085, 0).saturating_mul(n.into())) + // Measured: `995 + n * (1 ±0)` + // Estimated: `6932 + n * (1 ±0)` + // Minimum execution time: 345_453_000 picoseconds. + Weight::from_parts(363_052_686, 6932) + // Standard Error: 14 + .saturating_add(Weight::from_parts(5_932, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 160]`. fn seal_sr25519_verify(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `801 + r * (112 ±0)` - // Estimated: `6745 + r * (112 ±0)` - // Minimum execution time: 261_688_000 picoseconds. - Weight::from_parts(338_043_015, 6745) - // Standard Error: 13_532 - .saturating_add(Weight::from_parts(56_420_806, 0).saturating_mul(r.into())) + // Measured: `805 + r * (112 ±0)` + // Estimated: `6749 + r * (112 ±0)` + // Minimum execution time: 276_439_000 picoseconds. + Weight::from_parts(340_524_474, 6749) + // Standard Error: 14_776 + .saturating_add(Weight::from_parts(56_195_198, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 112).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 160]`. fn seal_ecdsa_recover(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `901 + r * (76 ±0)` - // Estimated: `6795 + r * (77 ±0)` - // Minimum execution time: 267_401_000 picoseconds. - Weight::from_parts(345_773_771, 6795) - // Standard Error: 14_486 - .saturating_add(Weight::from_parts(46_180_739, 0).saturating_mul(r.into())) + // Measured: `904 + r * (76 ±0)` + // Estimated: `6799 + r * (77 ±0)` + // Minimum execution time: 265_177_000 picoseconds. + Weight::from_parts(354_962_424, 6799) + // Standard Error: 19_335 + .saturating_add(Weight::from_parts(46_185_645, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 77).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 160]`. fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `871 + r * (42 ±0)` - // Estimated: `6810 + r * (42 ±0)` - // Minimum execution time: 277_890_000 picoseconds. - Weight::from_parts(319_211_194, 6810) - // Standard Error: 9_132 - .saturating_add(Weight::from_parts(12_128_696, 0).saturating_mul(r.into())) + // Measured: `875 + r * (42 ±0)` + // Estimated: `6815 + r * (42 ±0)` + // Minimum execution time: 269_843_000 picoseconds. + Weight::from_parts(320_179_949, 6815) + // Standard Error: 11_229 + .saturating_add(Weight::from_parts(12_025_678, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 42).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1536 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1536 w:1536) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:1538 w:1538) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1536 w:1536) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1536 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:1538 w:1538) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_set_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + r * (961 ±0)` - // Estimated: `6801 + r * (3087 ±10)` - // Minimum execution time: 259_692_000 picoseconds. - Weight::from_parts(278_327_000, 6801) - // Standard Error: 60_024 - .saturating_add(Weight::from_parts(25_758_805, 0).saturating_mul(r.into())) + // Measured: `0 + r * (965 ±0)` + // Estimated: `6805 + r * (3090 ±10)` + // Minimum execution time: 278_081_000 picoseconds. + Weight::from_parts(280_430_000, 6805) + // Standard Error: 66_737 + .saturating_add(Weight::from_parts(26_863_662, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 3087).saturating_mul(r.into())) - } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + .saturating_add(Weight::from_parts(0, 3090).saturating_mul(r.into())) + } + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_reentrance_count(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `852 + r * (3 ±0)` - // Estimated: `6802 + r * (3 ±0)` - // Minimum execution time: 258_907_000 picoseconds. - Weight::from_parts(285_755_890, 6802) - // Standard Error: 378 - .saturating_add(Weight::from_parts(179_649, 0).saturating_mul(r.into())) + // Measured: `856 + r * (3 ±0)` + // Estimated: `6806 + r * (3 ±0)` + // Minimum execution time: 266_348_000 picoseconds. + Weight::from_parts(288_045_413, 6806) + // Standard Error: 438 + .saturating_add(Weight::from_parts(181_089, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 3).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_account_reentrance_count(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2092 + r * (39 ±0)` - // Estimated: `7919 + r * (40 ±0)` - // Minimum execution time: 260_415_000 picoseconds. - Weight::from_parts(363_871_048, 7919) - // Standard Error: 2_010 - .saturating_add(Weight::from_parts(317_607, 0).saturating_mul(r.into())) + // Measured: `2096 + r * (39 ±0)` + // Estimated: `7916 + r * (40 ±0)` + // Minimum execution time: 275_791_000 picoseconds. + Weight::from_parts(373_949_987, 7916) + // Standard Error: 2_280 + .saturating_add(Weight::from_parts(319_620, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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 Nonce (r:1 w:1) - /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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::Nonce` (r:1 w:1) + /// Proof: `Contracts::Nonce` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) + /// Storage: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_instantiation_nonce(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `855 + r * (3 ±0)` - // Estimated: `6802 + r * (3 ±0)` - // Minimum execution time: 257_725_000 picoseconds. - Weight::from_parts(283_441_372, 6802) - // Standard Error: 371 - .saturating_add(Weight::from_parts(157_674, 0).saturating_mul(r.into())) + // Measured: `859 + r * (3 ±0)` + // Estimated: `6806 + r * (3 ±0)` + // Minimum execution time: 259_378_000 picoseconds. + Weight::from_parts(281_549_294, 6806) + // Standard Error: 491 + .saturating_add(Weight::from_parts(163_939, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 3).saturating_mul(r.into())) @@ -1921,227 +1923,225 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_635_000 picoseconds. - Weight::from_parts(2_990_110, 0) - // Standard Error: 31 - .saturating_add(Weight::from_parts(10_213, 0).saturating_mul(r.into())) + // Minimum execution time: 1_473_000 picoseconds. + Weight::from_parts(2_027_513, 0) + // Standard Error: 16 + .saturating_add(Weight::from_parts(10_451, 0).saturating_mul(r.into())) } } -// For backwards compatibility and tests +// For backwards compatibility and tests. impl WeightInfo for () { - /// Storage: Contracts DeletionQueueCounter (r:1 w:0) - /// Proof: Contracts DeletionQueueCounter (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: `142` // Estimated: `1627` - // Minimum execution time: 2_519_000 picoseconds. - Weight::from_parts(2_660_000, 1627) + // Minimum execution time: 2_497_000 picoseconds. + Weight::from_parts(2_614_000, 1627) .saturating_add(RocksDbWeight::get().reads(1_u64)) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `k` is `[0, 1024]`. fn on_initialize_per_trie_key(k: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `451 + k * (69 ±0)` // Estimated: `441 + k * (70 ±0)` - // Minimum execution time: 13_096_000 picoseconds. - Weight::from_parts(13_395_000, 441) - // Standard Error: 1_046 - .saturating_add(Weight::from_parts(1_246_238, 0).saturating_mul(k.into())) + // Minimum execution time: 12_942_000 picoseconds. + Weight::from_parts(13_496_000, 441) + // Standard Error: 1_214 + .saturating_add(Weight::from_parts(1_249_786, 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(2_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(k.into()))) .saturating_add(Weight::from_parts(0, 70).saturating_mul(k.into())) } - /// Storage: unknown `0x4342193e496fab7ec59d615ed0dc553022fca90611ba8b7942f8bdb3b97f6580` (r:2 w:1) - /// Proof Skipped: unknown `0x4342193e496fab7ec59d615ed0dc553022fca90611ba8b7942f8bdb3b97f6580` (r:2 w:1) + /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc553022fca90611ba8b7942f8bdb3b97f6580` (r:2 w:1) + /// Proof: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc553022fca90611ba8b7942f8bdb3b97f6580` (r:2 w:1) /// The range of component `c` is `[0, 125952]`. fn v9_migration_step(c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `211 + c * (1 ±0)` // Estimated: `6149 + c * (1 ±0)` - // Minimum execution time: 8_409_000 picoseconds. - Weight::from_parts(9_006_438, 6149) + // Minimum execution time: 8_660_000 picoseconds. + Weight::from_parts(9_087_764, 6149) // Standard Error: 1 - .saturating_add(Weight::from_parts(1_345, 0).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(1_327, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) } - /// Storage: Contracts ContractInfoOf (r:2 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) + /// Storage: `Contracts::ContractInfoOf` (r:2 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) fn v10_migration_step() -> Weight { // Proof Size summary in bytes: // Measured: `510` // Estimated: `6450` - // Minimum execution time: 16_962_000 picoseconds. - Weight::from_parts(17_716_000, 6450) + // Minimum execution time: 17_158_000 picoseconds. + Weight::from_parts(18_170_000, 6450) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: Contracts DeletionQueue (r:1 w:1025) - /// Proof: Contracts DeletionQueue (max_values: None, max_size: Some(142), added: 2617, mode: Measured) - /// Storage: Contracts DeletionQueueCounter (r:0 w:1) - /// Proof: Contracts DeletionQueueCounter (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) + /// Storage: `Contracts::DeletionQueue` (r:1 w:1025) + /// Proof: `Contracts::DeletionQueue` (`max_values`: None, `max_size`: Some(142), added: 2617, mode: `Measured`) + /// Storage: `Contracts::DeletionQueueCounter` (r:0 w:1) + /// Proof: `Contracts::DeletionQueueCounter` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) /// The range of component `k` is `[0, 1024]`. fn v11_migration_step(k: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `171 + k * (1 ±0)` // Estimated: `3635 + k * (1 ±0)` - // Minimum execution time: 3_763_000 picoseconds. - Weight::from_parts(2_401_625, 3635) - // Standard Error: 2_827 - .saturating_add(Weight::from_parts(1_201_671, 0).saturating_mul(k.into())) + // Minimum execution time: 3_857_000 picoseconds. + Weight::from_parts(3_943_000, 3635) + // Standard Error: 665 + .saturating_add(Weight::from_parts(1_155_661, 0).saturating_mul(k.into())) .saturating_add(RocksDbWeight::get().reads(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, 1).saturating_mul(k.into())) } - /// Storage: unknown `0x4342193e496fab7ec59d615ed0dc553053f13fd319a03c211337c76e0fe776df` (r:2 w:0) - /// Proof Skipped: unknown `0x4342193e496fab7ec59d615ed0dc553053f13fd319a03c211337c76e0fe776df` (r:2 w:0) - /// Storage: unknown `0x4342193e496fab7ec59d615ed0dc553022fca90611ba8b7942f8bdb3b97f6580` (r:1 w:1) - /// Proof Skipped: unknown `0x4342193e496fab7ec59d615ed0dc553022fca90611ba8b7942f8bdb3b97f6580` (r:1 w:1) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:0 w:1) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, mode: Measured) + /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc553053f13fd319a03c211337c76e0fe776df` (r:2 w:0) + /// Proof: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc553053f13fd319a03c211337c76e0fe776df` (r:2 w:0) + /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc553022fca90611ba8b7942f8bdb3b97f6580` (r:1 w:1) + /// Proof: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc553022fca90611ba8b7942f8bdb3b97f6580` (r:1 w:1) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:0 w:1) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// The range of component `c` is `[0, 125952]`. fn v12_migration_step(c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `325 + c * (1 ±0)` // Estimated: `6263 + c * (1 ±0)` - // Minimum execution time: 17_490_000 picoseconds. - Weight::from_parts(17_712_278, 6263) - // Standard Error: 0 - .saturating_add(Weight::from_parts(427, 0).saturating_mul(c.into())) + // Minimum execution time: 17_216_000 picoseconds. + Weight::from_parts(17_412_155, 6263) + // Standard Error: 1 + .saturating_add(Weight::from_parts(390, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) } - - /// Storage: `Contracts::ContractInfoOf` (r:2 w:0) - /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) - /// Storage: `System::Account` (r:2 w:2) + /// Storage: `Contracts::CodeInfoOf` (r:2 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) fn v13_migration_step() -> Weight { // Proof Size summary in bytes: - // Measured: `682` - // Estimated: `6622` - // Minimum execution time: 135_000_000 picoseconds. - Weight::from_parts(135_000_000, 6622) - .saturating_add(RocksDbWeight::get().reads(5_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) + // Measured: `260` + // Estimated: `6200` + // Minimum execution time: 27_995_000 picoseconds. + Weight::from_parts(28_661_000, 6200) + .saturating_add(RocksDbWeight::get().reads(3_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:1) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:1) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) fn migration_noop() -> Weight { // Proof Size summary in bytes: // Measured: `142` // Estimated: `1627` - // Minimum execution time: 3_282_000 picoseconds. - Weight::from_parts(3_536_000, 1627) + // Minimum execution time: 3_338_000 picoseconds. + Weight::from_parts(3_534_000, 1627) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:1) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: unknown `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:1) - /// Proof Skipped: unknown `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:1) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:1) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:1) + /// Proof: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:1) fn migrate() -> Weight { // Proof Size summary in bytes: // Measured: `166` // Estimated: `3631` - // Minimum execution time: 12_973_000 picoseconds. - Weight::from_parts(13_366_000, 3631) + // Minimum execution time: 12_774_000 picoseconds. + Weight::from_parts(13_255_000, 3631) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } - /// Storage: unknown `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) - /// Proof Skipped: unknown `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) + /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) + /// Proof: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) fn on_runtime_upgrade_noop() -> Weight { // Proof Size summary in bytes: // Measured: `142` // Estimated: `3607` - // Minimum execution time: 4_764_000 picoseconds. - Weight::from_parts(5_000_000, 3607) + // Minimum execution time: 4_903_000 picoseconds. + Weight::from_parts(5_102_000, 3607) .saturating_add(RocksDbWeight::get().reads(1_u64)) } - /// Storage: unknown `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) - /// Proof Skipped: unknown `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) + /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) + /// Proof: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) fn on_runtime_upgrade_in_progress() -> Weight { // Proof Size summary in bytes: // Measured: `167` // Estimated: `3632` - // Minimum execution time: 6_616_000 picoseconds. - Weight::from_parts(6_935_000, 3632) + // Minimum execution time: 6_684_000 picoseconds. + Weight::from_parts(7_060_000, 3632) .saturating_add(RocksDbWeight::get().reads(2_u64)) } - /// Storage: unknown `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) - /// Proof Skipped: unknown `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) - /// Storage: Contracts MigrationInProgress (r:1 w:1) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) + /// Storage: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) + /// Proof: UNKNOWN KEY `0x4342193e496fab7ec59d615ed0dc55304e7b9012096b41c4eb3aaf947f6ea429` (r:1 w:0) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:1) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) fn on_runtime_upgrade() -> Weight { // Proof Size summary in bytes: // Measured: `142` // Estimated: `3607` - // Minimum execution time: 6_953_000 picoseconds. - Weight::from_parts(7_440_000, 3607) + // Minimum execution time: 7_703_000 picoseconds. + Weight::from_parts(8_706_000, 3607) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `c` is `[0, 125952]`. fn call_with_code_per_byte(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `786` - // Estimated: `6735 + c * (1 ±0)` - // Minimum execution time: 302_714_000 picoseconds. - Weight::from_parts(271_320_595, 6735) - // Standard Error: 72 - .saturating_add(Weight::from_parts(38_474, 0).saturating_mul(c.into())) + // Measured: `790` + // Estimated: `6739 + c * (1 ±0)` + // Minimum execution time: 295_971_000 picoseconds. + Weight::from_parts(255_999_332, 6739) + // Standard Error: 92 + .saturating_add(Weight::from_parts(39_291, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(c.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:1) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, mode: Measured) - /// Storage: System EventTopics (r:3 w:3) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// Storage: Contracts Nonce (r:1 w:1) - /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, 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: System Account (r:2 w:2) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts PristineCode (r:0 w:1) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:1) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) + /// Storage: `System::EventTopics` (r:3 w:3) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Contracts::Nonce` (r:1 w:1) + /// Proof: `Contracts::Nonce` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, 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: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:0 w:1) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, mode: `Measured`) /// The range of component `c` is `[0, 125952]`. /// The range of component `i` is `[0, 1048576]`. /// The range of component `s` is `[0, 1048576]`. @@ -2149,1568 +2149,1572 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `303` // Estimated: `8745` - // Minimum execution time: 4_506_957_000 picoseconds. - Weight::from_parts(643_316_921, 8745) - // Standard Error: 278 - .saturating_add(Weight::from_parts(112_835, 0).saturating_mul(c.into())) - // Standard Error: 33 - .saturating_add(Weight::from_parts(1_830, 0).saturating_mul(i.into())) - // Standard Error: 33 - .saturating_add(Weight::from_parts(2_022, 0).saturating_mul(s.into())) - .saturating_add(RocksDbWeight::get().reads(10_u64)) - .saturating_add(RocksDbWeight::get().writes(9_u64)) - } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:1) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, mode: Measured) - /// Storage: Contracts Nonce (r:1 w:1) - /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, 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: System Account (r:2 w:2) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + // Minimum execution time: 4_437_080_000 picoseconds. + Weight::from_parts(686_397_680, 8745) + // Standard Error: 261 + .saturating_add(Weight::from_parts(113_664, 0).saturating_mul(c.into())) + // Standard Error: 31 + .saturating_add(Weight::from_parts(1_889, 0).saturating_mul(i.into())) + // Standard Error: 31 + .saturating_add(Weight::from_parts(1_864, 0).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(11_u64)) + .saturating_add(RocksDbWeight::get().writes(10_u64)) + } + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:1) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, mode: `Measured`) + /// Storage: `Contracts::Nonce` (r:1 w:1) + /// Proof: `Contracts::Nonce` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, 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: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `i` is `[0, 1048576]`. /// The range of component `s` is `[0, 1048576]`. fn instantiate(i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `523` - // Estimated: `6513` - // Minimum execution time: 2_103_482_000 picoseconds. - Weight::from_parts(316_666_183, 6513) - // Standard Error: 7 - .saturating_add(Weight::from_parts(1_933, 0).saturating_mul(i.into())) - // Standard Error: 7 - .saturating_add(Weight::from_parts(1_803, 0).saturating_mul(s.into())) + // Measured: `527` + // Estimated: `6517` + // Minimum execution time: 2_091_373_000 picoseconds. + Weight::from_parts(292_404_977, 6517) + // Standard Error: 11 + .saturating_add(Weight::from_parts(1_928, 0).saturating_mul(i.into())) + // Standard Error: 11 + .saturating_add(Weight::from_parts(1_808, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(10_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) fn call() -> Weight { // Proof Size summary in bytes: - // Measured: `820` - // Estimated: `6760` - // Minimum execution time: 207_530_000 picoseconds. - Weight::from_parts(217_243_000, 6760) + // Measured: `824` + // Estimated: `6764` + // Minimum execution time: 205_364_000 picoseconds. + Weight::from_parts(215_990_000, 6764) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:1) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, mode: Measured) - /// Storage: System EventTopics (r:1 w:1) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// Storage: Contracts PristineCode (r:0 w:1) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:1) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) + /// Storage: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:0 w:1) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, mode: `Measured`) /// The range of component `c` is `[0, 125952]`. fn upload_code(c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `142` - // Estimated: `3607` - // Minimum execution time: 246_381_000 picoseconds. - Weight::from_parts(242_933_576, 3607) - // Standard Error: 100 - .saturating_add(Weight::from_parts(74_645, 0).saturating_mul(c.into())) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) + // Estimated: `6082` + // Minimum execution time: 274_786_000 picoseconds. + Weight::from_parts(266_067_385, 6082) + // Standard Error: 94 + .saturating_add(Weight::from_parts(74_709, 0).saturating_mul(c.into())) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:1) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, mode: Measured) - /// Storage: System EventTopics (r:1 w:1) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// Storage: Contracts PristineCode (r:0 w:1) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:1) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `Measured`) + /// Storage: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:0 w:1) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, mode: `Measured`) fn remove_code() -> Weight { // Proof Size summary in bytes: - // Measured: `255` - // Estimated: `3720` - // Minimum execution time: 35_519_000 picoseconds. - Weight::from_parts(36_813_000, 3720) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) + // Measured: `315` + // Estimated: `6255` + // Minimum execution time: 57_719_000 picoseconds. + Weight::from_parts(59_435_000, 6255) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:2 w:2) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, mode: Measured) - /// Storage: System EventTopics (r:3 w:3) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:2 w:2) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `System::EventTopics` (r:3 w:3) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) fn set_code() -> Weight { // Proof Size summary in bytes: - // Measured: `575` - // Estimated: `8990` - // Minimum execution time: 37_769_000 picoseconds. - Weight::from_parts(39_349_000, 8990) + // Measured: `583` + // Estimated: `8998` + // Minimum execution time: 37_684_000 picoseconds. + Weight::from_parts(39_090_000, 8998) .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_caller(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `860 + r * (6 ±0)` - // Estimated: `6801 + r * (6 ±0)` - // Minimum execution time: 273_355_000 picoseconds. - Weight::from_parts(280_115_308, 6801) - // Standard Error: 662 - .saturating_add(Weight::from_parts(351_066, 0).saturating_mul(r.into())) + // Measured: `864 + r * (6 ±0)` + // Estimated: `6805 + r * (6 ±0)` + // Minimum execution time: 272_112_000 picoseconds. + Weight::from_parts(282_158_814, 6805) + // Standard Error: 781 + .saturating_add(Weight::from_parts(341_216, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1601 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1601 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_is_contract(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `918 + r * (240 ±0)` - // Estimated: `6822 + r * (2715 ±0)` - // Minimum execution time: 264_066_000 picoseconds. - Weight::from_parts(103_474_597, 6822) - // Standard Error: 7_010 - .saturating_add(Weight::from_parts(3_917_988, 0).saturating_mul(r.into())) + // Measured: `922 + r * (240 ±0)` + // Estimated: `6826 + r * (2715 ±0)` + // Minimum execution time: 268_314_000 picoseconds. + Weight::from_parts(126_904_914, 6826) + // Standard Error: 7_046 + .saturating_add(Weight::from_parts(3_892_238, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 2715).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1601 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1601 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `910 + r * (244 ±0)` - // Estimated: `6826 + r * (2719 ±0)` - // Minimum execution time: 275_726_000 picoseconds. - Weight::from_parts(111_512_451, 6826) - // Standard Error: 6_673 - .saturating_add(Weight::from_parts(4_626_511, 0).saturating_mul(r.into())) + // Measured: `914 + r * (244 ±0)` + // Estimated: `6830 + r * (2719 ±0)` + // Minimum execution time: 263_130_000 picoseconds. + Weight::from_parts(96_194_720, 6830) + // Standard Error: 10_058 + .saturating_add(Weight::from_parts(4_771_989, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 2719).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_own_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `867 + r * (6 ±0)` - // Estimated: `6809 + r * (6 ±0)` - // Minimum execution time: 274_377_000 picoseconds. - Weight::from_parts(286_299_699, 6809) - // Standard Error: 521 - .saturating_add(Weight::from_parts(419_417, 0).saturating_mul(r.into())) + // Measured: `871 + r * (6 ±0)` + // Estimated: `6813 + r * (6 ±0)` + // Minimum execution time: 271_664_000 picoseconds. + Weight::from_parts(277_275_309, 6813) + // Standard Error: 637 + .saturating_add(Weight::from_parts(436_077, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_caller_is_origin(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `857 + r * (3 ±0)` - // Estimated: `6802 + r * (3 ±0)` - // Minimum execution time: 265_297_000 picoseconds. - Weight::from_parts(283_474_927, 6802) - // Standard Error: 376 - .saturating_add(Weight::from_parts(186_214, 0).saturating_mul(r.into())) + // Measured: `861 + r * (3 ±0)` + // Estimated: `6806 + r * (3 ±0)` + // Minimum execution time: 268_589_000 picoseconds. + Weight::from_parts(281_768_995, 6806) + // Standard Error: 471 + .saturating_add(Weight::from_parts(188_536, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 3).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_caller_is_root(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `747 + r * (3 ±0)` - // Estimated: `6687 + r * (3 ±0)` - // Minimum execution time: 258_385_000 picoseconds. - Weight::from_parts(269_869_790, 6687) - // Standard Error: 334 - .saturating_add(Weight::from_parts(164_806, 0).saturating_mul(r.into())) + // Measured: `751 + r * (3 ±0)` + // Estimated: `6691 + r * (3 ±0)` + // Minimum execution time: 245_450_000 picoseconds. + Weight::from_parts(271_656_556, 6691) + // Standard Error: 384 + .saturating_add(Weight::from_parts(164_196, 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, 3).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_address(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `861 + r * (6 ±0)` - // Estimated: `6803 + r * (6 ±0)` - // Minimum execution time: 271_351_000 picoseconds. - Weight::from_parts(286_390_305, 6803) - // Standard Error: 628 - .saturating_add(Weight::from_parts(339_374, 0).saturating_mul(r.into())) + // Measured: `865 + r * (6 ±0)` + // Estimated: `6807 + r * (6 ±0)` + // Minimum execution time: 256_868_000 picoseconds. + Weight::from_parts(279_745_554, 6807) + // Standard Error: 679 + .saturating_add(Weight::from_parts(343_814, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_gas_left(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `857 + r * (6 ±0)` - // Estimated: `6798 + r * (6 ±0)` - // Minimum execution time: 273_060_000 picoseconds. - Weight::from_parts(285_959_049, 6798) - // Standard Error: 813 - .saturating_add(Weight::from_parts(544_941, 0).saturating_mul(r.into())) + // Measured: `861 + r * (6 ±0)` + // Estimated: `6802 + r * (6 ±0)` + // Minimum execution time: 270_057_000 picoseconds. + Weight::from_parts(281_336_735, 6802) + // Standard Error: 2_627 + .saturating_add(Weight::from_parts(560_174, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:2 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:2 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_balance(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1001 + r * (6 ±0)` - // Estimated: `6925 + r * (6 ±0)` - // Minimum execution time: 273_717_000 picoseconds. - Weight::from_parts(301_053_119, 6925) - // Standard Error: 3_314 - .saturating_add(Weight::from_parts(1_645_480, 0).saturating_mul(r.into())) + // Measured: `1005 + r * (6 ±0)` + // Estimated: `6929 + r * (6 ±0)` + // Minimum execution time: 268_359_000 picoseconds. + Weight::from_parts(290_915_805, 6929) + // Standard Error: 995 + .saturating_add(Weight::from_parts(1_670_565, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_value_transferred(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `871 + r * (6 ±0)` - // Estimated: `6820 + r * (6 ±0)` - // Minimum execution time: 273_480_000 picoseconds. - Weight::from_parts(284_751_212, 6820) - // Standard Error: 501 - .saturating_add(Weight::from_parts(334_063, 0).saturating_mul(r.into())) + // Measured: `875 + r * (6 ±0)` + // Estimated: `6824 + r * (6 ±0)` + // Minimum execution time: 260_771_000 picoseconds. + Weight::from_parts(288_312_316, 6824) + // Standard Error: 1_249 + .saturating_add(Weight::from_parts(334_930, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_minimum_balance(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `869 + r * (6 ±0)` - // Estimated: `6818 + r * (6 ±0)` - // Minimum execution time: 278_938_000 picoseconds. - Weight::from_parts(284_829_302, 6818) - // Standard Error: 488 - .saturating_add(Weight::from_parts(338_782, 0).saturating_mul(r.into())) + // Measured: `873 + r * (6 ±0)` + // Estimated: `6822 + r * (6 ±0)` + // Minimum execution time: 271_683_000 picoseconds. + Weight::from_parts(283_675_986, 6822) + // Standard Error: 973 + .saturating_add(Weight::from_parts(337_330, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_block_number(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `866 + r * (6 ±0)` - // Estimated: `6816 + r * (6 ±0)` - // Minimum execution time: 276_799_000 picoseconds. - Weight::from_parts(290_353_700, 6816) - // Standard Error: 675 - .saturating_add(Weight::from_parts(323_565, 0).saturating_mul(r.into())) + // Measured: `870 + r * (6 ±0)` + // Estimated: `6820 + r * (6 ±0)` + // Minimum execution time: 271_723_000 picoseconds. + Weight::from_parts(280_863_470, 6820) + // Standard Error: 1_086 + .saturating_add(Weight::from_parts(329_905, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_now(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `857 + r * (6 ±0)` - // Estimated: `6802 + r * (6 ±0)` - // Minimum execution time: 267_740_000 picoseconds. - Weight::from_parts(287_560_339, 6802) - // Standard Error: 479 - .saturating_add(Weight::from_parts(329_276, 0).saturating_mul(r.into())) + // Measured: `861 + r * (6 ±0)` + // Estimated: `6806 + r * (6 ±0)` + // Minimum execution time: 271_822_000 picoseconds. + Weight::from_parts(282_139_073, 6806) + // Standard Error: 667 + .saturating_add(Weight::from_parts(330_614, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: TransactionPayment NextFeeMultiplier (r:1 w:0) - /// Proof: TransactionPayment NextFeeMultiplier (max_values: Some(1), max_size: Some(16), added: 511, mode: Measured) - /// Storage: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `TransactionPayment::NextFeeMultiplier` (r:1 w:0) + /// Proof: `TransactionPayment::NextFeeMultiplier` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `Measured`) + /// Storage: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_weight_to_fee(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `931 + r * (14 ±0)` - // Estimated: `6864 + r * (14 ±0)` - // Minimum execution time: 275_471_000 picoseconds. - Weight::from_parts(297_332_107, 6864) - // Standard Error: 2_230 - .saturating_add(Weight::from_parts(1_484_476, 0).saturating_mul(r.into())) + // Measured: `935 + r * (14 ±0)` + // Estimated: `6868 + r * (14 ±0)` + // Minimum execution time: 278_670_000 picoseconds. + Weight::from_parts(299_683_202, 6868) + // Standard Error: 1_061 + .saturating_add(Weight::from_parts(1_388_677, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 14).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_input(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `859 + r * (6 ±0)` - // Estimated: `6803 + r * (6 ±0)` - // Minimum execution time: 255_279_000 picoseconds. - Weight::from_parts(282_649_020, 6803) - // Standard Error: 429 - .saturating_add(Weight::from_parts(290_527, 0).saturating_mul(r.into())) + // Measured: `863 + r * (6 ±0)` + // Estimated: `6807 + r * (6 ±0)` + // Minimum execution time: 255_982_000 picoseconds. + Weight::from_parts(280_566_090, 6807) + // Standard Error: 562 + .saturating_add(Weight::from_parts(293_398, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 6).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 1048576]`. fn seal_input_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `863` - // Estimated: `6803` - // Minimum execution time: 268_029_000 picoseconds. - Weight::from_parts(231_474_232, 6803) + // Measured: `867` + // Estimated: `6807` + // Minimum execution time: 277_805_000 picoseconds. + Weight::from_parts(226_812_344, 6807) // Standard Error: 23 - .saturating_add(Weight::from_parts(1_050, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_013, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1]`. fn seal_return(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `847 + r * (45 ±0)` - // Estimated: `6787 + r * (45 ±0)` - // Minimum execution time: 252_126_000 picoseconds. - Weight::from_parts(277_677_710, 6787) - // Standard Error: 770_704 - .saturating_add(Weight::from_parts(2_678_989, 0).saturating_mul(r.into())) + // Measured: `851 + r * (45 ±0)` + // Estimated: `6791 + r * (45 ±0)` + // Minimum execution time: 252_203_000 picoseconds. + Weight::from_parts(277_335_489, 6791) + // Standard Error: 893_885 + .saturating_add(Weight::from_parts(681_110, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 45).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 1048576]`. fn seal_return_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `857` - // Estimated: `6810` - // Minimum execution time: 271_967_000 picoseconds. - Weight::from_parts(282_988_484, 6810) - // Standard Error: 0 - .saturating_add(Weight::from_parts(387, 0).saturating_mul(n.into())) + // Measured: `861` + // Estimated: `6814` + // Minimum execution time: 265_214_000 picoseconds. + Weight::from_parts(279_705_994, 6814) + // Standard Error: 1 + .saturating_add(Weight::from_parts(327, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:4 w:4) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:1) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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 DeletionQueueCounter (r:1 w:1) - /// Proof: Contracts DeletionQueueCounter (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: System EventTopics (r:3 w:3) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) - /// Storage: Contracts DeletionQueue (r:0 w:1) - /// Proof: Contracts DeletionQueue (max_values: None, max_size: Some(142), added: 2617, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:4 w:4) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:1) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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::DeletionQueueCounter` (r:1 w:1) + /// Proof: `Contracts::DeletionQueueCounter` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) + /// Storage: `System::EventTopics` (r:3 w:3) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, 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: - // Measured: `889 + r * (300 ±0)` - // Estimated: `6829 + r * (7725 ±0)` - // Minimum execution time: 257_246_000 picoseconds. - Weight::from_parts(280_196_561, 6829) - // Standard Error: 815_845 - .saturating_add(Weight::from_parts(127_831_338, 0).saturating_mul(r.into())) + // Measured: `893 + r * (300 ±0)` + // Estimated: `6833 + r * (7725 ±0)` + // Minimum execution time: 256_416_000 picoseconds. + Weight::from_parts(279_758_997, 6833) + // Standard Error: 842_665 + .saturating_add(Weight::from_parts(134_807_902, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((8_u64).saturating_mul(r.into()))) .saturating_add(Weight::from_parts(0, 7725).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) - /// Proof: RandomnessCollectiveFlip RandomMaterial (max_values: Some(1), max_size: Some(2594), added: 3089, mode: Measured) - /// Storage: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `RandomnessCollectiveFlip::RandomMaterial` (r:1 w:0) + /// Proof: `RandomnessCollectiveFlip::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `Measured`) + /// Storage: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_random(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `938 + r * (10 ±0)` - // Estimated: `6879 + r * (10 ±0)` - // Minimum execution time: 270_074_000 picoseconds. - Weight::from_parts(292_298_331, 6879) - // Standard Error: 2_123 - .saturating_add(Weight::from_parts(2_089_487, 0).saturating_mul(r.into())) + // Measured: `942 + r * (10 ±0)` + // Estimated: `6883 + r * (10 ±0)` + // Minimum execution time: 269_693_000 picoseconds. + Weight::from_parts(294_618_859, 6883) + // Standard Error: 1_519 + .saturating_add(Weight::from_parts(1_937_907, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 10).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_deposit_event(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `857 + r * (10 ±0)` - // Estimated: `6802 + r * (10 ±0)` - // Minimum execution time: 267_080_000 picoseconds. - Weight::from_parts(298_470_496, 6802) - // Standard Error: 3_004 - .saturating_add(Weight::from_parts(3_898_460, 0).saturating_mul(r.into())) + // Measured: `861 + r * (10 ±0)` + // Estimated: `6806 + r * (10 ±0)` + // Minimum execution time: 254_826_000 picoseconds. + Weight::from_parts(291_600_221, 6806) + // Standard Error: 5_448 + .saturating_add(Weight::from_parts(3_783_146, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 10).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:6 w:6) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:6 w:6) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `t` is `[0, 4]`. /// The range of component `n` is `[0, 16384]`. fn seal_deposit_event_per_topic_and_byte(t: u32, n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `876 + t * (32 ±0)` - // Estimated: `6823 + t * (2508 ±0)` - // Minimum execution time: 277_152_000 picoseconds. - Weight::from_parts(290_745_178, 6823) - // Standard Error: 88_577 - .saturating_add(Weight::from_parts(2_476_405, 0).saturating_mul(t.into())) - // Standard Error: 24 - .saturating_add(Weight::from_parts(702, 0).saturating_mul(n.into())) + // Measured: `880 + t * (32 ±0)` + // Estimated: `6827 + t * (2508 ±0)` + // Minimum execution time: 278_275_000 picoseconds. + Weight::from_parts(294_178_600, 6827) + // Standard Error: 117_436 + .saturating_add(Weight::from_parts(2_066_248, 0).saturating_mul(t.into())) + // Standard Error: 32 + .saturating_add(Weight::from_parts(523, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(t.into()))) .saturating_add(Weight::from_parts(0, 2508).saturating_mul(t.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_debug_message(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `856 + r * (7 ±0)` - // Estimated: `6800 + r * (7 ±0)` - // Minimum execution time: 168_782_000 picoseconds. - Weight::from_parts(179_694_331, 6800) - // Standard Error: 338 - .saturating_add(Weight::from_parts(246_541, 0).saturating_mul(r.into())) + // Measured: `860 + r * (7 ±0)` + // Estimated: `6804 + r * (7 ±0)` + // Minimum execution time: 166_097_000 picoseconds. + Weight::from_parts(177_410_600, 6804) + // Standard Error: 358 + .saturating_add(Weight::from_parts(243_007, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 7).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: MaxEncodedLen) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: MaxEncodedLen) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) - /// Storage: Timestamp Now (r:1 w:0) - /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) - /// Storage: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `MaxEncodedLen`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `MaxEncodedLen`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `i` is `[0, 1048576]`. fn seal_debug_message_per_byte(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `125807` - // Estimated: `131749` - // Minimum execution time: 428_673_000 picoseconds. - Weight::from_parts(398_928_494, 131749) + // Measured: `125811` + // Estimated: `131753` + // Minimum execution time: 412_545_000 picoseconds. + Weight::from_parts(383_974_601, 131753) // Standard Error: 12 - .saturating_add(Weight::from_parts(1_106, 0).saturating_mul(i.into())) + .saturating_add(Weight::from_parts(1_061, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 800]`. fn seal_set_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `924 + r * (292 ±0)` - // Estimated: `922 + r * (293 ±0)` - // Minimum execution time: 271_384_000 picoseconds. - Weight::from_parts(147_677_611, 922) - // Standard Error: 13_371 - .saturating_add(Weight::from_parts(7_085_478, 0).saturating_mul(r.into())) + // Measured: `928 + r * (292 ±0)` + // Estimated: `926 + r * (293 ±0)` + // Minimum execution time: 265_218_000 picoseconds. + Weight::from_parts(146_643_084, 926) + // Standard Error: 15_110 + .saturating_add(Weight::from_parts(7_184_127, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(r.into()))) .saturating_add(Weight::from_parts(0, 293).saturating_mul(r.into())) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 16384]`. fn seal_set_storage_per_new_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1383` - // Estimated: `1359` - // Minimum execution time: 279_587_000 picoseconds. - Weight::from_parts(335_690_918, 1359) - // Standard Error: 57 - .saturating_add(Weight::from_parts(708, 0).saturating_mul(n.into())) + // Measured: `1387` + // Estimated: `1363` + // Minimum execution time: 277_854_000 picoseconds. + Weight::from_parts(336_305_967, 1363) + // Standard Error: 58 + .saturating_add(Weight::from_parts(618, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(10_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 16384]`. fn seal_set_storage_per_old_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1246 + n * (1 ±0)` - // Estimated: `1246 + n * (1 ±0)` - // Minimum execution time: 275_572_000 picoseconds. - Weight::from_parts(300_309_544, 1246) - // Standard Error: 35 - .saturating_add(Weight::from_parts(299, 0).saturating_mul(n.into())) + // Measured: `1250 + n * (1 ±0)` + // Estimated: `1250 + n * (1 ±0)` + // Minimum execution time: 272_361_000 picoseconds. + Weight::from_parts(296_852_347, 1250) + // Standard Error: 32 + .saturating_add(Weight::from_parts(286, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 800]`. fn seal_clear_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `920 + r * (288 ±0)` - // Estimated: `924 + r * (289 ±0)` - // Minimum execution time: 271_875_000 picoseconds. - Weight::from_parts(153_680_437, 924) - // Standard Error: 13_050 - .saturating_add(Weight::from_parts(6_892_925, 0).saturating_mul(r.into())) + // Measured: `924 + r * (288 ±0)` + // Estimated: `928 + r * (289 ±0)` + // Minimum execution time: 272_862_000 picoseconds. + Weight::from_parts(177_356_718, 928) + // Standard Error: 11_611 + .saturating_add(Weight::from_parts(6_992_298, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(r.into()))) .saturating_add(Weight::from_parts(0, 289).saturating_mul(r.into())) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 16384]`. fn seal_clear_storage_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1242 + n * (1 ±0)` - // Estimated: `1242 + n * (1 ±0)` - // Minimum execution time: 272_682_000 picoseconds. - Weight::from_parts(301_025_128, 1242) + // Measured: `1246 + n * (1 ±0)` + // Estimated: `1246 + n * (1 ±0)` + // Minimum execution time: 271_433_000 picoseconds. + Weight::from_parts(295_605_496, 1246) + // Standard Error: 33 + .saturating_add(Weight::from_parts(253, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 800]`. fn seal_get_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `914 + r * (296 ±0)` - // Estimated: `919 + r * (297 ±0)` - // Minimum execution time: 271_796_000 picoseconds. - Weight::from_parts(183_856_480, 919) - // Standard Error: 10_064 - .saturating_add(Weight::from_parts(5_660_636, 0).saturating_mul(r.into())) + // Measured: `918 + r * (296 ±0)` + // Estimated: `923 + r * (297 ±0)` + // Minimum execution time: 269_367_000 picoseconds. + Weight::from_parts(171_586_915, 923) + // Standard Error: 12_119 + .saturating_add(Weight::from_parts(5_786_433, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 297).saturating_mul(r.into())) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 16384]`. fn seal_get_storage_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1258 + n * (1 ±0)` - // Estimated: `1258 + n * (1 ±0)` - // Minimum execution time: 273_102_000 picoseconds. - Weight::from_parts(297_455_692, 1258) + // Measured: `1262 + n * (1 ±0)` + // Estimated: `1262 + n * (1 ±0)` + // Minimum execution time: 269_226_000 picoseconds. + Weight::from_parts(296_274_209, 1262) // Standard Error: 35 - .saturating_add(Weight::from_parts(868, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(624, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 800]`. fn seal_contains_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `935 + r * (288 ±0)` - // Estimated: `936 + r * (289 ±0)` - // Minimum execution time: 271_323_000 picoseconds. - Weight::from_parts(190_080_834, 936) - // Standard Error: 9_143 - .saturating_add(Weight::from_parts(5_488_362, 0).saturating_mul(r.into())) + // Measured: `939 + r * (288 ±0)` + // Estimated: `940 + r * (289 ±0)` + // Minimum execution time: 268_457_000 picoseconds. + Weight::from_parts(182_423_487, 940) + // Standard Error: 11_806 + .saturating_add(Weight::from_parts(5_587_320, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 289).saturating_mul(r.into())) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 16384]`. fn seal_contains_storage_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1245 + n * (1 ±0)` - // Estimated: `1245 + n * (1 ±0)` - // Minimum execution time: 270_399_000 picoseconds. - Weight::from_parts(296_679_410, 1245) - // Standard Error: 34 - .saturating_add(Weight::from_parts(161, 0).saturating_mul(n.into())) + // Measured: `1249 + n * (1 ±0)` + // Estimated: `1249 + n * (1 ±0)` + // Minimum execution time: 268_850_000 picoseconds. + Weight::from_parts(297_040_414, 1249) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 800]`. fn seal_take_storage(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `908 + r * (296 ±0)` - // Estimated: `915 + r * (297 ±0)` - // Minimum execution time: 271_645_000 picoseconds. - Weight::from_parts(147_320_521, 915) - // Standard Error: 13_502 - .saturating_add(Weight::from_parts(7_074_778, 0).saturating_mul(r.into())) + // Measured: `912 + r * (296 ±0)` + // Estimated: `919 + r * (297 ±0)` + // Minimum execution time: 270_450_000 picoseconds. + Weight::from_parts(146_102_173, 919) + // Standard Error: 18_029 + .saturating_add(Weight::from_parts(7_211_483, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(r.into()))) .saturating_add(Weight::from_parts(0, 297).saturating_mul(r.into())) } - /// Storage: Skipped Metadata (r:0 w:0) - /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 16384]`. fn seal_take_storage_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1259 + n * (1 ±0)` - // Estimated: `1259 + n * (1 ±0)` - // Minimum execution time: 280_680_000 picoseconds. - Weight::from_parts(304_043_474, 1259) - // Standard Error: 29 - .saturating_add(Weight::from_parts(644, 0).saturating_mul(n.into())) + // Measured: `1263 + n * (1 ±0)` + // Estimated: `1263 + n * (1 ±0)` + // Minimum execution time: 276_137_000 picoseconds. + Weight::from_parts(297_746_629, 1263) + // Standard Error: 34 + .saturating_add(Weight::from_parts(1_069, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1602 w:1601) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1602 w:1601) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_transfer(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1452 + r * (45 ±0)` - // Estimated: `7349 + r * (2520 ±0)` - // Minimum execution time: 274_928_000 picoseconds. - Weight::from_parts(192_111_339, 7349) - // Standard Error: 42_436 - .saturating_add(Weight::from_parts(40_323_660, 0).saturating_mul(r.into())) + // Measured: `1456 + r * (45 ±0)` + // Estimated: `7353 + r * (2520 ±0)` + // Minimum execution time: 270_088_000 picoseconds. + Weight::from_parts(265_367_984, 7353) + // Standard Error: 21_456 + .saturating_add(Weight::from_parts(41_278_150, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(r.into()))) .saturating_add(Weight::from_parts(0, 2520).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:801 w:801) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:2 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:2 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:803 w:803) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:801 w:801) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:2 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:2 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:803 w:803) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 800]`. fn seal_call(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1296 + r * (276 ±0)` - // Estimated: `9481 + r * (2752 ±0)` - // Minimum execution time: 275_293_000 picoseconds. - Weight::from_parts(278_243_000, 9481) - // Standard Error: 119_869 - .saturating_add(Weight::from_parts(245_114_905, 0).saturating_mul(r.into())) + // Measured: `1305 + r * (276 ±0)` + // Estimated: `9484 + r * (2752 ±0)` + // Minimum execution time: 265_246_000 picoseconds. + Weight::from_parts(280_488_000, 9484) + // Standard Error: 108_640 + .saturating_add(Weight::from_parts(243_995_043, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(11_u64)) .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(r.into()))) .saturating_add(Weight::from_parts(0, 2752).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:736 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:736 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:737 w:737) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:736 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:736 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:737 w:737) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 800]`. fn seal_delegate_call(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + r * (572 ±0)` - // Estimated: `6806 + r * (2633 ±3)` - // Minimum execution time: 271_857_000 picoseconds. - Weight::from_parts(278_276_000, 6806) - // Standard Error: 152_056 - .saturating_add(Weight::from_parts(243_744_830, 0).saturating_mul(r.into())) + // Measured: `0 + r * (576 ±0)` + // Estimated: `6810 + r * (2637 ±3)` + // Minimum execution time: 254_632_000 picoseconds. + Weight::from_parts(271_610_000, 6810) + // Standard Error: 141_373 + .saturating_add(Weight::from_parts(243_236_279, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 2633).saturating_mul(r.into())) - } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:3 w:2) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:2 w:2) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:2 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:2 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:4 w:4) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + .saturating_add(Weight::from_parts(0, 2637).saturating_mul(r.into())) + } + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:3 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:2 w:2) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:2 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:2 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:4 w:4) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `t` is `[0, 1]`. /// The range of component `c` is `[0, 1048576]`. fn seal_call_per_transfer_clone_byte(t: u32, c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1328 + t * (310 ±0)` - // Estimated: `12218 + t * (5260 ±0)` - // Minimum execution time: 463_865_000 picoseconds. - Weight::from_parts(70_396_050, 12218) - // Standard Error: 11_489_598 - .saturating_add(Weight::from_parts(359_195_747, 0).saturating_mul(t.into())) - // Standard Error: 16 - .saturating_add(Weight::from_parts(1_090, 0).saturating_mul(c.into())) + // Measured: `1336 + t * (310 ±0)` + // Estimated: `12226 + t * (5260 ±0)` + // Minimum execution time: 468_675_000 picoseconds. + Weight::from_parts(33_677_392, 12226) + // Standard Error: 11_951_296 + .saturating_add(Weight::from_parts(386_644_559, 0).saturating_mul(t.into())) + // Standard Error: 17 + .saturating_add(Weight::from_parts(1_080, 0).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(13_u64)) .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(t.into()))) .saturating_add(RocksDbWeight::get().writes(6_u64)) .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(t.into()))) .saturating_add(Weight::from_parts(0, 5260).saturating_mul(t.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1602 w:1602) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:801 w:801) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:801 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:801 w:800) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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 Nonce (r:1 w:1) - /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: System EventTopics (r:802 w:802) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1602 w:1602) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:801 w:801) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:801 w:800) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:801 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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::Nonce` (r:1 w:1) + /// Proof: `Contracts::Nonce` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) + /// Storage: `System::EventTopics` (r:802 w:802) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[1, 800]`. fn seal_instantiate(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1383 + r * (251 ±0)` - // Estimated: `7207 + r * (5202 ±0)` - // Minimum execution time: 660_947_000 picoseconds. - Weight::from_parts(668_346_000, 7207) - // Standard Error: 357_950 - .saturating_add(Weight::from_parts(397_202_020, 0).saturating_mul(r.into())) + // Measured: `1401 + r * (255 ±0)` + // Estimated: `7234 + r * (5206 ±0)` + // Minimum execution time: 671_411_000 picoseconds. + Weight::from_parts(682_502_000, 7234) + // Standard Error: 358_458 + .saturating_add(Weight::from_parts(403_141_393, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(10_u64)) .saturating_add(RocksDbWeight::get().reads((6_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(6_u64)) .saturating_add(RocksDbWeight::get().writes((5_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 5202).saturating_mul(r.into())) - } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:4 w:4) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:2 w:2) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:2 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:2 w:1) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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 Nonce (r:1 w:1) - /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: System EventTopics (r:3 w:3) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + .saturating_add(Weight::from_parts(0, 5206).saturating_mul(r.into())) + } + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:4 w:4) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:2 w:2) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:2 w:1) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:2 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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::Nonce` (r:1 w:1) + /// Proof: `Contracts::Nonce` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) + /// Storage: `System::EventTopics` (r:3 w:3) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `t` is `[0, 1]`. /// The range of component `i` is `[0, 983040]`. /// The range of component `s` is `[0, 983040]`. fn seal_instantiate_per_transfer_input_salt_byte(t: u32, i: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1232 + t * (156 ±0)` - // Estimated: `9662 + t * (2578 ±2)` - // Minimum execution time: 2_419_720_000 picoseconds. - Weight::from_parts(1_328_224_119, 9662) - // Standard Error: 17 - .saturating_add(Weight::from_parts(1_171, 0).saturating_mul(i.into())) - // Standard Error: 17 - .saturating_add(Weight::from_parts(1_263, 0).saturating_mul(s.into())) + // Measured: `1242 + t * (156 ±0)` + // Estimated: `9672 + t * (2578 ±2)` + // Minimum execution time: 2_396_346_000 picoseconds. + Weight::from_parts(1_391_208_964, 9672) + // Standard Error: 19 + .saturating_add(Weight::from_parts(1_110, 0).saturating_mul(i.into())) + // Standard Error: 19 + .saturating_add(Weight::from_parts(1_206, 0).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(15_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(RocksDbWeight::get().writes(10_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(t.into()))) .saturating_add(Weight::from_parts(0, 2578).saturating_mul(t.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_hash_sha2_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `856 + r * (8 ±0)` - // Estimated: `6797 + r * (8 ±0)` - // Minimum execution time: 263_620_000 picoseconds. - Weight::from_parts(285_686_431, 6797) - // Standard Error: 605 - .saturating_add(Weight::from_parts(393_863, 0).saturating_mul(r.into())) + // Measured: `860 + r * (8 ±0)` + // Estimated: `6801 + r * (8 ±0)` + // Minimum execution time: 258_627_000 picoseconds. + Weight::from_parts(279_826_907, 6801) + // Standard Error: 634 + .saturating_add(Weight::from_parts(402_011, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 8).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 1048576]`. fn seal_hash_sha2_256_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `864` - // Estimated: `6804` - // Minimum execution time: 271_378_000 picoseconds. - Weight::from_parts(266_737_832, 6804) + // Measured: `868` + // Estimated: `6808` + // Minimum execution time: 270_980_000 picoseconds. + Weight::from_parts(269_821_038, 6808) // Standard Error: 1 - .saturating_add(Weight::from_parts(1_124, 0).saturating_mul(n.into())) + .saturating_add(Weight::from_parts(1_093, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_hash_keccak_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `858 + r * (8 ±0)` - // Estimated: `6800 + r * (8 ±0)` - // Minimum execution time: 269_277_000 picoseconds. - Weight::from_parts(282_723_951, 6800) - // Standard Error: 577 - .saturating_add(Weight::from_parts(808_522, 0).saturating_mul(r.into())) + // Measured: `862 + r * (8 ±0)` + // Estimated: `6804 + r * (8 ±0)` + // Minimum execution time: 265_045_000 picoseconds. + Weight::from_parts(276_465_886, 6804) + // Standard Error: 717 + .saturating_add(Weight::from_parts(799_550, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 8).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 1048576]`. fn seal_hash_keccak_256_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `866` - // Estimated: `6808` - // Minimum execution time: 254_252_000 picoseconds. - Weight::from_parts(277_589_498, 6808) - // Standard Error: 1 - .saturating_add(Weight::from_parts(3_394, 0).saturating_mul(n.into())) + // Measured: `870` + // Estimated: `6812` + // Minimum execution time: 267_818_000 picoseconds. + Weight::from_parts(274_565_508, 6812) + // Standard Error: 2 + .saturating_add(Weight::from_parts(3_399, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_hash_blake2_256(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `858 + r * (8 ±0)` - // Estimated: `6803 + r * (8 ±0)` - // Minimum execution time: 254_411_000 picoseconds. - Weight::from_parts(283_572_987, 6803) - // Standard Error: 549 - .saturating_add(Weight::from_parts(455_436, 0).saturating_mul(r.into())) + // Measured: `862 + r * (8 ±0)` + // Estimated: `6807 + r * (8 ±0)` + // Minimum execution time: 268_071_000 picoseconds. + Weight::from_parts(280_629_875, 6807) + // Standard Error: 603 + .saturating_add(Weight::from_parts(461_392, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 8).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 1048576]`. fn seal_hash_blake2_256_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `866` - // Estimated: `6812` - // Minimum execution time: 264_371_000 picoseconds. - Weight::from_parts(269_330_603, 6812) - // Standard Error: 0 - .saturating_add(Weight::from_parts(1_249, 0).saturating_mul(n.into())) + // Measured: `870` + // Estimated: `6816` + // Minimum execution time: 255_606_000 picoseconds. + Weight::from_parts(264_796_539, 6816) + // Standard Error: 1 + .saturating_add(Weight::from_parts(1_232, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_hash_blake2_128(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `858 + r * (8 ±0)` - // Estimated: `6804 + r * (8 ±0)` - // Minimum execution time: 257_896_000 picoseconds. - Weight::from_parts(286_738_151, 6804) - // Standard Error: 680 - .saturating_add(Weight::from_parts(459_525, 0).saturating_mul(r.into())) + // Measured: `862 + r * (8 ±0)` + // Estimated: `6808 + r * (8 ±0)` + // Minimum execution time: 269_830_000 picoseconds. + Weight::from_parts(285_437_600, 6808) + // Standard Error: 553 + .saturating_add(Weight::from_parts(449_486, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 8).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 1048576]`. fn seal_hash_blake2_128_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `866` - // Estimated: `6806` - // Minimum execution time: 272_952_000 picoseconds. - Weight::from_parts(271_516_361, 6806) - // Standard Error: 0 - .saturating_add(Weight::from_parts(1_242, 0).saturating_mul(n.into())) + // Measured: `870` + // Estimated: `6810` + // Minimum execution time: 269_208_000 picoseconds. + Weight::from_parts(261_433_983, 6810) + // Standard Error: 2 + .saturating_add(Weight::from_parts(1_230, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `n` is `[0, 125697]`. fn seal_sr25519_verify_per_byte(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `991 + n * (1 ±0)` - // Estimated: `6928 + n * (1 ±0)` - // Minimum execution time: 351_363_000 picoseconds. - Weight::from_parts(356_558_856, 6928) - // Standard Error: 10 - .saturating_add(Weight::from_parts(6_085, 0).saturating_mul(n.into())) + // Measured: `995 + n * (1 ±0)` + // Estimated: `6932 + n * (1 ±0)` + // Minimum execution time: 345_453_000 picoseconds. + Weight::from_parts(363_052_686, 6932) + // Standard Error: 14 + .saturating_add(Weight::from_parts(5_932, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 160]`. fn seal_sr25519_verify(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `801 + r * (112 ±0)` - // Estimated: `6745 + r * (112 ±0)` - // Minimum execution time: 261_688_000 picoseconds. - Weight::from_parts(338_043_015, 6745) - // Standard Error: 13_532 - .saturating_add(Weight::from_parts(56_420_806, 0).saturating_mul(r.into())) + // Measured: `805 + r * (112 ±0)` + // Estimated: `6749 + r * (112 ±0)` + // Minimum execution time: 276_439_000 picoseconds. + Weight::from_parts(340_524_474, 6749) + // Standard Error: 14_776 + .saturating_add(Weight::from_parts(56_195_198, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 112).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 160]`. fn seal_ecdsa_recover(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `901 + r * (76 ±0)` - // Estimated: `6795 + r * (77 ±0)` - // Minimum execution time: 267_401_000 picoseconds. - Weight::from_parts(345_773_771, 6795) - // Standard Error: 14_486 - .saturating_add(Weight::from_parts(46_180_739, 0).saturating_mul(r.into())) + // Measured: `904 + r * (76 ±0)` + // Estimated: `6799 + r * (77 ±0)` + // Minimum execution time: 265_177_000 picoseconds. + Weight::from_parts(354_962_424, 6799) + // Standard Error: 19_335 + .saturating_add(Weight::from_parts(46_185_645, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 77).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 160]`. fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `871 + r * (42 ±0)` - // Estimated: `6810 + r * (42 ±0)` - // Minimum execution time: 277_890_000 picoseconds. - Weight::from_parts(319_211_194, 6810) - // Standard Error: 9_132 - .saturating_add(Weight::from_parts(12_128_696, 0).saturating_mul(r.into())) + // Measured: `875 + r * (42 ±0)` + // Estimated: `6815 + r * (42 ±0)` + // Minimum execution time: 269_843_000 picoseconds. + Weight::from_parts(320_179_949, 6815) + // Standard Error: 11_229 + .saturating_add(Weight::from_parts(12_025_678, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 42).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1536 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1536 w:1536) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:1538 w:1538) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1536 w:1536) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1536 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:1538 w:1538) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_set_code_hash(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + r * (961 ±0)` - // Estimated: `6801 + r * (3087 ±10)` - // Minimum execution time: 259_692_000 picoseconds. - Weight::from_parts(278_327_000, 6801) - // Standard Error: 60_024 - .saturating_add(Weight::from_parts(25_758_805, 0).saturating_mul(r.into())) + // Measured: `0 + r * (965 ±0)` + // Estimated: `6805 + r * (3090 ±10)` + // Minimum execution time: 278_081_000 picoseconds. + Weight::from_parts(280_430_000, 6805) + // Standard Error: 66_737 + .saturating_add(Weight::from_parts(26_863_662, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(r.into()))) - .saturating_add(Weight::from_parts(0, 3087).saturating_mul(r.into())) - } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + .saturating_add(Weight::from_parts(0, 3090).saturating_mul(r.into())) + } + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_reentrance_count(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `852 + r * (3 ±0)` - // Estimated: `6802 + r * (3 ±0)` - // Minimum execution time: 258_907_000 picoseconds. - Weight::from_parts(285_755_890, 6802) - // Standard Error: 378 - .saturating_add(Weight::from_parts(179_649, 0).saturating_mul(r.into())) + // Measured: `856 + r * (3 ±0)` + // Estimated: `6806 + r * (3 ±0)` + // Minimum execution time: 266_348_000 picoseconds. + Weight::from_parts(288_045_413, 6806) + // Standard Error: 438 + .saturating_add(Weight::from_parts(181_089, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 3).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_account_reentrance_count(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2092 + r * (39 ±0)` - // Estimated: `7919 + r * (40 ±0)` - // Minimum execution time: 260_415_000 picoseconds. - Weight::from_parts(363_871_048, 7919) - // Standard Error: 2_010 - .saturating_add(Weight::from_parts(317_607, 0).saturating_mul(r.into())) + // Measured: `2096 + r * (39 ±0)` + // Estimated: `7916 + r * (40 ±0)` + // Minimum execution time: 275_791_000 picoseconds. + Weight::from_parts(373_949_987, 7916) + // Standard Error: 2_280 + .saturating_add(Weight::from_parts(319_620, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(Weight::from_parts(0, 40).saturating_mul(r.into())) } - /// Storage: Contracts MigrationInProgress (r:1 w:0) - /// Proof: Contracts MigrationInProgress (max_values: Some(1), max_size: Some(1026), added: 1521, mode: Measured) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Measured) - /// Storage: Contracts ContractInfoOf (r:1 w:1) - /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(290), added: 2765, mode: Measured) - /// Storage: Contracts PristineCode (r:1 w:0) - /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Measured) - /// Storage: Contracts CodeInfoOf (r:1 w:0) - /// Proof: Contracts CodeInfoOf (max_values: None, max_size: Some(89), added: 2564, 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 Nonce (r:1 w:1) - /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Measured) - /// Storage: System EventTopics (r:2 w:2) - /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Measured) + /// Storage: `Contracts::MigrationInProgress` (r:1 w:0) + /// Proof: `Contracts::MigrationInProgress` (`max_values`: Some(1), `max_size`: Some(1026), added: 1521, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:0) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) + /// Storage: `Contracts::ContractInfoOf` (r:1 w:1) + /// Proof: `Contracts::ContractInfoOf` (`max_values`: None, `max_size`: Some(290), added: 2765, mode: `Measured`) + /// Storage: `Contracts::CodeInfoOf` (r:1 w:0) + /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) + /// Storage: `Contracts::PristineCode` (r:1 w:0) + /// Proof: `Contracts::PristineCode` (`max_values`: None, `max_size`: Some(125988), added: 128463, 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::Nonce` (r:1 w:1) + /// Proof: `Contracts::Nonce` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `Measured`) + /// Storage: `System::EventTopics` (r:2 w:2) + /// Proof: `System::EventTopics` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `r` is `[0, 1600]`. fn seal_instantiation_nonce(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `855 + r * (3 ±0)` - // Estimated: `6802 + r * (3 ±0)` - // Minimum execution time: 257_725_000 picoseconds. - Weight::from_parts(283_441_372, 6802) - // Standard Error: 371 - .saturating_add(Weight::from_parts(157_674, 0).saturating_mul(r.into())) + // Measured: `859 + r * (3 ±0)` + // Estimated: `6806 + r * (3 ±0)` + // Minimum execution time: 259_378_000 picoseconds. + Weight::from_parts(281_549_294, 6806) + // Standard Error: 491 + .saturating_add(Weight::from_parts(163_939, 0).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(Weight::from_parts(0, 3).saturating_mul(r.into())) @@ -3720,9 +3724,9 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_635_000 picoseconds. - Weight::from_parts(2_990_110, 0) - // Standard Error: 31 - .saturating_add(Weight::from_parts(10_213, 0).saturating_mul(r.into())) + // Minimum execution time: 1_473_000 picoseconds. + Weight::from_parts(2_027_513, 0) + // Standard Error: 16 + .saturating_add(Weight::from_parts(10_451, 0).saturating_mul(r.into())) } } From 55fd7ce7c3009b5e8ace275dd37e12f3aae90736 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 25 Jul 2023 11:29:54 +0200 Subject: [PATCH 075/105] remove all the `where BalanceOf` --- frame/contracts/proc-macro/src/lib.rs | 2 +- frame/contracts/src/benchmarking/mod.rs | 2 - frame/contracts/src/chain_extension.rs | 58 ++++++------------------- frame/contracts/src/exec.rs | 56 +++++------------------- frame/contracts/src/lib.rs | 55 +++++++---------------- frame/contracts/src/storage/meter.rs | 34 +++++---------- frame/contracts/src/tests.rs | 1 + frame/contracts/src/wasm/mod.rs | 22 +++------- frame/contracts/src/wasm/prepare.rs | 5 +-- frame/contracts/src/wasm/runtime.rs | 25 +++-------- 10 files changed, 65 insertions(+), 195 deletions(-) diff --git a/frame/contracts/proc-macro/src/lib.rs b/frame/contracts/proc-macro/src/lib.rs index ac50099f89e0d..b31403c29adfd 100644 --- a/frame/contracts/proc-macro/src/lib.rs +++ b/frame/contracts/proc-macro/src/lib.rs @@ -564,7 +564,7 @@ fn expand_impls(def: &EnvDef) -> TokenStream2 { let dummy_impls = expand_functions(def, false, quote! { () }); quote! { - impl<'a, E: Ext> crate::wasm::Environment> for Env where BalanceOf: FixedPointOperand + impl<'a, E: Ext> crate::wasm::Environment> for Env { fn define( store: &mut ::wasmi::Store>, diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 2fa7a85bee2d7..43a41c889c300 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -73,7 +73,6 @@ impl Contract where T: Config + pallet_balances::Config, as HasCompact>::Type: Clone + Eq + PartialEq + Debug + TypeInfo + Encode, - BalanceOf: FixedPointOperand, { /// Create new contract and use a default account id as instantiator. fn new(module: WasmModule, data: Vec) -> Result, &'static str> { @@ -202,7 +201,6 @@ macro_rules! load_benchmark { benchmarks! { where_clause { where as codec::HasCompact>::Type: Clone + Eq + PartialEq + sp_std::fmt::Debug + scale_info::TypeInfo + codec::Encode, - BalanceOf: FixedPointOperand, T: Config + pallet_balances::Config, } diff --git a/frame/contracts/src/chain_extension.rs b/frame/contracts/src/chain_extension.rs index ad261011ed40e..8ec922d343df4 100644 --- a/frame/contracts/src/chain_extension.rs +++ b/frame/contracts/src/chain_extension.rs @@ -73,13 +73,13 @@ pub use crate::{exec::Ext, gas::ChargedAmount, Config}; use crate::{ wasm::{Runtime, RuntimeCosts}, - BalanceOf, Error, + Error, }; use codec::{Decode, MaxEncodedLen}; use frame_support::weights::Weight; pub use frame_system::Config as SysConfig; pub use pallet_contracts_primitives::ReturnFlags; -use sp_runtime::{DispatchError, FixedPointOperand}; +use sp_runtime::DispatchError; use sp_std::{marker::PhantomData, vec::Vec}; /// Result that returns a [`DispatchError`] on error. @@ -111,9 +111,7 @@ pub trait ChainExtension { /// In case of `Err` the contract execution is immediately suspended and the passed error /// is returned to the caller. Otherwise the value of [`RetVal`] determines the exit /// behaviour. - fn call>(&mut self, env: Environment) -> Result - where - BalanceOf: FixedPointOperand; + fn call>(&mut self, env: Environment) -> Result; /// Determines whether chain extensions are enabled for this chain. /// @@ -149,10 +147,7 @@ pub trait RegisteredChainExtension: ChainExtension { #[impl_trait_for_tuples::impl_for_tuples(10)] #[tuple_types_custom_trait_bound(RegisteredChainExtension)] impl ChainExtension for Tuple { - fn call>(&mut self, mut env: Environment) -> Result - where - BalanceOf: FixedPointOperand, - { + fn call>(&mut self, mut env: Environment) -> Result { for_tuples!( #( if (Tuple::ID == env.ext_id()) && Tuple::enabled() { @@ -192,10 +187,7 @@ pub enum RetVal { /// /// It uses [typestate programming](https://docs.rust-embedded.org/book/static-guarantees/typestate-programming.html) /// to enforce the correct usage of the parameters passed to the chain extension. -pub struct Environment<'a, 'b, E: Ext, S: State> -where - BalanceOf: FixedPointOperand, -{ +pub struct Environment<'a, 'b, E: Ext, S: State> { /// The actual data of this type. inner: Inner<'a, 'b, E>, /// `S` is only used in the type system but never as value. @@ -203,10 +195,7 @@ where } /// Functions that are available in every state of this type. -impl<'a, 'b, E: Ext, S: State> Environment<'a, 'b, E, S> -where - BalanceOf: FixedPointOperand, -{ +impl<'a, 'b, E: Ext, S: State> Environment<'a, 'b, E, S> { /// The function id within the `id` passed by a contract. /// /// It returns the two least significant bytes of the `id` passed by a contract as the other @@ -261,10 +250,7 @@ where /// /// Those are the functions that determine how the arguments to the chain extensions /// should be consumed. -impl<'a, 'b, E: Ext> Environment<'a, 'b, E, InitState> -where - BalanceOf: FixedPointOperand, -{ +impl<'a, 'b, E: Ext> Environment<'a, 'b, E, InitState> { /// Creates a new environment for consumption by a chain extension. /// /// It is only available to this crate because only the wasm runtime module needs to @@ -277,10 +263,7 @@ where input_len: u32, output_ptr: u32, output_len_ptr: u32, - ) -> Self - where - BalanceOf: FixedPointOperand, - { + ) -> Self { Environment { inner: Inner { runtime, memory, id, input_ptr, input_len, output_ptr, output_len_ptr }, phantom: PhantomData, @@ -304,10 +287,7 @@ where } /// Functions to use the input arguments as integers. -impl<'a, 'b, E: Ext, S: PrimIn> Environment<'a, 'b, E, S> -where - BalanceOf: FixedPointOperand, -{ +impl<'a, 'b, E: Ext, S: PrimIn> Environment<'a, 'b, E, S> { /// The `input_ptr` argument. pub fn val0(&self) -> u32 { self.inner.input_ptr @@ -320,10 +300,7 @@ where } /// Functions to use the output arguments as integers. -impl<'a, 'b, E: Ext, S: PrimOut> Environment<'a, 'b, E, S> -where - BalanceOf: FixedPointOperand, -{ +impl<'a, 'b, E: Ext, S: PrimOut> Environment<'a, 'b, E, S> { /// The `output_ptr` argument. pub fn val2(&self) -> u32 { self.inner.output_ptr @@ -336,10 +313,7 @@ where } /// Functions to use the input arguments as pointer to a buffer. -impl<'a, 'b, E: Ext, S: BufIn> Environment<'a, 'b, E, S> -where - BalanceOf: FixedPointOperand, -{ +impl<'a, 'b, E: Ext, S: BufIn> Environment<'a, 'b, E, S> { /// Reads `min(max_len, in_len)` from contract memory. /// /// This does **not** charge any weight. The caller must make sure that the an @@ -411,10 +385,7 @@ where } /// Functions to use the output arguments as pointer to a buffer. -impl<'a, 'b, E: Ext, S: BufOut> Environment<'a, 'b, E, S> -where - BalanceOf: FixedPointOperand, -{ +impl<'a, 'b, E: Ext, S: BufOut> Environment<'a, 'b, E, S> { /// Write the supplied buffer to contract memory. /// /// If the contract supplied buffer is smaller than the passed `buffer` an `Err` is returned. @@ -446,10 +417,7 @@ where /// All data is put into this struct to easily pass it around as part of the typestate /// pattern. Also it creates the opportunity to box this struct in the future in case it /// gets too large. -struct Inner<'a, 'b, E: Ext> -where - BalanceOf: FixedPointOperand, -{ +struct Inner<'a, 'b, E: Ext> { /// The runtime contains all necessary functions to interact with the running contract. runtime: &'a mut Runtime<'b, E>, /// Reference to the contracts memory. diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 63482cca10c53..8b83fbf23e353 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -43,10 +43,7 @@ use sp_core::{ sr25519::{Public as SR25519Public, Signature as SR25519Signature}, }; use sp_io::{crypto::secp256k1_ecdsa_recover_compressed, hashing::blake2_256}; -use sp_runtime::{ - traits::{Convert, Hash, Zero}, - FixedPointOperand, -}; +use sp_runtime::traits::{Convert, Hash, Zero}; use sp_std::{marker::PhantomData, mem, prelude::*, vec::Vec}; pub type AccountIdOf = ::AccountId; @@ -147,9 +144,7 @@ pub trait Ext: sealing::Sealed { value: BalanceOf, input_data: Vec, allows_reentry: bool, - ) -> Result - where - BalanceOf: FixedPointOperand; + ) -> Result; /// Execute code in the current frame. /// @@ -158,9 +153,7 @@ pub trait Ext: sealing::Sealed { &mut self, code: CodeHash, input_data: Vec, - ) -> Result - where - BalanceOf: FixedPointOperand; + ) -> Result; /// Instantiate a contract from the given code. /// @@ -175,9 +168,7 @@ pub trait Ext: sealing::Sealed { value: BalanceOf, input_data: Vec, salt: &[u8], - ) -> Result<(AccountIdOf, ExecReturnValue), ExecError> - where - BalanceOf: FixedPointOperand; + ) -> Result<(AccountIdOf, ExecReturnValue), ExecError>; /// Transfer all funds to `beneficiary` and delete the contract. /// @@ -373,9 +364,7 @@ pub trait Executable: Sized { ext: &mut E, function: &ExportedFunction, input_data: Vec, - ) -> ExecResult - where - BalanceOf: FixedPointOperand; + ) -> ExecResult; /// The code hash of the executable. fn code_hash(&self) -> &CodeHash; @@ -647,10 +636,7 @@ where input_data: Vec, debug_message: Option<&'a mut DebugBufferVec>, determinism: Determinism, - ) -> Result - where - BalanceOf: FixedPointOperand, - { + ) -> Result { let (mut stack, executable) = Self::new( FrameArgs::Call { dest, cached_info: None, delegated_call: None }, origin, @@ -684,10 +670,7 @@ where input_data: Vec, salt: &[u8], debug_message: Option<&'a mut DebugBufferVec>, - ) -> Result<(T::AccountId, ExecReturnValue), ExecError> - where - BalanceOf: FixedPointOperand, - { + ) -> Result<(T::AccountId, ExecReturnValue), ExecError> { let (mut stack, executable) = Self::new( FrameArgs::Instantiate { sender: origin.clone(), @@ -862,10 +845,7 @@ where /// Run the current (top) frame. /// /// This can be either a call or an instantiate. - fn run(&mut self, executable: E, input_data: Vec) -> Result - where - BalanceOf: FixedPointOperand, - { + fn run(&mut self, executable: E, input_data: Vec) -> Result { let frame = self.top_frame(); let entry_point = frame.entry_point; let delegated_code_hash = @@ -989,10 +969,7 @@ where /// /// This is called after running the current frame. It commits cached values to storage /// and invalidates all stale references to it that might exist further down the call stack. - fn pop_frame(&mut self, persist: bool) - where - BalanceOf: FixedPointOperand, - { + fn pop_frame(&mut self, persist: bool) { // Revert changes to the nonce in case of a failed instantiation. if !persist && self.top_frame().entry_point == ExportedFunction::Constructor { self.nonce.as_mut().map(|c| *c = c.wrapping_sub(1)); @@ -1179,10 +1156,7 @@ where value: BalanceOf, input_data: Vec, allows_reentry: bool, - ) -> Result - where - BalanceOf: FixedPointOperand, - { + ) -> Result { // Before pushing the new frame: Protect the caller contract against reentrancy attacks. // It is important to do this before calling `allows_reentry` so that a direct recursion // is caught by it. @@ -1224,10 +1198,7 @@ where &mut self, code_hash: CodeHash, input_data: Vec, - ) -> Result - where - BalanceOf: FixedPointOperand, - { + ) -> Result { let executable = E::from_storage(code_hash, self.gas_meter_mut())?; let top_frame = self.top_frame_mut(); let contract_info = top_frame.contract_info().clone(); @@ -1254,10 +1225,7 @@ where value: BalanceOf, input_data: Vec, salt: &[u8], - ) -> Result<(AccountIdOf, ExecReturnValue), ExecError> - where - BalanceOf: FixedPointOperand, - { + ) -> Result<(AccountIdOf, ExecReturnValue), ExecError> { let executable = E::from_storage(code_hash, self.gas_meter_mut())?; let nonce = self.next_nonce(); diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index d2b68737838d5..340e00a18ff38 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -126,6 +126,7 @@ use frame_support::{ error::BadOrigin, traits::{ fungible::{Inspect, Mutate, MutateHold}, + tokens::Balance, ConstU32, Contains, Get, Randomness, Time, }, weights::Weight, @@ -151,8 +152,7 @@ pub use crate::wasm::api_doc; type CodeHash = ::Hash; type TrieId = BoundedVec>; -type BalanceOf = - <::Currency as Inspect<::AccountId>>::Balance; +type BalanceOf = ::Balance; type CodeVec = BoundedVec::MaxCodeLen>; type AccountIdLookupOf = <::Lookup as StaticLookup>::Source; type DebugBufferVec = BoundedVec::MaxDebugBufferLen>; @@ -214,10 +214,13 @@ pub mod pallet { type Randomness: Randomness>; /// The fungible in which fees are paid and contract balances are held. - type Currency: Inspect + type Currency: Inspect + Mutate + MutateHold; + /// The units in which we record balances. + type Balance: Balance + FixedPointOperand; + /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; @@ -444,7 +447,6 @@ pub mod pallet { impl Pallet where as HasCompact>::Type: Clone + Eq + PartialEq + Debug + TypeInfo + Encode, - BalanceOf: FixedPointOperand, { /// Deprecated version if [`Self::call`] for use in an in-storage `Call`. #[pallet::call_index(0)] @@ -553,10 +555,7 @@ pub mod pallet { code: Vec, storage_deposit_limit: Option< as codec::HasCompact>::Type>, determinism: Determinism, - ) -> DispatchResult - where - BalanceOf: FixedPointOperand, - { + ) -> DispatchResult { Migration::::ensure_migrated()?; let origin = ensure_signed(origin)?; Self::bare_upload_code(origin, code, storage_deposit_limit.map(Into::into), determinism) @@ -1158,10 +1157,7 @@ trait Invokable: Sized { /// /// We enforce a re-entrancy guard here by initializing and checking a boolean flag through a /// global reference. - fn run_guarded(self, common: CommonInput) -> InternalOutput - where - BalanceOf: FixedPointOperand, - { + fn run_guarded(self, common: CommonInput) -> InternalOutput { // Set up a global reference to the boolean flag used for the re-entrancy guard. environmental!(executing_contract: bool); @@ -1209,9 +1205,8 @@ trait Invokable: Sized { /// contract or a instantiation of a new one. /// /// Called by dispatchables and public functions through the [`Invokable::run_guarded`]. - fn run(self, common: CommonInput, gas_meter: GasMeter) -> InternalOutput - where - BalanceOf: FixedPointOperand; + fn run(self, common: CommonInput, gas_meter: GasMeter) + -> InternalOutput; /// This method ensures that the given `origin` is allowed to invoke the current `Invokable`. /// @@ -1226,10 +1221,7 @@ impl Invokable for CallInput { self, common: CommonInput, mut gas_meter: GasMeter, - ) -> InternalOutput - where - BalanceOf: FixedPointOperand, - { + ) -> InternalOutput { let CallInput { dest, determinism } = self; let CommonInput { origin, value, data, debug_message, .. } = common; let mut storage_meter = @@ -1277,10 +1269,7 @@ impl Invokable for InstantiateInput { self, common: CommonInput, mut gas_meter: GasMeter, - ) -> InternalOutput - where - BalanceOf: FixedPointOperand, - { + ) -> InternalOutput { let mut storage_deposit = Default::default(); let try_exec = || { let schedule = T::Schedule::get(); @@ -1361,10 +1350,7 @@ impl Pallet { debug: DebugInfo, collect_events: CollectEvents, determinism: Determinism, - ) -> ContractExecResult, EventRecordOf> - where - BalanceOf: FixedPointOperand, - { + ) -> ContractExecResult, EventRecordOf> { ensure_no_migration_in_progress!(); let mut debug_message = if matches!(debug, DebugInfo::UnsafeDebug) { @@ -1422,10 +1408,7 @@ impl Pallet { salt: Vec, debug: DebugInfo, collect_events: CollectEvents, - ) -> ContractInstantiateResult, EventRecordOf> - where - BalanceOf: FixedPointOperand, - { + ) -> ContractInstantiateResult, EventRecordOf> { ensure_no_migration_in_progress!(); let mut debug_message = if debug == DebugInfo::UnsafeDebug { @@ -1506,10 +1489,7 @@ impl Pallet { code: Vec, storage_deposit_limit: Option>, determinism: Determinism, - ) -> CodeUploadResult, BalanceOf> - where - BalanceOf: FixedPointOperand, - { + ) -> CodeUploadResult, BalanceOf> { Migration::::ensure_migrated()?; let (module, deposit) = Self::try_upload_code(origin, code, storage_deposit_limit, determinism, None)?; @@ -1523,10 +1503,7 @@ impl Pallet { storage_deposit_limit: Option>, determinism: Determinism, mut debug_message: Option<&mut DebugBufferVec>, - ) -> Result<(WasmBlob, BalanceOf), DispatchError> - where - BalanceOf: FixedPointOperand, - { + ) -> Result<(WasmBlob, BalanceOf), DispatchError> { let schedule = T::Schedule::get(); let mut module = WasmBlob::from_code(code, &schedule, origin, determinism).map_err(|(err, msg)| { diff --git a/frame/contracts/src/storage/meter.rs b/frame/contracts/src/storage/meter.rs index 45397e64caaee..0111d31bf35d8 100644 --- a/frame/contracts/src/storage/meter.rs +++ b/frame/contracts/src/storage/meter.rs @@ -35,7 +35,7 @@ use frame_support::{ use pallet_contracts_primitives::StorageDeposit as Deposit; use sp_runtime::{ traits::{Saturating, Zero}, - FixedPointNumber, FixedPointOperand, FixedU128, + FixedPointNumber, FixedU128, }; use sp_std::{marker::PhantomData, vec::Vec}; @@ -157,10 +157,7 @@ impl Diff { /// In case `None` is passed for `info` only charges are calculated. This is because refunds /// are calculated pro rata of the existing storage within a contract and hence need extract /// this information from the passed `info`. - pub fn update_contract(&self, info: Option<&mut ContractInfo>) -> DepositOf - where - BalanceOf: FixedPointOperand, - { + pub fn update_contract(&self, info: Option<&mut ContractInfo>) -> DepositOf { let per_byte = T::DepositPerByte::get(); let per_item = T::DepositPerItem::get(); let bytes_added = self.bytes_added.saturating_sub(self.bytes_removed); @@ -255,10 +252,7 @@ enum Contribution { impl Contribution { /// See [`Diff::update_contract`]. - fn update_contract(&self, info: Option<&mut ContractInfo>) -> DepositOf - where - BalanceOf: FixedPointOperand, - { + fn update_contract(&self, info: Option<&mut ContractInfo>) -> DepositOf { match self { Self::Alive(diff) => diff.update_contract::(info), Self::Terminated(deposit) | Self::Checked(deposit) => deposit.clone(), @@ -317,9 +311,7 @@ where absorbed: RawMeter, deposit_account: DepositAccount, info: Option<&mut ContractInfo>, - ) where - BalanceOf: FixedPointOperand, - { + ) { let own_deposit = absorbed.own_contribution.update_contract(info); self.total_deposit = self .total_deposit @@ -423,10 +415,7 @@ where origin: &T::AccountId, contract: &T::AccountId, info: &mut ContractInfo, - ) -> Result, DispatchError> - where - BalanceOf: FixedPointOperand, - { + ) -> Result, DispatchError> { debug_assert!(self.is_alive()); let ed = Pallet::::min_balance(); @@ -484,10 +473,10 @@ where /// call. However, if a dedicated limit is specified for a sub-call, this needs to be called /// once the sub-call has returned. For this, the [`Self::enforce_subcall_limit`] wrapper is /// used. - pub fn enforce_limit(&mut self, info: Option<&mut ContractInfo>) -> Result<(), DispatchError> - where - BalanceOf: FixedPointOperand, - { + pub fn enforce_limit( + &mut self, + info: Option<&mut ContractInfo>, + ) -> Result<(), DispatchError> { let deposit = self.own_contribution.update_contract(info); let total_deposit = self.total_deposit.saturating_add(&deposit); // We don't want to override a `Terminated` with a `Checked`. @@ -507,10 +496,7 @@ where pub fn enforce_subcall_limit( &mut self, info: Option<&mut ContractInfo>, - ) -> Result<(), DispatchError> - where - BalanceOf: FixedPointOperand, - { + ) -> Result<(), DispatchError> { match self.nested { Nested::OwnLimit => self.enforce_limit(info), Nested::DerivedLimit => Ok(()), diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 1ef9107557327..dbf90c75beb93 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -433,6 +433,7 @@ impl Config for Test { type Time = Timestamp; type Randomness = Randomness; type Currency = Balances; + type Balance = ::AccountId>>::Balance; type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; type CallFilter = TestFilter; diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index cee83bbe0b48b..a4f516d60ce50 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -48,7 +48,7 @@ use frame_support::{ }; use sp_api::HashT; use sp_core::Get; -use sp_runtime::{FixedPointOperand, RuntimeDebug}; +use sp_runtime::RuntimeDebug; use sp_std::prelude::*; use wasmi::{Instance, Linker, Memory, MemoryType, StackLimits, Store}; @@ -152,10 +152,7 @@ impl WasmBlob { schedule: &Schedule, owner: AccountIdOf, determinism: Determinism, - ) -> Result - where - BalanceOf: FixedPointOperand, - { + ) -> Result { prepare::prepare::( code.try_into().map_err(|_| (>::CodeTooLarge.into(), ""))?, schedule, @@ -376,10 +373,7 @@ impl Executable for WasmBlob { ext: &mut E, function: &ExportedFunction, input_data: Vec, - ) -> ExecResult - where - BalanceOf: FixedPointOperand, - { + ) -> ExecResult { let code = self.code.as_slice(); // Instantiate the Wasm module to the engine. let runtime = Runtime::new(ext, input_data); @@ -565,10 +559,7 @@ mod tests { value: u64, data: Vec, allows_reentry: bool, - ) -> Result - where - BalanceOf: FixedPointOperand, - { + ) -> Result { self.calls.push(CallEntry { to, value, data, allows_reentry }); Ok(ExecReturnValue { flags: ReturnFlags::empty(), data: call_return_data() }) } @@ -588,10 +579,7 @@ mod tests { value: u64, data: Vec, salt: &[u8], - ) -> Result<(AccountIdOf, ExecReturnValue), ExecError> - where - BalanceOf: FixedPointOperand, - { + ) -> Result<(AccountIdOf, ExecReturnValue), ExecError> { self.instantiates.push(InstantiateEntry { code_hash, value, diff --git a/frame/contracts/src/wasm/prepare.rs b/frame/contracts/src/wasm/prepare.rs index cf273d8e4469f..7a9ecb9e0e885 100644 --- a/frame/contracts/src/wasm/prepare.rs +++ b/frame/contracts/src/wasm/prepare.rs @@ -25,10 +25,10 @@ use crate::{ runtime::AllowDeprecatedInterface, CodeInfo, Determinism, Environment, WasmBlob, BYTES_PER_PAGE, }, - AccountIdOf, BalanceOf, CodeVec, Config, Error, Schedule, LOG_TARGET, + AccountIdOf, CodeVec, Config, Error, Schedule, LOG_TARGET, }; use codec::MaxEncodedLen; -use sp_runtime::{traits::Hash, DispatchError, FixedPointOperand}; +use sp_runtime::{traits::Hash, DispatchError}; #[cfg(any(test, feature = "runtime-benchmarks"))] use sp_std::prelude::Vec; use wasmi::{ @@ -281,7 +281,6 @@ pub fn prepare( where E: Environment<()>, T: Config, - BalanceOf: FixedPointOperand, { validate::(code.as_ref(), schedule, determinism)?; diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index 37340789ea3ac..4c5b98d8786d0 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -30,10 +30,7 @@ use frame_support::{dispatch::DispatchError, ensure, traits::Get, weights::Weigh use pallet_contracts_primitives::{ExecReturnValue, ReturnFlags}; use pallet_contracts_proc_macro::define_env; use sp_io::hashing::{blake2_128, blake2_256, keccak_256, sha2_256}; -use sp_runtime::{ - traits::{Bounded, Zero}, - FixedPointOperand, -}; +use sp_runtime::traits::{Bounded, Zero}; use sp_std::{fmt, prelude::*}; use wasmi::{core::HostError, errors::LinkerError, Linker, Memory, Store}; @@ -456,20 +453,14 @@ fn already_charged(_: u32) -> Option { } /// Can only be used for one call. -pub struct Runtime<'a, E: Ext + 'a> -where - BalanceOf: FixedPointOperand, -{ +pub struct Runtime<'a, E: Ext + 'a> { ext: &'a mut E, input_data: Option>, memory: Option, chain_extension: Option::ChainExtension>>, } -impl<'a, E: Ext + 'a> Runtime<'a, E> -where - BalanceOf: FixedPointOperand, -{ +impl<'a, E: Ext + 'a> Runtime<'a, E> { pub fn new(ext: &'a mut E, input_data: Vec) -> Self { Runtime { ext, @@ -881,10 +872,7 @@ where input_data_len: u32, output_ptr: u32, output_len_ptr: u32, - ) -> Result - where - BalanceOf<::T>: FixedPointOperand, - { + ) -> Result { self.charge_gas(call_type.cost())?; let input_data = if flags.contains(CallFlags::CLONE_INPUT) { let input = self.input_data.as_ref().ok_or(Error::::InputForwarded)?; @@ -968,10 +956,7 @@ where output_len_ptr: u32, salt_ptr: u32, salt_len: u32, - ) -> Result - where - BalanceOf<::T>: FixedPointOperand, - { + ) -> Result { self.charge_gas(RuntimeCosts::InstantiateBase { input_data_len, salt_len })?; let deposit_limit: BalanceOf<::T> = if deposit_ptr == SENTINEL { BalanceOf::<::T>::zero() From 50e0348921acaaf5d7b0bb68f47e4b6af6368315 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 25 Jul 2023 12:57:53 +0200 Subject: [PATCH 076/105] add Balance to Config --- bin/node/runtime/src/lib.rs | 1 + frame/contracts/src/tests.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index d90c6cad6c31b..5416ff8295322 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1229,6 +1229,7 @@ impl pallet_contracts::Config for Runtime { type Time = Timestamp; type Randomness = RandomnessCollectiveFlip; type Currency = Balances; + type Balance = Balance; type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; /// The safest default is to allow no calls at all. diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index dbf90c75beb93..60d68402d5b57 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -433,7 +433,7 @@ impl Config for Test { type Time = Timestamp; type Randomness = Randomness; type Currency = Balances; - type Balance = ::AccountId>>::Balance; + type Balance = u64; type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; type CallFilter = TestFilter; From a7417371321b3a693837755def8c91d43d72987a Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 25 Jul 2023 15:16:39 +0200 Subject: [PATCH 077/105] improve docs --- frame/contracts/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/contracts/README.md b/frame/contracts/README.md index bb890e52c5c0c..aeb30cef32fc8 100644 --- a/frame/contracts/README.md +++ b/frame/contracts/README.md @@ -9,8 +9,8 @@ The Contracts module provides functionality for the runtime to deploy and execut ## Overview -This module extends accounts based on the `fungible` traits to have smart-contract functionality. It can -be used with other modules that implement accounts based on `fungible`. These "smart-contract accounts" +This module extends accounts based on the [`frame_support::traits::fungible`] traits to have smart-contract functionality. It can +be used with other modules that implement accounts based on [`frame_support::traits::fungible`]. These "smart-contract accounts" have the ability to instantiate smart-contracts and make calls to other contract and non-contract accounts. The smart-contract code is stored once, and later retrievable via its `code_hash`. From 3950327e93eb6afcb806101c81795df90d72b2a6 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 25 Jul 2023 16:03:30 +0200 Subject: [PATCH 078/105] add new deposit storage error --- frame/contracts/src/lib.rs | 2 ++ frame/contracts/src/tests.rs | 2 +- frame/contracts/src/wasm/mod.rs | 3 +-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 340e00a18ff38..b5f371b1c5ca7 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -956,6 +956,8 @@ pub mod pallet { StorageDepositNotEnoughFunds, /// More storage was created than allowed by the storage deposit limit. StorageDepositLimitExhausted, + /// Some storage deposit could not be held. + StorageDepositNotHeld, /// Code removal was denied because the code is still in use by at least one contract. CodeInUse, /// The contract ran to completion but decided to revert its storage changes. diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 60d68402d5b57..babf4ffdb71be 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -3561,7 +3561,7 @@ fn upload_code_not_enough_balance() { Some(codec::Compact(1_000)), Determinism::Enforced ), - >::StorageDepositNotEnoughFunds, + >::StorageDepositNotHeld, ); assert_eq!(System::events(), vec![]); diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index a4f516d60ce50..e0cf3cdaffbf5 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -249,8 +249,7 @@ impl WasmBlob { // TODO: better error mapping .map_err(|_| { let _ = System::::dec_providers(&self.code_info.owner); - - >::StorageDepositNotEnoughFunds + >::StorageDepositNotHeld })?; >::deposit_event( From 0a790a6bb9d9dbbe459a6ad0bb6c9d81c15423ac Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 25 Jul 2023 17:22:13 +0200 Subject: [PATCH 079/105] remove todo message --- frame/contracts/src/wasm/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index e0cf3cdaffbf5..7ed743479e48b 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -246,7 +246,6 @@ impl WasmBlob { &self.code_info.owner, deposit, ) - // TODO: better error mapping .map_err(|_| { let _ = System::::dec_providers(&self.code_info.owner); >::StorageDepositNotHeld From 0c574516badf6ac9d260c96a23466a8086d8e9d3 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Wed, 26 Jul 2023 16:51:36 +0200 Subject: [PATCH 080/105] rename migration v13 pre rebase --- frame/contracts/src/benchmarking/mod.rs | 10 +- frame/contracts/src/migration.rs | 2 +- frame/contracts/src/migration/v13.rs | 283 ------------------------ frame/contracts/src/weights.rs | 6 +- 4 files changed, 9 insertions(+), 292 deletions(-) delete mode 100644 frame/contracts/src/migration/v13.rs diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 43a41c889c300..fddc145643bf4 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -30,7 +30,7 @@ use self::{ }; use crate::{ exec::{AccountIdOf, Key}, - migration::{v09, v10, v11, v12, v13, MigrationStep}, + migration::{v09, v10, v11, v12, v14, MigrationStep}, wasm::CallFlags, Pallet as Contracts, *, }; @@ -288,15 +288,15 @@ benchmarks! { m.step(); } - // This benchmarks the v13 migration step (Move code owners' reserved balance to be held instead). + // This benchmarks the v14 migration step (Move code owners' reserved balance to be held instead). #[pov_mode = Measured] - v13_migration_step { - v13::store_dummy_code::< + v14_migration_step { + v14::store_dummy_code::< T, pallet_balances::Pallet >(); - let mut m = v13::Migration::>::default(); + let mut m = v14::Migration::>::default(); }: { m.step(); } diff --git a/frame/contracts/src/migration.rs b/frame/contracts/src/migration.rs index b082f4f29ddfa..a2f334f764517 100644 --- a/frame/contracts/src/migration.rs +++ b/frame/contracts/src/migration.rs @@ -61,7 +61,7 @@ pub mod v09; pub mod v10; pub mod v11; pub mod v12; -pub mod v13; +pub mod v14; use crate::{weights::WeightInfo, Config, Error, MigrationInProgress, Pallet, Weight, LOG_TARGET}; use codec::{Codec, Decode}; diff --git a/frame/contracts/src/migration/v13.rs b/frame/contracts/src/migration/v13.rs deleted file mode 100644 index 597e659d95ef6..0000000000000 --- a/frame/contracts/src/migration/v13.rs +++ /dev/null @@ -1,283 +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. - -//! Update the code owner balance, make the storage deposit reserved balance to be held instead. - -use crate::{ - exec::AccountIdOf, - migration::{IsFinished, MigrationStep}, - weights::WeightInfo, - BalanceOf, CodeHash, Config, Determinism, HoldReason, Pallet, Weight, LOG_TARGET, -}; -use codec::{Decode, Encode}; -#[cfg(feature = "try-runtime")] -use environmental::Vec; -#[cfg(feature = "try-runtime")] -use frame_support::traits::fungible::Inspect; -#[cfg(feature = "try-runtime")] -use frame_support::traits::fungible::InspectHold; -use frame_support::{ - codec, - pallet_prelude::*, - storage_alias, - traits::{fungible::MutateHold, ReservableCurrency}, - DefaultNoBound, -}; -use sp_core::hexdisplay::HexDisplay; -#[cfg(feature = "try-runtime")] -use sp_runtime::TryRuntimeError; -use sp_runtime::{traits::Zero, Saturating}; -#[cfg(feature = "try-runtime")] -use sp_std::collections::btree_map::BTreeMap; - -mod old { - use super::*; - - pub type BalanceOf = ::AccountId, - >>::Balance; - - #[derive(Encode, Decode, scale_info::TypeInfo, MaxEncodedLen)] - #[codec(mel_bound())] - #[scale_info(skip_type_params(T, OldCurrency))] - pub struct CodeInfo - where - T: Config, - OldCurrency: ReservableCurrency<::AccountId>, - { - pub owner: AccountIdOf, - #[codec(compact)] - pub deposit: old::BalanceOf, - #[codec(compact)] - pub refcount: u64, - pub determinism: Determinism, - pub code_len: u32, - } - - #[storage_alias] - pub type CodeInfoOf = - StorageMap, Twox64Concat, CodeHash, CodeInfo>; -} - -#[cfg(feature = "runtime-benchmarks")] -pub fn store_dummy_code() -where - T: Config, - OldCurrency: ReservableCurrency<::AccountId> + 'static, -{ - use frame_benchmarking::account; - use sp_runtime::traits::Hash; - use sp_std::vec; - - let len = T::MaxCodeLen::get(); - let code = vec![42u8; len as usize]; - let hash = T::Hashing::hash(&code); - - let info = old::CodeInfo { - owner: account::("account", 0, 0), - deposit: u32::MAX.into(), - refcount: u64::MAX, - determinism: Determinism::Enforced, - code_len: len, - }; - old::CodeInfoOf::::insert(hash, info); -} - -#[cfg(feature = "try-runtime")] -#[derive(Encode, Decode)] -/// Accounts for the balance allocation of a code owner. -struct BalanceAllocation -where - T: Config, - OldCurrency: ReservableCurrency<::AccountId>, -{ - /// Total reserved balance as storage deposit for the owner. - reserved: old::BalanceOf, - /// Total balance of the owner. - total: old::BalanceOf, -} - -#[derive(Encode, Decode, MaxEncodedLen, DefaultNoBound)] -pub struct Migration -where - T: Config, - OldCurrency: ReservableCurrency<::AccountId>, -{ - last_code_hash: Option>, - _phantom: PhantomData<(T, OldCurrency)>, -} - -impl MigrationStep for Migration -where - T: Config, - OldCurrency: 'static + ReservableCurrency<::AccountId>, -{ - const VERSION: u16 = 13; - - fn max_step_weight() -> Weight { - T::WeightInfo::v13_migration_step() - } - - fn step(&mut self) -> (IsFinished, Weight) { - let mut iter = if let Some(last_hash) = self.last_code_hash.take() { - old::CodeInfoOf::::iter_from( - old::CodeInfoOf::::hashed_key_for(last_hash), - ) - } else { - old::CodeInfoOf::::iter() - }; - - if let Some((hash, code_info)) = iter.next() { - log::debug!(target: LOG_TARGET, "Migrating storage deposit for 0x{:?}", HexDisplay::from(&code_info.owner.encode())); - - let remaining = OldCurrency::unreserve(&code_info.owner, code_info.deposit); - - if remaining > Zero::zero() { - log::warn!( - target: LOG_TARGET, - "Code owner's account 0x{:?} for code {:?} has some non-unreservable deposit {:?} from a total of {:?} that will remain in reserved.", - HexDisplay::from(&code_info.owner.encode()), - hash, - remaining, - code_info.deposit - ); - } - - let unreserved = code_info.deposit.saturating_sub(remaining); - - let amount = if let Ok(amount) = BalanceOf::::decode(&mut &unreserved.encode()[..]) { - amount - } else { - log::error!( - target: LOG_TARGET, - "Failed to decode unreserved amount {:?} for code {:?}.", - unreserved, - hash - ); - Zero::zero() - }; - - T::Currency::hold(&HoldReason::StorageDepositReserve.into(), &code_info.owner, amount) - .map(|_| { - log::debug!( - target: LOG_TARGET, - "{:?} held on the code owner's account 0x{:?} for code {:?}.", - unreserved, - HexDisplay::from(&code_info.owner.encode()), - hash, - ); - }) - .unwrap_or_else(|err| { - log::error!( - target: LOG_TARGET, - "Failed to hold {:?} from the code owner's account 0x{:?} for code {:?}, reason: {:?}.", - unreserved, - HexDisplay::from(&code_info.owner.encode()), - hash, - err - ); - }); - - self.last_code_hash = Some(hash); - (IsFinished::No, T::WeightInfo::v13_migration_step()) - } else { - log::debug!(target: LOG_TARGET, "No more storage deposit to migrate"); - (IsFinished::Yes, T::WeightInfo::v13_migration_step()) - } - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade_step() -> Result, TryRuntimeError> { - let info: Vec<_> = old::CodeInfoOf::::iter().collect(); - - let mut owner_balance_allocation = - BTreeMap::, BalanceAllocation>::new(); - - // Calculates the balance allocation by accumulating the storage deposits of all codes owned - // by an owner. - for (_, code_info) in info { - owner_balance_allocation - .entry(code_info.owner.clone()) - .and_modify(|alloc| { - alloc.reserved = alloc.reserved.saturating_add(code_info.deposit); - }) - .or_insert(BalanceAllocation { - reserved: code_info.deposit, - total: OldCurrency::total_balance(&code_info.owner), - }); - } - - Ok(owner_balance_allocation.encode()) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade_step(state: Vec) -> Result<(), TryRuntimeError> { - let owner_balance_allocation = - , BalanceAllocation> as Decode>::decode( - &mut &state[..], - ) - .expect("pre_upgrade_step provides a valid state; qed"); - - let mut total_held: BalanceOf = Zero::zero(); - let count = owner_balance_allocation.len(); - for (owner, old_balance_allocation) in owner_balance_allocation { - let held = - T::Currency::balance_on_hold(&HoldReason::StorageDepositReserve.into(), &owner); - log::debug!( - target: LOG_TARGET, - "Validating storage deposit for owner 0x{:?}, reserved: {:?}, held: {:?}", - HexDisplay::from(&owner.encode()), - old_balance_allocation.reserved, - held - ); - ensure!( - held == BalanceOf::::decode(&mut &old_balance_allocation.reserved.encode()[..]) - .unwrap(), - "Held amount mismatch" - ); - - log::debug!( - target: LOG_TARGET, - "Validating total balance for owner 0x{:?}, new: {:?}, old: {:?}", - HexDisplay::from(&owner.encode()), - T::Currency::total_balance(&owner), - old_balance_allocation.total - ); - ensure!( - T::Currency::total_balance(&owner) == - BalanceOf::::decode(&mut &old_balance_allocation.total.encode()[..]) - .unwrap(), - "Balance mismatch " - ); - total_held += held; - } - - log::info!( - target: LOG_TARGET, - "Code owners processed: {:?}.", - count - ); - - log::info!( - target: LOG_TARGET, - "Total held amount for storage deposit: {:?}", - total_held - ); - - Ok(()) - } -} diff --git a/frame/contracts/src/weights.rs b/frame/contracts/src/weights.rs index 1c13fe31ed66b..a95564512f555 100644 --- a/frame/contracts/src/weights.rs +++ b/frame/contracts/src/weights.rs @@ -55,7 +55,7 @@ pub trait WeightInfo { fn v10_migration_step() -> Weight; fn v11_migration_step(k: u32, ) -> Weight; fn v12_migration_step(c: u32, ) -> Weight; - fn v13_migration_step() -> Weight; + fn v14_migration_step() -> Weight; fn migration_noop() -> Weight; fn migrate() -> Weight; fn on_runtime_upgrade_noop() -> Weight; @@ -229,7 +229,7 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) - fn v13_migration_step() -> Weight { + fn v14_migration_step() -> Weight { // Proof Size summary in bytes: // Measured: `260` // Estimated: `6200` @@ -2030,7 +2030,7 @@ impl WeightInfo for () { /// Proof: `Contracts::CodeInfoOf` (`max_values`: None, `max_size`: Some(93), added: 2568, mode: `Measured`) /// Storage: `System::Account` (r:1 w:0) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `Measured`) - fn v13_migration_step() -> Weight { + fn v14_migration_step() -> Weight { // Proof Size summary in bytes: // Measured: `260` // Estimated: `6200` From 560d190ce50a4d226bf6a59bb255c643fa8a1849 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Wed, 26 Jul 2023 17:57:43 +0200 Subject: [PATCH 081/105] fix tests --- frame/contracts/src/storage/meter.rs | 1 + frame/contracts/src/tests.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/frame/contracts/src/storage/meter.rs b/frame/contracts/src/storage/meter.rs index baf2945b0b47a..4ff39ed672d0f 100644 --- a/frame/contracts/src/storage/meter.rs +++ b/frame/contracts/src/storage/meter.rs @@ -538,6 +538,7 @@ impl Ext for ReservingExt { terminated: bool, ) -> Result<(), DispatchError> { match amount { + Deposit::Charge(amount) | Deposit::Refund(amount) if amount.is_zero() => return Ok(()), Deposit::Charge(amount) => { T::Currency::transfer(origin, deposit_account, *amount, Preservation::Protect)?; Ok(()) diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 0db431809a859..77cbbd78533ba 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -5452,7 +5452,7 @@ fn add_remove_delegate_dependency_works() { const ED: u64 = 2000; ExtBuilder::default().existential_deposit(ED).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); // Instantiate with add_delegate_dependency should fail since the code is not yet on chain. assert_err!( @@ -5557,7 +5557,7 @@ fn native_dependency_deposit_works() { // Test with both existing and uploaded code for code in [Code::Upload(wasm.clone()), Code::Existing(code_hash)] { ExtBuilder::default().existential_deposit(ED).build().execute_with(|| { - let _ = Balances::deposit_creating(&ALICE, 1_000_000); + let _ = Balances::set_balance(&ALICE, 1_000_000); let lockup_deposit_percent = CodeHashLockupDepositPercent::get(); let per_byte = DepositPerByte::get(); let per_item = DepositPerItem::get(); From ed3b399364612ca07a2c444bef1ccfd5051fa107 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Wed, 26 Jul 2023 17:58:21 +0200 Subject: [PATCH 082/105] add missing migration; --- frame/contracts/src/migration/v14.rs | 283 +++++++++++++++++++++++++++ 1 file changed, 283 insertions(+) create mode 100644 frame/contracts/src/migration/v14.rs diff --git a/frame/contracts/src/migration/v14.rs b/frame/contracts/src/migration/v14.rs new file mode 100644 index 0000000000000..33ebd786acd2e --- /dev/null +++ b/frame/contracts/src/migration/v14.rs @@ -0,0 +1,283 @@ +// 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. + +//! Update the code owner balance, make the storage deposit reserved balance to be held instead. + +use crate::{ + exec::AccountIdOf, + migration::{IsFinished, MigrationStep}, + weights::WeightInfo, + BalanceOf, CodeHash, Config, Determinism, HoldReason, Pallet, Weight, LOG_TARGET, +}; +use codec::{Decode, Encode}; +#[cfg(feature = "try-runtime")] +use environmental::Vec; +#[cfg(feature = "try-runtime")] +use frame_support::traits::fungible::Inspect; +#[cfg(feature = "try-runtime")] +use frame_support::traits::fungible::InspectHold; +use frame_support::{ + codec, + pallet_prelude::*, + storage_alias, + traits::{fungible::MutateHold, ReservableCurrency}, + DefaultNoBound, +}; +use sp_core::hexdisplay::HexDisplay; +#[cfg(feature = "try-runtime")] +use sp_runtime::TryRuntimeError; +use sp_runtime::{traits::Zero, Saturating}; +#[cfg(feature = "try-runtime")] +use sp_std::collections::btree_map::BTreeMap; + +mod old { + use super::*; + + pub type BalanceOf = ::AccountId, + >>::Balance; + + #[derive(Encode, Decode, scale_info::TypeInfo, MaxEncodedLen)] + #[codec(mel_bound())] + #[scale_info(skip_type_params(T, OldCurrency))] + pub struct CodeInfo + where + T: Config, + OldCurrency: ReservableCurrency<::AccountId>, + { + pub owner: AccountIdOf, + #[codec(compact)] + pub deposit: old::BalanceOf, + #[codec(compact)] + pub refcount: u64, + pub determinism: Determinism, + pub code_len: u32, + } + + #[storage_alias] + pub type CodeInfoOf = + StorageMap, Twox64Concat, CodeHash, CodeInfo>; +} + +#[cfg(feature = "runtime-benchmarks")] +pub fn store_dummy_code() +where + T: Config, + OldCurrency: ReservableCurrency<::AccountId> + 'static, +{ + use frame_benchmarking::account; + use sp_runtime::traits::Hash; + use sp_std::vec; + + let len = T::MaxCodeLen::get(); + let code = vec![42u8; len as usize]; + let hash = T::Hashing::hash(&code); + + let info = old::CodeInfo { + owner: account::("account", 0, 0), + deposit: u32::MAX.into(), + refcount: u64::MAX, + determinism: Determinism::Enforced, + code_len: len, + }; + old::CodeInfoOf::::insert(hash, info); +} + +#[cfg(feature = "try-runtime")] +#[derive(Encode, Decode)] +/// Accounts for the balance allocation of a code owner. +struct BalanceAllocation +where + T: Config, + OldCurrency: ReservableCurrency<::AccountId>, +{ + /// Total reserved balance as storage deposit for the owner. + reserved: old::BalanceOf, + /// Total balance of the owner. + total: old::BalanceOf, +} + +#[derive(Encode, Decode, MaxEncodedLen, DefaultNoBound)] +pub struct Migration +where + T: Config, + OldCurrency: ReservableCurrency<::AccountId>, +{ + last_code_hash: Option>, + _phantom: PhantomData<(T, OldCurrency)>, +} + +impl MigrationStep for Migration +where + T: Config, + OldCurrency: 'static + ReservableCurrency<::AccountId>, +{ + const VERSION: u16 = 14; + + fn max_step_weight() -> Weight { + T::WeightInfo::v14_migration_step() + } + + fn step(&mut self) -> (IsFinished, Weight) { + let mut iter = if let Some(last_hash) = self.last_code_hash.take() { + old::CodeInfoOf::::iter_from( + old::CodeInfoOf::::hashed_key_for(last_hash), + ) + } else { + old::CodeInfoOf::::iter() + }; + + if let Some((hash, code_info)) = iter.next() { + log::debug!(target: LOG_TARGET, "Migrating storage deposit for 0x{:?}", HexDisplay::from(&code_info.owner.encode())); + + let remaining = OldCurrency::unreserve(&code_info.owner, code_info.deposit); + + if remaining > Zero::zero() { + log::warn!( + target: LOG_TARGET, + "Code owner's account 0x{:?} for code {:?} has some non-unreservable deposit {:?} from a total of {:?} that will remain in reserved.", + HexDisplay::from(&code_info.owner.encode()), + hash, + remaining, + code_info.deposit + ); + } + + let unreserved = code_info.deposit.saturating_sub(remaining); + + let amount = if let Ok(amount) = BalanceOf::::decode(&mut &unreserved.encode()[..]) { + amount + } else { + log::error!( + target: LOG_TARGET, + "Failed to decode unreserved amount {:?} for code {:?}.", + unreserved, + hash + ); + Zero::zero() + }; + + T::Currency::hold(&HoldReason::StorageDepositReserve.into(), &code_info.owner, amount) + .map(|_| { + log::debug!( + target: LOG_TARGET, + "{:?} held on the code owner's account 0x{:?} for code {:?}.", + unreserved, + HexDisplay::from(&code_info.owner.encode()), + hash, + ); + }) + .unwrap_or_else(|err| { + log::error!( + target: LOG_TARGET, + "Failed to hold {:?} from the code owner's account 0x{:?} for code {:?}, reason: {:?}.", + unreserved, + HexDisplay::from(&code_info.owner.encode()), + hash, + err + ); + }); + + self.last_code_hash = Some(hash); + (IsFinished::No, T::WeightInfo::v14_migration_step()) + } else { + log::debug!(target: LOG_TARGET, "No more storage deposit to migrate"); + (IsFinished::Yes, T::WeightInfo::v14_migration_step()) + } + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade_step() -> Result, TryRuntimeError> { + let info: Vec<_> = old::CodeInfoOf::::iter().collect(); + + let mut owner_balance_allocation = + BTreeMap::, BalanceAllocation>::new(); + + // Calculates the balance allocation by accumulating the storage deposits of all codes owned + // by an owner. + for (_, code_info) in info { + owner_balance_allocation + .entry(code_info.owner.clone()) + .and_modify(|alloc| { + alloc.reserved = alloc.reserved.saturating_add(code_info.deposit); + }) + .or_insert(BalanceAllocation { + reserved: code_info.deposit, + total: OldCurrency::total_balance(&code_info.owner), + }); + } + + Ok(owner_balance_allocation.encode()) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade_step(state: Vec) -> Result<(), TryRuntimeError> { + let owner_balance_allocation = + , BalanceAllocation> as Decode>::decode( + &mut &state[..], + ) + .expect("pre_upgrade_step provides a valid state; qed"); + + let mut total_held: BalanceOf = Zero::zero(); + let count = owner_balance_allocation.len(); + for (owner, old_balance_allocation) in owner_balance_allocation { + let held = + T::Currency::balance_on_hold(&HoldReason::StorageDepositReserve.into(), &owner); + log::debug!( + target: LOG_TARGET, + "Validating storage deposit for owner 0x{:?}, reserved: {:?}, held: {:?}", + HexDisplay::from(&owner.encode()), + old_balance_allocation.reserved, + held + ); + ensure!( + held == BalanceOf::::decode(&mut &old_balance_allocation.reserved.encode()[..]) + .unwrap(), + "Held amount mismatch" + ); + + log::debug!( + target: LOG_TARGET, + "Validating total balance for owner 0x{:?}, new: {:?}, old: {:?}", + HexDisplay::from(&owner.encode()), + T::Currency::total_balance(&owner), + old_balance_allocation.total + ); + ensure!( + T::Currency::total_balance(&owner) == + BalanceOf::::decode(&mut &old_balance_allocation.total.encode()[..]) + .unwrap(), + "Balance mismatch " + ); + total_held += held; + } + + log::info!( + target: LOG_TARGET, + "Code owners processed: {:?}.", + count + ); + + log::info!( + target: LOG_TARGET, + "Total held amount for storage deposit: {:?}", + total_held + ); + + Ok(()) + } +} From 8186e21dc749822cdbbc78e17529d90e2ab51d03 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 27 Jul 2023 11:06:45 +0200 Subject: [PATCH 083/105] bump storage version --- 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 51c6d7a4f686e..36e7236707bdc 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -189,7 +189,7 @@ pub mod pallet { /// The current storage version. #[cfg(not(any(test, feature = "runtime-benchmarks")))] - const STORAGE_VERSION: StorageVersion = StorageVersion::new(13); + const STORAGE_VERSION: StorageVersion = StorageVersion::new(14); /// Hard coded storage version for running tests that depend on the current storage version. #[cfg(any(test, feature = "runtime-benchmarks"))] From 08619a05f7f57e57d967a0dc25745cb40d965705 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 27 Jul 2023 11:55:55 +0200 Subject: [PATCH 084/105] apply review suggestions --- frame/contracts/src/benchmarking/mod.rs | 1 + frame/contracts/src/wasm/mod.rs | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 15c3b9bc6b719..5cbdf6a98e50b 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -177,6 +177,7 @@ where /// The funding that each account that either calls or instantiates contracts is funded with. fn caller_funding() -> BalanceOf { + // Minting can overflow, so we can't abuse of the funding. BalanceOf::::max_value() / 10_000u32.into() } diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index 3d897fac28317..c4f724a06fae3 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -239,8 +239,6 @@ impl WasmBlob { None => { let deposit = self.code_info.deposit; System::::inc_providers(&self.code_info.owner); - // This `None` case happens only in freshly uploaded modules. This means that - // the `owner` is always the origin of the current transaction. T::Currency::hold( &HoldReason::StorageDepositReserve.into(), &self.code_info.owner, From 9435d4b959d26506c3d681ae8915161fc1e1e99b Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 27 Jul 2023 12:24:33 +0200 Subject: [PATCH 085/105] improved comment --- frame/contracts/src/benchmarking/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 5cbdf6a98e50b..34efa29c7fc12 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -177,7 +177,8 @@ where /// The funding that each account that either calls or instantiates contracts is funded with. fn caller_funding() -> BalanceOf { - // Minting can overflow, so we can't abuse of the funding. + // Minting can overflow, so we can't abuse of the funding. This value happens to be big enough, + // but not too big to make the total supply overflow. BalanceOf::::max_value() / 10_000u32.into() } From 06f79413336520284b2722ad8d3725c639f9a954 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 27 Jul 2023 14:05:54 +0200 Subject: [PATCH 086/105] remove unnecessary code --- frame/contracts/src/wasm/mod.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index c4f724a06fae3..be00ac611211d 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -38,7 +38,7 @@ use crate::{ wasm::prepare::LoadedModule, weights::WeightInfo, AccountIdOf, BadOrigin, BalanceOf, CodeHash, CodeInfoOf, CodeVec, Config, Error, Event, - HoldReason, Pallet, PristineCode, Schedule, System, Weight, LOG_TARGET, + HoldReason, Pallet, PristineCode, Schedule, Weight, LOG_TARGET, }; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ @@ -238,16 +238,12 @@ impl WasmBlob { // the `owner` is always the origin of the current transaction. None => { let deposit = self.code_info.deposit; - System::::inc_providers(&self.code_info.owner); T::Currency::hold( &HoldReason::StorageDepositReserve.into(), &self.code_info.owner, deposit, ) - .map_err(|_| { - let _ = System::::dec_providers(&self.code_info.owner); - >::StorageDepositNotHeld - })?; + .map_err(|_| >::StorageDepositNotHeld)?; >::deposit_event( vec![T::Hashing::hash_of(&self.code_info.owner)], @@ -280,8 +276,6 @@ impl WasmBlob { BestEffort, ); - let _ = System::::dec_providers(&code_info.owner); - >::deposit_event( vec![T::Hashing::hash_of(&code_info.owner)], Event::StorageDepositReleased { From eec1d20b6bc56219911c525d580b33367ea4e35f Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Thu, 27 Jul 2023 15:57:26 +0200 Subject: [PATCH 087/105] simplify migrations --- frame/contracts/src/benchmarking/mod.rs | 56 ++++++--------------- frame/contracts/src/migration/v10.rs | 19 ++------ frame/contracts/src/migration/v12.rs | 31 +++--------- frame/contracts/src/migration/v14.rs | 65 ++++++++++--------------- frame/contracts/src/weights.rs | 2 +- 5 files changed, 51 insertions(+), 122 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 34efa29c7fc12..ee6bf3ccb0772 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -37,10 +37,7 @@ use crate::{ use codec::{Encode, MaxEncodedLen}; use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; use frame_support::{ - self, - pallet_prelude::StorageVersion, - traits::{fungible::InspectHold, ReservableCurrency}, - weights::Weight, + self, pallet_prelude::StorageVersion, traits::fungible::InspectHold, weights::Weight, }; use frame_system::RawOrigin; use pallet_balances; @@ -261,44 +258,9 @@ benchmarks! { #[pov_mode = Measured] v12_migration_step { let c in 0 .. T::MaxCodeLen::get(); - v12::store_old_dummy_code::< - T, - pallet_balances::Pallet - >(c as usize, account::("account", 0, 0)); - - struct OldDepositPerItem(PhantomData<(T,Currency)>); - - type OldDepositPerByte = OldDepositPerItem; - - impl Get> for OldDepositPerItem - where - T: Config, - Currency: ReservableCurrency<::AccountId>, - { - fn get() -> v12::old::BalanceOf { - v12::old::BalanceOf::::default() - } - } - - let mut m = v12::Migration::< - T, - pallet_balances::Pallet, - OldDepositPerItem>, - OldDepositPerByte> - >::default(); - }: { - m.step(); - } - - // This benchmarks the v14 migration step (Move code owners' reserved balance to be held instead). - #[pov_mode = Measured] - v14_migration_step { - v14::store_dummy_code::< - T, - pallet_balances::Pallet - >(); - - let mut m = v14::Migration::>::default(); + type Balances = (); + v12::store_old_dummy_code::(c as usize, account::("account", 0, 0)); + let mut m = v12::Migration::::default(); }: { m.step(); } @@ -316,6 +278,16 @@ benchmarks! { m.step(); } + // This benchmarks the v14 migration step (Move code owners' reserved balance to be held instead). + #[pov_mode = Measured] + v14_migration_step { + type Balances = (); + v14::store_dummy_code::(); + let mut m = v14::Migration::::default(); + }: { + m.step(); + } + // This benchmarks the weight of executing Migration::migrate to execute a noop migration. #[pov_mode = Measured] migration_noop { diff --git a/frame/contracts/src/migration/v10.rs b/frame/contracts/src/migration/v10.rs index fb8d5b926810c..3fc7cabe94942 100644 --- a/frame/contracts/src/migration/v10.rs +++ b/frame/contracts/src/migration/v10.rs @@ -54,11 +54,7 @@ mod old { #[scale_info(skip_type_params(T, OldCurrency))] pub struct ContractInfo where - OldCurrency: ReservableCurrency<::AccountId> - + Inspect< - ::AccountId, - Balance = old::BalanceOf, - >, + OldCurrency: ReservableCurrency<::AccountId>, { pub trie_id: TrieId, pub code_hash: CodeHash, @@ -83,9 +79,7 @@ pub fn store_old_contract_info( account: T::AccountId, info: crate::ContractInfo, ) where - OldCurrency: ReservableCurrency<::AccountId> - + Inspect<::AccountId, Balance = old::BalanceOf> - + 'static, + OldCurrency: ReservableCurrency<::AccountId> + 'static, { let info = old::ContractInfo { trie_id: info.trie_id, @@ -115,8 +109,7 @@ impl Deref for DepositAccount { #[scale_info(skip_type_params(T, OldCurrency))] pub struct ContractInfo where - OldCurrency: ReservableCurrency<::AccountId> - + Inspect<::AccountId, Balance = old::BalanceOf>, + OldCurrency: ReservableCurrency<::AccountId>, { pub trie_id: TrieId, deposit_account: DepositAccount, @@ -129,11 +122,7 @@ where } #[derive(Encode, Decode, MaxEncodedLen, DefaultNoBound)] -pub struct Migration -where - OldCurrency: ReservableCurrency<::AccountId> - + Inspect<::AccountId, Balance = old::BalanceOf>, -{ +pub struct Migration { last_account: Option, _phantom: PhantomData<(T, OldCurrency)>, } diff --git a/frame/contracts/src/migration/v12.rs b/frame/contracts/src/migration/v12.rs index 7ced58e6e1c07..070559a2e25b7 100644 --- a/frame/contracts/src/migration/v12.rs +++ b/frame/contracts/src/migration/v12.rs @@ -25,11 +25,7 @@ use crate::{ }; use codec::{Decode, Encode}; use frame_support::{ - codec, - pallet_prelude::*, - storage_alias, - traits::{fungible::Inspect, ReservableCurrency}, - DefaultNoBound, Identity, + codec, pallet_prelude::*, storage_alias, traits::ReservableCurrency, DefaultNoBound, Identity, }; use scale_info::prelude::format; use sp_core::hexdisplay::HexDisplay; @@ -50,11 +46,7 @@ pub mod old { #[scale_info(skip_type_params(T, OldCurrency))] pub struct OwnerInfo where - OldCurrency: ReservableCurrency<::AccountId> - + Inspect< - ::AccountId, - Balance = old::BalanceOf, - >, + OldCurrency: ReservableCurrency<::AccountId>, { pub owner: AccountIdOf, #[codec(compact)] @@ -91,8 +83,7 @@ pub mod old { #[scale_info(skip_type_params(T, OldCurrency))] pub struct CodeInfo where - OldCurrency: ReservableCurrency<::AccountId> - + Inspect<::AccountId, Balance = old::BalanceOf>, + OldCurrency: ReservableCurrency<::AccountId>, { owner: AccountIdOf, #[codec(compact)] @@ -111,12 +102,7 @@ pub type CodeInfoOf = pub type PristineCode = StorageMap, Identity, CodeHash, Vec>; #[cfg(feature = "runtime-benchmarks")] -pub fn store_old_dummy_code(len: usize, account: T::AccountId) -where - OldCurrency: ReservableCurrency<::AccountId> - + Inspect<::AccountId, Balance = old::BalanceOf> - + 'static, -{ +pub fn store_old_dummy_code(len: usize, account: T::AccountId) { use sp_runtime::traits::Hash; let code = vec![42u8; len]; @@ -133,14 +119,13 @@ where old::CodeStorage::::insert(hash, module); let info = old::OwnerInfo { owner: account, deposit: u32::MAX.into(), refcount: u64::MAX }; - old::OwnerInfoOf::::insert(hash, info); + old::OwnerInfoOf::::insert(hash, info); } #[derive(Encode, Decode, MaxEncodedLen, DefaultNoBound)] pub struct Migration where - OldCurrency: ReservableCurrency<::AccountId> - + Inspect<::AccountId, Balance = old::BalanceOf>, + OldCurrency: ReservableCurrency<::AccountId>, OldDepositPerByte: Get>, OldDepositPerItem: Get>, { @@ -151,9 +136,7 @@ where impl MigrationStep for Migration where - OldCurrency: ReservableCurrency<::AccountId> - + Inspect<::AccountId, Balance = old::BalanceOf> - + 'static, + OldCurrency: ReservableCurrency<::AccountId> + 'static, OldDepositPerByte: Get>, OldDepositPerItem: Get>, { diff --git a/frame/contracts/src/migration/v14.rs b/frame/contracts/src/migration/v14.rs index 33ebd786acd2e..a53094cb246d7 100644 --- a/frame/contracts/src/migration/v14.rs +++ b/frame/contracts/src/migration/v14.rs @@ -44,7 +44,7 @@ use sp_runtime::{traits::Zero, Saturating}; #[cfg(feature = "try-runtime")] use sp_std::collections::btree_map::BTreeMap; -mod old { +pub mod old { use super::*; pub type BalanceOf = () -where - T: Config, - OldCurrency: ReservableCurrency<::AccountId> + 'static, -{ +pub fn store_dummy_code() { use frame_benchmarking::account; use sp_runtime::traits::Hash; use sp_std::vec; @@ -94,7 +90,7 @@ where determinism: Determinism::Enforced, code_len: len, }; - old::CodeInfoOf::::insert(hash, info); + old::CodeInfoOf::::insert(hash, info); } #[cfg(feature = "try-runtime")] @@ -125,6 +121,7 @@ impl MigrationStep for Migration where T: Config, OldCurrency: 'static + ReservableCurrency<::AccountId>, + BalanceOf: From>, { const VERSION: u16 = 14; @@ -159,38 +156,30 @@ where let unreserved = code_info.deposit.saturating_sub(remaining); - let amount = if let Ok(amount) = BalanceOf::::decode(&mut &unreserved.encode()[..]) { - amount - } else { + T::Currency::hold( + &HoldReason::StorageDepositReserve.into(), + &code_info.owner, + unreserved.into(), + ) + .map(|_| { + log::debug!( + target: LOG_TARGET, + "{:?} held on the code owner's account 0x{:?} for code {:?}.", + unreserved, + HexDisplay::from(&code_info.owner.encode()), + hash, + ); + }) + .unwrap_or_else(|err| { log::error!( target: LOG_TARGET, - "Failed to decode unreserved amount {:?} for code {:?}.", + "Failed to hold {:?} from the code owner's account 0x{:?} for code {:?}, reason: {:?}.", unreserved, - hash + HexDisplay::from(&code_info.owner.encode()), + hash, + err ); - Zero::zero() - }; - - T::Currency::hold(&HoldReason::StorageDepositReserve.into(), &code_info.owner, amount) - .map(|_| { - log::debug!( - target: LOG_TARGET, - "{:?} held on the code owner's account 0x{:?} for code {:?}.", - unreserved, - HexDisplay::from(&code_info.owner.encode()), - hash, - ); - }) - .unwrap_or_else(|err| { - log::error!( - target: LOG_TARGET, - "Failed to hold {:?} from the code owner's account 0x{:?} for code {:?}, reason: {:?}.", - unreserved, - HexDisplay::from(&code_info.owner.encode()), - hash, - err - ); - }); + }); self.last_code_hash = Some(hash); (IsFinished::No, T::WeightInfo::v14_migration_step()) @@ -244,11 +233,7 @@ where old_balance_allocation.reserved, held ); - ensure!( - held == BalanceOf::::decode(&mut &old_balance_allocation.reserved.encode()[..]) - .unwrap(), - "Held amount mismatch" - ); + ensure!(held == old_balance_allocation.reserved.into(), "Held amount mismatch"); log::debug!( target: LOG_TARGET, diff --git a/frame/contracts/src/weights.rs b/frame/contracts/src/weights.rs index eda67b850e38c..d8f873b0615be 100644 --- a/frame/contracts/src/weights.rs +++ b/frame/contracts/src/weights.rs @@ -55,8 +55,8 @@ pub trait WeightInfo { fn v10_migration_step() -> Weight; fn v11_migration_step(k: u32, ) -> Weight; fn v12_migration_step(c: u32, ) -> Weight; - fn v14_migration_step() -> Weight; fn v13_migration_step() -> Weight; + fn v14_migration_step() -> Weight; fn migration_noop() -> Weight; fn migrate() -> Weight; fn on_runtime_upgrade_noop() -> Weight; From 8b69d3e3947acf7fe94579ab66cec924caf5e67e Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 28 Jul 2023 11:16:47 +0200 Subject: [PATCH 088/105] mock balance --- frame/contracts/src/benchmarking/mod.rs | 157 ++++++++++++++++++++++-- frame/contracts/src/migration/v12.rs | 7 +- frame/contracts/src/migration/v14.rs | 10 +- 3 files changed, 162 insertions(+), 12 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index ee6bf3ccb0772..2584f3f22561d 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -37,7 +37,10 @@ use crate::{ use codec::{Encode, MaxEncodedLen}; use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; use frame_support::{ - self, pallet_prelude::StorageVersion, traits::fungible::InspectHold, weights::Weight, + self, + pallet_prelude::StorageVersion, + traits::{fungible::InspectHold, ReservableCurrency}, + weights::Weight, }; use frame_system::RawOrigin; use pallet_balances; @@ -258,9 +261,31 @@ benchmarks! { #[pov_mode = Measured] v12_migration_step { let c in 0 .. T::MaxCodeLen::get(); - type Balances = (); - v12::store_old_dummy_code::(c as usize, account::("account", 0, 0)); - let mut m = v12::Migration::::default(); + v12::store_old_dummy_code::< + T, + pallet_balances::Pallet + >(c as usize, account::("account", 0, 0)); + + struct OldDepositPerItem(PhantomData<(T,Currency)>); + + type OldDepositPerByte = OldDepositPerItem; + + impl Get> for OldDepositPerItem + where + T: Config, + Currency: ReservableCurrency<::AccountId>, + { + fn get() -> v12::old::BalanceOf { + v12::old::BalanceOf::::default() + } + } + + let mut m = v12::Migration::< + T, + pallet_balances::Pallet, + OldDepositPerItem>, + OldDepositPerByte> + >::default(); }: { m.step(); } @@ -281,9 +306,127 @@ benchmarks! { // This benchmarks the v14 migration step (Move code owners' reserved balance to be held instead). #[pov_mode = Measured] v14_migration_step { - type Balances = (); - v14::store_dummy_code::(); - let mut m = v14::Migration::::default(); + use frame_support::traits::{BalanceStatus, Currency, ExistenceRequirement, SignedImbalance, WithdrawReasons}; + use sp_runtime::DispatchResult; + + struct MockBalance; + + impl Currency for MockBalance { + type Balance = u32; + type PositiveImbalance = (); + type NegativeImbalance = (); + fn total_balance(_: &AccountId) -> Self::Balance { + 0 + } + fn can_slash(_: &AccountId, _: Self::Balance) -> bool { + true + } + fn total_issuance() -> Self::Balance { + 0 + } + fn minimum_balance() -> Self::Balance { + 0 + } + fn burn(_: Self::Balance) -> Self::PositiveImbalance { + () + } + fn issue(_: Self::Balance) -> Self::NegativeImbalance { + () + } + fn pair(_: Self::Balance) -> (Self::PositiveImbalance, Self::NegativeImbalance) { + ((), ()) + } + fn free_balance(_: &AccountId) -> Self::Balance { + 0 + } + fn ensure_can_withdraw( + _: &AccountId, + _: Self::Balance, + _: WithdrawReasons, + _: Self::Balance, + ) -> DispatchResult { + Ok(()) + } + fn transfer( + _: &AccountId, + _: &AccountId, + _: Self::Balance, + _: ExistenceRequirement, + ) -> DispatchResult { + Ok(()) + } + fn slash(_: &AccountId, _: Self::Balance) -> (Self::NegativeImbalance, Self::Balance) { + ((), 0) + } + fn deposit_into_existing( + _: &AccountId, + _: Self::Balance, + ) -> Result { + Ok(()) + } + fn resolve_into_existing( + _: &AccountId, + _: Self::NegativeImbalance, + ) -> Result<(), Self::NegativeImbalance> { + Ok(()) + } + fn deposit_creating(_: &AccountId, _: Self::Balance) -> Self::PositiveImbalance { + () + } + fn resolve_creating(_: &AccountId, _: Self::NegativeImbalance) {} + fn withdraw( + _: &AccountId, + _: Self::Balance, + _: WithdrawReasons, + _: ExistenceRequirement, + ) -> Result { + Ok(()) + } + fn settle( + _: &AccountId, + _: Self::PositiveImbalance, + _: WithdrawReasons, + _: ExistenceRequirement, + ) -> Result<(), Self::PositiveImbalance> { + Ok(()) + } + fn make_free_balance_be( + _: &AccountId, + _: Self::Balance, + ) -> SignedImbalance { + SignedImbalance::Positive(()) + } + } + + impl ReservableCurrency for MockBalance { + fn can_reserve(_: &AccountId, _: Self::Balance) -> bool { + true + } + fn slash_reserved(_: &AccountId, _: Self::Balance) -> (Self::NegativeImbalance, Self::Balance) { + ((), 0) + } + fn reserved_balance(_: &AccountId) -> Self::Balance { + 0 + } + fn reserve(_: &AccountId, _: Self::Balance) -> DispatchResult { + Ok(()) + } + fn unreserve(_: &AccountId, _: Self::Balance) -> Self::Balance { + 0 + } + fn repatriate_reserved( + _: &AccountId, + _: &AccountId, + _: Self::Balance, + _: BalanceStatus, + ) -> Result { + Ok(0) + } + } + + v14::store_dummy_code::(); + + let mut m = v14::Migration::::default(); }: { m.step(); } diff --git a/frame/contracts/src/migration/v12.rs b/frame/contracts/src/migration/v12.rs index 070559a2e25b7..d5265015bd4a5 100644 --- a/frame/contracts/src/migration/v12.rs +++ b/frame/contracts/src/migration/v12.rs @@ -102,7 +102,10 @@ pub type CodeInfoOf = pub type PristineCode = StorageMap, Identity, CodeHash, Vec>; #[cfg(feature = "runtime-benchmarks")] -pub fn store_old_dummy_code(len: usize, account: T::AccountId) { +pub fn store_old_dummy_code(len: usize, account: T::AccountId) +where + OldCurrency: ReservableCurrency<::AccountId> + 'static, +{ use sp_runtime::traits::Hash; let code = vec![42u8; len]; @@ -119,7 +122,7 @@ pub fn store_old_dummy_code(len: usize, account: T::AccountId) { old::CodeStorage::::insert(hash, module); let info = old::OwnerInfo { owner: account, deposit: u32::MAX.into(), refcount: u64::MAX }; - old::OwnerInfoOf::::insert(hash, info); + old::OwnerInfoOf::::insert(hash, info); } #[derive(Encode, Decode, MaxEncodedLen, DefaultNoBound)] diff --git a/frame/contracts/src/migration/v14.rs b/frame/contracts/src/migration/v14.rs index a53094cb246d7..d737c000a2405 100644 --- a/frame/contracts/src/migration/v14.rs +++ b/frame/contracts/src/migration/v14.rs @@ -74,7 +74,11 @@ pub mod old { } #[cfg(feature = "runtime-benchmarks")] -pub fn store_dummy_code() { +pub fn store_dummy_code() +where + T: Config, + OldCurrency: ReservableCurrency<::AccountId> + 'static, +{ use frame_benchmarking::account; use sp_runtime::traits::Hash; use sp_std::vec; @@ -90,7 +94,7 @@ pub fn store_dummy_code() { determinism: Determinism::Enforced, code_len: len, }; - old::CodeInfoOf::::insert(hash, info); + old::CodeInfoOf::::insert(hash, info); } #[cfg(feature = "try-runtime")] @@ -121,7 +125,7 @@ impl MigrationStep for Migration where T: Config, OldCurrency: 'static + ReservableCurrency<::AccountId>, - BalanceOf: From>, + BalanceOf: From, { const VERSION: u16 = 14; From 38c044c757c99713d7e890e191720e4ab43f1dfe Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 28 Jul 2023 12:44:59 +0200 Subject: [PATCH 089/105] mock more for benchmarks --- frame/contracts/src/benchmarking/mod.rs | 288 ++++++++++++++---------- 1 file changed, 175 insertions(+), 113 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 2584f3f22561d..62632d01287a6 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -306,127 +306,189 @@ benchmarks! { // This benchmarks the v14 migration step (Move code owners' reserved balance to be held instead). #[pov_mode = Measured] v14_migration_step { - use frame_support::traits::{BalanceStatus, Currency, ExistenceRequirement, SignedImbalance, WithdrawReasons}; - use sp_runtime::DispatchResult; - - struct MockBalance; - - impl Currency for MockBalance { - type Balance = u32; - type PositiveImbalance = (); - type NegativeImbalance = (); - fn total_balance(_: &AccountId) -> Self::Balance { - 0 - } - fn can_slash(_: &AccountId, _: Self::Balance) -> bool { - true - } - fn total_issuance() -> Self::Balance { - 0 - } - fn minimum_balance() -> Self::Balance { - 0 - } - fn burn(_: Self::Balance) -> Self::PositiveImbalance { - () - } - fn issue(_: Self::Balance) -> Self::NegativeImbalance { - () - } - fn pair(_: Self::Balance) -> (Self::PositiveImbalance, Self::NegativeImbalance) { - ((), ()) - } - fn free_balance(_: &AccountId) -> Self::Balance { - 0 - } - fn ensure_can_withdraw( - _: &AccountId, - _: Self::Balance, - _: WithdrawReasons, - _: Self::Balance, - ) -> DispatchResult { - Ok(()) - } - fn transfer( - _: &AccountId, - _: &AccountId, - _: Self::Balance, - _: ExistenceRequirement, - ) -> DispatchResult { - Ok(()) - } - fn slash(_: &AccountId, _: Self::Balance) -> (Self::NegativeImbalance, Self::Balance) { - ((), 0) - } - fn deposit_into_existing( - _: &AccountId, - _: Self::Balance, - ) -> Result { - Ok(()) - } - fn resolve_into_existing( - _: &AccountId, - _: Self::NegativeImbalance, - ) -> Result<(), Self::NegativeImbalance> { - Ok(()) - } - fn deposit_creating(_: &AccountId, _: Self::Balance) -> Self::PositiveImbalance { - () - } - fn resolve_creating(_: &AccountId, _: Self::NegativeImbalance) {} - fn withdraw( - _: &AccountId, - _: Self::Balance, - _: WithdrawReasons, - _: ExistenceRequirement, - ) -> Result { - Ok(()) - } - fn settle( - _: &AccountId, - _: Self::PositiveImbalance, - _: WithdrawReasons, - _: ExistenceRequirement, - ) -> Result<(), Self::PositiveImbalance> { - Ok(()) - } - fn make_free_balance_be( - _: &AccountId, - _: Self::Balance, - ) -> SignedImbalance { - SignedImbalance::Positive(()) + mod mock { + use frame_support::traits::{BalanceStatus, Currency, ExistenceRequirement, Imbalance, ReservableCurrency, + SameOrOther, SignedImbalance, TryDrop, WithdrawReasons}; + use sp_runtime::{DispatchResult, Saturating, DispatchError}; + use sp_std::ops::Div; + + #[derive(Default)] + pub struct MockBalance; + + impl TryDrop for MockBalance { + fn try_drop(self) -> Result<(), Self> { + Ok(()) + } } - } - impl ReservableCurrency for MockBalance { - fn can_reserve(_: &AccountId, _: Self::Balance) -> bool { - true - } - fn slash_reserved(_: &AccountId, _: Self::Balance) -> (Self::NegativeImbalance, Self::Balance) { - ((), 0) - } - fn reserved_balance(_: &AccountId) -> Self::Balance { - 0 - } - fn reserve(_: &AccountId, _: Self::Balance) -> DispatchResult { - Ok(()) + impl Imbalance for MockBalance { + type Opposite = MockBalance; + fn zero() -> Self { + MockBalance::default() + } + fn drop_zero(self) -> Result<(), Self> { + Ok(()) + } + fn split(self, _: Balance) -> (Self, Self) { + (MockBalance::default(), MockBalance::default()) + } + fn ration(self, _: u32, _: u32) -> (Self, Self) + where + Balance: From + Saturating + Div, + { + (MockBalance::default(), MockBalance::default()) + } + fn split_merge(self, _: Balance, _: (Self, Self)) -> (Self, Self) { + (MockBalance::default(), MockBalance::default()) + } + fn ration_merge(self, _: u32, _: u32, _: (Self, Self)) -> (Self, Self) + where + Balance: From + Saturating + Div, + { + (MockBalance::default(), MockBalance::default()) + } + fn split_merge_into(self, _: Balance, _: &mut (Self, Self)) {} + fn ration_merge_into(self, _: u32, _: u32, _: &mut (Self, Self)) + where + Balance: From + Saturating + Div, + { + } + fn merge(self, _: Self) -> Self { + MockBalance::default() + } + fn merge_into(self, _: &mut Self) {} + fn maybe_merge(self, _: Option) -> Self { + MockBalance::default() + } + fn subsume(&mut self, _: Self) {} + fn maybe_subsume(&mut self, _: Option) { + () + } + fn offset(self, _: Self::Opposite) -> SameOrOther { + SameOrOther::None + } + fn peek(&self) -> Balance { + Default::default() + } } - fn unreserve(_: &AccountId, _: Self::Balance) -> Self::Balance { - 0 + + impl Currency for MockBalance { + type Balance = u32; + type PositiveImbalance = MockBalance; + type NegativeImbalance = MockBalance; + fn total_balance(_: &AccountId) -> Self::Balance { + 0 + } + fn can_slash(_: &AccountId, _: Self::Balance) -> bool { + true + } + fn total_issuance() -> Self::Balance { + 0 + } + fn minimum_balance() -> Self::Balance { + 0 + } + fn burn(_: Self::Balance) -> Self::PositiveImbalance { + MockBalance::default() + } + fn issue(_: Self::Balance) -> Self::NegativeImbalance { + MockBalance::default() + } + fn pair(_: Self::Balance) -> (Self::PositiveImbalance, Self::NegativeImbalance) { + (MockBalance::default(), MockBalance::default()) + } + fn free_balance(_: &AccountId) -> Self::Balance { + 0 + } + fn ensure_can_withdraw( + _: &AccountId, + _: Self::Balance, + _: WithdrawReasons, + _: Self::Balance, + ) -> DispatchResult { + Ok(()) + } + fn transfer( + _: &AccountId, + _: &AccountId, + _: Self::Balance, + _: ExistenceRequirement, + ) -> DispatchResult { + Ok(()) + } + fn slash(_: &AccountId, _: Self::Balance) -> (Self::NegativeImbalance, Self::Balance) { + (MockBalance::default(), 0) + } + fn deposit_into_existing( + _: &AccountId, + _: Self::Balance, + ) -> Result { + Ok(MockBalance::default()) + } + fn resolve_into_existing( + _: &AccountId, + _: Self::NegativeImbalance, + ) -> Result<(), Self::NegativeImbalance> { + Ok(()) + } + fn deposit_creating(_: &AccountId, _: Self::Balance) -> Self::PositiveImbalance { + MockBalance::default() + } + fn resolve_creating(_: &AccountId, _: Self::NegativeImbalance) {} + fn withdraw( + _: &AccountId, + _: Self::Balance, + _: WithdrawReasons, + _: ExistenceRequirement, + ) -> Result { + Ok(MockBalance::default()) + } + fn settle( + _: &AccountId, + _: Self::PositiveImbalance, + _: WithdrawReasons, + _: ExistenceRequirement, + ) -> Result<(), Self::PositiveImbalance> { + Ok(()) + } + fn make_free_balance_be( + _: &AccountId, + _: Self::Balance, + ) -> SignedImbalance { + SignedImbalance::Positive(MockBalance::default()) + } } - fn repatriate_reserved( - _: &AccountId, - _: &AccountId, - _: Self::Balance, - _: BalanceStatus, - ) -> Result { - Ok(0) + + impl ReservableCurrency for MockBalance { + fn can_reserve(_: &AccountId, _: Self::Balance) -> bool { + true + } + fn slash_reserved(_: &AccountId, _: Self::Balance) -> (Self::NegativeImbalance, Self::Balance) { + (MockBalance::default(), 0) + } + fn reserved_balance(_: &AccountId) -> Self::Balance { + 0 + } + fn reserve(_: &AccountId, _: Self::Balance) -> DispatchResult { + Ok(()) + } + fn unreserve(_: &AccountId, _: Self::Balance) -> Self::Balance { + 0 + } + fn repatriate_reserved( + _: &AccountId, + _: &AccountId, + _: Self::Balance, + _: BalanceStatus, + ) -> Result { + Ok(0) + } } } - v14::store_dummy_code::(); + v14::store_dummy_code::(); - let mut m = v14::Migration::::default(); + let mut m = v14::Migration::::default(); }: { m.step(); } From 4cd120f036f7407df089724e37335598e9bd72de Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 28 Jul 2023 16:24:29 +0200 Subject: [PATCH 090/105] fix benchmarking tests --- frame/contracts/src/benchmarking/mod.rs | 5 ++- frame/contracts/src/migration/v14.rs | 54 ++++++++++++------------- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 62632d01287a6..a825f9d78a7c7 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -486,8 +486,9 @@ benchmarks! { } } - v14::store_dummy_code::(); - + let account = account::("account", 0, 0); + T::Currency::set_balance(&account, caller_funding::()); + v14::store_dummy_code::(account); let mut m = v14::Migration::::default(); }: { m.step(); diff --git a/frame/contracts/src/migration/v14.rs b/frame/contracts/src/migration/v14.rs index d737c000a2405..c6d96a1ec3fd5 100644 --- a/frame/contracts/src/migration/v14.rs +++ b/frame/contracts/src/migration/v14.rs @@ -74,12 +74,11 @@ pub mod old { } #[cfg(feature = "runtime-benchmarks")] -pub fn store_dummy_code() +pub fn store_dummy_code(account: T::AccountId) where T: Config, OldCurrency: ReservableCurrency<::AccountId> + 'static, { - use frame_benchmarking::account; use sp_runtime::traits::Hash; use sp_std::vec; @@ -88,8 +87,8 @@ where let hash = T::Hashing::hash(&code); let info = old::CodeInfo { - owner: account::("account", 0, 0), - deposit: u32::MAX.into(), + owner: account, + deposit: 10_000u32.into(), refcount: u64::MAX, determinism: Determinism::Enforced, code_len: len, @@ -159,31 +158,28 @@ where } let unreserved = code_info.deposit.saturating_sub(remaining); - - T::Currency::hold( - &HoldReason::StorageDepositReserve.into(), - &code_info.owner, - unreserved.into(), - ) - .map(|_| { - log::debug!( - target: LOG_TARGET, - "{:?} held on the code owner's account 0x{:?} for code {:?}.", - unreserved, - HexDisplay::from(&code_info.owner.encode()), - hash, - ); - }) - .unwrap_or_else(|err| { - log::error!( - target: LOG_TARGET, - "Failed to hold {:?} from the code owner's account 0x{:?} for code {:?}, reason: {:?}.", - unreserved, - HexDisplay::from(&code_info.owner.encode()), - hash, - err - ); - }); + let amount = BalanceOf::::from(unreserved); + + T::Currency::hold(&HoldReason::StorageDepositReserve.into(), &code_info.owner, amount) + .map(|_| { + log::debug!( + target: LOG_TARGET, + "{:?} held on the code owner's account 0x{:?} for code {:?}.", + amount, + HexDisplay::from(&code_info.owner.encode()), + hash, + ); + }) + .unwrap_or_else(|err| { + log::error!( + target: LOG_TARGET, + "Failed to hold {:?} from the code owner's account 0x{:?} for code {:?}, reason: {:?}.", + amount, + HexDisplay::from(&code_info.owner.encode()), + hash, + err + ); + }); self.last_code_hash = Some(hash); (IsFinished::No, T::WeightInfo::v14_migration_step()) From f08f844d19b1b381645d9e50dad5d788c800648a Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 28 Jul 2023 17:05:49 +0200 Subject: [PATCH 091/105] fix benchmarking tests with caller --- frame/contracts/src/benchmarking/mod.rs | 29 +++++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index a825f9d78a7c7..2e70535b0ea27 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -1069,12 +1069,15 @@ benchmarks! { let beneficiary = account::("beneficiary", 0, 0); let beneficiary_bytes = beneficiary.encode(); let beneficiary_len = beneficiary_bytes.len(); + let caller = whitelisted_caller(); + + T::Currency::set_balance(&caller, caller_funding::()); // Maximize the delegate_dependencies to account for the worst-case scenario. let code_hashes = (0..T::MaxDelegateDependencies::get()) .map(|i| { let new_code = WasmModule::::dummy_with_bytes(65 + i); - Contracts::::store_code_raw(new_code.code, whitelisted_caller())?; + Contracts::::store_code_raw(new_code.code, caller.clone())?; Ok(new_code.hash) }) .collect::, &'static str>>()?; @@ -1991,7 +1994,9 @@ benchmarks! { let hashes = (0..r) .map(|i| { let code = WasmModule::::dummy_with_bytes(i); - Contracts::::store_code_raw(code.code, whitelisted_caller())?; + let caller = whitelisted_caller(); + T::Currency::set_balance(&caller, caller_funding::()); + Contracts::::store_code_raw(code.code, caller)?; Ok(code.hash) }) .collect::, &'static str>>()?; @@ -2111,7 +2116,9 @@ benchmarks! { ])), .. Default::default() }); - Contracts::::store_code_raw(code.code, whitelisted_caller())?; + let caller = whitelisted_caller(); + T::Currency::set_balance(&caller, caller_funding::()); + Contracts::::store_code_raw(code.code, caller)?; Ok(code.hash) }) .collect::, &'static str>>()?; @@ -2215,7 +2222,9 @@ benchmarks! { let hash = callee_code.hash; let hash_bytes = callee_code.hash.encode(); let hash_len = hash_bytes.len(); - Contracts::::store_code_raw(callee_code.code, whitelisted_caller())?; + let caller = whitelisted_caller(); + T::Currency::set_balance(&caller, caller_funding::()); + Contracts::::store_code_raw(callee_code.code, caller)?; let value: BalanceOf = t.into(); let value_bytes = value.encode(); @@ -2557,7 +2566,9 @@ benchmarks! { let code_hashes = (0..r) .map(|i| { let new_code = WasmModule::::dummy_with_bytes(i); - Contracts::::store_code_raw(new_code.code, whitelisted_caller())?; + let caller = whitelisted_caller(); + T::Currency::set_balance(&caller, caller_funding::()); + Contracts::::store_code_raw(new_code.code, caller)?; Ok(new_code.hash) }) .collect::, &'static str>>()?; @@ -2598,7 +2609,9 @@ benchmarks! { let code_hashes = (0..r) .map(|i| { let new_code = WasmModule::::dummy_with_bytes(65 + i); - Contracts::::store_code_raw(new_code.code, whitelisted_caller())?; + let caller = whitelisted_caller(); + T::Currency::set_balance(&caller, caller_funding::()); + Contracts::::store_code_raw(new_code.code, caller)?; Ok(new_code.hash) }) .collect::, &'static str>>()?; @@ -2634,7 +2647,9 @@ benchmarks! { let code_hashes = (0..r) .map(|i| { let new_code = WasmModule::::dummy_with_bytes(65 + i); - Contracts::::store_code_raw(new_code.code, whitelisted_caller())?; + let caller = whitelisted_caller(); + T::Currency::set_balance(&caller, caller_funding::()); + Contracts::::store_code_raw(new_code.code, caller)?; Ok(new_code.hash) }) .collect::, &'static str>>()?; From da6e8c1a6bd009c557476a8dbfdabec7bf572d31 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 28 Jul 2023 17:38:55 +0200 Subject: [PATCH 092/105] improve cargo toml --- frame/contracts/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/contracts/Cargo.toml b/frame/contracts/Cargo.toml index 8004c6e0eed27..3da0345ecbbc8 100644 --- a/frame/contracts/Cargo.toml +++ b/frame/contracts/Cargo.toml @@ -55,8 +55,8 @@ pretty_assertions = "1" wat = "1" # Substrate Dependencies -pallet-timestamp = { version = "4.0.0-dev", path = "../timestamp" } pallet-balances = { version = "4.0.0-dev", path = "../balances" } +pallet-timestamp = { version = "4.0.0-dev", path = "../timestamp" } pallet-insecure-randomness-collective-flip = { version = "4.0.0-dev", path = "../insecure-randomness-collective-flip" } pallet-utility = { version = "4.0.0-dev", path = "../utility" } pallet-proxy = { version = "4.0.0-dev", path = "../proxy" } @@ -82,7 +82,7 @@ std = [ "log/std", "rand/std", "environmental/std", - "pallet-balances/std", + "pallet-balances?/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", From 3e6ce6af2068cdf854856882d0caa0ed034e2e85 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 28 Jul 2023 17:55:11 +0200 Subject: [PATCH 093/105] solve nit --- frame/contracts/src/chain_extension.rs | 7 ++++--- frame/contracts/src/exec.rs | 1 - frame/contracts/src/lib.rs | 17 +++++++++-------- frame/contracts/src/wasm/prepare.rs | 1 + 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/frame/contracts/src/chain_extension.rs b/frame/contracts/src/chain_extension.rs index 8ec922d343df4..6d1f3df90f23e 100644 --- a/frame/contracts/src/chain_extension.rs +++ b/frame/contracts/src/chain_extension.rs @@ -70,18 +70,19 @@ //! [end-to-end example](https://github.com/paritytech/ink-examples/tree/main/rand-extension) //! on how to use a chain extension in order to provide new features to ink! contracts. -pub use crate::{exec::Ext, gas::ChargedAmount, Config}; use crate::{ wasm::{Runtime, RuntimeCosts}, Error, }; use codec::{Decode, MaxEncodedLen}; use frame_support::weights::Weight; -pub use frame_system::Config as SysConfig; -pub use pallet_contracts_primitives::ReturnFlags; use sp_runtime::DispatchError; use sp_std::{marker::PhantomData, vec::Vec}; +pub use crate::{exec::Ext, gas::ChargedAmount, Config}; +pub use frame_system::Config as SysConfig; +pub use pallet_contracts_primitives::ReturnFlags; + /// Result that returns a [`DispatchError`] on error. pub type Result = sp_std::result::Result; diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index a75dc62c3211d..97fc51df20bb3 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -1263,7 +1263,6 @@ where salt: &[u8], ) -> Result<(AccountIdOf, ExecReturnValue), ExecError> { let executable = E::from_storage(code_hash, self.gas_meter_mut())?; - let nonce = self.next_nonce(); let executable = self.push_frame( FrameArgs::Instantiate { diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 0144f396ce8bb..4e1876df306ff 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -101,14 +101,6 @@ pub mod weights; #[cfg(test)] mod tests; -pub use crate::{ - address::{AddressGenerator, DefaultAddressGenerator}, - exec::Frame, - migration::{MigrateSequence, Migration, NoopMigration}, - pallet::*, - schedule::{HostFnWeights, InstructionWeights, Limits, Schedule}, - wasm::Determinism, -}; use crate::{ exec::{AccountIdOf, ErrorOrigin, ExecError, Executable, Key, Stack as ExecStack}, gas::GasMeter, @@ -145,6 +137,15 @@ use sp_runtime::{ FixedPointOperand, }; use sp_std::{fmt::Debug, prelude::*}; + +pub use crate::{ + address::{AddressGenerator, DefaultAddressGenerator}, + exec::Frame, + migration::{MigrateSequence, Migration, NoopMigration}, + pallet::*, + schedule::{HostFnWeights, InstructionWeights, Limits, Schedule}, + wasm::Determinism, +}; pub use weights::WeightInfo; #[cfg(doc)] diff --git a/frame/contracts/src/wasm/prepare.rs b/frame/contracts/src/wasm/prepare.rs index 1c05085be90f6..b129c17e13eca 100644 --- a/frame/contracts/src/wasm/prepare.rs +++ b/frame/contracts/src/wasm/prepare.rs @@ -18,6 +18,7 @@ //! This module takes care of loading, checking and preprocessing of a //! wasm module before execution. It also extracts some essential information //! from a module. + use crate::{ chain_extension::ChainExtension, storage::meter::Diff, From 0ce5815cf06f3afb28230c1290c1bf14a81d5265 Mon Sep 17 00:00:00 2001 From: Juan Date: Mon, 31 Jul 2023 12:18:39 +0200 Subject: [PATCH 094/105] 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 4e1876df306ff..765e02ecbd7ca 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -1007,8 +1007,8 @@ pub mod pallet { /// A reason for the pallet contracts placing a hold on funds. #[pallet::composite_enum] pub enum HoldReason { - /// The Pallet has reserved it for storage deposit. - StorageDepositReserve, + /// The Pallet has reserved it for storing code on-chain. + CodeUploadDepositReserve, } /// A mapping from a contract's code hash to its code. From 3054dce0b99be7cd30c932ebf1e94fee13558805 Mon Sep 17 00:00:00 2001 From: Juan Date: Mon, 31 Jul 2023 12:19:09 +0200 Subject: [PATCH 095/105] Update frame/contracts/src/exec.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/exec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 97fc51df20bb3..d628ffaa162e6 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -1133,7 +1133,7 @@ where Origin::Root if value.is_zero() => return Ok(()), Origin::Root => return DispatchError::RootNotAllowed.into(), }; - Self::transfer(Preservation::Protect, &caller, &frame.account_id, value) + Self::transfer(Preservation::Preserve, &caller, &frame.account_id, value) } /// Reference to the current (top) frame. From b0a6d39c4dc217eccd5b590416f787f11194f6dd Mon Sep 17 00:00:00 2001 From: Juan Date: Mon, 31 Jul 2023 12:19:23 +0200 Subject: [PATCH 096/105] Update frame/contracts/src/exec.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/exec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index d628ffaa162e6..f0a7dacbf2f80 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -1316,7 +1316,7 @@ where } fn transfer(&mut self, to: &T::AccountId, value: BalanceOf) -> DispatchResult { - Self::transfer(Preservation::Protect, &self.top_frame().account_id, to, value) + Self::transfer(Preservation::Preserve, &self.top_frame().account_id, to, value) } fn get_storage(&mut self, key: &Key) -> Option> { From 49d8f7f2ef5584c483cbef04629990e69eb17c3d Mon Sep 17 00:00:00 2001 From: Juan Date: Mon, 31 Jul 2023 12:19:35 +0200 Subject: [PATCH 097/105] Update frame/contracts/src/storage/meter.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/meter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/contracts/src/storage/meter.rs b/frame/contracts/src/storage/meter.rs index 4ff39ed672d0f..c718caca9a999 100644 --- a/frame/contracts/src/storage/meter.rs +++ b/frame/contracts/src/storage/meter.rs @@ -540,7 +540,7 @@ impl Ext for ReservingExt { match amount { Deposit::Charge(amount) | Deposit::Refund(amount) if amount.is_zero() => return Ok(()), Deposit::Charge(amount) => { - T::Currency::transfer(origin, deposit_account, *amount, Preservation::Protect)?; + T::Currency::transfer(origin, deposit_account, *amount, Preservation::Preserve)?; Ok(()) }, Deposit::Refund(amount) => { From 432ea0785e33d9b1affc5cf6ce7c8cd71c8dc11c Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Mon, 31 Jul 2023 13:07:52 +0200 Subject: [PATCH 098/105] review improvements --- frame/contracts/src/benchmarking/mod.rs | 212 +----------------------- frame/contracts/src/exec.rs | 4 +- frame/contracts/src/lib.rs | 2 - frame/contracts/src/migration/v12.rs | 21 +-- frame/contracts/src/migration/v14.rs | 46 ++--- frame/contracts/src/storage/meter.rs | 4 +- frame/contracts/src/tests.rs | 8 +- frame/contracts/src/wasm/mod.rs | 6 +- 8 files changed, 52 insertions(+), 251 deletions(-) diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 2e70535b0ea27..0b334f256b533 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -39,7 +39,7 @@ use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; use frame_support::{ self, pallet_prelude::StorageVersion, - traits::{fungible::InspectHold, ReservableCurrency}, + traits::{fungible::InspectHold, Currency}, weights::Weight, }; use frame_system::RawOrigin; @@ -204,6 +204,8 @@ benchmarks! { where_clause { where as codec::HasCompact>::Type: Clone + Eq + PartialEq + sp_std::fmt::Debug + scale_info::TypeInfo + codec::Encode, T: Config + pallet_balances::Config, + BalanceOf: From< as Currency>::Balance>, + as Currency>::Balance: From>, } // The base weight consumed on processing contracts deletion queue. @@ -265,27 +267,7 @@ benchmarks! { T, pallet_balances::Pallet >(c as usize, account::("account", 0, 0)); - - struct OldDepositPerItem(PhantomData<(T,Currency)>); - - type OldDepositPerByte = OldDepositPerItem; - - impl Get> for OldDepositPerItem - where - T: Config, - Currency: ReservableCurrency<::AccountId>, - { - fn get() -> v12::old::BalanceOf { - v12::old::BalanceOf::::default() - } - } - - let mut m = v12::Migration::< - T, - pallet_balances::Pallet, - OldDepositPerItem>, - OldDepositPerByte> - >::default(); + let mut m = v12::Migration::>::default(); }: { m.step(); } @@ -306,190 +288,10 @@ benchmarks! { // This benchmarks the v14 migration step (Move code owners' reserved balance to be held instead). #[pov_mode = Measured] v14_migration_step { - mod mock { - use frame_support::traits::{BalanceStatus, Currency, ExistenceRequirement, Imbalance, ReservableCurrency, - SameOrOther, SignedImbalance, TryDrop, WithdrawReasons}; - use sp_runtime::{DispatchResult, Saturating, DispatchError}; - use sp_std::ops::Div; - - #[derive(Default)] - pub struct MockBalance; - - impl TryDrop for MockBalance { - fn try_drop(self) -> Result<(), Self> { - Ok(()) - } - } - - impl Imbalance for MockBalance { - type Opposite = MockBalance; - fn zero() -> Self { - MockBalance::default() - } - fn drop_zero(self) -> Result<(), Self> { - Ok(()) - } - fn split(self, _: Balance) -> (Self, Self) { - (MockBalance::default(), MockBalance::default()) - } - fn ration(self, _: u32, _: u32) -> (Self, Self) - where - Balance: From + Saturating + Div, - { - (MockBalance::default(), MockBalance::default()) - } - fn split_merge(self, _: Balance, _: (Self, Self)) -> (Self, Self) { - (MockBalance::default(), MockBalance::default()) - } - fn ration_merge(self, _: u32, _: u32, _: (Self, Self)) -> (Self, Self) - where - Balance: From + Saturating + Div, - { - (MockBalance::default(), MockBalance::default()) - } - fn split_merge_into(self, _: Balance, _: &mut (Self, Self)) {} - fn ration_merge_into(self, _: u32, _: u32, _: &mut (Self, Self)) - where - Balance: From + Saturating + Div, - { - } - fn merge(self, _: Self) -> Self { - MockBalance::default() - } - fn merge_into(self, _: &mut Self) {} - fn maybe_merge(self, _: Option) -> Self { - MockBalance::default() - } - fn subsume(&mut self, _: Self) {} - fn maybe_subsume(&mut self, _: Option) { - () - } - fn offset(self, _: Self::Opposite) -> SameOrOther { - SameOrOther::None - } - fn peek(&self) -> Balance { - Default::default() - } - } - - impl Currency for MockBalance { - type Balance = u32; - type PositiveImbalance = MockBalance; - type NegativeImbalance = MockBalance; - fn total_balance(_: &AccountId) -> Self::Balance { - 0 - } - fn can_slash(_: &AccountId, _: Self::Balance) -> bool { - true - } - fn total_issuance() -> Self::Balance { - 0 - } - fn minimum_balance() -> Self::Balance { - 0 - } - fn burn(_: Self::Balance) -> Self::PositiveImbalance { - MockBalance::default() - } - fn issue(_: Self::Balance) -> Self::NegativeImbalance { - MockBalance::default() - } - fn pair(_: Self::Balance) -> (Self::PositiveImbalance, Self::NegativeImbalance) { - (MockBalance::default(), MockBalance::default()) - } - fn free_balance(_: &AccountId) -> Self::Balance { - 0 - } - fn ensure_can_withdraw( - _: &AccountId, - _: Self::Balance, - _: WithdrawReasons, - _: Self::Balance, - ) -> DispatchResult { - Ok(()) - } - fn transfer( - _: &AccountId, - _: &AccountId, - _: Self::Balance, - _: ExistenceRequirement, - ) -> DispatchResult { - Ok(()) - } - fn slash(_: &AccountId, _: Self::Balance) -> (Self::NegativeImbalance, Self::Balance) { - (MockBalance::default(), 0) - } - fn deposit_into_existing( - _: &AccountId, - _: Self::Balance, - ) -> Result { - Ok(MockBalance::default()) - } - fn resolve_into_existing( - _: &AccountId, - _: Self::NegativeImbalance, - ) -> Result<(), Self::NegativeImbalance> { - Ok(()) - } - fn deposit_creating(_: &AccountId, _: Self::Balance) -> Self::PositiveImbalance { - MockBalance::default() - } - fn resolve_creating(_: &AccountId, _: Self::NegativeImbalance) {} - fn withdraw( - _: &AccountId, - _: Self::Balance, - _: WithdrawReasons, - _: ExistenceRequirement, - ) -> Result { - Ok(MockBalance::default()) - } - fn settle( - _: &AccountId, - _: Self::PositiveImbalance, - _: WithdrawReasons, - _: ExistenceRequirement, - ) -> Result<(), Self::PositiveImbalance> { - Ok(()) - } - fn make_free_balance_be( - _: &AccountId, - _: Self::Balance, - ) -> SignedImbalance { - SignedImbalance::Positive(MockBalance::default()) - } - } - - impl ReservableCurrency for MockBalance { - fn can_reserve(_: &AccountId, _: Self::Balance) -> bool { - true - } - fn slash_reserved(_: &AccountId, _: Self::Balance) -> (Self::NegativeImbalance, Self::Balance) { - (MockBalance::default(), 0) - } - fn reserved_balance(_: &AccountId) -> Self::Balance { - 0 - } - fn reserve(_: &AccountId, _: Self::Balance) -> DispatchResult { - Ok(()) - } - fn unreserve(_: &AccountId, _: Self::Balance) -> Self::Balance { - 0 - } - fn repatriate_reserved( - _: &AccountId, - _: &AccountId, - _: Self::Balance, - _: BalanceStatus, - ) -> Result { - Ok(0) - } - } - } - let account = account::("account", 0, 0); T::Currency::set_balance(&account, caller_funding::()); - v14::store_dummy_code::(account); - let mut m = v14::Migration::::default(); + v14::store_dummy_code::>(account); + let mut m = v14::Migration::>::default(); }: { m.step(); } @@ -1985,7 +1787,7 @@ benchmarks! { }); let instance = Contract::::new(code, vec![])?; let origin = RawOrigin::Signed(instance.caller.clone()); - }: call(origin, instance.addr, 0u32.into(), Weight::MAX, Some(BalanceOf::::from(u32::MAX).into()), vec![]) + }: call(origin, instance.addr, 0u32.into(), Weight::MAX, Some(BalanceOf::::from(u32::MAX.into()).into()), vec![]) // This is a slow call: We redeuce the number of runs. #[pov_mode = Measured] diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index f0a7dacbf2f80..6203b31f67a5b 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -1810,7 +1810,7 @@ mod tests { set_balance(&origin, 100); set_balance(&dest, 0); - MockStack::transfer(Preservation::Protect, &origin, &dest, 55).unwrap(); + MockStack::transfer(Preservation::Preserve, &origin, &dest, 55).unwrap(); assert_eq!(get_balance(&origin), 45); assert_eq!(get_balance(&dest), 55); @@ -1948,7 +1948,7 @@ mod tests { ExtBuilder::default().build().execute_with(|| { set_balance(&origin, 0); - let result = MockStack::transfer(Preservation::Protect, &origin, &dest, 100); + let result = MockStack::transfer(Preservation::Preserve, &origin, &dest, 100); assert_eq!(result, Err(Error::::TransferFailed.into())); assert_eq!(get_balance(&origin), 0); diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 765e02ecbd7ca..cb49d70e3b277 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -970,8 +970,6 @@ pub mod pallet { StorageDepositNotEnoughFunds, /// More storage was created than allowed by the storage deposit limit. StorageDepositLimitExhausted, - /// Some storage deposit could not be held. - StorageDepositNotHeld, /// Code removal was denied because the code is still in use by at least one contract. CodeInUse, /// The contract ran to completion but decided to revert its storage changes. diff --git a/frame/contracts/src/migration/v12.rs b/frame/contracts/src/migration/v12.rs index d5265015bd4a5..9642041e386f0 100644 --- a/frame/contracts/src/migration/v12.rs +++ b/frame/contracts/src/migration/v12.rs @@ -21,7 +21,7 @@ use crate::{ migration::{IsFinished, MigrationStep}, weights::WeightInfo, - AccountIdOf, CodeHash, Config, Determinism, Pallet, Weight, LOG_TARGET, + AccountIdOf, BalanceOf, CodeHash, Config, Determinism, Pallet, Weight, LOG_TARGET, }; use codec::{Decode, Encode}; use frame_support::{ @@ -126,22 +126,19 @@ where } #[derive(Encode, Decode, MaxEncodedLen, DefaultNoBound)] -pub struct Migration +pub struct Migration where OldCurrency: ReservableCurrency<::AccountId>, - OldDepositPerByte: Get>, - OldDepositPerItem: Get>, + OldCurrency::Balance: From>, { last_code_hash: Option>, - _phantom: PhantomData<(OldCurrency, OldDepositPerByte, OldDepositPerItem)>, + _phantom: PhantomData, } -impl MigrationStep - for Migration +impl MigrationStep for Migration where OldCurrency: ReservableCurrency<::AccountId> + 'static, - OldDepositPerByte: Get>, - OldDepositPerItem: Get>, + OldCurrency::Balance: From>, { const VERSION: u16 = 12; @@ -182,8 +179,8 @@ where // 3. Calculate the deposit amount for storage after the migration, given current // prices. // 4. Calculate real deposit amount to be reserved after the migration. - let price_per_byte = OldDepositPerByte::get(); - let price_per_item = OldDepositPerItem::get(); + let price_per_byte = T::DepositPerByte::get(); + let price_per_item = T::DepositPerItem::get(); let bytes_before = module .encoded_size() .saturating_add(code_len) @@ -207,7 +204,7 @@ where let info = CodeInfo:: { determinism: module.determinism, owner: old_info.owner, - deposit, + deposit: deposit.into(), refcount: old_info.refcount, code_len: code_len as u32, }; diff --git a/frame/contracts/src/migration/v14.rs b/frame/contracts/src/migration/v14.rs index c6d96a1ec3fd5..7ce5e9ec3e6b5 100644 --- a/frame/contracts/src/migration/v14.rs +++ b/frame/contracts/src/migration/v14.rs @@ -160,26 +160,30 @@ where let unreserved = code_info.deposit.saturating_sub(remaining); let amount = BalanceOf::::from(unreserved); - T::Currency::hold(&HoldReason::StorageDepositReserve.into(), &code_info.owner, amount) - .map(|_| { - log::debug!( - target: LOG_TARGET, - "{:?} held on the code owner's account 0x{:?} for code {:?}.", - amount, - HexDisplay::from(&code_info.owner.encode()), - hash, - ); - }) - .unwrap_or_else(|err| { - log::error!( - target: LOG_TARGET, - "Failed to hold {:?} from the code owner's account 0x{:?} for code {:?}, reason: {:?}.", - amount, - HexDisplay::from(&code_info.owner.encode()), - hash, - err - ); - }); + T::Currency::hold( + &HoldReason::CodeUploadDepositReserve.into(), + &code_info.owner, + amount, + ) + .map(|_| { + log::debug!( + target: LOG_TARGET, + "{:?} held on the code owner's account 0x{:?} for code {:?}.", + amount, + HexDisplay::from(&code_info.owner.encode()), + hash, + ); + }) + .unwrap_or_else(|err| { + log::error!( + target: LOG_TARGET, + "Failed to hold {:?} from the code owner's account 0x{:?} for code {:?}, reason: {:?}.", + amount, + HexDisplay::from(&code_info.owner.encode()), + hash, + err + ); + }); self.last_code_hash = Some(hash); (IsFinished::No, T::WeightInfo::v14_migration_step()) @@ -225,7 +229,7 @@ where let count = owner_balance_allocation.len(); for (owner, old_balance_allocation) in owner_balance_allocation { let held = - T::Currency::balance_on_hold(&HoldReason::StorageDepositReserve.into(), &owner); + T::Currency::balance_on_hold(&HoldReason::CodeUploadDepositReserve.into(), &owner); log::debug!( target: LOG_TARGET, "Validating storage deposit for owner 0x{:?}, reserved: {:?}, held: {:?}", diff --git a/frame/contracts/src/storage/meter.rs b/frame/contracts/src/storage/meter.rs index c718caca9a999..2fa11678f4fad 100644 --- a/frame/contracts/src/storage/meter.rs +++ b/frame/contracts/src/storage/meter.rs @@ -454,7 +454,7 @@ where System::::inc_consumers(contract_info.deposit_account())?; // We also need to make sure that the contract's account itself exists. - T::Currency::transfer(origin, contract, ed, Preservation::Protect)?; + T::Currency::transfer(origin, contract, ed, Preservation::Preserve)?; System::::inc_consumers(contract)?; Ok(deposit) @@ -518,7 +518,7 @@ impl Ext for ReservingExt { // We are sending the `min_leftover` and the `min_balance` from the origin // account as part of a contract call. Hence origin needs to have those left over // as free balance after accounting for all deposits. - let max = T::Currency::reducible_balance(origin, Preservation::Protect, Polite) + let max = T::Currency::reducible_balance(origin, Preservation::Preserve, Polite) .saturating_sub(min_leftover) .saturating_sub(Pallet::::min_balance()); let default = max.min(T::DefaultDepositLimit::get()); diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 77cbbd78533ba..77df85af9d6d1 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -3587,7 +3587,7 @@ fn upload_code_not_enough_balance() { Some(codec::Compact(1_000)), Determinism::Enforced ), - >::StorageDepositNotHeld, + >::StorageDepositNotEnoughFunds, ); assert_eq!(System::events(), vec![]); @@ -4288,7 +4288,7 @@ fn slash_cannot_kill_account() { // We need to hold some balances in order to have something to slash. As slashing can only // affect balances held under certain HoldReason. ::Currency::hold( - &HoldReason::StorageDepositReserve.into(), + &HoldReason::CodeUploadDepositReserve.into(), &addr, balance_held, ) @@ -4300,7 +4300,7 @@ fn slash_cannot_kill_account() { // The account does not get destroyed because of the consumer reference. // Slashing can for example happen if the contract takes part in staking. let _ = ::Currency::slash( - &HoldReason::StorageDepositReserve.into(), + &HoldReason::CodeUploadDepositReserve.into(), &addr, ::Currency::total_balance(&addr), ); @@ -5043,7 +5043,7 @@ fn deposit_limit_honors_liquidity_restrictions() { // check that the hold is honored ::Currency::hold( - &HoldReason::StorageDepositReserve.into(), + &HoldReason::CodeUploadDepositReserve.into(), &BOB, bobs_balance - ED, ) diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index be00ac611211d..e37af37ab6e6f 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -239,11 +239,11 @@ impl WasmBlob { None => { let deposit = self.code_info.deposit; T::Currency::hold( - &HoldReason::StorageDepositReserve.into(), + &HoldReason::CodeUploadDepositReserve.into(), &self.code_info.owner, deposit, ) - .map_err(|_| >::StorageDepositNotHeld)?; + .map_err(|_| >::StorageDepositNotEnoughFunds)?; >::deposit_event( vec![T::Hashing::hash_of(&self.code_info.owner)], @@ -270,7 +270,7 @@ impl WasmBlob { ensure!(code_info.refcount == 0, >::CodeInUse); ensure!(&code_info.owner == origin, BadOrigin); let _ = T::Currency::release( - &HoldReason::StorageDepositReserve.into(), + &HoldReason::CodeUploadDepositReserve.into(), &code_info.owner, code_info.deposit, BestEffort, From a7bf91121ff18acc92d429f7ae4b6bd32019d2b4 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Mon, 31 Jul 2023 15:22:22 +0200 Subject: [PATCH 099/105] remove extra events --- frame/contracts/src/lib.rs | 10 +--- frame/contracts/src/tests.rs | 94 ++++++++++----------------------- frame/contracts/src/wasm/mod.rs | 28 ++++------ 3 files changed, 40 insertions(+), 92 deletions(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index cb49d70e3b277..82b772c11daa1 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -849,7 +849,7 @@ pub mod pallet { }, /// Code with the specified hash has been stored. - CodeStored { code_hash: T::Hash }, + CodeStored { code_hash: T::Hash, deposit_held: BalanceOf }, /// A custom event emitted by the contract. ContractEmitted { @@ -861,7 +861,7 @@ pub mod pallet { }, /// A code with the specified hash was removed. - CodeRemoved { code_hash: T::Hash }, + CodeRemoved { code_hash: T::Hash, deposit_released: BalanceOf }, /// A contract's code was updated. ContractCodeUpdated { @@ -901,12 +901,6 @@ pub mod pallet { /// The code hash that was delegate called. code_hash: CodeHash, }, - - /// Some funds have been held as storage deposit. - StorageDepositHeld { who: T::AccountId, amount: BalanceOf }, - - /// Some funds have been released as storage deposit. - StorageDepositReleased { who: T::AccountId, amount: BalanceOf }, } #[pallet::error] diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 77df85af9d6d1..e791eb4e42266 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -3523,21 +3523,14 @@ fn upload_code_works() { assert_eq!( System::events(), - vec![ - EventRecord { - phase: Phase::Initialization, - event: RuntimeEvent::Contracts(pallet_contracts::Event::StorageDepositHeld { - who: ALICE, - amount: deposit_expected, - }), - topics: vec![hash(&ALICE)], - }, - EventRecord { - phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::Event::CodeStored { code_hash }), - topics: vec![code_hash], - }, - ] + vec![EventRecord { + phase: Phase::Initialization, + event: RuntimeEvent::Contracts(crate::Event::CodeStored { + code_hash, + deposit_held: deposit_expected + }), + topics: vec![code_hash], + },] ); }); } @@ -3619,30 +3612,18 @@ fn remove_code_works() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(pallet_contracts::Event::StorageDepositHeld { - who: ALICE, - amount: deposit_expected, + event: RuntimeEvent::Contracts(crate::Event::CodeStored { + code_hash, + deposit_held: deposit_expected }), - topics: vec![hash(&ALICE)], - }, - EventRecord { - phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::Event::CodeStored { code_hash }), topics: vec![code_hash], }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts( - pallet_contracts::Event::StorageDepositReleased { - who: ALICE, - amount: deposit_expected, - } - ), - topics: vec![hash(&ALICE)], - }, - EventRecord { - phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::Event::CodeRemoved { code_hash }), + event: RuntimeEvent::Contracts(crate::Event::CodeRemoved { + code_hash, + deposit_released: deposit_expected + }), topics: vec![code_hash], }, ] @@ -3676,21 +3657,14 @@ fn remove_code_wrong_origin() { assert_eq!( System::events(), - vec![ - EventRecord { - phase: Phase::Initialization, - event: RuntimeEvent::Contracts(pallet_contracts::Event::StorageDepositHeld { - who: ALICE, - amount: deposit_expected, - }), - topics: vec![hash(&ALICE)], - }, - EventRecord { - phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::Event::CodeStored { code_hash }), - topics: vec![code_hash], - }, - ] + vec![EventRecord { + phase: Phase::Initialization, + event: RuntimeEvent::Contracts(crate::Event::CodeStored { + code_hash, + deposit_held: deposit_expected + }), + topics: vec![code_hash], + },] ); }); } @@ -3784,15 +3758,10 @@ fn instantiate_with_zero_balance_works() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(pallet_contracts::Event::StorageDepositHeld { - who: ALICE, - amount: deposit_expected, + event: RuntimeEvent::Contracts(crate::Event::CodeStored { + code_hash, + deposit_held: deposit_expected }), - topics: vec![hash(&ALICE)], - }, - EventRecord { - phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::Event::CodeStored { code_hash }), topics: vec![code_hash], }, EventRecord { @@ -3896,15 +3865,10 @@ fn instantiate_with_below_existential_deposit_works() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(pallet_contracts::Event::StorageDepositHeld { - who: ALICE, - amount: deposit_expected, + event: RuntimeEvent::Contracts(crate::Event::CodeStored { + code_hash, + deposit_held: deposit_expected }), - topics: vec![hash(&ALICE)], - }, - EventRecord { - phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::Event::CodeStored { code_hash }), topics: vec![code_hash], }, EventRecord { diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index e37af37ab6e6f..46d4a7a59703d 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -46,7 +46,6 @@ use frame_support::{ ensure, traits::{fungible::MutateHold, tokens::Precision::BestEffort}, }; -use sp_api::HashT; use sp_core::Get; use sp_runtime::RuntimeDebug; use sp_std::prelude::*; @@ -245,18 +244,13 @@ impl WasmBlob { ) .map_err(|_| >::StorageDepositNotEnoughFunds)?; - >::deposit_event( - vec![T::Hashing::hash_of(&self.code_info.owner)], - Event::StorageDepositHeld { - who: self.code_info.owner.clone(), - amount: deposit, - }, - ); - self.code_info.refcount = 0; >::insert(code_hash, &self.code); *stored_code_info = Some(self.code_info.clone()); - >::deposit_event(vec![code_hash], Event::CodeStored { code_hash }); + >::deposit_event( + vec![code_hash], + Event::CodeStored { code_hash, deposit_held: deposit }, + ); Ok(deposit) }, } @@ -275,18 +269,14 @@ impl WasmBlob { code_info.deposit, BestEffort, ); - - >::deposit_event( - vec![T::Hashing::hash_of(&code_info.owner)], - Event::StorageDepositReleased { - who: code_info.owner.clone(), - amount: code_info.deposit, - }, - ); + let deposit_released = code_info.deposit; *existing = None; >::remove(&code_hash); - >::deposit_event(vec![code_hash], Event::CodeRemoved { code_hash }); + >::deposit_event( + vec![code_hash], + Event::CodeRemoved { code_hash, deposit_released }, + ); Ok(()) } else { Err(>::CodeNotFound.into()) From 41812ef6d04a89d38c2b8b320149483d72a233f8 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Mon, 31 Jul 2023 15:23:21 +0200 Subject: [PATCH 100/105] update cargo --- Cargo.lock | 1063 +++++++++++++++++++++++++++------------------------- 1 file changed, 560 insertions(+), 503 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 93a8e5e988305..578e0d020a88e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -21,6 +21,15 @@ dependencies = [ "gimli", ] +[[package]] +name = "addr2line" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" +dependencies = [ + "gimli", +] + [[package]] name = "adler" version = "1.0.2" @@ -103,7 +112,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", "once_cell", "version_check", ] @@ -115,20 +124,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if", - "getrandom 0.2.9", + "getrandom 0.2.10", "once_cell", "version_check", ] -[[package]] -name = "aho-corasick" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" -dependencies = [ - "memchr", -] - [[package]] name = "aho-corasick" version = "1.0.2" @@ -185,15 +185,15 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" +checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" [[package]] name = "anstyle-parse" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" +checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" dependencies = [ "utf8parse", ] @@ -219,9 +219,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.71" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" +checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" [[package]] name = "approx" @@ -504,9 +504,9 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "assert_cmd" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86d6b683edf8d1119fe420a94f8a7e389239666aa72e65495d91c00462510151" +checksum = "88903cb14723e4d4003335bb7f8a14f27691649105346a0f0957466c096adfe6" dependencies = [ "anstyle", "bstr", @@ -525,9 +525,9 @@ checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" [[package]] name = "async-channel" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" +checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" dependencies = [ "concurrent-queue", "event-listener", @@ -548,7 +548,7 @@ dependencies = [ "log", "parking", "polling", - "rustix 0.37.19", + "rustix 0.37.23", "slab", "socket2 0.4.9", "waker-fn", @@ -571,7 +571,7 @@ checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -582,7 +582,7 @@ checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" dependencies = [ "async-stream-impl", "futures-core", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", ] [[package]] @@ -593,31 +593,31 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] name = "async-trait" -version = "0.1.68" +version = "0.1.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" +checksum = "cc6dde6e4ed435a4c1ee4e73592f5ba9da2151af10076cc04858746af9352d09" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] name = "asynchronous-codec" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06a0daa378f5fd10634e44b0a29b2a87b890657658e072a30d6f26e57ddee182" +checksum = "4057f2c32adbb2fc158e22fb38433c8e9bbf76b75a4732c7c0cbaf695fb65568" dependencies = [ "bytes", "futures-sink", "futures-util", "memchr", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", ] [[package]] @@ -639,16 +639,16 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.67" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" +checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" dependencies = [ - "addr2line", + "addr2line 0.20.0", "cc", "cfg-if", "libc", - "miniz_oxide 0.6.2", - "object", + "miniz_oxide", + "object 0.31.1", "rustc-demangle", ] @@ -684,9 +684,9 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "basic-toml" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c0de75129aa8d0cceaf750b89013f0e08804d6ec61416da787b35ad0d7cddf1" +checksum = "7bfc506e7a2370ec239e1d072507b2a80c833083699d3c6fa176fbb4de8448c6" dependencies = [ "serde", ] @@ -727,19 +727,19 @@ version = "0.65.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cexpr", "clang-sys", "lazy_static", "lazycell", "peeking_take_while", - "prettyplease 0.2.6", + "prettyplease 0.2.12", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -748,6 +748,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" + [[package]] name = "bitvec" version = "1.0.1" @@ -777,7 +783,7 @@ checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" dependencies = [ "arrayref", "arrayvec 0.7.4", - "constant_time_eq", + "constant_time_eq 0.2.6", ] [[package]] @@ -788,20 +794,20 @@ checksum = "6637f448b9e61dfadbdcbae9a885fadee1f3eaffb1f8d3c1965d3ade8bdfd44f" dependencies = [ "arrayref", "arrayvec 0.7.4", - "constant_time_eq", + "constant_time_eq 0.2.6", ] [[package]] name = "blake3" -version = "1.3.3" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ae2468a89544a466886840aa467a25b766499f4f04bf7d9fcd10ecee9fccef" +checksum = "199c42ab6972d92c9f8995f086273d25c42fc0f7b2a1fcefba465c1352d25ba5" dependencies = [ "arrayref", "arrayvec 0.7.4", "cc", "cfg-if", - "constant_time_eq", + "constant_time_eq 0.3.0", "digest 0.10.7", ] @@ -873,13 +879,12 @@ dependencies = [ [[package]] name = "bstr" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a246e68bb43f6cd9db24bea052a53e40405417c5fb372e3d1a8a7f770a564ef5" +checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05" dependencies = [ "memchr", - "once_cell", - "regex-automata", + "regex-automata 0.3.4", "serde", ] @@ -941,18 +946,18 @@ dependencies = [ [[package]] name = "camino" -version = "1.1.4" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c530edf18f37068ac2d977409ed5cd50d53d73bc653c7647b48eb78976ac9ae2" +checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" dependencies = [ "serde", ] [[package]] name = "cargo-platform" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" +checksum = "2cfa25e60aea747ec7e1124f238816749faa93759c6ff5b31f1ccdda137f4479" dependencies = [ "serde", ] @@ -965,7 +970,7 @@ checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" dependencies = [ "camino", "cargo-platform", - "semver 1.0.17", + "semver 1.0.18", "serde", "serde_json", "thiserror", @@ -997,9 +1002,9 @@ dependencies = [ [[package]] name = "cfg-expr" -version = "0.15.2" +version = "0.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e70d3ad08698a0568b0562f22710fe6bfc1f4a61a367c77d0398c562eadd453a" +checksum = "b40ccee03b5175c18cde8f37e7d2a33bcef6f8ec8f7cc0d81090d1bb380949c9" dependencies = [ "smallvec", ] @@ -1046,7 +1051,7 @@ name = "chain-spec-builder" version = "2.0.0" dependencies = [ "ansi_term", - "clap 4.3.2", + "clap 4.3.19", "node-cli", "rand 0.8.5", "sc-chain-spec", @@ -1155,17 +1160,17 @@ version = "3.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ - "bitflags", + "bitflags 1.3.2", "clap_lex 0.2.4", - "indexmap", + "indexmap 1.9.3", "textwrap", ] [[package]] name = "clap" -version = "4.3.2" +version = "4.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "401a4694d2bf92537b6867d94de48c4842089645fdcdf6c71865b175d836e9c2" +checksum = "5fd304a20bff958a57f04c4e96a2e7594cc4490a0e809cbd48bb6437edaa452d" dependencies = [ "clap_builder", "clap_derive", @@ -1174,36 +1179,35 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.1" +version = "4.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72394f3339a76daf211e57d4bcb374410f3965dcc606dd0e03738c7888766980" +checksum = "01c6a3f08f1fe5662a35cfe393aec09c4df95f60ee93b7556505260f75eee9e1" dependencies = [ "anstream", "anstyle", - "bitflags", "clap_lex 0.5.0", "strsim", ] [[package]] name = "clap_complete" -version = "4.3.1" +version = "4.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6b5c519bab3ea61843a7923d074b04245624bb84a64a8c150f5deb014e388b" +checksum = "5fc443334c81a804575546c5a8a79b4913b50e28d69232903604cada1de817ce" dependencies = [ - "clap 4.3.2", + "clap 4.3.19", ] [[package]] name = "clap_derive" -version = "4.3.2" +version = "4.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f" +checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -1239,9 +1243,9 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "comfy-table" -version = "7.0.0" +version = "7.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9e1f7e5d046697d34b593bdba8ee31f4649366e452a2ccabb3baf3511e503d1" +checksum = "9ab77dbd8adecaf3f0db40581631b995f312a8a5ae3aa9993188bb8f23d83a5b" dependencies = [ "strum", "strum_macros", @@ -1278,9 +1282,9 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.9.2" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" +checksum = "795bc6e66a8e340f075fcf6227e417a2dc976b92b91f3cdc778bb858778b6747" [[package]] name = "const-random" @@ -1298,7 +1302,7 @@ version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d7d6ab3c3a2282db210df5f02c4dab6e0a7057af0fb7ebd4070f30fe05c0ddb" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", "once_cell", "proc-macro-hack", "tiny-keccak", @@ -1306,9 +1310,15 @@ dependencies = [ [[package]] name = "constant_time_eq" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13418e745008f7349ec7e449155f419a61b92b58a99cc3616942b926825ec76b" +checksum = "21a53c0a4d288377e7415b53dcfc3c04da5cdc2cc95c8d5ac178b58f0b861ad6" + +[[package]] +name = "constant_time_eq" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" [[package]] name = "constcat" @@ -1352,9 +1362,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.7" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" +checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" dependencies = [ "libc", ] @@ -1527,22 +1537,22 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.14" +version = "0.9.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" +checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "memoffset 0.8.0", + "memoffset 0.9.0", "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" dependencies = [ "cfg-if", ] @@ -1596,16 +1606,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "ctor" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" -dependencies = [ - "quote", - "syn 1.0.109", -] - [[package]] name = "ctr" version = "0.8.0" @@ -1666,9 +1666,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.95" +version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109308c20e8445959c2792e81871054c6a17e6976489a93d2769641a2ba5839c" +checksum = "f68e12e817cb19eaab81aaec582b4052d07debd3c3c6b083b9d361db47c7dc9d" dependencies = [ "cc", "cxxbridge-flags", @@ -1678,9 +1678,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.95" +version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daf4c6755cdf10798b97510e0e2b3edb9573032bd9379de8fffa59d68165494f" +checksum = "e789217e4ab7cf8cc9ce82253180a9fe331f35f5d339f0ccfe0270b39433f397" dependencies = [ "cc", "codespan-reporting", @@ -1688,24 +1688,24 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] name = "cxxbridge-flags" -version = "1.0.95" +version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "882074421238e84fe3b4c65d0081de34e5b323bf64555d3e61991f76eb64a7bb" +checksum = "78a19f4c80fd9ab6c882286fa865e92e07688f4387370a209508014ead8751d0" [[package]] name = "cxxbridge-macro" -version = "1.0.95" +version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a076022ece33e7686fb76513518e219cca4fce5750a8ae6d1ce6c0f48fd1af9" +checksum = "b8fcfa71f66c8563c4fa9dd2bb68368d50267856f831ac5d85367e0805f9606c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -1736,9 +1736,9 @@ dependencies = [ [[package]] name = "der" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56acb310e15652100da43d130af8d97b509e95af61aab1c5a7939ef24337ee17" +checksum = "0c7ed52955ce76b1554f509074bb357d3fb8ac9b51288a65a3fd480d1dfba946" dependencies = [ "const-oid", "zeroize", @@ -1862,9 +1862,9 @@ dependencies = [ [[package]] name = "dissimilar" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "210ec60ae7d710bed8683e333e9d2855a8a56a3e9892b38bad3bb0d4d29b0d5e" +checksum = "86e3bdc80eee6e16b2b6b0f87fbc98c04bee3455e35174c0de1a125d0688c632" [[package]] name = "doc-comment" @@ -1902,7 +1902,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.18", + "syn 2.0.28", "termcolor", "walkdir", ] @@ -1919,7 +1919,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.18", + "syn 2.0.28", "termcolor", "walkdir", ] @@ -1938,9 +1938,9 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "dtoa" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65d09067bfacaa79114679b279d7f5885b53295b1e2cfb4e79c8e4bd3d633169" +checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653" [[package]] name = "dyn-clonable" @@ -1965,15 +1965,15 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" +checksum = "304e6508efa593091e97a9abbc10f90aa7ca635b6d2784feff3c89d41dd12272" [[package]] name = "ecdsa" -version = "0.16.7" +version = "0.16.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0997c976637b606099b9985693efa3581e84e41f5c11ba5255f88711058ad428" +checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" dependencies = [ "der", "digest 0.10.7", @@ -2022,9 +2022,9 @@ dependencies = [ [[package]] name = "either" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "elliptic-curve" @@ -2080,7 +2080,7 @@ checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -2115,11 +2115,17 @@ version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "errno" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" dependencies = [ "errno-dragonfly", "libc", @@ -2161,7 +2167,7 @@ dependencies = [ "fs-err", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -2185,6 +2191,12 @@ dependencies = [ "instant", ] +[[package]] +name = "fastrand" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" + [[package]] name = "fdlimit" version = "0.2.1" @@ -2274,7 +2286,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" dependencies = [ "crc32fast", - "miniz_oxide 0.7.1", + "miniz_oxide", ] [[package]] @@ -2358,7 +2370,7 @@ dependencies = [ "Inflector", "array-bytes", "chrono", - "clap 4.3.2", + "clap 4.3.19", "comfy-table", "frame-benchmarking", "frame-support", @@ -2424,7 +2436,7 @@ dependencies = [ "quote", "scale-info", "sp-arithmetic", - "syn 2.0.18", + "syn 2.0.28", "trybuild", ] @@ -2450,7 +2462,7 @@ dependencies = [ name = "frame-election-solution-type-fuzzer" version = "2.0.0-alpha.5" dependencies = [ - "clap 4.3.2", + "clap 4.3.19", "frame-election-provider-solution-type", "frame-election-provider-support", "frame-support", @@ -2526,7 +2538,7 @@ dependencies = [ "aquamarine", "array-bytes", "assert_matches", - "bitflags", + "bitflags 1.3.2", "environmental", "frame-metadata", "frame-support-procedural", @@ -2573,7 +2585,7 @@ dependencies = [ "proc-macro-warning", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -2584,7 +2596,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -2593,7 +2605,7 @@ version = "3.0.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -2722,11 +2734,11 @@ dependencies = [ [[package]] name = "fs4" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7672706608ecb74ab2e055c68327ffc25ae4cac1e12349204fd5fb0f3487cce2" +checksum = "2eeb4ed9e12f43b7fa0baae3f9cdda28352770132ef2e09a23760c29cae8bd47" dependencies = [ - "rustix 0.37.19", + "rustix 0.38.4", "windows-sys 0.48.0", ] @@ -2797,12 +2809,12 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" dependencies = [ - "fastrand", + "fastrand 1.9.0", "futures-core", "futures-io", "memchr", "parking", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "waker-fn", ] @@ -2814,7 +2826,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -2859,7 +2871,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "pin-utils", "slab", ] @@ -2929,9 +2941,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "js-sys", @@ -2962,12 +2974,12 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.2" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" +checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" dependencies = [ "fallible-iterator", - "indexmap", + "indexmap 1.9.3", "stable_deref_trait", ] @@ -2979,11 +2991,11 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.10" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" +checksum = "aca8bbd8e0707c1887a8bbb7e6b40e228f251ff5d62c8220a4a7a53c73aff006" dependencies = [ - "aho-corasick 0.7.20", + "aho-corasick", "bstr", "fnv", "log", @@ -3003,9 +3015,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.19" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d357c7ae988e7d2182f7d7871d0b963962420b0678b0997ce7de72001aeab782" +checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" dependencies = [ "bytes", "fnv", @@ -3013,7 +3025,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap", + "indexmap 1.9.3", "slab", "tokio", "tokio-util", @@ -3073,6 +3085,12 @@ dependencies = [ "ahash 0.8.3", ] +[[package]] +name = "hashbrown" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" + [[package]] name = "heck" version = "0.4.1" @@ -3090,18 +3108,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] - -[[package]] -name = "hermit-abi" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" [[package]] name = "hex" @@ -3206,14 +3215,14 @@ checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", "http", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", ] [[package]] name = "http-range-header" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29" +checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" [[package]] name = "httparse" @@ -3235,9 +3244,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.26" +version = "0.14.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" +checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" dependencies = [ "bytes", "futures-channel", @@ -3249,7 +3258,7 @@ dependencies = [ "httparse", "httpdate", "itoa", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "socket2 0.4.9", "tokio", "tower-service", @@ -3275,24 +3284,25 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0646026eb1b3eea4cd9ba47912ea5ce9cc07713d105b1a14698f4e6433d348b7" +checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" dependencies = [ + "futures-util", "http", "hyper", "log", - "rustls 0.21.1", + "rustls 0.21.5", "rustls-native-certs", "tokio", - "tokio-rustls 0.24.0", + "tokio-rustls 0.24.1", ] [[package]] name = "iana-time-zone" -version = "0.1.56" +version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" +checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -3431,6 +3441,16 @@ dependencies = [ "serde", ] +[[package]] +name = "indexmap" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +dependencies = [ + "equivalent", + "hashbrown 0.14.0", +] + [[package]] name = "indexmap-nostd" version = "0.4.0" @@ -3489,7 +3509,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.1", + "hermit-abi 0.3.2", "libc", "windows-sys 0.48.0", ] @@ -3502,31 +3522,30 @@ checksum = "aa2f047c0a98b2f299aa5d6d7088443570faae494e9ae1305e48be000c9e0eb1" [[package]] name = "ipconfig" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd302af1b90f2463a98fa5ad469fc212c8e3175a41c3068601bfa2727591c5be" +checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" dependencies = [ - "socket2 0.4.9", + "socket2 0.5.3", "widestring", - "winapi", + "windows-sys 0.48.0", "winreg", ] [[package]] name = "ipnet" -version = "2.7.2" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" +checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" [[package]] name = "is-terminal" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.1", - "io-lifetimes", - "rustix 0.37.19", + "hermit-abi 0.3.2", + "rustix 0.38.4", "windows-sys 0.48.0", ] @@ -3541,9 +3560,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "jobserver" @@ -3556,9 +3575,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.63" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f37a4a5928311ac501dee68b3c7613a1037d0edb30c8e5427bd832d55d1b790" +checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" dependencies = [ "wasm-bindgen", ] @@ -3913,9 +3932,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.145" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc86cde3ff845662b8f4ef6cb50ea0e20c524eb3d29ae048287e06a1b3fa6a81" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "libloading" @@ -3948,7 +3967,7 @@ dependencies = [ "bytes", "futures", "futures-timer", - "getrandom 0.2.9", + "getrandom 0.2.10", "instant", "libp2p-allow-block-list", "libp2p-connection-limits", @@ -3985,9 +4004,9 @@ dependencies = [ [[package]] name = "libp2p-connection-limits" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d45dd90e8f0e1fa59e85ff5316dd4d1ac41a9a507e79cda1b0e9b7be43ad1a56" +checksum = "2f5107ad45cb20b2f6c3628c7b6014b996fcb13a88053f4569c872c6e30abf58" dependencies = [ "libp2p-core", "libp2p-identity", @@ -4062,9 +4081,9 @@ dependencies = [ [[package]] name = "libp2p-identity" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2874d9c6575f1d7a151022af5c42bb0ffdcdfbafe0a6fd039de870b384835a2" +checksum = "a38d6012784fe4cc14e6d443eb415b11fc7c456dc15d9f0d90d9b70bc7ac3ec1" dependencies = [ "bs58 0.5.0", "ed25519-dalek", @@ -4079,9 +4098,9 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.44.2" +version = "0.44.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0eeb75763862ff762c3240722fbed06ff6bb025d6afbdf2ce887f3610657789" +checksum = "4f2584b0c27f879a1cca4b753fd96874109e5a2f46bd6e30924096456c2ba9b2" dependencies = [ "arrayvec 0.7.4", "asynchronous-codec", @@ -4206,9 +4225,9 @@ dependencies = [ [[package]] name = "libp2p-swarm" -version = "0.43.1" +version = "0.43.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de15b2097fc3bde063df8c202803538ff467fedb18f01c13bc5da55913d246c" +checksum = "43106820057e0f65c77b01a3873593f66e676da4e40c70c3a809b239109f1d30" dependencies = [ "either", "fnv", @@ -4237,7 +4256,7 @@ dependencies = [ "proc-macro-warning", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -4369,9 +4388,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.9" +version = "1.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56ee889ecc9568871456d42f603d6a0ce59ff328d291063a45cbdf0036baf6db" +checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b" dependencies = [ "cc", "pkg-config", @@ -4380,9 +4399,9 @@ dependencies = [ [[package]] name = "link-cplusplus" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" +checksum = "9d240c6f7e1ba3a28b0249f774e6a9dd0175054b52dfbb61b16eb8505c3785c9" dependencies = [ "cc", ] @@ -4404,9 +4423,9 @@ dependencies = [ [[package]] name = "linregress" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "475015a7f8f017edb28d2e69813be23500ad4b32cfe3421c4148efc97324ee52" +checksum = "4de0b5f52a9f84544d268f5fabb71b38962d6aa3c6600b8bcd27d44ccf9c9c45" dependencies = [ "nalgebra", ] @@ -4423,6 +4442,12 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +[[package]] +name = "linux-raw-sys" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" + [[package]] name = "lite-json" version = "0.2.0" @@ -4459,9 +4484,9 @@ checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" [[package]] name = "lru" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03f1160296536f10c833a82dca22267d5486734230d47bf00bf435885814ba1e" +checksum = "718e8fae447df0c7e1ba7f5189829e63fd536945c8988d61444c19039f16b670" dependencies = [ "hashbrown 0.13.2", ] @@ -4513,7 +4538,7 @@ dependencies = [ "macro_magic_core", "macro_magic_macros", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -4527,7 +4552,7 @@ dependencies = [ "macro_magic_core_macros", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -4538,7 +4563,7 @@ checksum = "c12469fc165526520dff2807c2975310ab47cf7190a45b99b49a7dc8befab17b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -4549,7 +4574,7 @@ checksum = "b8fb85ec1620619edf2984a7693497d4ec88a9665d8b87e942856884c92dbf2a" dependencies = [ "macro_magic_core", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -4570,7 +4595,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" dependencies = [ - "regex-automata", + "regex-automata 0.1.10", ] [[package]] @@ -4579,7 +4604,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" dependencies = [ - "regex-automata", + "regex-automata 0.1.10", ] [[package]] @@ -4610,7 +4635,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffc89ccdc6e10d6907450f753537ebc5c5d3460d2e4e62ea74bd571db62c0f9e" dependencies = [ - "rustix 0.37.19", + "rustix 0.37.23", ] [[package]] @@ -4640,6 +4665,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memoffset" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +dependencies = [ + "autocfg", +] + [[package]] name = "memory-db" version = "0.32.0" @@ -4667,15 +4701,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "miniz_oxide" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" -dependencies = [ - "adler", -] - [[package]] name = "miniz_oxide" version = "0.7.1" @@ -4899,9 +4924,9 @@ dependencies = [ [[package]] name = "nalgebra" -version = "0.32.2" +version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d68d47bba83f9e2006d117a9a33af1524e655516b8919caac694427a6fb1e511" +checksum = "307ed9b18cc2423f29e83f84fd23a8e73628727990181f18641a8b5dc2ab1caa" dependencies = [ "approx", "matrixmultiply", @@ -4915,9 +4940,9 @@ dependencies = [ [[package]] name = "nalgebra-macros" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d232c68884c0c99810a5a4d333ef7e47689cfd0edc85efc9e54e1e6bf5212766" +checksum = "91761aed67d03ad966ef783ae962ef9bbaca728d2dd7ceb7939ec110fffad998" dependencies = [ "proc-macro2", "quote", @@ -4952,7 +4977,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9ea4302b9759a7a88242299225ea3688e63c85ea136371bb6cf94fd674efaab" dependencies = [ "anyhow", - "bitflags", + "bitflags 1.3.2", "byteorder", "libc", "netlink-packet-core", @@ -5005,7 +5030,7 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "libc", ] @@ -5016,7 +5041,7 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "libc", "memoffset 0.7.1", @@ -5029,7 +5054,7 @@ name = "node-bench" version = "0.9.0-dev" dependencies = [ "array-bytes", - "clap 4.3.2", + "clap 4.3.19", "derive_more", "fs_extra", "futures", @@ -5066,7 +5091,7 @@ version = "3.0.0-dev" dependencies = [ "array-bytes", "assert_cmd", - "clap 4.3.2", + "clap 4.3.19", "clap_complete", "criterion", "frame-benchmarking-cli", @@ -5192,7 +5217,7 @@ dependencies = [ name = "node-inspect" version = "0.9.0-dev" dependencies = [ - "clap 4.3.2", + "clap 4.3.19", "parity-scale-codec", "sc-cli", "sc-client-api", @@ -5246,7 +5271,7 @@ dependencies = [ name = "node-runtime-generate-bags" version = "3.0.0" dependencies = [ - "clap 4.3.2", + "clap 4.3.19", "generate-bags", "kitchensink-runtime", ] @@ -5255,7 +5280,7 @@ dependencies = [ name = "node-template" version = "4.0.0-dev" dependencies = [ - "clap 4.3.2", + "clap 4.3.19", "frame-benchmarking", "frame-benchmarking-cli", "frame-system", @@ -5298,7 +5323,7 @@ dependencies = [ name = "node-template-release" version = "3.0.0" dependencies = [ - "clap 4.3.2", + "clap 4.3.19", "flate2", "fs_extra", "glob", @@ -5414,9 +5439,9 @@ dependencies = [ [[package]] name = "num" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" +checksum = "b05180d69e3da0e530ba2a1dae5110317e49e3b7f3d41be227dc5f92e49ee7af" dependencies = [ "num-bigint", "num-complex", @@ -5491,9 +5516,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ "autocfg", "libm 0.2.7", @@ -5501,11 +5526,11 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.2.6", + "hermit-abi 0.3.2", "libc", ] @@ -5523,7 +5548,16 @@ checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" dependencies = [ "crc32fast", "hashbrown 0.13.2", - "indexmap", + "indexmap 1.9.3", + "memchr", +] + +[[package]] +name = "object" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" +dependencies = [ "memchr", ] @@ -5559,18 +5593,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "os_str_bytes" -version = "6.5.0" +version = "6.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267" - -[[package]] -name = "output_vt100" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66" -dependencies = [ - "winapi", -] +checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac" [[package]] name = "overload" @@ -5968,7 +5993,7 @@ version = "4.0.0-dev" dependencies = [ "array-bytes", "assert_matches", - "bitflags", + "bitflags 1.3.2", "env_logger 0.9.3", "environmental", "frame-benchmarking", @@ -6005,7 +6030,7 @@ dependencies = [ name = "pallet-contracts-primitives" version = "24.0.0" dependencies = [ - "bitflags", + "bitflags 1.3.2", "parity-scale-codec", "scale-info", "sp-runtime", @@ -6019,7 +6044,7 @@ version = "4.0.0-dev" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -7054,7 +7079,7 @@ dependencies = [ "proc-macro2", "quote", "sp-runtime", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -7095,7 +7120,7 @@ dependencies = [ "substrate-state-trie-migration-rpc", "thousands", "tokio", - "zstd 0.12.3+zstd.1.5.2", + "zstd 0.12.4", ] [[package]] @@ -7339,9 +7364,9 @@ dependencies = [ [[package]] name = "parity-db" -version = "0.4.8" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4890dcb9556136a4ec2b0c51fa4a08c8b733b829506af8fff2e853f3a065985b" +checksum = "78f19d20a0d2cc52327a88d131fa1c4ea81ea4a04714aedcfeca2dd410049cf8" dependencies = [ "blake2", "crc32fast", @@ -7359,9 +7384,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.6.1" +version = "3.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2287753623c76f953acd29d15d8100bcab84d29db78fb6f352adb3c53e83b967" +checksum = "dd8e946cc0cc711189c0b0249fb8b599cbeeab9784d83c415719368bb8d4ac64" dependencies = [ "arrayvec 0.7.4", "bitvec", @@ -7374,9 +7399,9 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.1" +version = "3.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b6937b5e67bfba3351b87b040d48352a2fcb6ad72f81855412ce97b45c8f110" +checksum = "2a296c3079b5fefbc499e1de58dc26c09b1b9a5952d26694ee89f04a43ebbb3e" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -7441,7 +7466,7 @@ dependencies = [ "libc", "redox_syscall 0.3.5", "smallvec", - "windows-targets 0.48.0", + "windows-targets 0.48.1", ] [[package]] @@ -7452,9 +7477,9 @@ checksum = "7924d1d0ad836f665c9065e26d016c673ece3993f30d340068b16f282afc1156" [[package]] name = "paste" -version = "1.0.12" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "pbkdf2" @@ -7488,9 +7513,9 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" -version = "2.6.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e68e84bfb01f0507134eac1e9b410a12ba379d064eab48c50ba4ce329a527b70" +checksum = "0d2d1d55045829d65aad9d389139882ad623b33b904e7c9f1b10c5b8927298e5" dependencies = [ "thiserror", "ucd-trie", @@ -7498,9 +7523,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.6.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b79d4c71c865a25a4322296122e3924d30bc8ee0834c8bfc8b95f7f054afbfb" +checksum = "5f94bca7e7a599d89dea5dfa309e217e7906c3c007fb9c3299c40b10d6a315d3" dependencies = [ "pest", "pest_generator", @@ -7508,22 +7533,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.6.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c435bf1076437b851ebc8edc3a18442796b30f1728ffea6262d59bbe28b077e" +checksum = "99d490fe7e8556575ff6911e45567ab95e71617f43781e5c05490dc8d75c965c" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] name = "pest_meta" -version = "2.6.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "745a452f8eb71e39ffd8ee32b3c5f51d03845f99786fa9b68db6ff509c505411" +checksum = "2674c66ebb4b4d9036012091b537aae5878970d6999f81a265034d85b136b341" dependencies = [ "once_cell", "pest", @@ -7537,27 +7562,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" dependencies = [ "fixedbitset", - "indexmap", + "indexmap 1.9.3", ] [[package]] name = "pin-project" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c95a7476719eab1e366eaf73d0260af3021184f18177925b07f54b30089ceead" +checksum = "030ad2bc4db10a8944cb0d837f158bdfec4d4a4873ab701a95046770d11f8842" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" +checksum = "ec2e072ecce94ec471b13398d5402c188e76ac03cf74dd1a975161b23a3f6d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -7568,9 +7593,9 @@ checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" [[package]] name = "pin-utils" @@ -7602,9 +7627,9 @@ checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" [[package]] name = "plotters" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2538b639e642295546c50fcd545198c9d64ee2a38620a628724a3b266d5fbf97" +checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" dependencies = [ "num-traits", "plotters-backend", @@ -7615,15 +7640,15 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "193228616381fecdc1224c62e96946dfbc73ff4384fba576e052ff8c1bea8142" +checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" [[package]] name = "plotters-svg" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a81d2759aae1dae668f783c308bc5c8ebd191ff4184aaa1b37f65a6ae5a56f" +checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" dependencies = [ "plotters-backend", ] @@ -7635,12 +7660,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" dependencies = [ "autocfg", - "bitflags", + "bitflags 1.3.2", "cfg-if", "concurrent-queue", "libc", "log", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "windows-sys 0.48.0", ] @@ -7681,9 +7706,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.3.3" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "767eb9f07d4a5ebcb39bbf2d452058a93c011373abf6832e24194a1c3f004794" +checksum = "f32154ba0af3a075eefa1eda8bb414ee928f62303a54ea85b8d6638ff1a6ee9e" [[package]] name = "ppv-lite86" @@ -7735,13 +7760,11 @@ dependencies = [ [[package]] name = "pretty_assertions" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a25e9bcb20aa780fd0bb16b72403a9064d6b3f22f026946029acb941a50af755" +checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" dependencies = [ - "ctor", "diff", - "output_vt100", "yansi", ] @@ -7757,12 +7780,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.6" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b69d39aab54d069e7f2fe8cb970493e7834601ca2d8c65fd7bbd183578080d1" +checksum = "6c64d9ba0963cdcea2e1b2230fbae2bab30eb25a174be395c41e764bfb65dd62" dependencies = [ "proc-macro2", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -7827,14 +7850,14 @@ checksum = "70550716265d1ec349c41f70dd4f964b4fd88394efe4405f0c1da679c4799a07" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] name = "proc-macro2" -version = "1.0.60" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] @@ -7989,9 +8012,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.28" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" dependencies = [ "proc-macro2", ] @@ -8061,7 +8084,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", ] [[package]] @@ -8126,7 +8149,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -8135,7 +8158,7 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -8144,29 +8167,29 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", "redox_syscall 0.2.16", "thiserror", ] [[package]] name = "ref-cast" -version = "1.0.16" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43faa91b1c8b36841ee70e97188a869d37ae21759da6846d4be66de5bf7b12c" +checksum = "61ef7e18e8841942ddb1cf845054f8008410030a3997875d9e49b7a363063df1" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.16" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d2275aab483050ab2a7364c1a46604865ee7d6906684e08db0f090acf74f9e7" +checksum = "2dfaf0c85b766276c797f3791f5bc6d5bd116b41d53049af2789666b0c0bc9fa" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -8183,13 +8206,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.8.4" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" +checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" dependencies = [ - "aho-corasick 1.0.2", + "aho-corasick", "memchr", - "regex-syntax 0.7.2", + "regex-automata 0.3.4", + "regex-syntax 0.7.4", ] [[package]] @@ -8201,6 +8225,17 @@ dependencies = [ "regex-syntax 0.6.29", ] +[[package]] +name = "regex-automata" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7b6d6190b7594385f61bd3911cd1be99dfddcfc365a4160cc2ab5bff4aed294" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.7.4", +] + [[package]] name = "regex-syntax" version = "0.6.29" @@ -8209,9 +8244,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" +checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" [[package]] name = "resolv-conf" @@ -8336,16 +8371,16 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.17", + "semver 1.0.18", ] [[package]] name = "rustix" -version = "0.36.14" +version = "0.36.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14e4d67015953998ad0eb82887a0eb0129e18a7e2f3b7b0f6c422fddcd503d62" +checksum = "c37f1bd5ef1b5422177b7646cba67430579cfe2ace80f284fee876bca52ad941" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", @@ -8355,11 +8390,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.19" +version = "0.37.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" +checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", @@ -8367,6 +8402,19 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "rustix" +version = "0.38.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a962918ea88d644592894bc6dc55acc6c0956488adcebbfb6e273506b7fd6e5" +dependencies = [ + "bitflags 2.3.3", + "errno", + "libc", + "linux-raw-sys 0.4.3", + "windows-sys 0.48.0", +] + [[package]] name = "rustls" version = "0.20.8" @@ -8381,21 +8429,21 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.1" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c911ba11bc8433e811ce56fde130ccf32f5127cab0e0194e9c68c5a5b671791e" +checksum = "79ea77c539259495ce8ca47f53e66ae0330a8819f67e23ac96ca02f50e7b7d36" dependencies = [ "log", "ring", - "rustls-webpki", + "rustls-webpki 0.101.2", "sct", ] [[package]] name = "rustls-native-certs" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0167bac7a9f490495f3c33013e7722b53cb087ecbe082fb0c6387c96f634ea50" +checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", "rustls-pemfile", @@ -8405,9 +8453,9 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" +checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ "base64 0.21.2", ] @@ -8422,11 +8470,21 @@ dependencies = [ "untrusted", ] +[[package]] +name = "rustls-webpki" +version = "0.101.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "513722fd73ad80a71f72b61009ea1b584bcfa1483ca93949c8f290298837fa59" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "rustversion" -version = "1.0.12" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "rusty-fork" @@ -8452,9 +8510,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.13" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "safe-mix" @@ -8467,9 +8525,9 @@ dependencies = [ [[package]] name = "safe_arch" -version = "0.6.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "794821e4ccb0d9f979512f9c1973480123f9bd62a90d74ab0f9426fcf8f4a529" +checksum = "f398075ce1e6a179b46f51bd88d0598b92b00d3551f1a2d4ac49e771b56ac354" dependencies = [ "bytemuck", ] @@ -8589,7 +8647,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -8598,7 +8656,7 @@ version = "0.10.0-dev" dependencies = [ "array-bytes", "chrono", - "clap 4.3.2", + "clap 4.3.19", "fdlimit", "futures", "futures-timer", @@ -9120,7 +9178,7 @@ dependencies = [ "log", "parity-scale-codec", "paste", - "rustix 0.36.14", + "rustix 0.36.15", "sc-allocator", "sc-executor-common", "sc-runtime-test", @@ -9246,7 +9304,7 @@ name = "sc-network-common" version = "0.10.0-dev" dependencies = [ "async-trait", - "bitflags", + "bitflags 1.3.2", "futures", "libp2p-identity", "parity-scale-codec", @@ -9412,7 +9470,7 @@ dependencies = [ "futures", "futures-timer", "hyper", - "hyper-rustls 0.24.0", + "hyper-rustls 0.24.1", "lazy_static", "libp2p", "log", @@ -9705,7 +9763,7 @@ dependencies = [ name = "sc-storage-monitor" version = "0.1.0" dependencies = [ - "clap 4.3.2", + "clap 4.3.19", "fs4", "log", "sc-client-db", @@ -9805,7 +9863,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -9874,9 +9932,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.7.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b569c32c806ec3abdf3b5869fb8bf1e0d275a7c1c9b0b05603d9464632649edf" +checksum = "35c0a159d0c45c12b20c5a844feb1fe4bea86e28f17b92a5f0c42193634d3782" dependencies = [ "bitvec", "cfg-if", @@ -9888,9 +9946,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.6.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53012eae69e5aa5c14671942a5dd47de59d4cdcff8532a6dd0e081faf1119482" +checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -9938,15 +9996,15 @@ dependencies = [ [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "scratch" -version = "1.0.5" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" +checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" [[package]] name = "sct" @@ -9960,9 +10018,9 @@ dependencies = [ [[package]] name = "sec1" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0aec48e813d6b90b15f0b8948af3c63483992dee44c03e9930b3eebdabe046e" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ "base16ct", "der", @@ -10001,11 +10059,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.9.1" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc758eb7bffce5b308734e9b0c1468893cae9ff70ebf13e7090be8dcbcc83a8" +checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", @@ -10014,9 +10072,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f51d0c0d83bec45f16480d0ce0058397a69e48fcdc52d1dc8855fb68acbd31a7" +checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" dependencies = [ "core-foundation-sys", "libc", @@ -10042,9 +10100,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" +checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" dependencies = [ "serde", ] @@ -10063,29 +10121,29 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.164" +version = "1.0.179" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" +checksum = "0a5bf42b8d227d4abf38a1ddb08602e229108a517cd4e5bb28f9c7eaafdce5c0" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.164" +version = "1.0.179" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" +checksum = "741e124f5485c7e60c03b043f79f320bff3527f4bbf12cf3831750dc46a0ec2c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] name = "serde_json" -version = "1.0.96" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" +checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" dependencies = [ "itoa", "ryu", @@ -10094,9 +10152,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93107647184f6027e3b7dcb2e11034cf95ffa1e3a682c67951963ac69c1c007d" +checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" dependencies = [ "serde", ] @@ -10342,7 +10400,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -10507,7 +10565,7 @@ dependencies = [ "ark-serialize", "ark-std", "derivative", - "getrandom 0.2.9", + "getrandom 0.2.10", "itertools", "num-traits", "zeroize", @@ -10665,7 +10723,7 @@ name = "sp-core" version = "21.0.0" dependencies = [ "array-bytes", - "bitflags", + "bitflags 1.3.2", "blake2", "bounded-collections", "bs58 0.4.0", @@ -10727,7 +10785,7 @@ version = "9.0.0" dependencies = [ "quote", "sp-core-hashing", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -10771,7 +10829,7 @@ version = "8.0.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -10860,7 +10918,7 @@ name = "sp-maybe-compressed-blob" version = "4.1.0-dev" dependencies = [ "thiserror", - "zstd 0.12.3+zstd.1.5.2", + "zstd 0.12.4", ] [[package]] @@ -10910,7 +10968,7 @@ dependencies = [ name = "sp-npos-elections-fuzzer" version = "2.0.0-alpha.5" dependencies = [ - "clap 4.3.2", + "clap 4.3.19", "honggfuzz", "rand 0.8.5", "sp-npos-elections", @@ -10969,7 +11027,7 @@ dependencies = [ "sp-tracing", "sp-weights", "substrate-test-runtime-client", - "zstd 0.12.3+zstd.1.5.2", + "zstd 0.12.4", ] [[package]] @@ -11003,7 +11061,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -11243,7 +11301,7 @@ dependencies = [ "proc-macro2", "quote", "sp-version", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -11307,9 +11365,9 @@ dependencies = [ [[package]] name = "ss58-registry" -version = "1.40.0" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb47a8ad42e5fc72d5b1eb104a5546937eaf39843499948bb666d6e93c62423b" +checksum = "bfc443bad666016e012538782d9e3006213a7db43e9fb1dda91657dc06a6fa08" dependencies = [ "Inflector", "num-format", @@ -11338,7 +11396,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a2a1c578e98c1c16fc3b8ec1328f7659a500737d7a0c6d625e73e830ff9c1f6" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg_aliases", "libc", "parking_lot 0.11.2", @@ -11366,7 +11424,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fabb238a1cccccfa4c4fb703670c0d157e1256c1ba695abf1b93bd2bb14bab2d" dependencies = [ - "bitflags", + "bitflags 1.3.2", "byteorder", "keccak", "subtle", @@ -11405,7 +11463,7 @@ dependencies = [ name = "subkey" version = "3.0.0" dependencies = [ - "clap 4.3.2", + "clap 4.3.19", "sc-cli", ] @@ -11464,7 +11522,7 @@ dependencies = [ name = "substrate-frame-cli" version = "4.0.0-dev" dependencies = [ - "clap 4.3.2", + "clap 4.3.19", "frame-support", "frame-system", "sc-cli", @@ -11679,7 +11737,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -11703,7 +11761,7 @@ dependencies = [ "sp-maybe-compressed-blob", "strum", "tempfile", - "toml 0.7.4", + "toml 0.7.6", "walkdir", "wasm-opt", ] @@ -11727,9 +11785,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.18" +version = "2.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" +checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" dependencies = [ "proc-macro2", "quote", @@ -11754,7 +11812,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "system-configuration-sys", ] @@ -11777,9 +11835,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tar" -version = "0.4.38" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b55807c0344e1e6c04d7c965f5289c39a8d94ae23ed5c0b57aabac549f871c6" +checksum = "ec96d2ffad078296368d46ff1cb309be1c23c513b4ab0e22a45de0185275ac96" dependencies = [ "filetime", "libc", @@ -11788,21 +11846,20 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.7" +version = "0.12.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" +checksum = "1d2faeef5759ab89935255b1a4cd98e0baf99d1085e37d36599c625dac49ae8e" [[package]] name = "tempfile" -version = "3.6.0" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" +checksum = "5486094ee78b2e5038a6382ed7645bc084dc2ec433426ca4c3cb61e2007b8998" dependencies = [ - "autocfg", "cfg-if", - "fastrand", + "fastrand 2.0.0", "redox_syscall 0.3.5", - "rustix 0.37.19", + "rustix 0.38.4", "windows-sys 0.48.0", ] @@ -11829,22 +11886,22 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -11874,9 +11931,9 @@ dependencies = [ [[package]] name = "tikv-jemalloc-sys" -version = "0.5.3+5.3.0-patched" +version = "0.5.4+5.3.0-patched" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a678df20055b43e57ef8cddde41cdfda9a3c1a060b67f4c5836dfb1d78543ba8" +checksum = "9402443cb8fd499b6f327e40565234ff34dbda27460c5b47db0db77443dd85d1" dependencies = [ "cc", "libc", @@ -11959,7 +12016,7 @@ dependencies = [ "mio", "num_cpus", "parking_lot 0.12.1", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "signal-hook-registry", "socket2 0.4.9", "tokio-macros", @@ -11974,7 +12031,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -12001,11 +12058,11 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0d409377ff5b1e3ca6437aa86c1eb7d40c134bfec254e44c830defa92669db5" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.1", + "rustls 0.21.5", "tokio", ] @@ -12016,7 +12073,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" dependencies = [ "futures-core", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "tokio", "tokio-util", ] @@ -12044,7 +12101,7 @@ dependencies = [ "futures-core", "futures-io", "futures-sink", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "tokio", "tracing", ] @@ -12060,9 +12117,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6135d499e69981f9ff0ef2167955a5333c35e36f6937d382974566b3d5b94ec" +checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" dependencies = [ "serde", "serde_spanned", @@ -12072,20 +12129,20 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.19.10" +version = "0.19.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739" +checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" dependencies = [ - "indexmap", + "indexmap 2.0.0", "serde", "serde_spanned", "toml_datetime", @@ -12105,18 +12162,18 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.4.0" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d1d42a9b3f3ec46ba828e8d376aec14592ea199f70a06a548587ecd1c4ab658" +checksum = "55ae70283aba8d2a8b411c695c437fe25b8b5e44e23e780662002fc72fb47a82" dependencies = [ - "bitflags", + "bitflags 2.3.3", "bytes", "futures-core", "futures-util", "http", "http-body", "http-range-header", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "tower-layer", "tower-service", ] @@ -12141,20 +12198,20 @@ checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", "log", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "tracing-attributes", "tracing-core", ] [[package]] name = "tracing-attributes" -version = "0.1.24" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -12345,7 +12402,7 @@ version = "0.10.0-dev" dependencies = [ "assert_cmd", "async-trait", - "clap 4.3.2", + "clap 4.3.19", "frame-remote-externalities", "frame-try-runtime", "hex", @@ -12377,14 +12434,14 @@ dependencies = [ "substrate-rpc-client", "tempfile", "tokio", - "zstd 0.12.3+zstd.1.5.2", + "zstd 0.12.4", ] [[package]] name = "trybuild" -version = "1.0.80" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501dbdbb99861e4ab6b60eb6a7493956a9defb644fd034bc4a5ef27c693c8a3a" +checksum = "a84e0202ea606ba5ebee8507ab2bfbe89b98551ed9b8f0be198109275cff284b" dependencies = [ "basic-toml", "dissimilar", @@ -12422,9 +12479,9 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "ucd-trie" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" +checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" [[package]] name = "uint" @@ -12446,9 +12503,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "unicode-normalization" @@ -12601,11 +12658,10 @@ dependencies = [ [[package]] name = "want" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" dependencies = [ - "log", "try-lock", ] @@ -12629,9 +12685,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73" +checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -12639,24 +12695,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" +checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.36" +version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d1985d03709c53167ce907ff394f5316aa22cb4e12761295c5dc57dacb6297e" +checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" dependencies = [ "cfg-if", "js-sys", @@ -12666,9 +12722,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258" +checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -12676,28 +12732,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" +checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" +checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "wasm-encoder" -version = "0.29.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18c41dbd92eaebf3612a39be316540b8377c871cb9bde6b064af962984912881" +checksum = "41763f20eafed1399fff1afb466496d3a959f58241436cfdc17e3f5ca954de16" dependencies = [ "leb128", ] @@ -12813,7 +12869,7 @@ version = "0.102.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48134de3d7598219ab9eaf6b91b15d8e50d31da76b8519fe4ecfcec2cf35104b" dependencies = [ - "indexmap", + "indexmap 1.9.3", "url", ] @@ -12835,10 +12891,10 @@ dependencies = [ "anyhow", "bincode", "cfg-if", - "indexmap", + "indexmap 1.9.3", "libc", "log", - "object", + "object 0.30.4", "once_cell", "paste", "psm", @@ -12875,7 +12931,7 @@ dependencies = [ "directories-next", "file-per-thread-logger", "log", - "rustix 0.36.14", + "rustix 0.36.15", "serde", "sha2 0.10.7", "toml 0.5.11", @@ -12897,7 +12953,7 @@ dependencies = [ "cranelift-wasm", "gimli", "log", - "object", + "object 0.30.4", "target-lexicon", "thiserror", "wasmparser", @@ -12915,7 +12971,7 @@ dependencies = [ "cranelift-codegen", "cranelift-native", "gimli", - "object", + "object 0.30.4", "target-lexicon", "wasmtime-environ", ] @@ -12929,9 +12985,9 @@ dependencies = [ "anyhow", "cranelift-entity", "gimli", - "indexmap", + "indexmap 1.9.3", "log", - "object", + "object 0.30.4", "serde", "target-lexicon", "thiserror", @@ -12945,14 +13001,14 @@ version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0de48df552cfca1c9b750002d3e07b45772dd033b0b206d5c0968496abf31244" dependencies = [ - "addr2line", + "addr2line 0.19.0", "anyhow", "bincode", "cfg-if", "cpp_demangle", "gimli", "log", - "object", + "object 0.30.4", "rustc-demangle", "serde", "target-lexicon", @@ -12969,9 +13025,9 @@ version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e0554b84c15a27d76281d06838aed94e13a77d7bf604bbbaf548aa20eb93846" dependencies = [ - "object", + "object 0.30.4", "once_cell", - "rustix 0.36.14", + "rustix 0.36.15", ] [[package]] @@ -12994,7 +13050,7 @@ dependencies = [ "anyhow", "cc", "cfg-if", - "indexmap", + "indexmap 1.9.3", "libc", "log", "mach", @@ -13002,7 +13058,7 @@ dependencies = [ "memoffset 0.8.0", "paste", "rand 0.8.5", - "rustix 0.36.14", + "rustix 0.36.15", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-jit-debug", @@ -13023,9 +13079,9 @@ dependencies = [ [[package]] name = "wast" -version = "60.0.0" +version = "62.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd06cc744b536e30387e72a48fdd492105b9c938bb4f415c39c616a7a0a697ad" +checksum = "b8ae06f09dbe377b889fbd620ff8fa21e1d49d1d9d364983c0cdbf9870cb9f1f" dependencies = [ "leb128", "memchr", @@ -13035,18 +13091,18 @@ dependencies = [ [[package]] name = "wat" -version = "1.0.66" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5abe520f0ab205366e9ac7d3e6b2fc71de44e32a2b58f2ec871b6b575bdcea3b" +checksum = "842e15861d203fb4a96d314b0751cdeaf0f6f8b35e8d81d2953af2af5e44e637" dependencies = [ "wast", ] [[package]] name = "web-sys" -version = "0.3.63" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bdd9ef4e984da1187bf8110c5cf5b845fbc87a23602cdf912386a76fcd3a7c2" +checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" dependencies = [ "js-sys", "wasm-bindgen", @@ -13077,7 +13133,7 @@ version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" dependencies = [ - "rustls-webpki", + "rustls-webpki 0.100.1", ] [[package]] @@ -13093,9 +13149,9 @@ dependencies = [ [[package]] name = "wide" -version = "0.7.9" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cd0496a71f3cc6bc4bf0ed91346426a5099e93d89807e663162dc5a1069ff65" +checksum = "aa469ffa65ef7e0ba0f164183697b89b854253fd31aeb92358b7b6155177d62f" dependencies = [ "bytemuck", "safe_arch", @@ -13103,9 +13159,9 @@ dependencies = [ [[package]] name = "widestring" -version = "0.5.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17882f045410753661207383517a6f62ec3dbeb6a4ed2acce01f0728238d1983" +checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8" [[package]] name = "winapi" @@ -13157,7 +13213,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets 0.48.0", + "windows-targets 0.48.1", ] [[package]] @@ -13175,7 +13231,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.0", + "windows-targets 0.48.1", ] [[package]] @@ -13195,9 +13251,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.0" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ "windows_aarch64_gnullvm 0.48.0", "windows_aarch64_msvc 0.48.0", @@ -13324,20 +13380,21 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "winnow" -version = "0.4.6" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" +checksum = "8bd122eb777186e60c3fdf765a58ac76e41c582f1f535fbf3314434c6b58f3f7" dependencies = [ "memchr", ] [[package]] name = "winreg" -version = "0.10.1" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "winapi", + "cfg-if", + "windows-sys 0.48.0", ] [[package]] @@ -13417,7 +13474,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.18", + "syn 2.0.28", ] [[package]] @@ -13431,11 +13488,11 @@ dependencies = [ [[package]] name = "zstd" -version = "0.12.3+zstd.1.5.2" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76eea132fb024e0e13fd9c2f5d5d595d8a967aa72382ac2f9d39fcc95afd0806" +checksum = "1a27595e173641171fc74a1232b7b1c7a7cb6e18222c11e9dfb9888fa424c53c" dependencies = [ - "zstd-safe 6.0.5+zstd.1.5.4", + "zstd-safe 6.0.6", ] [[package]] @@ -13450,9 +13507,9 @@ dependencies = [ [[package]] name = "zstd-safe" -version = "6.0.5+zstd.1.5.4" +version = "6.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56d9e60b4b1758206c238a10165fbcae3ca37b01744e394c463463f6529d23b" +checksum = "ee98ffd0b48ee95e6c5168188e44a54550b1564d9d530ee21d5f0eaed1069581" dependencies = [ "libc", "zstd-sys", From 2ed2c852a5464abc98a807a2ee9d7b70e4b21efc Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Mon, 31 Jul 2023 15:43:44 +0200 Subject: [PATCH 101/105] undo update cargo --- Cargo.lock | 1063 +++++++++++++++++++++++++--------------------------- 1 file changed, 503 insertions(+), 560 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 578e0d020a88e..93a8e5e988305 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -21,15 +21,6 @@ dependencies = [ "gimli", ] -[[package]] -name = "addr2line" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" -dependencies = [ - "gimli", -] - [[package]] name = "adler" version = "1.0.2" @@ -112,7 +103,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.9", "once_cell", "version_check", ] @@ -124,11 +115,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if", - "getrandom 0.2.10", + "getrandom 0.2.9", "once_cell", "version_check", ] +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + [[package]] name = "aho-corasick" version = "1.0.2" @@ -185,15 +185,15 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.1" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" +checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" [[package]] name = "anstyle-parse" -version = "0.2.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" dependencies = [ "utf8parse", ] @@ -219,9 +219,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.72" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" +checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" [[package]] name = "approx" @@ -504,9 +504,9 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "assert_cmd" -version = "2.0.12" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88903cb14723e4d4003335bb7f8a14f27691649105346a0f0957466c096adfe6" +checksum = "86d6b683edf8d1119fe420a94f8a7e389239666aa72e65495d91c00462510151" dependencies = [ "anstyle", "bstr", @@ -525,9 +525,9 @@ checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" [[package]] name = "async-channel" -version = "1.9.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" +checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" dependencies = [ "concurrent-queue", "event-listener", @@ -548,7 +548,7 @@ dependencies = [ "log", "parking", "polling", - "rustix 0.37.23", + "rustix 0.37.19", "slab", "socket2 0.4.9", "waker-fn", @@ -571,7 +571,7 @@ checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -582,7 +582,7 @@ checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" dependencies = [ "async-stream-impl", "futures-core", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.9", ] [[package]] @@ -593,31 +593,31 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] name = "async-trait" -version = "0.1.72" +version = "0.1.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc6dde6e4ed435a4c1ee4e73592f5ba9da2151af10076cc04858746af9352d09" +checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] name = "asynchronous-codec" -version = "0.6.2" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4057f2c32adbb2fc158e22fb38433c8e9bbf76b75a4732c7c0cbaf695fb65568" +checksum = "06a0daa378f5fd10634e44b0a29b2a87b890657658e072a30d6f26e57ddee182" dependencies = [ "bytes", "futures-sink", "futures-util", "memchr", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.9", ] [[package]] @@ -639,16 +639,16 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.68" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" +checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" dependencies = [ - "addr2line 0.20.0", + "addr2line", "cc", "cfg-if", "libc", - "miniz_oxide", - "object 0.31.1", + "miniz_oxide 0.6.2", + "object", "rustc-demangle", ] @@ -684,9 +684,9 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "basic-toml" -version = "0.1.4" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bfc506e7a2370ec239e1d072507b2a80c833083699d3c6fa176fbb4de8448c6" +checksum = "5c0de75129aa8d0cceaf750b89013f0e08804d6ec61416da787b35ad0d7cddf1" dependencies = [ "serde", ] @@ -727,19 +727,19 @@ version = "0.65.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5" dependencies = [ - "bitflags 1.3.2", + "bitflags", "cexpr", "clang-sys", "lazy_static", "lazycell", "peeking_take_while", - "prettyplease 0.2.12", + "prettyplease 0.2.6", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -748,12 +748,6 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "bitflags" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" - [[package]] name = "bitvec" version = "1.0.1" @@ -783,7 +777,7 @@ checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" dependencies = [ "arrayref", "arrayvec 0.7.4", - "constant_time_eq 0.2.6", + "constant_time_eq", ] [[package]] @@ -794,20 +788,20 @@ checksum = "6637f448b9e61dfadbdcbae9a885fadee1f3eaffb1f8d3c1965d3ade8bdfd44f" dependencies = [ "arrayref", "arrayvec 0.7.4", - "constant_time_eq 0.2.6", + "constant_time_eq", ] [[package]] name = "blake3" -version = "1.4.1" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "199c42ab6972d92c9f8995f086273d25c42fc0f7b2a1fcefba465c1352d25ba5" +checksum = "42ae2468a89544a466886840aa467a25b766499f4f04bf7d9fcd10ecee9fccef" dependencies = [ "arrayref", "arrayvec 0.7.4", "cc", "cfg-if", - "constant_time_eq 0.3.0", + "constant_time_eq", "digest 0.10.7", ] @@ -879,12 +873,13 @@ dependencies = [ [[package]] name = "bstr" -version = "1.6.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05" +checksum = "a246e68bb43f6cd9db24bea052a53e40405417c5fb372e3d1a8a7f770a564ef5" dependencies = [ "memchr", - "regex-automata 0.3.4", + "once_cell", + "regex-automata", "serde", ] @@ -946,18 +941,18 @@ dependencies = [ [[package]] name = "camino" -version = "1.1.6" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" +checksum = "c530edf18f37068ac2d977409ed5cd50d53d73bc653c7647b48eb78976ac9ae2" dependencies = [ "serde", ] [[package]] name = "cargo-platform" -version = "0.1.3" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cfa25e60aea747ec7e1124f238816749faa93759c6ff5b31f1ccdda137f4479" +checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" dependencies = [ "serde", ] @@ -970,7 +965,7 @@ checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" dependencies = [ "camino", "cargo-platform", - "semver 1.0.18", + "semver 1.0.17", "serde", "serde_json", "thiserror", @@ -1002,9 +997,9 @@ dependencies = [ [[package]] name = "cfg-expr" -version = "0.15.4" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b40ccee03b5175c18cde8f37e7d2a33bcef6f8ec8f7cc0d81090d1bb380949c9" +checksum = "e70d3ad08698a0568b0562f22710fe6bfc1f4a61a367c77d0398c562eadd453a" dependencies = [ "smallvec", ] @@ -1051,7 +1046,7 @@ name = "chain-spec-builder" version = "2.0.0" dependencies = [ "ansi_term", - "clap 4.3.19", + "clap 4.3.2", "node-cli", "rand 0.8.5", "sc-chain-spec", @@ -1160,17 +1155,17 @@ version = "3.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ - "bitflags 1.3.2", + "bitflags", "clap_lex 0.2.4", - "indexmap 1.9.3", + "indexmap", "textwrap", ] [[package]] name = "clap" -version = "4.3.19" +version = "4.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fd304a20bff958a57f04c4e96a2e7594cc4490a0e809cbd48bb6437edaa452d" +checksum = "401a4694d2bf92537b6867d94de48c4842089645fdcdf6c71865b175d836e9c2" dependencies = [ "clap_builder", "clap_derive", @@ -1179,35 +1174,36 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.19" +version = "4.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01c6a3f08f1fe5662a35cfe393aec09c4df95f60ee93b7556505260f75eee9e1" +checksum = "72394f3339a76daf211e57d4bcb374410f3965dcc606dd0e03738c7888766980" dependencies = [ "anstream", "anstyle", + "bitflags", "clap_lex 0.5.0", "strsim", ] [[package]] name = "clap_complete" -version = "4.3.2" +version = "4.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc443334c81a804575546c5a8a79b4913b50e28d69232903604cada1de817ce" +checksum = "7f6b5c519bab3ea61843a7923d074b04245624bb84a64a8c150f5deb014e388b" dependencies = [ - "clap 4.3.19", + "clap 4.3.2", ] [[package]] name = "clap_derive" -version = "4.3.12" +version = "4.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" +checksum = "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -1243,9 +1239,9 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "comfy-table" -version = "7.0.1" +version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ab77dbd8adecaf3f0db40581631b995f312a8a5ae3aa9993188bb8f23d83a5b" +checksum = "f9e1f7e5d046697d34b593bdba8ee31f4649366e452a2ccabb3baf3511e503d1" dependencies = [ "strum", "strum_macros", @@ -1282,9 +1278,9 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.9.4" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "795bc6e66a8e340f075fcf6227e417a2dc976b92b91f3cdc778bb858778b6747" +checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" [[package]] name = "const-random" @@ -1302,7 +1298,7 @@ version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d7d6ab3c3a2282db210df5f02c4dab6e0a7057af0fb7ebd4070f30fe05c0ddb" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.9", "once_cell", "proc-macro-hack", "tiny-keccak", @@ -1310,15 +1306,9 @@ dependencies = [ [[package]] name = "constant_time_eq" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a53c0a4d288377e7415b53dcfc3c04da5cdc2cc95c8d5ac178b58f0b861ad6" - -[[package]] -name = "constant_time_eq" -version = "0.3.0" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" +checksum = "13418e745008f7349ec7e449155f419a61b92b58a99cc3616942b926825ec76b" [[package]] name = "constcat" @@ -1362,9 +1352,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" dependencies = [ "libc", ] @@ -1537,22 +1527,22 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.15" +version = "0.9.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "memoffset 0.9.0", + "memoffset 0.8.0", "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.16" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" dependencies = [ "cfg-if", ] @@ -1606,6 +1596,16 @@ dependencies = [ "subtle", ] +[[package]] +name = "ctor" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" +dependencies = [ + "quote", + "syn 1.0.109", +] + [[package]] name = "ctr" version = "0.8.0" @@ -1666,9 +1666,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.102" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f68e12e817cb19eaab81aaec582b4052d07debd3c3c6b083b9d361db47c7dc9d" +checksum = "109308c20e8445959c2792e81871054c6a17e6976489a93d2769641a2ba5839c" dependencies = [ "cc", "cxxbridge-flags", @@ -1678,9 +1678,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.102" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e789217e4ab7cf8cc9ce82253180a9fe331f35f5d339f0ccfe0270b39433f397" +checksum = "daf4c6755cdf10798b97510e0e2b3edb9573032bd9379de8fffa59d68165494f" dependencies = [ "cc", "codespan-reporting", @@ -1688,24 +1688,24 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] name = "cxxbridge-flags" -version = "1.0.102" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78a19f4c80fd9ab6c882286fa865e92e07688f4387370a209508014ead8751d0" +checksum = "882074421238e84fe3b4c65d0081de34e5b323bf64555d3e61991f76eb64a7bb" [[package]] name = "cxxbridge-macro" -version = "1.0.102" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fcfa71f66c8563c4fa9dd2bb68368d50267856f831ac5d85367e0805f9606c" +checksum = "4a076022ece33e7686fb76513518e219cca4fce5750a8ae6d1ce6c0f48fd1af9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -1736,9 +1736,9 @@ dependencies = [ [[package]] name = "der" -version = "0.7.7" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c7ed52955ce76b1554f509074bb357d3fb8ac9b51288a65a3fd480d1dfba946" +checksum = "56acb310e15652100da43d130af8d97b509e95af61aab1c5a7939ef24337ee17" dependencies = [ "const-oid", "zeroize", @@ -1862,9 +1862,9 @@ dependencies = [ [[package]] name = "dissimilar" -version = "1.0.7" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86e3bdc80eee6e16b2b6b0f87fbc98c04bee3455e35174c0de1a125d0688c632" +checksum = "210ec60ae7d710bed8683e333e9d2855a8a56a3e9892b38bad3bb0d4d29b0d5e" [[package]] name = "doc-comment" @@ -1902,7 +1902,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.28", + "syn 2.0.18", "termcolor", "walkdir", ] @@ -1919,7 +1919,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.28", + "syn 2.0.18", "termcolor", "walkdir", ] @@ -1938,9 +1938,9 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "dtoa" -version = "1.0.9" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653" +checksum = "65d09067bfacaa79114679b279d7f5885b53295b1e2cfb4e79c8e4bd3d633169" [[package]] name = "dyn-clonable" @@ -1965,15 +1965,15 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.12" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "304e6508efa593091e97a9abbc10f90aa7ca635b6d2784feff3c89d41dd12272" +checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" [[package]] name = "ecdsa" -version = "0.16.8" +version = "0.16.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" +checksum = "0997c976637b606099b9985693efa3581e84e41f5c11ba5255f88711058ad428" dependencies = [ "der", "digest 0.10.7", @@ -2022,9 +2022,9 @@ dependencies = [ [[package]] name = "either" -version = "1.9.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "elliptic-curve" @@ -2080,7 +2080,7 @@ checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -2115,17 +2115,11 @@ version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - [[package]] name = "errno" -version = "0.3.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", @@ -2167,7 +2161,7 @@ dependencies = [ "fs-err", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -2191,12 +2185,6 @@ dependencies = [ "instant", ] -[[package]] -name = "fastrand" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" - [[package]] name = "fdlimit" version = "0.2.1" @@ -2286,7 +2274,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" dependencies = [ "crc32fast", - "miniz_oxide", + "miniz_oxide 0.7.1", ] [[package]] @@ -2370,7 +2358,7 @@ dependencies = [ "Inflector", "array-bytes", "chrono", - "clap 4.3.19", + "clap 4.3.2", "comfy-table", "frame-benchmarking", "frame-support", @@ -2436,7 +2424,7 @@ dependencies = [ "quote", "scale-info", "sp-arithmetic", - "syn 2.0.28", + "syn 2.0.18", "trybuild", ] @@ -2462,7 +2450,7 @@ dependencies = [ name = "frame-election-solution-type-fuzzer" version = "2.0.0-alpha.5" dependencies = [ - "clap 4.3.19", + "clap 4.3.2", "frame-election-provider-solution-type", "frame-election-provider-support", "frame-support", @@ -2538,7 +2526,7 @@ dependencies = [ "aquamarine", "array-bytes", "assert_matches", - "bitflags 1.3.2", + "bitflags", "environmental", "frame-metadata", "frame-support-procedural", @@ -2585,7 +2573,7 @@ dependencies = [ "proc-macro-warning", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -2596,7 +2584,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -2605,7 +2593,7 @@ version = "3.0.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -2734,11 +2722,11 @@ dependencies = [ [[package]] name = "fs4" -version = "0.6.6" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eeb4ed9e12f43b7fa0baae3f9cdda28352770132ef2e09a23760c29cae8bd47" +checksum = "7672706608ecb74ab2e055c68327ffc25ae4cac1e12349204fd5fb0f3487cce2" dependencies = [ - "rustix 0.38.4", + "rustix 0.37.19", "windows-sys 0.48.0", ] @@ -2809,12 +2797,12 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" dependencies = [ - "fastrand 1.9.0", + "fastrand", "futures-core", "futures-io", "memchr", "parking", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.9", "waker-fn", ] @@ -2826,7 +2814,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -2871,7 +2859,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.9", "pin-utils", "slab", ] @@ -2941,9 +2929,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if", "js-sys", @@ -2974,12 +2962,12 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.3" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" dependencies = [ "fallible-iterator", - "indexmap 1.9.3", + "indexmap", "stable_deref_trait", ] @@ -2991,11 +2979,11 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.12" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aca8bbd8e0707c1887a8bbb7e6b40e228f251ff5d62c8220a4a7a53c73aff006" +checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" dependencies = [ - "aho-corasick", + "aho-corasick 0.7.20", "bstr", "fnv", "log", @@ -3015,9 +3003,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.20" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" +checksum = "d357c7ae988e7d2182f7d7871d0b963962420b0678b0997ce7de72001aeab782" dependencies = [ "bytes", "fnv", @@ -3025,7 +3013,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 1.9.3", + "indexmap", "slab", "tokio", "tokio-util", @@ -3085,12 +3073,6 @@ dependencies = [ "ahash 0.8.3", ] -[[package]] -name = "hashbrown" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" - [[package]] name = "heck" version = "0.4.1" @@ -3108,9 +3090,18 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.2" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" [[package]] name = "hex" @@ -3215,14 +3206,14 @@ checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", "http", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.9", ] [[package]] name = "http-range-header" -version = "0.3.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" +checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29" [[package]] name = "httparse" @@ -3244,9 +3235,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.27" +version = "0.14.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" dependencies = [ "bytes", "futures-channel", @@ -3258,7 +3249,7 @@ dependencies = [ "httparse", "httpdate", "itoa", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.9", "socket2 0.4.9", "tokio", "tower-service", @@ -3284,25 +3275,24 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.24.1" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" +checksum = "0646026eb1b3eea4cd9ba47912ea5ce9cc07713d105b1a14698f4e6433d348b7" dependencies = [ - "futures-util", "http", "hyper", "log", - "rustls 0.21.5", + "rustls 0.21.1", "rustls-native-certs", "tokio", - "tokio-rustls 0.24.1", + "tokio-rustls 0.24.0", ] [[package]] name = "iana-time-zone" -version = "0.1.57" +version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -3441,16 +3431,6 @@ dependencies = [ "serde", ] -[[package]] -name = "indexmap" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" -dependencies = [ - "equivalent", - "hashbrown 0.14.0", -] - [[package]] name = "indexmap-nostd" version = "0.4.0" @@ -3509,7 +3489,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi 0.3.1", "libc", "windows-sys 0.48.0", ] @@ -3522,30 +3502,31 @@ checksum = "aa2f047c0a98b2f299aa5d6d7088443570faae494e9ae1305e48be000c9e0eb1" [[package]] name = "ipconfig" -version = "0.3.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" +checksum = "bd302af1b90f2463a98fa5ad469fc212c8e3175a41c3068601bfa2727591c5be" dependencies = [ - "socket2 0.5.3", + "socket2 0.4.9", "widestring", - "windows-sys 0.48.0", + "winapi", "winreg", ] [[package]] name = "ipnet" -version = "2.8.0" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" +checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" [[package]] name = "is-terminal" -version = "0.4.9" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ - "hermit-abi 0.3.2", - "rustix 0.38.4", + "hermit-abi 0.3.1", + "io-lifetimes", + "rustix 0.37.19", "windows-sys 0.48.0", ] @@ -3560,9 +3541,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "jobserver" @@ -3575,9 +3556,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "2f37a4a5928311ac501dee68b3c7613a1037d0edb30c8e5427bd832d55d1b790" dependencies = [ "wasm-bindgen", ] @@ -3932,9 +3913,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.145" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "fc86cde3ff845662b8f4ef6cb50ea0e20c524eb3d29ae048287e06a1b3fa6a81" [[package]] name = "libloading" @@ -3967,7 +3948,7 @@ dependencies = [ "bytes", "futures", "futures-timer", - "getrandom 0.2.10", + "getrandom 0.2.9", "instant", "libp2p-allow-block-list", "libp2p-connection-limits", @@ -4004,9 +3985,9 @@ dependencies = [ [[package]] name = "libp2p-connection-limits" -version = "0.2.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f5107ad45cb20b2f6c3628c7b6014b996fcb13a88053f4569c872c6e30abf58" +checksum = "d45dd90e8f0e1fa59e85ff5316dd4d1ac41a9a507e79cda1b0e9b7be43ad1a56" dependencies = [ "libp2p-core", "libp2p-identity", @@ -4081,9 +4062,9 @@ dependencies = [ [[package]] name = "libp2p-identity" -version = "0.2.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a38d6012784fe4cc14e6d443eb415b11fc7c456dc15d9f0d90d9b70bc7ac3ec1" +checksum = "d2874d9c6575f1d7a151022af5c42bb0ffdcdfbafe0a6fd039de870b384835a2" dependencies = [ "bs58 0.5.0", "ed25519-dalek", @@ -4098,9 +4079,9 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.44.3" +version = "0.44.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f2584b0c27f879a1cca4b753fd96874109e5a2f46bd6e30924096456c2ba9b2" +checksum = "f0eeb75763862ff762c3240722fbed06ff6bb025d6afbdf2ce887f3610657789" dependencies = [ "arrayvec 0.7.4", "asynchronous-codec", @@ -4225,9 +4206,9 @@ dependencies = [ [[package]] name = "libp2p-swarm" -version = "0.43.2" +version = "0.43.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43106820057e0f65c77b01a3873593f66e676da4e40c70c3a809b239109f1d30" +checksum = "5de15b2097fc3bde063df8c202803538ff467fedb18f01c13bc5da55913d246c" dependencies = [ "either", "fnv", @@ -4256,7 +4237,7 @@ dependencies = [ "proc-macro-warning", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -4388,9 +4369,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.12" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b" +checksum = "56ee889ecc9568871456d42f603d6a0ce59ff328d291063a45cbdf0036baf6db" dependencies = [ "cc", "pkg-config", @@ -4399,9 +4380,9 @@ dependencies = [ [[package]] name = "link-cplusplus" -version = "1.0.9" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d240c6f7e1ba3a28b0249f774e6a9dd0175054b52dfbb61b16eb8505c3785c9" +checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" dependencies = [ "cc", ] @@ -4423,9 +4404,9 @@ dependencies = [ [[package]] name = "linregress" -version = "0.5.2" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4de0b5f52a9f84544d268f5fabb71b38962d6aa3c6600b8bcd27d44ccf9c9c45" +checksum = "475015a7f8f017edb28d2e69813be23500ad4b32cfe3421c4148efc97324ee52" dependencies = [ "nalgebra", ] @@ -4442,12 +4423,6 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" -[[package]] -name = "linux-raw-sys" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" - [[package]] name = "lite-json" version = "0.2.0" @@ -4484,9 +4459,9 @@ checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" [[package]] name = "lru" -version = "0.10.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718e8fae447df0c7e1ba7f5189829e63fd536945c8988d61444c19039f16b670" +checksum = "03f1160296536f10c833a82dca22267d5486734230d47bf00bf435885814ba1e" dependencies = [ "hashbrown 0.13.2", ] @@ -4538,7 +4513,7 @@ dependencies = [ "macro_magic_core", "macro_magic_macros", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -4552,7 +4527,7 @@ dependencies = [ "macro_magic_core_macros", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -4563,7 +4538,7 @@ checksum = "c12469fc165526520dff2807c2975310ab47cf7190a45b99b49a7dc8befab17b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -4574,7 +4549,7 @@ checksum = "b8fb85ec1620619edf2984a7693497d4ec88a9665d8b87e942856884c92dbf2a" dependencies = [ "macro_magic_core", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -4595,7 +4570,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" dependencies = [ - "regex-automata 0.1.10", + "regex-automata", ] [[package]] @@ -4604,7 +4579,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" dependencies = [ - "regex-automata 0.1.10", + "regex-automata", ] [[package]] @@ -4635,7 +4610,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffc89ccdc6e10d6907450f753537ebc5c5d3460d2e4e62ea74bd571db62c0f9e" dependencies = [ - "rustix 0.37.23", + "rustix 0.37.19", ] [[package]] @@ -4665,15 +4640,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "memoffset" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg", -] - [[package]] name = "memory-db" version = "0.32.0" @@ -4701,6 +4667,15 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" +[[package]] +name = "miniz_oxide" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +dependencies = [ + "adler", +] + [[package]] name = "miniz_oxide" version = "0.7.1" @@ -4924,9 +4899,9 @@ dependencies = [ [[package]] name = "nalgebra" -version = "0.32.3" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307ed9b18cc2423f29e83f84fd23a8e73628727990181f18641a8b5dc2ab1caa" +checksum = "d68d47bba83f9e2006d117a9a33af1524e655516b8919caac694427a6fb1e511" dependencies = [ "approx", "matrixmultiply", @@ -4940,9 +4915,9 @@ dependencies = [ [[package]] name = "nalgebra-macros" -version = "0.2.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91761aed67d03ad966ef783ae962ef9bbaca728d2dd7ceb7939ec110fffad998" +checksum = "d232c68884c0c99810a5a4d333ef7e47689cfd0edc85efc9e54e1e6bf5212766" dependencies = [ "proc-macro2", "quote", @@ -4977,7 +4952,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9ea4302b9759a7a88242299225ea3688e63c85ea136371bb6cf94fd674efaab" dependencies = [ "anyhow", - "bitflags 1.3.2", + "bitflags", "byteorder", "libc", "netlink-packet-core", @@ -5030,7 +5005,7 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" dependencies = [ - "bitflags 1.3.2", + "bitflags", "cfg-if", "libc", ] @@ -5041,7 +5016,7 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" dependencies = [ - "bitflags 1.3.2", + "bitflags", "cfg-if", "libc", "memoffset 0.7.1", @@ -5054,7 +5029,7 @@ name = "node-bench" version = "0.9.0-dev" dependencies = [ "array-bytes", - "clap 4.3.19", + "clap 4.3.2", "derive_more", "fs_extra", "futures", @@ -5091,7 +5066,7 @@ version = "3.0.0-dev" dependencies = [ "array-bytes", "assert_cmd", - "clap 4.3.19", + "clap 4.3.2", "clap_complete", "criterion", "frame-benchmarking-cli", @@ -5217,7 +5192,7 @@ dependencies = [ name = "node-inspect" version = "0.9.0-dev" dependencies = [ - "clap 4.3.19", + "clap 4.3.2", "parity-scale-codec", "sc-cli", "sc-client-api", @@ -5271,7 +5246,7 @@ dependencies = [ name = "node-runtime-generate-bags" version = "3.0.0" dependencies = [ - "clap 4.3.19", + "clap 4.3.2", "generate-bags", "kitchensink-runtime", ] @@ -5280,7 +5255,7 @@ dependencies = [ name = "node-template" version = "4.0.0-dev" dependencies = [ - "clap 4.3.19", + "clap 4.3.2", "frame-benchmarking", "frame-benchmarking-cli", "frame-system", @@ -5323,7 +5298,7 @@ dependencies = [ name = "node-template-release" version = "3.0.0" dependencies = [ - "clap 4.3.19", + "clap 4.3.2", "flate2", "fs_extra", "glob", @@ -5439,9 +5414,9 @@ dependencies = [ [[package]] name = "num" -version = "0.4.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b05180d69e3da0e530ba2a1dae5110317e49e3b7f3d41be227dc5f92e49ee7af" +checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" dependencies = [ "num-bigint", "num-complex", @@ -5516,9 +5491,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", "libm 0.2.7", @@ -5526,11 +5501,11 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.16.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi 0.2.6", "libc", ] @@ -5548,16 +5523,7 @@ checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" dependencies = [ "crc32fast", "hashbrown 0.13.2", - "indexmap 1.9.3", - "memchr", -] - -[[package]] -name = "object" -version = "0.31.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" -dependencies = [ + "indexmap", "memchr", ] @@ -5593,9 +5559,18 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "os_str_bytes" -version = "6.5.1" +version = "6.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac" +checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267" + +[[package]] +name = "output_vt100" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66" +dependencies = [ + "winapi", +] [[package]] name = "overload" @@ -5993,7 +5968,7 @@ version = "4.0.0-dev" dependencies = [ "array-bytes", "assert_matches", - "bitflags 1.3.2", + "bitflags", "env_logger 0.9.3", "environmental", "frame-benchmarking", @@ -6030,7 +6005,7 @@ dependencies = [ name = "pallet-contracts-primitives" version = "24.0.0" dependencies = [ - "bitflags 1.3.2", + "bitflags", "parity-scale-codec", "scale-info", "sp-runtime", @@ -6044,7 +6019,7 @@ version = "4.0.0-dev" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -7079,7 +7054,7 @@ dependencies = [ "proc-macro2", "quote", "sp-runtime", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -7120,7 +7095,7 @@ dependencies = [ "substrate-state-trie-migration-rpc", "thousands", "tokio", - "zstd 0.12.4", + "zstd 0.12.3+zstd.1.5.2", ] [[package]] @@ -7364,9 +7339,9 @@ dependencies = [ [[package]] name = "parity-db" -version = "0.4.10" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78f19d20a0d2cc52327a88d131fa1c4ea81ea4a04714aedcfeca2dd410049cf8" +checksum = "4890dcb9556136a4ec2b0c51fa4a08c8b733b829506af8fff2e853f3a065985b" dependencies = [ "blake2", "crc32fast", @@ -7384,9 +7359,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.6.4" +version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8e946cc0cc711189c0b0249fb8b599cbeeab9784d83c415719368bb8d4ac64" +checksum = "2287753623c76f953acd29d15d8100bcab84d29db78fb6f352adb3c53e83b967" dependencies = [ "arrayvec 0.7.4", "bitvec", @@ -7399,9 +7374,9 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.4" +version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a296c3079b5fefbc499e1de58dc26c09b1b9a5952d26694ee89f04a43ebbb3e" +checksum = "2b6937b5e67bfba3351b87b040d48352a2fcb6ad72f81855412ce97b45c8f110" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -7466,7 +7441,7 @@ dependencies = [ "libc", "redox_syscall 0.3.5", "smallvec", - "windows-targets 0.48.1", + "windows-targets 0.48.0", ] [[package]] @@ -7477,9 +7452,9 @@ checksum = "7924d1d0ad836f665c9065e26d016c673ece3993f30d340068b16f282afc1156" [[package]] name = "paste" -version = "1.0.14" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" [[package]] name = "pbkdf2" @@ -7513,9 +7488,9 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" -version = "2.7.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d2d1d55045829d65aad9d389139882ad623b33b904e7c9f1b10c5b8927298e5" +checksum = "e68e84bfb01f0507134eac1e9b410a12ba379d064eab48c50ba4ce329a527b70" dependencies = [ "thiserror", "ucd-trie", @@ -7523,9 +7498,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f94bca7e7a599d89dea5dfa309e217e7906c3c007fb9c3299c40b10d6a315d3" +checksum = "6b79d4c71c865a25a4322296122e3924d30bc8ee0834c8bfc8b95f7f054afbfb" dependencies = [ "pest", "pest_generator", @@ -7533,22 +7508,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d490fe7e8556575ff6911e45567ab95e71617f43781e5c05490dc8d75c965c" +checksum = "6c435bf1076437b851ebc8edc3a18442796b30f1728ffea6262d59bbe28b077e" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] name = "pest_meta" -version = "2.7.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2674c66ebb4b4d9036012091b537aae5878970d6999f81a265034d85b136b341" +checksum = "745a452f8eb71e39ffd8ee32b3c5f51d03845f99786fa9b68db6ff509c505411" dependencies = [ "once_cell", "pest", @@ -7562,27 +7537,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" dependencies = [ "fixedbitset", - "indexmap 1.9.3", + "indexmap", ] [[package]] name = "pin-project" -version = "1.1.2" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030ad2bc4db10a8944cb0d837f158bdfec4d4a4873ab701a95046770d11f8842" +checksum = "c95a7476719eab1e366eaf73d0260af3021184f18177925b07f54b30089ceead" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.2" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec2e072ecce94ec471b13398d5402c188e76ac03cf74dd1a975161b23a3f6d9c" +checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -7593,9 +7568,9 @@ checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" [[package]] name = "pin-project-lite" -version = "0.2.10" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" [[package]] name = "pin-utils" @@ -7627,9 +7602,9 @@ checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" [[package]] name = "plotters" -version = "0.3.5" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" +checksum = "2538b639e642295546c50fcd545198c9d64ee2a38620a628724a3b266d5fbf97" dependencies = [ "num-traits", "plotters-backend", @@ -7640,15 +7615,15 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.5" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" +checksum = "193228616381fecdc1224c62e96946dfbc73ff4384fba576e052ff8c1bea8142" [[package]] name = "plotters-svg" -version = "0.3.5" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" +checksum = "f9a81d2759aae1dae668f783c308bc5c8ebd191ff4184aaa1b37f65a6ae5a56f" dependencies = [ "plotters-backend", ] @@ -7660,12 +7635,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" dependencies = [ "autocfg", - "bitflags 1.3.2", + "bitflags", "cfg-if", "concurrent-queue", "libc", "log", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.9", "windows-sys 0.48.0", ] @@ -7706,9 +7681,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.4.2" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f32154ba0af3a075eefa1eda8bb414ee928f62303a54ea85b8d6638ff1a6ee9e" +checksum = "767eb9f07d4a5ebcb39bbf2d452058a93c011373abf6832e24194a1c3f004794" [[package]] name = "ppv-lite86" @@ -7760,11 +7735,13 @@ dependencies = [ [[package]] name = "pretty_assertions" -version = "1.4.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" +checksum = "a25e9bcb20aa780fd0bb16b72403a9064d6b3f22f026946029acb941a50af755" dependencies = [ + "ctor", "diff", + "output_vt100", "yansi", ] @@ -7780,12 +7757,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.12" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c64d9ba0963cdcea2e1b2230fbae2bab30eb25a174be395c41e764bfb65dd62" +checksum = "3b69d39aab54d069e7f2fe8cb970493e7834601ca2d8c65fd7bbd183578080d1" dependencies = [ "proc-macro2", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -7850,14 +7827,14 @@ checksum = "70550716265d1ec349c41f70dd4f964b4fd88394efe4405f0c1da679c4799a07" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406" dependencies = [ "unicode-ident", ] @@ -8012,9 +7989,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.32" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" dependencies = [ "proc-macro2", ] @@ -8084,7 +8061,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.9", ] [[package]] @@ -8149,7 +8126,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags 1.3.2", + "bitflags", ] [[package]] @@ -8158,7 +8135,7 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ - "bitflags 1.3.2", + "bitflags", ] [[package]] @@ -8167,29 +8144,29 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.9", "redox_syscall 0.2.16", "thiserror", ] [[package]] name = "ref-cast" -version = "1.0.19" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61ef7e18e8841942ddb1cf845054f8008410030a3997875d9e49b7a363063df1" +checksum = "f43faa91b1c8b36841ee70e97188a869d37ae21759da6846d4be66de5bf7b12c" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.19" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dfaf0c85b766276c797f3791f5bc6d5bd116b41d53049af2789666b0c0bc9fa" +checksum = "8d2275aab483050ab2a7364c1a46604865ee7d6906684e08db0f090acf74f9e7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -8206,14 +8183,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.1" +version = "1.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" +checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" dependencies = [ - "aho-corasick", + "aho-corasick 1.0.2", "memchr", - "regex-automata 0.3.4", - "regex-syntax 0.7.4", + "regex-syntax 0.7.2", ] [[package]] @@ -8225,17 +8201,6 @@ dependencies = [ "regex-syntax 0.6.29", ] -[[package]] -name = "regex-automata" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7b6d6190b7594385f61bd3911cd1be99dfddcfc365a4160cc2ab5bff4aed294" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax 0.7.4", -] - [[package]] name = "regex-syntax" version = "0.6.29" @@ -8244,9 +8209,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.4" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" [[package]] name = "resolv-conf" @@ -8371,16 +8336,16 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.18", + "semver 1.0.17", ] [[package]] name = "rustix" -version = "0.36.15" +version = "0.36.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c37f1bd5ef1b5422177b7646cba67430579cfe2ace80f284fee876bca52ad941" +checksum = "14e4d67015953998ad0eb82887a0eb0129e18a7e2f3b7b0f6c422fddcd503d62" dependencies = [ - "bitflags 1.3.2", + "bitflags", "errno", "io-lifetimes", "libc", @@ -8390,11 +8355,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.23" +version = "0.37.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" +checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" dependencies = [ - "bitflags 1.3.2", + "bitflags", "errno", "io-lifetimes", "libc", @@ -8402,19 +8367,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "rustix" -version = "0.38.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a962918ea88d644592894bc6dc55acc6c0956488adcebbfb6e273506b7fd6e5" -dependencies = [ - "bitflags 2.3.3", - "errno", - "libc", - "linux-raw-sys 0.4.3", - "windows-sys 0.48.0", -] - [[package]] name = "rustls" version = "0.20.8" @@ -8429,21 +8381,21 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.5" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79ea77c539259495ce8ca47f53e66ae0330a8819f67e23ac96ca02f50e7b7d36" +checksum = "c911ba11bc8433e811ce56fde130ccf32f5127cab0e0194e9c68c5a5b671791e" dependencies = [ "log", "ring", - "rustls-webpki 0.101.2", + "rustls-webpki", "sct", ] [[package]] name = "rustls-native-certs" -version = "0.6.3" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" +checksum = "0167bac7a9f490495f3c33013e7722b53cb087ecbe082fb0c6387c96f634ea50" dependencies = [ "openssl-probe", "rustls-pemfile", @@ -8453,9 +8405,9 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" dependencies = [ "base64 0.21.2", ] @@ -8470,21 +8422,11 @@ dependencies = [ "untrusted", ] -[[package]] -name = "rustls-webpki" -version = "0.101.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "513722fd73ad80a71f72b61009ea1b584bcfa1483ca93949c8f290298837fa59" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" [[package]] name = "rusty-fork" @@ -8510,9 +8452,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "safe-mix" @@ -8525,9 +8467,9 @@ dependencies = [ [[package]] name = "safe_arch" -version = "0.7.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f398075ce1e6a179b46f51bd88d0598b92b00d3551f1a2d4ac49e771b56ac354" +checksum = "794821e4ccb0d9f979512f9c1973480123f9bd62a90d74ab0f9426fcf8f4a529" dependencies = [ "bytemuck", ] @@ -8647,7 +8589,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -8656,7 +8598,7 @@ version = "0.10.0-dev" dependencies = [ "array-bytes", "chrono", - "clap 4.3.19", + "clap 4.3.2", "fdlimit", "futures", "futures-timer", @@ -9178,7 +9120,7 @@ dependencies = [ "log", "parity-scale-codec", "paste", - "rustix 0.36.15", + "rustix 0.36.14", "sc-allocator", "sc-executor-common", "sc-runtime-test", @@ -9304,7 +9246,7 @@ name = "sc-network-common" version = "0.10.0-dev" dependencies = [ "async-trait", - "bitflags 1.3.2", + "bitflags", "futures", "libp2p-identity", "parity-scale-codec", @@ -9470,7 +9412,7 @@ dependencies = [ "futures", "futures-timer", "hyper", - "hyper-rustls 0.24.1", + "hyper-rustls 0.24.0", "lazy_static", "libp2p", "log", @@ -9763,7 +9705,7 @@ dependencies = [ name = "sc-storage-monitor" version = "0.1.0" dependencies = [ - "clap 4.3.19", + "clap 4.3.2", "fs4", "log", "sc-client-db", @@ -9863,7 +9805,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -9932,9 +9874,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.9.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35c0a159d0c45c12b20c5a844feb1fe4bea86e28f17b92a5f0c42193634d3782" +checksum = "b569c32c806ec3abdf3b5869fb8bf1e0d275a7c1c9b0b05603d9464632649edf" dependencies = [ "bitvec", "cfg-if", @@ -9946,9 +9888,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.9.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" +checksum = "53012eae69e5aa5c14671942a5dd47de59d4cdcff8532a6dd0e081faf1119482" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -9996,15 +9938,15 @@ dependencies = [ [[package]] name = "scopeguard" -version = "1.2.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "scratch" -version = "1.0.7" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" +checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" [[package]] name = "sct" @@ -10018,9 +9960,9 @@ dependencies = [ [[package]] name = "sec1" -version = "0.7.3" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +checksum = "f0aec48e813d6b90b15f0b8948af3c63483992dee44c03e9930b3eebdabe046e" dependencies = [ "base16ct", "der", @@ -10059,11 +10001,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.9.2" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +checksum = "1fc758eb7bffce5b308734e9b0c1468893cae9ff70ebf13e7090be8dcbcc83a8" dependencies = [ - "bitflags 1.3.2", + "bitflags", "core-foundation", "core-foundation-sys", "libc", @@ -10072,9 +10014,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.1" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "f51d0c0d83bec45f16480d0ce0058397a69e48fcdc52d1dc8855fb68acbd31a7" dependencies = [ "core-foundation-sys", "libc", @@ -10100,9 +10042,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.18" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" +checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" dependencies = [ "serde", ] @@ -10121,29 +10063,29 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.179" +version = "1.0.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a5bf42b8d227d4abf38a1ddb08602e229108a517cd4e5bb28f9c7eaafdce5c0" +checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.179" +version = "1.0.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "741e124f5485c7e60c03b043f79f320bff3527f4bbf12cf3831750dc46a0ec2c" +checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] name = "serde_json" -version = "1.0.104" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ "itoa", "ryu", @@ -10152,9 +10094,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.3" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +checksum = "93107647184f6027e3b7dcb2e11034cf95ffa1e3a682c67951963ac69c1c007d" dependencies = [ "serde", ] @@ -10400,7 +10342,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -10565,7 +10507,7 @@ dependencies = [ "ark-serialize", "ark-std", "derivative", - "getrandom 0.2.10", + "getrandom 0.2.9", "itertools", "num-traits", "zeroize", @@ -10723,7 +10665,7 @@ name = "sp-core" version = "21.0.0" dependencies = [ "array-bytes", - "bitflags 1.3.2", + "bitflags", "blake2", "bounded-collections", "bs58 0.4.0", @@ -10785,7 +10727,7 @@ version = "9.0.0" dependencies = [ "quote", "sp-core-hashing", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -10829,7 +10771,7 @@ version = "8.0.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -10918,7 +10860,7 @@ name = "sp-maybe-compressed-blob" version = "4.1.0-dev" dependencies = [ "thiserror", - "zstd 0.12.4", + "zstd 0.12.3+zstd.1.5.2", ] [[package]] @@ -10968,7 +10910,7 @@ dependencies = [ name = "sp-npos-elections-fuzzer" version = "2.0.0-alpha.5" dependencies = [ - "clap 4.3.19", + "clap 4.3.2", "honggfuzz", "rand 0.8.5", "sp-npos-elections", @@ -11027,7 +10969,7 @@ dependencies = [ "sp-tracing", "sp-weights", "substrate-test-runtime-client", - "zstd 0.12.4", + "zstd 0.12.3+zstd.1.5.2", ] [[package]] @@ -11061,7 +11003,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -11301,7 +11243,7 @@ dependencies = [ "proc-macro2", "quote", "sp-version", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -11365,9 +11307,9 @@ dependencies = [ [[package]] name = "ss58-registry" -version = "1.41.0" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfc443bad666016e012538782d9e3006213a7db43e9fb1dda91657dc06a6fa08" +checksum = "eb47a8ad42e5fc72d5b1eb104a5546937eaf39843499948bb666d6e93c62423b" dependencies = [ "Inflector", "num-format", @@ -11396,7 +11338,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a2a1c578e98c1c16fc3b8ec1328f7659a500737d7a0c6d625e73e830ff9c1f6" dependencies = [ - "bitflags 1.3.2", + "bitflags", "cfg_aliases", "libc", "parking_lot 0.11.2", @@ -11424,7 +11366,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fabb238a1cccccfa4c4fb703670c0d157e1256c1ba695abf1b93bd2bb14bab2d" dependencies = [ - "bitflags 1.3.2", + "bitflags", "byteorder", "keccak", "subtle", @@ -11463,7 +11405,7 @@ dependencies = [ name = "subkey" version = "3.0.0" dependencies = [ - "clap 4.3.19", + "clap 4.3.2", "sc-cli", ] @@ -11522,7 +11464,7 @@ dependencies = [ name = "substrate-frame-cli" version = "4.0.0-dev" dependencies = [ - "clap 4.3.19", + "clap 4.3.2", "frame-support", "frame-system", "sc-cli", @@ -11737,7 +11679,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -11761,7 +11703,7 @@ dependencies = [ "sp-maybe-compressed-blob", "strum", "tempfile", - "toml 0.7.6", + "toml 0.7.4", "walkdir", "wasm-opt", ] @@ -11785,9 +11727,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.28" +version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" +checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" dependencies = [ "proc-macro2", "quote", @@ -11812,7 +11754,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ - "bitflags 1.3.2", + "bitflags", "core-foundation", "system-configuration-sys", ] @@ -11835,9 +11777,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tar" -version = "0.4.39" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec96d2ffad078296368d46ff1cb309be1c23c513b4ab0e22a45de0185275ac96" +checksum = "4b55807c0344e1e6c04d7c965f5289c39a8d94ae23ed5c0b57aabac549f871c6" dependencies = [ "filetime", "libc", @@ -11846,20 +11788,21 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.10" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2faeef5759ab89935255b1a4cd98e0baf99d1085e37d36599c625dac49ae8e" +checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" [[package]] name = "tempfile" -version = "3.7.0" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5486094ee78b2e5038a6382ed7645bc084dc2ec433426ca4c3cb61e2007b8998" +checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" dependencies = [ + "autocfg", "cfg-if", - "fastrand 2.0.0", + "fastrand", "redox_syscall 0.3.5", - "rustix 0.38.4", + "rustix 0.37.19", "windows-sys 0.48.0", ] @@ -11886,22 +11829,22 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" -version = "1.0.44" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.44" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -11931,9 +11874,9 @@ dependencies = [ [[package]] name = "tikv-jemalloc-sys" -version = "0.5.4+5.3.0-patched" +version = "0.5.3+5.3.0-patched" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9402443cb8fd499b6f327e40565234ff34dbda27460c5b47db0db77443dd85d1" +checksum = "a678df20055b43e57ef8cddde41cdfda9a3c1a060b67f4c5836dfb1d78543ba8" dependencies = [ "cc", "libc", @@ -12016,7 +11959,7 @@ dependencies = [ "mio", "num_cpus", "parking_lot 0.12.1", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.9", "signal-hook-registry", "socket2 0.4.9", "tokio-macros", @@ -12031,7 +11974,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -12058,11 +12001,11 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.24.1" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +checksum = "e0d409377ff5b1e3ca6437aa86c1eb7d40c134bfec254e44c830defa92669db5" dependencies = [ - "rustls 0.21.5", + "rustls 0.21.1", "tokio", ] @@ -12073,7 +12016,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" dependencies = [ "futures-core", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.9", "tokio", "tokio-util", ] @@ -12101,7 +12044,7 @@ dependencies = [ "futures-core", "futures-io", "futures-sink", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.9", "tokio", "tracing", ] @@ -12117,9 +12060,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.6" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" +checksum = "d6135d499e69981f9ff0ef2167955a5333c35e36f6937d382974566b3d5b94ec" dependencies = [ "serde", "serde_spanned", @@ -12129,20 +12072,20 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.19.14" +version = "0.19.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" +checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739" dependencies = [ - "indexmap 2.0.0", + "indexmap", "serde", "serde_spanned", "toml_datetime", @@ -12162,18 +12105,18 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.4.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55ae70283aba8d2a8b411c695c437fe25b8b5e44e23e780662002fc72fb47a82" +checksum = "5d1d42a9b3f3ec46ba828e8d376aec14592ea199f70a06a548587ecd1c4ab658" dependencies = [ - "bitflags 2.3.3", + "bitflags", "bytes", "futures-core", "futures-util", "http", "http-body", "http-range-header", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.9", "tower-layer", "tower-service", ] @@ -12198,20 +12141,20 @@ checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", "log", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.9", "tracing-attributes", "tracing-core", ] [[package]] name = "tracing-attributes" -version = "0.1.26" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -12402,7 +12345,7 @@ version = "0.10.0-dev" dependencies = [ "assert_cmd", "async-trait", - "clap 4.3.19", + "clap 4.3.2", "frame-remote-externalities", "frame-try-runtime", "hex", @@ -12434,14 +12377,14 @@ dependencies = [ "substrate-rpc-client", "tempfile", "tokio", - "zstd 0.12.4", + "zstd 0.12.3+zstd.1.5.2", ] [[package]] name = "trybuild" -version = "1.0.82" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a84e0202ea606ba5ebee8507ab2bfbe89b98551ed9b8f0be198109275cff284b" +checksum = "501dbdbb99861e4ab6b60eb6a7493956a9defb644fd034bc4a5ef27c693c8a3a" dependencies = [ "basic-toml", "dissimilar", @@ -12479,9 +12422,9 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "ucd-trie" -version = "0.1.6" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" +checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" [[package]] name = "uint" @@ -12503,9 +12446,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" [[package]] name = "unicode-normalization" @@ -12658,10 +12601,11 @@ dependencies = [ [[package]] name = "want" -version = "0.3.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" dependencies = [ + "log", "try-lock", ] @@ -12685,9 +12629,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -12695,24 +12639,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.37" +version = "0.4.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +checksum = "2d1985d03709c53167ce907ff394f5316aa22cb4e12761295c5dc57dacb6297e" dependencies = [ "cfg-if", "js-sys", @@ -12722,9 +12666,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -12732,28 +12676,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" [[package]] name = "wasm-encoder" -version = "0.31.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41763f20eafed1399fff1afb466496d3a959f58241436cfdc17e3f5ca954de16" +checksum = "18c41dbd92eaebf3612a39be316540b8377c871cb9bde6b064af962984912881" dependencies = [ "leb128", ] @@ -12869,7 +12813,7 @@ version = "0.102.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48134de3d7598219ab9eaf6b91b15d8e50d31da76b8519fe4ecfcec2cf35104b" dependencies = [ - "indexmap 1.9.3", + "indexmap", "url", ] @@ -12891,10 +12835,10 @@ dependencies = [ "anyhow", "bincode", "cfg-if", - "indexmap 1.9.3", + "indexmap", "libc", "log", - "object 0.30.4", + "object", "once_cell", "paste", "psm", @@ -12931,7 +12875,7 @@ dependencies = [ "directories-next", "file-per-thread-logger", "log", - "rustix 0.36.15", + "rustix 0.36.14", "serde", "sha2 0.10.7", "toml 0.5.11", @@ -12953,7 +12897,7 @@ dependencies = [ "cranelift-wasm", "gimli", "log", - "object 0.30.4", + "object", "target-lexicon", "thiserror", "wasmparser", @@ -12971,7 +12915,7 @@ dependencies = [ "cranelift-codegen", "cranelift-native", "gimli", - "object 0.30.4", + "object", "target-lexicon", "wasmtime-environ", ] @@ -12985,9 +12929,9 @@ dependencies = [ "anyhow", "cranelift-entity", "gimli", - "indexmap 1.9.3", + "indexmap", "log", - "object 0.30.4", + "object", "serde", "target-lexicon", "thiserror", @@ -13001,14 +12945,14 @@ version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0de48df552cfca1c9b750002d3e07b45772dd033b0b206d5c0968496abf31244" dependencies = [ - "addr2line 0.19.0", + "addr2line", "anyhow", "bincode", "cfg-if", "cpp_demangle", "gimli", "log", - "object 0.30.4", + "object", "rustc-demangle", "serde", "target-lexicon", @@ -13025,9 +12969,9 @@ version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e0554b84c15a27d76281d06838aed94e13a77d7bf604bbbaf548aa20eb93846" dependencies = [ - "object 0.30.4", + "object", "once_cell", - "rustix 0.36.15", + "rustix 0.36.14", ] [[package]] @@ -13050,7 +12994,7 @@ dependencies = [ "anyhow", "cc", "cfg-if", - "indexmap 1.9.3", + "indexmap", "libc", "log", "mach", @@ -13058,7 +13002,7 @@ dependencies = [ "memoffset 0.8.0", "paste", "rand 0.8.5", - "rustix 0.36.15", + "rustix 0.36.14", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-jit-debug", @@ -13079,9 +13023,9 @@ dependencies = [ [[package]] name = "wast" -version = "62.0.1" +version = "60.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8ae06f09dbe377b889fbd620ff8fa21e1d49d1d9d364983c0cdbf9870cb9f1f" +checksum = "bd06cc744b536e30387e72a48fdd492105b9c938bb4f415c39c616a7a0a697ad" dependencies = [ "leb128", "memchr", @@ -13091,18 +13035,18 @@ dependencies = [ [[package]] name = "wat" -version = "1.0.69" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "842e15861d203fb4a96d314b0751cdeaf0f6f8b35e8d81d2953af2af5e44e637" +checksum = "5abe520f0ab205366e9ac7d3e6b2fc71de44e32a2b58f2ec871b6b575bdcea3b" dependencies = [ "wast", ] [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "3bdd9ef4e984da1187bf8110c5cf5b845fbc87a23602cdf912386a76fcd3a7c2" dependencies = [ "js-sys", "wasm-bindgen", @@ -13133,7 +13077,7 @@ version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" dependencies = [ - "rustls-webpki 0.100.1", + "rustls-webpki", ] [[package]] @@ -13149,9 +13093,9 @@ dependencies = [ [[package]] name = "wide" -version = "0.7.11" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa469ffa65ef7e0ba0f164183697b89b854253fd31aeb92358b7b6155177d62f" +checksum = "5cd0496a71f3cc6bc4bf0ed91346426a5099e93d89807e663162dc5a1069ff65" dependencies = [ "bytemuck", "safe_arch", @@ -13159,9 +13103,9 @@ dependencies = [ [[package]] name = "widestring" -version = "1.0.2" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8" +checksum = "17882f045410753661207383517a6f62ec3dbeb6a4ed2acce01f0728238d1983" [[package]] name = "winapi" @@ -13213,7 +13157,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets 0.48.1", + "windows-targets 0.48.0", ] [[package]] @@ -13231,7 +13175,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.1", + "windows-targets 0.48.0", ] [[package]] @@ -13251,9 +13195,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" dependencies = [ "windows_aarch64_gnullvm 0.48.0", "windows_aarch64_msvc 0.48.0", @@ -13380,21 +13324,20 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "winnow" -version = "0.5.2" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bd122eb777186e60c3fdf765a58ac76e41c582f1f535fbf3314434c6b58f3f7" +checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" dependencies = [ "memchr", ] [[package]] name = "winreg" -version = "0.50.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" dependencies = [ - "cfg-if", - "windows-sys 0.48.0", + "winapi", ] [[package]] @@ -13474,7 +13417,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.18", ] [[package]] @@ -13488,11 +13431,11 @@ dependencies = [ [[package]] name = "zstd" -version = "0.12.4" +version = "0.12.3+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a27595e173641171fc74a1232b7b1c7a7cb6e18222c11e9dfb9888fa424c53c" +checksum = "76eea132fb024e0e13fd9c2f5d5d595d8a967aa72382ac2f9d39fcc95afd0806" dependencies = [ - "zstd-safe 6.0.6", + "zstd-safe 6.0.5+zstd.1.5.4", ] [[package]] @@ -13507,9 +13450,9 @@ dependencies = [ [[package]] name = "zstd-safe" -version = "6.0.6" +version = "6.0.5+zstd.1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee98ffd0b48ee95e6c5168188e44a54550b1564d9d530ee21d5f0eaed1069581" +checksum = "d56d9e60b4b1758206c238a10165fbcae3ca37b01744e394c463463f6529d23b" dependencies = [ "libc", "zstd-sys", From 49efe878d3d277f72e445b8ba604346ba6ad45c6 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 1 Aug 2023 11:11:58 +0200 Subject: [PATCH 102/105] review updates --- frame/contracts/src/migration/v12.rs | 2 +- frame/contracts/src/migration/v14.rs | 23 ++++++++++------------- frame/contracts/src/storage/meter.rs | 2 +- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/frame/contracts/src/migration/v12.rs b/frame/contracts/src/migration/v12.rs index 9642041e386f0..75018f943d100 100644 --- a/frame/contracts/src/migration/v12.rs +++ b/frame/contracts/src/migration/v12.rs @@ -34,7 +34,7 @@ use sp_runtime::TryRuntimeError; use sp_runtime::{traits::Zero, FixedPointNumber, FixedU128, Saturating}; use sp_std::prelude::*; -pub mod old { +mod old { use super::*; pub type BalanceOf = = ::from(unreserved); + log::debug!( + target: LOG_TARGET, + "Holding {:?} on the code owner's account 0x{:?} for code {:?}.", + amount, + HexDisplay::from(&code_info.owner.encode()), + hash, + ); + T::Currency::hold( &HoldReason::CodeUploadDepositReserve.into(), &code_info.owner, amount, ) - .map(|_| { - log::debug!( - target: LOG_TARGET, - "{:?} held on the code owner's account 0x{:?} for code {:?}.", - amount, - HexDisplay::from(&code_info.owner.encode()), - hash, - ); - }) .unwrap_or_else(|err| { log::error!( target: LOG_TARGET, diff --git a/frame/contracts/src/storage/meter.rs b/frame/contracts/src/storage/meter.rs index 2fa11678f4fad..93885b37b4795 100644 --- a/frame/contracts/src/storage/meter.rs +++ b/frame/contracts/src/storage/meter.rs @@ -551,7 +551,7 @@ impl Ext for ReservingExt { deposit_account, origin, *amount, - // We can safely make it `Expendable` because our own consumer prevents an + // We can safely make it `Expendable` because our own consumer prevents a // removal. Preservation::Expendable, )?; From 5c668aa9bfefdcda14f16507a1ac9a61f36841ce Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Wed, 2 Aug 2023 10:25:27 +0200 Subject: [PATCH 103/105] remove type Balance --- bin/node/runtime/src/lib.rs | 1 - frame/contracts/src/lib.rs | 14 ++++---------- frame/contracts/src/tests.rs | 1 - 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 2372aeb291100..69dedfb599583 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1229,7 +1229,6 @@ impl pallet_contracts::Config for Runtime { type Time = Timestamp; type Randomness = RandomnessCollectiveFlip; type Currency = Balances; - type Balance = Balance; type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; /// The safest default is to allow no calls at all. diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 918cd6aa4b945..da896e80d76f2 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -118,7 +118,6 @@ use frame_support::{ error::BadOrigin, traits::{ fungible::{Inspect, Mutate, MutateHold}, - tokens::Balance, ConstU32, Contains, Get, Randomness, Time, }, weights::Weight, @@ -132,10 +131,7 @@ use pallet_contracts_primitives::{ }; use scale_info::TypeInfo; use smallvec::Array; -use sp_runtime::{ - traits::{Convert, Hash, Saturating, StaticLookup, Zero}, - FixedPointOperand, -}; +use sp_runtime::traits::{Convert, Hash, Saturating, StaticLookup, Zero}; use sp_std::{fmt::Debug, prelude::*}; pub use crate::{ @@ -153,7 +149,8 @@ pub use crate::wasm::api_doc; type CodeHash = ::Hash; type TrieId = BoundedVec>; -type BalanceOf = ::Balance; +type BalanceOf = + <::Currency as Inspect<::AccountId>>::Balance; type CodeVec = BoundedVec::MaxCodeLen>; type AccountIdLookupOf = <::Lookup as StaticLookup>::Source; type DebugBufferVec = BoundedVec::MaxDebugBufferLen>; @@ -211,13 +208,10 @@ pub mod pallet { type Randomness: Randomness>; /// The fungible in which fees are paid and contract balances are held. - type Currency: Inspect + type Currency: Inspect + Mutate + MutateHold; - /// The units in which we record balances. - type Balance: Balance + FixedPointOperand; - /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 85c4e89cba3c3..0f7dad2dccd09 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -443,7 +443,6 @@ impl Config for Test { type Time = Timestamp; type Randomness = Randomness; type Currency = Balances; - type Balance = u64; type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; type CallFilter = TestFilter; From 39e83cc1e57cb97da2c318ecc1c9940cc4e93d31 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Wed, 2 Aug 2023 10:39:35 +0200 Subject: [PATCH 104/105] add extra fields to events --- frame/contracts/src/lib.rs | 4 ++-- frame/contracts/src/tests.rs | 18 ++++++++++++------ frame/contracts/src/wasm/mod.rs | 9 +++++++-- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index da896e80d76f2..158e4802cf186 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -838,7 +838,7 @@ pub mod pallet { }, /// Code with the specified hash has been stored. - CodeStored { code_hash: T::Hash, deposit_held: BalanceOf }, + CodeStored { code_hash: T::Hash, deposit_held: BalanceOf, uploader: T::AccountId }, /// A custom event emitted by the contract. ContractEmitted { @@ -850,7 +850,7 @@ pub mod pallet { }, /// A code with the specified hash was removed. - CodeRemoved { code_hash: T::Hash, deposit_released: BalanceOf }, + CodeRemoved { code_hash: T::Hash, deposit_released: BalanceOf, remover: T::AccountId }, /// A contract's code was updated. ContractCodeUpdated { diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 0f7dad2dccd09..2e6161dcff544 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -3531,7 +3531,8 @@ fn upload_code_works() { phase: Phase::Initialization, event: RuntimeEvent::Contracts(crate::Event::CodeStored { code_hash, - deposit_held: deposit_expected + deposit_held: deposit_expected, + uploader: ALICE }), topics: vec![code_hash], },] @@ -3618,7 +3619,8 @@ fn remove_code_works() { phase: Phase::Initialization, event: RuntimeEvent::Contracts(crate::Event::CodeStored { code_hash, - deposit_held: deposit_expected + deposit_held: deposit_expected, + uploader: ALICE }), topics: vec![code_hash], }, @@ -3626,7 +3628,8 @@ fn remove_code_works() { phase: Phase::Initialization, event: RuntimeEvent::Contracts(crate::Event::CodeRemoved { code_hash, - deposit_released: deposit_expected + deposit_released: deposit_expected, + remover: ALICE }), topics: vec![code_hash], }, @@ -3665,7 +3668,8 @@ fn remove_code_wrong_origin() { phase: Phase::Initialization, event: RuntimeEvent::Contracts(crate::Event::CodeStored { code_hash, - deposit_held: deposit_expected + deposit_held: deposit_expected, + uploader: ALICE }), topics: vec![code_hash], },] @@ -3764,7 +3768,8 @@ fn instantiate_with_zero_balance_works() { phase: Phase::Initialization, event: RuntimeEvent::Contracts(crate::Event::CodeStored { code_hash, - deposit_held: deposit_expected + deposit_held: deposit_expected, + uploader: ALICE }), topics: vec![code_hash], }, @@ -3871,7 +3876,8 @@ fn instantiate_with_below_existential_deposit_works() { phase: Phase::Initialization, event: RuntimeEvent::Contracts(crate::Event::CodeStored { code_hash, - deposit_held: deposit_expected + deposit_held: deposit_expected, + uploader: ALICE }), topics: vec![code_hash], }, diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index 46d4a7a59703d..551bfba3fbe6f 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -249,7 +249,11 @@ impl WasmBlob { *stored_code_info = Some(self.code_info.clone()); >::deposit_event( vec![code_hash], - Event::CodeStored { code_hash, deposit_held: deposit }, + Event::CodeStored { + code_hash, + deposit_held: deposit, + uploader: self.code_info.owner.clone(), + }, ); Ok(deposit) }, @@ -270,12 +274,13 @@ impl WasmBlob { BestEffort, ); let deposit_released = code_info.deposit; + let remover = code_info.owner.clone(); *existing = None; >::remove(&code_hash); >::deposit_event( vec![code_hash], - Event::CodeRemoved { code_hash, deposit_released }, + Event::CodeRemoved { code_hash, deposit_released, remover }, ); Ok(()) } else { From aae16ccf391470d2f4e8f62ae9c2e1659ed376cc Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Wed, 2 Aug 2023 11:39:06 +0200 Subject: [PATCH 105/105] fix zepter ci --- frame/contracts/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/contracts/Cargo.toml b/frame/contracts/Cargo.toml index 1a21d5a0747ab..feaa7cf73fbcc 100644 --- a/frame/contracts/Cargo.toml +++ b/frame/contracts/Cargo.toml @@ -95,8 +95,8 @@ runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "rand", "rand_pcg", - "pallet-balances", "wasm-instrument", + "pallet-balances/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "pallet-proxy/runtime-benchmarks",