diff --git a/Cargo.lock b/Cargo.lock index 29b0e24d37..b3d4d013a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -137,12 +137,14 @@ dependencies = [ "module-evm-bridge", "module-evm-rpc-runtime-api", "module-homa", + "module-homa-validator-list", "module-honzon", "module-idle-scheduler", "module-incentives", "module-liquid-crowdloan", "module-loans", "module-nft", + "module-nominees-election", "module-prices", "module-relaychain", "module-session-manager", @@ -188,6 +190,7 @@ dependencies = [ "pallet-treasury", "pallet-utility", "pallet-xcm", + "pallet-xcm-benchmarks", "parachains-common", "parity-scale-codec", "polkadot-parachain-primitives", @@ -4866,7 +4869,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite 0.2.13", - "socket2 0.4.10", + "socket2 0.5.7", "tokio", "tower-service", "tracing", @@ -5632,12 +5635,14 @@ dependencies = [ "module-evm-bridge", "module-evm-rpc-runtime-api", "module-homa", + "module-homa-validator-list", "module-honzon", "module-honzon-bridge", "module-idle-scheduler", "module-incentives", "module-loans", "module-nft", + "module-nominees-election", "module-prices", "module-relaychain", "module-session-manager", @@ -5676,6 +5681,7 @@ dependencies = [ "pallet-proxy", "pallet-scheduler", "pallet-session", + "pallet-state-trie-migration", "pallet-sudo", "pallet-timestamp", "pallet-tips", @@ -5684,6 +5690,7 @@ dependencies = [ "pallet-treasury", "pallet-utility", "pallet-xcm", + "pallet-xcm-benchmarks", "parachains-common", "parity-scale-codec", "polkadot-parachain-primitives", @@ -7007,6 +7014,7 @@ dependencies = [ "module-evm-rpc-runtime-api", "module-evm-utility", "module-homa", + "module-homa-validator-list", "module-honzon", "module-idle-scheduler", "module-incentives", @@ -7064,6 +7072,7 @@ dependencies = [ "pallet-treasury", "pallet-utility", "pallet-xcm", + "pallet-xcm-benchmarks", "parachains-common", "parity-scale-codec", "polkadot-parachain-primitives", diff --git a/Cargo.toml b/Cargo.toml index 8e406600b3..49331edfff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -204,6 +204,7 @@ module-evm-bridge = { path = "modules/evm-bridge", default-features = false } module-evm-rpc-runtime-api = { path = "modules/evm/rpc/runtime-api", default-features = false } module-evm-utility = { path = "modules/evm-utility", default-features = false } module-homa = { path = "modules/homa", default-features = false } +module-homa-validator-list = { path = "modules/homa-validator-list", default-features = false } module-honzon = { path = "modules/honzon", default-features = false } module-honzon-bridge = { path = "modules/honzon-bridge", default-features = false } module-idle-scheduler = { path = "modules/idle-scheduler", default-features = false } @@ -263,6 +264,7 @@ pallet-recovery = { version = "37.0.0", default-features = false } pallet-root-testing = { version = "13.0.0", default-features = false } pallet-scheduler = { version = "38.0.0", default-features = false } pallet-session = { version = "37.0.0", default-features = false } +pallet-state-trie-migration = { version = "39.0.0", default-features = false } pallet-sudo = { version = "37.0.0", default-features = false } pallet-timestamp = { version = "36.0.0", default-features = false } pallet-tips = { version = "36.0.0", default-features = false } @@ -271,6 +273,7 @@ pallet-transaction-payment-rpc-runtime-api = { version = "37.0.0", default-featu pallet-treasury = { version = "36.0.0", default-features = false } pallet-utility = { version = "37.0.0", default-features = false } pallet-xcm = { version = "16.0.0", default-features = false } +pallet-xcm-benchmarks = { version = "16.0.0", default-features = false } parachain-info = { version = "0.16.0", package = "staging-parachain-info", default-features = false } parachains-common = { version = "17.0.0", default-features = false } polkadot-core-primitives = { version = "15.0.0", default-features = false } diff --git a/launch/yarn.lock b/launch/yarn.lock index a9bbb03d38..ebc9d7231a 100644 --- a/launch/yarn.lock +++ b/launch/yarn.lock @@ -739,9 +739,9 @@ wrappy@1: integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= ws@^8.14.2, ws@^8.8.1: - version "8.15.1" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.15.1.tgz#271ba33a45ca0cc477940f7f200cd7fba7ee1997" - integrity sha512-W5OZiCjXEmk0yZ66ZN82beM5Sz7l7coYxpRkzS+p9PP+ToQry8szKh+61eNktr7EA9DOwvFGhfC605jDHbP6QQ== + version "8.17.1" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.1.tgz#9293da530bb548febc95371d90f9c878727d919b" + integrity sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ== y18n@^5.0.5: version "5.0.8" diff --git a/modules/homa-validator-list/src/lib.rs b/modules/homa-validator-list/src/lib.rs index 3664b23fdf..e26603424f 100644 --- a/modules/homa-validator-list/src/lib.rs +++ b/modules/homa-validator-list/src/lib.rs @@ -27,80 +27,49 @@ #![cfg_attr(not(feature = "std"), no_std)] #![allow(clippy::unused_unit)] #![allow(clippy::collapsible_if)] +#![allow(clippy::type_complexity)] -use frame_support::{pallet_prelude::*, traits::Contains}; +use frame_support::pallet_prelude::*; +use frame_support::traits::Contains; use frame_system::pallet_prelude::*; use module_support::{ExchangeRateProvider, Ratio}; -use orml_traits::{BasicCurrency, BasicLockableCurrency, Happened, LockIdentifier}; +use orml_traits::{BasicCurrency, BasicLockableCurrency, LockIdentifier}; use parity_scale_codec::MaxEncodedLen; -use primitives::Balance; +use primitives::{Balance, EraIndex}; use scale_info::TypeInfo; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; use sp_runtime::{ - traits::{BlockNumberProvider, Bounded, MaybeDisplay, MaybeSerializeDeserialize, Member, Zero}, + traits::{Bounded, MaybeDisplay, MaybeSerializeDeserialize, Member, Zero}, DispatchResult, FixedPointNumber, RuntimeDebug, }; -use sp_std::{fmt::Debug, vec::Vec}; +use sp_std::{fmt::Debug, vec, vec::Vec}; mod mock; mod tests; +pub mod weights; pub use module::*; +pub use weights::WeightInfo; -pub const HOMA_VALIDATOR_LIST_ID: LockIdentifier = *b"acalahvl"; - -pub trait WeightInfo { - fn bond() -> Weight; - fn unbond() -> Weight; - fn rebond() -> Weight; - fn withdraw_unbonded() -> Weight; - fn freeze(u: u32) -> Weight; - fn thaw() -> Weight; - fn slash() -> Weight; -} - -// TODO: do benchmarking test. -impl WeightInfo for () { - fn bond() -> Weight { - Weight::from_parts(10_000, 0) - } - fn unbond() -> Weight { - Weight::from_parts(10_000, 0) - } - fn rebond() -> Weight { - Weight::from_parts(10_000, 0) - } - fn withdraw_unbonded() -> Weight { - Weight::from_parts(10_000, 0) - } - fn freeze(_u: u32) -> Weight { - Weight::from_parts(10_000, 0) - } - fn thaw() -> Weight { - Weight::from_parts(10_000, 0) - } - fn slash() -> Weight { - Weight::from_parts(10_000, 0) - } -} +pub const HOMA_VALIDATOR_LIST_ID: LockIdentifier = *b"aca/hmvl"; /// Insurance for a validator from a single address #[derive(Encode, Decode, Clone, Copy, RuntimeDebug, Default, PartialEq, Eq, MaxEncodedLen, TypeInfo)] -pub struct Guarantee { +pub struct Guarantee { /// The total tokens the validator has in insurance total: Balance, /// The number of tokens that are actively bonded for insurance bonded: Balance, /// The number of tokens that are in the process of unbonding for insurance - unbonding: Option<(Balance, BlockNumber)>, + unbonding: Option<(Balance, EraIndex)>, } -impl Guarantee { +impl Guarantee { /// Take `unbonding` that are sufficiently old - fn consolidate_unbonding(mut self, current_block: BlockNumber) -> Self { + fn consolidate_unbonding(mut self, current_era: EraIndex) -> Self { match self.unbonding { - Some((_, expired_block)) if expired_block <= current_block => { + Some((_, expired_era)) if expired_era <= current_era => { self.unbonding = None; } _ => {} @@ -145,15 +114,15 @@ impl Guarantee { /// Information on a relay chain validator's slash #[derive(Encode, Decode, Clone, RuntimeDebug, Eq, PartialEq, MaxEncodedLen, TypeInfo)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -pub struct SlashInfo { +pub struct SlashInfo { /// Address of a validator on the relay chain - validator: RelaychainAccountId, + pub validator: RelayChainAccountId, /// The amount of tokens a validator has in backing on the relay chain - relaychain_token_amount: Balance, + pub relaychain_token_amount: Balance, } /// Validator insurance and frozen status -#[derive(Encode, Decode, Clone, Copy, RuntimeDebug, Default, MaxEncodedLen, TypeInfo)] +#[derive(Encode, Decode, Clone, Copy, RuntimeDebug, Default, MaxEncodedLen, TypeInfo, PartialEq)] pub struct ValidatorBacking { /// Total insurance from all guarantors total_insurance: Balance, @@ -168,42 +137,41 @@ pub mod module { pub trait Config: frame_system::Config { /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; + /// The AccountId of a relay chain account. - type RelaychainAccountId: Parameter + type RelayChainAccountId: Parameter + Member + MaybeSerializeDeserialize + Debug + MaybeDisplay + Ord - + Default + MaxEncodedLen; + /// The liquid representation of the staking token on the relay chain. type LiquidTokenCurrency: BasicLockableCurrency; - #[pallet::constant] + /// The minimum amount of tokens that can be bonded to a validator. - type MinBondAmount: Get; #[pallet::constant] - /// The number of blocks a token is bonded to a validator for. - type BondingDuration: Get>; + type MinBondAmount: Get; + + /// The waiting eras when unbond token. #[pallet::constant] + type BondingDuration: Get; + /// The minimum amount of insurance a validator needs. + #[pallet::constant] type ValidatorInsuranceThreshold: Get; - /// The AccountId that can perform a freeze. - type FreezeOrigin: EnsureOrigin; - /// The AccountId that can perform a slash. - type SlashOrigin: EnsureOrigin; - /// Callback to be called when a slash occurs. - type OnSlash: Happened; + + /// Origin represented Governance + type GovernanceOrigin: EnsureOrigin; + /// Exchange rate between staked token and liquid token equivalent. type LiquidStakingExchangeRateProvider: ExchangeRateProvider; - type WeightInfo: WeightInfo; - /// Callback to be called when a validator's insurance increases. - type OnIncreaseGuarantee: Happened<(Self::AccountId, Self::RelaychainAccountId, Balance)>; - /// Callback to be called when a validator's insurance decreases. - type OnDecreaseGuarantee: Happened<(Self::AccountId, Self::RelaychainAccountId, Balance)>; - // The block number provider - type BlockNumberProvider: BlockNumberProvider>; + /// Current era. + type CurrentEra: Get; + + type WeightInfo: WeightInfo; } #[pallet::error] @@ -217,45 +185,45 @@ pub mod module { #[pallet::generate_deposit(pub(crate) fn deposit_event)] pub enum Event { FreezeValidator { - validator: T::RelaychainAccountId, + validator: T::RelayChainAccountId, }, ThawValidator { - validator: T::RelaychainAccountId, + validator: T::RelayChainAccountId, }, BondGuarantee { who: T::AccountId, - validator: T::RelaychainAccountId, + validator: T::RelayChainAccountId, bond: Balance, }, UnbondGuarantee { who: T::AccountId, - validator: T::RelaychainAccountId, + validator: T::RelayChainAccountId, bond: Balance, }, WithdrawnGuarantee { who: T::AccountId, - validator: T::RelaychainAccountId, + validator: T::RelayChainAccountId, bond: Balance, }, SlashGuarantee { who: T::AccountId, - validator: T::RelaychainAccountId, + validator: T::RelayChainAccountId, bond: Balance, }, } /// The slash guarantee deposits for relaychain validators. /// - /// Guarantees: double_map RelaychainAccountId, AccountId => Option + /// Guarantees: double_map RelayChainAccountId, AccountId => Option #[pallet::storage] #[pallet::getter(fn guarantees)] pub type Guarantees = StorageDoubleMap< _, Blake2_128Concat, - T::RelaychainAccountId, + T::RelayChainAccountId, Twox64Concat, T::AccountId, - Guarantee>, + Guarantee, OptionQuery, >; @@ -268,11 +236,11 @@ pub mod module { /// Total deposit for validators. /// - /// ValidatorBackings: map RelaychainAccountId => Option + /// ValidatorBackings: map RelayChainAccountId => Option #[pallet::storage] #[pallet::getter(fn validator_backings)] pub type ValidatorBackings = - StorageMap<_, Blake2_128Concat, T::RelaychainAccountId, ValidatorBacking, OptionQuery>; + StorageMap<_, Blake2_128Concat, T::RelayChainAccountId, ValidatorBacking, OptionQuery>; #[pallet::pallet] pub struct Pallet(_); @@ -291,7 +259,7 @@ pub mod module { #[pallet::weight(T::WeightInfo::bond())] pub fn bond( origin: OriginFor, - validator: T::RelaychainAccountId, + validator: T::RelayChainAccountId, #[pallet::compact] amount: Balance, ) -> DispatchResult { let guarantor = ensure_signed(origin)?; @@ -330,7 +298,7 @@ pub mod module { #[pallet::weight(T::WeightInfo::unbond())] pub fn unbond( origin: OriginFor, - validator: T::RelaychainAccountId, + validator: T::RelayChainAccountId, #[pallet::compact] amount: Balance, ) -> DispatchResult { let guarantor = ensure_signed(origin)?; @@ -344,8 +312,8 @@ pub mod module { guarantee.bonded.is_zero() || guarantee.bonded >= T::MinBondAmount::get(), Error::::BelowMinBondAmount, ); - let expired_block = T::BlockNumberProvider::current_block_number() + T::BondingDuration::get(); - guarantee.unbonding = Some((amount, expired_block)); + let expired_era = T::CurrentEra::get() + T::BondingDuration::get(); + guarantee.unbonding = Some((amount, expired_era)); Self::deposit_event(Event::UnbondGuarantee { who: guarantor.clone(), @@ -366,7 +334,7 @@ pub mod module { #[pallet::weight(T::WeightInfo::rebond())] pub fn rebond( origin: OriginFor, - validator: T::RelaychainAccountId, + validator: T::RelayChainAccountId, #[pallet::compact] amount: Balance, ) -> DispatchResult { let guarantor = ensure_signed(origin)?; @@ -386,7 +354,7 @@ pub mod module { /// - `validator`: The AccountId of a validator on the relay chain to withdraw from #[pallet::call_index(3)] #[pallet::weight(T::WeightInfo::withdraw_unbonded())] - pub fn withdraw_unbonded(origin: OriginFor, validator: T::RelaychainAccountId) -> DispatchResult { + pub fn withdraw_unbonded(origin: OriginFor, validator: T::RelayChainAccountId) -> DispatchResult { let guarantor = ensure_signed(origin)?; ensure!( !Self::validator_backings(&validator).unwrap_or_default().is_frozen, @@ -394,7 +362,7 @@ pub mod module { ); Self::update_guarantee(&guarantor, &validator, |guarantee| -> DispatchResult { let old_total = guarantee.total; - *guarantee = guarantee.consolidate_unbonding(T::BlockNumberProvider::current_block_number()); + *guarantee = guarantee.consolidate_unbonding(T::CurrentEra::get()); let new_total = guarantee .bonded .saturating_add(guarantee.unbonding.unwrap_or_default().0); @@ -417,8 +385,8 @@ pub mod module { /// - `validators`: The AccountIds of the validators on the relay chain to freeze #[pallet::call_index(4)] #[pallet::weight(T::WeightInfo::freeze(validators.len() as u32))] - pub fn freeze(origin: OriginFor, validators: Vec) -> DispatchResult { - T::FreezeOrigin::ensure_origin(origin)?; + pub fn freeze(origin: OriginFor, validators: Vec) -> DispatchResult { + T::GovernanceOrigin::ensure_origin(origin)?; validators.iter().for_each(|validator| { ValidatorBackings::::mutate_exists(validator, |maybe_validator| { let mut v = maybe_validator.take().unwrap_or_default(); @@ -439,11 +407,9 @@ pub mod module { /// /// - `validators`: The AccountIds of the validators on the relay chain to unfreeze #[pallet::call_index(5)] - #[pallet::weight(T::WeightInfo::thaw())] - pub fn thaw(origin: OriginFor, validators: Vec) -> DispatchResult { - // Using SlashOrigin instead of FreezeOrigin so that un-freezing requires more council members than - // freezing - T::SlashOrigin::ensure_origin(origin)?; + #[pallet::weight(T::WeightInfo::thaw(validators.len() as u32))] + pub fn thaw(origin: OriginFor, validators: Vec) -> DispatchResult { + T::GovernanceOrigin::ensure_origin(origin)?; validators.iter().for_each(|validator| { ValidatorBackings::::mutate_exists(validator, |maybe_validator| { let mut v = maybe_validator.take().unwrap_or_default(); @@ -464,9 +430,9 @@ pub mod module { /// /// - `slashes`: The SlashInfos of the validators to be slashed #[pallet::call_index(6)] - #[pallet::weight(T::WeightInfo::slash())] - pub fn slash(origin: OriginFor, slashes: Vec>) -> DispatchResult { - T::SlashOrigin::ensure_origin(origin)?; + #[pallet::weight(T::WeightInfo::slash(slashes.len() as u32))] + pub fn slash(origin: OriginFor, slashes: Vec>) -> DispatchResult { + T::GovernanceOrigin::ensure_origin(origin)?; let liquid_staking_exchange_rate = T::LiquidStakingExchangeRateProvider::get_exchange_rate(); let staking_liquid_exchange_rate = liquid_staking_exchange_rate.reciprocal().unwrap_or_default(); let mut actual_total_slashing: Balance = Zero::zero(); @@ -502,7 +468,6 @@ pub mod module { } } - T::OnSlash::happened(&actual_total_slashing); Ok(()) } } @@ -511,8 +476,8 @@ pub mod module { impl Pallet { fn update_guarantee( guarantor: &T::AccountId, - validator: &T::RelaychainAccountId, - f: impl FnOnce(&mut Guarantee>) -> DispatchResult, + validator: &T::RelayChainAccountId, + f: impl FnOnce(&mut Guarantee) -> DispatchResult, ) -> DispatchResult { Guarantees::::try_mutate_exists(validator, guarantor, |maybe_guarantee| -> DispatchResult { let mut guarantee = maybe_guarantee.take().unwrap_or_default(); @@ -542,12 +507,10 @@ impl Pallet { let gap = new_total - old_total; vb.total_insurance = vb.total_insurance.saturating_add(gap); tl = tl.saturating_add(gap); - T::OnIncreaseGuarantee::happened(&(guarantor.clone(), validator.clone(), gap)); } else { let gap = old_total - new_total; vb.total_insurance = vb.total_insurance.saturating_sub(gap); tl = tl.saturating_sub(gap); - T::OnDecreaseGuarantee::happened(&(guarantor.clone(), validator.clone(), gap)); }; if tl.is_zero() { @@ -572,11 +535,9 @@ impl Pallet { } } -impl Contains for Pallet { - fn contains(relaychain_account_id: &T::RelaychainAccountId) -> bool { - Self::validator_backings(relaychain_account_id) - .unwrap_or_default() - .total_insurance - >= T::ValidatorInsuranceThreshold::get() +impl Contains for Pallet { + fn contains(account: &T::RelayChainAccountId) -> bool { + ValidatorBackings::::get(account) + .is_some_and(|vb| vb.total_insurance >= T::ValidatorInsuranceThreshold::get() && !vb.is_frozen) } } diff --git a/modules/homa-validator-list/src/mock.rs b/modules/homa-validator-list/src/mock.rs index 9f92194fd2..f8bc85b233 100644 --- a/modules/homa-validator-list/src/mock.rs +++ b/modules/homa-validator-list/src/mock.rs @@ -22,24 +22,24 @@ use super::*; use frame_support::{ - construct_runtime, derive_impl, ord_parameter_types, parameter_types, - traits::{ConstU128, ConstU32, ConstU64, Nothing}, + construct_runtime, derive_impl, parameter_types, + traits::{ConstU128, ConstU32, Nothing}, }; -use frame_system::EnsureSignedBy; +use frame_system::EnsureRoot; use module_support::ExchangeRate; use orml_traits::parameter_type_with_key; use primitives::{Amount, Balance, CurrencyId, TokenSymbol}; use sp_runtime::{traits::IdentityLookup, BuildStorage}; -use std::collections::HashMap; pub type AccountId = u128; pub type BlockNumber = u64; pub const ALICE: AccountId = 0; pub const BOB: AccountId = 1; -pub const VALIDATOR_1: AccountId = 2; -pub const VALIDATOR_2: AccountId = 3; -pub const VALIDATOR_3: AccountId = 4; +pub const CHARLIE: AccountId = 2; +pub const VALIDATOR_1: AccountId = 11; +pub const VALIDATOR_2: AccountId = 12; +pub const VALIDATOR_3: AccountId = 13; pub const ACA: CurrencyId = CurrencyId::Token(TokenSymbol::ACA); pub const LDOT: CurrencyId = CurrencyId::Token(TokenSymbol::LDOT); @@ -106,52 +106,6 @@ impl orml_currencies::Config for Runtime { type WeightInfo = (); } -parameter_types! { - pub static Shares: HashMap<(AccountId, AccountId), Balance> = HashMap::new(); - pub static AccumulatedSlash: Balance = 0; -} - -pub struct MockOnSlash; -impl Happened for MockOnSlash { - fn happened(amount: &Balance) { - AccumulatedSlash::mutate(|v| *v += amount); - } -} - -pub struct MockOnIncreaseGuarantee; -impl Happened<(AccountId, AccountId, Balance)> for MockOnIncreaseGuarantee { - fn happened(info: &(AccountId, AccountId, Balance)) { - let (account_id, relaychain_id, amount) = info; - Shares::mutate(|v| { - let mut old_map = v.clone(); - if let Some(share) = old_map.get_mut(&(*account_id, *relaychain_id)) { - *share = share.saturating_add(*amount); - } else { - old_map.insert((*account_id, *relaychain_id), *amount); - }; - - *v = old_map; - }); - } -} - -pub struct MockOnDecreaseGuarantee; -impl Happened<(AccountId, AccountId, Balance)> for MockOnDecreaseGuarantee { - fn happened(info: &(AccountId, AccountId, Balance)) { - let (account_id, relaychain_id, amount) = info; - Shares::mutate(|v| { - let mut old_map = v.clone(); - if let Some(share) = old_map.get_mut(&(*account_id, *relaychain_id)) { - *share = share.saturating_sub(*amount); - } else { - old_map.insert((*account_id, *relaychain_id), Default::default()); - }; - - *v = old_map; - }); - } -} - pub struct MockLiquidStakingExchangeProvider; impl ExchangeRateProvider for MockLiquidStakingExchangeProvider { fn get_exchange_rate() -> ExchangeRate { @@ -160,36 +114,22 @@ impl ExchangeRateProvider for MockLiquidStakingExchangeProvider { } parameter_types! { - pub static MockBlockNumberProvider: u64 = 0; -} - -impl BlockNumberProvider for MockBlockNumberProvider { - type BlockNumber = u64; - - fn current_block_number() -> Self::BlockNumber { - Self::get() - } -} - -ord_parameter_types! { - pub const Admin: AccountId = 10; + pub static MockCurrentEra: EraIndex = 0; + pub ActiveSubAccountsIndexList: Vec = vec![0, 1, 2]; + pub const BondingDuration: EraIndex = 28; } impl Config for Runtime { type RuntimeEvent = RuntimeEvent; - type RelaychainAccountId = AccountId; + type RelayChainAccountId = AccountId; type LiquidTokenCurrency = LDOTCurrency; type MinBondAmount = ConstU128<100>; - type BondingDuration = ConstU64<100>; + type BondingDuration = BondingDuration; type ValidatorInsuranceThreshold = ConstU128<200>; - type FreezeOrigin = EnsureSignedBy; - type SlashOrigin = EnsureSignedBy; - type OnSlash = MockOnSlash; + type GovernanceOrigin = EnsureRoot; type LiquidStakingExchangeRateProvider = MockLiquidStakingExchangeProvider; + type CurrentEra = MockCurrentEra; type WeightInfo = (); - type OnIncreaseGuarantee = MockOnIncreaseGuarantee; - type OnDecreaseGuarantee = MockOnDecreaseGuarantee; - type BlockNumberProvider = MockBlockNumberProvider; } type Block = frame_system::mocking::MockBlock; @@ -211,7 +151,7 @@ pub struct ExtBuilder { impl Default for ExtBuilder { fn default() -> Self { Self { - balances: vec![(ALICE, LDOT, 1000), (BOB, LDOT, 1000)], + balances: vec![(ALICE, LDOT, 1000), (BOB, LDOT, 1000), (CHARLIE, LDOT, 1000000)], } } } @@ -228,6 +168,10 @@ impl ExtBuilder { .assimilate_storage(&mut t) .unwrap(); - t.into() + let mut ext = sp_io::TestExternalities::new(t); + ext.execute_with(|| { + System::set_block_number(1); + }); + ext } } diff --git a/modules/homa-validator-list/src/tests.rs b/modules/homa-validator-list/src/tests.rs index 5bcbfbdd73..e77d4e6f9f 100644 --- a/modules/homa-validator-list/src/tests.rs +++ b/modules/homa-validator-list/src/tests.rs @@ -84,7 +84,6 @@ fn guarantee_work() { #[test] fn freeze_work() { ExtBuilder::default().build().execute_with(|| { - System::set_block_number(1); assert_noop!( HomaValidatorListModule::freeze( RuntimeOrigin::signed(ALICE), @@ -109,7 +108,7 @@ fn freeze_work() { .is_frozen, ); assert_ok!(HomaValidatorListModule::freeze( - RuntimeOrigin::signed(10), + RuntimeOrigin::root(), vec![VALIDATOR_1, VALIDATOR_2, VALIDATOR_3] )); assert!( @@ -143,7 +142,6 @@ fn freeze_work() { #[test] fn thaw_work() { ExtBuilder::default().build().execute_with(|| { - System::set_block_number(1); assert_noop!( HomaValidatorListModule::thaw( RuntimeOrigin::signed(ALICE), @@ -153,7 +151,7 @@ fn thaw_work() { ); assert_ok!(HomaValidatorListModule::freeze( - RuntimeOrigin::signed(10), + RuntimeOrigin::root(), vec![VALIDATOR_1, VALIDATOR_2] )); assert!( @@ -172,7 +170,7 @@ fn thaw_work() { .is_frozen ); assert_ok!(HomaValidatorListModule::thaw( - RuntimeOrigin::signed(10), + RuntimeOrigin::root(), vec![VALIDATOR_1, VALIDATOR_2, VALIDATOR_3] )); assert!( @@ -202,8 +200,6 @@ fn thaw_work() { #[test] fn bond_work() { ExtBuilder::default().build().execute_with(|| { - System::set_block_number(1); - assert_noop!( HomaValidatorListModule::bond(RuntimeOrigin::signed(ALICE), VALIDATOR_1, 99), Error::::BelowMinBondAmount @@ -227,7 +223,6 @@ fn bond_work() { .total_insurance, 0 ); - assert_eq!(SHARES.with(|v| *v.borrow().get(&(ALICE, VALIDATOR_1)).unwrap_or(&0)), 0); assert_ok!(HomaValidatorListModule::bond( RuntimeOrigin::signed(ALICE), @@ -260,10 +255,6 @@ fn bond_work() { .total_insurance, 100 ); - assert_eq!( - SHARES.with(|v| *v.borrow().get(&(ALICE, VALIDATOR_1)).unwrap_or(&0)), - 100 - ); assert_eq!( HomaValidatorListModule::guarantees(VALIDATOR_1, BOB).unwrap_or_default(), @@ -284,7 +275,6 @@ fn bond_work() { .total_insurance, 100 ); - assert_eq!(SHARES.with(|v| *v.borrow().get(&(BOB, VALIDATOR_1)).unwrap_or(&0)), 0); assert_ok!(HomaValidatorListModule::bond( RuntimeOrigin::signed(BOB), @@ -317,7 +307,6 @@ fn bond_work() { .total_insurance, 400 ); - assert_eq!(SHARES.with(|v| *v.borrow().get(&(BOB, VALIDATOR_1)).unwrap_or(&0)), 300); assert_eq!( HomaValidatorListModule::guarantees(VALIDATOR_2, BOB).unwrap_or_default(), @@ -338,7 +327,6 @@ fn bond_work() { .total_insurance, 0 ); - assert_eq!(SHARES.with(|v| *v.borrow().get(&(BOB, VALIDATOR_2)).unwrap_or(&0)), 0); assert_ok!(HomaValidatorListModule::bond( RuntimeOrigin::signed(BOB), @@ -371,15 +359,13 @@ fn bond_work() { .total_insurance, 200 ); - assert_eq!(SHARES.with(|v| *v.borrow().get(&(BOB, VALIDATOR_2)).unwrap_or(&0)), 200); }); } #[test] fn unbond_work() { ExtBuilder::default().build().execute_with(|| { - System::set_block_number(1); - MockBlockNumberProvider::set(1); + MockCurrentEra::set(1); assert_ok!(HomaValidatorListModule::bond( RuntimeOrigin::signed(ALICE), @@ -405,10 +391,6 @@ fn unbond_work() { .total_insurance, 200 ); - assert_eq!( - SHARES.with(|v| *v.borrow().get(&(ALICE, VALIDATOR_1)).unwrap_or(&0)), - 200 - ); assert_noop!( HomaValidatorListModule::unbond(RuntimeOrigin::signed(ALICE), VALIDATOR_1, 199), @@ -432,7 +414,7 @@ fn unbond_work() { Guarantee { total: 200, bonded: 100, - unbonding: Some((100, 101)) + unbonding: Some((100, 29)) } ); assert_eq!(OrmlTokens::accounts(ALICE, LDOT).frozen, 200); @@ -446,10 +428,6 @@ fn unbond_work() { .total_insurance, 200 ); - assert_eq!( - SHARES.with(|v| *v.borrow().get(&(ALICE, VALIDATOR_1)).unwrap_or(&0)), - 200 - ); assert_noop!( HomaValidatorListModule::unbond(RuntimeOrigin::signed(ALICE), VALIDATOR_1, 100), @@ -461,8 +439,7 @@ fn unbond_work() { #[test] fn rebond_work() { ExtBuilder::default().build().execute_with(|| { - System::set_block_number(1); - MockBlockNumberProvider::set(1); + MockCurrentEra::set(1); assert_ok!(HomaValidatorListModule::bond( RuntimeOrigin::signed(ALICE), @@ -480,7 +457,7 @@ fn rebond_work() { Guarantee { total: 200, bonded: 100, - unbonding: Some((100, 101)) + unbonding: Some((100, 29)) } ); assert_eq!(OrmlTokens::accounts(ALICE, LDOT).frozen, 200); @@ -494,10 +471,6 @@ fn rebond_work() { .total_insurance, 200 ); - assert_eq!( - SHARES.with(|v| *v.borrow().get(&(ALICE, VALIDATOR_1)).unwrap_or(&0)), - 200 - ); assert_ok!(HomaValidatorListModule::rebond( RuntimeOrigin::signed(ALICE), @@ -509,7 +482,7 @@ fn rebond_work() { Guarantee { total: 200, bonded: 150, - unbonding: Some((50, 101)) + unbonding: Some((50, 29)) } ); assert_eq!(OrmlTokens::accounts(ALICE, LDOT).frozen, 200); @@ -523,18 +496,13 @@ fn rebond_work() { .total_insurance, 200 ); - assert_eq!( - SHARES.with(|v| *v.borrow().get(&(ALICE, VALIDATOR_1)).unwrap_or(&0)), - 200 - ); }); } #[test] fn withdraw_unbonded_work() { ExtBuilder::default().build().execute_with(|| { - System::set_block_number(1); - MockBlockNumberProvider::set(1); + MockCurrentEra::set(1); assert_ok!(HomaValidatorListModule::bond( RuntimeOrigin::signed(ALICE), @@ -562,7 +530,7 @@ fn withdraw_unbonded_work() { Guarantee { total: 200, bonded: 100, - unbonding: Some((100, 101)) + unbonding: Some((100, 29)) } ); assert_eq!(OrmlTokens::accounts(ALICE, LDOT).frozen, 200); @@ -576,12 +544,8 @@ fn withdraw_unbonded_work() { .total_insurance, 400 ); - assert_eq!( - SHARES.with(|v| *v.borrow().get(&(ALICE, VALIDATOR_1)).unwrap_or(&0)), - 200 - ); - MockBlockNumberProvider::set(100); + MockCurrentEra::set(28); assert_ok!(HomaValidatorListModule::withdraw_unbonded( RuntimeOrigin::signed(ALICE), VALIDATOR_1 @@ -591,7 +555,7 @@ fn withdraw_unbonded_work() { Guarantee { total: 200, bonded: 100, - unbonding: Some((100, 101)) + unbonding: Some((100, 29)) } ); assert_eq!(OrmlTokens::accounts(ALICE, LDOT).frozen, 200); @@ -605,12 +569,8 @@ fn withdraw_unbonded_work() { .total_insurance, 400 ); - assert_eq!( - SHARES.with(|v| *v.borrow().get(&(ALICE, VALIDATOR_1)).unwrap_or(&0)), - 200 - ); System::reset_events(); - MockBlockNumberProvider::set(101); + MockCurrentEra::set(29); assert_ok!(HomaValidatorListModule::withdraw_unbonded( RuntimeOrigin::signed(ALICE), VALIDATOR_1 @@ -641,13 +601,9 @@ fn withdraw_unbonded_work() { .total_insurance, 300 ); - assert_eq!( - SHARES.with(|v| *v.borrow().get(&(ALICE, VALIDATOR_1)).unwrap_or(&0)), - 100 - ); assert_ok!(HomaValidatorListModule::freeze( - RuntimeOrigin::signed(10), + RuntimeOrigin::root(), vec![VALIDATOR_1] )); assert_noop!( @@ -660,8 +616,6 @@ fn withdraw_unbonded_work() { #[test] fn slash_work() { ExtBuilder::default().build().execute_with(|| { - System::set_block_number(1); - assert_ok!(HomaValidatorListModule::bond( RuntimeOrigin::signed(ALICE), VALIDATOR_1, @@ -700,10 +654,6 @@ fn slash_work() { unbonding: None } ); - assert_eq!( - SHARES.with(|v| *v.borrow().get(&(ALICE, VALIDATOR_1)).unwrap_or(&0)), - 100 - ); assert_eq!(OrmlTokens::accounts(ALICE, LDOT).frozen, 100); assert_eq!( HomaValidatorListModule::total_locked_by_guarantor(ALICE).unwrap_or_default(), @@ -719,7 +669,6 @@ fn slash_work() { unbonding: None } ); - assert_eq!(SHARES.with(|v| *v.borrow().get(&(BOB, VALIDATOR_1)).unwrap_or(&0)), 200); assert_eq!( HomaValidatorListModule::guarantees(VALIDATOR_2, BOB).unwrap_or_default(), Guarantee { @@ -728,7 +677,6 @@ fn slash_work() { unbonding: None } ); - assert_eq!(SHARES.with(|v| *v.borrow().get(&(BOB, VALIDATOR_2)).unwrap_or(&0)), 300); assert_eq!(OrmlTokens::accounts(BOB, LDOT).frozen, 500); assert_eq!( HomaValidatorListModule::total_locked_by_guarantor(BOB).unwrap_or_default(), @@ -753,7 +701,7 @@ fn slash_work() { ); assert_ok!(HomaValidatorListModule::slash( - RuntimeOrigin::signed(10), + RuntimeOrigin::root(), vec![ SlashInfo { validator: VALIDATOR_1, @@ -808,10 +756,6 @@ fn slash_work() { unbonding: None } ); - assert_eq!( - SHARES.with(|v| *v.borrow().get(&(ALICE, VALIDATOR_1)).unwrap_or(&0)), - 41 - ); assert_eq!(OrmlTokens::accounts(ALICE, LDOT).frozen, 41); assert_eq!( HomaValidatorListModule::total_locked_by_guarantor(ALICE).unwrap_or_default(), @@ -827,7 +771,6 @@ fn slash_work() { unbonding: None } ); - assert_eq!(SHARES.with(|v| *v.borrow().get(&(BOB, VALIDATOR_1)).unwrap_or(&0)), 81); assert_eq!( HomaValidatorListModule::guarantees(VALIDATOR_2, BOB).unwrap_or_default(), Guarantee { @@ -836,7 +779,6 @@ fn slash_work() { unbonding: None } ); - assert_eq!(SHARES.with(|v| *v.borrow().get(&(BOB, VALIDATOR_2)).unwrap_or(&0)), 200); assert_eq!(OrmlTokens::accounts(BOB, LDOT).frozen, 281); assert_eq!( HomaValidatorListModule::total_locked_by_guarantor(BOB).unwrap_or_default(), @@ -844,36 +786,3 @@ fn slash_work() { ); }); } - -#[test] -fn contains_work() { - ExtBuilder::default().build().execute_with(|| { - MockBlockNumberProvider::set(1); - - assert_ok!(HomaValidatorListModule::bond( - RuntimeOrigin::signed(ALICE), - VALIDATOR_1, - 100 - )); - assert_eq!( - HomaValidatorListModule::validator_backings(VALIDATOR_1) - .unwrap_or_default() - .total_insurance, - 100 - ); - assert!(!HomaValidatorListModule::contains(&VALIDATOR_1)); - - assert_ok!(HomaValidatorListModule::bond( - RuntimeOrigin::signed(ALICE), - VALIDATOR_1, - 100 - )); - assert_eq!( - HomaValidatorListModule::validator_backings(VALIDATOR_1) - .unwrap_or_default() - .total_insurance, - 200 - ); - assert!(HomaValidatorListModule::contains(&VALIDATOR_1)); - }); -} diff --git a/modules/homa-validator-list/src/weights.rs b/modules/homa-validator-list/src/weights.rs new file mode 100644 index 0000000000..5e344ad7d2 --- /dev/null +++ b/modules/homa-validator-list/src/weights.rs @@ -0,0 +1,324 @@ +// This file is part of Acala. + +// Copyright (C) 2020-2024 Acala Foundation. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +//! Autogenerated weights for module_homa_validator_list +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-04-14, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `192.168.1.2`, CPU: `` +//! WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 + +// Executed Command: +// target/release/acala +// benchmark +// pallet +// --chain=dev +// --steps=50 +// --repeat=20 +// --pallet=module_homa_validator_list +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --output=./modules/homa-validator-list/src/weights.rs +// --template=./templates/module-weight-template.hbs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for module_homa_validator_list. +pub trait WeightInfo { + fn bond() -> Weight; + fn unbond() -> Weight; + fn rebond() -> Weight; + fn withdraw_unbonded() -> Weight; + fn freeze(n: u32, ) -> Weight; + fn thaw(n: u32, ) -> Weight; + fn slash(n: u32, ) -> Weight; +} + +/// Weights for module_homa_validator_list using the Acala node and recommended hardware. +pub struct AcalaWeight(PhantomData); +impl WeightInfo for AcalaWeight { + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::TotalLockedByGuarantor` (r:1 w:1) + // Proof: `HomaValidatorList::TotalLockedByGuarantor` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::Guarantees` (r:1 w:1) + // Proof: `HomaValidatorList::Guarantees` (`max_values`: None, `max_size`: Some(141), added: 2616, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::ValidatorBackings` (r:1 w:1) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + fn bond() -> Weight { + // Proof Size summary in bytes: + // Measured: `2388` + // Estimated: `4765` + // Minimum execution time: 47_000 nanoseconds. + Weight::from_parts(50_000_000, 4765) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) + } + // Storage: `HomaValidatorList::Guarantees` (r:1 w:1) + // Proof: `HomaValidatorList::Guarantees` (`max_values`: None, `max_size`: Some(141), added: 2616, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::ValidationData` (r:1 w:0) + // Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::LastRelayChainBlockNumber` (r:1 w:0) + // Proof: `ParachainSystem::LastRelayChainBlockNumber` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + fn unbond() -> Weight { + // Proof Size summary in bytes: + // Measured: `1506` + // Estimated: `3606` + // Minimum execution time: 22_000 nanoseconds. + Weight::from_parts(22_000_000, 3606) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: `HomaValidatorList::Guarantees` (r:1 w:1) + // Proof: `HomaValidatorList::Guarantees` (`max_values`: None, `max_size`: Some(141), added: 2616, mode: `MaxEncodedLen`) + fn rebond() -> Weight { + // Proof Size summary in bytes: + // Measured: `1044` + // Estimated: `3606` + // Minimum execution time: 11_000 nanoseconds. + Weight::from_parts(11_000_000, 3606) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: `HomaValidatorList::ValidatorBackings` (r:1 w:1) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::Guarantees` (r:1 w:1) + // Proof: `HomaValidatorList::Guarantees` (`max_values`: None, `max_size`: Some(141), added: 2616, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::ValidationData` (r:1 w:0) + // Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `HomaValidatorList::TotalLockedByGuarantor` (r:1 w:1) + // Proof: `HomaValidatorList::TotalLockedByGuarantor` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + fn withdraw_unbonded() -> Weight { + // Proof Size summary in bytes: + // Measured: `2312` + // Estimated: `4765` + // Minimum execution time: 49_000 nanoseconds. + Weight::from_parts(50_000_000, 4765) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) + } + // Storage: `HomaValidatorList::ValidatorBackings` (r:10 w:10) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// The range of component `n` is `[1, 10]`. + fn freeze(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1235 + n * (71 ±0)` + // Estimated: `990 + n * (2540 ±0)` + // Minimum execution time: 17_000 nanoseconds. + Weight::from_parts(12_956_759, 990) + // Standard Error: 11_087 + .saturating_add(Weight::from_parts(5_475_545, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 2540).saturating_mul(n.into())) + } + // Storage: `HomaValidatorList::ValidatorBackings` (r:10 w:10) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// The range of component `n` is `[1, 10]`. + fn thaw(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1235 + n * (71 ±0)` + // Estimated: `990 + n * (2540 ±0)` + // Minimum execution time: 17_000 nanoseconds. + Weight::from_parts(13_302_017, 990) + // Standard Error: 13_600 + .saturating_add(Weight::from_parts(5_468_920, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 2540).saturating_mul(n.into())) + } + // Storage: `Homa::TotalStakingBonded` (r:1 w:0) + // Proof: `Homa::TotalStakingBonded` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `Homa::ToBondPool` (r:1 w:0) + // Proof: `Homa::ToBondPool` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `Tokens::TotalIssuance` (r:1 w:1) + // Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + // Storage: `Homa::TotalVoidLiquid` (r:1 w:0) + // Proof: `Homa::TotalVoidLiquid` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `HomaValidatorList::ValidatorBackings` (r:10 w:10) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::Guarantees` (r:20 w:10) + // Proof: `HomaValidatorList::Guarantees` (`max_values`: None, `max_size`: Some(141), added: 2616, mode: `MaxEncodedLen`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::TotalLockedByGuarantor` (r:1 w:1) + // Proof: `HomaValidatorList::TotalLockedByGuarantor` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + /// The range of component `n` is `[1, 10]`. + fn slash(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2834 + n * (200 ±0)` + // Estimated: `4765 + n * (5232 ±0)` + // Minimum execution time: 73_000 nanoseconds. + Weight::from_parts(37_933_640, 4765) + // Standard Error: 120_845 + .saturating_add(Weight::from_parts(41_000_469, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes(4)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 5232).saturating_mul(n.into())) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::TotalLockedByGuarantor` (r:1 w:1) + // Proof: `HomaValidatorList::TotalLockedByGuarantor` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::Guarantees` (r:1 w:1) + // Proof: `HomaValidatorList::Guarantees` (`max_values`: None, `max_size`: Some(141), added: 2616, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::ValidatorBackings` (r:1 w:1) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + fn bond() -> Weight { + // Proof Size summary in bytes: + // Measured: `2388` + // Estimated: `4765` + // Minimum execution time: 47_000 nanoseconds. + Weight::from_parts(50_000_000, 4765) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(5)) + } + // Storage: `HomaValidatorList::Guarantees` (r:1 w:1) + // Proof: `HomaValidatorList::Guarantees` (`max_values`: None, `max_size`: Some(141), added: 2616, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::ValidationData` (r:1 w:0) + // Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::LastRelayChainBlockNumber` (r:1 w:0) + // Proof: `ParachainSystem::LastRelayChainBlockNumber` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + fn unbond() -> Weight { + // Proof Size summary in bytes: + // Measured: `1506` + // Estimated: `3606` + // Minimum execution time: 22_000 nanoseconds. + Weight::from_parts(22_000_000, 3606) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().writes(1)) + } + // Storage: `HomaValidatorList::Guarantees` (r:1 w:1) + // Proof: `HomaValidatorList::Guarantees` (`max_values`: None, `max_size`: Some(141), added: 2616, mode: `MaxEncodedLen`) + fn rebond() -> Weight { + // Proof Size summary in bytes: + // Measured: `1044` + // Estimated: `3606` + // Minimum execution time: 11_000 nanoseconds. + Weight::from_parts(11_000_000, 3606) + .saturating_add(RocksDbWeight::get().reads(1)) + .saturating_add(RocksDbWeight::get().writes(1)) + } + // Storage: `HomaValidatorList::ValidatorBackings` (r:1 w:1) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::Guarantees` (r:1 w:1) + // Proof: `HomaValidatorList::Guarantees` (`max_values`: None, `max_size`: Some(141), added: 2616, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::ValidationData` (r:1 w:0) + // Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `HomaValidatorList::TotalLockedByGuarantor` (r:1 w:1) + // Proof: `HomaValidatorList::TotalLockedByGuarantor` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + fn withdraw_unbonded() -> Weight { + // Proof Size summary in bytes: + // Measured: `2312` + // Estimated: `4765` + // Minimum execution time: 49_000 nanoseconds. + Weight::from_parts(50_000_000, 4765) + .saturating_add(RocksDbWeight::get().reads(6)) + .saturating_add(RocksDbWeight::get().writes(5)) + } + // Storage: `HomaValidatorList::ValidatorBackings` (r:10 w:10) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// The range of component `n` is `[1, 10]`. + fn freeze(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1235 + n * (71 ±0)` + // Estimated: `990 + n * (2540 ±0)` + // Minimum execution time: 17_000 nanoseconds. + Weight::from_parts(12_956_759, 990) + // Standard Error: 11_087 + .saturating_add(Weight::from_parts(5_475_545, 0).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 2540).saturating_mul(n.into())) + } + // Storage: `HomaValidatorList::ValidatorBackings` (r:10 w:10) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// The range of component `n` is `[1, 10]`. + fn thaw(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1235 + n * (71 ±0)` + // Estimated: `990 + n * (2540 ±0)` + // Minimum execution time: 17_000 nanoseconds. + Weight::from_parts(13_302_017, 990) + // Standard Error: 13_600 + .saturating_add(Weight::from_parts(5_468_920, 0).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 2540).saturating_mul(n.into())) + } + // Storage: `Homa::TotalStakingBonded` (r:1 w:0) + // Proof: `Homa::TotalStakingBonded` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `Homa::ToBondPool` (r:1 w:0) + // Proof: `Homa::ToBondPool` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `Tokens::TotalIssuance` (r:1 w:1) + // Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + // Storage: `Homa::TotalVoidLiquid` (r:1 w:0) + // Proof: `Homa::TotalVoidLiquid` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `HomaValidatorList::ValidatorBackings` (r:10 w:10) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::Guarantees` (r:20 w:10) + // Proof: `HomaValidatorList::Guarantees` (`max_values`: None, `max_size`: Some(141), added: 2616, mode: `MaxEncodedLen`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::TotalLockedByGuarantor` (r:1 w:1) + // Proof: `HomaValidatorList::TotalLockedByGuarantor` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + /// The range of component `n` is `[1, 10]`. + fn slash(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2834 + n * (200 ±0)` + // Estimated: `4765 + n * (5232 ±0)` + // Minimum execution time: 73_000 nanoseconds. + Weight::from_parts(37_933_640, 4765) + // Standard Error: 120_845 + .saturating_add(Weight::from_parts(41_000_469, 0).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(7)) + .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(n.into()))) + .saturating_add(RocksDbWeight::get().writes(4)) + .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 5232).saturating_mul(n.into())) + } +} diff --git a/modules/homa/src/lib.rs b/modules/homa/src/lib.rs index 819c78e4c5..ccba0cb274 100644 --- a/modules/homa/src/lib.rs +++ b/modules/homa/src/lib.rs @@ -23,7 +23,9 @@ use frame_support::{pallet_prelude::*, transactional, PalletId}; use frame_system::{ensure_signed, pallet_prelude::*}; -use module_support::{ExchangeRate, ExchangeRateProvider, FractionalRate, HomaManager, HomaSubAccountXcm, Rate, Ratio}; +use module_support::{ + ExchangeRate, ExchangeRateProvider, FractionalRate, HomaManager, HomaSubAccountXcm, NomineesProvider, Rate, Ratio, +}; use orml_traits::MultiCurrency; use primitives::{Balance, CurrencyId, EraIndex}; use scale_info::TypeInfo; @@ -47,6 +49,11 @@ pub mod weights; pub mod module { use super::*; + pub type RelayChainAccountIdOf = <::XcmInterface as HomaSubAccountXcm< + ::AccountId, + Balance, + >>::RelayChainAccountId; + /// The subaccount's staking ledger which kept by Homa protocol #[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo, Default)] pub struct StakingLedger { @@ -151,6 +158,8 @@ pub mod module { /// Weight information for the extrinsics in this module. type WeightInfo: WeightInfo; + + type NominationsProvider: NomineesProvider>; } #[pallet::error] @@ -241,6 +250,19 @@ pub mod module { LastEraBumpedBlockUpdated { last_era_bumped_block: BlockNumberFor }, /// The frequency to bump era has been updated. BumpEraFrequencyUpdated { frequency: BlockNumberFor }, + /// The interval eras to nominate. + NominateIntervalEraUpdated { eras: EraIndex }, + /// Withdraw unbonded from RelayChain + HomaWithdrawUnbonded { sub_account_index: u16, amount: Balance }, + /// Unbond staking currency of sub account on RelayChain + HomaUnbond { sub_account_index: u16, amount: Balance }, + /// Transfer staking currency to sub account and bond on RelayChain + HomaBondExtra { sub_account_index: u16, amount: Balance }, + /// Nominate validators on RelayChain + HomaNominate { + sub_account_index: u16, + nominations: Vec>, + }, } /// The current era of relaychain @@ -250,13 +272,6 @@ pub mod module { #[pallet::getter(fn relay_chain_current_era)] pub type RelayChainCurrentEra = StorageValue<_, EraIndex, ValueQuery>; - // /// The latest processed era of Homa, it should be always <= RelayChainCurrentEra - // /// - // /// ProcessedEra : EraIndex - // #[pallet::storage] - // #[pallet::getter(fn processed_era)] - // pub type ProcessedEra = StorageValue<_, EraIndex, ValueQuery>; - /// The staking ledger of Homa subaccounts. /// /// StakingLedgers map: u16 => Option @@ -345,13 +360,20 @@ pub mod module { #[pallet::getter(fn last_era_bumped_block)] pub type LastEraBumpedBlock = StorageValue<_, BlockNumberFor, ValueQuery>; - /// The internal of relaychain block number of relaychain to bump local current era. + /// The interval of relaychain block number of relaychain to bump local current era. /// /// LastEraBumpedRelayChainBlock: value: BlockNumberFor #[pallet::storage] #[pallet::getter(fn bump_era_frequency)] pub type BumpEraFrequency = StorageValue<_, BlockNumberFor, ValueQuery>; + /// The interval of eras to nominate on relaychain. + /// + /// NominateIntervalEra: value: EraIndex + #[pallet::storage] + #[pallet::getter(fn nominate_interval_era)] + pub type NominateIntervalEra = StorageValue<_, EraIndex, ValueQuery>; + #[pallet::pallet] #[pallet::without_storage_info] pub struct Pallet(_); @@ -489,6 +511,7 @@ pub mod module { estimated_reward_rate_per_era: Option, commission_rate: Option, fast_match_fee_rate: Option, + nominate_interval_era: Option, ) -> DispatchResult { T::GovernanceOrigin::ensure_origin(origin)?; @@ -516,6 +539,10 @@ pub mod module { })?; Self::deposit_event(Event::::FastMatchFeeRateUpdated { fast_match_fee_rate }); } + if let Some(interval) = nominate_interval_era { + NominateIntervalEra::::set(interval); + Self::deposit_event(Event::::NominateIntervalEraUpdated { eras: interval }); + } Ok(()) } @@ -971,6 +998,11 @@ pub mod module { Ok(()) })?; total_withdrawn_staking = total_withdrawn_staking.saturating_add(expired_unlocking); + + Self::deposit_event(Event::::HomaWithdrawUnbonded { + sub_account_index, + amount: expired_unlocking, + }); } } @@ -1018,6 +1050,11 @@ pub mod module { ledger.bonded = ledger.bonded.saturating_add(bond_amount); Ok(()) })?; + + Self::deposit_event(Event::::HomaBondExtra { + sub_account_index, + amount: bond_amount, + }); } } @@ -1080,6 +1117,11 @@ pub mod module { }); Ok(()) })?; + + Self::deposit_event(Event::::HomaUnbond { + sub_account_index, + amount: unbond_amount, + }); } } @@ -1087,6 +1129,28 @@ pub mod module { Self::burn_liquid_currency(&Self::account_id(), total_redeem_amount) } + /// Process nominate validators for subaccounts on relaychain. + pub fn process_nominate(new_era: EraIndex) -> DispatchResult { + // check whether need to nominate + let nominate_interval_era = NominateIntervalEra::::get(); + if !nominate_interval_era.is_zero() && new_era % nominate_interval_era == 0 { + for (sub_account_index, nominations) in + T::NominationsProvider::nominees_in_groups(T::ActiveSubAccountsIndexList::get()) + { + if !nominations.is_empty() { + T::XcmInterface::nominate_on_sub_account(sub_account_index, nominations.clone())?; + + Self::deposit_event(Event::::HomaNominate { + sub_account_index, + nominations, + }); + } + } + } + + Ok(()) + } + pub fn era_amount_should_to_bump(relaychain_block_number: BlockNumberFor) -> EraIndex { relaychain_block_number .checked_sub(&Self::last_era_bumped_block()) @@ -1113,6 +1177,7 @@ pub mod module { Self::process_scheduled_unbond(new_era)?; Self::process_to_bond_pool()?; Self::process_redeem_requests(new_era)?; + Self::process_nominate(new_era)?; Ok(()) }(); @@ -1141,11 +1206,17 @@ pub mod module { T::Currency::deposit(T::StakingCurrencyId::get(), who, amount) } } +} - impl ExchangeRateProvider for Pallet { - fn get_exchange_rate() -> ExchangeRate { - Self::current_exchange_rate() - } +impl ExchangeRateProvider for Pallet { + fn get_exchange_rate() -> ExchangeRate { + Self::current_exchange_rate() + } +} + +impl Get for Pallet { + fn get() -> EraIndex { + Self::relay_chain_current_era() } } diff --git a/modules/homa/src/mock.rs b/modules/homa/src/mock.rs index 9ecabe4db4..d34c9f070a 100644 --- a/modules/homa/src/mock.rs +++ b/modules/homa/src/mock.rs @@ -48,10 +48,16 @@ pub const HOMA_TREASURY: AccountId = AccountId32::new([255u8; 32]); pub const NATIVE_CURRENCY_ID: CurrencyId = CurrencyId::Token(TokenSymbol::ACA); pub const STAKING_CURRENCY_ID: CurrencyId = CurrencyId::Token(TokenSymbol::DOT); pub const LIQUID_CURRENCY_ID: CurrencyId = CurrencyId::Token(TokenSymbol::LDOT); +pub const VALIDATOR_A: AccountId = AccountId32::new([200u8; 32]); +pub const VALIDATOR_B: AccountId = AccountId32::new([201u8; 32]); +pub const VALIDATOR_C: AccountId = AccountId32::new([202u8; 32]); +pub const VALIDATOR_D: AccountId = AccountId32::new([203u8; 32]); /// mock XCM transfer. pub struct MockHomaSubAccountXcm; impl HomaSubAccountXcm for MockHomaSubAccountXcm { + type RelayChainAccountId = AccountId; + fn transfer_staking_to_sub_account(sender: &AccountId, _: u16, amount: Balance) -> DispatchResult { Currencies::withdraw(StakingCurrencyId::get(), sender, amount) } @@ -68,6 +74,10 @@ impl HomaSubAccountXcm for MockHomaSubAccountXcm { Ok(()) } + fn nominate_on_sub_account(_: u16, _: Vec) -> DispatchResult { + Ok(()) + } + fn get_xcm_transfer_fee() -> Balance { 1_000_000 } @@ -167,6 +177,28 @@ parameter_types! { pub static MockRelayBlockNumberProvider: BlockNumber = 0; } +pub struct MockNominationsProvider; +impl NomineesProvider for MockNominationsProvider { + fn nominees() -> Vec { + unimplemented!() + } + + fn nominees_in_groups(group_index_list: Vec) -> Vec<(u16, Vec)> { + group_index_list + .iter() + .map(|group_index| { + let nominees: Vec = match *group_index { + 0 => vec![VALIDATOR_A, VALIDATOR_B], + 2 => vec![VALIDATOR_A, VALIDATOR_C], + 3 => vec![VALIDATOR_D], + _ => vec![], + }; + (*group_index, nominees) + }) + .collect() + } +} + impl Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Currencies; @@ -183,6 +215,7 @@ impl Config for Runtime { type RelayChainBlockNumber = MockRelayBlockNumberProvider; type XcmInterface = MockHomaSubAccountXcm; type WeightInfo = (); + type NominationsProvider = MockNominationsProvider; } type Block = frame_system::mocking::MockBlock; diff --git a/modules/homa/src/tests.rs b/modules/homa/src/tests.rs index dfaac614aa..d09b969527 100644 --- a/modules/homa/src/tests.rs +++ b/modules/homa/src/tests.rs @@ -41,6 +41,7 @@ fn mint_works() { None, None, None, + None, )); MintThreshold::set(100_000); @@ -92,6 +93,7 @@ fn mint_works() { Some(Rate::saturating_from_rational(10, 100)), None, None, + None, )); assert_eq!(Currencies::free_balance(LIQUID_CURRENCY_ID, &BOB), 0); assert_eq!(Currencies::free_balance(STAKING_CURRENCY_ID, &BOB), 1_000_000); @@ -252,7 +254,7 @@ fn claim_redemption_works() { fn update_homa_params_works() { ExtBuilder::default().build().execute_with(|| { assert_noop!( - Homa::update_homa_params(RuntimeOrigin::signed(ALICE), None, None, None, None), + Homa::update_homa_params(RuntimeOrigin::signed(ALICE), None, None, None, None, None), BadOrigin ); @@ -260,6 +262,7 @@ fn update_homa_params_works() { assert_eq!(Homa::estimated_reward_rate_per_era(), Rate::zero()); assert_eq!(Homa::commission_rate(), Rate::zero()); assert_eq!(Homa::fast_match_fee_rate(), Rate::zero()); + assert_eq!(Homa::nominate_interval_era(), 0); assert_ok!(Homa::update_homa_params( RuntimeOrigin::signed(HomaAdmin::get()), @@ -267,6 +270,7 @@ fn update_homa_params_works() { Some(Rate::saturating_from_rational(1, 10000)), Some(Rate::saturating_from_rational(5, 100)), Some(Rate::saturating_from_rational(1, 100)), + Some(1), )); System::assert_has_event(RuntimeEvent::Homa(crate::Event::SoftBondedCapPerSubAccountUpdated { cap_amount: 1_000_000_000, @@ -280,6 +284,7 @@ fn update_homa_params_works() { System::assert_has_event(RuntimeEvent::Homa(crate::Event::FastMatchFeeRateUpdated { fast_match_fee_rate: Rate::saturating_from_rational(1, 100), })); + System::assert_has_event(RuntimeEvent::Homa(crate::Event::NominateIntervalEraUpdated { eras: 1 })); assert_eq!(Homa::soft_bonded_cap_per_sub_account(), 1_000_000_000); assert_eq!( Homa::estimated_reward_rate_per_era(), @@ -287,6 +292,7 @@ fn update_homa_params_works() { ); assert_eq!(Homa::commission_rate(), Rate::saturating_from_rational(5, 100)); assert_eq!(Homa::fast_match_fee_rate(), Rate::saturating_from_rational(1, 100)); + assert_eq!(Homa::nominate_interval_era(), 1); }); } @@ -579,6 +585,7 @@ fn do_fast_match_redeem_works() { None, None, Some(Rate::saturating_from_rational(1, 10)), + None, )); RedeemThreshold::set(1_000_000); assert_ok!(Homa::mint(RuntimeOrigin::signed(CHARLIE), 1_000_000)); @@ -689,6 +696,7 @@ fn process_staking_rewards_works() { Some(Rate::saturating_from_rational(20, 100)), None, None, + None, )); assert_eq!( Homa::staking_ledgers(0), @@ -734,6 +742,7 @@ fn process_staking_rewards_works() { None, Some(Rate::saturating_from_rational(10, 100)), None, + None, )); // accumulate staking rewards, will draw commission to TreasuryAccount @@ -834,6 +843,14 @@ fn process_scheduled_unbond_works() { assert_eq!(Currencies::free_balance(STAKING_CURRENCY_ID, &Homa::account_id()), 0); assert_ok!(Homa::process_scheduled_unbond(13)); + System::assert_has_event(RuntimeEvent::Homa(crate::Event::HomaWithdrawUnbonded { + sub_account_index: 0, + amount: 1_000_000, + })); + System::assert_has_event(RuntimeEvent::Homa(crate::Event::HomaWithdrawUnbonded { + sub_account_index: 1, + amount: 300_000, + })); assert_eq!( Homa::staking_ledgers(0), Some(StakingLedger { @@ -866,6 +883,7 @@ fn process_to_bond_pool_works() { None, None, None, + None, )); assert_ok!(Homa::reset_ledgers( RuntimeOrigin::signed(HomaAdmin::get()), @@ -941,6 +959,14 @@ fn process_to_bond_pool_works() { 6_000_000 ); assert_ok!(Homa::process_to_bond_pool()); + System::assert_has_event(RuntimeEvent::Homa(crate::Event::HomaBondExtra { + sub_account_index: 1, + amount: 3_000_000, + })); + System::assert_has_event(RuntimeEvent::Homa(crate::Event::HomaBondExtra { + sub_account_index: 2, + amount: 1_000_000, + })); assert_eq!( Homa::staking_ledgers(0), Some(StakingLedger { @@ -1038,6 +1064,10 @@ fn process_redeem_requests_works() { liquid_amount: 20_000_000, unbonding_staking_amount: 2_000_000, })); + System::assert_has_event(RuntimeEvent::Homa(crate::Event::HomaUnbond { + sub_account_index: 1, + amount: 2_000_000, + })); assert_eq!(Homa::redeem_requests(&ALICE), None); assert_eq!(Homa::unbondings(&ALICE, 1 + BondingDuration::get()), 2_000_000); assert_eq!(Homa::get_total_bonded(), 3_000_000); @@ -1089,6 +1119,14 @@ fn process_redeem_requests_works() { liquid_amount: 10_000_000, unbonding_staking_amount: 1_000_000, })); + System::assert_has_event(RuntimeEvent::Homa(crate::Event::HomaUnbond { + sub_account_index: 0, + amount: 2_000_000, + })); + System::assert_has_event(RuntimeEvent::Homa(crate::Event::HomaUnbond { + sub_account_index: 1, + amount: 1_000_000, + })); assert_eq!(Homa::redeem_requests(&BOB), None); assert_eq!(Homa::redeem_requests(&CHARLIE), None); assert_eq!(Homa::redeem_requests(&DAVE), Some((10_000_000, false))); @@ -1130,6 +1168,35 @@ fn process_redeem_requests_works() { }); } +#[test] +fn process_nominate_works() { + ExtBuilder::default().build().execute_with(|| { + assert_eq!(Homa::nominate_interval_era(), 0); + + // will not nominate + assert_ok!(Homa::process_nominate(1)); + assert_eq!(System::events(), vec![]); + + NominateIntervalEra::::put(4); + + // will not nominate + assert_ok!(Homa::process_nominate(2)); + assert_ok!(Homa::process_nominate(3)); + assert_eq!(System::events(), vec![]); + + assert_ok!(Homa::process_nominate(4)); + System::assert_has_event(RuntimeEvent::Homa(crate::Event::HomaNominate { + sub_account_index: 0, + nominations: vec![VALIDATOR_A, VALIDATOR_B], + })); + System::assert_has_event(RuntimeEvent::Homa(crate::Event::HomaNominate { + sub_account_index: 2, + nominations: vec![VALIDATOR_A, VALIDATOR_C], + })); + // will not nominate for subaccount#1 because doesn't get nominations + }); +} + #[test] fn era_amount_should_to_bump_works() { ExtBuilder::default().build().execute_with(|| { @@ -1177,6 +1244,7 @@ fn bump_current_era_works() { Some(Rate::saturating_from_rational(1, 100)), Some(Rate::saturating_from_rational(20, 100)), None, + None, )); MintThreshold::set(2_000_000); @@ -1277,6 +1345,7 @@ fn bump_current_era_works() { Some(Rate::zero()), None, None, + None, )); // and there's redeem request diff --git a/modules/incentives/src/lib.rs b/modules/incentives/src/lib.rs index 9bc117943b..b7a90da498 100644 --- a/modules/incentives/src/lib.rs +++ b/modules/incentives/src/lib.rs @@ -23,7 +23,7 @@ //! Acala platform need support different types of rewards for some other protocol. //! Each Pool has its own multi currencies rewards and reward accumulation //! mechanism. ORML rewards module records the total shares, total multi currencies rewards anduser -//! shares of specific pool. Incentives module provides hooks to other protocals to manage shares, +//! shares of specific pool. Incentives module provides hooks to other protocols to manage shares, //! accumulates rewards and distributes rewards to users based on their shares. //! //! Pool types: @@ -255,7 +255,7 @@ pub mod module { Ok(()) } - /// Claim all avalible multi currencies rewards for specific PoolId. + /// Claim all available multi currencies rewards for specific PoolId. /// /// The dispatch origin of this call must be `Signed` by the transactor. /// @@ -617,3 +617,17 @@ impl Handler<(T::AccountId, Balance)> for OnEarningUnbonded { >::remove_share(who, &PoolId::Earning(T::NativeCurrencyId::get()), *amount) } } + +pub struct OnNomineesElectionBonded(sp_std::marker::PhantomData); +impl Handler<(T::AccountId, Balance)> for OnNomineesElectionBonded { + fn handle((who, amount): &(T::AccountId, Balance)) -> DispatchResult { + >::add_share(who, &PoolId::NomineesElection, *amount) + } +} + +pub struct OnNomineesElectionUnbonded(sp_std::marker::PhantomData); +impl Handler<(T::AccountId, Balance)> for OnNomineesElectionUnbonded { + fn handle((who, amount): &(T::AccountId, Balance)) -> DispatchResult { + >::remove_share(who, &PoolId::NomineesElection, *amount) + } +} diff --git a/modules/incentives/src/tests.rs b/modules/incentives/src/tests.rs index c95fe29fbb..d80d2c566d 100644 --- a/modules/incentives/src/tests.rs +++ b/modules/incentives/src/tests.rs @@ -1338,3 +1338,44 @@ fn claim_reward_deduction_currency_works() { assert_eq!(TokensModule::free_balance(AUSD, &ALICE::get()), 1900); }); } + +#[test] +fn nominees_election_should_work() { + ExtBuilder::default().build().execute_with(|| { + assert_ok!(OnNomineesElectionBonded::::handle(&(ALICE::get(), 80))); + assert_eq!( + RewardsModule::pool_infos(PoolId::NomineesElection), + PoolInfo { + total_shares: 80, + ..Default::default() + } + ); + assert_eq!( + RewardsModule::shares_and_withdrawn_rewards(PoolId::NomineesElection, ALICE::get()), + (80, Default::default()) + ); + + assert_ok!(OnNomineesElectionUnbonded::::handle(&(ALICE::get(), 20))); + assert_eq!( + RewardsModule::pool_infos(PoolId::NomineesElection), + PoolInfo { + total_shares: 60, + ..Default::default() + } + ); + assert_eq!( + RewardsModule::shares_and_withdrawn_rewards(PoolId::NomineesElection, ALICE::get()), + (60, Default::default()) + ); + + assert_ok!(OnNomineesElectionUnbonded::::handle(&(ALICE::get(), 60))); + assert_eq!( + RewardsModule::pool_infos(PoolId::NomineesElection), + PoolInfo { ..Default::default() } + ); + assert_eq!( + RewardsModule::shares_and_withdrawn_rewards(PoolId::NomineesElection, ALICE::get()), + (0, Default::default()) + ); + }); +} diff --git a/modules/nominees-election/src/lib.rs b/modules/nominees-election/src/lib.rs index f589a33da3..af6d087ab2 100644 --- a/modules/nominees-election/src/lib.rs +++ b/modules/nominees-election/src/lib.rs @@ -18,6 +18,7 @@ #![cfg_attr(not(feature = "std"), no_std)] #![allow(clippy::unused_unit)] +#![allow(clippy::type_complexity)] use frame_support::{ pallet_prelude::*, @@ -25,16 +26,13 @@ use frame_support::{ BoundedVec, }; use frame_system::pallet_prelude::*; -use module_support::{NomineesProvider, OnNewEra}; -use orml_traits::{BasicCurrency, BasicLockableCurrency}; +use module_support::NomineesProvider; +use orml_traits::{BasicCurrency, BasicLockableCurrency, Handler}; use primitives::{ bonding::{self, BondingController}, Balance, EraIndex, }; -use sp_runtime::{ - traits::{MaybeDisplay, MaybeSerializeDeserialize, Member, Zero}, - SaturatedConversion, -}; +use sp_runtime::traits::{MaybeDisplay, MaybeSerializeDeserialize, Member, Zero}; use sp_std::{fmt::Debug, prelude::*}; mod mock; @@ -50,21 +48,50 @@ pub mod module { #[pallet::config] pub trait Config: frame_system::Config { + /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; + + /// The token as vote. type Currency: BasicLockableCurrency, Balance = Balance>; + + /// Nominee ID type NomineeId: Parameter + Member + MaybeSerializeDeserialize + Debug + MaybeDisplay + Ord; + + /// LockIdentifier for lock vote token. #[pallet::constant] type PalletId: Get; + + /// The minimum amount of tokens that can be bonded. #[pallet::constant] type MinBond: Get; + + /// The waiting eras when unbond token. #[pallet::constant] type BondingDuration: Get; + + /// The maximum number of nominees when voted and picked up. #[pallet::constant] - type NominateesCount: Get; + type MaxNominateesCount: Get; + + /// The maximum number of simultaneous unbonding chunks that can exist. #[pallet::constant] type MaxUnbondingChunks: Get; + + /// The valid nominee filter. type NomineeFilter: Contains; - /// Weight information for the extrinsics in this module. + + /// Origin represented Governance + type GovernanceOrigin: EnsureOrigin; + + /// Callback when an account bonded. + type OnBonded: Handler<(Self::AccountId, Balance)>; + + /// Callback when an account unbonded. + type OnUnbonded: Handler<(Self::AccountId, Balance)>; + + /// Current era. + type CurrentEra: Get; + type WeightInfo: WeightInfo; } @@ -83,7 +110,30 @@ pub mod module { #[pallet::event] #[pallet::generate_deposit(pub(crate) fn deposit_event)] pub enum Event, I: 'static = ()> { - Rebond { who: T::AccountId, amount: Balance }, + Bond { + who: T::AccountId, + amount: Balance, + }, + Unbond { + who: T::AccountId, + amount: Balance, + }, + Rebond { + who: T::AccountId, + amount: Balance, + }, + WithdrawUnbonded { + who: T::AccountId, + amount: Balance, + }, + Nominate { + who: T::AccountId, + targets: Vec, + }, + ResetReservedNominees { + group_index: u16, + reserved_nominees: Vec, + }, } /// The nominations for nominators. @@ -95,7 +145,7 @@ pub mod module { _, Twox64Concat, T::AccountId, - BoundedVec<>::NomineeId, T::NominateesCount>, + BoundedVec<>::NomineeId, T::MaxNominateesCount>, ValueQuery, >; @@ -115,20 +165,18 @@ pub mod module { pub type Votes, I: 'static = ()> = StorageMap<_, Twox64Concat, >::NomineeId, Balance, ValueQuery>; - /// The elected nominees. + /// Reserved nominees. /// - /// Nominees: Vec + /// ReservedNominees: map u16 => Vec #[pallet::storage] - #[pallet::getter(fn nominees)] - pub type Nominees, I: 'static = ()> = - StorageValue<_, BoundedVec<>::NomineeId, T::NominateesCount>, ValueQuery>; - - /// Current era index. - /// - /// CurrentEra: EraIndex - #[pallet::storage] - #[pallet::getter(fn current_era)] - pub type CurrentEra, I: 'static = ()> = StorageValue<_, EraIndex, ValueQuery>; + #[pallet::getter(fn reserved_nominees)] + pub type ReservedNominees, I: 'static = ()> = StorageMap< + _, + Blake2_128Concat, + u16, + BoundedVec<>::NomineeId, T::MaxNominateesCount>, + ValueQuery, + >; #[pallet::pallet] #[pallet::without_storage_info] @@ -150,6 +198,13 @@ pub mod module { let old_nominations = Self::nominations(&who); Self::update_votes(change.old, &old_nominations, change.new, &old_nominations); + + T::OnBonded::handle(&(who.clone(), change.change))?; + + Self::deposit_event(Event::Bond { + who, + amount: change.change, + }); } Ok(()) } @@ -159,13 +214,20 @@ pub mod module { pub fn unbond(origin: OriginFor, #[pallet::compact] amount: Balance) -> DispatchResult { let who = ensure_signed(origin)?; - let unbond_at = Self::current_era().saturating_add(T::BondingDuration::get()); + let unbond_at = T::CurrentEra::get().saturating_add(T::BondingDuration::get()); let change = ::unbond(&who, amount, unbond_at)?; if let Some(change) = change { let old_nominations = Self::nominations(&who); Self::update_votes(change.old, &old_nominations, change.new, &old_nominations); + + T::OnUnbonded::handle(&(who.clone(), change.change))?; + + Self::deposit_event(Event::Unbond { + who, + amount: change.change, + }); } Ok(()) @@ -182,6 +244,9 @@ pub mod module { let old_nominations = Self::nominations(&who); Self::update_votes(change.old, &old_nominations, change.new, &old_nominations); + + T::OnBonded::handle(&(who.clone(), change.change))?; + Self::deposit_event(Event::Rebond { who, amount: change.change, @@ -196,7 +261,14 @@ pub mod module { pub fn withdraw_unbonded(origin: OriginFor) -> DispatchResult { let who = ensure_signed(origin)?; - ::withdraw_unbonded(&who, Self::current_era())?; + let change = ::withdraw_unbonded(&who, T::CurrentEra::get())?; + + if let Some(change) = change { + Self::deposit_event(Event::WithdrawUnbonded { + who, + amount: change.change, + }); + } Ok(()) } @@ -208,7 +280,7 @@ pub mod module { let ledger = Self::ledger(&who).ok_or(Error::::NotBonded)?; - let bounded_targets: BoundedVec<>::NomineeId, >::NominateesCount> = { + let bounded_targets: BoundedVec<>::NomineeId, >::MaxNominateesCount> = { if targets.is_empty() { Err(Error::::InvalidTargetsLength) } else { @@ -232,11 +304,16 @@ pub mod module { Self::update_votes(old_active, &old_nominations, old_active, &bounded_targets); Nominations::::insert(&who, &bounded_targets); + + Self::deposit_event(Event::Nominate { + who, + targets: bounded_targets.to_vec(), + }); Ok(()) } #[pallet::call_index(5)] - #[pallet::weight(T::WeightInfo::chill(T::NominateesCount::get()))] + #[pallet::weight(T::WeightInfo::chill(T::MaxNominateesCount::get()))] pub fn chill(origin: OriginFor) -> DispatchResult { let who = ensure_signed(origin)?; @@ -248,6 +325,33 @@ pub mod module { Self::update_votes(old_active, &old_nominations, Zero::zero(), &[]); Nominations::::remove(&who); + Self::deposit_event(Event::Nominate { who, targets: vec![] }); + Ok(()) + } + + #[pallet::call_index(6)] + #[pallet::weight(T::WeightInfo::reset_reserved_nominees(updates.len() as u32))] + pub fn reset_reserved_nominees( + origin: OriginFor, + updates: Vec<(u16, BoundedVec)>, + ) -> DispatchResult { + T::GovernanceOrigin::ensure_origin(origin)?; + for (group_index, reserved_nominees) in updates { + let mut reserved_nominees: Vec = reserved_nominees.to_vec(); + reserved_nominees.sort(); + reserved_nominees.dedup(); + + let reserved: BoundedVec = reserved_nominees + .clone() + .try_into() + .expect("the length has been checked in params; qed"); + ReservedNominees::::insert(group_index, reserved); + + Self::deposit_event(Event::ResetReservedNominees { + group_index, + reserved_nominees, + }); + } Ok(()) } } @@ -273,33 +377,68 @@ impl, I: 'static> Pallet { } } - fn rebalance() { - let mut voters = Votes::::iter().collect::>(); + fn sort_voted_nominees() -> Vec { + let mut voters = Votes::::iter() + .filter(|(id, _)| T::NomineeFilter::contains(id)) + .collect::>(); voters.sort_by(|a, b| b.1.cmp(&a.1)); - let new_nominees: BoundedVec<>::NomineeId, >::NominateesCount> = voters - .into_iter() - .take(T::NominateesCount::get().saturated_into()) - .map(|(nominee, _)| nominee) - .collect::>() - .try_into() - .expect("Only took from voters"); - - Nominees::::put(new_nominees); + voters + .iter() + .map(|(nomination, _)| nomination.clone()) + .collect::>() } } impl, I: 'static> NomineesProvider for Pallet { fn nominees() -> Vec { - Nominees::::get().into_inner() + let mut sorted_voted_nominees = Self::sort_voted_nominees(); + sorted_voted_nominees.truncate(T::MaxNominateesCount::get() as usize); + sorted_voted_nominees } -} -impl, I: 'static> OnNewEra for Pallet { - fn on_new_era(era: EraIndex) { - CurrentEra::::put(era); - Self::rebalance(); + fn nominees_in_groups(group_index_list: Vec) -> Vec<(u16, Vec)> { + let mut nominees_in_groups = group_index_list + .into_iter() + .map(|group_index| (group_index, ReservedNominees::::get(group_index).to_vec())) + .collect::)>>(); + + let max_nominatees_count = T::MaxNominateesCount::get() as usize; + + for nominee in Self::sort_voted_nominees() { + if nominees_in_groups + .iter() + .all(|(_, nominees)| nominees.len() == max_nominatees_count) + { + break; + } + + let mut distribute_index: Option<(usize, usize)> = None; + + // distribute nominee to the group that does not contain nominee and has the shortest length + for (index, (_, nominees)) in nominees_in_groups.iter().enumerate() { + if !nominees.contains(&nominee) && nominees.len() < max_nominatees_count { + match distribute_index { + Some((_, len)) => { + if nominees.len() < len { + distribute_index = Some((index, nominees.len())); + } + } + None => { + distribute_index = Some((index, nominees.len())); + } + } + } + } + + // insert nominee to groups + if let Some((index, _)) = distribute_index { + nominees_in_groups[index].1.push(nominee); + } + } + + nominees_in_groups } } diff --git a/modules/nominees-election/src/mock.rs b/modules/nominees-election/src/mock.rs index b1c71a8adb..1e4f7ee6ac 100644 --- a/modules/nominees-election/src/mock.rs +++ b/modules/nominees-election/src/mock.rs @@ -27,15 +27,32 @@ use frame_support::{ construct_runtime, derive_impl, ord_parameter_types, parameter_types, traits::{ConstU128, ConstU32, Nothing}, }; +use frame_system::EnsureRoot; use orml_traits::parameter_type_with_key; use primitives::{Amount, CurrencyId, TokenSymbol}; use sp_runtime::{traits::IdentityLookup, BuildStorage}; +use std::collections::HashMap; pub type AccountId = u128; pub type BlockNumber = u64; pub const ALICE: AccountId = 0; pub const BOB: AccountId = 1; +pub const CHARLIE: AccountId = 2; +pub const DAVE: AccountId = 3; +pub const EVE: AccountId = 4; +pub const NOMINATEE_1: AccountId = 10; +pub const NOMINATEE_2: AccountId = 11; +pub const NOMINATEE_3: AccountId = 12; +pub const NOMINATEE_4: AccountId = 13; +pub const NOMINATEE_5: AccountId = 14; +pub const NOMINATEE_6: AccountId = 15; +pub const NOMINATEE_7: AccountId = 16; +pub const NOMINATEE_8: AccountId = 17; +pub const NOMINATEE_9: AccountId = 18; +pub const NOMINATEE_10: AccountId = 19; +pub const NOMINATEE_11: AccountId = 20; +pub const NOMINATEE_12: AccountId = 21; pub const ACA: CurrencyId = CurrencyId::Token(TokenSymbol::ACA); pub const LDOT: CurrencyId = CurrencyId::Token(TokenSymbol::LDOT); @@ -106,10 +123,51 @@ parameter_types! { pub const PalletId: LockIdentifier = *b"1 "; } -pub struct MockNomineeFilter; -impl Contains for MockNomineeFilter { +parameter_types! { + pub static Shares: HashMap = HashMap::new(); + pub static InvalidNominees: Vec = vec![]; + pub static MockCurrentEra: EraIndex = 0; +} + +pub struct MockOnBonded; +impl Handler<(AccountId, Balance)> for MockOnBonded { + fn handle(info: &(AccountId, Balance)) -> DispatchResult { + let (account_id, amount) = info; + Shares::mutate(|v| { + let mut old_map = v.clone(); + if let Some(share) = old_map.get_mut(account_id) { + *share = share.saturating_add(*amount); + } else { + old_map.insert(*account_id, *amount); + }; + + *v = old_map; + }); + Ok(()) + } +} + +pub struct MockOnUnbonded; +impl Handler<(AccountId, Balance)> for MockOnUnbonded { + fn handle(info: &(AccountId, Balance)) -> DispatchResult { + let (account_id, amount) = info; + Shares::mutate(|v| { + let mut old_map = v.clone(); + if let Some(share) = old_map.get_mut(account_id) { + *share = share.saturating_sub(*amount); + } else { + old_map.insert(*account_id, Default::default()); + }; + + *v = old_map; + }); + Ok(()) + } +} + +impl Contains for InvalidNominees { fn contains(a: &AccountId) -> bool { - (0..=6).contains(a) + !Self::get().contains(a) } } @@ -120,9 +178,13 @@ impl Config for Runtime { type PalletId = PalletId; type MinBond = ConstU128<5>; type BondingDuration = ConstU32<4>; - type NominateesCount = ConstU32<5>; + type MaxNominateesCount = ConstU32<5>; type MaxUnbondingChunks = ConstU32<3>; - type NomineeFilter = MockNomineeFilter; + type NomineeFilter = InvalidNominees; + type GovernanceOrigin = EnsureRoot; + type OnBonded = MockOnBonded; + type OnUnbonded = MockOnUnbonded; + type CurrentEra = MockCurrentEra; type WeightInfo = (); } @@ -145,7 +207,13 @@ pub struct ExtBuilder { impl Default for ExtBuilder { fn default() -> Self { Self { - balances: vec![(ALICE, LDOT, 1000), (BOB, LDOT, 1000)], + balances: vec![ + (ALICE, LDOT, 1000), + (BOB, LDOT, 1000), + (CHARLIE, LDOT, 1000), + (DAVE, LDOT, 1000), + (EVE, LDOT, 1000), + ], } } } @@ -162,6 +230,10 @@ impl ExtBuilder { .assimilate_storage(&mut t) .unwrap(); - t.into() + let mut ext = sp_io::TestExternalities::new(t); + ext.execute_with(|| { + System::set_block_number(1); + }); + ext } } diff --git a/modules/nominees-election/src/tests.rs b/modules/nominees-election/src/tests.rs index eea82117f6..4e9fcc6f3a 100644 --- a/modules/nominees-election/src/tests.rs +++ b/modules/nominees-election/src/tests.rs @@ -23,6 +23,7 @@ use super::*; use frame_support::{assert_noop, assert_ok}; use mock::*; +use sp_runtime::traits::BadOrigin; #[test] fn bond_below_min_bond_threshold() { @@ -37,20 +38,32 @@ fn bond_below_min_bond_threshold() { #[test] fn bond_work() { ExtBuilder::default().build().execute_with(|| { + assert_eq!(SHARES.with(|v| *v.borrow().get(&ALICE).unwrap_or(&0)), 0); + assert_eq!(TokensModule::accounts(&ALICE, LDOT).frozen, 0); + assert_eq!(NomineesElectionModule::ledger(&ALICE), None); assert_ok!(NomineesElectionModule::bond(RuntimeOrigin::signed(ALICE), 50)); + System::assert_has_event(mock::RuntimeEvent::NomineesElectionModule(crate::Event::Bond { + who: ALICE, + amount: 50, + })); assert_eq!(TokensModule::accounts(&ALICE, LDOT).frozen, 50); assert_eq!(NomineesElectionModule::ledger(&ALICE).unwrap().total(), 50); assert_eq!(NomineesElectionModule::ledger(&ALICE).unwrap().active(), 50); - }); -} + assert_eq!(SHARES.with(|v| *v.borrow().get(&ALICE).unwrap_or(&0)), 50); -#[test] -fn bond_amount_over_remain_free() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(NomineesElectionModule::bond(RuntimeOrigin::signed(ALICE), 2000)); - assert_eq!(TokensModule::accounts(&ALICE, LDOT).frozen, 1000); - assert_eq!(NomineesElectionModule::ledger(&ALICE).unwrap().total(), 1000); - assert_eq!(NomineesElectionModule::ledger(&ALICE).unwrap().active(), 1000); + // bond amount over remain free + assert_eq!(SHARES.with(|v| *v.borrow().get(&BOB).unwrap_or(&0)), 0); + assert_eq!(TokensModule::accounts(&BOB, LDOT).frozen, 0); + assert_eq!(NomineesElectionModule::ledger(&BOB), None); + assert_ok!(NomineesElectionModule::bond(RuntimeOrigin::signed(BOB), 2000)); + System::assert_has_event(mock::RuntimeEvent::NomineesElectionModule(crate::Event::Bond { + who: BOB, + amount: 1000, + })); + assert_eq!(TokensModule::accounts(&BOB, LDOT).frozen, 1000); + assert_eq!(NomineesElectionModule::ledger(&BOB).unwrap().total(), 1000); + assert_eq!(NomineesElectionModule::ledger(&BOB).unwrap().active(), 1000); + assert_eq!(SHARES.with(|v| *v.borrow().get(&BOB).unwrap_or(&0)), 1000); }); } @@ -58,15 +71,37 @@ fn bond_amount_over_remain_free() { fn unbond_work() { ExtBuilder::default().build().execute_with(|| { assert_ok!(NomineesElectionModule::bond(RuntimeOrigin::signed(ALICE), 200)); + assert_eq!(SHARES.with(|v| *v.borrow().get(&ALICE).unwrap_or(&0)), 200); + assert_eq!(NomineesElectionModule::ledger(&ALICE).unwrap().total(), 200); + assert_eq!(NomineesElectionModule::ledger(&ALICE).unwrap().active(), 200); + assert_eq!(TokensModule::accounts(&ALICE, LDOT).frozen, 200); + assert_ok!(NomineesElectionModule::unbond(RuntimeOrigin::signed(ALICE), 100)); + System::assert_has_event(mock::RuntimeEvent::NomineesElectionModule(crate::Event::Unbond { + who: ALICE, + amount: 100, + })); + assert_eq!(SHARES.with(|v| *v.borrow().get(&ALICE).unwrap_or(&0)), 100); assert_eq!(NomineesElectionModule::ledger(&ALICE).unwrap().total(), 200); assert_eq!(NomineesElectionModule::ledger(&ALICE).unwrap().active(), 100); assert_eq!(TokensModule::accounts(&ALICE, LDOT).frozen, 200); - NomineesElectionModule::on_new_era(4); + + MockCurrentEra::set(4); assert_ok!(NomineesElectionModule::withdraw_unbonded(RuntimeOrigin::signed(ALICE))); assert_eq!(NomineesElectionModule::ledger(&ALICE).unwrap().total(), 100); assert_eq!(NomineesElectionModule::ledger(&ALICE).unwrap().active(), 100); assert_eq!(TokensModule::accounts(&ALICE, LDOT).frozen, 100); + + // unbond amount over active + assert_ok!(NomineesElectionModule::unbond(RuntimeOrigin::signed(ALICE), 200)); + System::assert_has_event(mock::RuntimeEvent::NomineesElectionModule(crate::Event::Unbond { + who: ALICE, + amount: 100, + })); + assert_eq!(SHARES.with(|v| *v.borrow().get(&ALICE).unwrap_or(&0)), 0); + assert_eq!(NomineesElectionModule::ledger(&ALICE).unwrap().total(), 100); + assert_eq!(NomineesElectionModule::ledger(&ALICE).unwrap().active(), 0); + assert_eq!(TokensModule::accounts(&ALICE, LDOT).frozen, 100); }); } @@ -75,11 +110,11 @@ fn unbond_exceed_max_unlock_chunk() { ExtBuilder::default().build().execute_with(|| { assert_ok!(NomineesElectionModule::bond(RuntimeOrigin::signed(ALICE), 1000)); assert_ok!(NomineesElectionModule::unbond(RuntimeOrigin::signed(ALICE), 100)); - NomineesElectionModule::on_new_era(1); + MockCurrentEra::set(1); assert_ok!(NomineesElectionModule::unbond(RuntimeOrigin::signed(ALICE), 100)); - NomineesElectionModule::on_new_era(2); + MockCurrentEra::set(2); assert_ok!(NomineesElectionModule::unbond(RuntimeOrigin::signed(ALICE), 100)); - NomineesElectionModule::on_new_era(3); + MockCurrentEra::set(3); assert_noop!( NomineesElectionModule::unbond(RuntimeOrigin::signed(ALICE), 100), Error::::MaxUnlockChunksExceeded, @@ -87,21 +122,6 @@ fn unbond_exceed_max_unlock_chunk() { }); } -#[test] -fn unbond_amount_over_active() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(NomineesElectionModule::bond(RuntimeOrigin::signed(ALICE), 1000)); - assert_ok!(NomineesElectionModule::unbond(RuntimeOrigin::signed(ALICE), 1500)); - assert_eq!(NomineesElectionModule::ledger(&ALICE).unwrap().total(), 1000); - assert_eq!(NomineesElectionModule::ledger(&ALICE).unwrap().active(), 0); - assert_eq!(TokensModule::accounts(&ALICE, LDOT).frozen, 1000); - NomineesElectionModule::on_new_era(4); - assert_ok!(NomineesElectionModule::withdraw_unbonded(RuntimeOrigin::signed(ALICE))); - assert_eq!(TokensModule::accounts(&ALICE, LDOT).frozen, 0); - assert_eq!(TokensModule::accounts(&ALICE, LDOT).free, 1000); - }); -} - #[test] fn unbond_remain_below_threshold() { ExtBuilder::default().build().execute_with(|| { @@ -116,37 +136,41 @@ fn unbond_remain_below_threshold() { #[test] fn rebond_work() { ExtBuilder::default().build().execute_with(|| { - System::set_block_number(1); - assert_noop!( NomineesElectionModule::rebond(RuntimeOrigin::signed(ALICE), 100), Error::::NotBonded, ); assert_ok!(NomineesElectionModule::bond(RuntimeOrigin::signed(ALICE), 1000)); assert_ok!(NomineesElectionModule::unbond(RuntimeOrigin::signed(ALICE), 100)); - NomineesElectionModule::on_new_era(1); + MockCurrentEra::set(1); assert_ok!(NomineesElectionModule::unbond(RuntimeOrigin::signed(ALICE), 100)); - NomineesElectionModule::on_new_era(2); + MockCurrentEra::set(2); assert_ok!(NomineesElectionModule::unbond(RuntimeOrigin::signed(ALICE), 100)); - NomineesElectionModule::on_new_era(3); + MockCurrentEra::set(3); + assert_eq!(SHARES.with(|v| *v.borrow().get(&ALICE).unwrap_or(&0)), 700); assert_eq!(NomineesElectionModule::ledger(&ALICE).unwrap().total(), 1000); assert_eq!(NomineesElectionModule::ledger(&ALICE).unwrap().active(), 700); + assert_ok!(NomineesElectionModule::rebond(RuntimeOrigin::signed(ALICE), 150)); System::assert_last_event(mock::RuntimeEvent::NomineesElectionModule(crate::Event::Rebond { who: ALICE, amount: 150, })); - NomineesElectionModule::on_new_era(4); + assert_eq!(SHARES.with(|v| *v.borrow().get(&ALICE).unwrap_or(&0)), 850); + + MockCurrentEra::set(4); assert_ok!(NomineesElectionModule::withdraw_unbonded(RuntimeOrigin::signed(ALICE))); assert_eq!(NomineesElectionModule::ledger(&ALICE).unwrap().total(), 900); assert_eq!(NomineesElectionModule::ledger(&ALICE).unwrap().active(), 850); assert_eq!(TokensModule::accounts(&ALICE, LDOT).frozen, 900); + // rebond amount over unbonding assert_ok!(NomineesElectionModule::rebond(RuntimeOrigin::signed(ALICE), 200)); System::assert_last_event(mock::RuntimeEvent::NomineesElectionModule(crate::Event::Rebond { who: ALICE, amount: 50, })); + assert_eq!(SHARES.with(|v| *v.borrow().get(&ALICE).unwrap_or(&0)), 900); assert_eq!(NomineesElectionModule::ledger(&ALICE).unwrap().total(), 900); assert_eq!(NomineesElectionModule::ledger(&ALICE).unwrap().active(), 900); assert_eq!(TokensModule::accounts(&ALICE, LDOT).frozen, 900); @@ -156,17 +180,25 @@ fn rebond_work() { #[test] fn withdraw_unbonded_work() { ExtBuilder::default().build().execute_with(|| { - assert_eq!(NomineesElectionModule::current_era(), 0); + assert_eq!(MockCurrentEra::get(), 0); assert_ok!(NomineesElectionModule::bond(RuntimeOrigin::signed(ALICE), 1000)); assert_ok!(NomineesElectionModule::unbond(RuntimeOrigin::signed(ALICE), 100)); assert_eq!(NomineesElectionModule::ledger(&ALICE).unwrap().total(), 1000); - NomineesElectionModule::on_new_era(3); + + MockCurrentEra::set(3); assert_ok!(NomineesElectionModule::withdraw_unbonded(RuntimeOrigin::signed(ALICE))); assert_eq!(NomineesElectionModule::ledger(&ALICE).unwrap().total(), 1000); assert_eq!(NomineesElectionModule::ledger(&ALICE).unwrap().unlocking_len(), 1); assert_ok!(NomineesElectionModule::unbond(RuntimeOrigin::signed(ALICE), 100)); - NomineesElectionModule::on_new_era(4); + + MockCurrentEra::set(4); assert_ok!(NomineesElectionModule::withdraw_unbonded(RuntimeOrigin::signed(ALICE))); + System::assert_has_event(mock::RuntimeEvent::NomineesElectionModule( + crate::Event::WithdrawUnbonded { + who: ALICE, + amount: 100, + }, + )); assert_eq!(NomineesElectionModule::ledger(&ALICE).unwrap().total(), 900); }); } @@ -175,7 +207,7 @@ fn withdraw_unbonded_work() { fn nominate_work() { ExtBuilder::default().build().execute_with(|| { assert_noop!( - NomineesElectionModule::nominate(RuntimeOrigin::signed(ALICE), vec![1, 2, 3, 4, 5]), + NomineesElectionModule::nominate(RuntimeOrigin::signed(ALICE), vec![NOMINATEE_1]), Error::::NotBonded, ); @@ -186,26 +218,67 @@ fn nominate_work() { Error::::InvalidTargetsLength, ); assert_noop!( - NomineesElectionModule::nominate(RuntimeOrigin::signed(ALICE), vec![1, 2, 3, 4, 5, 6]), + NomineesElectionModule::nominate( + RuntimeOrigin::signed(ALICE), + vec![ + NOMINATEE_1, + NOMINATEE_2, + NOMINATEE_3, + NOMINATEE_4, + NOMINATEE_5, + NOMINATEE_6 + ] + ), Error::::InvalidTargetsLength, ); assert_eq!(NomineesElectionModule::nominations(&ALICE), vec![]); - assert_eq!(NomineesElectionModule::votes(1), 0); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_1), 0); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_2), 0); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_3), 0); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_4), 0); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_5), 0); assert_ok!(NomineesElectionModule::nominate( RuntimeOrigin::signed(ALICE), - vec![1, 2, 3, 4, 5] + vec![NOMINATEE_1, NOMINATEE_2, NOMINATEE_3, NOMINATEE_4, NOMINATEE_5] )); - assert_eq!(NomineesElectionModule::nominations(&ALICE), vec![1, 2, 3, 4, 5]); - assert_eq!(NomineesElectionModule::votes(1), 500); - assert_eq!(NomineesElectionModule::votes(2), 500); + System::assert_has_event(mock::RuntimeEvent::NomineesElectionModule(crate::Event::Nominate { + who: ALICE, + targets: vec![NOMINATEE_1, NOMINATEE_2, NOMINATEE_3, NOMINATEE_4, NOMINATEE_5], + })); + assert_eq!( + NomineesElectionModule::nominations(&ALICE), + vec![NOMINATEE_1, NOMINATEE_2, NOMINATEE_3, NOMINATEE_4, NOMINATEE_5] + ); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_1), 500); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_2), 500); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_3), 500); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_4), 500); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_5), 500); assert_ok!(NomineesElectionModule::nominate( RuntimeOrigin::signed(ALICE), - vec![2, 3, 4, 5, 6] + vec![NOMINATEE_2, NOMINATEE_3, NOMINATEE_4, NOMINATEE_5, NOMINATEE_6] )); - assert_eq!(NomineesElectionModule::nominations(&ALICE), vec![2, 3, 4, 5, 6]); - assert_eq!(NomineesElectionModule::votes(1), 0); - assert_eq!(NomineesElectionModule::votes(2), 500); + System::assert_has_event(mock::RuntimeEvent::NomineesElectionModule(crate::Event::Nominate { + who: ALICE, + targets: vec![NOMINATEE_2, NOMINATEE_3, NOMINATEE_4, NOMINATEE_5, NOMINATEE_6], + })); + assert_eq!( + NomineesElectionModule::nominations(&ALICE), + vec![NOMINATEE_2, NOMINATEE_3, NOMINATEE_4, NOMINATEE_5, NOMINATEE_6] + ); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_1), 0); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_2), 500); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_3), 500); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_4), 500); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_5), 500); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_6), 500); + + InvalidNominees::set(vec![NOMINATEE_8]); + assert_noop!( + NomineesElectionModule::nominate(RuntimeOrigin::signed(ALICE), vec![NOMINATEE_8]), + Error::::InvalidNominee, + ); }); } @@ -215,59 +288,540 @@ fn chill_work() { assert_ok!(NomineesElectionModule::bond(RuntimeOrigin::signed(ALICE), 500)); assert_ok!(NomineesElectionModule::nominate( RuntimeOrigin::signed(ALICE), - vec![1, 2, 3, 4, 5] + vec![NOMINATEE_1, NOMINATEE_2, NOMINATEE_3, NOMINATEE_4, NOMINATEE_5] )); - assert_eq!(NomineesElectionModule::nominations(&ALICE), vec![1, 2, 3, 4, 5]); - assert_eq!(NomineesElectionModule::votes(1), 500); - assert_eq!(NomineesElectionModule::votes(2), 500); + assert_eq!( + NomineesElectionModule::nominations(&ALICE), + vec![NOMINATEE_1, NOMINATEE_2, NOMINATEE_3, NOMINATEE_4, NOMINATEE_5] + ); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_1), 500); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_2), 500); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_3), 500); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_4), 500); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_5), 500); + assert_ok!(NomineesElectionModule::chill(RuntimeOrigin::signed(ALICE))); + System::assert_has_event(mock::RuntimeEvent::NomineesElectionModule(crate::Event::Nominate { + who: ALICE, + targets: vec![], + })); assert_eq!(NomineesElectionModule::nominations(&ALICE), vec![]); - assert_eq!(NomineesElectionModule::votes(1), 0); - assert_eq!(NomineesElectionModule::votes(2), 0); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_1), 0); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_2), 0); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_3), 0); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_4), 0); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_5), 0); }); } #[test] -fn rebalance_work() { +fn update_votes_work() { ExtBuilder::default().build().execute_with(|| { - assert_ok!(NomineesElectionModule::bond(RuntimeOrigin::signed(ALICE), 500)); + >::insert(NOMINATEE_1, 50); + >::insert(NOMINATEE_2, 100); + NomineesElectionModule::update_votes(30, &[NOMINATEE_1, NOMINATEE_2], 50, &[NOMINATEE_1, NOMINATEE_2]); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_1), 70); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_2), 120); + NomineesElectionModule::update_votes(0, &[NOMINATEE_1, NOMINATEE_2], 50, &[NOMINATEE_3, NOMINATEE_4]); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_1), 70); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_2), 120); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_3), 50); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_4), 50); + NomineesElectionModule::update_votes( + 200, + &[NOMINATEE_1, NOMINATEE_2, NOMINATEE_3, NOMINATEE_4], + 10, + &[NOMINATEE_3, NOMINATEE_4], + ); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_1), 0); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_2), 0); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_3), 10); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_4), 10); + }); +} + +#[test] +fn reset_reserved_nominees_work() { + ExtBuilder::default().build().execute_with(|| { + assert_noop!( + NomineesElectionModule::reset_reserved_nominees(RuntimeOrigin::signed(ALICE), vec![]), + BadOrigin + ); + + assert_eq!(NomineesElectionModule::reserved_nominees(0), vec![]); + assert_eq!(NomineesElectionModule::reserved_nominees(1), vec![]); + assert_eq!(NomineesElectionModule::reserved_nominees(2), vec![]); + + assert_ok!(NomineesElectionModule::reset_reserved_nominees( + RuntimeOrigin::root(), + vec![ + ( + 0, + vec![NOMINATEE_1, NOMINATEE_2, NOMINATEE_3, NOMINATEE_4, NOMINATEE_5] + .try_into() + .unwrap() + ), + ( + 2, + vec![NOMINATEE_5, NOMINATEE_3, NOMINATEE_4, NOMINATEE_1] + .try_into() + .unwrap() + ), + ( + 1, + vec![NOMINATEE_1, NOMINATEE_2, NOMINATEE_1, NOMINATEE_2, NOMINATEE_1] + .try_into() + .unwrap() + ), + ] + )); + System::assert_has_event(mock::RuntimeEvent::NomineesElectionModule( + crate::Event::ResetReservedNominees { + group_index: 0, + reserved_nominees: vec![NOMINATEE_1, NOMINATEE_2, NOMINATEE_3, NOMINATEE_4, NOMINATEE_5], + }, + )); + System::assert_has_event(mock::RuntimeEvent::NomineesElectionModule( + crate::Event::ResetReservedNominees { + group_index: 2, + reserved_nominees: vec![NOMINATEE_1, NOMINATEE_3, NOMINATEE_4, NOMINATEE_5], + }, + )); + System::assert_has_event(mock::RuntimeEvent::NomineesElectionModule( + crate::Event::ResetReservedNominees { + group_index: 1, + reserved_nominees: vec![NOMINATEE_1, NOMINATEE_2], + }, + )); + assert_eq!( + NomineesElectionModule::reserved_nominees(0), + vec![NOMINATEE_1, NOMINATEE_2, NOMINATEE_3, NOMINATEE_4, NOMINATEE_5] + ); + assert_eq!( + NomineesElectionModule::reserved_nominees(1), + vec![NOMINATEE_1, NOMINATEE_2] + ); + assert_eq!( + NomineesElectionModule::reserved_nominees(2), + vec![NOMINATEE_1, NOMINATEE_3, NOMINATEE_4, NOMINATEE_5] + ); + + assert_ok!(NomineesElectionModule::reset_reserved_nominees( + RuntimeOrigin::root(), + vec![(2, Default::default())] + )); + System::assert_has_event(mock::RuntimeEvent::NomineesElectionModule( + crate::Event::ResetReservedNominees { + group_index: 2, + reserved_nominees: vec![], + }, + )); + assert_eq!(NomineesElectionModule::reserved_nominees(2), vec![]); + }); +} + +#[test] +fn sort_voted_nominees_work() { + ExtBuilder::default().build().execute_with(|| { + assert_ok!(NomineesElectionModule::bond(RuntimeOrigin::signed(ALICE), 100)); + assert_ok!(NomineesElectionModule::bond(RuntimeOrigin::signed(BOB), 101)); + assert_ok!(NomineesElectionModule::bond(RuntimeOrigin::signed(CHARLIE), 102)); + assert_ok!(NomineesElectionModule::bond(RuntimeOrigin::signed(DAVE), 103)); + assert_ok!(NomineesElectionModule::bond(RuntimeOrigin::signed(EVE), 104)); + assert_ok!(NomineesElectionModule::nominate( RuntimeOrigin::signed(ALICE), - vec![1, 2, 3, 4, 5] + vec![NOMINATEE_1, NOMINATEE_2, NOMINATEE_3, NOMINATEE_4, NOMINATEE_5] + )); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_1), 100); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_2), 100); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_3), 100); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_4), 100); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_5), 100); + assert_eq!( + NomineesElectionModule::sort_voted_nominees(), + vec![NOMINATEE_5, NOMINATEE_4, NOMINATEE_2, NOMINATEE_1, NOMINATEE_3] + ); + + assert_ok!(NomineesElectionModule::nominate( + RuntimeOrigin::signed(BOB), + vec![NOMINATEE_2, NOMINATEE_6, NOMINATEE_10] + )); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_1), 100); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_2), 201); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_3), 100); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_4), 100); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_5), 100); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_6), 101); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_10), 101); + assert_eq!( + NomineesElectionModule::sort_voted_nominees(), + vec![ + NOMINATEE_2, + NOMINATEE_6, + NOMINATEE_10, + NOMINATEE_5, + NOMINATEE_4, + NOMINATEE_1, + NOMINATEE_3 + ] + ); + + assert_ok!(NomineesElectionModule::nominate( + RuntimeOrigin::signed(CHARLIE), + vec![NOMINATEE_3, NOMINATEE_7, NOMINATEE_11] + )); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_1), 100); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_2), 201); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_3), 202); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_4), 100); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_5), 100); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_6), 101); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_7), 102); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_10), 101); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_11), 102); + assert_eq!( + NomineesElectionModule::sort_voted_nominees(), + vec![ + NOMINATEE_3, + NOMINATEE_2, + NOMINATEE_11, + NOMINATEE_7, + NOMINATEE_6, + NOMINATEE_10, + NOMINATEE_5, + NOMINATEE_4, + NOMINATEE_1 + ] + ); + + assert_ok!(NomineesElectionModule::nominate( + RuntimeOrigin::signed(DAVE), + vec![NOMINATEE_4, NOMINATEE_8, NOMINATEE_12] + )); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_1), 100); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_2), 201); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_3), 202); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_4), 203); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_5), 100); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_6), 101); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_7), 102); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_8), 103); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_10), 101); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_11), 102); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_12), 103); + assert_eq!( + NomineesElectionModule::sort_voted_nominees(), + vec![ + NOMINATEE_4, + NOMINATEE_3, + NOMINATEE_2, + NOMINATEE_8, + NOMINATEE_12, + NOMINATEE_11, + NOMINATEE_7, + NOMINATEE_6, + NOMINATEE_10, + NOMINATEE_5, + NOMINATEE_1 + ] + ); + + assert_ok!(NomineesElectionModule::nominate( + RuntimeOrigin::signed(EVE), + vec![NOMINATEE_5, NOMINATEE_9, NOMINATEE_10, NOMINATEE_11, NOMINATEE_12] )); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_1), 100); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_2), 201); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_3), 202); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_4), 203); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_5), 204); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_6), 101); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_7), 102); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_8), 103); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_9), 104); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_10), 205); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_11), 206); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_12), 207); + assert_eq!( + NomineesElectionModule::sort_voted_nominees(), + vec![ + NOMINATEE_12, + NOMINATEE_11, + NOMINATEE_10, + NOMINATEE_5, + NOMINATEE_4, + NOMINATEE_3, + NOMINATEE_2, + NOMINATEE_9, + NOMINATEE_8, + NOMINATEE_7, + NOMINATEE_6, + NOMINATEE_1 + ] + ); + + InvalidNominees::set(vec![NOMINATEE_12, NOMINATEE_11, NOMINATEE_2, NOMINATEE_9]); + assert_eq!( + NomineesElectionModule::sort_voted_nominees(), + vec![ + NOMINATEE_10, + NOMINATEE_5, + NOMINATEE_4, + NOMINATEE_3, + NOMINATEE_8, + NOMINATEE_7, + NOMINATEE_6, + NOMINATEE_1 + ] + ); + }); +} + +#[test] +fn nominees_work() { + ExtBuilder::default().build().execute_with(|| { assert_eq!(NomineesElectionModule::nominees(), vec![]); - assert_eq!(NomineesElectionModule::nominees().len(), 0); - NomineesElectionModule::rebalance(); - assert_eq!(NomineesElectionModule::nominees().len(), 5); - assert!(NomineesElectionModule::nominees().contains(&1)); - assert_ok!(NomineesElectionModule::bond(RuntimeOrigin::signed(BOB), 600)); + assert_ok!(NomineesElectionModule::bond(RuntimeOrigin::signed(ALICE), 100)); + assert_ok!(NomineesElectionModule::bond(RuntimeOrigin::signed(BOB), 101)); + assert_ok!(NomineesElectionModule::bond(RuntimeOrigin::signed(CHARLIE), 102)); + assert_ok!(NomineesElectionModule::nominate( + RuntimeOrigin::signed(BOB), + vec![NOMINATEE_2, NOMINATEE_6, NOMINATEE_10] + )); + assert_eq!( + NomineesElectionModule::nominees(), + vec![NOMINATEE_2, NOMINATEE_6, NOMINATEE_10] + ); + assert_ok!(NomineesElectionModule::nominate( RuntimeOrigin::signed(ALICE), - vec![2, 3, 4, 5, 6] + vec![NOMINATEE_1, NOMINATEE_2, NOMINATEE_3, NOMINATEE_4, NOMINATEE_5] )); - NomineesElectionModule::rebalance(); - assert_eq!(NomineesElectionModule::nominees().len(), 5); - assert!(!NomineesElectionModule::nominees().contains(&1)); + assert_eq!( + NomineesElectionModule::nominees(), + vec![NOMINATEE_2, NOMINATEE_6, NOMINATEE_10, NOMINATEE_5, NOMINATEE_4] + ); + + assert_ok!(NomineesElectionModule::nominate( + RuntimeOrigin::signed(CHARLIE), + vec![NOMINATEE_3, NOMINATEE_7, NOMINATEE_11] + )); + assert_eq!( + NomineesElectionModule::nominees(), + vec![NOMINATEE_3, NOMINATEE_2, NOMINATEE_11, NOMINATEE_7, NOMINATEE_6] + ); }); } #[test] -fn update_votes_work() { +fn nominees_in_groups_work() { ExtBuilder::default().build().execute_with(|| { - >::insert(1, 50); - >::insert(2, 100); - NomineesElectionModule::update_votes(30, &[1, 2], 50, &[1, 2]); - assert_eq!(NomineesElectionModule::votes(1), 70); - assert_eq!(NomineesElectionModule::votes(2), 120); - NomineesElectionModule::update_votes(0, &[1, 2], 50, &[3, 4]); - assert_eq!(NomineesElectionModule::votes(1), 70); - assert_eq!(NomineesElectionModule::votes(2), 120); - assert_eq!(NomineesElectionModule::votes(3), 50); - assert_eq!(NomineesElectionModule::votes(4), 50); - NomineesElectionModule::update_votes(200, &[1, 2, 3, 4], 10, &[3, 4]); - assert_eq!(NomineesElectionModule::votes(1), 0); - assert_eq!(NomineesElectionModule::votes(2), 0); - assert_eq!(NomineesElectionModule::votes(3), 10); - assert_eq!(NomineesElectionModule::votes(4), 10); + assert_ok!(NomineesElectionModule::bond(RuntimeOrigin::signed(ALICE), 100)); + assert_ok!(NomineesElectionModule::bond(RuntimeOrigin::signed(BOB), 101)); + assert_ok!(NomineesElectionModule::bond(RuntimeOrigin::signed(CHARLIE), 102)); + assert_ok!(NomineesElectionModule::bond(RuntimeOrigin::signed(DAVE), 103)); + assert_ok!(NomineesElectionModule::bond(RuntimeOrigin::signed(EVE), 104)); + + assert_ok!(NomineesElectionModule::nominate( + RuntimeOrigin::signed(ALICE), + vec![NOMINATEE_1, NOMINATEE_2, NOMINATEE_3, NOMINATEE_4, NOMINATEE_5] + )); + assert_ok!(NomineesElectionModule::nominate( + RuntimeOrigin::signed(BOB), + vec![NOMINATEE_2, NOMINATEE_6, NOMINATEE_10] + )); + assert_ok!(NomineesElectionModule::nominate( + RuntimeOrigin::signed(CHARLIE), + vec![NOMINATEE_3, NOMINATEE_7, NOMINATEE_11] + )); + assert_ok!(NomineesElectionModule::nominate( + RuntimeOrigin::signed(DAVE), + vec![NOMINATEE_4, NOMINATEE_8, NOMINATEE_12] + )); + assert_ok!(NomineesElectionModule::nominate( + RuntimeOrigin::signed(EVE), + vec![NOMINATEE_5, NOMINATEE_9, NOMINATEE_10, NOMINATEE_11, NOMINATEE_12] + )); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_1), 100); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_2), 201); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_3), 202); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_4), 203); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_5), 204); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_6), 101); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_7), 102); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_8), 103); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_9), 104); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_10), 205); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_11), 206); + assert_eq!(NomineesElectionModule::votes(NOMINATEE_12), 207); + assert_eq!( + NomineesElectionModule::sort_voted_nominees(), + vec![ + NOMINATEE_12, + NOMINATEE_11, + NOMINATEE_10, + NOMINATEE_5, + NOMINATEE_4, + NOMINATEE_3, + NOMINATEE_2, + NOMINATEE_9, + NOMINATEE_8, + NOMINATEE_7, + NOMINATEE_6, + NOMINATEE_1 + ] + ); + + assert_eq!( + NomineesElectionModule::nominees(), + vec![NOMINATEE_12, NOMINATEE_11, NOMINATEE_10, NOMINATEE_5, NOMINATEE_4] + ); + assert_eq!( + NomineesElectionModule::nominees_in_groups(vec![0]), + vec![( + 0, + vec![NOMINATEE_12, NOMINATEE_11, NOMINATEE_10, NOMINATEE_5, NOMINATEE_4] + )] + ); + assert_eq!( + NomineesElectionModule::nominees_in_groups(vec![0, 1]), + vec![ + ( + 0, + vec![NOMINATEE_12, NOMINATEE_10, NOMINATEE_4, NOMINATEE_2, NOMINATEE_8] + ), + ( + 1, + vec![NOMINATEE_11, NOMINATEE_5, NOMINATEE_3, NOMINATEE_9, NOMINATEE_7] + ) + ] + ); + assert_eq!( + NomineesElectionModule::nominees_in_groups(vec![0, 1, 2]), + vec![ + (0, vec![NOMINATEE_12, NOMINATEE_5, NOMINATEE_2, NOMINATEE_7]), + (1, vec![NOMINATEE_11, NOMINATEE_4, NOMINATEE_9, NOMINATEE_6]), + (2, vec![NOMINATEE_10, NOMINATEE_3, NOMINATEE_8, NOMINATEE_1]) + ] + ); + + assert_ok!(NomineesElectionModule::reset_reserved_nominees( + RuntimeOrigin::root(), + vec![(0, vec![NOMINATEE_10, NOMINATEE_2, NOMINATEE_1].try_into().unwrap())] + )); + assert_eq!( + NomineesElectionModule::nominees_in_groups(vec![0]), + vec![( + 0, + vec![NOMINATEE_1, NOMINATEE_2, NOMINATEE_10, NOMINATEE_12, NOMINATEE_11] + )] + ); + assert_eq!( + NomineesElectionModule::nominees_in_groups(vec![0, 1]), + vec![ + ( + 0, + vec![NOMINATEE_1, NOMINATEE_2, NOMINATEE_10, NOMINATEE_5, NOMINATEE_3] + ), + ( + 1, + vec![NOMINATEE_12, NOMINATEE_11, NOMINATEE_10, NOMINATEE_4, NOMINATEE_2] + ) + ] + ); + assert_eq!( + NomineesElectionModule::nominees_in_groups(vec![0, 1, 2]), + vec![ + ( + 0, + vec![NOMINATEE_1, NOMINATEE_2, NOMINATEE_10, NOMINATEE_9, NOMINATEE_7] + ), + ( + 1, + vec![NOMINATEE_12, NOMINATEE_10, NOMINATEE_4, NOMINATEE_2, NOMINATEE_6] + ), + ( + 2, + vec![NOMINATEE_11, NOMINATEE_5, NOMINATEE_3, NOMINATEE_8, NOMINATEE_1] + ) + ] + ); + assert_eq!( + NomineesElectionModule::nominees_in_groups(vec![0, 1, 2, 3]), + vec![ + (0, vec![NOMINATEE_1, NOMINATEE_2, NOMINATEE_10, NOMINATEE_7]), + (1, vec![NOMINATEE_12, NOMINATEE_5, NOMINATEE_2, NOMINATEE_6]), + (2, vec![NOMINATEE_11, NOMINATEE_4, NOMINATEE_9, NOMINATEE_1]), + (3, vec![NOMINATEE_10, NOMINATEE_3, NOMINATEE_8]) + ] + ); + + assert_ok!(NomineesElectionModule::reset_reserved_nominees( + RuntimeOrigin::root(), + vec![ + (0, vec![NOMINATEE_10, NOMINATEE_2, NOMINATEE_1].try_into().unwrap()), + (1, vec![NOMINATEE_11, NOMINATEE_4, NOMINATEE_3].try_into().unwrap()), + (2, vec![NOMINATEE_12, NOMINATEE_6, NOMINATEE_5].try_into().unwrap()) + ] + )); + assert_eq!( + NomineesElectionModule::nominees_in_groups(vec![0]), + vec![( + 0, + vec![NOMINATEE_1, NOMINATEE_2, NOMINATEE_10, NOMINATEE_12, NOMINATEE_11] + )] + ); + assert_eq!( + NomineesElectionModule::nominees_in_groups(vec![0, 1]), + vec![ + ( + 0, + vec![NOMINATEE_1, NOMINATEE_2, NOMINATEE_10, NOMINATEE_12, NOMINATEE_11] + ), + ( + 1, + vec![NOMINATEE_3, NOMINATEE_4, NOMINATEE_11, NOMINATEE_10, NOMINATEE_5] + ) + ] + ); + assert_eq!( + NomineesElectionModule::nominees_in_groups(vec![0, 1, 2]), + vec![ + ( + 0, + vec![NOMINATEE_1, NOMINATEE_2, NOMINATEE_10, NOMINATEE_12, NOMINATEE_5] + ), + ( + 1, + vec![NOMINATEE_3, NOMINATEE_4, NOMINATEE_11, NOMINATEE_10, NOMINATEE_2] + ), + ( + 2, + vec![NOMINATEE_5, NOMINATEE_6, NOMINATEE_12, NOMINATEE_11, NOMINATEE_4] + ) + ] + ); + assert_eq!( + NomineesElectionModule::nominees_in_groups(vec![0, 1, 2, 3]), + vec![ + ( + 0, + vec![NOMINATEE_1, NOMINATEE_2, NOMINATEE_10, NOMINATEE_5, NOMINATEE_9] + ), + ( + 1, + vec![NOMINATEE_3, NOMINATEE_4, NOMINATEE_11, NOMINATEE_2, NOMINATEE_8] + ), + ( + 2, + vec![NOMINATEE_5, NOMINATEE_6, NOMINATEE_12, NOMINATEE_4, NOMINATEE_7] + ), + ( + 3, + vec![NOMINATEE_12, NOMINATEE_11, NOMINATEE_10, NOMINATEE_3, NOMINATEE_6] + ), + ] + ); }); } diff --git a/modules/nominees-election/src/weights.rs b/modules/nominees-election/src/weights.rs index c32bbb5841..773499375a 100644 --- a/modules/nominees-election/src/weights.rs +++ b/modules/nominees-election/src/weights.rs @@ -18,29 +18,28 @@ //! Autogenerated weights for module_nominees_election //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 -//! DATE: 2021-06-28, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Native), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-04-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `192.168.1.3`, CPU: `` +//! WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: // target/release/acala // benchmark +// pallet // --chain=dev // --steps=50 // --repeat=20 // --pallet=module_nominees_election // --extrinsic=* -// --execution=native // --wasm-execution=compiled // --heap-pages=4096 // --output=./modules/nominees-election/src/weights.rs // --template=./templates/module-weight-template.hbs - #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] -#![allow(clippy::unnecessary_cast)] use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; @@ -53,97 +52,300 @@ pub trait WeightInfo { fn withdraw_unbonded(c: u32, ) -> Weight; fn nominate(c: u32, ) -> Weight; fn chill(c: u32, ) -> Weight; + fn reset_reserved_nominees(c: u32, ) -> Weight; } /// Weights for module_nominees_election using the Acala node and recommended hardware. pub struct AcalaWeight(PhantomData); impl WeightInfo for AcalaWeight { + // Storage: `NomineesElection::Ledger` (r:1 w:1) + // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + // Storage: `NomineesElection::Nominations` (r:1 w:0) + // Proof: `NomineesElection::Nominations` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::PoolInfos` (r:1 w:1) + // Proof: `Rewards::PoolInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::SharesAndWithdrawnRewards` (r:1 w:1) + // Proof: `Rewards::SharesAndWithdrawnRewards` (`max_values`: None, `max_size`: None, mode: `Measured`) fn bond() -> Weight { - Weight::from_parts(17_919_000, 0) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `2634` + // Estimated: `6099` + // Minimum execution time: 50_000 nanoseconds. + Weight::from_parts(51_000_000, 6099) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) } + // Storage: `Homa::RelayChainCurrentEra` (r:1 w:0) + // Proof: `Homa::RelayChainCurrentEra` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `NomineesElection::Ledger` (r:1 w:1) + // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `NomineesElection::Nominations` (r:1 w:0) + // Proof: `NomineesElection::Nominations` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::SharesAndWithdrawnRewards` (r:1 w:1) + // Proof: `Rewards::SharesAndWithdrawnRewards` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::PoolInfos` (r:1 w:1) + // Proof: `Rewards::PoolInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) fn unbond() -> Weight { - Weight::from_parts(16_640_000, 0) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `2388` + // Estimated: `5853` + // Minimum execution time: 51_000 nanoseconds. + Weight::from_parts(52_000_000, 5853) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(5)) } - fn rebond(c: u32, ) -> Weight { - Weight::from_parts(23_396_000, 0) - // Standard Error: 8_000 - .saturating_add(Weight::from_parts(46_000, 0).saturating_mul(c as u64)) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Storage: `NomineesElection::Ledger` (r:1 w:1) + // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `NomineesElection::Nominations` (r:1 w:0) + // Proof: `NomineesElection::Nominations` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::PoolInfos` (r:1 w:1) + // Proof: `Rewards::PoolInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::SharesAndWithdrawnRewards` (r:1 w:1) + // Proof: `Rewards::SharesAndWithdrawnRewards` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `c` is `[1, 7]`. + fn rebond(_c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2266` + // Estimated: `5731` + // Minimum execution time: 46_000 nanoseconds. + Weight::from_parts(47_756_966, 5731) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) } + // Storage: `Homa::RelayChainCurrentEra` (r:1 w:0) + // Proof: `Homa::RelayChainCurrentEra` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `NomineesElection::Ledger` (r:1 w:1) + // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + /// The range of component `c` is `[1, 7]`. fn withdraw_unbonded(c: u32, ) -> Weight { - Weight::from_parts(15_118_000, 0) - // Standard Error: 4_000 - .saturating_add(Weight::from_parts(42_000, 0).saturating_mul(c as u64)) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `2168` + // Estimated: `5633` + // Minimum execution time: 41_000 nanoseconds. + Weight::from_parts(42_083_720, 5633) + // Standard Error: 8_852 + .saturating_add(Weight::from_parts(17_693, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } + // Storage: `NomineesElection::Ledger` (r:1 w:0) + // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `HomaValidatorList::ValidatorBackings` (r:16 w:0) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + // Storage: `NomineesElection::Nominations` (r:1 w:1) + // Proof: `NomineesElection::Nominations` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `NomineesElection::Votes` (r:16 w:16) + // Proof: `NomineesElection::Votes` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `c` is `[1, 16]`. fn nominate(c: u32, ) -> Weight { - Weight::from_parts(6_287_000, 0) - // Standard Error: 8_000 - .saturating_add(Weight::from_parts(2_509_000, 0).saturating_mul(c as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(c as u64))) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(c as u64))) + // Proof Size summary in bytes: + // Measured: `1508 + c * (72 ±0)` + // Estimated: `4973 + c * (2547 ±0)` + // Minimum execution time: 27_000 nanoseconds. + Weight::from_parts(23_636_270, 4973) + // Standard Error: 8_350 + .saturating_add(Weight::from_parts(5_042_360, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(c.into()))) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 2547).saturating_mul(c.into())) } + // Storage: `NomineesElection::Ledger` (r:1 w:0) + // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `NomineesElection::Nominations` (r:1 w:1) + // Proof: `NomineesElection::Nominations` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `NomineesElection::Votes` (r:16 w:16) + // Proof: `NomineesElection::Votes` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `c` is `[1, 16]`. fn chill(c: u32, ) -> Weight { - Weight::from_parts(5_871_000, 0) - // Standard Error: 15_000 - .saturating_add(Weight::from_parts(3_870_000, 0).saturating_mul(c as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(c as u64))) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(c as u64))) + // Proof Size summary in bytes: + // Measured: `1372 + c * (93 ±0)` + // Estimated: `4835 + c * (2569 ±0)` + // Minimum execution time: 27_000 nanoseconds. + Weight::from_parts(24_376_618, 4835) + // Standard Error: 6_967 + .saturating_add(Weight::from_parts(3_399_922, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into()))) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 2569).saturating_mul(c.into())) + } + // Storage: `NomineesElection::ReservedNominees` (r:0 w:4) + // Proof: `NomineesElection::ReservedNominees` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `c` is `[1, 4]`. + fn reset_reserved_nominees(c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1001` + // Estimated: `1001` + // Minimum execution time: 14_000 nanoseconds. + Weight::from_parts(10_545_159, 1001) + // Standard Error: 19_194 + .saturating_add(Weight::from_parts(4_201_406, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) } } // For backwards compatibility and tests impl WeightInfo for () { + // Storage: `NomineesElection::Ledger` (r:1 w:1) + // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + // Storage: `NomineesElection::Nominations` (r:1 w:0) + // Proof: `NomineesElection::Nominations` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::PoolInfos` (r:1 w:1) + // Proof: `Rewards::PoolInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::SharesAndWithdrawnRewards` (r:1 w:1) + // Proof: `Rewards::SharesAndWithdrawnRewards` (`max_values`: None, `max_size`: None, mode: `Measured`) fn bond() -> Weight { - Weight::from_parts(17_919_000, 0) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `2634` + // Estimated: `6099` + // Minimum execution time: 50_000 nanoseconds. + Weight::from_parts(51_000_000, 6099) + .saturating_add(RocksDbWeight::get().reads(6)) + .saturating_add(RocksDbWeight::get().writes(5)) } + // Storage: `Homa::RelayChainCurrentEra` (r:1 w:0) + // Proof: `Homa::RelayChainCurrentEra` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `NomineesElection::Ledger` (r:1 w:1) + // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `NomineesElection::Nominations` (r:1 w:0) + // Proof: `NomineesElection::Nominations` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::SharesAndWithdrawnRewards` (r:1 w:1) + // Proof: `Rewards::SharesAndWithdrawnRewards` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::PoolInfos` (r:1 w:1) + // Proof: `Rewards::PoolInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) fn unbond() -> Weight { - Weight::from_parts(16_640_000, 0) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `2388` + // Estimated: `5853` + // Minimum execution time: 51_000 nanoseconds. + Weight::from_parts(52_000_000, 5853) + .saturating_add(RocksDbWeight::get().reads(7)) + .saturating_add(RocksDbWeight::get().writes(5)) } - fn rebond(c: u32, ) -> Weight { - Weight::from_parts(23_396_000, 0) - // Standard Error: 8_000 - .saturating_add(Weight::from_parts(46_000, 0).saturating_mul(c as u64)) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Storage: `NomineesElection::Ledger` (r:1 w:1) + // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `NomineesElection::Nominations` (r:1 w:0) + // Proof: `NomineesElection::Nominations` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::PoolInfos` (r:1 w:1) + // Proof: `Rewards::PoolInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::SharesAndWithdrawnRewards` (r:1 w:1) + // Proof: `Rewards::SharesAndWithdrawnRewards` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `c` is `[1, 7]`. + fn rebond(_c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2266` + // Estimated: `5731` + // Minimum execution time: 46_000 nanoseconds. + Weight::from_parts(47_756_966, 5731) + .saturating_add(RocksDbWeight::get().reads(6)) + .saturating_add(RocksDbWeight::get().writes(5)) } + // Storage: `Homa::RelayChainCurrentEra` (r:1 w:0) + // Proof: `Homa::RelayChainCurrentEra` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `NomineesElection::Ledger` (r:1 w:1) + // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + /// The range of component `c` is `[1, 7]`. fn withdraw_unbonded(c: u32, ) -> Weight { - Weight::from_parts(15_118_000, 0) - // Standard Error: 4_000 - .saturating_add(Weight::from_parts(42_000, 0).saturating_mul(c as u64)) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `2168` + // Estimated: `5633` + // Minimum execution time: 41_000 nanoseconds. + Weight::from_parts(42_083_720, 5633) + // Standard Error: 8_852 + .saturating_add(Weight::from_parts(17_693, 0).saturating_mul(c.into())) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(3)) } + // Storage: `NomineesElection::Ledger` (r:1 w:0) + // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `HomaValidatorList::ValidatorBackings` (r:16 w:0) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + // Storage: `NomineesElection::Nominations` (r:1 w:1) + // Proof: `NomineesElection::Nominations` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `NomineesElection::Votes` (r:16 w:16) + // Proof: `NomineesElection::Votes` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `c` is `[1, 16]`. fn nominate(c: u32, ) -> Weight { - Weight::from_parts(6_287_000, 0) - // Standard Error: 8_000 - .saturating_add(Weight::from_parts(2_509_000, 0).saturating_mul(c as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(c as u64))) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(c as u64))) + // Proof Size summary in bytes: + // Measured: `1508 + c * (72 ±0)` + // Estimated: `4973 + c * (2547 ±0)` + // Minimum execution time: 27_000 nanoseconds. + Weight::from_parts(23_636_270, 4973) + // Standard Error: 8_350 + .saturating_add(Weight::from_parts(5_042_360, 0).saturating_mul(c.into())) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(c.into()))) + .saturating_add(RocksDbWeight::get().writes(1)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 2547).saturating_mul(c.into())) } + // Storage: `NomineesElection::Ledger` (r:1 w:0) + // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `NomineesElection::Nominations` (r:1 w:1) + // Proof: `NomineesElection::Nominations` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `NomineesElection::Votes` (r:16 w:16) + // Proof: `NomineesElection::Votes` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `c` is `[1, 16]`. fn chill(c: u32, ) -> Weight { - Weight::from_parts(5_871_000, 0) - // Standard Error: 15_000 - .saturating_add(Weight::from_parts(3_870_000, 0).saturating_mul(c as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(c as u64))) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(c as u64))) + // Proof Size summary in bytes: + // Measured: `1372 + c * (93 ±0)` + // Estimated: `4835 + c * (2569 ±0)` + // Minimum execution time: 27_000 nanoseconds. + Weight::from_parts(24_376_618, 4835) + // Standard Error: 6_967 + .saturating_add(Weight::from_parts(3_399_922, 0).saturating_mul(c.into())) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(c.into()))) + .saturating_add(RocksDbWeight::get().writes(1)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 2569).saturating_mul(c.into())) + } + // Storage: `NomineesElection::ReservedNominees` (r:0 w:4) + // Proof: `NomineesElection::ReservedNominees` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `c` is `[1, 4]`. + fn reset_reserved_nominees(c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1001` + // Estimated: `1001` + // Minimum execution time: 14_000 nanoseconds. + Weight::from_parts(10_545_159, 1001) + // Standard Error: 19_194 + .saturating_add(Weight::from_parts(4_201_406, 0).saturating_mul(c.into())) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(c.into()))) } } diff --git a/modules/relaychain/src/lib.rs b/modules/relaychain/src/lib.rs index 334a7652ef..ed68804b1f 100644 --- a/modules/relaychain/src/lib.rs +++ b/modules/relaychain/src/lib.rs @@ -35,7 +35,7 @@ use sp_std::{boxed::Box, marker::PhantomData, prelude::*}; pub use cumulus_primitives_core::ParaId; use xcm::v4::{prelude::*, Weight as XcmWeight}; -/// The encoded index correspondes to Kusama's Runtime module configuration. +/// The encoded index corresponds to Kusama's Runtime module configuration. /// https://github.com/paritytech/polkadot/blob/444e96ae34bcec8362f0f947a07bd912b32ca48f/runtime/kusama/src/lib.rs#L1379 #[derive(Encode, Decode, RuntimeDebug)] pub enum KusamaRelayChainCall { @@ -73,7 +73,7 @@ impl RelayChainCall for KusamaRelayChainCall { } } -/// The encoded index correspondes to Polkadot's Runtime module configuration. +/// The encoded index corresponds to Polkadot's Runtime module configuration. /// https://github.com/paritytech/polkadot/blob/84a3962e76151ac5ed3afa4ef1e0af829531ab42/runtime/polkadot/src/lib.rs#L1040 #[derive(Encode, Decode, RuntimeDebug)] pub enum PolkadotRelayChainCall { @@ -118,7 +118,7 @@ where ParachainId: Get, RCC: RelayChainCall + FullCodec, { - type AccountId = AccountId; + type RelayChainAccountId = AccountId; type Balance = Balance; type RelayChainCall = RCC; @@ -138,7 +138,13 @@ where RCC::staking(StakingCall::WithdrawUnbonded(num_slashing_spans)) } - fn balances_transfer_keep_alive(to: Self::AccountId, amount: Self::Balance) -> RCC { + fn staking_nominate(targets: Vec) -> RCC { + RCC::staking(StakingCall::Nominate( + targets.iter().map(|a| RelayChainLookup::unlookup(a.clone())).collect(), + )) + } + + fn balances_transfer_keep_alive(to: Self::RelayChainAccountId, amount: Self::Balance) -> RCC { RCC::balances(BalancesCall::TransferKeepAlive(RelayChainLookup::unlookup(to), amount)) } @@ -157,7 +163,7 @@ where )) } - fn proxy_call(real: Self::AccountId, call: RCC) -> RCC { + fn proxy_call(real: Self::RelayChainAccountId, call: RCC) -> RCC { RCC::proxy(ProxyCall::Proxy(RelayChainLookup::unlookup(real), None, call)) } diff --git a/modules/support/src/homa.rs b/modules/support/src/homa.rs index 676150bec5..637e02ed4b 100644 --- a/modules/support/src/homa.rs +++ b/modules/support/src/homa.rs @@ -18,9 +18,11 @@ use crate::{ExchangeRate, Rate}; use sp_runtime::DispatchResult; +use sp_std::{fmt::Debug, vec::Vec}; use xcm::v4::prelude::*; pub trait HomaSubAccountXcm { + type RelayChainAccountId: Debug + Clone + Ord; /// Cross-chain transfer staking currency to sub account on relaychain. fn transfer_staking_to_sub_account(sender: &AccountId, sub_account_index: u16, amount: Balance) -> DispatchResult; /// Send XCM message to the relaychain for sub account to withdraw_unbonded staking currency and @@ -30,6 +32,8 @@ pub trait HomaSubAccountXcm { fn bond_extra_on_sub_account(sub_account_index: u16, amount: Balance) -> DispatchResult; /// Send XCM message to the relaychain for sub account to unbond. fn unbond_on_sub_account(sub_account_index: u16, amount: Balance) -> DispatchResult; + /// Send XCM message to the relaychain for sub account to nominate. + fn nominate_on_sub_account(sub_account_index: u16, targets: Vec) -> DispatchResult; /// The fee of cross-chain transfer is deducted from the recipient. fn get_xcm_transfer_fee() -> Balance; /// The fee of parachain diff --git a/modules/support/src/incentives.rs b/modules/support/src/incentives.rs index 53ad0b5a8d..7414f7f19c 100644 --- a/modules/support/src/incentives.rs +++ b/modules/support/src/incentives.rs @@ -34,6 +34,9 @@ pub enum PoolId { /// Rewards and shares pool for earning module Earning(CurrencyId), + + /// Rewards and shares pool for Homa nominees election + NomineesElection, } pub trait IncentivesManager { diff --git a/modules/support/src/lib.rs b/modules/support/src/lib.rs index f2d4ddb869..666ae37c18 100644 --- a/modules/support/src/lib.rs +++ b/modules/support/src/lib.rs @@ -26,7 +26,7 @@ use primitives::{task::TaskResult, Balance, CurrencyId, Multiplier, ReserveIdent use sp_runtime::{ traits::CheckedDiv, transaction_validity::TransactionValidityError, DispatchError, DispatchResult, FixedU128, }; -use sp_std::{prelude::*, result::Result}; +use sp_std::{prelude::*, result::Result, vec}; use xcm::prelude::*; pub mod bounded; @@ -168,6 +168,17 @@ pub trait OnNewEra { pub trait NomineesProvider { fn nominees() -> Vec; + fn nominees_in_groups(group_index_list: Vec) -> Vec<(u16, Vec)>; +} + +impl NomineesProvider for () { + fn nominees() -> Vec { + vec![] + } + + fn nominees_in_groups(_: Vec) -> Vec<(u16, Vec)> { + vec![] + } } pub trait LiquidateCollateral { diff --git a/modules/support/src/relaychain.rs b/modules/support/src/relaychain.rs index 8943093fde..071994bcf6 100644 --- a/modules/support/src/relaychain.rs +++ b/modules/support/src/relaychain.rs @@ -48,6 +48,8 @@ pub enum StakingCall { Unbond(#[codec(compact)] Balance), #[codec(index = 3)] WithdrawUnbonded(u32), + #[codec(index = 5)] + Nominate(Vec<::Source>), } /// `pallet-xcm` calls. @@ -80,7 +82,7 @@ pub trait RelayChainCall: Sized { } pub trait CallBuilder { - type AccountId: FullCodec; + type RelayChainAccountId: FullCodec; type Balance: FullCodec; type RelayChainCall: FullCodec + RelayChainCall; @@ -105,11 +107,16 @@ pub trait CallBuilder { /// - num_slashing_spans: The number of slashing spans to withdraw from. fn staking_withdraw_unbonded(num_slashing_spans: u32) -> Self::RelayChainCall; + /// Nominate the relay-chain. + /// params: + /// - targets: The target validator list. + fn staking_nominate(targets: Vec) -> Self::RelayChainCall; + /// Transfer Staking currency to another account, disallowing "death". /// params: /// - to: The destination for the transfer /// - amount: The amount of staking currency to be transferred. - fn balances_transfer_keep_alive(to: Self::AccountId, amount: Self::Balance) -> Self::RelayChainCall; + fn balances_transfer_keep_alive(to: Self::RelayChainAccountId, amount: Self::Balance) -> Self::RelayChainCall; /// Reserve transfer assets. /// params: @@ -128,7 +135,7 @@ pub trait CallBuilder { /// params: /// - real: The real account. /// - call: The call to be executed. - fn proxy_call(real: Self::AccountId, call: Self::RelayChainCall) -> Self::RelayChainCall; + fn proxy_call(real: Self::RelayChainAccountId, call: Self::RelayChainCall) -> Self::RelayChainCall; /// Wrap the final call into the Xcm format. /// params: diff --git a/modules/xcm-interface/src/lib.rs b/modules/xcm-interface/src/lib.rs index 76021b0549..d24c555037 100644 --- a/modules/xcm-interface/src/lib.rs +++ b/modules/xcm-interface/src/lib.rs @@ -58,6 +58,7 @@ pub mod module { ParachainFee(Box), // `XcmPallet::reserve_transfer_assets` call via proxy account ProxyReserveTransferAssets, + HomaNominate, } #[pallet::config] @@ -84,7 +85,7 @@ pub mod module { type SovereignSubAccountLocationConvert: Convert; /// The Call builder for communicating with RelayChain via XCM messaging. - type RelayChainCallBuilder: CallBuilder; + type RelayChainCallBuilder: CallBuilder; /// The interface to Cross-chain transfer. type XcmTransfer: XcmTransfer; @@ -205,6 +206,8 @@ pub mod module { } impl HomaSubAccountXcm for Pallet { + type RelayChainAccountId = T::AccountId; + /// Cross-chain transfer staking currency to sub account on relaychain. fn transfer_staking_to_sub_account( sender: &T::AccountId, @@ -305,6 +308,28 @@ pub mod module { Ok(()) } + /// Send XCM message to the relaychain for sub account to nominate. + fn nominate_on_sub_account(sub_account_index: u16, targets: Vec) -> DispatchResult { + let (xcm_dest_weight, xcm_fee) = Self::xcm_dest_weight_and_fee(XcmInterfaceOperation::HomaNominate); + let xcm_message = T::RelayChainCallBuilder::finalize_call_into_xcm_message( + T::RelayChainCallBuilder::utility_as_derivative_call( + T::RelayChainCallBuilder::staking_nominate(targets.clone()), + sub_account_index, + ), + xcm_fee, + xcm_dest_weight, + ); + let result = pallet_xcm::Pallet::::send_xcm(Here, Parent, xcm_message); + log::debug!( + target: "xcm-interface", + "subaccount {:?} send XCM to nominate {:?}, result: {:?}", + sub_account_index, targets, result + ); + + ensure!(result.is_ok(), Error::::XcmFailed); + Ok(()) + } + /// The fee of cross-chain transfer is deducted from the recipient. fn get_xcm_transfer_fee() -> Balance { Self::xcm_dest_weight_and_fee(XcmInterfaceOperation::XtokensTransfer).1 diff --git a/primitives/src/bonding/controller.rs b/primitives/src/bonding/controller.rs index 46761159a1..1eac65c8c1 100644 --- a/primitives/src/bonding/controller.rs +++ b/primitives/src/bonding/controller.rs @@ -48,7 +48,6 @@ where type MaxUnbondingChunks: Get; type Moment: Ord + Eq + Copy; type AccountId: Parameter + Member; - type Ledger: StorageMap, Query = Option>>; fn available_balance(who: &Self::AccountId, ledger: &BondingLedgerOf) -> Balance; diff --git a/runtime/acala/Cargo.toml b/runtime/acala/Cargo.toml index 620607bb82..deb2a93a8f 100644 --- a/runtime/acala/Cargo.toml +++ b/runtime/acala/Cargo.toml @@ -71,6 +71,7 @@ xcm = { workspace = true } xcm-executor = { workspace = true } xcm-builder = { workspace = true } pallet-xcm = { workspace = true } +pallet-xcm-benchmarks = { workspace = true, optional = true } polkadot-runtime-common = { workspace = true } parachains-common = { workspace = true } @@ -110,6 +111,7 @@ module-evm-accounts = { workspace = true } module-evm-bridge = { workspace = true } module-evm-rpc-runtime-api = { workspace = true } module-homa = { workspace = true } +module-homa-validator-list = { workspace = true } module-honzon = { workspace = true } module-idle-scheduler = { workspace = true } module-incentives = { workspace = true } @@ -123,6 +125,7 @@ module-support = { workspace = true } module-transaction-pause = { workspace = true } module-transaction-payment = { workspace = true } module-xcm-interface = { workspace = true } +module-nominees-election = { workspace = true } primitives = { workspace = true } runtime-common = { workspace = true } @@ -243,6 +246,7 @@ std = [ "module-evm-rpc-runtime-api/std", "module-evm/std", "module-homa/std", + "module-homa-validator-list/std", "module-honzon/std", "module-idle-scheduler/std", "module-incentives/std", @@ -256,6 +260,7 @@ std = [ "module-transaction-pause/std", "module-transaction-payment/std", "module-xcm-interface/std", + "module-nominees-election/std", "primitives/std", "runtime-common/std", @@ -288,7 +293,9 @@ runtime-benchmarks = [ "cumulus-pallet-parachain-system/runtime-benchmarks", "cumulus-pallet-xcmp-queue/runtime-benchmarks", + "cumulus-primitives-utility/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", + "pallet-xcm-benchmarks/runtime-benchmarks", "polkadot-parachain-primitives/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", @@ -383,6 +390,7 @@ try-runtime = [ "module-evm-bridge/try-runtime", "module-evm/try-runtime", "module-homa/try-runtime", + "module-homa-validator-list/try-runtime", "module-honzon/try-runtime", "module-idle-scheduler/try-runtime", "module-incentives/try-runtime", @@ -394,6 +402,7 @@ try-runtime = [ "module-transaction-pause/try-runtime", "module-transaction-payment/try-runtime", "module-xcm-interface/try-runtime", + "module-nominees-election/try-runtime", "primitives/try-runtime", @@ -406,4 +415,4 @@ no-metadata-docs = ["frame-support/no-metadata-docs"] # more types in the metadata. full-metadata-docs = ["frame-support/full-metadata-docs"] -tracing = ["module-evm/tracing", "module-evm-rpc-runtime-api/tracing"] +tracing = ["module-evm/tracing", "module-evm-rpc-runtime-api/tracing", "runtime-common/tracing"] diff --git a/runtime/acala/src/benchmarking/mod.rs b/runtime/acala/src/benchmarking/mod.rs index 8c24ea8258..9128b1b343 100644 --- a/runtime/acala/src/benchmarking/mod.rs +++ b/runtime/acala/src/benchmarking/mod.rs @@ -62,6 +62,9 @@ pub mod evm_accounts { pub mod homa { include!("../../../mandala/src/benchmarking/homa.rs"); } +pub mod homa_validator_list { + include!("../../../mandala/src/benchmarking/homa_validator_list.rs"); +} pub mod honzon { include!("../../../mandala/src/benchmarking/honzon.rs"); } @@ -93,6 +96,9 @@ pub mod nutsfinance_stable_asset { pub mod aggregated_dex { include!("../../../mandala/src/benchmarking/aggregated_dex.rs"); } +pub mod nominees_election { + include!("../../../mandala/src/benchmarking/nominees_election.rs"); +} // orml benchmarking pub mod auction { diff --git a/runtime/acala/src/lib.rs b/runtime/acala/src/lib.rs index 9f65ff97d5..92927ceaf3 100644 --- a/runtime/acala/src/lib.rs +++ b/runtime/acala/src/lib.rs @@ -166,6 +166,7 @@ parameter_types! { pub const HomaTreasuryPalletId: PalletId = PalletId(*b"aca/hmtr"); pub const IncentivesPalletId: PalletId = PalletId(*b"aca/inct"); pub const CollatorPotId: PalletId = PalletId(*b"aca/cpot"); + pub const NomineesElectionId: LockIdentifier = *b"aca/nome"; // Treasury reserve pub const TreasuryReservePalletId: PalletId = PalletId(*b"aca/reve"); pub const NftPalletId: PalletId = PalletId(*b"aca/aNFT"); @@ -1314,6 +1315,9 @@ parameter_type_with_key! { ExistentialDeposits::get(currency_id) } } + PoolId::NomineesElection => { + ExistentialDeposits::get(&GetLiquidCurrencyId::get()) + } } }; } @@ -1572,6 +1576,7 @@ parameter_types! { ]; pub MintThreshold: Balance = dollar(DOT); pub RedeemThreshold: Balance = 5 * dollar(LDOT); + pub const BondingDuration: EraIndex = 28; } impl module_homa::Config for Runtime { @@ -1584,12 +1589,53 @@ impl module_homa::Config for Runtime { type TreasuryAccount = HomaTreasuryAccount; type DefaultExchangeRate = DefaultExchangeRate; type ActiveSubAccountsIndexList = ActiveSubAccountsIndexList; - type BondingDuration = ConstU32<28>; + type BondingDuration = BondingDuration; type MintThreshold = MintThreshold; type RedeemThreshold = RedeemThreshold; type RelayChainBlockNumber = RelaychainDataProvider; type XcmInterface = XcmInterface; type WeightInfo = weights::module_homa::WeightInfo; + type NominationsProvider = NomineesElection; +} + +parameter_types! { + pub MinBondAmount: Balance = 1_000 * dollar(LDOT); + pub ValidatorInsuranceThreshold: Balance = 10_000 * dollar(LDOT); +} + +impl module_homa_validator_list::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RelayChainAccountId = AccountId; + type LiquidTokenCurrency = module_currencies::Currency; + type MinBondAmount = MinBondAmount; + type BondingDuration = BondingDuration; + type ValidatorInsuranceThreshold = ValidatorInsuranceThreshold; + type GovernanceOrigin = EnsureRootOrHalfGeneralCouncil; + type LiquidStakingExchangeRateProvider = Homa; + type CurrentEra = Homa; + type WeightInfo = weights::module_homa_validator_list::WeightInfo; +} + +parameter_types! { + pub MinNomineesElectionBondThreshold: Balance = 10 * dollar(LDOT); + pub const MaxNominateesCount: u32 = 16; +} + +impl module_nominees_election::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = module_currencies::Currency; + type NomineeId = AccountId; + type PalletId = NomineesElectionId; + type MinBond = MinNomineesElectionBondThreshold; + type BondingDuration = BondingDuration; + type MaxNominateesCount = MaxNominateesCount; + type MaxUnbondingChunks = ConstU32<7>; + type NomineeFilter = HomaValidatorList; + type GovernanceOrigin = EnsureRootOrHalfGeneralCouncil; + type OnBonded = module_incentives::OnNomineesElectionBonded; + type OnUnbonded = module_incentives::OnNomineesElectionUnbonded; + type CurrentEra = Homa; + type WeightInfo = weights::module_nominees_election::WeightInfo; } pub fn create_x2_parachain_location(index: u16) -> Location { @@ -1879,6 +1925,8 @@ construct_runtime!( // Homa Homa: module_homa = 116, XcmInterface: module_xcm_interface = 117, + HomaValidatorList: module_homa_validator_list = 118, + NomineesElection: module_nominees_election = 119, // Acala Other Incentives: module_incentives = 120, @@ -1965,6 +2013,7 @@ mod benches { [module_emergency_shutdown, benchmarking::emergency_shutdown] [module_evm, benchmarking::evm] [module_homa, benchmarking::homa] + [module_homa_validator_list, benchmarking::homa_validator_list] [module_honzon, benchmarking::honzon] [module_cdp_treasury, benchmarking::cdp_treasury] [module_collator_selection, benchmarking::collator_selection] @@ -1984,7 +2033,12 @@ mod benches { [module_idle_scheduler, benchmarking::idle_scheduler] [module_aggregated_dex, benchmarking::aggregated_dex] [module_liquid_crowdloan, benchmarking::liquid_crowdloan] + [module_nominees_election, benchmarking::nominees_election] ); + // frame_benchmarking::define_benchmarks!( + // // XCM + // [pallet_xcm, PalletXcmExtrinsicsBenchmark::] + // ); } #[cfg(not(feature = "disable-runtime-api"))] @@ -2321,6 +2375,7 @@ sp_api::impl_runtime_apis! { use frame_benchmarking::{list_benchmark as frame_list_benchmark, Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; use module_nft::benchmarking::Pallet as NftBench; + // use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark; let mut list = Vec::::new(); @@ -2335,10 +2390,87 @@ sp_api::impl_runtime_apis! { fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, sp_runtime::RuntimeString> { - use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark as frame_add_benchmark}; + use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError, add_benchmark as frame_add_benchmark}; use module_nft::benchmarking::Pallet as NftBench; use frame_support::traits::{WhitelistedStorageKeys, TrackedStorageKey}; + // const UNITS: Balance = 1_000_000_000_000; + // const CENTS: Balance = UNITS / 100; + + // parameter_types! { + // pub FeeAssetId: AssetId = AssetId(Location::parent()); + // pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3); + // } + // pub type PriceForParentDelivery = polkadot_runtime_common::xcm_sender::ExponentialPrice< + // FeeAssetId, + // BaseDeliveryFee, + // TransactionByteFee, + // ParachainSystem, + // >; + + // use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark; + // impl pallet_xcm::benchmarking::Config for Runtime { + // type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper< + // xcm_config::XcmConfig, + // ExistentialDepositAsset, + // PriceForParentDelivery, + // >; + // fn reachable_dest() -> Option { + // Some(Parent.into()) + // } + + // fn teleportable_asset_and_dest() -> Option<(Asset, Location)> { + // Some(( + // Asset { + // fun: Fungible(NativeTokenExistentialDeposit::get()), + // id: AssetId(Parent.into()) + // }, + // Parent.into(), + // )) + // } + + // fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> { + // None + // } + + // fn get_asset() -> Asset { + // Asset { + // id: AssetId(Location::parent()), + // fun: Fungible(UNITS), + // } + // } + // } + + // parameter_types! { + // pub ExistentialDepositAsset: Option = Some(( + // Location::parent(), + // NativeTokenExistentialDeposit::get() + // ).into()); + // } + + // impl pallet_xcm_benchmarks::Config for Runtime { + // type XcmConfig = xcm_config::XcmConfig; + // type AccountIdConverter = xcm_config::LocationToAccountId; + // type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper< + // xcm_config::XcmConfig, + // ExistentialDepositAsset, + // PriceForParentDelivery, + // >; + // fn valid_destination() -> Result { + // Ok(Location::parent()) + // } + // fn worst_case_holding(_depositable_count: u32) -> Assets { + // // just concrete assets according to relay chain. + // let assets: Vec = vec![ + // Asset { + // id: AssetId(Location::parent()), + // fun: Fungible(1_000_000 * UNITS), + // } + // ]; + // assets.into() + // } + // } + let mut whitelist: Vec = AllPalletsWithSystem::whitelisted_storage_keys(); // Treasury Account @@ -2384,7 +2516,11 @@ impl Convert<(RuntimeCall, SignedExtra), Result<(EthereumTransactionMessage, Sig valid_until, }) => { if System::block_number() > valid_until { - return Err(InvalidTransaction::Stale); + if cfg!(feature = "tracing") { + // skip check when enable tracing feature + } else { + return Err(InvalidTransaction::Stale); + } } let (_, _, _, _, mortality, check_nonce, _, _, charge) = extra.clone(); @@ -2429,7 +2565,11 @@ impl Convert<(RuntimeCall, SignedExtra), Result<(EthereumTransactionMessage, Sig decode_gas_price(gas_price, gas_limit, TxFeePerGasV2::get()).ok_or(InvalidTransaction::Stale)?; if System::block_number() > valid_until { - return Err(InvalidTransaction::Stale); + if cfg!(feature = "tracing") { + // skip check when enable tracing feature + } else { + return Err(InvalidTransaction::Stale); + } } let (_, _, _, _, mortality, check_nonce, _, _, charge) = extra.clone(); diff --git a/runtime/acala/src/weights/mod.rs b/runtime/acala/src/weights/mod.rs index f4b83c739c..c45be1406b 100644 --- a/runtime/acala/src/weights/mod.rs +++ b/runtime/acala/src/weights/mod.rs @@ -32,10 +32,12 @@ pub mod module_emergency_shutdown; pub mod module_evm; pub mod module_evm_accounts; pub mod module_homa; +pub mod module_homa_validator_list; pub mod module_honzon; pub mod module_incentives; pub mod module_liquid_crowdloan; pub mod module_nft; +pub mod module_nominees_election; pub mod module_prices; pub mod module_session_manager; pub mod module_transaction_pause; diff --git a/runtime/acala/src/weights/module_homa_validator_list.rs b/runtime/acala/src/weights/module_homa_validator_list.rs new file mode 100644 index 0000000000..b64a95664d --- /dev/null +++ b/runtime/acala/src/weights/module_homa_validator_list.rs @@ -0,0 +1,180 @@ +// This file is part of Acala. + +// Copyright (C) 2020-2024 Acala Foundation. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +//! Autogenerated weights for module_homa_validator_list +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-04-17, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `192.168.1.2`, CPU: `` +//! WASM-EXECUTION: Compiled, CHAIN: Some("acala-dev"), DB CACHE: 1024 + +// Executed Command: +// target/production/acala +// benchmark +// pallet +// --chain=acala-dev +// --steps=50 +// --repeat=20 +// --pallet=* +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --template=./templates/runtime-weight-template.hbs +// --output=./runtime/acala/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for module_homa_validator_list. +pub struct WeightInfo(PhantomData); +impl module_homa_validator_list::WeightInfo for WeightInfo { + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::TotalLockedByGuarantor` (r:1 w:1) + // Proof: `HomaValidatorList::TotalLockedByGuarantor` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::Guarantees` (r:1 w:1) + // Proof: `HomaValidatorList::Guarantees` (`max_values`: None, `max_size`: Some(141), added: 2616, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::ValidatorBackings` (r:1 w:1) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + fn bond() -> Weight { + // Proof Size summary in bytes: + // Measured: `2388` + // Estimated: `4765` + // Minimum execution time: 36_000 nanoseconds. + Weight::from_parts(37_000_000, 4765) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) + } + // Storage: `HomaValidatorList::Guarantees` (r:1 w:1) + // Proof: `HomaValidatorList::Guarantees` (`max_values`: None, `max_size`: Some(141), added: 2616, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::ValidationData` (r:1 w:0) + // Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::LastRelayChainBlockNumber` (r:1 w:0) + // Proof: `ParachainSystem::LastRelayChainBlockNumber` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + fn unbond() -> Weight { + // Proof Size summary in bytes: + // Measured: `1506` + // Estimated: `3606` + // Minimum execution time: 19_000 nanoseconds. + Weight::from_parts(20_000_000, 3606) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: `HomaValidatorList::Guarantees` (r:1 w:1) + // Proof: `HomaValidatorList::Guarantees` (`max_values`: None, `max_size`: Some(141), added: 2616, mode: `MaxEncodedLen`) + fn rebond() -> Weight { + // Proof Size summary in bytes: + // Measured: `1044` + // Estimated: `3606` + // Minimum execution time: 8_000 nanoseconds. + Weight::from_parts(9_000_000, 3606) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: `HomaValidatorList::ValidatorBackings` (r:1 w:1) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::Guarantees` (r:1 w:1) + // Proof: `HomaValidatorList::Guarantees` (`max_values`: None, `max_size`: Some(141), added: 2616, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::ValidationData` (r:1 w:0) + // Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `HomaValidatorList::TotalLockedByGuarantor` (r:1 w:1) + // Proof: `HomaValidatorList::TotalLockedByGuarantor` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + fn withdraw_unbonded() -> Weight { + // Proof Size summary in bytes: + // Measured: `2312` + // Estimated: `4765` + // Minimum execution time: 40_000 nanoseconds. + Weight::from_parts(41_000_000, 4765) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) + } + // Storage: `HomaValidatorList::ValidatorBackings` (r:10 w:10) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// The range of component `n` is `[1, 10]`. + fn freeze(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1235 + n * (71 ±0)` + // Estimated: `990 + n * (2540 ±0)` + // Minimum execution time: 15_000 nanoseconds. + Weight::from_parts(10_990_773, 990) + // Standard Error: 8_735 + .saturating_add(Weight::from_parts(4_485_901, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 2540).saturating_mul(n.into())) + } + // Storage: `HomaValidatorList::ValidatorBackings` (r:10 w:10) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// The range of component `n` is `[1, 10]`. + fn thaw(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1235 + n * (71 ±0)` + // Estimated: `990 + n * (2540 ±0)` + // Minimum execution time: 15_000 nanoseconds. + Weight::from_parts(11_502_223, 990) + // Standard Error: 12_312 + .saturating_add(Weight::from_parts(4_428_242, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 2540).saturating_mul(n.into())) + } + // Storage: `Homa::TotalStakingBonded` (r:1 w:0) + // Proof: `Homa::TotalStakingBonded` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `Homa::ToBondPool` (r:1 w:0) + // Proof: `Homa::ToBondPool` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `Tokens::TotalIssuance` (r:1 w:1) + // Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + // Storage: `Homa::TotalVoidLiquid` (r:1 w:0) + // Proof: `Homa::TotalVoidLiquid` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `HomaValidatorList::ValidatorBackings` (r:10 w:10) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::Guarantees` (r:20 w:10) + // Proof: `HomaValidatorList::Guarantees` (`max_values`: None, `max_size`: Some(141), added: 2616, mode: `MaxEncodedLen`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::TotalLockedByGuarantor` (r:1 w:1) + // Proof: `HomaValidatorList::TotalLockedByGuarantor` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + /// The range of component `n` is `[1, 10]`. + fn slash(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2834 + n * (200 ±0)` + // Estimated: `4765 + n * (5232 ±0)` + // Minimum execution time: 57_000 nanoseconds. + Weight::from_parts(30_420_201, 4765) + // Standard Error: 30_290 + .saturating_add(Weight::from_parts(30_166_892, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes(4)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 5232).saturating_mul(n.into())) + } +} diff --git a/runtime/acala/src/weights/module_nominees_election.rs b/runtime/acala/src/weights/module_nominees_election.rs new file mode 100644 index 0000000000..55f570d2aa --- /dev/null +++ b/runtime/acala/src/weights/module_nominees_election.rs @@ -0,0 +1,193 @@ +// This file is part of Acala. + +// Copyright (C) 2020-2024 Acala Foundation. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +//! Autogenerated weights for module_nominees_election +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-04-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `192.168.1.3`, CPU: `` +//! WASM-EXECUTION: Compiled, CHAIN: Some("acala-dev"), DB CACHE: 1024 + +// Executed Command: +// target/production/acala +// benchmark +// pallet +// --chain=acala-dev +// --steps=50 +// --repeat=20 +// --pallet=* +// --extrinsic=* +// --wasm-execution=compiled +// --heap-pages=4096 +// --template=./templates/runtime-weight-template.hbs +// --output=./runtime/acala/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for module_nominees_election. +pub struct WeightInfo(PhantomData); +impl module_nominees_election::WeightInfo for WeightInfo { + // Storage: `NomineesElection::Ledger` (r:1 w:1) + // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + // Storage: `NomineesElection::Nominations` (r:1 w:0) + // Proof: `NomineesElection::Nominations` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::PoolInfos` (r:1 w:1) + // Proof: `Rewards::PoolInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::SharesAndWithdrawnRewards` (r:1 w:1) + // Proof: `Rewards::SharesAndWithdrawnRewards` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn bond() -> Weight { + // Proof Size summary in bytes: + // Measured: `2634` + // Estimated: `6099` + // Minimum execution time: 39_000 nanoseconds. + Weight::from_parts(40_000_000, 6099) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) + } + // Storage: `Homa::RelayChainCurrentEra` (r:1 w:0) + // Proof: `Homa::RelayChainCurrentEra` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `NomineesElection::Ledger` (r:1 w:1) + // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `NomineesElection::Nominations` (r:1 w:0) + // Proof: `NomineesElection::Nominations` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::SharesAndWithdrawnRewards` (r:1 w:1) + // Proof: `Rewards::SharesAndWithdrawnRewards` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::PoolInfos` (r:1 w:1) + // Proof: `Rewards::PoolInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn unbond() -> Weight { + // Proof Size summary in bytes: + // Measured: `2388` + // Estimated: `5853` + // Minimum execution time: 40_000 nanoseconds. + Weight::from_parts(41_000_000, 5853) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(5)) + } + // Storage: `NomineesElection::Ledger` (r:1 w:1) + // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `NomineesElection::Nominations` (r:1 w:0) + // Proof: `NomineesElection::Nominations` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::PoolInfos` (r:1 w:1) + // Proof: `Rewards::PoolInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::SharesAndWithdrawnRewards` (r:1 w:1) + // Proof: `Rewards::SharesAndWithdrawnRewards` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `c` is `[1, 7]`. + fn rebond(_c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2266` + // Estimated: `5731` + // Minimum execution time: 36_000 nanoseconds. + Weight::from_parts(37_652_826, 5731) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) + } + // Storage: `Homa::RelayChainCurrentEra` (r:1 w:0) + // Proof: `Homa::RelayChainCurrentEra` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `NomineesElection::Ledger` (r:1 w:1) + // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + /// The range of component `c` is `[1, 7]`. + fn withdraw_unbonded(c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2168` + // Estimated: `5633` + // Minimum execution time: 33_000 nanoseconds. + Weight::from_parts(34_118_349, 5633) + // Standard Error: 21_099 + .saturating_add(Weight::from_parts(96_491, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: `NomineesElection::Ledger` (r:1 w:0) + // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `HomaValidatorList::ValidatorBackings` (r:16 w:0) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + // Storage: `NomineesElection::Nominations` (r:1 w:1) + // Proof: `NomineesElection::Nominations` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `NomineesElection::Votes` (r:16 w:16) + // Proof: `NomineesElection::Votes` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `c` is `[1, 16]`. + fn nominate(c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1508 + c * (72 ±0)` + // Estimated: `4973 + c * (2547 ±0)` + // Minimum execution time: 22_000 nanoseconds. + Weight::from_parts(19_125_174, 4973) + // Standard Error: 12_496 + .saturating_add(Weight::from_parts(3_924_043, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(c.into()))) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 2547).saturating_mul(c.into())) + } + // Storage: `NomineesElection::Ledger` (r:1 w:0) + // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `NomineesElection::Nominations` (r:1 w:1) + // Proof: `NomineesElection::Nominations` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `NomineesElection::Votes` (r:16 w:16) + // Proof: `NomineesElection::Votes` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `c` is `[1, 16]`. + fn chill(c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1372 + c * (93 ±0)` + // Estimated: `4835 + c * (2569 ±0)` + // Minimum execution time: 21_000 nanoseconds. + Weight::from_parts(19_737_152, 4835) + // Standard Error: 11_893 + .saturating_add(Weight::from_parts(2_815_068, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into()))) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 2569).saturating_mul(c.into())) + } + // Storage: `NomineesElection::ReservedNominees` (r:0 w:4) + // Proof: `NomineesElection::ReservedNominees` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `c` is `[1, 4]`. + fn reset_reserved_nominees(c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1001` + // Estimated: `1001` + // Minimum execution time: 11_000 nanoseconds. + Weight::from_parts(8_689_832, 1001) + // Standard Error: 19_101 + .saturating_add(Weight::from_parts(3_395_132, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + } +} diff --git a/runtime/acala/src/weights/pallet_xcm.rs b/runtime/acala/src/weights/pallet_xcm.rs index f6e92391e1..1cc905ae29 100644 --- a/runtime/acala/src/weights/pallet_xcm.rs +++ b/runtime/acala/src/weights/pallet_xcm.rs @@ -16,350 +16,281 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -//! Autogenerated weights for `pallet_xcm` +//! Autogenerated weights for pallet_xcm //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-12-19, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `ggwpez-ref-hw`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` -//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("../asset-hub-kusama-chain-spec.json")`, DB CACHE: 1024 +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 35.0.1 +//! DATE: 2024-05-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `ip-172-31-30-173`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` +//! WASM-EXECUTION: Compiled, CHAIN: Some("acala-dev"), DB CACHE: 1024 // Executed Command: -// ./target/production/polkadot +// target/production/acala // benchmark // pallet -// --chain=../asset-hub-kusama-chain-spec.json +// --chain=acala-dev // --steps=50 // --repeat=20 -// --pallet=pallet_xcm +// --pallet=* // --extrinsic=* // --wasm-execution=compiled // --heap-pages=4096 -// --output=./asset-hub-kusama-weights -// --header=./file_header.txt +// --template=./templates/runtime-weight-template.hbs +// --output=./runtime/acala/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] -#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use core::marker::PhantomData; +use sp_std::marker::PhantomData; -/// Weight functions for `pallet_xcm`. +/// Weight functions for pallet_xcm. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { - /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn send() -> Weight { // Proof Size summary in bytes: - // Measured: `145` - // Estimated: `3610` - // Minimum execution time: 24_856_000 picoseconds. - Weight::from_parts(25_639_000, 0) - .saturating_add(Weight::from_parts(0, 3610)) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(2)) + // Measured: `147` + // Estimated: `3612` + // Minimum execution time: 17_558 nanoseconds. + Weight::from_parts(18_018_000, 3612) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) - /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `Benchmark::Override` (r:0 w:0) + // Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`) fn teleport_assets() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `1489` - // Minimum execution time: 20_000_000 picoseconds. - Weight::from_parts(20_357_000, 0) - .saturating_add(Weight::from_parts(0, 1489)) - .saturating_add(T::DbWeight::get().reads(1)) + // Estimated: `0` + // Minimum execution time: 18_446_744_073_709_551 nanoseconds. + Weight::from_parts(18_446_744_073_709_551_000, 0) } - /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) - /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `Benchmark::Override` (r:0 w:0) + // Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`) fn reserve_transfer_assets() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `1489` - // Minimum execution time: 14_600_000 picoseconds. - Weight::from_parts(15_045_000, 0) - .saturating_add(Weight::from_parts(0, 1489)) - .saturating_add(T::DbWeight::get().reads(1)) + // Estimated: `0` + // Minimum execution time: 18_446_744_073_709_551 nanoseconds. + Weight::from_parts(18_446_744_073_709_551_000, 0) } - /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) - /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Assets::Asset` (r:1 w:1) - /// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `Assets::Account` (r:2 w:2) - /// Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:2 w:2) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `Benchmark::Override` (r:0 w:0) + // Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`) fn transfer_assets() -> Weight { // Proof Size summary in bytes: - // Measured: `496` - // Estimated: `6208` - // Minimum execution time: 146_932_000 picoseconds. - Weight::from_parts(153_200_000, 0) - .saturating_add(Weight::from_parts(0, 6208)) - .saturating_add(T::DbWeight::get().reads(12)) - .saturating_add(T::DbWeight::get().writes(7)) + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 18_446_744_073_709_551 nanoseconds. + Weight::from_parts(18_446_744_073_709_551_000, 0) } - /// Storage: `Benchmark::Override` (r:0 w:0) - /// Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Benchmark::Override` (r:0 w:0) + // Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`) fn execute() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 18_446_744_073_709_551_000 picoseconds. + // Minimum execution time: 18_446_744_073_709_551 nanoseconds. Weight::from_parts(18_446_744_073_709_551_000, 0) - .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `PolkadotXcm::SupportedVersion` (r:0 w:1) - /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:0 w:1) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) fn force_xcm_version() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_899_000 picoseconds. - Weight::from_parts(7_127_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Minimum execution time: 5_936 nanoseconds. + Weight::from_parts(6_180_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `PolkadotXcm::SafeXcmVersion` (r:0 w:1) - /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn force_default_xcm_version() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_198_000 picoseconds. - Weight::from_parts(2_440_000, 0) - .saturating_add(Weight::from_parts(0, 0)) - .saturating_add(T::DbWeight::get().writes(1)) + // Minimum execution time: 1_790 nanoseconds. + Weight::from_parts(2_011_000, 0) } - /// Storage: `PolkadotXcm::VersionNotifiers` (r:1 w:1) - /// Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::QueryCounter` (r:1 w:1) - /// Proof: `PolkadotXcm::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::Queries` (r:0 w:1) - /// Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionNotifiers` (r:1 w:1) + // Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::QueryCounter` (r:1 w:1) + // Proof: `PolkadotXcm::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::Queries` (r:0 w:1) + // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) fn force_subscribe_version_notify() -> Weight { // Proof Size summary in bytes: - // Measured: `145` - // Estimated: `3610` - // Minimum execution time: 29_009_000 picoseconds. - Weight::from_parts(30_280_000, 0) - .saturating_add(Weight::from_parts(0, 3610)) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(5)) + // Measured: `147` + // Estimated: `3612` + // Minimum execution time: 22_353 nanoseconds. + Weight::from_parts(23_152_000, 3612) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) } - /// Storage: `PolkadotXcm::VersionNotifiers` (r:1 w:1) - /// Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::Queries` (r:0 w:1) - /// Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionNotifiers` (r:1 w:1) + // Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::Queries` (r:0 w:1) + // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) fn force_unsubscribe_version_notify() -> Weight { // Proof Size summary in bytes: - // Measured: `363` - // Estimated: `3828` - // Minimum execution time: 30_806_000 picoseconds. - Weight::from_parts(31_646_000, 0) - .saturating_add(Weight::from_parts(0, 3828)) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(4)) + // Measured: `205` + // Estimated: `3670` + // Minimum execution time: 22_646 nanoseconds. + Weight::from_parts(23_437_000, 3670) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: `PolkadotXcm::XcmExecutionSuspended` (r:0 w:1) - /// Proof: `PolkadotXcm::XcmExecutionSuspended` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::XcmExecutionSuspended` (r:0 w:1) + // Proof: `PolkadotXcm::XcmExecutionSuspended` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn force_suspension() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_139_000 picoseconds. - Weight::from_parts(2_319_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Minimum execution time: 1_879 nanoseconds. + Weight::from_parts(1_970_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `PolkadotXcm::SupportedVersion` (r:4 w:2) - /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:5 w:2) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) fn migrate_supported_version() -> Weight { // Proof Size summary in bytes: - // Measured: `162` - // Estimated: `11052` - // Minimum execution time: 16_833_000 picoseconds. - Weight::from_parts(17_423_000, 0) - .saturating_add(Weight::from_parts(0, 11052)) - .saturating_add(T::DbWeight::get().reads(4)) + // Measured: `22` + // Estimated: `13387` + // Minimum execution time: 17_620 nanoseconds. + Weight::from_parts(18_207_000, 13387) + .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: `PolkadotXcm::VersionNotifiers` (r:4 w:2) - /// Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionNotifiers` (r:5 w:2) + // Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) fn migrate_version_notifiers() -> Weight { // Proof Size summary in bytes: - // Measured: `166` - // Estimated: `11056` - // Minimum execution time: 17_002_000 picoseconds. - Weight::from_parts(17_667_000, 0) - .saturating_add(Weight::from_parts(0, 11056)) - .saturating_add(T::DbWeight::get().reads(4)) + // Measured: `26` + // Estimated: `13391` + // Minimum execution time: 17_721 nanoseconds. + Weight::from_parts(17_911_000, 13391) + .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: `PolkadotXcm::VersionNotifyTargets` (r:5 w:0) - /// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:6 w:0) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) fn already_notified_target() -> Weight { // Proof Size summary in bytes: - // Measured: `173` - // Estimated: `13538` - // Minimum execution time: 18_497_000 picoseconds. - Weight::from_parts(18_995_000, 0) - .saturating_add(Weight::from_parts(0, 13538)) - .saturating_add(T::DbWeight::get().reads(5)) + // Measured: `36` + // Estimated: `15876` + // Minimum execution time: 20_000 nanoseconds. + Weight::from_parts(20_500_000, 15876) + .saturating_add(T::DbWeight::get().reads(6)) } - /// Storage: `PolkadotXcm::VersionNotifyTargets` (r:2 w:1) - /// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:2 w:1) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn notify_current_targets() -> Weight { // Proof Size summary in bytes: - // Measured: `212` - // Estimated: `6152` - // Minimum execution time: 27_060_000 picoseconds. - Weight::from_parts(27_662_000, 0) - .saturating_add(Weight::from_parts(0, 6152)) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(3)) + // Measured: `180` + // Estimated: `6120` + // Minimum execution time: 22_508 nanoseconds. + Weight::from_parts(23_013_000, 6120) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: `PolkadotXcm::VersionNotifyTargets` (r:3 w:0) - /// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:4 w:0) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) fn notify_target_migration_fail() -> Weight { // Proof Size summary in bytes: - // Measured: `206` - // Estimated: `8621` - // Minimum execution time: 9_157_000 picoseconds. - Weight::from_parts(9_437_000, 0) - .saturating_add(Weight::from_parts(0, 8621)) - .saturating_add(T::DbWeight::get().reads(3)) + // Measured: `69` + // Estimated: `10959` + // Minimum execution time: 13_058 nanoseconds. + Weight::from_parts(13_414_000, 10959) + .saturating_add(T::DbWeight::get().reads(4)) } - /// Storage: `PolkadotXcm::VersionNotifyTargets` (r:4 w:2) - /// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:5 w:2) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) fn migrate_version_notify_targets() -> Weight { // Proof Size summary in bytes: - // Measured: `173` - // Estimated: `11063` - // Minimum execution time: 17_430_000 picoseconds. - Weight::from_parts(17_727_000, 0) - .saturating_add(Weight::from_parts(0, 11063)) - .saturating_add(T::DbWeight::get().reads(4)) + // Measured: `33` + // Estimated: `13398` + // Minimum execution time: 17_977 nanoseconds. + Weight::from_parts(18_467_000, 13398) + .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: `PolkadotXcm::VersionNotifyTargets` (r:4 w:2) - /// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:5 w:2) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn migrate_and_notify_old_targets() -> Weight { // Proof Size summary in bytes: - // Measured: `215` - // Estimated: `11105` - // Minimum execution time: 33_562_000 picoseconds. - Weight::from_parts(34_612_000, 0) - .saturating_add(Weight::from_parts(0, 11105)) - .saturating_add(T::DbWeight::get().reads(10)) - .saturating_add(T::DbWeight::get().writes(4)) + // Measured: `180` + // Estimated: `13545` + // Minimum execution time: 32_866 nanoseconds. + Weight::from_parts(33_409_000, 13545) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: `XcmPallet::QueryCounter` (r:1 w:1) - /// Proof: `XcmPallet::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::Queries` (r:0 w:1) - /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::QueryCounter` (r:1 w:1) + // Proof: `PolkadotXcm::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::Queries` (r:0 w:1) + // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) fn new_query() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `1485` - // Minimum execution time: 2_947_000 picoseconds. - Weight::from_parts(3_117_000, 0) - .saturating_add(Weight::from_parts(0, 1485)) + // Minimum execution time: 2_337 nanoseconds. + Weight::from_parts(2_507_000, 1485) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: `XcmPallet::Queries` (r:1 w:1) - /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::Queries` (r:1 w:1) + // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) fn take_response() -> Weight { // Proof Size summary in bytes: // Measured: `7576` // Estimated: `11041` - // Minimum execution time: 24_595_000 picoseconds. - Weight::from_parts(24_907_000, 0) - .saturating_add(Weight::from_parts(0, 11041)) + // Minimum execution time: 19_915 nanoseconds. + Weight::from_parts(20_255_000, 11041) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + // Storage: `EVM::XcmOrigin` (r:1 w:1) + // Proof: `EVM::XcmOrigin` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::AssetTraps` (r:1 w:1) + // Proof: `PolkadotXcm::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `Tokens::TotalIssuance` (r:1 w:1) + // Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) fn claim_assets() -> Weight { // Proof Size summary in bytes: - // Measured: `7576` - // Estimated: `11041` - // Minimum execution time: 24_595_000 picoseconds. - Weight::from_parts(24_907_000, 0) - .saturating_add(Weight::from_parts(0, 11041)) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + // Measured: `233` + // Estimated: `3698` + // Minimum execution time: 35_866 nanoseconds. + Weight::from_parts(36_680_000, 3698) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) } } diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index 574902919d..571f3fb224 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -181,3 +181,4 @@ wasm-bench = [ runtime-benchmarks = [ "orml-oracle/runtime-benchmarks" ] +tracing = [] diff --git a/runtime/common/src/check_nonce.rs b/runtime/common/src/check_nonce.rs index 9e3b4d922c..b2cd9accee 100644 --- a/runtime/common/src/check_nonce.rs +++ b/runtime/common/src/check_nonce.rs @@ -120,7 +120,10 @@ where let evm_nonce = module_evm::Accounts::::get(address) .map(|x| x.nonce) .unwrap_or_default(); - if self.nonce != evm_nonce { + + if cfg!(feature = "tracing") { + // skip check when enable tracing feature + } else if self.nonce != evm_nonce { return Err(if self.nonce < evm_nonce { InvalidTransaction::Stale } else { @@ -155,7 +158,10 @@ where let evm_nonce = module_evm::Accounts::::get(address) .map(|x| x.nonce) .unwrap_or_default(); - if self.nonce < evm_nonce { + + if cfg!(feature = "tracing") { + // skip check when enable tracing feature + } else if self.nonce < evm_nonce { return InvalidTransaction::Stale.into(); } diff --git a/runtime/common/src/precompile/homa.rs b/runtime/common/src/precompile/homa.rs index 880cc7633a..f4853e2309 100644 --- a/runtime/common/src/precompile/homa.rs +++ b/runtime/common/src/precompile/homa.rs @@ -236,6 +236,7 @@ mod tests { Some(FixedU128::saturating_from_rational(1, 10)), Some(FixedU128::saturating_from_rational(1, 10)), Some(FixedU128::saturating_from_rational(1, 10)), + None, )); assert_ok!(Currencies::update_balance( @@ -275,6 +276,7 @@ mod tests { Some(FixedU128::saturating_from_rational(1, 10)), Some(FixedU128::saturating_from_rational(1, 10)), Some(FixedU128::saturating_from_rational(1, 10)), + None, )); assert_ok!(Currencies::update_balance( @@ -353,6 +355,7 @@ mod tests { Some(FixedU128::saturating_from_rational(1, 10)), None, None, + None, )); // getEstimatedRewardRate() -> 0xd313f77e @@ -384,6 +387,7 @@ mod tests { None, Some(FixedU128::saturating_from_rational(1, 10)), None, + None, )); // getCommissionRate() => 0x3e4eb36c @@ -413,6 +417,7 @@ mod tests { None, None, Some(FixedU128::saturating_from_rational(1, 10)), + None, )); // getFastMatchFee() => 0xc18290dd diff --git a/runtime/common/src/precompile/mock.rs b/runtime/common/src/precompile/mock.rs index 163581dadd..474ac692f5 100644 --- a/runtime/common/src/precompile/mock.rs +++ b/runtime/common/src/precompile/mock.rs @@ -680,6 +680,7 @@ impl module_prices::Config for Test { /// mock XCM transfer. pub struct MockHomaSubAccountXcm; impl HomaSubAccountXcm for MockHomaSubAccountXcm { + type RelayChainAccountId = AccountId; fn transfer_staking_to_sub_account(sender: &AccountId, _: u16, amount: Balance) -> DispatchResult { Currencies::withdraw(StakingCurrencyId::get(), sender, amount) } @@ -696,6 +697,10 @@ impl HomaSubAccountXcm for MockHomaSubAccountXcm { Ok(()) } + fn nominate_on_sub_account(_: u16, _: Vec) -> DispatchResult { + Ok(()) + } + fn get_xcm_transfer_fee() -> Balance { 1_000_000 } @@ -737,6 +742,7 @@ impl module_homa::Config for Test { type RelayChainBlockNumber = MockRelayBlockNumberProvider; type XcmInterface = MockHomaSubAccountXcm; type WeightInfo = (); + type NominationsProvider = (); } parameter_type_with_key! { diff --git a/runtime/integration-tests/src/evm.rs b/runtime/integration-tests/src/evm.rs index 81670c7386..cc009ea8d6 100644 --- a/runtime/integration-tests/src/evm.rs +++ b/runtime/integration-tests/src/evm.rs @@ -816,7 +816,8 @@ fn transaction_payment_module_works_with_evm_contract() { let dollar = dollar(NATIVE_CURRENCY); let alice_evm_account = MockAddressMapping::get_account_id(&alice_evm_addr()); let ed = NativeTokenExistentialDeposit::get(); // 100_000_000_000 - // new account + + // new account let empty_account = AccountId::new([1u8; 32]); let empty_address = H160::from_slice(&[1u8; 20]); let empty_address_account = MockAddressMapping::get_account_id(&empty_address); diff --git a/runtime/karura/Cargo.toml b/runtime/karura/Cargo.toml index 5705405a3a..4c26403e31 100644 --- a/runtime/karura/Cargo.toml +++ b/runtime/karura/Cargo.toml @@ -54,6 +54,7 @@ sp-staking = { workspace = true } sp-std = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } +pallet-state-trie-migration = { workspace = true, optional = true } # cumulus cumulus-pallet-aura-ext = { workspace = true } @@ -71,6 +72,7 @@ xcm = { workspace = true } xcm-executor = { workspace = true } xcm-builder = { workspace = true } pallet-xcm = { workspace = true } +pallet-xcm-benchmarks = { workspace = true, optional = true } polkadot-runtime-common = { workspace = true } parachains-common = { workspace = true } @@ -110,6 +112,7 @@ module-evm-accounts = { workspace = true } module-evm-bridge = { workspace = true } module-evm-rpc-runtime-api = { workspace = true } module-homa = { workspace = true } +module-homa-validator-list = { workspace = true } module-honzon = { workspace = true } module-honzon-bridge = { workspace = true } module-idle-scheduler = { workspace = true } @@ -124,6 +127,7 @@ module-transaction-pause = { workspace = true } module-transaction-payment = { workspace = true } module-xcm-interface = { workspace = true } module-xnft = { workspace = true } +module-nominees-election = { workspace = true } primitives = { workspace = true } runtime-common = { workspace = true } @@ -192,6 +196,7 @@ std = [ "sp-transaction-pool/std", "sp-version/std", "substrate-wasm-builder", + "pallet-state-trie-migration/std", "cumulus-pallet-aura-ext/std", "cumulus-pallet-parachain-system/std", @@ -202,6 +207,7 @@ std = [ "cumulus-primitives-utility/std", "pallet-xcm/std", + "pallet-xcm-benchmarks?/std", "parachain-info/std", "polkadot-parachain-primitives/std", "xcm-builder/std", @@ -244,6 +250,7 @@ std = [ "module-evm-rpc-runtime-api/std", "module-evm/std", "module-homa/std", + "module-homa-validator-list/std", "module-honzon-bridge/std", "module-honzon/std", "module-idle-scheduler/std", @@ -258,6 +265,7 @@ std = [ "module-transaction-payment/std", "module-xcm-interface/std", "module-xnft/std", + "module-nominees-election/std", "primitives/std", "runtime-common/std", @@ -287,10 +295,13 @@ runtime-benchmarks = [ "pallet-utility/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "sp-staking/runtime-benchmarks", + "pallet-state-trie-migration/runtime-benchmarks", "cumulus-pallet-parachain-system/runtime-benchmarks", "cumulus-pallet-xcmp-queue/runtime-benchmarks", + "cumulus-primitives-utility/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", + "pallet-xcm-benchmarks/runtime-benchmarks", "polkadot-parachain-primitives/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", @@ -350,6 +361,7 @@ try-runtime = [ "pallet-transaction-payment/try-runtime", "pallet-treasury/try-runtime", "pallet-utility/try-runtime", + "pallet-state-trie-migration/try-runtime", "cumulus-pallet-aura-ext/try-runtime", "cumulus-pallet-parachain-system/try-runtime", @@ -385,6 +397,7 @@ try-runtime = [ "module-evm-bridge/try-runtime", "module-evm/try-runtime", "module-homa/try-runtime", + "module-homa-validator-list/try-runtime", "module-honzon-bridge/try-runtime", "module-honzon/try-runtime", "module-idle-scheduler/try-runtime", @@ -397,6 +410,7 @@ try-runtime = [ "module-transaction-payment/try-runtime", "module-xcm-interface/try-runtime", "module-xnft/try-runtime", + "module-nominees-election/try-runtime", "primitives/try-runtime", @@ -409,4 +423,4 @@ no-metadata-docs = ["frame-support/no-metadata-docs"] # more types in the metadata. full-metadata-docs = ["frame-support/full-metadata-docs"] -tracing = ["module-evm/tracing", "module-evm-rpc-runtime-api/tracing"] +tracing = ["module-evm/tracing", "module-evm-rpc-runtime-api/tracing", "runtime-common/tracing"] diff --git a/runtime/karura/src/benchmarking/mod.rs b/runtime/karura/src/benchmarking/mod.rs index 4065ae3bfd..df076bf69d 100644 --- a/runtime/karura/src/benchmarking/mod.rs +++ b/runtime/karura/src/benchmarking/mod.rs @@ -62,6 +62,9 @@ pub mod evm_accounts { pub mod homa { include!("../../../mandala/src/benchmarking/homa.rs"); } +pub mod homa_validator_list { + include!("../../../mandala/src/benchmarking/homa_validator_list.rs"); +} pub mod honzon { include!("../../../mandala/src/benchmarking/honzon.rs"); } @@ -89,6 +92,9 @@ pub mod nutsfinance_stable_asset { pub mod aggregated_dex { include!("../../../mandala/src/benchmarking/aggregated_dex.rs"); } +pub mod nominees_election { + include!("../../../mandala/src/benchmarking/nominees_election.rs"); +} // orml benchmarking pub mod auction { diff --git a/runtime/karura/src/lib.rs b/runtime/karura/src/lib.rs index 8a5cbcef51..b34fed4782 100644 --- a/runtime/karura/src/lib.rs +++ b/runtime/karura/src/lib.rs @@ -139,7 +139,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { #[cfg(feature = "disable-runtime-api")] apis: sp_version::create_apis_vec![[]], transaction_version: 2, - state_version: 0, + state_version: 1, }; /// The version information used to identify this runtime when compiled @@ -171,6 +171,7 @@ parameter_types! { pub const IncentivesPalletId: PalletId = PalletId(*b"aca/inct"); pub const CollatorPotId: PalletId = PalletId(*b"aca/cpot"); pub const HonzonBridgePalletId: PalletId = PalletId(*b"aca/hzbg"); + pub const NomineesElectionId: LockIdentifier = *b"aca/nome"; // Treasury reserve pub const TreasuryReservePalletId: PalletId = PalletId(*b"aca/reve"); pub const NftPalletId: PalletId = PalletId(*b"aca/aNFT"); @@ -1320,6 +1321,9 @@ parameter_type_with_key! { ExistentialDeposits::get(currency_id) } } + PoolId::NomineesElection => { + ExistentialDeposits::get(&GetLiquidCurrencyId::get()) + } } }; } @@ -1597,6 +1601,7 @@ parameter_types! { ]; pub MintThreshold: Balance = 10 * cent(KSM); pub RedeemThreshold: Balance = 50 * cent(LKSM); + pub const BondingDuration: EraIndex = 28; } impl module_homa::Config for Runtime { @@ -1609,12 +1614,53 @@ impl module_homa::Config for Runtime { type TreasuryAccount = HomaTreasuryAccount; type DefaultExchangeRate = DefaultExchangeRate; type ActiveSubAccountsIndexList = ActiveSubAccountsIndexList; - type BondingDuration = ConstU32<28>; + type BondingDuration = BondingDuration; type MintThreshold = MintThreshold; type RedeemThreshold = RedeemThreshold; type RelayChainBlockNumber = RelaychainDataProvider; type XcmInterface = XcmInterface; type WeightInfo = weights::module_homa::WeightInfo; + type NominationsProvider = NomineesElection; +} + +parameter_types! { + pub MinBondAmount: Balance = 100 * dollar(LKSM); + pub ValidatorInsuranceThreshold: Balance = 1_000 * dollar(LKSM); +} + +impl module_homa_validator_list::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RelayChainAccountId = AccountId; + type LiquidTokenCurrency = module_currencies::Currency; + type MinBondAmount = MinBondAmount; + type BondingDuration = BondingDuration; + type ValidatorInsuranceThreshold = ValidatorInsuranceThreshold; + type GovernanceOrigin = EnsureRootOrHalfGeneralCouncil; + type LiquidStakingExchangeRateProvider = Homa; + type CurrentEra = Homa; + type WeightInfo = weights::module_homa_validator_list::WeightInfo; +} + +parameter_types! { + pub MinNomineesElectionBondThreshold: Balance = dollar(LKSM); + pub const MaxNominateesCount: u32 = 24; +} + +impl module_nominees_election::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = module_currencies::Currency; + type NomineeId = AccountId; + type PalletId = NomineesElectionId; + type MinBond = MinNomineesElectionBondThreshold; + type BondingDuration = BondingDuration; + type MaxNominateesCount = MaxNominateesCount; + type MaxUnbondingChunks = ConstU32<7>; + type NomineeFilter = HomaValidatorList; + type GovernanceOrigin = EnsureRootOrHalfGeneralCouncil; + type OnBonded = module_incentives::OnNomineesElectionBonded; + type OnUnbonded = module_incentives::OnNomineesElectionUnbonded; + type CurrentEra = Homa; + type WeightInfo = weights::module_nominees_election::WeightInfo; } pub fn create_x2_parachain_location(index: u16) -> Location { @@ -1793,6 +1839,28 @@ impl orml_parameters::Config for Runtime { type WeightInfo = (); } +parameter_types! { + // The deposit configuration for the singed migration. Specially if you want to allow any signed account to do the migration (see `SignedFilter`, these deposits should be high) + pub MigrationSignedDepositPerItem: Balance = dollar(KAR); + pub MigrationSignedDepositBase: Balance = dollar(KAR); + pub const MigrationMaxKeyLen: u32 = 512; +} + +impl pallet_state_trie_migration::Config for Runtime { + // An origin that can control the whole pallet: should be Root, or a part of your council. + type ControlOrigin = EnsureRootOrTwoThirdsTechnicalCommittee; + // specific account for the migration, can trigger the signed migrations. + type SignedFilter = frame_support::traits::NeverEnsureOrigin; + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type RuntimeHoldReason = RuntimeHoldReason; + type MaxKeyLen = MigrationMaxKeyLen; + type SignedDepositPerItem = MigrationSignedDepositPerItem; + type SignedDepositBase = MigrationSignedDepositBase; + // Replace this with weight based on your runtime. + type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight; +} + construct_runtime!( pub enum Runtime { // Core & Utility @@ -1883,6 +1951,8 @@ construct_runtime!( // Homa Homa: module_homa = 116, XcmInterface: module_xcm_interface = 117, + HomaValidatorList: module_homa_validator_list = 118, + NomineesElection: module_nominees_election = 119, // Karura Other Incentives: module_incentives = 120, @@ -1901,6 +1971,8 @@ construct_runtime!( // Parachain System, always put it at the end ParachainSystem: cumulus_pallet_parachain_system = 30, + StateTrieMigration: pallet_state_trie_migration = 254, + // Temporary Sudo: pallet_sudo = 255, } @@ -1969,6 +2041,7 @@ mod benches { [module_emergency_shutdown, benchmarking::emergency_shutdown] [module_evm, benchmarking::evm] [module_homa, benchmarking::homa] + [module_homa_validator_list, benchmarking::homa_validator_list] [module_honzon, benchmarking::honzon] [module_cdp_treasury, benchmarking::cdp_treasury] [module_collator_selection, benchmarking::collator_selection] @@ -1988,7 +2061,12 @@ mod benches { [nutsfinance_stable_asset, benchmarking::nutsfinance_stable_asset] [module_idle_scheduler, benchmarking::idle_scheduler] [module_aggregated_dex, benchmarking::aggregated_dex] + [module_nominees_election, benchmarking::nominees_election] ); + // frame_benchmarking::define_benchmarks!( + // // XCM + // [pallet_xcm, PalletXcmExtrinsicsBenchmark::] + // ); } #[cfg(not(feature = "disable-runtime-api"))] @@ -2323,6 +2401,7 @@ impl_runtime_apis! { use frame_benchmarking::{list_benchmark as frame_list_benchmark, Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; use module_nft::benchmarking::Pallet as NftBench; + // use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark; let mut list = Vec::::new(); @@ -2337,10 +2416,87 @@ impl_runtime_apis! { fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, sp_runtime::RuntimeString> { - use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark as frame_add_benchmark}; + use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError, add_benchmark as frame_add_benchmark}; use module_nft::benchmarking::Pallet as NftBench; use frame_support::traits::{WhitelistedStorageKeys, TrackedStorageKey}; + // const UNITS: Balance = 1_000_000_000_000; + // const CENTS: Balance = UNITS / 100; + + // parameter_types! { + // pub FeeAssetId: AssetId = AssetId(Location::parent()); + // pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3); + // } + // pub type PriceForParentDelivery = polkadot_runtime_common::xcm_sender::ExponentialPrice< + // FeeAssetId, + // BaseDeliveryFee, + // TransactionByteFee, + // ParachainSystem, + // >; + + // use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark; + // impl pallet_xcm::benchmarking::Config for Runtime { + // type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper< + // xcm_config::XcmConfig, + // ExistentialDepositAsset, + // PriceForParentDelivery, + // >; + // fn reachable_dest() -> Option { + // Some(Parent.into()) + // } + + // fn teleportable_asset_and_dest() -> Option<(Asset, Location)> { + // Some(( + // Asset { + // fun: Fungible(NativeTokenExistentialDeposit::get()), + // id: AssetId(Parent.into()) + // }, + // Parent.into(), + // )) + // } + + // fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> { + // None + // } + + // fn get_asset() -> Asset { + // Asset { + // id: AssetId(Location::parent()), + // fun: Fungible(UNITS), + // } + // } + // } + + // parameter_types! { + // pub ExistentialDepositAsset: Option = Some(( + // Location::parent(), + // NativeTokenExistentialDeposit::get() + // ).into()); + // } + + // impl pallet_xcm_benchmarks::Config for Runtime { + // type XcmConfig = xcm_config::XcmConfig; + // type AccountIdConverter = xcm_config::LocationToAccountId; + // type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper< + // xcm_config::XcmConfig, + // ExistentialDepositAsset, + // PriceForParentDelivery, + // >; + // fn valid_destination() -> Result { + // Ok(Location::parent()) + // } + // fn worst_case_holding(_depositable_count: u32) -> Assets { + // // just concrete assets according to relay chain. + // let assets: Vec = vec![ + // Asset { + // id: AssetId(Location::parent()), + // fun: Fungible(1_000_000 * UNITS), + // } + // ]; + // assets.into() + // } + // } + let mut whitelist: Vec = AllPalletsWithSystem::whitelisted_storage_keys(); // Treasury Account @@ -2386,7 +2542,11 @@ impl Convert<(RuntimeCall, SignedExtra), Result<(EthereumTransactionMessage, Sig valid_until, }) => { if System::block_number() > valid_until { - return Err(InvalidTransaction::Stale); + if cfg!(feature = "tracing") { + // skip check when enable tracing feature + } else { + return Err(InvalidTransaction::Stale); + } } let (_, _, _, _, mortality, check_nonce, _, _, charge) = extra.clone(); @@ -2431,7 +2591,11 @@ impl Convert<(RuntimeCall, SignedExtra), Result<(EthereumTransactionMessage, Sig decode_gas_price(gas_price, gas_limit, TxFeePerGasV2::get()).ok_or(InvalidTransaction::Stale)?; if System::block_number() > valid_until { - return Err(InvalidTransaction::Stale); + if cfg!(feature = "tracing") { + // skip check when enable tracing feature + } else { + return Err(InvalidTransaction::Stale); + } } let (_, _, _, _, mortality, check_nonce, _, _, charge) = extra.clone(); diff --git a/runtime/karura/src/weights/mod.rs b/runtime/karura/src/weights/mod.rs index 8d83dd80d2..7ddd086b16 100644 --- a/runtime/karura/src/weights/mod.rs +++ b/runtime/karura/src/weights/mod.rs @@ -32,10 +32,12 @@ pub mod module_emergency_shutdown; pub mod module_evm; pub mod module_evm_accounts; pub mod module_homa; +pub mod module_homa_validator_list; pub mod module_honzon; pub mod module_honzon_bridge; pub mod module_incentives; pub mod module_nft; +pub mod module_nominees_election; pub mod module_prices; pub mod module_session_manager; pub mod module_transaction_pause; diff --git a/runtime/karura/src/weights/module_homa_validator_list.rs b/runtime/karura/src/weights/module_homa_validator_list.rs new file mode 100644 index 0000000000..84daca4838 --- /dev/null +++ b/runtime/karura/src/weights/module_homa_validator_list.rs @@ -0,0 +1,180 @@ +// This file is part of Acala. + +// Copyright (C) 2020-2024 Acala Foundation. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +//! Autogenerated weights for module_homa_validator_list +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-04-17, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `192.168.1.2`, CPU: `` +//! WASM-EXECUTION: Compiled, CHAIN: Some("karura-dev"), DB CACHE: 1024 + +// Executed Command: +// target/production/acala +// benchmark +// pallet +// --chain=karura-dev +// --steps=50 +// --repeat=20 +// --pallet=* +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --template=./templates/runtime-weight-template.hbs +// --output=./runtime/karura/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for module_homa_validator_list. +pub struct WeightInfo(PhantomData); +impl module_homa_validator_list::WeightInfo for WeightInfo { + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::TotalLockedByGuarantor` (r:1 w:1) + // Proof: `HomaValidatorList::TotalLockedByGuarantor` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::Guarantees` (r:1 w:1) + // Proof: `HomaValidatorList::Guarantees` (`max_values`: None, `max_size`: Some(141), added: 2616, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::ValidatorBackings` (r:1 w:1) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + fn bond() -> Weight { + // Proof Size summary in bytes: + // Measured: `2388` + // Estimated: `4765` + // Minimum execution time: 36_000 nanoseconds. + Weight::from_parts(37_000_000, 4765) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) + } + // Storage: `HomaValidatorList::Guarantees` (r:1 w:1) + // Proof: `HomaValidatorList::Guarantees` (`max_values`: None, `max_size`: Some(141), added: 2616, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::ValidationData` (r:1 w:0) + // Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::LastRelayChainBlockNumber` (r:1 w:0) + // Proof: `ParachainSystem::LastRelayChainBlockNumber` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + fn unbond() -> Weight { + // Proof Size summary in bytes: + // Measured: `1506` + // Estimated: `3606` + // Minimum execution time: 19_000 nanoseconds. + Weight::from_parts(20_000_000, 3606) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: `HomaValidatorList::Guarantees` (r:1 w:1) + // Proof: `HomaValidatorList::Guarantees` (`max_values`: None, `max_size`: Some(141), added: 2616, mode: `MaxEncodedLen`) + fn rebond() -> Weight { + // Proof Size summary in bytes: + // Measured: `1044` + // Estimated: `3606` + // Minimum execution time: 8_000 nanoseconds. + Weight::from_parts(9_000_000, 3606) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: `HomaValidatorList::ValidatorBackings` (r:1 w:1) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::Guarantees` (r:1 w:1) + // Proof: `HomaValidatorList::Guarantees` (`max_values`: None, `max_size`: Some(141), added: 2616, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::ValidationData` (r:1 w:0) + // Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `HomaValidatorList::TotalLockedByGuarantor` (r:1 w:1) + // Proof: `HomaValidatorList::TotalLockedByGuarantor` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + fn withdraw_unbonded() -> Weight { + // Proof Size summary in bytes: + // Measured: `2312` + // Estimated: `4765` + // Minimum execution time: 40_000 nanoseconds. + Weight::from_parts(41_000_000, 4765) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) + } + // Storage: `HomaValidatorList::ValidatorBackings` (r:10 w:10) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// The range of component `n` is `[1, 10]`. + fn freeze(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1235 + n * (71 ±0)` + // Estimated: `990 + n * (2540 ±0)` + // Minimum execution time: 15_000 nanoseconds. + Weight::from_parts(10_990_773, 990) + // Standard Error: 8_735 + .saturating_add(Weight::from_parts(4_485_901, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 2540).saturating_mul(n.into())) + } + // Storage: `HomaValidatorList::ValidatorBackings` (r:10 w:10) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// The range of component `n` is `[1, 10]`. + fn thaw(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1235 + n * (71 ±0)` + // Estimated: `990 + n * (2540 ±0)` + // Minimum execution time: 15_000 nanoseconds. + Weight::from_parts(11_502_223, 990) + // Standard Error: 12_312 + .saturating_add(Weight::from_parts(4_428_242, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 2540).saturating_mul(n.into())) + } + // Storage: `Homa::TotalStakingBonded` (r:1 w:0) + // Proof: `Homa::TotalStakingBonded` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `Homa::ToBondPool` (r:1 w:0) + // Proof: `Homa::ToBondPool` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `Tokens::TotalIssuance` (r:1 w:1) + // Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + // Storage: `Homa::TotalVoidLiquid` (r:1 w:0) + // Proof: `Homa::TotalVoidLiquid` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `HomaValidatorList::ValidatorBackings` (r:10 w:10) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::Guarantees` (r:20 w:10) + // Proof: `HomaValidatorList::Guarantees` (`max_values`: None, `max_size`: Some(141), added: 2616, mode: `MaxEncodedLen`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::TotalLockedByGuarantor` (r:1 w:1) + // Proof: `HomaValidatorList::TotalLockedByGuarantor` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + /// The range of component `n` is `[1, 10]`. + fn slash(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2834 + n * (200 ±0)` + // Estimated: `4765 + n * (5232 ±0)` + // Minimum execution time: 57_000 nanoseconds. + Weight::from_parts(30_420_201, 4765) + // Standard Error: 30_290 + .saturating_add(Weight::from_parts(30_166_892, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes(4)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 5232).saturating_mul(n.into())) + } +} diff --git a/runtime/karura/src/weights/module_nominees_election.rs b/runtime/karura/src/weights/module_nominees_election.rs new file mode 100644 index 0000000000..4691ce7ea3 --- /dev/null +++ b/runtime/karura/src/weights/module_nominees_election.rs @@ -0,0 +1,193 @@ +// This file is part of Acala. + +// Copyright (C) 2020-2024 Acala Foundation. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +//! Autogenerated weights for module_nominees_election +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-04-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `192.168.1.3`, CPU: `` +//! WASM-EXECUTION: Compiled, CHAIN: Some("karura-dev"), DB CACHE: 1024 + +// Executed Command: +// target/production/acala +// benchmark +// pallet +// --chain=karura-dev +// --steps=50 +// --repeat=20 +// --pallet=* +// --extrinsic=* +// --wasm-execution=compiled +// --heap-pages=4096 +// --template=./templates/runtime-weight-template.hbs +// --output=./runtime/karura/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for module_nominees_election. +pub struct WeightInfo(PhantomData); +impl module_nominees_election::WeightInfo for WeightInfo { + // Storage: `NomineesElection::Ledger` (r:1 w:1) + // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + // Storage: `NomineesElection::Nominations` (r:1 w:0) + // Proof: `NomineesElection::Nominations` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::PoolInfos` (r:1 w:1) + // Proof: `Rewards::PoolInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::SharesAndWithdrawnRewards` (r:1 w:1) + // Proof: `Rewards::SharesAndWithdrawnRewards` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn bond() -> Weight { + // Proof Size summary in bytes: + // Measured: `2634` + // Estimated: `6099` + // Minimum execution time: 39_000 nanoseconds. + Weight::from_parts(40_000_000, 6099) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) + } + // Storage: `Homa::RelayChainCurrentEra` (r:1 w:0) + // Proof: `Homa::RelayChainCurrentEra` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `NomineesElection::Ledger` (r:1 w:1) + // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `NomineesElection::Nominations` (r:1 w:0) + // Proof: `NomineesElection::Nominations` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::SharesAndWithdrawnRewards` (r:1 w:1) + // Proof: `Rewards::SharesAndWithdrawnRewards` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::PoolInfos` (r:1 w:1) + // Proof: `Rewards::PoolInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn unbond() -> Weight { + // Proof Size summary in bytes: + // Measured: `2388` + // Estimated: `5853` + // Minimum execution time: 40_000 nanoseconds. + Weight::from_parts(41_000_000, 5853) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(5)) + } + // Storage: `NomineesElection::Ledger` (r:1 w:1) + // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `NomineesElection::Nominations` (r:1 w:0) + // Proof: `NomineesElection::Nominations` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::PoolInfos` (r:1 w:1) + // Proof: `Rewards::PoolInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::SharesAndWithdrawnRewards` (r:1 w:1) + // Proof: `Rewards::SharesAndWithdrawnRewards` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `c` is `[1, 7]`. + fn rebond(_c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2266` + // Estimated: `5731` + // Minimum execution time: 36_000 nanoseconds. + Weight::from_parts(37_652_826, 5731) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) + } + // Storage: `Homa::RelayChainCurrentEra` (r:1 w:0) + // Proof: `Homa::RelayChainCurrentEra` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `NomineesElection::Ledger` (r:1 w:1) + // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + /// The range of component `c` is `[1, 7]`. + fn withdraw_unbonded(c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2168` + // Estimated: `5633` + // Minimum execution time: 33_000 nanoseconds. + Weight::from_parts(34_118_349, 5633) + // Standard Error: 21_099 + .saturating_add(Weight::from_parts(96_491, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: `NomineesElection::Ledger` (r:1 w:0) + // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `HomaValidatorList::ValidatorBackings` (r:16 w:0) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + // Storage: `NomineesElection::Nominations` (r:1 w:1) + // Proof: `NomineesElection::Nominations` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `NomineesElection::Votes` (r:16 w:16) + // Proof: `NomineesElection::Votes` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `c` is `[1, 16]`. + fn nominate(c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1508 + c * (72 ±0)` + // Estimated: `4973 + c * (2547 ±0)` + // Minimum execution time: 22_000 nanoseconds. + Weight::from_parts(19_125_174, 4973) + // Standard Error: 12_496 + .saturating_add(Weight::from_parts(3_924_043, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(c.into()))) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 2547).saturating_mul(c.into())) + } + // Storage: `NomineesElection::Ledger` (r:1 w:0) + // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `NomineesElection::Nominations` (r:1 w:1) + // Proof: `NomineesElection::Nominations` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `NomineesElection::Votes` (r:16 w:16) + // Proof: `NomineesElection::Votes` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `c` is `[1, 16]`. + fn chill(c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1372 + c * (93 ±0)` + // Estimated: `4835 + c * (2569 ±0)` + // Minimum execution time: 21_000 nanoseconds. + Weight::from_parts(19_737_152, 4835) + // Standard Error: 11_893 + .saturating_add(Weight::from_parts(2_815_068, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into()))) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 2569).saturating_mul(c.into())) + } + // Storage: `NomineesElection::ReservedNominees` (r:0 w:4) + // Proof: `NomineesElection::ReservedNominees` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `c` is `[1, 4]`. + fn reset_reserved_nominees(c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1001` + // Estimated: `1001` + // Minimum execution time: 11_000 nanoseconds. + Weight::from_parts(8_689_832, 1001) + // Standard Error: 19_101 + .saturating_add(Weight::from_parts(3_395_132, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + } +} diff --git a/runtime/karura/src/weights/pallet_xcm.rs b/runtime/karura/src/weights/pallet_xcm.rs index f6e92391e1..79ba624db5 100644 --- a/runtime/karura/src/weights/pallet_xcm.rs +++ b/runtime/karura/src/weights/pallet_xcm.rs @@ -16,350 +16,281 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -//! Autogenerated weights for `pallet_xcm` +//! Autogenerated weights for pallet_xcm //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-12-19, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `ggwpez-ref-hw`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` -//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("../asset-hub-kusama-chain-spec.json")`, DB CACHE: 1024 +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 35.0.1 +//! DATE: 2024-05-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `ip-172-31-18-22`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` +//! WASM-EXECUTION: Compiled, CHAIN: Some("karura-dev"), DB CACHE: 1024 // Executed Command: -// ./target/production/polkadot +// target/production/acala // benchmark // pallet -// --chain=../asset-hub-kusama-chain-spec.json +// --chain=karura-dev // --steps=50 // --repeat=20 -// --pallet=pallet_xcm +// --pallet=* // --extrinsic=* // --wasm-execution=compiled // --heap-pages=4096 -// --output=./asset-hub-kusama-weights -// --header=./file_header.txt +// --template=./templates/runtime-weight-template.hbs +// --output=./runtime/karura/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] -#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use core::marker::PhantomData; +use sp_std::marker::PhantomData; -/// Weight functions for `pallet_xcm`. +/// Weight functions for pallet_xcm. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { - /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn send() -> Weight { // Proof Size summary in bytes: - // Measured: `145` - // Estimated: `3610` - // Minimum execution time: 24_856_000 picoseconds. - Weight::from_parts(25_639_000, 0) - .saturating_add(Weight::from_parts(0, 3610)) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(2)) + // Measured: `147` + // Estimated: `3612` + // Minimum execution time: 17_140 nanoseconds. + Weight::from_parts(17_826_000, 3612) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) - /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `Benchmark::Override` (r:0 w:0) + // Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`) fn teleport_assets() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `1489` - // Minimum execution time: 20_000_000 picoseconds. - Weight::from_parts(20_357_000, 0) - .saturating_add(Weight::from_parts(0, 1489)) - .saturating_add(T::DbWeight::get().reads(1)) + // Estimated: `0` + // Minimum execution time: 18_446_744_073_709_551 nanoseconds. + Weight::from_parts(18_446_744_073_709_551_000, 0) } - /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) - /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `Benchmark::Override` (r:0 w:0) + // Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`) fn reserve_transfer_assets() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `1489` - // Minimum execution time: 14_600_000 picoseconds. - Weight::from_parts(15_045_000, 0) - .saturating_add(Weight::from_parts(0, 1489)) - .saturating_add(T::DbWeight::get().reads(1)) + // Estimated: `0` + // Minimum execution time: 18_446_744_073_709_551 nanoseconds. + Weight::from_parts(18_446_744_073_709_551_000, 0) } - /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) - /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Assets::Asset` (r:1 w:1) - /// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `Assets::Account` (r:2 w:2) - /// Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:2 w:2) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `Benchmark::Override` (r:0 w:0) + // Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`) fn transfer_assets() -> Weight { // Proof Size summary in bytes: - // Measured: `496` - // Estimated: `6208` - // Minimum execution time: 146_932_000 picoseconds. - Weight::from_parts(153_200_000, 0) - .saturating_add(Weight::from_parts(0, 6208)) - .saturating_add(T::DbWeight::get().reads(12)) - .saturating_add(T::DbWeight::get().writes(7)) + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 18_446_744_073_709_551 nanoseconds. + Weight::from_parts(18_446_744_073_709_551_000, 0) } - /// Storage: `Benchmark::Override` (r:0 w:0) - /// Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Benchmark::Override` (r:0 w:0) + // Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`) fn execute() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 18_446_744_073_709_551_000 picoseconds. + // Minimum execution time: 18_446_744_073_709_551 nanoseconds. Weight::from_parts(18_446_744_073_709_551_000, 0) - .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `PolkadotXcm::SupportedVersion` (r:0 w:1) - /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:0 w:1) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) fn force_xcm_version() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_899_000 picoseconds. - Weight::from_parts(7_127_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Minimum execution time: 5_533 nanoseconds. + Weight::from_parts(5_754_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `PolkadotXcm::SafeXcmVersion` (r:0 w:1) - /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn force_default_xcm_version() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_198_000 picoseconds. - Weight::from_parts(2_440_000, 0) - .saturating_add(Weight::from_parts(0, 0)) - .saturating_add(T::DbWeight::get().writes(1)) + // Minimum execution time: 1_704 nanoseconds. + Weight::from_parts(1_848_000, 0) } - /// Storage: `PolkadotXcm::VersionNotifiers` (r:1 w:1) - /// Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::QueryCounter` (r:1 w:1) - /// Proof: `PolkadotXcm::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::Queries` (r:0 w:1) - /// Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionNotifiers` (r:1 w:1) + // Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::QueryCounter` (r:1 w:1) + // Proof: `PolkadotXcm::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::Queries` (r:0 w:1) + // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) fn force_subscribe_version_notify() -> Weight { // Proof Size summary in bytes: - // Measured: `145` - // Estimated: `3610` - // Minimum execution time: 29_009_000 picoseconds. - Weight::from_parts(30_280_000, 0) - .saturating_add(Weight::from_parts(0, 3610)) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(5)) + // Measured: `147` + // Estimated: `3612` + // Minimum execution time: 22_331 nanoseconds. + Weight::from_parts(23_040_000, 3612) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) } - /// Storage: `PolkadotXcm::VersionNotifiers` (r:1 w:1) - /// Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::Queries` (r:0 w:1) - /// Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionNotifiers` (r:1 w:1) + // Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::Queries` (r:0 w:1) + // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) fn force_unsubscribe_version_notify() -> Weight { // Proof Size summary in bytes: - // Measured: `363` - // Estimated: `3828` - // Minimum execution time: 30_806_000 picoseconds. - Weight::from_parts(31_646_000, 0) - .saturating_add(Weight::from_parts(0, 3828)) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(4)) + // Measured: `205` + // Estimated: `3670` + // Minimum execution time: 22_398 nanoseconds. + Weight::from_parts(22_877_000, 3670) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: `PolkadotXcm::XcmExecutionSuspended` (r:0 w:1) - /// Proof: `PolkadotXcm::XcmExecutionSuspended` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::XcmExecutionSuspended` (r:0 w:1) + // Proof: `PolkadotXcm::XcmExecutionSuspended` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn force_suspension() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_139_000 picoseconds. - Weight::from_parts(2_319_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Minimum execution time: 1_738 nanoseconds. + Weight::from_parts(1_902_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `PolkadotXcm::SupportedVersion` (r:4 w:2) - /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:5 w:2) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) fn migrate_supported_version() -> Weight { // Proof Size summary in bytes: - // Measured: `162` - // Estimated: `11052` - // Minimum execution time: 16_833_000 picoseconds. - Weight::from_parts(17_423_000, 0) - .saturating_add(Weight::from_parts(0, 11052)) - .saturating_add(T::DbWeight::get().reads(4)) + // Measured: `22` + // Estimated: `13387` + // Minimum execution time: 17_278 nanoseconds. + Weight::from_parts(18_006_000, 13387) + .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: `PolkadotXcm::VersionNotifiers` (r:4 w:2) - /// Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionNotifiers` (r:5 w:2) + // Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) fn migrate_version_notifiers() -> Weight { // Proof Size summary in bytes: - // Measured: `166` - // Estimated: `11056` - // Minimum execution time: 17_002_000 picoseconds. - Weight::from_parts(17_667_000, 0) - .saturating_add(Weight::from_parts(0, 11056)) - .saturating_add(T::DbWeight::get().reads(4)) + // Measured: `26` + // Estimated: `13391` + // Minimum execution time: 17_180 nanoseconds. + Weight::from_parts(17_820_000, 13391) + .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: `PolkadotXcm::VersionNotifyTargets` (r:5 w:0) - /// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:6 w:0) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) fn already_notified_target() -> Weight { // Proof Size summary in bytes: - // Measured: `173` - // Estimated: `13538` - // Minimum execution time: 18_497_000 picoseconds. - Weight::from_parts(18_995_000, 0) - .saturating_add(Weight::from_parts(0, 13538)) - .saturating_add(T::DbWeight::get().reads(5)) + // Measured: `36` + // Estimated: `15876` + // Minimum execution time: 20_003 nanoseconds. + Weight::from_parts(20_416_000, 15876) + .saturating_add(T::DbWeight::get().reads(6)) } - /// Storage: `PolkadotXcm::VersionNotifyTargets` (r:2 w:1) - /// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:2 w:1) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn notify_current_targets() -> Weight { // Proof Size summary in bytes: - // Measured: `212` - // Estimated: `6152` - // Minimum execution time: 27_060_000 picoseconds. - Weight::from_parts(27_662_000, 0) - .saturating_add(Weight::from_parts(0, 6152)) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(3)) + // Measured: `180` + // Estimated: `6120` + // Minimum execution time: 22_811 nanoseconds. + Weight::from_parts(23_421_000, 6120) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: `PolkadotXcm::VersionNotifyTargets` (r:3 w:0) - /// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:4 w:0) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) fn notify_target_migration_fail() -> Weight { // Proof Size summary in bytes: - // Measured: `206` - // Estimated: `8621` - // Minimum execution time: 9_157_000 picoseconds. - Weight::from_parts(9_437_000, 0) - .saturating_add(Weight::from_parts(0, 8621)) - .saturating_add(T::DbWeight::get().reads(3)) + // Measured: `69` + // Estimated: `10959` + // Minimum execution time: 12_866 nanoseconds. + Weight::from_parts(13_542_000, 10959) + .saturating_add(T::DbWeight::get().reads(4)) } - /// Storage: `PolkadotXcm::VersionNotifyTargets` (r:4 w:2) - /// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:5 w:2) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) fn migrate_version_notify_targets() -> Weight { // Proof Size summary in bytes: - // Measured: `173` - // Estimated: `11063` - // Minimum execution time: 17_430_000 picoseconds. - Weight::from_parts(17_727_000, 0) - .saturating_add(Weight::from_parts(0, 11063)) - .saturating_add(T::DbWeight::get().reads(4)) + // Measured: `33` + // Estimated: `13398` + // Minimum execution time: 17_531 nanoseconds. + Weight::from_parts(18_412_000, 13398) + .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: `PolkadotXcm::VersionNotifyTargets` (r:4 w:2) - /// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:5 w:2) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn migrate_and_notify_old_targets() -> Weight { // Proof Size summary in bytes: - // Measured: `215` - // Estimated: `11105` - // Minimum execution time: 33_562_000 picoseconds. - Weight::from_parts(34_612_000, 0) - .saturating_add(Weight::from_parts(0, 11105)) - .saturating_add(T::DbWeight::get().reads(10)) - .saturating_add(T::DbWeight::get().writes(4)) + // Measured: `180` + // Estimated: `13545` + // Minimum execution time: 32_435 nanoseconds. + Weight::from_parts(33_531_000, 13545) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: `XcmPallet::QueryCounter` (r:1 w:1) - /// Proof: `XcmPallet::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::Queries` (r:0 w:1) - /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::QueryCounter` (r:1 w:1) + // Proof: `PolkadotXcm::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::Queries` (r:0 w:1) + // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) fn new_query() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `1485` - // Minimum execution time: 2_947_000 picoseconds. - Weight::from_parts(3_117_000, 0) - .saturating_add(Weight::from_parts(0, 1485)) + // Minimum execution time: 2_224 nanoseconds. + Weight::from_parts(2_421_000, 1485) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: `XcmPallet::Queries` (r:1 w:1) - /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::Queries` (r:1 w:1) + // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) fn take_response() -> Weight { // Proof Size summary in bytes: // Measured: `7576` // Estimated: `11041` - // Minimum execution time: 24_595_000 picoseconds. - Weight::from_parts(24_907_000, 0) - .saturating_add(Weight::from_parts(0, 11041)) + // Minimum execution time: 20_497 nanoseconds. + Weight::from_parts(20_855_000, 11041) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + // Storage: `EVM::XcmOrigin` (r:1 w:1) + // Proof: `EVM::XcmOrigin` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::AssetTraps` (r:1 w:1) + // Proof: `PolkadotXcm::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `Tokens::TotalIssuance` (r:1 w:1) + // Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) fn claim_assets() -> Weight { // Proof Size summary in bytes: - // Measured: `7576` - // Estimated: `11041` - // Minimum execution time: 24_595_000 picoseconds. - Weight::from_parts(24_907_000, 0) - .saturating_add(Weight::from_parts(0, 11041)) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + // Measured: `233` + // Estimated: `3698` + // Minimum execution time: 34_391 nanoseconds. + Weight::from_parts(35_825_000, 3698) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) } } diff --git a/runtime/mandala/Cargo.toml b/runtime/mandala/Cargo.toml index f8cb1333d0..776918b1f4 100644 --- a/runtime/mandala/Cargo.toml +++ b/runtime/mandala/Cargo.toml @@ -75,6 +75,7 @@ xcm = { workspace = true } xcm-executor = { workspace = true } xcm-builder = { workspace = true } pallet-xcm = { workspace = true } +pallet-xcm-benchmarks = { workspace = true, optional = true } polkadot-runtime-common = { workspace = true } parachains-common = { workspace = true } @@ -123,6 +124,7 @@ module-prices = { workspace = true } module-incentives = { workspace = true } module-support = { workspace = true } module-homa = { workspace = true } +module-homa-validator-list = { workspace = true } module-xcm-interface = { workspace = true } module-nominees-election = { workspace = true } module-session-manager = { workspace = true } @@ -218,6 +220,7 @@ std = [ "cumulus-primitives-utility/std", "pallet-xcm/std", + "pallet-xcm-benchmarks?/std", "parachain-info/std", "polkadot-parachain-primitives/std", "xcm-builder/std", @@ -262,6 +265,7 @@ std = [ "module-evm-utility/std", "module-evm/std", "module-homa/std", + "module-homa-validator-list/std", "module-honzon/std", "module-idle-scheduler/std", "module-incentives/std", @@ -310,7 +314,9 @@ runtime-benchmarks = [ "cumulus-pallet-parachain-system/runtime-benchmarks", "cumulus-pallet-xcmp-queue/runtime-benchmarks", + "cumulus-primitives-utility/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", + "pallet-xcm-benchmarks/runtime-benchmarks", "polkadot-parachain-primitives/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", @@ -416,6 +422,7 @@ try-runtime = [ "module-evm-bridge/try-runtime", "module-evm/try-runtime", "module-homa/try-runtime", + "module-homa-validator-list/try-runtime", "module-honzon/try-runtime", "module-idle-scheduler/try-runtime", "module-incentives/try-runtime", @@ -440,4 +447,4 @@ no-metadata-docs = ["frame-support/no-metadata-docs"] # more types in the metadata. full-metadata-docs = ["frame-support/full-metadata-docs"] -tracing = ["module-evm/tracing", "module-evm-rpc-runtime-api/tracing"] +tracing = ["module-evm/tracing", "module-evm-rpc-runtime-api/tracing", "runtime-common/tracing"] diff --git a/runtime/mandala/src/benchmarking/homa.rs b/runtime/mandala/src/benchmarking/homa.rs index 9e589cb56a..64b02c3e8d 100644 --- a/runtime/mandala/src/benchmarking/homa.rs +++ b/runtime/mandala/src/benchmarking/homa.rs @@ -56,6 +56,7 @@ runtime_benchmarks! { Some(Rate::saturating_from_rational(1, 100)), Some(Rate::saturating_from_rational(20, 100)), None, + None, )?; RelaychainDataProvider::::set_block_number(10); Homa::update_bump_era_params(RawOrigin::Root.into(), None, Some(1))?; @@ -76,6 +77,7 @@ runtime_benchmarks! { Some(Rate::saturating_from_rational(1, 10000)), None, None, + None, )?; set_balance(STAKING, &caller, amount * 2); }: _(RawOrigin::Signed(caller), amount) @@ -100,6 +102,7 @@ runtime_benchmarks! { Some(Rate::saturating_from_rational(1, 10000)), None, None, + None, )?; Homa::mint(RawOrigin::Signed(minter.clone()).into(), mint_amount)?; @@ -129,7 +132,9 @@ runtime_benchmarks! { Some(1_000_000_000_000), Some(Rate::saturating_from_rational(1, 100)), Some(Rate::saturating_from_rational(1, 100)), - Some(Rate::saturating_from_rational(1, 100))) + Some(Rate::saturating_from_rational(1, 100)), + Some(7) + ) update_bump_era_params { RelaychainDataProvider::::set_block_number(10000); diff --git a/runtime/mandala/src/benchmarking/homa_validator_list.rs b/runtime/mandala/src/benchmarking/homa_validator_list.rs new file mode 100644 index 0000000000..be95d649f8 --- /dev/null +++ b/runtime/mandala/src/benchmarking/homa_validator_list.rs @@ -0,0 +1,152 @@ +// This file is part of Acala. + +// Copyright (C) 2020-2024 Acala Foundation. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +use crate::{ + AccountId, Balance, BondingDuration, Homa, HomaValidatorList, MinBondAmount, Runtime, ValidatorInsuranceThreshold, +}; + +use super::utils::{set_balance, LIQUID}; +use frame_benchmarking::{account, whitelisted_caller}; +use frame_system::RawOrigin; +use module_homa_validator_list::SlashInfo; +use orml_benchmarking::runtime_benchmarks; +use sp_std::{prelude::*, vec}; + +const SEED: u32 = 0; + +runtime_benchmarks! { + { Runtime, module_homa_validator_list } + + bond { + let caller: AccountId = whitelisted_caller(); + let validator: AccountId = account("validator", 0, SEED); + set_balance(LIQUID, &caller, MinBondAmount::get() * 10); + }: _(RawOrigin::Signed(caller), validator, MinBondAmount::get()) + + unbond { + let caller: AccountId = whitelisted_caller(); + let validator: AccountId = account("validator", 0, SEED); + let amount: Balance = MinBondAmount::get() * 10; + + set_balance(LIQUID, &caller, amount); + HomaValidatorList::bond( + RawOrigin::Signed(caller.clone()).into(), + validator.clone(), + amount + )?; + }: _(RawOrigin::Signed(caller), validator, amount) + + rebond { + let caller: AccountId = whitelisted_caller(); + let validator: AccountId = account("validator", 0, SEED); + + set_balance(LIQUID, &caller, MinBondAmount::get() * 10); + HomaValidatorList::bond( + RawOrigin::Signed(caller.clone()).into(), + validator.clone(), + MinBondAmount::get() * 10 + )?; + HomaValidatorList::unbond( + RawOrigin::Signed(caller.clone()).into(), + validator.clone(), + MinBondAmount::get() * 5 + )?; + }: _(RawOrigin::Signed(caller), validator, MinBondAmount::get() * 5) + + withdraw_unbonded { + let caller: AccountId = whitelisted_caller(); + let validator: AccountId = account("validator", 0, SEED); + + set_balance(LIQUID, &caller, MinBondAmount::get() * 10); + HomaValidatorList::bond( + RawOrigin::Signed(caller.clone()).into(), + validator.clone(), + MinBondAmount::get() * 10 + )?; + HomaValidatorList::unbond( + RawOrigin::Signed(caller.clone()).into(), + validator.clone(), + MinBondAmount::get() * 5 + )?; + Homa::force_bump_current_era(RawOrigin::Root.into(), BondingDuration::get())?; + }: _(RawOrigin::Signed(caller), validator) + + freeze { + let n in 1 .. 10; + let caller: AccountId = whitelisted_caller(); + let mut validators: Vec = vec![]; + + set_balance(LIQUID, &caller, MinBondAmount::get() * 100); + for i in 0 .. n { + let validator: AccountId = account("validator", i, SEED); + HomaValidatorList::bond( + RawOrigin::Signed(caller.clone()).into(), + validator.clone(), + MinBondAmount::get() + )?; + validators.push(validator); + } + }: _(RawOrigin::Root, validators) + + thaw { + let n in 1 .. 10; + let caller: AccountId = whitelisted_caller(); + let mut validators: Vec = vec![]; + + set_balance(LIQUID, &caller, MinBondAmount::get() * 100); + for i in 0 .. n { + let validator: AccountId = account("validator", i, SEED); + HomaValidatorList::bond( + RawOrigin::Signed(caller.clone()).into(), + validator.clone(), + MinBondAmount::get() + )?; + validators.push(validator); + } + HomaValidatorList::freeze(RawOrigin::Root.into(), validators.clone())?; + }: _(RawOrigin::Root, validators) + + slash { + let n in 1 .. 10; + let caller: AccountId = whitelisted_caller(); + let mut slashes: Vec> = vec![]; + + set_balance(LIQUID, &caller, ValidatorInsuranceThreshold::get() * 100); + for i in 0 .. n { + let validator: AccountId = account("validator", i, SEED); + HomaValidatorList::bond( + RawOrigin::Signed(caller.clone()).into(), + validator.clone(), + ValidatorInsuranceThreshold::get() * 10 + )?; + slashes.push(SlashInfo{ + validator, + relaychain_token_amount: ValidatorInsuranceThreshold::get() * 9 + }); + } + }: _(RawOrigin::Root, slashes) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::benchmarking::utils::tests::new_test_ext; + use orml_benchmarking::impl_benchmark_test_suite; + + impl_benchmark_test_suite!(new_test_ext(),); +} diff --git a/runtime/mandala/src/benchmarking/mod.rs b/runtime/mandala/src/benchmarking/mod.rs index 7c9b57d54e..6de441f595 100644 --- a/runtime/mandala/src/benchmarking/mod.rs +++ b/runtime/mandala/src/benchmarking/mod.rs @@ -40,6 +40,7 @@ pub mod emergency_shutdown; pub mod evm; pub mod evm_accounts; pub mod homa; +pub mod homa_validator_list; pub mod honzon; pub mod idle_scheduler; pub mod incentives; diff --git a/runtime/mandala/src/benchmarking/nominees_election.rs b/runtime/mandala/src/benchmarking/nominees_election.rs index 1d06aa1a10..bdf166cb62 100644 --- a/runtime/mandala/src/benchmarking/nominees_election.rs +++ b/runtime/mandala/src/benchmarking/nominees_election.rs @@ -16,14 +16,17 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::{AccountId, MinCouncilBondThreshold, NomineesElection, Runtime}; +use crate::{ + AccountId, Balance, BondingDuration, Homa, HomaValidatorList, MinNomineesElectionBondThreshold, NomineesElection, + Runtime, ValidatorInsuranceThreshold, +}; use super::utils::{set_balance, LIQUID}; use frame_benchmarking::{account, whitelisted_caller}; -use frame_support::traits::Get; +use frame_support::{traits::Get, BoundedVec}; use frame_system::RawOrigin; -use module_support::OnNewEra; use orml_benchmarking::runtime_benchmarks; +use sp_runtime::SaturatedConversion; use sp_std::prelude::*; const SEED: u32 = 0; @@ -33,56 +36,75 @@ runtime_benchmarks! { bond { let caller: AccountId = whitelisted_caller(); - set_balance(LIQUID, &caller, 2 * MinCouncilBondThreshold::get()); - }: _(RawOrigin::Signed(caller), MinCouncilBondThreshold::get()) + set_balance(LIQUID, &caller, 2 * MinNomineesElectionBondThreshold::get()); + }: _(RawOrigin::Signed(caller), MinNomineesElectionBondThreshold::get()) unbond { let caller: AccountId = whitelisted_caller(); - set_balance(LIQUID, &caller, 2 * MinCouncilBondThreshold::get()); - NomineesElection::bond(RawOrigin::Signed(caller.clone()).into(), MinCouncilBondThreshold::get())?; - }: _(RawOrigin::Signed(caller), MinCouncilBondThreshold::get()) + set_balance(LIQUID, &caller, 2 * MinNomineesElectionBondThreshold::get()); + NomineesElection::bond(RawOrigin::Signed(caller.clone()).into(), MinNomineesElectionBondThreshold::get())?; + }: _(RawOrigin::Signed(caller), MinNomineesElectionBondThreshold::get()) rebond { let c in 1 .. ::MaxUnbondingChunks::get(); let caller: AccountId = whitelisted_caller(); - set_balance(LIQUID, &caller, 2 * MinCouncilBondThreshold::get()); - NomineesElection::bond(RawOrigin::Signed(caller.clone()).into(), 2 * MinCouncilBondThreshold::get())?; + set_balance(LIQUID, &caller, 2 * MinNomineesElectionBondThreshold::get()); + NomineesElection::bond(RawOrigin::Signed(caller.clone()).into(), 2 * MinNomineesElectionBondThreshold::get())?; for _ in 0..c { - NomineesElection::unbond(RawOrigin::Signed(caller.clone()).into(), MinCouncilBondThreshold::get()/c as u128)?; + NomineesElection::unbond(RawOrigin::Signed(caller.clone()).into(), MinNomineesElectionBondThreshold::get()/c as u128)?; } - }: _(RawOrigin::Signed(caller), MinCouncilBondThreshold::get()) + }: _(RawOrigin::Signed(caller), MinNomineesElectionBondThreshold::get()) withdraw_unbonded { let c in 1 .. ::MaxUnbondingChunks::get(); let caller: AccountId = whitelisted_caller(); - set_balance(LIQUID, &caller, 2 * MinCouncilBondThreshold::get()); - NomineesElection::bond(RawOrigin::Signed(caller.clone()).into(), 2 * MinCouncilBondThreshold::get())?; + set_balance(LIQUID, &caller, 2 * MinNomineesElectionBondThreshold::get()); + NomineesElection::bond(RawOrigin::Signed(caller.clone()).into(), 2 * MinNomineesElectionBondThreshold::get())?; for _ in 0..c { - NomineesElection::unbond(RawOrigin::Signed(caller.clone()).into(), MinCouncilBondThreshold::get()/c as u128)?; + NomineesElection::unbond(RawOrigin::Signed(caller.clone()).into(), MinNomineesElectionBondThreshold::get()/c as u128)?; } - NomineesElection::on_new_era(1); + Homa::force_bump_current_era(RawOrigin::Root.into(), BondingDuration::get())?; }: _(RawOrigin::Signed(caller)) nominate { - let c in 1 .. ::NominateesCount::get(); - let targets = (0..c).map(|c| account("nominatees", c, SEED)).collect::>(); + let c in 1 .. ::MaxNominateesCount::get(); + let targets: Vec = (0..c).map(|c| account("nominatees", c, SEED)).collect(); + let caller: AccountId = whitelisted_caller(); + set_balance(LIQUID, &caller, 2 * MinNomineesElectionBondThreshold::get() + ValidatorInsuranceThreshold::get() * targets.len().saturated_into::()); + + for validator in targets.iter() { + HomaValidatorList::bond(RawOrigin::Signed(caller.clone()).into(), validator.clone(), ValidatorInsuranceThreshold::get())?; + } let caller: AccountId = whitelisted_caller(); - set_balance(LIQUID, &caller, 2 * MinCouncilBondThreshold::get()); - NomineesElection::bond(RawOrigin::Signed(caller.clone()).into(), MinCouncilBondThreshold::get())?; + NomineesElection::bond(RawOrigin::Signed(caller.clone()).into(), MinNomineesElectionBondThreshold::get())?; }: _(RawOrigin::Signed(caller), targets) chill { - let c in 1 .. ::NominateesCount::get(); - let targets = (0..c).map(|c| account("nominatees", c, SEED)).collect::>(); + let c in 1 .. ::MaxNominateesCount::get(); + let targets: Vec = (0..c).map(|c| account("nominatees", c, SEED)).collect(); let caller: AccountId = whitelisted_caller(); - set_balance(LIQUID, &caller, 2 * MinCouncilBondThreshold::get()); - NomineesElection::bond(RawOrigin::Signed(caller.clone()).into(), MinCouncilBondThreshold::get())?; + set_balance(LIQUID, &caller, 2 * MinNomineesElectionBondThreshold::get() + ValidatorInsuranceThreshold::get() * targets.len().saturated_into::()); + + for validator in targets.iter() { + HomaValidatorList::bond(RawOrigin::Signed(caller.clone()).into(), validator.clone(), ValidatorInsuranceThreshold::get())?; + } + + NomineesElection::bond(RawOrigin::Signed(caller.clone()).into(), MinNomineesElectionBondThreshold::get())?; NomineesElection::nominate(RawOrigin::Signed(caller.clone()).into(), targets)?; }: _(RawOrigin::Signed(caller)) + + reset_reserved_nominees { + let c in 1 .. 4; + let updates: Vec<(u16, BoundedVec::MaxNominateesCount>)> = (0..c).map(|c| { + let reserved: BoundedVec::MaxNominateesCount> = + (0..::MaxNominateesCount::get()).map(|c| account("nominatees", c, SEED)).collect::>().try_into().unwrap(); + (c.saturated_into(), reserved) + }).collect(); + }: _(RawOrigin::Root, updates) } #[cfg(test)] diff --git a/runtime/mandala/src/lib.rs b/runtime/mandala/src/lib.rs index f83730c614..8aa8905cb0 100644 --- a/runtime/mandala/src/lib.rs +++ b/runtime/mandala/src/lib.rs @@ -49,7 +49,7 @@ use frame_support::{ use frame_system::{EnsureRoot, EnsureSigned, RawOrigin}; use module_asset_registry::{AssetIdMaps, EvmErc20InfoMapping}; use module_cdp_engine::CollateralCurrencyIds; -use module_currencies::{BasicCurrencyAdapter, Currency}; +use module_currencies::BasicCurrencyAdapter; use module_evm::{runner::RunnerExtended, CallInfo, CreateInfo, EvmChainId, EvmTask}; use module_evm_accounts::EvmAddressMapping; use module_relaychain::RelayChainCallBuilder; @@ -139,7 +139,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { #[cfg(feature = "disable-runtime-api")] apis: sp_version::create_apis_vec![[]], transaction_version: 3, - state_version: 0, + state_version: 1, }; /// The version information used to identify this runtime when compiled @@ -1375,6 +1375,9 @@ parameter_type_with_key! { ExistentialDeposits::get(currency_id) } } + PoolId::NomineesElection => { + ExistentialDeposits::get(&GetLiquidCurrencyId::get()) + } } }; } @@ -1427,6 +1430,7 @@ parameter_types! { ]; pub MintThreshold: Balance = dollar(DOT); pub RedeemThreshold: Balance = 10 * dollar(LDOT); + pub const BondingDuration: EraIndex = 28; } impl module_homa::Config for Runtime { @@ -1439,12 +1443,53 @@ impl module_homa::Config for Runtime { type TreasuryAccount = HomaTreasuryAccount; type DefaultExchangeRate = DefaultExchangeRate; type ActiveSubAccountsIndexList = ActiveSubAccountsIndexList; - type BondingDuration = ConstU32<28>; + type BondingDuration = BondingDuration; type MintThreshold = MintThreshold; type RedeemThreshold = RedeemThreshold; type RelayChainBlockNumber = RelaychainDataProvider; type XcmInterface = XcmInterface; type WeightInfo = weights::module_homa::WeightInfo; + type NominationsProvider = NomineesElection; +} + +parameter_types! { + pub MinBondAmount: Balance = 1_000 * dollar(LDOT); + pub ValidatorInsuranceThreshold: Balance = 10_000 * dollar(LDOT); +} + +impl module_homa_validator_list::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RelayChainAccountId = AccountId; + type LiquidTokenCurrency = module_currencies::Currency; + type MinBondAmount = MinBondAmount; + type BondingDuration = BondingDuration; + type ValidatorInsuranceThreshold = ValidatorInsuranceThreshold; + type GovernanceOrigin = EnsureRootOrHalfGeneralCouncil; + type LiquidStakingExchangeRateProvider = Homa; + type CurrentEra = Homa; + type WeightInfo = weights::module_homa_validator_list::WeightInfo; +} + +parameter_types! { + pub MinNomineesElectionBondThreshold: Balance = 10 * dollar(LDOT); + pub const MaxNominateesCount: u32 = 16; +} + +impl module_nominees_election::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = module_currencies::Currency; + type NomineeId = AccountId; + type PalletId = NomineesElectionId; + type MinBond = MinNomineesElectionBondThreshold; + type BondingDuration = BondingDuration; + type MaxNominateesCount = MaxNominateesCount; + type MaxUnbondingChunks = ConstU32<7>; + type NomineeFilter = HomaValidatorList; + type GovernanceOrigin = EnsureRootOrHalfGeneralCouncil; + type OnBonded = module_incentives::OnNomineesElectionBonded; + type OnUnbonded = module_incentives::OnNomineesElectionUnbonded; + type CurrentEra = Homa; + type WeightInfo = weights::module_nominees_election::WeightInfo; } parameter_types! { @@ -1471,23 +1516,6 @@ impl module_xcm_interface::Config for Runtime { type AccountIdToLocation = xcm_config::AccountIdToLocation; } -parameter_types! { - pub MinCouncilBondThreshold: Balance = dollar(LDOT); -} - -impl module_nominees_election::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Currency = Currency; - type NomineeId = AccountId; - type PalletId = NomineesElectionId; - type MinBond = MinCouncilBondThreshold; - type BondingDuration = ConstU32<28>; - type NominateesCount = ConstU32<7>; - type MaxUnbondingChunks = ConstU32<7>; - type NomineeFilter = runtime_common::DummyNomineeFilter; - type WeightInfo = weights::module_nominees_election::WeightInfo; -} - parameter_types! { pub CreateClassDeposit: Balance = 20 * dollar(ACA); pub CreateTokenDeposit: Balance = 2 * dollar(ACA); @@ -1891,7 +1919,11 @@ impl Convert<(RuntimeCall, SignedExtra), Result<(EthereumTransactionMessage, Sig valid_until, }) => { if System::block_number() > valid_until { - return Err(InvalidTransaction::Stale); + if cfg!(feature = "tracing") { + // skip check when enable tracing feature + } else { + return Err(InvalidTransaction::Stale); + } } let (_, _, _, _, mortality, check_nonce, _, _, charge) = extra.clone(); @@ -1936,7 +1968,11 @@ impl Convert<(RuntimeCall, SignedExtra), Result<(EthereumTransactionMessage, Sig decode_gas_price(gas_price, gas_limit, TxFeePerGasV2::get()).ok_or(InvalidTransaction::Stale)?; if System::block_number() > valid_until { - return Err(InvalidTransaction::Stale); + if cfg!(feature = "tracing") { + // skip check when enable tracing feature + } else { + return Err(InvalidTransaction::Stale); + } } let (_, _, _, _, mortality, check_nonce, _, _, charge) = extra.clone(); @@ -2097,6 +2133,7 @@ construct_runtime!( NomineesElection: module_nominees_election = 131, Homa: module_homa = 136, XcmInterface: module_xcm_interface = 137, + HomaValidatorList: module_homa_validator_list = 138, // Acala Other Incentives: module_incentives = 140, @@ -2161,6 +2198,7 @@ mod benches { [module_emergency_shutdown, benchmarking::emergency_shutdown] [module_evm, benchmarking::evm] [module_homa, benchmarking::homa] + [module_homa_validator_list, benchmarking::homa_validator_list] [module_honzon, benchmarking::honzon] [module_cdp_treasury, benchmarking::cdp_treasury] [module_collator_selection, benchmarking::collator_selection] @@ -2182,6 +2220,10 @@ mod benches { [module_idle_scheduler, benchmarking::idle_scheduler] [module_aggregated_dex, benchmarking::aggregated_dex] ); + // frame_benchmarking::define_benchmarks!( + // // XCM + // [pallet_xcm, PalletXcmExtrinsicsBenchmark::] + // ); } #[cfg(not(feature = "disable-runtime-api"))] @@ -2517,6 +2559,7 @@ impl_runtime_apis! { use frame_support::traits::StorageInfoTrait; use module_nft::benchmarking::Pallet as NftBench; + // use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark; let mut list = Vec::::new(); @@ -2531,10 +2574,87 @@ impl_runtime_apis! { fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, sp_runtime::RuntimeString> { - use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark as frame_add_benchmark}; + use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError, add_benchmark as frame_add_benchmark}; use module_nft::benchmarking::Pallet as NftBench; use frame_support::traits::{WhitelistedStorageKeys, TrackedStorageKey}; + // const UNITS: Balance = 1_000_000_000_000; + // const CENTS: Balance = UNITS / 100; + + // parameter_types! { + // pub FeeAssetId: AssetId = AssetId(Location::parent()); + // pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3); + // } + // pub type PriceForParentDelivery = polkadot_runtime_common::xcm_sender::ExponentialPrice< + // FeeAssetId, + // BaseDeliveryFee, + // TransactionByteFee, + // ParachainSystem, + // >; + + // use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark; + // impl pallet_xcm::benchmarking::Config for Runtime { + // type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper< + // xcm_config::XcmConfig, + // ExistentialDepositAsset, + // PriceForParentDelivery, + // >; + // fn reachable_dest() -> Option { + // Some(Parent.into()) + // } + + // fn teleportable_asset_and_dest() -> Option<(Asset, Location)> { + // Some(( + // Asset { + // fun: Fungible(NativeTokenExistentialDeposit::get()), + // id: AssetId(Parent.into()) + // }, + // Parent.into(), + // )) + // } + + // fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> { + // None + // } + + // fn get_asset() -> Asset { + // Asset { + // id: AssetId(Location::parent()), + // fun: Fungible(UNITS), + // } + // } + // } + + // parameter_types! { + // pub ExistentialDepositAsset: Option = Some(( + // Location::parent(), + // NativeTokenExistentialDeposit::get() + // ).into()); + // } + + // impl pallet_xcm_benchmarks::Config for Runtime { + // type XcmConfig = xcm_config::XcmConfig; + // type AccountIdConverter = xcm_config::LocationToAccountId; + // type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper< + // xcm_config::XcmConfig, + // ExistentialDepositAsset, + // PriceForParentDelivery, + // >; + // fn valid_destination() -> Result { + // Ok(Location::parent()) + // } + // fn worst_case_holding(_depositable_count: u32) -> Assets { + // // just concrete assets according to relay chain. + // let assets: Vec = vec![ + // Asset { + // id: AssetId(Location::parent()), + // fun: Fungible(1_000_000 * UNITS), + // } + // ]; + // assets.into() + // } + // } + let mut whitelist: Vec = AllPalletsWithSystem::whitelisted_storage_keys(); // Treasury Account diff --git a/runtime/mandala/src/weights/mod.rs b/runtime/mandala/src/weights/mod.rs index fbdfc46611..7a7ba5a1bc 100644 --- a/runtime/mandala/src/weights/mod.rs +++ b/runtime/mandala/src/weights/mod.rs @@ -33,6 +33,7 @@ pub mod module_emergency_shutdown; pub mod module_evm; pub mod module_evm_accounts; pub mod module_homa; +pub mod module_homa_validator_list; pub mod module_honzon; pub mod module_idle_scheduler; pub mod module_incentives; diff --git a/runtime/mandala/src/weights/module_homa_validator_list.rs b/runtime/mandala/src/weights/module_homa_validator_list.rs new file mode 100644 index 0000000000..752e2a9ee7 --- /dev/null +++ b/runtime/mandala/src/weights/module_homa_validator_list.rs @@ -0,0 +1,180 @@ +// This file is part of Acala. + +// Copyright (C) 2020-2024 Acala Foundation. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +//! Autogenerated weights for module_homa_validator_list +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2024-04-17, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `192.168.1.2`, CPU: `` +//! WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 + +// Executed Command: +// target/production/acala +// benchmark +// pallet +// --chain=dev +// --steps=50 +// --repeat=20 +// --pallet=* +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --template=./templates/runtime-weight-template.hbs +// --output=./runtime/mandala/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for module_homa_validator_list. +pub struct WeightInfo(PhantomData); +impl module_homa_validator_list::WeightInfo for WeightInfo { + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::TotalLockedByGuarantor` (r:1 w:1) + // Proof: `HomaValidatorList::TotalLockedByGuarantor` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::Guarantees` (r:1 w:1) + // Proof: `HomaValidatorList::Guarantees` (`max_values`: None, `max_size`: Some(141), added: 2616, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::ValidatorBackings` (r:1 w:1) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + fn bond() -> Weight { + // Proof Size summary in bytes: + // Measured: `2388` + // Estimated: `4765` + // Minimum execution time: 36_000 nanoseconds. + Weight::from_parts(37_000_000, 4765) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) + } + // Storage: `HomaValidatorList::Guarantees` (r:1 w:1) + // Proof: `HomaValidatorList::Guarantees` (`max_values`: None, `max_size`: Some(141), added: 2616, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::ValidationData` (r:1 w:0) + // Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::LastRelayChainBlockNumber` (r:1 w:0) + // Proof: `ParachainSystem::LastRelayChainBlockNumber` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + fn unbond() -> Weight { + // Proof Size summary in bytes: + // Measured: `1506` + // Estimated: `3606` + // Minimum execution time: 19_000 nanoseconds. + Weight::from_parts(20_000_000, 3606) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: `HomaValidatorList::Guarantees` (r:1 w:1) + // Proof: `HomaValidatorList::Guarantees` (`max_values`: None, `max_size`: Some(141), added: 2616, mode: `MaxEncodedLen`) + fn rebond() -> Weight { + // Proof Size summary in bytes: + // Measured: `1044` + // Estimated: `3606` + // Minimum execution time: 8_000 nanoseconds. + Weight::from_parts(9_000_000, 3606) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: `HomaValidatorList::ValidatorBackings` (r:1 w:1) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::Guarantees` (r:1 w:1) + // Proof: `HomaValidatorList::Guarantees` (`max_values`: None, `max_size`: Some(141), added: 2616, mode: `MaxEncodedLen`) + // Storage: `ParachainSystem::ValidationData` (r:1 w:0) + // Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `HomaValidatorList::TotalLockedByGuarantor` (r:1 w:1) + // Proof: `HomaValidatorList::TotalLockedByGuarantor` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + fn withdraw_unbonded() -> Weight { + // Proof Size summary in bytes: + // Measured: `2312` + // Estimated: `4765` + // Minimum execution time: 40_000 nanoseconds. + Weight::from_parts(41_000_000, 4765) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) + } + // Storage: `HomaValidatorList::ValidatorBackings` (r:10 w:10) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// The range of component `n` is `[1, 10]`. + fn freeze(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1235 + n * (71 ±0)` + // Estimated: `990 + n * (2540 ±0)` + // Minimum execution time: 15_000 nanoseconds. + Weight::from_parts(10_990_773, 990) + // Standard Error: 8_735 + .saturating_add(Weight::from_parts(4_485_901, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 2540).saturating_mul(n.into())) + } + // Storage: `HomaValidatorList::ValidatorBackings` (r:10 w:10) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + /// The range of component `n` is `[1, 10]`. + fn thaw(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1235 + n * (71 ±0)` + // Estimated: `990 + n * (2540 ±0)` + // Minimum execution time: 15_000 nanoseconds. + Weight::from_parts(11_502_223, 990) + // Standard Error: 12_312 + .saturating_add(Weight::from_parts(4_428_242, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 2540).saturating_mul(n.into())) + } + // Storage: `Homa::TotalStakingBonded` (r:1 w:0) + // Proof: `Homa::TotalStakingBonded` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `Homa::ToBondPool` (r:1 w:0) + // Proof: `Homa::ToBondPool` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `Tokens::TotalIssuance` (r:1 w:1) + // Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + // Storage: `Homa::TotalVoidLiquid` (r:1 w:0) + // Proof: `Homa::TotalVoidLiquid` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `HomaValidatorList::ValidatorBackings` (r:10 w:10) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::Guarantees` (r:20 w:10) + // Proof: `HomaValidatorList::Guarantees` (`max_values`: None, `max_size`: Some(141), added: 2616, mode: `MaxEncodedLen`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `HomaValidatorList::TotalLockedByGuarantor` (r:1 w:1) + // Proof: `HomaValidatorList::TotalLockedByGuarantor` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + /// The range of component `n` is `[1, 10]`. + fn slash(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2834 + n * (200 ±0)` + // Estimated: `4765 + n * (5232 ±0)` + // Minimum execution time: 57_000 nanoseconds. + Weight::from_parts(30_420_201, 4765) + // Standard Error: 30_290 + .saturating_add(Weight::from_parts(30_166_892, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes(4)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 5232).saturating_mul(n.into())) + } +} diff --git a/runtime/mandala/src/weights/module_nominees_election.rs b/runtime/mandala/src/weights/module_nominees_election.rs index e9f524c68a..bf523794f6 100644 --- a/runtime/mandala/src/weights/module_nominees_election.rs +++ b/runtime/mandala/src/weights/module_nominees_election.rs @@ -55,17 +55,21 @@ impl module_nominees_election::WeightInfo for WeightInf // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) // Storage: `NomineesElection::Nominations` (r:1 w:0) // Proof: `NomineesElection::Nominations` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::PoolInfos` (r:1 w:1) + // Proof: `Rewards::PoolInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::SharesAndWithdrawnRewards` (r:1 w:1) + // Proof: `Rewards::SharesAndWithdrawnRewards` (`max_values`: None, `max_size`: None, mode: `Measured`) fn bond() -> Weight { // Proof Size summary in bytes: - // Measured: `2426` - // Estimated: `5891` - // Minimum execution time: 42_505 nanoseconds. - Weight::from_parts(43_748_000, 5891) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) + // Measured: `2634` + // Estimated: `6099` + // Minimum execution time: 39_000 nanoseconds. + Weight::from_parts(40_000_000, 6099) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) } - // Storage: `NomineesElection::CurrentEra` (r:1 w:0) - // Proof: `NomineesElection::CurrentEra` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `Homa::RelayChainCurrentEra` (r:1 w:0) + // Proof: `Homa::RelayChainCurrentEra` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) // Storage: `NomineesElection::Ledger` (r:1 w:1) // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) // Storage: `Tokens::Locks` (r:1 w:1) @@ -74,14 +78,18 @@ impl module_nominees_election::WeightInfo for WeightInf // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) // Storage: `NomineesElection::Nominations` (r:1 w:0) // Proof: `NomineesElection::Nominations` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::SharesAndWithdrawnRewards` (r:1 w:1) + // Proof: `Rewards::SharesAndWithdrawnRewards` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::PoolInfos` (r:1 w:1) + // Proof: `Rewards::PoolInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) fn unbond() -> Weight { // Proof Size summary in bytes: - // Measured: `1900` - // Estimated: `5365` - // Minimum execution time: 37_198 nanoseconds. - Weight::from_parts(37_955_000, 5365) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(3)) + // Measured: `2388` + // Estimated: `5853` + // Minimum execution time: 40_000 nanoseconds. + Weight::from_parts(41_000_000, 5853) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(5)) } // Storage: `NomineesElection::Ledger` (r:1 w:1) // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -91,6 +99,10 @@ impl module_nominees_election::WeightInfo for WeightInf // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) // Storage: `NomineesElection::Nominations` (r:1 w:0) // Proof: `NomineesElection::Nominations` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::PoolInfos` (r:1 w:1) + // Proof: `Rewards::PoolInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::SharesAndWithdrawnRewards` (r:1 w:1) + // Proof: `Rewards::SharesAndWithdrawnRewards` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `c` is `[1, 7]`. fn rebond(c: u32, ) -> Weight { // Proof Size summary in bytes: @@ -103,61 +115,81 @@ impl module_nominees_election::WeightInfo for WeightInf .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } - // Storage: `NomineesElection::CurrentEra` (r:1 w:0) - // Proof: `NomineesElection::CurrentEra` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - // Storage: `NomineesElection::Ledger` (r:1 w:0) + // Storage: `Homa::RelayChainCurrentEra` (r:1 w:0) + // Proof: `Homa::RelayChainCurrentEra` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `NomineesElection::Ledger` (r:1 w:1) // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Tokens::Locks` (r:1 w:1) + // Proof: `Tokens::Locks` (`max_values`: None, `max_size`: Some(1300), added: 3775, mode: `MaxEncodedLen`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) /// The range of component `c` is `[1, 7]`. fn withdraw_unbonded(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1012` - // Estimated: `4477` - // Minimum execution time: 12_833 nanoseconds. - Weight::from_parts(13_428_726, 4477) - // Standard Error: 2_718 - .saturating_add(Weight::from_parts(10_670, 0).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(2)) + // Measured: `2168` + // Estimated: `5633` + // Minimum execution time: 33_000 nanoseconds. + Weight::from_parts(34_118_349, 5633) + // Standard Error: 21_099 + .saturating_add(Weight::from_parts(96_491, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: `NomineesElection::Ledger` (r:1 w:0) // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `HomaValidatorList::ValidatorBackings` (r:16 w:0) + // Proof: `HomaValidatorList::ValidatorBackings` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`) // Storage: `NomineesElection::Nominations` (r:1 w:1) // Proof: `NomineesElection::Nominations` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `NomineesElection::Votes` (r:7 w:7) + // Storage: `NomineesElection::Votes` (r:16 w:16) // Proof: `NomineesElection::Votes` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// The range of component `c` is `[1, 7]`. + /// The range of component `c` is `[1, 16]`. fn nominate(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `944` - // Estimated: `4409 + c * (2475 ±0)` - // Minimum execution time: 15_435 nanoseconds. - Weight::from_parts(14_435_638, 4409) - // Standard Error: 4_274 - .saturating_add(Weight::from_parts(1_610_409, 0).saturating_mul(c.into())) + // Measured: `1508 + c * (72 ±0)` + // Estimated: `4973 + c * (2547 ±0)` + // Minimum execution time: 22_000 nanoseconds. + Weight::from_parts(19_125_174, 4973) + // Standard Error: 12_496 + .saturating_add(Weight::from_parts(3_924_043, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into()))) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(c.into()))) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) - .saturating_add(Weight::from_parts(0, 2475).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(0, 2547).saturating_mul(c.into())) } // Storage: `NomineesElection::Ledger` (r:1 w:0) // Proof: `NomineesElection::Ledger` (`max_values`: None, `max_size`: None, mode: `Measured`) // Storage: `NomineesElection::Nominations` (r:1 w:1) // Proof: `NomineesElection::Nominations` (`max_values`: None, `max_size`: None, mode: `Measured`) - // Storage: `NomineesElection::Votes` (r:7 w:7) + // Storage: `NomineesElection::Votes` (r:16 w:16) // Proof: `NomineesElection::Votes` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// The range of component `c` is `[1, 7]`. + /// The range of component `c` is `[1, 16]`. fn chill(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1030 + c * (95 ±0)` - // Estimated: `4496 + c * (2570 ±0)` - // Minimum execution time: 18_571 nanoseconds. - Weight::from_parts(16_544_031, 4496) - // Standard Error: 14_536 - .saturating_add(Weight::from_parts(3_358_687, 0).saturating_mul(c.into())) + // Measured: `1372 + c * (93 ±0)` + // Estimated: `4835 + c * (2569 ±0)` + // Minimum execution time: 21_000 nanoseconds. + Weight::from_parts(19_737_152, 4835) + // Standard Error: 11_893 + .saturating_add(Weight::from_parts(2_815_068, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into()))) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) - .saturating_add(Weight::from_parts(0, 2570).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(0, 2569).saturating_mul(c.into())) + } + // Storage: `NomineesElection::ReservedNominees` (r:0 w:4) + // Proof: `NomineesElection::ReservedNominees` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `c` is `[1, 4]`. + fn reset_reserved_nominees(c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1001` + // Estimated: `1001` + // Minimum execution time: 11_000 nanoseconds. + Weight::from_parts(8_689_832, 1001) + // Standard Error: 19_101 + .saturating_add(Weight::from_parts(3_395_132, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) } } diff --git a/runtime/mandala/src/weights/pallet_xcm.rs b/runtime/mandala/src/weights/pallet_xcm.rs index f6e92391e1..9e9d4de408 100644 --- a/runtime/mandala/src/weights/pallet_xcm.rs +++ b/runtime/mandala/src/weights/pallet_xcm.rs @@ -16,350 +16,271 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -//! Autogenerated weights for `pallet_xcm` +//! Autogenerated weights for pallet_xcm //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-12-19, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `ggwpez-ref-hw`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` -//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("../asset-hub-kusama-chain-spec.json")`, DB CACHE: 1024 +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 35.0.1 +//! DATE: 2024-05-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `ip-172-31-21-214`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` +//! WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// ./target/production/polkadot +// target/production/acala // benchmark // pallet -// --chain=../asset-hub-kusama-chain-spec.json +// --chain=dev // --steps=50 // --repeat=20 -// --pallet=pallet_xcm +// --pallet=* // --extrinsic=* // --wasm-execution=compiled // --heap-pages=4096 -// --output=./asset-hub-kusama-weights -// --header=./file_header.txt +// --template=./templates/runtime-weight-template.hbs +// --output=./runtime/mandala/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] -#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use core::marker::PhantomData; +use sp_std::marker::PhantomData; -/// Weight functions for `pallet_xcm`. +/// Weight functions for pallet_xcm. pub struct WeightInfo(PhantomData); impl pallet_xcm::WeightInfo for WeightInfo { - /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn send() -> Weight { // Proof Size summary in bytes: - // Measured: `145` - // Estimated: `3610` - // Minimum execution time: 24_856_000 picoseconds. - Weight::from_parts(25_639_000, 0) - .saturating_add(Weight::from_parts(0, 3610)) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(2)) + // Measured: `147` + // Estimated: `1632` + // Minimum execution time: 11_782 nanoseconds. + Weight::from_parts(12_157_000, 1632) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) - /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `Benchmark::Override` (r:0 w:0) + // Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`) fn teleport_assets() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `1489` - // Minimum execution time: 20_000_000 picoseconds. - Weight::from_parts(20_357_000, 0) - .saturating_add(Weight::from_parts(0, 1489)) - .saturating_add(T::DbWeight::get().reads(1)) + // Estimated: `0` + // Minimum execution time: 18_446_744_073_709_551 nanoseconds. + Weight::from_parts(18_446_744_073_709_551_000, 0) } - /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) - /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + // Storage: `Benchmark::Override` (r:0 w:0) + // Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`) fn reserve_transfer_assets() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `1489` - // Minimum execution time: 14_600_000 picoseconds. - Weight::from_parts(15_045_000, 0) - .saturating_add(Weight::from_parts(0, 1489)) - .saturating_add(T::DbWeight::get().reads(1)) + // Estimated: `0` + // Minimum execution time: 18_446_744_073_709_551 nanoseconds. + Weight::from_parts(18_446_744_073_709_551_000, 0) } - /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) - /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Assets::Asset` (r:1 w:1) - /// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `Assets::Account` (r:2 w:2) - /// Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:2 w:2) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `Benchmark::Override` (r:0 w:0) + // Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`) fn transfer_assets() -> Weight { // Proof Size summary in bytes: - // Measured: `496` - // Estimated: `6208` - // Minimum execution time: 146_932_000 picoseconds. - Weight::from_parts(153_200_000, 0) - .saturating_add(Weight::from_parts(0, 6208)) - .saturating_add(T::DbWeight::get().reads(12)) - .saturating_add(T::DbWeight::get().writes(7)) + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 18_446_744_073_709_551 nanoseconds. + Weight::from_parts(18_446_744_073_709_551_000, 0) } - /// Storage: `Benchmark::Override` (r:0 w:0) - /// Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Benchmark::Override` (r:0 w:0) + // Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`) fn execute() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 18_446_744_073_709_551_000 picoseconds. + // Minimum execution time: 18_446_744_073_709_551 nanoseconds. Weight::from_parts(18_446_744_073_709_551_000, 0) - .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `PolkadotXcm::SupportedVersion` (r:0 w:1) - /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:0 w:1) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) fn force_xcm_version() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_899_000 picoseconds. - Weight::from_parts(7_127_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Minimum execution time: 5_748 nanoseconds. + Weight::from_parts(5_993_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `PolkadotXcm::SafeXcmVersion` (r:0 w:1) - /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn force_default_xcm_version() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_198_000 picoseconds. - Weight::from_parts(2_440_000, 0) - .saturating_add(Weight::from_parts(0, 0)) - .saturating_add(T::DbWeight::get().writes(1)) + // Minimum execution time: 1_666 nanoseconds. + Weight::from_parts(1_809_000, 0) } - /// Storage: `PolkadotXcm::VersionNotifiers` (r:1 w:1) - /// Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::QueryCounter` (r:1 w:1) - /// Proof: `PolkadotXcm::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::Queries` (r:0 w:1) - /// Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionNotifiers` (r:1 w:1) + // Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::QueryCounter` (r:1 w:1) + // Proof: `PolkadotXcm::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::Queries` (r:0 w:1) + // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) fn force_subscribe_version_notify() -> Weight { // Proof Size summary in bytes: - // Measured: `145` - // Estimated: `3610` - // Minimum execution time: 29_009_000 picoseconds. - Weight::from_parts(30_280_000, 0) - .saturating_add(Weight::from_parts(0, 3610)) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(5)) + // Measured: `147` + // Estimated: `3612` + // Minimum execution time: 17_057 nanoseconds. + Weight::from_parts(17_699_000, 3612) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) } - /// Storage: `PolkadotXcm::VersionNotifiers` (r:1 w:1) - /// Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::Queries` (r:0 w:1) - /// Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionNotifiers` (r:1 w:1) + // Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::Queries` (r:0 w:1) + // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) fn force_unsubscribe_version_notify() -> Weight { // Proof Size summary in bytes: - // Measured: `363` - // Estimated: `3828` - // Minimum execution time: 30_806_000 picoseconds. - Weight::from_parts(31_646_000, 0) - .saturating_add(Weight::from_parts(0, 3828)) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(4)) + // Measured: `206` + // Estimated: `3671` + // Minimum execution time: 16_923 nanoseconds. + Weight::from_parts(17_451_000, 3671) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: `PolkadotXcm::XcmExecutionSuspended` (r:0 w:1) - /// Proof: `PolkadotXcm::XcmExecutionSuspended` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::XcmExecutionSuspended` (r:0 w:1) + // Proof: `PolkadotXcm::XcmExecutionSuspended` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn force_suspension() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_139_000 picoseconds. - Weight::from_parts(2_319_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Minimum execution time: 1_774 nanoseconds. + Weight::from_parts(1_902_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } - /// Storage: `PolkadotXcm::SupportedVersion` (r:4 w:2) - /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::SupportedVersion` (r:5 w:2) + // Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) fn migrate_supported_version() -> Weight { // Proof Size summary in bytes: - // Measured: `162` - // Estimated: `11052` - // Minimum execution time: 16_833_000 picoseconds. - Weight::from_parts(17_423_000, 0) - .saturating_add(Weight::from_parts(0, 11052)) - .saturating_add(T::DbWeight::get().reads(4)) + // Measured: `22` + // Estimated: `13387` + // Minimum execution time: 17_359 nanoseconds. + Weight::from_parts(17_820_000, 13387) + .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: `PolkadotXcm::VersionNotifiers` (r:4 w:2) - /// Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionNotifiers` (r:5 w:2) + // Proof: `PolkadotXcm::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`) fn migrate_version_notifiers() -> Weight { // Proof Size summary in bytes: - // Measured: `166` - // Estimated: `11056` - // Minimum execution time: 17_002_000 picoseconds. - Weight::from_parts(17_667_000, 0) - .saturating_add(Weight::from_parts(0, 11056)) - .saturating_add(T::DbWeight::get().reads(4)) + // Measured: `26` + // Estimated: `13391` + // Minimum execution time: 17_800 nanoseconds. + Weight::from_parts(18_357_000, 13391) + .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: `PolkadotXcm::VersionNotifyTargets` (r:5 w:0) - /// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:6 w:0) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) fn already_notified_target() -> Weight { // Proof Size summary in bytes: - // Measured: `173` - // Estimated: `13538` - // Minimum execution time: 18_497_000 picoseconds. - Weight::from_parts(18_995_000, 0) - .saturating_add(Weight::from_parts(0, 13538)) - .saturating_add(T::DbWeight::get().reads(5)) + // Measured: `36` + // Estimated: `15876` + // Minimum execution time: 20_010 nanoseconds. + Weight::from_parts(20_531_000, 15876) + .saturating_add(T::DbWeight::get().reads(6)) } - /// Storage: `PolkadotXcm::VersionNotifyTargets` (r:2 w:1) - /// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:2 w:1) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn notify_current_targets() -> Weight { // Proof Size summary in bytes: - // Measured: `212` - // Estimated: `6152` - // Minimum execution time: 27_060_000 picoseconds. - Weight::from_parts(27_662_000, 0) - .saturating_add(Weight::from_parts(0, 6152)) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(3)) + // Measured: `180` + // Estimated: `6120` + // Minimum execution time: 17_253 nanoseconds. + Weight::from_parts(17_820_000, 6120) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: `PolkadotXcm::VersionNotifyTargets` (r:3 w:0) - /// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:4 w:0) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) fn notify_target_migration_fail() -> Weight { // Proof Size summary in bytes: - // Measured: `206` - // Estimated: `8621` - // Minimum execution time: 9_157_000 picoseconds. - Weight::from_parts(9_437_000, 0) - .saturating_add(Weight::from_parts(0, 8621)) - .saturating_add(T::DbWeight::get().reads(3)) + // Measured: `69` + // Estimated: `10959` + // Minimum execution time: 12_846 nanoseconds. + Weight::from_parts(13_588_000, 10959) + .saturating_add(T::DbWeight::get().reads(4)) } - /// Storage: `PolkadotXcm::VersionNotifyTargets` (r:4 w:2) - /// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:5 w:2) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) fn migrate_version_notify_targets() -> Weight { // Proof Size summary in bytes: - // Measured: `173` - // Estimated: `11063` - // Minimum execution time: 17_430_000 picoseconds. - Weight::from_parts(17_727_000, 0) - .saturating_add(Weight::from_parts(0, 11063)) - .saturating_add(T::DbWeight::get().reads(4)) + // Measured: `33` + // Estimated: `13398` + // Minimum execution time: 18_075 nanoseconds. + Weight::from_parts(18_699_000, 13398) + .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: `PolkadotXcm::VersionNotifyTargets` (r:4 w:2) - /// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) - /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1) - /// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0) - /// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) - /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) - /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::VersionNotifyTargets` (r:5 w:2) + // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + // Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + // Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn migrate_and_notify_old_targets() -> Weight { // Proof Size summary in bytes: - // Measured: `215` - // Estimated: `11105` - // Minimum execution time: 33_562_000 picoseconds. - Weight::from_parts(34_612_000, 0) - .saturating_add(Weight::from_parts(0, 11105)) - .saturating_add(T::DbWeight::get().reads(10)) - .saturating_add(T::DbWeight::get().writes(4)) + // Measured: `180` + // Estimated: `13545` + // Minimum execution time: 27_420 nanoseconds. + Weight::from_parts(28_122_000, 13545) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: `XcmPallet::QueryCounter` (r:1 w:1) - /// Proof: `XcmPallet::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `XcmPallet::Queries` (r:0 w:1) - /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::QueryCounter` (r:1 w:1) + // Proof: `PolkadotXcm::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::Queries` (r:0 w:1) + // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) fn new_query() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `1485` - // Minimum execution time: 2_947_000 picoseconds. - Weight::from_parts(3_117_000, 0) - .saturating_add(Weight::from_parts(0, 1485)) + // Minimum execution time: 2_356 nanoseconds. + Weight::from_parts(2_467_000, 1485) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } - /// Storage: `XcmPallet::Queries` (r:1 w:1) - /// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::Queries` (r:1 w:1) + // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) fn take_response() -> Weight { // Proof Size summary in bytes: // Measured: `7576` // Estimated: `11041` - // Minimum execution time: 24_595_000 picoseconds. - Weight::from_parts(24_907_000, 0) - .saturating_add(Weight::from_parts(0, 11041)) + // Minimum execution time: 20_718 nanoseconds. + Weight::from_parts(21_084_000, 11041) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + // Storage: `EVM::XcmOrigin` (r:1 w:1) + // Proof: `EVM::XcmOrigin` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + // Storage: `PolkadotXcm::AssetTraps` (r:1 w:1) + // Proof: `PolkadotXcm::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Tokens::Accounts` (r:1 w:1) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `Tokens::TotalIssuance` (r:1 w:1) + // Proof: `Tokens::TotalIssuance` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) fn claim_assets() -> Weight { // Proof Size summary in bytes: - // Measured: `7576` - // Estimated: `11041` - // Minimum execution time: 24_595_000 picoseconds. - Weight::from_parts(24_907_000, 0) - .saturating_add(Weight::from_parts(0, 11041)) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + // Measured: `856` + // Estimated: `4321` + // Minimum execution time: 39_330 nanoseconds. + Weight::from_parts(40_676_000, 4321) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) } } diff --git a/runtime/mandala/src/xcm_config.rs b/runtime/mandala/src/xcm_config.rs index 1d3e2e93d4..f32d4b4577 100644 --- a/runtime/mandala/src/xcm_config.rs +++ b/runtime/mandala/src/xcm_config.rs @@ -121,7 +121,7 @@ impl xcm_executor::Config for XcmConfig { >; type AssetLocker = (); type AssetExchanger = (); - type AssetClaims = (); + type AssetClaims = PolkadotXcm; type SubscriptionService = PolkadotXcm; type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = ConstU32<64>;