From 1060325a21dbcaf414fed55a4a6621772b089c18 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 6 Oct 2023 11:10:22 +0300 Subject: [PATCH 01/14] fix outdated comment --- substrate/frame/recovery/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/substrate/frame/recovery/src/lib.rs b/substrate/frame/recovery/src/lib.rs index 5673147c8e00..089a561eba27 100644 --- a/substrate/frame/recovery/src/lib.rs +++ b/substrate/frame/recovery/src/lib.rs @@ -254,8 +254,8 @@ pub mod pallet { /// The maximum amount of friends allowed in a recovery configuration. /// - /// NOTE: The threshold programmed in this Pallet uses u16, so it does - /// not really make sense to have a limit here greater than u16::MAX. + /// NOTE: The threshold programmed in this Pallet uses u32, so it does + /// not really make sense to have a limit here greater than u32::MAX. /// But also, that is a lot more than you should probably set this value /// to anyway... #[pallet::constant] From 880f041aece4195b68025a8ee38dfca9bd743aae Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 6 Oct 2023 15:24:31 +0300 Subject: [PATCH 02/14] remove ReservableCurrency --- substrate/frame/recovery/src/lib.rs | 72 ++++++++++++++++++--------- substrate/frame/recovery/src/mock.rs | 5 +- substrate/frame/recovery/src/tests.rs | 28 +++++------ 3 files changed, 66 insertions(+), 39 deletions(-) diff --git a/substrate/frame/recovery/src/lib.rs b/substrate/frame/recovery/src/lib.rs index 089a561eba27..6e053f53f548 100644 --- a/substrate/frame/recovery/src/lib.rs +++ b/substrate/frame/recovery/src/lib.rs @@ -68,10 +68,10 @@ //! configuration on the recovered account and reclaim the recovery configuration deposit they //! placed. //! 9. Using `as_recovered`, the account owner is able to call any other pallets to clean up their -//! state and reclaim any reserved or locked funds. They can then transfer all funds from the +//! state and reclaim any held or locked funds. They can then transfer all funds from the //! recovered account to the new account. -//! 10. When the recovered account becomes reaped (i.e. its free and reserved balance drops to -//! zero), the final recovery link is removed. +//! 10. When the recovered account becomes reaped (i.e. its free and held balance drops to zero), +//! the final recovery link is removed. //! //! ### Malicious Recovery Attempts //! @@ -160,7 +160,10 @@ use sp_std::prelude::*; use frame_support::{ dispatch::{GetDispatchInfo, PostDispatchInfo}, - traits::{BalanceStatus, Currency, ReservableCurrency}, + traits::{ + fungible::{Inspect, Mutate, MutateHold}, + tokens::{Fortitude, Precision, Restriction}, + }, BoundedVec, }; @@ -177,7 +180,7 @@ mod tests; pub mod weights; type BalanceOf = - <::Currency as Currency<::AccountId>>::Balance; + <::Currency as Inspect<::AccountId>>::Balance; type FriendsOf = BoundedVec<::AccountId, ::MaxFriends>; type AccountIdLookupOf = <::Lookup as StaticLookup>::Source; @@ -187,7 +190,7 @@ type AccountIdLookupOf = <::Lookup as StaticLookup pub struct ActiveRecovery { /// The block number when the recovery process started. created: BlockNumber, - /// The amount held in reserve of the `depositor`, + /// The amount held the `depositor`, /// To be returned once this recovery process is closed. deposit: Balance, /// The friends which have vouched so far. Always sorted. @@ -200,7 +203,7 @@ pub struct RecoveryConfig { /// The minimum number of blocks since the start of the recovery process before the account /// can be recovered. delay_period: BlockNumber, - /// The amount held in reserve of the `depositor`, + /// The amount held of the `depositor`, /// to be returned once this configuration is removed. deposit: Balance, /// The list of friends which can help recover an account. Always sorted. @@ -235,9 +238,10 @@ pub mod pallet { + From>; /// The currency mechanism. - type Currency: ReservableCurrency; + type Currency: Mutate + + MutateHold; - /// The base amount of currency needed to reserve for creating a recovery configuration. + /// The base amount of currency needed to hold for creating a recovery configuration. /// /// This is held for an additional storage item whose value size is /// `2 + sizeof(BlockNumber, Balance)` bytes. @@ -261,7 +265,7 @@ pub mod pallet { #[pallet::constant] type MaxFriends: Get; - /// The base amount of currency needed to reserve for starting a recovery. + /// The base amount of currency needed to hold for starting a recovery. /// /// This is primarily held for deterring malicious recovery attempts, and should /// have a value large enough that a bad actor would choose not to place this @@ -270,6 +274,9 @@ pub mod pallet { /// threshold. #[pallet::constant] type RecoveryDeposit: Get>; + + /// The overarching hold reason. + type RuntimeHoldReason: From; } /// Events type. @@ -330,6 +337,16 @@ pub mod pallet { BadState, } + /// The reasons for the pallet recovery placing holds on funds. + #[pallet::composite_enum] + pub enum HoldReason { + /// The Pallet holds it as the initial Configuration Deposit, when the Recovery + /// Configuration is created. + ConfigurationDeposit, + /// The Pallet holds it as the Deposit for starting a Recovery Process. + RecoveryProcessDeposit, + } + /// The set of recoverable accounts and their recovery configuration. #[pallet::storage] #[pallet::getter(fn recovery_config)] @@ -424,7 +441,7 @@ pub mod pallet { /// Create a recovery configuration for your account. This makes your account recoverable. /// /// Payment: `ConfigDepositBase` + `FriendDepositFactor` * #_of_friends balance - /// will be reserved for storing the recovery configuration. This deposit is returned + /// will be held for storing the recovery configuration. This deposit is returned /// in full when the user calls `remove_recovery`. /// /// The dispatch origin for this call must be _Signed_. @@ -462,8 +479,8 @@ pub mod pallet { let total_deposit = T::ConfigDepositBase::get() .checked_add(&friend_deposit) .ok_or(ArithmeticError::Overflow)?; - // Reserve the deposit - T::Currency::reserve(&who, total_deposit)?; + // Hold the deposit + T::Currency::hold(&HoldReason::ConfigurationDeposit.into(), &who, total_deposit)?; // Create the recovery configuration let recovery_config = RecoveryConfig { delay_period, @@ -480,7 +497,7 @@ pub mod pallet { /// Initiate the process for recovering a recoverable account. /// - /// Payment: `RecoveryDeposit` balance will be reserved for initiating the + /// Payment: `RecoveryDeposit` balance will be held for initiating the /// recovery process. This deposit will always be repatriated to the account /// trying to be recovered. See `close_recovery`. /// @@ -506,7 +523,7 @@ pub mod pallet { ); // Take recovery deposit let recovery_deposit = T::RecoveryDeposit::get(); - T::Currency::reserve(&who, recovery_deposit)?; + T::Currency::hold(&HoldReason::RecoveryProcessDeposit.into(), &who, recovery_deposit)?; // Create an active recovery status let recovery_status = ActiveRecovery { created: >::block_number(), @@ -637,13 +654,16 @@ pub mod pallet { // Take the active recovery process started by the rescuer for this account. let active_recovery = >::take(&who, &rescuer).ok_or(Error::::NotStarted)?; - // Move the reserved funds from the rescuer to the rescued account. + // Move the held funds from the rescuer to the rescued account. // Acts like a slashing mechanism for those who try to maliciously recover accounts. - let res = T::Currency::repatriate_reserved( + let res = T::Currency::transfer_on_hold( + &HoldReason::RecoveryProcessDeposit.into(), &rescuer, &who, active_recovery.deposit, - BalanceStatus::Free, + Precision::BestEffort, + Restriction::Free, + Fortitude::Force, ); debug_assert!(res.is_ok()); Self::deposit_event(Event::::RecoveryClosed { @@ -658,7 +678,7 @@ pub mod pallet { /// NOTE: The user must make sure to call `close_recovery` on all active /// recovery attempts before calling this function else it will fail. /// - /// Payment: By calling this function the recoverable account will unreserve + /// Payment: By calling this function the recoverable account will release /// their recovery configuration deposit. /// (`ConfigDepositBase` + `FriendDepositFactor` * #_of_friends) /// @@ -671,11 +691,17 @@ pub mod pallet { // Check there are no active recoveries let mut active_recoveries = >::iter_prefix_values(&who); ensure!(active_recoveries.next().is_none(), Error::::StillActive); - // Take the recovery configuration for this account. - let recovery_config = >::take(&who).ok_or(Error::::NotRecoverable)?; - // Unreserve the initial deposit for the recovery configuration. - T::Currency::unreserve(&who, recovery_config.deposit); + // Release the initial deposit for the recovery configuration. + // We can safely "release all" of the held balance under this reason because each + // account can set up a maximum of one recovery configuration. Meaning that all held + // balance on this account under this particular reason belongs to this specific + // configuration. + let _ = T::Currency::release_all( + &HoldReason::ConfigurationDeposit.into(), + &who, + Precision::BestEffort, + ); Self::deposit_event(Event::::RecoveryRemoved { lost_account: who }); Ok(()) } diff --git a/substrate/frame/recovery/src/mock.rs b/substrate/frame/recovery/src/mock.rs index 2f2bd866a719..d48dbe952e9a 100644 --- a/substrate/frame/recovery/src/mock.rs +++ b/substrate/frame/recovery/src/mock.rs @@ -37,7 +37,7 @@ frame_support::construct_runtime!( { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, - Recovery: recovery::{Pallet, Call, Storage, Event}, + Recovery: recovery::{Pallet, Call, Storage, Event, HoldReason}, } ); @@ -83,7 +83,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); type FreezeIdentifier = (); type MaxFreezes = (); - type RuntimeHoldReason = (); + type RuntimeHoldReason = RuntimeHoldReason; type MaxHolds = (); } @@ -104,6 +104,7 @@ impl Config for Test { type FriendDepositFactor = FriendDepositFactor; type MaxFriends = MaxFriends; type RecoveryDeposit = RecoveryDeposit; + type RuntimeHoldReason = RuntimeHoldReason; } pub type BalancesCall = pallet_balances::Call; diff --git a/substrate/frame/recovery/src/tests.rs b/substrate/frame/recovery/src/tests.rs index 93df07015852..010632906b18 100644 --- a/substrate/frame/recovery/src/tests.rs +++ b/substrate/frame/recovery/src/tests.rs @@ -18,10 +18,10 @@ //! Tests for the module. use super::*; -use frame_support::{assert_noop, assert_ok, traits::Currency}; +use frame_support::{assert_noop, assert_ok}; use mock::{ - new_test_ext, run_to_block, Balances, BalancesCall, MaxFriends, Recovery, RecoveryCall, - RuntimeCall, RuntimeOrigin, Test, + new_test_ext, run_to_block, BalancesCall, MaxFriends, Recovery, RecoveryCall, RuntimeCall, + RuntimeOrigin, Test, }; use sp_runtime::{bounded_vec, traits::BadOrigin}; @@ -33,7 +33,7 @@ fn basic_setup_works() { assert_eq!(Recovery::active_recovery(&1, &2), None); assert_eq!(Recovery::recovery_config(&1), None); // Everyone should have starting balance of 100 - assert_eq!(Balances::free_balance(1), 100); + assert_eq!(::Currency::free_balance(1), 100); }); } @@ -51,8 +51,8 @@ fn set_recovered_works() { })); assert_ok!(Recovery::as_recovered(RuntimeOrigin::signed(1), 5, call)); // Account 1 has successfully drained the funds from account 5 - assert_eq!(Balances::free_balance(1), 200); - assert_eq!(Balances::free_balance(5), 0); + assert_eq!(::Currency::free_balance(1), 200); + assert_eq!(::Currency::free_balance(5), 0); }); } @@ -95,15 +95,15 @@ fn recovery_life_cycle_works() { let call = Box::new(RuntimeCall::Recovery(RecoveryCall::remove_recovery {})); assert_ok!(Recovery::as_recovered(RuntimeOrigin::signed(1), 5, call)); // Account 1 should now be able to make a call through account 5 to get all of their funds - assert_eq!(Balances::free_balance(5), 110); + assert_eq!(::Currency::free_balance(5), 110); let call = Box::new(RuntimeCall::Balances(BalancesCall::transfer_allow_death { dest: 1, value: 110, })); assert_ok!(Recovery::as_recovered(RuntimeOrigin::signed(1), 5, call)); // All funds have been fully recovered! - assert_eq!(Balances::free_balance(1), 200); - assert_eq!(Balances::free_balance(5), 0); + assert_eq!(::Currency::free_balance(1), 200); + assert_eq!(::Currency::free_balance(5), 0); // Remove the proxy link. assert_ok!(Recovery::cancel_recovered(RuntimeOrigin::signed(1), 5)); @@ -154,9 +154,9 @@ fn malicious_recovery_fails() { // Account 5 can close the recovery process before account 1 can claim it assert_ok!(Recovery::close_recovery(RuntimeOrigin::signed(5), 1)); // By doing so, account 5 has now claimed the deposit originally reserved by account 1 - assert_eq!(Balances::total_balance(&1), 90); + assert_eq!(::Currency::total_balance(&1), 90); // Thanks for the free money! - assert_eq!(Balances::total_balance(&5), 110); + assert_eq!(::Currency::total_balance(&5), 110); // The recovery process has been closed, so account 1 can't make the claim run_to_block(20); assert_noop!( @@ -236,7 +236,7 @@ fn create_recovery_works() { )); // Deposit is taken, and scales with the number of friends they pick // Base 10 + 1 per friends = 13 total reserved - assert_eq!(Balances::reserved_balance(5), 13); + assert_eq!(::Currency::reserved_balance(5), 13); // Recovery configuration is correctly stored let recovery_config = RecoveryConfig { delay_period, @@ -273,7 +273,7 @@ fn initiate_recovery_handles_basic_errors() { Error::::AlreadyStarted ); // No double deposit - assert_eq!(Balances::reserved_balance(1), 10); + assert_eq!(::Currency::reserved_balance(1), 10); }); } @@ -293,7 +293,7 @@ fn initiate_recovery_works() { // Recovery can be initiated assert_ok!(Recovery::initiate_recovery(RuntimeOrigin::signed(1), 5)); // Deposit is reserved - assert_eq!(Balances::reserved_balance(1), 10); + assert_eq!(::Currency::reserved_balance(1), 10); // Recovery status object is created correctly let recovery_status = ActiveRecovery { created: 0, deposit: 10, friends: Default::default() }; From 3ba2634cca678c59727002ddeb0965ae7a8d34d3 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 6 Oct 2023 15:42:31 +0300 Subject: [PATCH 03/14] update max holds --- substrate/frame/recovery/src/mock.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/recovery/src/mock.rs b/substrate/frame/recovery/src/mock.rs index d48dbe952e9a..7a96053df368 100644 --- a/substrate/frame/recovery/src/mock.rs +++ b/substrate/frame/recovery/src/mock.rs @@ -84,7 +84,7 @@ impl pallet_balances::Config for Test { type FreezeIdentifier = (); type MaxFreezes = (); type RuntimeHoldReason = RuntimeHoldReason; - type MaxHolds = (); + type MaxHolds = ConstU32<1>; } parameter_types! { From f693be300fd100806de69bc89393209218dc46b3 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 6 Oct 2023 15:47:24 +0300 Subject: [PATCH 04/14] re-add recovery config check --- substrate/frame/recovery/src/lib.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/substrate/frame/recovery/src/lib.rs b/substrate/frame/recovery/src/lib.rs index 6e053f53f548..88a3bc4dfa78 100644 --- a/substrate/frame/recovery/src/lib.rs +++ b/substrate/frame/recovery/src/lib.rs @@ -691,15 +691,13 @@ pub mod pallet { // Check there are no active recoveries let mut active_recoveries = >::iter_prefix_values(&who); ensure!(active_recoveries.next().is_none(), Error::::StillActive); - + // Take the recovery configuration for this account. + let recovery_config = >::take(&who).ok_or(Error::::NotRecoverable)?; // Release the initial deposit for the recovery configuration. - // We can safely "release all" of the held balance under this reason because each - // account can set up a maximum of one recovery configuration. Meaning that all held - // balance on this account under this particular reason belongs to this specific - // configuration. - let _ = T::Currency::release_all( + let _ = T::Currency::release( &HoldReason::ConfigurationDeposit.into(), &who, + recovery_config.deposit, Precision::BestEffort, ); Self::deposit_event(Event::::RecoveryRemoved { lost_account: who }); From 964c2cf6b091c682101d91c9f6b6f9d0967ed8aa Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 6 Oct 2023 15:48:38 +0300 Subject: [PATCH 05/14] reformat --- substrate/frame/recovery/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/substrate/frame/recovery/src/lib.rs b/substrate/frame/recovery/src/lib.rs index 88a3bc4dfa78..e21acfd1f4f8 100644 --- a/substrate/frame/recovery/src/lib.rs +++ b/substrate/frame/recovery/src/lib.rs @@ -693,6 +693,7 @@ pub mod pallet { ensure!(active_recoveries.next().is_none(), Error::::StillActive); // Take the recovery configuration for this account. let recovery_config = >::take(&who).ok_or(Error::::NotRecoverable)?; + // Release the initial deposit for the recovery configuration. let _ = T::Currency::release( &HoldReason::ConfigurationDeposit.into(), From b9717be0143a8f91078567c11d2823033def20ed Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 6 Oct 2023 17:51:32 +0300 Subject: [PATCH 06/14] fix benchmarking --- substrate/frame/recovery/src/benchmarking.rs | 48 +++++++++----------- substrate/frame/recovery/src/lib.rs | 10 +++- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/substrate/frame/recovery/src/benchmarking.rs b/substrate/frame/recovery/src/benchmarking.rs index 2deb55bb69f2..1a73b96a3d42 100644 --- a/substrate/frame/recovery/src/benchmarking.rs +++ b/substrate/frame/recovery/src/benchmarking.rs @@ -21,12 +21,12 @@ use super::*; use crate::Pallet; use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; -use frame_support::traits::{Currency, Get}; +use frame_support::traits::Get; use frame_system::RawOrigin; -use sp_runtime::traits::Bounded; const SEED: u32 = 0; const DEFAULT_DELAY: u32 = 0; +const TOP_UP: u32 = 10000; fn assert_last_event(generic_event: ::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); @@ -34,8 +34,7 @@ fn assert_last_event(generic_event: ::RuntimeEvent) { fn get_total_deposit( bounded_friends: &FriendsOf, -) -> Option<<::Currency as Currency<::AccountId>>::Balance> -{ +) -> Option<<::Currency as Inspect<::AccountId>>::Balance> { let friend_deposit = T::FriendDepositFactor::get() .checked_mul(&bounded_friends.len().saturated_into()) .unwrap(); @@ -51,10 +50,7 @@ fn generate_friends(num: u32) -> Vec<::Acc for friend in 0..friends.len() { // Top up accounts of friends - T::Currency::make_free_balance_be( - &friends.get(friend).unwrap(), - BalanceOf::::max_value(), - ); + T::Currency::set_balance(&friends.get(friend).unwrap(), TOP_UP.into()); } friends @@ -67,7 +63,7 @@ fn add_caller_and_generate_friends( // Create friends let mut friends = generate_friends::(num - 1); - T::Currency::make_free_balance_be(&caller, BalanceOf::::max_value()); + T::Currency::set_balance(&caller, TOP_UP.into()); friends.push(caller); @@ -78,7 +74,7 @@ fn add_caller_and_generate_friends( } fn insert_recovery_account(caller: &T::AccountId, account: &T::AccountId) { - T::Currency::make_free_balance_be(&account, BalanceOf::::max_value()); + T::Currency::set_balance(&account, TOP_UP.into()); let n = T::MaxFriends::get(); @@ -96,8 +92,8 @@ fn insert_recovery_account(caller: &T::AccountId, account: &T::Accoun threshold: n as u16, }; - // Reserve deposit for recovery - T::Currency::reserve(&caller, total_deposit).unwrap(); + // Hold deposit for recovery + T::Currency::hold(&HoldReason::RecoveryProcessDeposit.into(), &caller, total_deposit).unwrap(); >::insert(&account, recovery_config); } @@ -138,7 +134,7 @@ benchmarks! { let n in 1 .. T::MaxFriends::get(); let caller: T::AccountId = whitelisted_caller(); - T::Currency::make_free_balance_be(&caller, BalanceOf::::max_value()); + T::Currency::set_balance(&caller, TOP_UP.into()); // Create friends let friends = generate_friends::(n); @@ -153,7 +149,7 @@ benchmarks! { initiate_recovery { let caller: T::AccountId = whitelisted_caller(); - T::Currency::make_free_balance_be(&caller, BalanceOf::::max_value()); + T::Currency::set_balance(&caller, TOP_UP.into()); let lost_account: T::AccountId = account("lost_account", 0, SEED); let lost_account_lookup = T::Lookup::unlookup(lost_account.clone()); @@ -198,8 +194,8 @@ benchmarks! { // Create the recovery config storage item >::insert(&lost_account, recovery_config.clone()); - // Reserve deposit for recovery - T::Currency::reserve(&caller, total_deposit).unwrap(); + // Hold deposit for recovery + T::Currency::hold(&HoldReason::ConfigurationDeposit.into(), &caller, total_deposit).unwrap(); // Create an active recovery status let recovery_status = ActiveRecovery { @@ -232,7 +228,7 @@ benchmarks! { let lost_account: T::AccountId = account("lost_account", 0, SEED); let lost_account_lookup = T::Lookup::unlookup(lost_account.clone()); - T::Currency::make_free_balance_be(&caller, BalanceOf::::max_value()); + T::Currency::set_balance(&caller, TOP_UP.into()); // Create friends let friends = generate_friends::(n); @@ -251,8 +247,8 @@ benchmarks! { // Create the recovery config storage item >::insert(&lost_account, recovery_config.clone()); - // Reserve deposit for recovery - T::Currency::reserve(&caller, total_deposit).unwrap(); + // Hold deposit for recovery + T::Currency::hold(&HoldReason::ConfigurationDeposit.into(), &caller, total_deposit).unwrap(); // Create an active recovery status let recovery_status = ActiveRecovery { @@ -282,8 +278,8 @@ benchmarks! { let n in 1 .. T::MaxFriends::get(); - T::Currency::make_free_balance_be(&caller, BalanceOf::::max_value()); - T::Currency::make_free_balance_be(&rescuer_account, BalanceOf::::max_value()); + T::Currency::set_balance(&caller, TOP_UP.into()); + T::Currency::set_balance(&rescuer_account, TOP_UP.into()); // Create friends let friends = generate_friends::(n); @@ -302,8 +298,8 @@ benchmarks! { // Create the recovery config storage item >::insert(&caller, recovery_config.clone()); - // Reserve deposit for recovery - T::Currency::reserve(&caller, total_deposit).unwrap(); + // Hold deposit for recovery + T::Currency::hold(&HoldReason::ConfigurationDeposit.into(), &caller, total_deposit).unwrap(); // Create an active recovery status let recovery_status = ActiveRecovery { @@ -331,7 +327,7 @@ benchmarks! { let caller: T::AccountId = whitelisted_caller(); - T::Currency::make_free_balance_be(&caller, BalanceOf::::max_value()); + T::Currency::set_balance(&caller, TOP_UP.into()); // Create friends let friends = generate_friends::(n); @@ -350,8 +346,8 @@ benchmarks! { // Create the recovery config storage item >::insert(&caller, recovery_config); - // Reserve deposit for recovery - T::Currency::reserve(&caller, total_deposit).unwrap(); + // Hold deposit for recovery + T::Currency::hold(&HoldReason::ConfigurationDeposit.into(), &caller, total_deposit).unwrap(); }: _( RawOrigin::Signed(caller.clone()) ) verify { diff --git a/substrate/frame/recovery/src/lib.rs b/substrate/frame/recovery/src/lib.rs index e21acfd1f4f8..91dceeb8616c 100644 --- a/substrate/frame/recovery/src/lib.rs +++ b/substrate/frame/recovery/src/lib.rs @@ -158,10 +158,12 @@ use sp_runtime::{ }; use sp_std::prelude::*; +#[cfg(feature = "runtime-benchmarks")] +use frame_support::traits::fungible::Mutate; use frame_support::{ dispatch::{GetDispatchInfo, PostDispatchInfo}, traits::{ - fungible::{Inspect, Mutate, MutateHold}, + fungible::{Inspect, MutateHold}, tokens::{Fortitude, Precision, Restriction}, }, BoundedVec, @@ -238,9 +240,15 @@ pub mod pallet { + From>; /// The currency mechanism. + #[cfg(feature = "runtime-benchmarks")] type Currency: Mutate + + Inspect + MutateHold; + /// The currency mechanism. + #[cfg(not(feature = "runtime-benchmarks"))] + type Currency: MutateHold; + /// The base amount of currency needed to hold for creating a recovery configuration. /// /// This is held for an additional storage item whose value size is From 6d02f14a0ed6089414e96f6cbe09d9d5b465d4b2 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 6 Oct 2023 17:55:04 +0300 Subject: [PATCH 07/14] improve comments --- substrate/frame/recovery/src/benchmarking.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/substrate/frame/recovery/src/benchmarking.rs b/substrate/frame/recovery/src/benchmarking.rs index 1a73b96a3d42..0e5301edc945 100644 --- a/substrate/frame/recovery/src/benchmarking.rs +++ b/substrate/frame/recovery/src/benchmarking.rs @@ -194,7 +194,7 @@ benchmarks! { // Create the recovery config storage item >::insert(&lost_account, recovery_config.clone()); - // Hold deposit for recovery + // Hold deposit for configuration T::Currency::hold(&HoldReason::ConfigurationDeposit.into(), &caller, total_deposit).unwrap(); // Create an active recovery status @@ -247,7 +247,7 @@ benchmarks! { // Create the recovery config storage item >::insert(&lost_account, recovery_config.clone()); - // Hold deposit for recovery + // Hold deposit for configuration T::Currency::hold(&HoldReason::ConfigurationDeposit.into(), &caller, total_deposit).unwrap(); // Create an active recovery status @@ -298,7 +298,7 @@ benchmarks! { // Create the recovery config storage item >::insert(&caller, recovery_config.clone()); - // Hold deposit for recovery + // Hold deposit for configuration T::Currency::hold(&HoldReason::ConfigurationDeposit.into(), &caller, total_deposit).unwrap(); // Create an active recovery status @@ -346,7 +346,7 @@ benchmarks! { // Create the recovery config storage item >::insert(&caller, recovery_config); - // Hold deposit for recovery + // Hold deposit for configuration T::Currency::hold(&HoldReason::ConfigurationDeposit.into(), &caller, total_deposit).unwrap(); }: _( RawOrigin::Signed(caller.clone()) From ef5995a42a0ccf738f03611579341498860c0624 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 6 Oct 2023 17:57:42 +0300 Subject: [PATCH 08/14] refactor runtime-benchmarks Currency --- substrate/frame/recovery/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/substrate/frame/recovery/src/lib.rs b/substrate/frame/recovery/src/lib.rs index 91dceeb8616c..231d176b3423 100644 --- a/substrate/frame/recovery/src/lib.rs +++ b/substrate/frame/recovery/src/lib.rs @@ -242,7 +242,6 @@ pub mod pallet { /// The currency mechanism. #[cfg(feature = "runtime-benchmarks")] type Currency: Mutate - + Inspect + MutateHold; /// The currency mechanism. From 7fed5fb5a4a20b802de0ab62b38ad462e8d1cd95 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 6 Oct 2023 18:20:35 +0300 Subject: [PATCH 09/14] update runtimes --- polkadot/runtime/rococo/src/lib.rs | 3 ++- polkadot/runtime/westend/src/lib.rs | 3 ++- substrate/bin/node/runtime/src/lib.rs | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index 4bdcc1237394..4a0d6cd687f9 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -633,6 +633,7 @@ impl pallet_recovery::Config for Runtime { type FriendDepositFactor = FriendDepositFactor; type MaxFriends = MaxFriends; type RecoveryDeposit = RecoveryDeposit; + type RuntimeHoldReason = RuntimeHoldReason; } parameter_types! { @@ -1262,7 +1263,7 @@ construct_runtime! { Society: pallet_society::{Pallet, Call, Storage, Event} = 26, // Social recovery module. - Recovery: pallet_recovery::{Pallet, Call, Storage, Event} = 27, + Recovery: pallet_recovery::{Pallet, Call, Storage, Event, HoldReason} = 27, // Vesting. Usable initially, but removed once all vesting is finished. Vesting: pallet_vesting::{Pallet, Call, Storage, Event, Config} = 28, diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index 6085b6e37455..a44d1613418e 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -900,6 +900,7 @@ impl pallet_recovery::Config for Runtime { type FriendDepositFactor = FriendDepositFactor; type MaxFriends = MaxFriends; type RecoveryDeposit = RecoveryDeposit; + type RuntimeHoldReason = RuntimeHoldReason; } parameter_types! { @@ -1372,7 +1373,7 @@ construct_runtime! { Identity: pallet_identity::{Pallet, Call, Storage, Event} = 17, // Social recovery module. - Recovery: pallet_recovery::{Pallet, Call, Storage, Event} = 18, + Recovery: pallet_recovery::{Pallet, Call, Storage, Event, HoldReason} = 18, // Vesting. Usable initially, but removed once all vesting is finished. Vesting: pallet_vesting::{Pallet, Call, Storage, Event, Config} = 19, diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index f018639b732e..9e2949043ab8 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -1486,6 +1486,7 @@ impl pallet_recovery::Config for Runtime { type FriendDepositFactor = FriendDepositFactor; type MaxFriends = MaxFriends; type RecoveryDeposit = RecoveryDeposit; + type RuntimeHoldReason = RuntimeHoldReason; } parameter_types! { From 798a69b56a12e45cfeb49f98c877942c86e3873a Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 6 Oct 2023 18:43:39 +0300 Subject: [PATCH 10/14] make TOP_UP higher --- substrate/frame/recovery/src/benchmarking.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/recovery/src/benchmarking.rs b/substrate/frame/recovery/src/benchmarking.rs index 0e5301edc945..2f839c7ad634 100644 --- a/substrate/frame/recovery/src/benchmarking.rs +++ b/substrate/frame/recovery/src/benchmarking.rs @@ -26,7 +26,7 @@ use frame_system::RawOrigin; const SEED: u32 = 0; const DEFAULT_DELAY: u32 = 0; -const TOP_UP: u32 = 10000; +const TOP_UP: u32 = 100000000000; fn assert_last_event(generic_event: ::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); From 7f3898d269985d6fdc27848073419df7bebb1330 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Fri, 6 Oct 2023 18:44:06 +0300 Subject: [PATCH 11/14] make TOP_UP higher --- substrate/frame/recovery/src/benchmarking.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/recovery/src/benchmarking.rs b/substrate/frame/recovery/src/benchmarking.rs index 2f839c7ad634..02dad793e4fc 100644 --- a/substrate/frame/recovery/src/benchmarking.rs +++ b/substrate/frame/recovery/src/benchmarking.rs @@ -26,7 +26,7 @@ use frame_system::RawOrigin; const SEED: u32 = 0; const DEFAULT_DELAY: u32 = 0; -const TOP_UP: u32 = 100000000000; +const TOP_UP: u32 = 1000000000000; fn assert_last_event(generic_event: ::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); From 3a00835adf2e37270f25503cbfcb426a1b440809 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Tue, 10 Oct 2023 19:28:23 +0200 Subject: [PATCH 12/14] update top up --- substrate/frame/recovery/src/benchmarking.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/frame/recovery/src/benchmarking.rs b/substrate/frame/recovery/src/benchmarking.rs index 02dad793e4fc..fa5a257f0554 100644 --- a/substrate/frame/recovery/src/benchmarking.rs +++ b/substrate/frame/recovery/src/benchmarking.rs @@ -26,7 +26,7 @@ use frame_system::RawOrigin; const SEED: u32 = 0; const DEFAULT_DELAY: u32 = 0; -const TOP_UP: u32 = 1000000000000; +const TOP_UP: u32 = 1000000000; fn assert_last_event(generic_event: ::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); From 72707cfde45d2082be1b0649db13918148553e88 Mon Sep 17 00:00:00 2001 From: Juan Girini Date: Wed, 11 Oct 2023 11:31:43 +0200 Subject: [PATCH 13/14] remove top up --- substrate/frame/recovery/src/benchmarking.rs | 22 +++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/substrate/frame/recovery/src/benchmarking.rs b/substrate/frame/recovery/src/benchmarking.rs index fa5a257f0554..e6b652a58e3b 100644 --- a/substrate/frame/recovery/src/benchmarking.rs +++ b/substrate/frame/recovery/src/benchmarking.rs @@ -26,7 +26,6 @@ use frame_system::RawOrigin; const SEED: u32 = 0; const DEFAULT_DELAY: u32 = 0; -const TOP_UP: u32 = 1000000000; fn assert_last_event(generic_event: ::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); @@ -50,7 +49,10 @@ fn generate_friends(num: u32) -> Vec<::Acc for friend in 0..friends.len() { // Top up accounts of friends - T::Currency::set_balance(&friends.get(friend).unwrap(), TOP_UP.into()); + T::Currency::set_balance( + &friends.get(friend).unwrap(), + T::Currency::minimum_balance() * 10000u32.into(), + ); } friends @@ -63,7 +65,7 @@ fn add_caller_and_generate_friends( // Create friends let mut friends = generate_friends::(num - 1); - T::Currency::set_balance(&caller, TOP_UP.into()); + T::Currency::set_balance(&caller, T::Currency::minimum_balance() * 10000u32.into()); friends.push(caller); @@ -74,7 +76,7 @@ fn add_caller_and_generate_friends( } fn insert_recovery_account(caller: &T::AccountId, account: &T::AccountId) { - T::Currency::set_balance(&account, TOP_UP.into()); + T::Currency::set_balance(&account, T::Currency::minimum_balance() * 10000u32.into()); let n = T::MaxFriends::get(); @@ -134,7 +136,7 @@ benchmarks! { let n in 1 .. T::MaxFriends::get(); let caller: T::AccountId = whitelisted_caller(); - T::Currency::set_balance(&caller, TOP_UP.into()); + T::Currency::set_balance(&caller, T::Currency::minimum_balance() * 10000u32.into()); // Create friends let friends = generate_friends::(n); @@ -149,7 +151,7 @@ benchmarks! { initiate_recovery { let caller: T::AccountId = whitelisted_caller(); - T::Currency::set_balance(&caller, TOP_UP.into()); + T::Currency::set_balance(&caller, T::Currency::minimum_balance() * 10000u32.into()); let lost_account: T::AccountId = account("lost_account", 0, SEED); let lost_account_lookup = T::Lookup::unlookup(lost_account.clone()); @@ -228,7 +230,7 @@ benchmarks! { let lost_account: T::AccountId = account("lost_account", 0, SEED); let lost_account_lookup = T::Lookup::unlookup(lost_account.clone()); - T::Currency::set_balance(&caller, TOP_UP.into()); + T::Currency::set_balance(&caller, T::Currency::minimum_balance() * 10000u32.into()); // Create friends let friends = generate_friends::(n); @@ -278,8 +280,8 @@ benchmarks! { let n in 1 .. T::MaxFriends::get(); - T::Currency::set_balance(&caller, TOP_UP.into()); - T::Currency::set_balance(&rescuer_account, TOP_UP.into()); + T::Currency::set_balance(&caller, T::Currency::minimum_balance() * 10000u32.into()); + T::Currency::set_balance(&rescuer_account, T::Currency::minimum_balance() * 10000u32.into()); // Create friends let friends = generate_friends::(n); @@ -327,7 +329,7 @@ benchmarks! { let caller: T::AccountId = whitelisted_caller(); - T::Currency::set_balance(&caller, TOP_UP.into()); + T::Currency::set_balance(&caller, T::Currency::minimum_balance() * 10000u32.into()); // Create friends let friends = generate_friends::(n); From 658971eae8c9ab6048fdef868ea1ebb8abe8d150 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Wed, 11 Oct 2023 11:38:28 +0000 Subject: [PATCH 14/14] ".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime=dev --target_dir=substrate --pallet=pallet_recovery --- substrate/frame/recovery/src/weights.rs | 359 +++++++++++++----------- 1 file changed, 188 insertions(+), 171 deletions(-) diff --git a/substrate/frame/recovery/src/weights.rs b/substrate/frame/recovery/src/weights.rs index 84b19ae694ee..59c1c07880df 100644 --- a/substrate/frame/recovery/src/weights.rs +++ b/substrate/frame/recovery/src/weights.rs @@ -15,32 +15,29 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! Autogenerated weights for pallet_recovery +//! Autogenerated weights for `pallet_recovery` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-06-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-11, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-e8ezs4ez-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-nbnwcyh-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: -// ./target/production/substrate +// target/production/substrate-node // benchmark // pallet -// --chain=dev // --steps=50 // --repeat=20 -// --pallet=pallet_recovery -// --no-storage-info -// --no-median-slopes -// --no-min-squares // --extrinsic=* -// --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./frame/recovery/src/weights.rs -// --header=./HEADER-APACHE2 -// --template=./.maintain/frame-weight-template.hbs +// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json +// --pallet=pallet_recovery +// --chain=dev +// --header=./substrate/HEADER-APACHE2 +// --output=./substrate/frame/recovery/src/weights.rs +// --template=./substrate/.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -50,7 +47,7 @@ use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use core::marker::PhantomData; -/// Weight functions needed for pallet_recovery. +/// Weight functions needed for `pallet_recovery`. pub trait WeightInfo { fn as_recovered() -> Weight; fn set_recovered() -> Weight; @@ -63,258 +60,278 @@ pub trait WeightInfo { fn cancel_recovered() -> Weight; } -/// Weights for pallet_recovery using the Substrate node and recommended hardware. +/// Weights for `pallet_recovery` using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - /// Storage: Recovery Proxy (r:1 w:0) - /// Proof: Recovery Proxy (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: `Recovery::Proxy` (r:1 w:0) + /// Proof: `Recovery::Proxy` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + /// Storage: `SafeMode::EnteredUntil` (r:1 w:0) + /// Proof: `SafeMode::EnteredUntil` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `TxPause::PausedCalls` (r:1 w:0) + /// Proof: `TxPause::PausedCalls` (`max_values`: None, `max_size`: Some(532), added: 3007, mode: `MaxEncodedLen`) fn as_recovered() -> Weight { // Proof Size summary in bytes: - // Measured: `281` - // Estimated: `3545` - // Minimum execution time: 9_360_000 picoseconds. - Weight::from_parts(9_773_000, 3545) - .saturating_add(T::DbWeight::get().reads(1_u64)) + // Measured: `497` + // Estimated: `3997` + // Minimum execution time: 14_978_000 picoseconds. + Weight::from_parts(15_426_000, 3997) + .saturating_add(T::DbWeight::get().reads(3_u64)) } - /// Storage: Recovery Proxy (r:0 w:1) - /// Proof: Recovery Proxy (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: `Recovery::Proxy` (r:0 w:1) + /// Proof: `Recovery::Proxy` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) fn set_recovered() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_146_000 picoseconds. - Weight::from_parts(9_507_000, 0) + // Minimum execution time: 7_215_000 picoseconds. + Weight::from_parts(7_533_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: Recovery Recoverable (r:1 w:1) - /// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen) + /// Storage: `Recovery::Recoverable` (r:1 w:1) + /// Proof: `Recovery::Recoverable` (`max_values`: None, `max_size`: Some(351), added: 2826, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `MaxEncodedLen`) /// The range of component `n` is `[1, 9]`. - fn create_recovery(n: u32, ) -> Weight { + fn create_recovery(_n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `175` + // Measured: `246` // Estimated: `3816` - // Minimum execution time: 26_472_000 picoseconds. - Weight::from_parts(27_917_651, 3816) - // Standard Error: 7_129 - .saturating_add(Weight::from_parts(59_239, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Minimum execution time: 40_846_000 picoseconds. + Weight::from_parts(43_003_881, 3816) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - /// Storage: Recovery Recoverable (r:1 w:0) - /// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen) - /// Storage: Recovery ActiveRecoveries (r:1 w:1) - /// Proof: Recovery ActiveRecoveries (max_values: None, max_size: Some(389), added: 2864, mode: MaxEncodedLen) + /// Storage: `Recovery::Recoverable` (r:1 w:0) + /// Proof: `Recovery::Recoverable` (`max_values`: None, `max_size`: Some(351), added: 2826, mode: `MaxEncodedLen`) + /// Storage: `Recovery::ActiveRecoveries` (r:1 w:1) + /// Proof: `Recovery::ActiveRecoveries` (`max_values`: None, `max_size`: Some(389), added: 2864, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `MaxEncodedLen`) fn initiate_recovery() -> Weight { // Proof Size summary in bytes: - // Measured: `272` + // Measured: `399` // Estimated: `3854` - // Minimum execution time: 29_618_000 picoseconds. - Weight::from_parts(30_192_000, 3854) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Minimum execution time: 46_415_000 picoseconds. + Weight::from_parts(47_838_000, 3854) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - /// Storage: Recovery Recoverable (r:1 w:0) - /// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen) - /// Storage: Recovery ActiveRecoveries (r:1 w:1) - /// Proof: Recovery ActiveRecoveries (max_values: None, max_size: Some(389), added: 2864, mode: MaxEncodedLen) + /// Storage: `Recovery::Recoverable` (r:1 w:0) + /// Proof: `Recovery::Recoverable` (`max_values`: None, `max_size`: Some(351), added: 2826, mode: `MaxEncodedLen`) + /// Storage: `Recovery::ActiveRecoveries` (r:1 w:1) + /// Proof: `Recovery::ActiveRecoveries` (`max_values`: None, `max_size`: Some(389), added: 2864, mode: `MaxEncodedLen`) /// The range of component `n` is `[1, 9]`. fn vouch_recovery(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `360 + n * (64 ±0)` + // Measured: `431 + n * (64 ±0)` // Estimated: `3854` - // Minimum execution time: 19_464_000 picoseconds. - Weight::from_parts(20_642_522, 3854) - // Standard Error: 5_974 - .saturating_add(Weight::from_parts(142_308, 0).saturating_mul(n.into())) + // Minimum execution time: 17_650_000 picoseconds. + Weight::from_parts(18_549_554, 3854) + // Standard Error: 5_639 + .saturating_add(Weight::from_parts(165_063, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: Recovery Recoverable (r:1 w:0) - /// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen) - /// Storage: Recovery ActiveRecoveries (r:1 w:0) - /// Proof: Recovery ActiveRecoveries (max_values: None, max_size: Some(389), added: 2864, mode: MaxEncodedLen) - /// Storage: Recovery Proxy (r:1 w:1) - /// Proof: Recovery Proxy (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: `Recovery::Recoverable` (r:1 w:0) + /// Proof: `Recovery::Recoverable` (`max_values`: None, `max_size`: Some(351), added: 2826, mode: `MaxEncodedLen`) + /// Storage: `Recovery::ActiveRecoveries` (r:1 w:0) + /// Proof: `Recovery::ActiveRecoveries` (`max_values`: None, `max_size`: Some(389), added: 2864, mode: `MaxEncodedLen`) + /// Storage: `Recovery::Proxy` (r:1 w:1) + /// Proof: `Recovery::Proxy` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) /// The range of component `n` is `[1, 9]`. fn claim_recovery(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `392 + n * (64 ±0)` + // Measured: `463 + n * (64 ±0)` // Estimated: `3854` - // Minimum execution time: 23_656_000 picoseconds. - Weight::from_parts(24_903_269, 3854) - // Standard Error: 5_771 - .saturating_add(Weight::from_parts(117_343, 0).saturating_mul(n.into())) + // Minimum execution time: 22_116_000 picoseconds. + Weight::from_parts(23_394_422, 3854) + // Standard Error: 6_460 + .saturating_add(Weight::from_parts(123_990, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: Recovery ActiveRecoveries (r:1 w:1) - /// Proof: Recovery ActiveRecoveries (max_values: None, max_size: Some(389), added: 2864, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: `Recovery::ActiveRecoveries` (r:1 w:1) + /// Proof: `Recovery::ActiveRecoveries` (`max_values`: None, `max_size`: Some(389), added: 2864, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// The range of component `n` is `[1, 9]`. fn close_recovery(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `513 + n * (32 ±0)` + // Measured: `640 + n * (32 ±0)` // Estimated: `3854` - // Minimum execution time: 34_866_000 picoseconds. - Weight::from_parts(36_368_748, 3854) - // Standard Error: 6_600 - .saturating_add(Weight::from_parts(118_610, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + // Minimum execution time: 33_055_000 picoseconds. + Weight::from_parts(33_866_688, 3854) + // Standard Error: 11_055 + .saturating_add(Weight::from_parts(375_493, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } - /// Storage: Recovery ActiveRecoveries (r:1 w:0) - /// Proof: Recovery ActiveRecoveries (max_values: None, max_size: Some(389), added: 2864, mode: MaxEncodedLen) - /// Storage: Recovery Recoverable (r:1 w:1) - /// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen) + /// Storage: `Recovery::ActiveRecoveries` (r:1 w:0) + /// Proof: `Recovery::ActiveRecoveries` (`max_values`: None, `max_size`: Some(389), added: 2864, mode: `MaxEncodedLen`) + /// Storage: `Recovery::Recoverable` (r:1 w:1) + /// Proof: `Recovery::Recoverable` (`max_values`: None, `max_size`: Some(351), added: 2826, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `MaxEncodedLen`) /// The range of component `n` is `[1, 9]`. fn remove_recovery(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `270 + n * (32 ±0)` + // Measured: `397 + n * (32 ±0)` // Estimated: `3854` - // Minimum execution time: 31_405_000 picoseconds. - Weight::from_parts(32_552_838, 3854) - // Standard Error: 8_043 - .saturating_add(Weight::from_parts(171_605, 0).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Minimum execution time: 41_769_000 picoseconds. + Weight::from_parts(43_418_125, 3854) + // Standard Error: 8_521 + .saturating_add(Weight::from_parts(175_925, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - /// Storage: Recovery Proxy (r:1 w:1) - /// Proof: Recovery Proxy (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: `Recovery::Proxy` (r:1 w:1) + /// Proof: `Recovery::Proxy` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) fn cancel_recovered() -> Weight { // Proof Size summary in bytes: - // Measured: `281` + // Measured: `352` // Estimated: `3545` - // Minimum execution time: 11_530_000 picoseconds. - Weight::from_parts(11_851_000, 3545) + // Minimum execution time: 11_635_000 picoseconds. + Weight::from_parts(12_200_000, 3545) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } } -// For backwards compatibility and tests +// For backwards compatibility and tests. impl WeightInfo for () { - /// Storage: Recovery Proxy (r:1 w:0) - /// Proof: Recovery Proxy (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: `Recovery::Proxy` (r:1 w:0) + /// Proof: `Recovery::Proxy` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + /// Storage: `SafeMode::EnteredUntil` (r:1 w:0) + /// Proof: `SafeMode::EnteredUntil` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `TxPause::PausedCalls` (r:1 w:0) + /// Proof: `TxPause::PausedCalls` (`max_values`: None, `max_size`: Some(532), added: 3007, mode: `MaxEncodedLen`) fn as_recovered() -> Weight { // Proof Size summary in bytes: - // Measured: `281` - // Estimated: `3545` - // Minimum execution time: 9_360_000 picoseconds. - Weight::from_parts(9_773_000, 3545) - .saturating_add(RocksDbWeight::get().reads(1_u64)) + // Measured: `497` + // Estimated: `3997` + // Minimum execution time: 14_978_000 picoseconds. + Weight::from_parts(15_426_000, 3997) + .saturating_add(RocksDbWeight::get().reads(3_u64)) } - /// Storage: Recovery Proxy (r:0 w:1) - /// Proof: Recovery Proxy (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: `Recovery::Proxy` (r:0 w:1) + /// Proof: `Recovery::Proxy` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) fn set_recovered() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_146_000 picoseconds. - Weight::from_parts(9_507_000, 0) + // Minimum execution time: 7_215_000 picoseconds. + Weight::from_parts(7_533_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: Recovery Recoverable (r:1 w:1) - /// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen) + /// Storage: `Recovery::Recoverable` (r:1 w:1) + /// Proof: `Recovery::Recoverable` (`max_values`: None, `max_size`: Some(351), added: 2826, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `MaxEncodedLen`) /// The range of component `n` is `[1, 9]`. - fn create_recovery(n: u32, ) -> Weight { + fn create_recovery(_n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `175` + // Measured: `246` // Estimated: `3816` - // Minimum execution time: 26_472_000 picoseconds. - Weight::from_parts(27_917_651, 3816) - // Standard Error: 7_129 - .saturating_add(Weight::from_parts(59_239, 0).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) + // Minimum execution time: 40_846_000 picoseconds. + Weight::from_parts(43_003_881, 3816) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - /// Storage: Recovery Recoverable (r:1 w:0) - /// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen) - /// Storage: Recovery ActiveRecoveries (r:1 w:1) - /// Proof: Recovery ActiveRecoveries (max_values: None, max_size: Some(389), added: 2864, mode: MaxEncodedLen) + /// Storage: `Recovery::Recoverable` (r:1 w:0) + /// Proof: `Recovery::Recoverable` (`max_values`: None, `max_size`: Some(351), added: 2826, mode: `MaxEncodedLen`) + /// Storage: `Recovery::ActiveRecoveries` (r:1 w:1) + /// Proof: `Recovery::ActiveRecoveries` (`max_values`: None, `max_size`: Some(389), added: 2864, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `MaxEncodedLen`) fn initiate_recovery() -> Weight { // Proof Size summary in bytes: - // Measured: `272` + // Measured: `399` // Estimated: `3854` - // Minimum execution time: 29_618_000 picoseconds. - Weight::from_parts(30_192_000, 3854) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) + // Minimum execution time: 46_415_000 picoseconds. + Weight::from_parts(47_838_000, 3854) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - /// Storage: Recovery Recoverable (r:1 w:0) - /// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen) - /// Storage: Recovery ActiveRecoveries (r:1 w:1) - /// Proof: Recovery ActiveRecoveries (max_values: None, max_size: Some(389), added: 2864, mode: MaxEncodedLen) + /// Storage: `Recovery::Recoverable` (r:1 w:0) + /// Proof: `Recovery::Recoverable` (`max_values`: None, `max_size`: Some(351), added: 2826, mode: `MaxEncodedLen`) + /// Storage: `Recovery::ActiveRecoveries` (r:1 w:1) + /// Proof: `Recovery::ActiveRecoveries` (`max_values`: None, `max_size`: Some(389), added: 2864, mode: `MaxEncodedLen`) /// The range of component `n` is `[1, 9]`. fn vouch_recovery(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `360 + n * (64 ±0)` + // Measured: `431 + n * (64 ±0)` // Estimated: `3854` - // Minimum execution time: 19_464_000 picoseconds. - Weight::from_parts(20_642_522, 3854) - // Standard Error: 5_974 - .saturating_add(Weight::from_parts(142_308, 0).saturating_mul(n.into())) + // Minimum execution time: 17_650_000 picoseconds. + Weight::from_parts(18_549_554, 3854) + // Standard Error: 5_639 + .saturating_add(Weight::from_parts(165_063, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: Recovery Recoverable (r:1 w:0) - /// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen) - /// Storage: Recovery ActiveRecoveries (r:1 w:0) - /// Proof: Recovery ActiveRecoveries (max_values: None, max_size: Some(389), added: 2864, mode: MaxEncodedLen) - /// Storage: Recovery Proxy (r:1 w:1) - /// Proof: Recovery Proxy (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: `Recovery::Recoverable` (r:1 w:0) + /// Proof: `Recovery::Recoverable` (`max_values`: None, `max_size`: Some(351), added: 2826, mode: `MaxEncodedLen`) + /// Storage: `Recovery::ActiveRecoveries` (r:1 w:0) + /// Proof: `Recovery::ActiveRecoveries` (`max_values`: None, `max_size`: Some(389), added: 2864, mode: `MaxEncodedLen`) + /// Storage: `Recovery::Proxy` (r:1 w:1) + /// Proof: `Recovery::Proxy` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) /// The range of component `n` is `[1, 9]`. fn claim_recovery(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `392 + n * (64 ±0)` + // Measured: `463 + n * (64 ±0)` // Estimated: `3854` - // Minimum execution time: 23_656_000 picoseconds. - Weight::from_parts(24_903_269, 3854) - // Standard Error: 5_771 - .saturating_add(Weight::from_parts(117_343, 0).saturating_mul(n.into())) + // Minimum execution time: 22_116_000 picoseconds. + Weight::from_parts(23_394_422, 3854) + // Standard Error: 6_460 + .saturating_add(Weight::from_parts(123_990, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } - /// Storage: Recovery ActiveRecoveries (r:1 w:1) - /// Proof: Recovery ActiveRecoveries (max_values: None, max_size: Some(389), added: 2864, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: `Recovery::ActiveRecoveries` (r:1 w:1) + /// Proof: `Recovery::ActiveRecoveries` (`max_values`: None, `max_size`: Some(389), added: 2864, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// The range of component `n` is `[1, 9]`. fn close_recovery(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `513 + n * (32 ±0)` + // Measured: `640 + n * (32 ±0)` // Estimated: `3854` - // Minimum execution time: 34_866_000 picoseconds. - Weight::from_parts(36_368_748, 3854) - // Standard Error: 6_600 - .saturating_add(Weight::from_parts(118_610, 0).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) + // Minimum execution time: 33_055_000 picoseconds. + Weight::from_parts(33_866_688, 3854) + // Standard Error: 11_055 + .saturating_add(Weight::from_parts(375_493, 0).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } - /// Storage: Recovery ActiveRecoveries (r:1 w:0) - /// Proof: Recovery ActiveRecoveries (max_values: None, max_size: Some(389), added: 2864, mode: MaxEncodedLen) - /// Storage: Recovery Recoverable (r:1 w:1) - /// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen) + /// Storage: `Recovery::ActiveRecoveries` (r:1 w:0) + /// Proof: `Recovery::ActiveRecoveries` (`max_values`: None, `max_size`: Some(389), added: 2864, mode: `MaxEncodedLen`) + /// Storage: `Recovery::Recoverable` (r:1 w:1) + /// Proof: `Recovery::Recoverable` (`max_values`: None, `max_size`: Some(351), added: 2826, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(85), added: 2560, mode: `MaxEncodedLen`) /// The range of component `n` is `[1, 9]`. fn remove_recovery(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `270 + n * (32 ±0)` + // Measured: `397 + n * (32 ±0)` // Estimated: `3854` - // Minimum execution time: 31_405_000 picoseconds. - Weight::from_parts(32_552_838, 3854) - // Standard Error: 8_043 - .saturating_add(Weight::from_parts(171_605, 0).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) + // Minimum execution time: 41_769_000 picoseconds. + Weight::from_parts(43_418_125, 3854) + // Standard Error: 8_521 + .saturating_add(Weight::from_parts(175_925, 0).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - /// Storage: Recovery Proxy (r:1 w:1) - /// Proof: Recovery Proxy (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: `Recovery::Proxy` (r:1 w:1) + /// Proof: `Recovery::Proxy` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) fn cancel_recovered() -> Weight { // Proof Size summary in bytes: - // Measured: `281` + // Measured: `352` // Estimated: `3545` - // Minimum execution time: 11_530_000 picoseconds. - Weight::from_parts(11_851_000, 3545) + // Minimum execution time: 11_635_000 picoseconds. + Weight::from_parts(12_200_000, 3545) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) }