From 956f0f04907a0400d3ea05c133b1bf7480387b7c Mon Sep 17 00:00:00 2001 From: Igor Papandinas <26460174+ipapandinas@users.noreply.github.com> Date: Fri, 30 Jan 2026 16:14:10 +0400 Subject: [PATCH 01/16] feat: dapp-staking revamp --- pallets/dapp-staking/src/benchmarking/mod.rs | 88 +-- .../dapp-staking/src/benchmarking/utils.rs | 8 + pallets/dapp-staking/src/lib.rs | 135 +++-- pallets/dapp-staking/src/migration.rs | 536 +++++++----------- pallets/dapp-staking/src/test/migrations.rs | 85 --- pallets/dapp-staking/src/test/mock.rs | 11 +- pallets/dapp-staking/src/test/mod.rs | 1 - pallets/dapp-staking/src/test/tests.rs | 154 +++-- pallets/dapp-staking/src/test/tests_types.rs | 266 ++++++++- pallets/dapp-staking/src/types.rs | 40 +- precompiles/dapp-staking/src/test/mock.rs | 8 + primitives/src/dapp_staking.rs | 128 +++-- runtime/astar/src/genesis_config.rs | 51 +- runtime/astar/src/lib.rs | 66 ++- runtime/shibuya/src/genesis_config.rs | 54 +- runtime/shibuya/src/lib.rs | 67 ++- runtime/shiden/src/genesis_config.rs | 51 +- runtime/shiden/src/lib.rs | 68 ++- 18 files changed, 1099 insertions(+), 718 deletions(-) delete mode 100644 pallets/dapp-staking/src/test/migrations.rs diff --git a/pallets/dapp-staking/src/benchmarking/mod.rs b/pallets/dapp-staking/src/benchmarking/mod.rs index 46569ce670..239486e16e 100644 --- a/pallets/dapp-staking/src/benchmarking/mod.rs +++ b/pallets/dapp-staking/src/benchmarking/mod.rs @@ -21,7 +21,7 @@ use super::{Pallet as DappStaking, *}; use astar_primitives::Balance; use frame_benchmarking::v2::*; -use frame_support::{assert_ok, migrations::SteppedMigration, weights::WeightMeter}; +use frame_support::assert_ok; use frame_system::{Pallet as System, RawOrigin}; use sp_std::prelude::*; @@ -1145,12 +1145,28 @@ mod benchmarks { }); EraRewards::::insert(&cleanup_marker.era_reward_index, reward_span); + let rank_points: BoundedVec< + BoundedVec>, + T::NumberOfTiers, + > = (1..=T::NumberOfTiers::get()) + .map(|slots| { + let inner: BoundedVec> = + (1..=slots as u8) + .collect::>() + .try_into() + .expect("Using incremental points; QED."); + inner + }) + .collect::>() + .try_into() + .expect("Using `NumberOfTiers` as length; QED."); + // Prepare completely filled up tier rewards and insert it into storage. DAppTiers::::insert( &cleanup_marker.dapp_tiers_index, DAppTierRewardsFor:: { dapps: (0..T::MaxNumberOfContracts::get()) - .map(|dapp_id| (dapp_id as DAppId, RankedTier::new_saturated(0, 0))) + .map(|dapp_id| (dapp_id as DAppId, RankedTier::new_saturated(0, 0, 10))) .collect::>() .try_into() .expect("Using `MaxNumberOfContracts` as length; QED."), @@ -1161,6 +1177,7 @@ mod benchmarks { rank_rewards: vec![0; T::NumberOfTiers::get() as usize] .try_into() .expect("Using `NumberOfTiers` as length; QED."), + rank_points, }, ); @@ -1180,73 +1197,6 @@ mod benchmarks { ); } - /// Benchmark a single step of mbm migration. - #[benchmark] - fn step() { - let alice: T::AccountId = account("alice", 0, 1); - - Ledger::::set( - &alice, - AccountLedger { - locked: 1000, - unlocking: vec![ - UnlockingChunk { - amount: 100, - unlock_block: 5, - }, - UnlockingChunk { - amount: 100, - unlock_block: 20, - }, - ] - .try_into() - .unwrap(), - staked: Default::default(), - staked_future: None, - contract_stake_count: 0, - }, - ); - CurrentEraInfo::::put(EraInfo { - total_locked: 1000, - unlocking: 200, - current_stake_amount: Default::default(), - next_stake_amount: Default::default(), - }); - - System::::set_block_number(10u32.into()); - let mut meter = WeightMeter::new(); - - #[block] - { - crate::migration::LazyMigration::>::step( - None, &mut meter, - ) - .unwrap(); - } - - assert_eq!( - Ledger::::get(&alice), - AccountLedger { - locked: 1000, - unlocking: vec![ - UnlockingChunk { - amount: 100, - unlock_block: 5, // already unlocked - }, - UnlockingChunk { - amount: 100, - unlock_block: 30, // double remaining blocks - }, - ] - .try_into() - .unwrap(), - staked: Default::default(), - staked_future: None, - contract_stake_count: 0, - } - ); - } - #[benchmark] fn set_static_tier_params() { initial_config::(); diff --git a/pallets/dapp-staking/src/benchmarking/utils.rs b/pallets/dapp-staking/src/benchmarking/utils.rs index a59861fe73..f9915ae539 100644 --- a/pallets/dapp-staking/src/benchmarking/utils.rs +++ b/pallets/dapp-staking/src/benchmarking/utils.rs @@ -198,6 +198,14 @@ pub(super) fn init_tier_settings() { ]) .unwrap(), slot_number_args: STANDARD_TIER_SLOTS_ARGS, + rank_points: BoundedVec::try_from(vec![ + BoundedVec::try_from(vec![1u8]).unwrap(), + BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]).unwrap(), + BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]).unwrap(), + BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]).unwrap(), + ]) + .unwrap(), + base_reward_portion: Permill::from_percent(50), }; let total_issuance = 1000 * MIN_TIER_THRESHOLD; diff --git a/pallets/dapp-staking/src/lib.rs b/pallets/dapp-staking/src/lib.rs index 177eb08c05..b707d8bf4b 100644 --- a/pallets/dapp-staking/src/lib.rs +++ b/pallets/dapp-staking/src/lib.rs @@ -35,6 +35,10 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; + +use alloc::vec; +pub use alloc::vec::Vec; use frame_support::{ pallet_prelude::*, traits::{ @@ -49,13 +53,12 @@ use sp_runtime::{ traits::{One, Saturating, UniqueSaturatedInto, Zero}, Perbill, Permill, SaturatedConversion, }; -pub use sp_std::vec::Vec; use astar_primitives::{ dapp_staking::{ AccountCheck, CycleConfiguration, DAppId, EraNumber, Observer as DAppStakingObserver, PeriodNumber, Rank, RankedTier, SmartContractHandle, StakingRewardHandler, TierId, - TierSlots as TierSlotFunc, STANDARD_TIER_SLOTS_ARGS, + TierSlots as TierSlotFunc, MAX_ENCODED_RANK, STANDARD_TIER_SLOTS_ARGS, }, oracle::PriceProvider, Balance, BlockNumber, @@ -94,7 +97,7 @@ pub mod pallet { use super::*; /// The current storage version. - pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(10); + pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(11); #[pallet::pallet] #[pallet::storage_version(STORAGE_VERSION)] @@ -530,6 +533,8 @@ pub mod pallet { pub slot_number_args: (u64, u64), pub slots_per_tier: Vec, pub safeguard: Option, + pub rank_points: Vec>, + pub base_reward_portion: Permill, #[serde(skip)] pub _config: PhantomData, } @@ -538,6 +543,15 @@ pub mod pallet { fn default() -> Self { use sp_std::vec; let num_tiers = T::NumberOfTiers::get(); + let slots_per_tier = vec![100u16; num_tiers as usize]; + let rank_points: Vec> = slots_per_tier + .iter() + .map(|&slots| { + let capped = slots.min(MAX_ENCODED_RANK as u16); + (1..=capped as u8).collect() + }) + .collect(); + Self { reward_portion: vec![Permill::from_percent(100 / num_tiers); num_tiers as usize], slot_distribution: vec![Permill::from_percent(100 / num_tiers); num_tiers as usize], @@ -548,8 +562,10 @@ pub mod pallet { }) .collect(), slot_number_args: STANDARD_TIER_SLOTS_ARGS, - slots_per_tier: vec![100; num_tiers as usize], + slots_per_tier, safeguard: None, + rank_points, + base_reward_portion: Permill::from_percent(50), _config: Default::default(), } } @@ -558,6 +574,12 @@ pub mod pallet { #[pallet::genesis_build] impl BuildGenesisConfig for GenesisConfig { fn build(&self) { + let rank_points: Vec>> = self + .rank_points + .iter() + .map(|inner| BoundedVec::try_from(inner.clone()).expect("Too many rank points")) + .collect(); + // Prepare tier parameters & verify their correctness let tier_params = TierParameters:: { reward_portion: BoundedVec::::try_from( @@ -573,6 +595,8 @@ pub mod pallet { ) .expect("Invalid number of tier thresholds provided."), slot_number_args: self.slot_number_args, + rank_points: BoundedVec::try_from(rank_points).expect("Too many tiers"), + base_reward_portion: self.base_reward_portion, }; assert!( tier_params.is_valid(), @@ -1882,6 +1906,7 @@ pub mod pallet { dapp_stakes.sort_unstable_by(|(_, amount_1), (_, amount_2)| amount_2.cmp(amount_1)); let tier_config = TierConfig::::get(); + let tier_params = StaticTierParams::::get(); // In case when tier has 1 more free slot, but two dApps with exactly same score satisfy the threshold, // one of them will be assigned to the tier, and the other one will be assigned to the lower tier, if it exists. @@ -1890,29 +1915,35 @@ pub mod pallet { // There is no guarantee this will persist in the future, so it's best for dApps to do their // best to avoid getting themselves into such situations. - // 3. Calculate rewards. - let tier_rewards = tier_config + // 3. Calculate tier allocations + let tier_allocations: Vec = tier_config .reward_portion + .iter() + .map(|percent| *percent * dapp_reward_pool) + .collect(); + + // 4. Base rewards = base_reward_portion% of allocation / slots capacity + let base_portion = tier_params.base_reward_portion; + let base_rewards_per_tier: Vec = tier_allocations .iter() .zip(tier_config.slots_per_tier.iter()) - .map(|(percent, slots)| { - if slots.is_zero() { + .map(|(allocation, capacity)| { + if capacity.is_zero() { Zero::zero() } else { - *percent * dapp_reward_pool / >::into(*slots) + base_portion + .mul_floor(*allocation) + .saturating_div((*capacity).into()) } }) - .collect::>(); + .collect(); - // 4. + // 5. // Iterate over configured tier and potential dApps. // Each dApp will be assigned to the best possible tier if it satisfies the required condition, // and tier capacity hasn't been filled yet. let mut dapp_tiers = BTreeMap::new(); - let mut tier_slots = BTreeMap::new(); - let mut upper_bound = Balance::zero(); - let mut rank_rewards = Vec::new(); for (tier_id, (tier_capacity, lower_bound)) in tier_config .slots_per_tier @@ -1929,49 +1960,71 @@ pub mod pallet { .take_while(|(_, amount)| amount.ge(lower_bound)) .take(*tier_capacity as usize) { + let max_rank = tier_params + .rank_points + .get(tier_id) + .map(|v| v.len().saturating_sub(1) as u8) // ranks 0 to len-1, never exceed valid indices + .unwrap_or(0); + let rank = if T::RankingEnabled::get() { - RankedTier::find_rank(*lower_bound, upper_bound, *staked_amount) + RankedTier::find_rank(*lower_bound, upper_bound, *staked_amount, max_rank) } else { 0 }; - tier_slots.insert(*dapp_id, RankedTier::new_saturated(tier_id as u8, rank)); - } - - // sum of all ranks for this tier - let ranks_sum = tier_slots - .iter() - .fold(0u32, |accum, (_, x)| accum.saturating_add(x.rank().into())); - let reward_per_rank = if ranks_sum.is_zero() { - Balance::zero() - } else { - // calculate reward per rank - let tier_reward = tier_rewards.get(tier_id).copied().unwrap_or_default(); - let empty_slots = tier_capacity.saturating_sub(tier_slots.len() as u16); - let remaining_reward = tier_reward.saturating_mul(empty_slots.into()); - // make sure required reward doesn't exceed remaining reward - let reward_per_rank = tier_reward.saturating_div(RankedTier::MAX_RANK.into()); - let expected_reward_for_ranks = - reward_per_rank.saturating_mul(ranks_sum.into()); - let reward_for_ranks = expected_reward_for_ranks.min(remaining_reward); - // re-calculate reward per rank based on available reward - reward_for_ranks.saturating_div(ranks_sum.into()) - }; + let ranked_tier = RankedTier::new_saturated(tier_id as u8, rank, max_rank); + dapp_tiers.insert(*dapp_id, ranked_tier); + } - rank_rewards.push(reward_per_rank); - dapp_tiers.append(&mut tier_slots); upper_bound = *lower_bound; // current threshold becomes upper bound for next tier } - // 5. + // 6. Calculate rank_rewards (reward per rank point for each tier) + // rank_rewards[tier] = (remainder portion of base% of tier allocation) / sum_of_all_rank_points_in_tier + let rank_rewards: Vec = tier_allocations + .iter() + .zip(tier_config.slots_per_tier.iter()) + .enumerate() + .map(|(tier_id, (allocation, slots))| { + // If tier has no slots, no rank rewards can be claimed + if slots.is_zero() { + return Zero::zero(); + } + + // Sum ALL configured rank_points for this tier + let total_points: u32 = tier_params + .rank_points + .get(tier_id) + .map(|points| points.iter().map(|&p| p as u32).sum()) + .unwrap_or(0); + + if total_points.is_zero() { + Zero::zero() + } else { + let rank_portion = + Permill::one().saturating_sub(tier_params.base_reward_portion); + let rank_pool = rank_portion.mul_floor(*allocation); + rank_pool.saturating_div(total_points.into()) + } + }) + .collect(); + + let rank_points_vec: Vec> = tier_params + .rank_points + .iter() + .map(|inner_bv| inner_bv.clone().into_inner()) + .collect(); + + // 7. // Prepare and return tier & rewards info. // In case rewards creation fails, we just write the default value. This should never happen though. ( DAppTierRewards::::new( dapp_tiers, - tier_rewards, + base_rewards_per_tier, period, rank_rewards, + rank_points_vec, ) .unwrap_or_default(), counter, diff --git a/pallets/dapp-staking/src/migration.rs b/pallets/dapp-staking/src/migration.rs index 8bd7057b21..e411c548e7 100644 --- a/pallets/dapp-staking/src/migration.rs +++ b/pallets/dapp-staking/src/migration.rs @@ -18,401 +18,261 @@ use super::*; use core::marker::PhantomData; -use frame_support::{ - migration::clear_storage_prefix, - migrations::{MigrationId, SteppedMigration, SteppedMigrationError}, - traits::{GetStorageVersion, OnRuntimeUpgrade, UncheckedOnRuntimeUpgrade}, - weights::WeightMeter, -}; +use frame_support::traits::UncheckedOnRuntimeUpgrade; #[cfg(feature = "try-runtime")] -use sp_std::vec::Vec; +mod try_runtime_imports { + pub use sp_runtime::TryRuntimeError; +} #[cfg(feature = "try-runtime")] -use sp_runtime::TryRuntimeError; +use try_runtime_imports::*; /// Exports for versioned migration `type`s for this pallet. pub mod versioned_migrations { use super::*; - /// Migration V9 to V10 wrapped in a [`frame_support::migrations::VersionedMigration`], ensuring - /// the migration is only performed when on-chain version is 9. - pub type V9ToV10 = frame_support::migrations::VersionedMigration< - 9, + /// Migration V10 to V11 wrapped in a [`frame_support::migrations::VersionedMigration`], ensuring + /// the migration is only performed when on-chain version is 10. + pub type V10ToV11 = frame_support::migrations::VersionedMigration< 10, - v10::VersionMigrateV9ToV10, + 11, + v11::VersionMigrateV10ToV11, Pallet, ::DbWeight, >; } -mod v10 { +/// Configuration for V11 tier parameters +pub trait TierParamsV11Config { + fn reward_portion() -> [Permill; 4]; + fn slot_distribution() -> [Permill; 4]; + fn tier_thresholds() -> [TierThreshold; 4]; + fn slot_number_args() -> (u64, u64); + fn rank_points() -> [Vec; 4]; + fn base_reward_portion() -> Permill; +} + +mod v11 { use super::*; - use crate::migration::v9::{ - TierParameters as TierParametersV9, TierThreshold as TierThresholdV9, + use crate::migration::v10::{ + DAppTierRewards as DAppTierRewardsV10, }; - pub struct VersionMigrateV9ToV10(PhantomData<(T, MaxPercentages)>); + pub struct VersionMigrateV10ToV11(PhantomData<(T, P)>); - impl; 4]>> UncheckedOnRuntimeUpgrade - for VersionMigrateV9ToV10 - { + impl UncheckedOnRuntimeUpgrade for VersionMigrateV10ToV11 { fn on_runtime_upgrade() -> Weight { - let max_percentages = MaxPercentages::get(); - - // Update static tier parameters with new max thresholds from the runtime configurable param TierThresholds - let result = StaticTierParams::::translate::, _>( - |maybe_old_params| match maybe_old_params { - Some(old_params) => { - let new_tier_thresholds: Vec = old_params - .tier_thresholds - .iter() - .enumerate() - .map(|(idx, old_threshold)| { - let maximum_percentage = if idx < max_percentages.len() { - max_percentages[idx] - } else { - None - }; - map_threshold(old_threshold, maximum_percentage) - }) - .collect(); - - let tier_thresholds = - BoundedVec::::try_from( - new_tier_thresholds, - ); - - match tier_thresholds { - Ok(tier_thresholds) => Some(TierParameters { - slot_distribution: old_params.slot_distribution, - reward_portion: old_params.reward_portion, - tier_thresholds, - slot_number_args: old_params.slot_number_args, - }), - Err(err) => { - log::error!( - "Failed to convert TierThresholds parameters: {:?}", - err - ); - None - } - } - } - _ => None, - }, + let mut reads = 1u64; // HistoryCleanupMarker + let mut writes = 0u64; + + let cleanup_marker = HistoryCleanupMarker::::get(); + let oldest_valid_era = cleanup_marker.oldest_valid_era; + + log::info!( + target: LOG_TARGET, + "Migration v11: oldest_valid_era = {}, will skip expired entries", + oldest_valid_era ); - if result.is_err() { - log::error!("Failed to translate StaticTierParams from previous V9 type to current V10 type. Check TierParametersV9 decoding."); - // Enable maintenance mode. + // 1. Migrate StaticTierParams + let reward_portion = P::reward_portion(); + let slot_distribution = P::slot_distribution(); + let tier_thresholds = P::tier_thresholds(); + let rank_points_config = P::rank_points(); + + let new_params = TierParameters:: { + reward_portion: BoundedVec::try_from(reward_portion.to_vec()) + .expect("4 tiers configured"), + slot_distribution: BoundedVec::try_from(slot_distribution.to_vec()) + .expect("4 tiers configured"), + tier_thresholds: BoundedVec::try_from(tier_thresholds.to_vec()) + .expect("4 tiers configured"), + slot_number_args: P::slot_number_args(), + rank_points: BoundedVec::try_from( + rank_points_config + .into_iter() + .map(|points| BoundedVec::try_from(points).expect("rank points")) + .collect::>() + ).expect("4 tiers"), + base_reward_portion: P::base_reward_portion(), + }; + + if !new_params.is_valid() { + log::error!( + target: LOG_TARGET, + "New TierParameters validation failed. Enabling maintenance mode." + ); ActiveProtocolState::::mutate(|state| { state.maintenance = true; }); - log::warn!("Maintenance mode enabled."); - return T::DbWeight::get().reads_writes(1, 0); + return T::DbWeight::get().reads_writes(reads, 1); } - T::DbWeight::get().reads_writes(1, 1) - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, TryRuntimeError> { - let old_params = v9::StaticTierParams::::get().ok_or_else(|| { - TryRuntimeError::Other( - "dapp-staking-v3::migration::v10: No old params found for StaticTierParams", - ) - })?; - Ok(old_params.encode()) - } + StaticTierParams::::put(new_params); + writes += 1; + log::info!(target: LOG_TARGET, "StaticTierParams updated successfully"); - #[cfg(feature = "try-runtime")] - fn post_upgrade(data: Vec) -> Result<(), TryRuntimeError> { - // Decode the old values - let old_params: TierParametersV9 = Decode::decode(&mut &data[..]) - .map_err(|_| { - TryRuntimeError::Other( - "dapp-staking-v3::migration::v10: Failed to decode old values", - ) - })?; - - // Get the new values - let new_config = TierConfig::::get(); - let new_params = StaticTierParams::::get(); + // 2. Migrate DAppTiers entries - only valid ones + let mut migrated_count = 0u32; + let mut deleted_count = 0u32; + let mut migration_failed = false; - // Verify that new params and new config are valid - assert!(new_params.is_valid()); - assert!(new_config.is_valid()); + let all_eras: Vec = v10::DAppTiers::::iter_keys().collect(); + reads += all_eras.len() as u64; - // Verify parameters remain unchanged - assert_eq!( - old_params.slot_distribution, new_params.slot_distribution, - "dapp-staking-v3::migration::v10: Slot distribution has changed" - ); - assert_eq!( - old_params.reward_portion, new_params.reward_portion, - "dapp-staking-v3::migration::v10: Reward portion has changed" - ); - assert_eq!( - old_params.tier_thresholds.len(), - new_params.tier_thresholds.len(), - "dapp-staking-v3::migration::v10: Number of tier thresholds has changed" - ); + for era in all_eras { + // Delete expired entries + if era < oldest_valid_era { + v10::DAppTiers::::remove(era); + deleted_count += 1; + writes += 1; + continue; + } - for (_, (old_threshold, new_threshold)) in old_params - .tier_thresholds - .iter() - .zip(new_params.tier_thresholds.iter()) - .enumerate() - { - match (old_threshold, new_threshold) { - ( - TierThresholdV9::FixedPercentage { - required_percentage: old_req, - }, - TierThreshold::FixedPercentage { - required_percentage: new_req, - }, - ) => { - assert_eq!( - old_req, new_req, - "dapp-staking-v3::migration::v10: Fixed percentage changed", - ); + reads += 1; + let maybe_old: Option> = + v10::DAppTiers::::get(era); + + match maybe_old { + Some(old) => { + let new = DAppTierRewards { + dapps: old.dapps, + rewards: old.rewards, + period: old.period, + rank_rewards: old.rank_rewards, + rank_points: BoundedVec::default(), // Empty = legacy formula + }; + DAppTiers::::insert(era, new); + migrated_count += 1; + writes += 1; } - ( - TierThresholdV9::DynamicPercentage { - percentage: old_percentage, - minimum_required_percentage: old_min, - }, - TierThreshold::DynamicPercentage { - percentage: new_percentage, - minimum_required_percentage: new_min, - maximum_possible_percentage: _, // We don't verify this as it's new - }, - ) => { - assert_eq!( - old_percentage, new_percentage, - "dapp-staking-v3::migration::v10: Percentage changed" - ); - assert_eq!( - old_min, new_min, - "dapp-staking-v3::migration::v10: Minimum percentage changed" + None => { + log::error!( + target: LOG_TARGET, + "Failed to decode DAppTiers for valid era {}", + era ); - } - _ => { - return Err(TryRuntimeError::Other( - "dapp-staking-v3::migration::v10: Tier threshold type mismatch", - )); + migration_failed = true; + break; } } } - let expected_max_percentages = MaxPercentages::get(); - for (idx, tier_threshold) in new_params.tier_thresholds.iter().enumerate() { - if let TierThreshold::DynamicPercentage { - maximum_possible_percentage, - .. - } = tier_threshold - { - let expected_maximum_percentage = if idx < expected_max_percentages.len() { - expected_max_percentages[idx] - } else { - None - } - .unwrap_or(Perbill::from_percent(100)); - assert_eq!( - *maximum_possible_percentage, expected_maximum_percentage, - "dapp-staking-v3::migration::v10: Max percentage differs from expected", - ); - } + if migration_failed { + log::error!( + target: LOG_TARGET, + "DAppTiers migration failed. Enabling maintenance mode." + ); + ActiveProtocolState::::mutate(|state| { + state.maintenance = true; + }); + return T::DbWeight::get().reads_writes(reads, writes + 1); } - // Verify storage version has been updated - ensure!( - Pallet::::on_chain_storage_version() >= 10, - "dapp-staking-v3::migration::v10: Wrong storage version." - ); + // 3. Update cleanup marker + if deleted_count > 0 { + HistoryCleanupMarker::::mutate(|marker| { + marker.dapp_tiers_index = marker.dapp_tiers_index.max(oldest_valid_era); + }); + writes += 1; + } - Ok(()) - } - } + log::info!( + target: LOG_TARGET, + "Migration v11 complete: migrated={}, deleted_expired={}", + migrated_count, + deleted_count + ); - pub fn map_threshold(old: &TierThresholdV9, max_percentage: Option) -> TierThreshold { - match old { - TierThresholdV9::FixedPercentage { - required_percentage, - } => TierThreshold::FixedPercentage { - required_percentage: *required_percentage, - }, - TierThresholdV9::DynamicPercentage { - percentage, - minimum_required_percentage, - } => TierThreshold::DynamicPercentage { - percentage: *percentage, - minimum_required_percentage: *minimum_required_percentage, - maximum_possible_percentage: max_percentage.unwrap_or(Perbill::from_percent(100)), // Default to 100% if not specified, - }, + T::DbWeight::get().reads_writes(reads, writes) } - } -} -mod v9 { - use super::*; - use frame_support::storage_alias; - - #[derive(Encode, Decode)] - pub struct TierParameters> { - pub reward_portion: BoundedVec, - pub slot_distribution: BoundedVec, - pub tier_thresholds: BoundedVec, - pub slot_number_args: (u64, u64), - } - - #[derive(Encode, Decode)] - pub enum TierThreshold { - FixedPercentage { - required_percentage: Perbill, - }, - DynamicPercentage { - percentage: Perbill, - minimum_required_percentage: Perbill, - }, - } - - /// v9 type for [`crate::StaticTierParams`] - #[storage_alias] - pub type StaticTierParams = - StorageValue, TierParameters<::NumberOfTiers>>; -} - -const PALLET_MIGRATIONS_ID: &[u8; 16] = b"dapp-staking-mbm"; - -pub struct LazyMigration(PhantomData<(T, W)>); - -impl SteppedMigration for LazyMigration { - type Cursor = ::AccountId; - // Without the explicit length here the construction of the ID would not be infallible. - type Identifier = MigrationId<16>; + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, TryRuntimeError> { + let cleanup_marker = HistoryCleanupMarker::::get(); + let oldest_valid_era = cleanup_marker.oldest_valid_era; + + let valid_count = v10::DAppTiers::::iter_keys() + .filter(|era| *era >= oldest_valid_era) + .count() as u32; + + log::info!( + target: LOG_TARGET, + "Pre-upgrade: {} valid DAppTiers entries (era >= {})", + valid_count, + oldest_valid_era + ); - /// The identifier of this migration. Which should be globally unique. - fn id() -> Self::Identifier { - MigrationId { - pallet_id: *PALLET_MIGRATIONS_ID, - version_from: 0, - version_to: 1, - } - } + // Verify all valid entries can be decoded + for era in v10::DAppTiers::::iter_keys() { + if era >= oldest_valid_era { + ensure!( + v10::DAppTiers::::get(era).is_some(), + "Failed to decode DAppTiers for era {}", + ); + } + } - fn step( - mut cursor: Option, - meter: &mut WeightMeter, - ) -> Result, SteppedMigrationError> { - let required = W::step(); - // If there is not enough weight for a single step, return an error. This case can be - // problematic if it is the first migration that ran in this block. But there is nothing - // that we can do about it here. - if meter.remaining().any_lt(required) { - return Err(SteppedMigrationError::InsufficientWeight { required }); + Ok((valid_count, oldest_valid_era).encode()) } - let mut count = 0u32; - let mut migrated = 0u32; - let current_block_number = - frame_system::Pallet::::block_number().saturated_into::(); - - // We loop here to do as much progress as possible per step. - loop { - if meter.try_consume(required).is_err() { - break; - } + #[cfg(feature = "try-runtime")] + fn post_upgrade(data: Vec) -> Result<(), TryRuntimeError> { + let (expected_count, oldest_valid_era): (u32, EraNumber) = + Decode::decode(&mut &data[..]) + .map_err(|_| TryRuntimeError::Other("Failed to decode pre-upgrade data"))?; - let mut iter = if let Some(last_key) = cursor { - // If a cursor is provided, start iterating from the stored value - // corresponding to the last key processed in the previous step. - // Note that this only works if the old and the new map use the same way to hash - // storage keys. - Ledger::::iter_from(Ledger::::hashed_key_for(last_key)) - } else { - // If no cursor is provided, start iterating from the beginning. - Ledger::::iter() - }; + ensure!( + Pallet::::on_chain_storage_version() == StorageVersion::new(11), + "Version should be 11" + ); - // If there's a next item in the iterator, perform the migration. - if let Some((ref last_key, mut ledger)) = iter.next() { - // inc count - count.saturating_inc(); + let new_params = StaticTierParams::::get(); + ensure!(new_params.is_valid(), "New tier params invalid"); - if ledger.unlocking.is_empty() { - // no unlocking for this account, nothing to update - // Return the processed key as the new cursor. - cursor = Some(last_key.clone()); - continue; - } - for chunk in ledger.unlocking.iter_mut() { - if current_block_number >= chunk.unlock_block { - continue; // chunk already unlocked - } - let remaining_blocks = chunk.unlock_block.saturating_sub(current_block_number); - chunk.unlock_block.saturating_accrue(remaining_blocks); - } + let new_count = DAppTiers::::iter().count() as u32; + ensure!( + new_count == expected_count, + "DAppTiers count mismatch" + ); - // Override ledger - Ledger::::insert(last_key, ledger); + for (era, rewards) in DAppTiers::::iter() { + ensure!(era >= oldest_valid_era, "Found expired entry"); + ensure!(rewards.rank_points.is_empty(), "Should have empty rank_points"); + } - // inc migrated - migrated.saturating_inc(); + ensure!( + !ActiveProtocolState::::get().maintenance, + "Maintenance mode should not be enabled" + ); - // Return the processed key as the new cursor. - cursor = Some(last_key.clone()) - } else { - // Signal that the migration is complete (no more items to process). - cursor = None; - break; - } + Ok(()) } - log::info!(target: LOG_TARGET, "🚚 iterated {count} entries, migrated {migrated}"); - Ok(cursor) } } -/// Double the remaining block for next era start -pub struct AdjustEraMigration(PhantomData); - -impl OnRuntimeUpgrade for AdjustEraMigration { - fn on_runtime_upgrade() -> Weight { - log::info!("🚚 migrated to async backing, adjust next era start"); - ActiveProtocolState::::mutate_exists(|maybe| { - if let Some(state) = maybe { - let current_block_number = - frame_system::Pallet::::block_number().saturated_into::(); - let remaining = state.next_era_start.saturating_sub(current_block_number); - state.next_era_start.saturating_accrue(remaining); - } - }); - T::DbWeight::get().reads_writes(1, 1) - } -} - -pub const EXPECTED_PALLET_DAPP_STAKING_VERSION: u16 = 9; - -pub struct DappStakingCleanupMigration(PhantomData); -impl OnRuntimeUpgrade for DappStakingCleanupMigration { - fn on_runtime_upgrade() -> Weight { - let dapp_staking_storage_version = - as GetStorageVersion>::on_chain_storage_version(); - if dapp_staking_storage_version != EXPECTED_PALLET_DAPP_STAKING_VERSION { - log::info!("Aborting migration due to unexpected on-chain storage versions for pallet-dapp-staking: {:?}. Expectation was: {:?}.", dapp_staking_storage_version, EXPECTED_PALLET_DAPP_STAKING_VERSION); - return T::DbWeight::get().reads(1); - } - - let pallet_prefix: &[u8] = b"DappStaking"; - let result = - clear_storage_prefix(pallet_prefix, b"ActiveBonusUpdateState", &[], None, None); - log::info!( - "cleanup dAppStaking migration result: {:?}", - result.deconstruct() - ); +mod v10 { + use super::*; + use frame_support::storage_alias; - T::DbWeight::get().reads_writes(1, 1) + /// v10 DAppTierRewards (without rank_points) + #[derive(Encode, Decode, Clone)] + pub struct DAppTierRewards, NT: Get> { + pub dapps: BoundedBTreeMap, + pub rewards: BoundedVec, + #[codec(compact)] + pub period: PeriodNumber, + pub rank_rewards: BoundedVec, } + + /// v10 storage alias for DAppTiers + #[storage_alias] + pub type DAppTiers = StorageMap< + Pallet, + Twox64Concat, + EraNumber, + DAppTierRewards<::MaxNumberOfContracts, ::NumberOfTiers>, + OptionQuery, + >; } diff --git a/pallets/dapp-staking/src/test/migrations.rs b/pallets/dapp-staking/src/test/migrations.rs deleted file mode 100644 index d1e1109acc..0000000000 --- a/pallets/dapp-staking/src/test/migrations.rs +++ /dev/null @@ -1,85 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later - -// Astar 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. - -// Astar 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 Astar. If not, see . - -#![cfg(all(test, not(feature = "runtime-benchmarks")))] - -use crate::test::mock::*; -use crate::{AccountLedger, CurrentEraInfo, EraInfo, Ledger, UnlockingChunk}; -use frame_support::traits::OnRuntimeUpgrade; - -#[test] -fn lazy_migrations() { - ExtBuilder::default().build_and_execute(|| { - Ledger::::set( - &1, - AccountLedger { - locked: 1000, - unlocking: vec![ - UnlockingChunk { - amount: 100, - unlock_block: 5, - }, - UnlockingChunk { - amount: 100, - unlock_block: 20, - }, - ] - .try_into() - .unwrap(), - staked: Default::default(), - staked_future: None, - contract_stake_count: 0, - }, - ); - CurrentEraInfo::::put(EraInfo { - total_locked: 1000, - unlocking: 200, - current_stake_amount: Default::default(), - next_stake_amount: Default::default(), - }); - - // go to block before migration - run_to_block(9); - - // onboard MBMs - AllPalletsWithSystem::on_runtime_upgrade(); - run_to_block(10); - - assert_eq!( - Ledger::::get(&1), - AccountLedger { - locked: 1000, - unlocking: vec![ - UnlockingChunk { - amount: 100, - unlock_block: 5, // already unlocked - }, - UnlockingChunk { - amount: 100, - unlock_block: 30, // double remaining blocks - }, - ] - .try_into() - .unwrap(), - staked: Default::default(), - staked_future: None, - contract_stake_count: 0, - } - ); - }) -} diff --git a/pallets/dapp-staking/src/test/mock.rs b/pallets/dapp-staking/src/test/mock.rs index 754b74635d..cfb067e8ba 100644 --- a/pallets/dapp-staking/src/test/mock.rs +++ b/pallets/dapp-staking/src/test/mock.rs @@ -88,8 +88,7 @@ parameter_types! { #[derive_impl(pallet_migrations::config_preludes::TestDefaultConfig)] impl pallet_migrations::Config for Test { #[cfg(not(feature = "runtime-benchmarks"))] - type Migrations = - (crate::migration::LazyMigration>,); + type Migrations = (); #[cfg(feature = "runtime-benchmarks")] type Migrations = pallet_migrations::mock_helpers::MockedMigrations; type MaxServiceWeight = MaxServiceWeight; @@ -342,6 +341,14 @@ impl ExtBuilder { ]) .unwrap(), slot_number_args: STANDARD_TIER_SLOTS_ARGS, + rank_points: BoundedVec::try_from(vec![ + BoundedVec::try_from(vec![1u8]).unwrap(), + BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10]).unwrap(), + BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10]).unwrap(), + BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10]).unwrap(), + ]) + .unwrap(), + base_reward_portion: Permill::from_percent(50), }; let total_issuance = ::Currency::total_issuance(); diff --git a/pallets/dapp-staking/src/test/mod.rs b/pallets/dapp-staking/src/test/mod.rs index 7c891a6b2d..f5baecd0a1 100644 --- a/pallets/dapp-staking/src/test/mod.rs +++ b/pallets/dapp-staking/src/test/mod.rs @@ -16,7 +16,6 @@ // You should have received a copy of the GNU General Public License // along with Astar. If not, see . -mod migrations; pub(crate) mod mock; mod testing_utils; mod tests; diff --git a/pallets/dapp-staking/src/test/tests.rs b/pallets/dapp-staking/src/test/tests.rs index c502e60da8..426559e2ae 100644 --- a/pallets/dapp-staking/src/test/tests.rs +++ b/pallets/dapp-staking/src/test/tests.rs @@ -2798,6 +2798,8 @@ fn get_dapp_tier_assignment_and_rewards_basic_example_works() { config.slots_per_tier = BoundedVec::try_from(vec![2, 5, 13, 20]).unwrap(); }); + let tier_params = StaticTierParams::::get(); + // Scenario: // - 1st tier is filled up, with one dApp satisfying the threshold but not making it due to lack of tier capacity // - 2nd tier has 2 dApps - 1 that could make it into the 1st tier and one that's supposed to be in the 2nd tier @@ -2869,18 +2871,25 @@ fn get_dapp_tier_assignment_and_rewards_basic_example_works() { // Finally, the actual test let protocol_state = ActiveProtocolState::::get(); - let dapp_reward_pool = 1000000; + let dapp_reward_pool = 1_000_000; let (tier_assignment, counter) = DappStaking::get_dapp_tier_assignment_and_rewards( protocol_state.era + 1, protocol_state.period_number(), dapp_reward_pool, ); - // There's enough reward to satisfy 100% reward per rank. - // Slot reward is 60_000 therefore expected rank reward is 6_000 + // Debug: Print actual ranks assigned + for (dapp_id, ranked_tier) in tier_assignment.dapps.iter() { + let (tier, rank) = ranked_tier.deconstruct(); + println!("Tier {}: dApp {} has rank {}", tier, dapp_id, rank); + } + + // Ranks rewards are 50% of the tier allocation + // Dapp rewards allocations for tiers are: 40%, 30%, 20%, 10% + // Points per tiers are: 1, 55, 55, 55 assert_eq!( tier_assignment.rank_rewards, - BoundedVec::>::try_from(vec![0, 6_000, 0, 0]).unwrap() + BoundedVec::>::try_from(vec![200_000, 2_727, 1_818, 909]).unwrap() ); // Basic checks @@ -2896,18 +2905,18 @@ fn get_dapp_tier_assignment_and_rewards_basic_example_works() { // 1st tier checks let (dapp_1_tier, dapp_2_tier) = (tier_assignment.dapps[&0], tier_assignment.dapps[&1]); - assert_eq!(dapp_1_tier, RankedTier::new_saturated(0, 0)); - assert_eq!(dapp_2_tier, RankedTier::new_saturated(0, 0)); + assert_eq!(dapp_1_tier, RankedTier::new_saturated(0, 0, 9)); + assert_eq!(dapp_2_tier, RankedTier::new_saturated(0, 0, 9)); // 2nd tier checks let (dapp_3_tier, dapp_4_tier) = (tier_assignment.dapps[&2], tier_assignment.dapps[&3]); - assert_eq!(dapp_3_tier, RankedTier::new_saturated(1, 10)); - assert_eq!(dapp_4_tier, RankedTier::new_saturated(1, 9)); + assert_eq!(dapp_3_tier, RankedTier::new_saturated(1, 9, 9)); + assert_eq!(dapp_4_tier, RankedTier::new_saturated(1, 9, 9)); // 4th tier checks let (dapp_5_tier, dapp_6_tier) = (tier_assignment.dapps[&4], tier_assignment.dapps[&5]); - assert_eq!(dapp_5_tier, RankedTier::new_saturated(3, 0)); - assert_eq!(dapp_6_tier, RankedTier::new_saturated(3, 0)); + assert_eq!(dapp_5_tier, RankedTier::new_saturated(3, 0, 9)); + assert_eq!(dapp_6_tier, RankedTier::new_saturated(3, 0, 9)); // Sanity check - last dapp should not exists in the tier assignment assert!(tier_assignment @@ -2923,7 +2932,10 @@ fn get_dapp_tier_assignment_and_rewards_basic_example_works() { .enumerate() .for_each(|(idx, (reward_portion, slots))| { let total_tier_allocation = *reward_portion * dapp_reward_pool; - let tier_reward: Balance = total_tier_allocation / (*slots as Balance); + let base_portion = tier_params.base_reward_portion; + let tier_reward: Balance = base_portion + .mul_floor(total_tier_allocation) + .saturating_div((*slots).into()); assert_eq!(tier_assignment.rewards[idx], tier_reward,); }); @@ -2961,6 +2973,10 @@ fn get_dapp_tier_assignment_and_rewards_zero_slots_per_tier_works() { tier_assignment.rewards[0].is_zero(), "1st tier has no slots so no rewards should be assigned to it." ); + assert!( + tier_assignment.rank_rewards[0].is_zero(), + "1st tier has no slots so no rank rewards should be assigned." + ); // Regardless of that, other tiers shouldn't benefit from this assert!(tier_assignment.rewards.iter().sum::() < dapp_reward_pool); @@ -3571,14 +3587,45 @@ fn base_number_of_slots_is_respected() { } #[test] -fn ranking_will_calc_reward_correctly() { +fn ranking_with_points_calculates_reward_correctly() { ExtBuilder::default().build_and_execute(|| { + // Configure tiers with specific rank_points for predictable testing + // Tier 1: 3 slots with points [5, 10, 15] (sum = 30) + // Tier 2: 2 slots with points [4, 8] (sum = 12) + let tier_params = TierParameters::<::NumberOfTiers> { + reward_portion: BoundedVec::try_from(vec![ + Permill::from_percent(40), + Permill::from_percent(30), + Permill::from_percent(20), + Permill::from_percent(10), + ]) + .unwrap(), + slot_distribution: BoundedVec::try_from(vec![ + Permill::from_percent(10), + Permill::from_percent(20), + Permill::from_percent(30), + Permill::from_percent(40), + ]) + .unwrap(), + tier_thresholds: StaticTierParams::::get().tier_thresholds, + slot_number_args: (0, 16), + rank_points: BoundedVec::try_from(vec![ + BoundedVec::try_from(vec![]).unwrap(), // tier 0: no ranking + BoundedVec::try_from(vec![5u8, 10, 15]).unwrap(), // tier 1: sum = 30 + BoundedVec::try_from(vec![4u8, 8]).unwrap(), // tier 2: sum = 12 + BoundedVec::try_from(vec![]).unwrap(), // tier 3: no ranking + ]) + .unwrap(), + base_reward_portion: Permill::from_percent(50), + }; + StaticTierParams::::put(tier_params); + // Tier config is specially adapted for this test. TierConfig::::mutate(|config| { config.slots_per_tier = BoundedVec::try_from(vec![2, 3, 2, 20]).unwrap(); }); - // Register smart contracts + // Register 8 smart contracts let smart_contracts: Vec<_> = (1..=8u32) .map(|x| { let smart_contract = MockSmartContract::Wasm(x.into()); @@ -3606,38 +3653,64 @@ fn ranking_will_calc_reward_correctly() { 1_000_000, ); + // Verify rank_points are stored + assert_eq!(tier_assignment.rank_points[1], vec![5u8, 10, 15]); + assert_eq!(tier_assignment.rank_points[2], vec![4u8, 8]); + assert_eq!( tier_assignment, DAppTierRewardsFor:: { dapps: BoundedBTreeMap::try_from(BTreeMap::from([ - (0, RankedTier::new_saturated(0, 0)), - (1, RankedTier::new_saturated(0, 0)), - (2, RankedTier::new_saturated(1, 10)), - (3, RankedTier::new_saturated(1, 9)), - (5, RankedTier::new_saturated(2, 9)), - (6, RankedTier::new_saturated(2, 5)), - (4, RankedTier::new_saturated(3, 0)), + (0, RankedTier::new_saturated(0, 0, 0)), + (1, RankedTier::new_saturated(0, 0, 0)), + (2, RankedTier::new_saturated(1, 2, 3)), + (3, RankedTier::new_saturated(1, 1, 3)), + (5, RankedTier::new_saturated(2, 0, 2)), + (6, RankedTier::new_saturated(2, 0, 2)), + (4, RankedTier::new_saturated(3, 0, 0)), ])) .unwrap(), - rewards: BoundedVec::try_from(vec![200_000, 100_000, 100_000, 5_000]).unwrap(), + // Verify base rewards (50% of tier allocation / slots) + rewards: BoundedVec::try_from(vec![100_000, 50_000, 50_000, 2_500]).unwrap(), period: 1, - // Tier 0 has no ranking therefore no rank reward. - // For tier 1 there's not enough reward to satisfy 100% reward per rank. - // Only one slot is empty. Slot reward is 100_000 therefore expected rank reward is 100_000 / 19 (ranks_sum). - // Tier 2 has ranking but there's no empty slot therefore no rank reward. - // Tier 3 has no ranking therefore no rank reward. - rank_rewards: BoundedVec::try_from(vec![0, 5_263, 0, 0]).unwrap() + // Verify rank rewards (50% of tier allocation / total_points) + // Tier 0: no ranking β†’ 0 + // Tier 1: 150k / 30 points = 5k per point + // Tier 2: 100k / 12 points = 8,333 per point + // Tier 3: no ranking β†’ 0 + rank_rewards: BoundedVec::try_from(vec![0, 5_000, 8_333, 0]).unwrap(), + rank_points: BoundedVec::try_from(vec![ + BoundedVec::try_from(vec![]).unwrap(), // tier 0: no ranking + BoundedVec::try_from(vec![5u8, 10, 15]).unwrap(), // tier 1: sum = 30 + BoundedVec::try_from(vec![4u8, 8]).unwrap(), // tier 2: sum = 12 + BoundedVec::try_from(vec![]).unwrap(), // tier 3: no ranking + ]) + .unwrap(), } ); // one didn't make it assert_eq!(counter, 8); + assert_eq!(tier_assignment.dapps.len(), 7); }) } #[test] -fn claim_dapp_reward_with_rank() { +fn claim_dapp_reward_with_rank_points() { ExtBuilder::default().build_and_execute(|| { + // Configure tier 1 with rank_points for testing + // 5 slots with points [1, 5, 10, 15, 20] + StaticTierParams::::mutate(|params| { + params.rank_points = BoundedVec::try_from(vec![ + BoundedVec::try_from(vec![]).unwrap(), + BoundedVec::try_from(vec![1, 5, 10, 15, 20]).unwrap(), + BoundedVec::try_from(vec![]).unwrap(), + BoundedVec::try_from(vec![]).unwrap(), + ]) + .unwrap(); + params.base_reward_portion = Permill::from_percent(50); + }); + let total_issuance = ::Currency::total_issuance(); // Register smart contract, lock&stake some amount @@ -3645,7 +3718,7 @@ fn claim_dapp_reward_with_rank() { assert_register(1, &smart_contract); let alice = 2; - let amount = Perbill::from_parts(11_000_000) * total_issuance; // very close to tier 0 so will enter tier 1 with rank 9 + let amount = Perbill::from_parts(11_000_000) * total_issuance; // very close to tier 0 so will enter tier 1 with rank 4 assert_lock(alice, amount); assert_stake(alice, &smart_contract, amount); @@ -3655,8 +3728,19 @@ fn claim_dapp_reward_with_rank() { let era = ActiveProtocolState::::get().era - 1; let tiers = DAppTiers::::get(era).unwrap(); - let slot_reward = tiers.rewards[1]; - let rank_reward = tiers.rank_rewards[1]; + // Verify tier assignment + let ranked_tier = tiers.dapps.get(&0).unwrap(); + assert_eq!(ranked_tier.tier(), 1, "Should be in tier 1"); + let (tier_id, rank) = ranked_tier.deconstruct(); + + // Get reward components + let base_reward = tiers.rewards[tier_id as usize]; + let rank_reward_per_point = tiers.rank_rewards[tier_id as usize]; + let points = tiers.rank_points[tier_id as usize][rank as usize]; + + // Calculate expected reward: base + (rank_reward_per_point * points) + let expected_rank_reward = rank_reward_per_point * (points as Balance); + let expected_total_reward = base_reward + expected_rank_reward; // Claim dApp reward & verify event assert_ok!(DappStaking::claim_dapp_reward( @@ -3665,17 +3749,11 @@ fn claim_dapp_reward_with_rank() { era, )); - let expected_rank = 9; - let expected_total_reward = slot_reward + expected_rank * rank_reward; - assert_eq!(slot_reward, 15_000_000); - assert_eq!(rank_reward, 1_500_000); // slot_reward / 10 - assert_eq!(expected_total_reward, 28_500_000); - System::assert_last_event(RuntimeEvent::DappStaking(Event::DAppReward { beneficiary: 1, smart_contract: smart_contract.clone(), tier_id: 1, - rank: 9, + rank: 4, era, amount: expected_total_reward, })); diff --git a/pallets/dapp-staking/src/test/tests_types.rs b/pallets/dapp-staking/src/test/tests_types.rs index 3810dfaa9c..7404ec9a33 100644 --- a/pallets/dapp-staking/src/test/tests_types.rs +++ b/pallets/dapp-staking/src/test/tests_types.rs @@ -3488,6 +3488,13 @@ fn tier_params_check_is_ok() { ]) .unwrap(), slot_number_args: STANDARD_TIER_SLOTS_ARGS, + rank_points: BoundedVec::try_from(vec![ + BoundedVec::try_from(vec![6u8, 8, 10]).unwrap(), + BoundedVec::try_from(vec![1u8, 3, 5]).unwrap(), + BoundedVec::try_from(vec![1u8, 2]).unwrap(), + ]) + .unwrap(), + base_reward_portion: Permill::from_percent(50), }; assert!(params.is_valid()); @@ -3572,6 +3579,25 @@ fn tier_params_check_is_ok() { ]) .unwrap(); assert!(!invalid_dynamic_params.is_valid()); + + // 7th scenario - rank_points length mismatch with number of tiers + let mut invalid_rank_points = params.clone(); + invalid_rank_points.rank_points = BoundedVec::try_from(vec![ + BoundedVec::try_from(vec![8u8, 10]).unwrap(), + BoundedVec::try_from(vec![3u8, 5]).unwrap(), + // Missing 3rd tier rank_points + ]) + .unwrap(); + assert!(!invalid_rank_points.is_valid()); + + // 8th scenario - base_reward_portion at extremes (0% and 100% are valid) + let mut zero_base = params.clone(); + zero_base.base_reward_portion = Permill::from_percent(0); + assert!(zero_base.is_valid(), "0% base (100% rank) is valid"); + + let mut full_base = params.clone(); + full_base.base_reward_portion = Permill::from_percent(100); + assert!(full_base.is_valid(), "100% base (0% rank) is valid"); } #[test] @@ -3615,6 +3641,14 @@ fn tier_configuration_basic_tests() { ]) .unwrap(), slot_number_args: STANDARD_TIER_SLOTS_ARGS, + rank_points: BoundedVec::try_from(vec![ + BoundedVec::try_from(vec![6u8, 9, 12, 15]).unwrap(), + BoundedVec::try_from(vec![4u8, 7, 10]).unwrap(), + BoundedVec::try_from(vec![1u8, 3, 5]).unwrap(), + BoundedVec::try_from(vec![1u8]).unwrap(), + ]) + .unwrap(), + base_reward_portion: Permill::from_percent(50), }; assert!(params.is_valid(), "Example params must be valid!"); @@ -3658,11 +3692,11 @@ fn dapp_tier_rewards_basic_tests() { // Example dApps & rewards let dapps = BTreeMap::::from([ - (1, RankedTier::new_saturated(0, 0)), - (2, RankedTier::new_saturated(0, 0)), - (3, RankedTier::new_saturated(1, 0)), - (5, RankedTier::new_saturated(1, 0)), - (6, RankedTier::new_saturated(2, 0)), + (1, RankedTier::new_saturated(0, 0, 10)), + (2, RankedTier::new_saturated(0, 0, 10)), + (3, RankedTier::new_saturated(1, 0, 10)), + (5, RankedTier::new_saturated(1, 0, 10)), + (6, RankedTier::new_saturated(2, 0, 10)), ]); let tier_rewards = vec![300, 20, 1]; let period = 2; @@ -3672,6 +3706,7 @@ fn dapp_tier_rewards_basic_tests() { tier_rewards.clone(), period, vec![0, 0, 0], + vec![], ) .expect("Bounds are respected."); @@ -3746,11 +3781,11 @@ fn dapp_tier_rewards_with_rank() { // Example dApps & rewards let dapps = BTreeMap::::from([ - (1, RankedTier::new_saturated(0, 5)), - (2, RankedTier::new_saturated(0, 0)), - (3, RankedTier::new_saturated(1, 10)), - (5, RankedTier::new_saturated(1, 5)), - (6, RankedTier::new_saturated(2, 0)), + (1, RankedTier::new_saturated(0, 5, 10)), + (2, RankedTier::new_saturated(0, 0, 10)), + (3, RankedTier::new_saturated(1, 10, 10)), + (5, RankedTier::new_saturated(1, 5, 10)), + (6, RankedTier::new_saturated(2, 0, 10)), ]); let tier_rewards = vec![300, 20, 1]; let rank_rewards = vec![0, 2, 0]; @@ -3761,6 +3796,7 @@ fn dapp_tier_rewards_with_rank() { tier_rewards.clone(), period, rank_rewards.clone(), + vec![], ) .expect("Bounds are respected."); @@ -3791,6 +3827,212 @@ fn dapp_tier_rewards_with_rank() { ); } +#[test] +fn dapp_tier_rewards_with_rank_points() { + get_u32_type!(NumberOfDApps, 8); + get_u32_type!(NumberOfTiers, 3); + + // New behavior: rank_points populated, uses points * rank_rewards + // Tier 0: positions 0,1,2 have points [15, 12, 9] + // Tier 1: positions 0,1,2,3 have points [10, 7, 4, 1] + // Tier 2: positions 0,1 have points [5, 2] + let dapps = BTreeMap::::from([ + (1, RankedTier::new_saturated(0, 0, 10)), // tier 0, rank 0 β†’ points 15 + (2, RankedTier::new_saturated(0, 2, 10)), // tier 0, rank 2 β†’ points 9 + (3, RankedTier::new_saturated(1, 1, 10)), // tier 1, rank 1 β†’ points 7 + (4, RankedTier::new_saturated(1, 3, 10)), // tier 1, rank 3 β†’ points 1 + (5, RankedTier::new_saturated(2, 0, 10)), // tier 2, rank 0 β†’ points 5 + ]); + let tier_rewards = vec![100, 50, 10]; // base reward per tier + let rank_rewards = vec![10, 5, 2]; // reward per point per tier + let period = 2; + let rank_points = vec![ + vec![9u8, 12, 15], // tier 0 + vec![1u8, 4, 7, 10], // tier 1 + vec![2u8, 5], // tier 2 + ]; + + let mut dapp_tier_rewards = DAppTierRewards::::new( + dapps.clone(), + tier_rewards.clone(), + period, + rank_rewards.clone(), + rank_points.clone(), + ) + .expect("Bounds are respected."); + + // dApp 1: tier 0, rank 0, points 9 β†’ 100 + (10 * 9) = 190 + let ranked_tier = dapps[&1]; + assert_eq!( + dapp_tier_rewards.try_claim(1), + Ok((100 + 10 * 9, ranked_tier)) + ); + + // dApp 2: tier 0, rank 2, points 15 β†’ 100 + (10 * 15) = 250 + let ranked_tier = dapps[&2]; + assert_eq!( + dapp_tier_rewards.try_claim(2), + Ok((100 + 10 * 15, ranked_tier)) + ); + + // dApp 3: tier 1, rank 1, points 4 β†’ 50 + (5 * 4) = 70 + let ranked_tier = dapps[&3]; + assert_eq!( + dapp_tier_rewards.try_claim(3), + Ok((50 + 5 * 4, ranked_tier)) + ); + + // dApp 4: tier 1, rank 3, points 10 β†’ 50 + (5 * 10) = 100 + let ranked_tier = dapps[&4]; + assert_eq!( + dapp_tier_rewards.try_claim(4), + Ok((50 + 5 * 10, ranked_tier)) + ); + + // dApp 5: tier 2, rank 0, points 2 β†’ 10 + (2 * 2) = 14 + let ranked_tier = dapps[&5]; + assert_eq!( + dapp_tier_rewards.try_claim(5), + Ok((10 + 2 * 2, ranked_tier)) + ); +} + +#[test] +fn dapp_tier_rewards_rank_out_of_bounds() { + get_u32_type!(NumberOfDApps, 4); + get_u32_type!(NumberOfTiers, 2); + + // rank_points only has 2 entries per tier, but dApp has rank 5 + let dapps = BTreeMap::::from([ + (1, RankedTier::new_saturated(0, 5, 10)), // rank 5, but only points[0..2] exist + ]); + let tier_rewards = vec![100, 50]; + let rank_rewards = vec![10, 5]; + let rank_points = vec![ + vec![12u8, 15], // only 2 entries + vec![7u8, 10], + ]; + + let mut dapp_tier_rewards = DAppTierRewards::::new( + dapps.clone(), + tier_rewards.clone(), + 2, + rank_rewards.clone(), + rank_points, + ) + .expect("Bounds are respected."); + + // rank 5 is out of bounds β†’ points = 0 β†’ only base reward + let ranked_tier = dapps[&1]; + assert_eq!( + dapp_tier_rewards.try_claim(1), + Ok((100, ranked_tier)), // base only, no rank reward + ); +} + +#[test] +fn dapp_tier_rewards_base_portion_allocation() { + get_u32_type!(NumberOfDApps, 8); + get_u32_type!(NumberOfTiers, 3); + + // rank_points for tier 1 (ascending): [2, 4, 6, 8, 10] (5 elements, indices 0-4) + let rank_points_tier1 = vec![2u8, 4, 6, 8, 10]; + let max_rank: u8 = rank_points_tier1.len() as u8; // 5 + + // Scenario 1: 50% base / 50% rank, dApp at rank 3 (8 points) + { + let dapps = BTreeMap::from([ + (1, RankedTier::new_saturated(1, 3, max_rank)), // tier 1, rank 3 + ]); + let mut entry = DAppTierRewards::::new( + dapps, + vec![0, 500, 0], // base reward per tier + 1, + vec![0, 16, 0], // reward per point + vec![vec![], rank_points_tier1.clone(), vec![]], + ) + .unwrap(); + + let (reward, rt) = entry.try_claim(1).unwrap(); + let (_, rank) = rt.deconstruct(); + + assert_eq!(rank, 3); + let points = rank_points_tier1[rank as usize]; + assert_eq!(points, 8, "rank 3 β†’ index 3 β†’ 8 points"); + assert_eq!(reward, 500 + 16 * 8, "base=500 + rank=128 = 628"); + } + + // Scenario 2: Compare all ranks in tier 1 + { + let dapps = BTreeMap::from([ + (0, RankedTier::new_saturated(1, 0, max_rank)), // rank 0 β†’ 2 points + (1, RankedTier::new_saturated(1, 1, max_rank)), // rank 1 β†’ 4 points + (2, RankedTier::new_saturated(1, 2, max_rank)), // rank 2 β†’ 6 points + (3, RankedTier::new_saturated(1, 3, max_rank)), // rank 3 β†’ 8 points + (4, RankedTier::new_saturated(1, 4, max_rank)), // rank 4 β†’ 10 points + ]); + let mut entry = DAppTierRewards::::new( + dapps, + vec![0, 100, 0], // base = 100 + 1, + vec![0, 10, 0], // 10 per point + vec![vec![], rank_points_tier1.clone(), vec![]], + ) + .unwrap(); + + // Claim in order and verify rewards increase with rank + let (r0, _) = entry.try_claim(0).unwrap(); + let (r1, _) = entry.try_claim(1).unwrap(); + let (r2, _) = entry.try_claim(2).unwrap(); + let (r3, _) = entry.try_claim(3).unwrap(); + let (r4, _) = entry.try_claim(4).unwrap(); + + assert_eq!(r0, 100 + 10 * 2, "rank 0: 100 + 20 = 120"); + assert_eq!(r1, 100 + 10 * 4, "rank 1: 100 + 40 = 140"); + assert_eq!(r2, 100 + 10 * 6, "rank 2: 100 + 60 = 160"); + assert_eq!(r3, 100 + 10 * 8, "rank 3: 100 + 80 = 180"); + assert_eq!(r4, 100 + 10 * 10, "rank 4: 100 + 100 = 200"); + + assert!( + r0 < r1 && r1 < r2 && r2 < r3 && r3 < r4, + "Higher rank (higher stake) should earn more" + ); + } + + // Scenario 3: 100% base (no rank bonus) + { + let dapps = BTreeMap::from([(1, RankedTier::new_saturated(1, 4, max_rank))]); + let mut entry = DAppTierRewards::::new( + dapps, + vec![0, 1000, 0], // 100% to base + 1, + vec![0, 0, 0], // 0% to rank + vec![vec![], rank_points_tier1.clone(), vec![]], + ) + .unwrap(); + + let (reward, _) = entry.try_claim(1).unwrap(); + assert_eq!(reward, 1000, "100% base: only base reward, no rank bonus"); + } + + // Scenario 4: 0% base (all rank) + { + let dapps = BTreeMap::from([(1, RankedTier::new_saturated(1, 4, max_rank))]); + let mut entry = DAppTierRewards::::new( + dapps, + vec![0, 0, 0], // 0% base + 1, + vec![0, 33, 0], // all to rank + vec![vec![], rank_points_tier1.clone(), vec![]], + ) + .unwrap(); + + let (reward, _) = entry.try_claim(1).unwrap(); + // rank 4 β†’ 10 points β†’ 33 * 10 = 330 + assert_eq!(reward, 33 * 10, "0% base: only rank reward = 330"); + } +} + #[test] fn tier_thresholds_conversion_test() { get_u32_type!(TiersNum, 2); @@ -3890,6 +4132,8 @@ fn tier_configuration_calculate_new_with_maximum_threshold() { tier_thresholds: tier_thresholds_legacy, reward_portion: reward_portion.clone(), slot_number_args: STANDARD_TIER_SLOTS_ARGS, + rank_points: Default::default(), + base_reward_portion: Default::default(), }; let params_with_max = TierParameters:: { @@ -3897,6 +4141,8 @@ fn tier_configuration_calculate_new_with_maximum_threshold() { tier_thresholds: tier_thresholds_with_max, reward_portion: reward_portion.clone(), slot_number_args: STANDARD_TIER_SLOTS_ARGS, + rank_points: Default::default(), + base_reward_portion: Default::default(), }; // Create a starting configuration with some values diff --git a/pallets/dapp-staking/src/types.rs b/pallets/dapp-staking/src/types.rs index aa44e0508a..76b273a18a 100644 --- a/pallets/dapp-staking/src/types.rs +++ b/pallets/dapp-staking/src/types.rs @@ -75,13 +75,13 @@ use sp_runtime::{ }; pub use sp_std::{collections::btree_map::BTreeMap, fmt::Debug, vec::Vec}; +use crate::pallet::Config; +use astar_primitives::dapp_staking::MAX_ENCODED_RANK; use astar_primitives::{ dapp_staking::{DAppId, EraNumber, PeriodNumber, RankedTier, TierSlots as TierSlotsFunc}, Balance, BlockNumber, }; -use crate::pallet::Config; - // Convenience type for `AccountLedger` usage. pub type AccountLedgerFor = AccountLedger<::MaxUnlockingChunks>; @@ -879,7 +879,7 @@ impl Iterator for EraStakePairIter { if self.start_era <= self.end_era { let value = (self.start_era, self.amount); self.start_era.saturating_inc(); - return Some(value); + Some(value) } else { None } @@ -1710,6 +1710,11 @@ pub struct TierParameters> { /// This can be made more generic in the future in case more complex equations are required. /// But for now this simple tuple serves the purpose. pub(crate) slot_number_args: (u64, u64), + /// Rank points per tier in ASCENDING order, index = rank + pub(crate) rank_points: BoundedVec>, NT>, + /// Portion of tier allocation for base rewards (remainder β†’ rank rewards) + /// e.g., Permill::from_percent(50) = 50% base, 50% rank + pub(crate) base_reward_portion: Permill, } impl> TierParameters { @@ -1760,6 +1765,7 @@ impl> TierParameters { number_of_tiers == self.reward_portion.len() && number_of_tiers == self.slot_distribution.len() && number_of_tiers == self.tier_thresholds.len() + && number_of_tiers == self.rank_points.len() } } @@ -1931,6 +1937,8 @@ pub struct DAppTierRewards, NT: Get> { pub(crate) period: PeriodNumber, /// Rank reward for each tier. First entry refers to the first tier, and so on. pub(crate) rank_rewards: BoundedVec, + /// Points configuration for each tier/rank in ASCENDING order. + pub(crate) rank_points: BoundedVec>, NT>, } impl, NT: Get> DAppTierRewards { @@ -1941,15 +1949,24 @@ impl, NT: Get> DAppTierRewards { rewards: Vec, period: PeriodNumber, rank_rewards: Vec, + rank_points: Vec>, ) -> Result { let dapps = BoundedBTreeMap::try_from(dapps).map_err(|_| ())?; let rewards = BoundedVec::try_from(rewards).map_err(|_| ())?; let rank_rewards = BoundedVec::try_from(rank_rewards).map_err(|_| ())?; + + let rank_points: Vec>> = rank_points + .into_iter() + .map(|inner| BoundedVec::try_from(inner).map_err(|_| ())) + .collect::, ()>>()?; + let rank_points = BoundedVec::try_from(rank_points).map_err(|_| ())?; + Ok(Self { dapps, rewards, period, rank_rewards, + rank_points, }) } @@ -1968,12 +1985,25 @@ impl, NT: Get> DAppTierRewards { .get(tier_id as usize) .map_or(Balance::zero(), |x| *x); - let reward_per_rank = self + let reward_per_point = self .rank_rewards .get(tier_id as usize) .map_or(Balance::zero(), |x| *x); - let additional_reward = reward_per_rank.saturating_mul(rank.into()); + let additional_reward = if self.rank_points.is_empty() { + // Legacy formula: reward_per_point * rank + reward_per_point.saturating_mul(rank.into()) + } else { + let points: u32 = self + .rank_points + .get(tier_id as usize) + .and_then(|tier_points| tier_points.get(rank as usize)) + .copied() + .unwrap_or(0) + .into(); + reward_per_point.saturating_mul(points.into()) + }; + amount = amount.saturating_add(additional_reward); Ok((amount, ranked_tier)) diff --git a/precompiles/dapp-staking/src/test/mock.rs b/precompiles/dapp-staking/src/test/mock.rs index d577eebe53..2ee840282e 100644 --- a/precompiles/dapp-staking/src/test/mock.rs +++ b/precompiles/dapp-staking/src/test/mock.rs @@ -303,6 +303,14 @@ impl ExternalityBuilder { slot_number_args: STANDARD_TIER_SLOTS_ARGS, slots_per_tier: vec![10, 20, 30, 40], safeguard: None, + rank_points: BoundedVec::try_from(vec![ + BoundedVec::try_from(vec![1u8]).unwrap(), + BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]).unwrap(), + BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]).unwrap(), + BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]).unwrap(), + ]) + .unwrap(), + base_reward_portion: Permill::from_percent(50), _config: PhantomData, }, &mut storage, diff --git a/primitives/src/dapp_staking.rs b/primitives/src/dapp_staking.rs index edf3221276..4e847f0770 100644 --- a/primitives/src/dapp_staking.rs +++ b/primitives/src/dapp_staking.rs @@ -37,9 +37,14 @@ pub type PeriodNumber = u32; pub type DAppId = u16; /// Tier Id type pub type TierId = u8; -// Tier Rank type +/// Tier Rank type pub type Rank = u8; +/// Maximum encodable rank (4 bits) +pub const MAX_ENCODED_RANK: u32 = 0x0f; +/// Maximum encodable tier (4 bits) +pub const MAX_ENCODED_TIER: u8 = 0x0f; + /// Configuration for cycles, periods, subperiods & eras. /// /// * `cycle` - Time unit similar to 'year' in the real world. Consists of one or more periods. At the beginning of each cycle, inflation is recalculated. @@ -208,6 +213,7 @@ impl TierSlots for StandardTierSlots { /// Standard tier slots arguments. /// Initially decided for Astar, during the Tokenomics 2.0 work. pub const STANDARD_TIER_SLOTS_ARGS: (u64, u64) = (1000, 50); +pub const FIXED_TIER_SLOTS_ARGS: (u64, u64) = (0, 16); /// RankedTier is wrapper around u8 to hold both tier and rank. u8 has 2 bytes (8bits) and they're using in this order `0xrank_tier`. /// First 4 bits are used to hold rank and second 4 bits are used to hold tier. @@ -216,30 +222,43 @@ pub const STANDARD_TIER_SLOTS_ARGS: (u64, u64) = (1000, 50); pub struct RankedTier(u8); impl RankedTier { - pub const MAX_RANK: u8 = 10; + /// Validate max_rank fits in 4 bits + /// Returns Err(ArithmeticError::Overflow) if max value is not respected. + #[inline(always)] + fn validate_max_rank(max_rank: Rank) -> Result<(), ArithmeticError> { + if (max_rank as u32) > MAX_ENCODED_RANK { + Err(ArithmeticError::Overflow) + } else { + Ok(()) + } + } /// Create new encoded RankedTier from tier and rank. - /// Returns Err(ArithmeticError::Overflow) if max value is not respected. - pub fn new(tier: TierId, rank: Rank) -> Result { - if rank > Self::MAX_RANK || tier > 0xf { + /// `max_rank` defines how many ranks this tier supports. + /// Returns Err(ArithmeticError::Overflow) if max values are not respected. + pub fn new(tier: TierId, rank: Rank, max_rank: Rank) -> Result { + Self::validate_max_rank(max_rank)?; + + if tier > MAX_ENCODED_TIER || rank > max_rank { return Err(ArithmeticError::Overflow); } - Ok(Self(rank << 4 | tier & 0x0f)) + + Ok(Self((rank << 4) | (tier & 0x0f))) } /// Create new encoded RankedTier from tier and rank with saturation. - pub fn new_saturated(tier: TierId, rank: Rank) -> Self { - Self(rank.min(Self::MAX_RANK) << 4 | tier.min(0xf) & 0x0f) + pub fn new_saturated(tier: TierId, rank: Rank, max_rank: Rank) -> Self { + Self((rank.min(max_rank) << 4) | (tier.min(0x0f) & 0x0f)) } #[inline(always)] pub fn tier(&self) -> TierId { - self.0 & 0x0f + self.0 & MAX_ENCODED_TIER } #[inline(always)] pub fn rank(&self) -> Rank { - (self.0 >> 4).min(Self::MAX_RANK) + (self.0 >> 4).min(MAX_ENCODED_RANK as u8) } #[inline(always)] @@ -258,30 +277,35 @@ impl core::fmt::Debug for RankedTier { } impl RankedTier { - /// Find rank based on lower/upper bounds and staked amount. - /// Delta between upper and lower bound is divided in 10 and will increase rank + /// Find rank based on lower/upper bounds, stake amount and number of ranks. + /// Delta between upper and lower bound is divided in `max_rank` and will increase rank /// by one for each threshold staked amount will reach. - /// i.e. find_rank(10, 20, 10) -> 0 - /// i.e. find_rank(10, 20, 15) -> 5 - /// i.e. find_rank(10, 20, 20) -> 10 - pub fn find_rank(lower_bound: Balance, upper_bound: Balance, stake_amount: Balance) -> Rank { - if upper_bound.is_zero() { + /// + /// `max_rank` is the maximum rank for the tier (≀ 15). + pub fn find_rank( + lower_bound: Balance, + upper_bound: Balance, + stake_amount: Balance, + max_rank: Rank, + ) -> Rank { + if upper_bound.is_zero() || max_rank == 0 || (max_rank as u32) > MAX_ENCODED_RANK { return 0; } + let rank_threshold = upper_bound .saturating_sub(lower_bound) - .saturating_div(RankedTier::MAX_RANK.into()); + .saturating_div(max_rank.into()); if rank_threshold.is_zero() { - 0 - } else { - >::try_into( - stake_amount - .saturating_sub(lower_bound) - .saturating_div(rank_threshold), - ) - .unwrap_or_default() - .min(RankedTier::MAX_RANK) + return 0; } + + >::try_into( + stake_amount + .saturating_sub(lower_bound) + .saturating_div(rank_threshold), + ) + .unwrap_or_default() + .min(max_rank) } } @@ -289,42 +313,56 @@ impl RankedTier { mod tests { use super::*; + const MAX_RANK: u8 = 10; + #[test] fn tier_and_rank() { - let t = RankedTier::new(0, 0).unwrap(); + let t = RankedTier::new(0, 0, MAX_RANK).unwrap(); assert_eq!(t.deconstruct(), (0, 0)); - let t = RankedTier::new(15, 10).unwrap(); + let t = RankedTier::new(15, 10, MAX_RANK).unwrap(); assert_eq!(t.deconstruct(), (15, 10)); - assert_eq!(RankedTier::new(16, 10), Err(ArithmeticError::Overflow)); - assert_eq!(RankedTier::new(15, 11), Err(ArithmeticError::Overflow)); + assert_eq!( + RankedTier::new(16, 10, MAX_RANK), + Err(ArithmeticError::Overflow) + ); + assert_eq!( + RankedTier::new(15, 11, MAX_RANK), + Err(ArithmeticError::Overflow) + ); - let t = RankedTier::new_saturated(0, 0); + let t = RankedTier::new_saturated(0, 0, MAX_RANK); assert_eq!(t.deconstruct(), (0, 0)); - let t = RankedTier::new_saturated(1, 1); + let t = RankedTier::new_saturated(1, 1, MAX_RANK); assert_eq!(t.deconstruct(), (1, 1)); - let t = RankedTier::new_saturated(3, 15); + let t = RankedTier::new_saturated(3, 15, MAX_RANK); assert_eq!(t.deconstruct(), (3, 10)); // max value for tier and rank - let t = RankedTier::new_saturated(16, 16); + let t = RankedTier::new_saturated(16, 16, MAX_RANK); assert_eq!(t.deconstruct(), (15, 10)); } #[test] fn find_rank() { - assert_eq!(RankedTier::find_rank(0, 0, 0), 0); - assert_eq!(RankedTier::find_rank(0, 100, 9), 0); - assert_eq!(RankedTier::find_rank(0, 100, 10), 1); - assert_eq!(RankedTier::find_rank(0, 100, 49), 4); - assert_eq!(RankedTier::find_rank(0, 100, 50), 5); - assert_eq!(RankedTier::find_rank(0, 100, 51), 5); - assert_eq!(RankedTier::find_rank(0, 100, 101), 10); - - assert_eq!(RankedTier::find_rank(100, 100, 100), 0); - assert_eq!(RankedTier::find_rank(200, 100, 100), 0); + assert_eq!(RankedTier::find_rank(0, 0, 0, MAX_RANK), 0); + assert_eq!(RankedTier::find_rank(0, 100, 9, MAX_RANK), 0); + assert_eq!(RankedTier::find_rank(0, 100, 10, MAX_RANK), 1); + assert_eq!(RankedTier::find_rank(0, 100, 49, MAX_RANK), 4); + assert_eq!(RankedTier::find_rank(0, 100, 50, MAX_RANK), 5); + assert_eq!(RankedTier::find_rank(0, 100, 51, MAX_RANK), 5); + assert_eq!(RankedTier::find_rank(0, 100, 101, MAX_RANK), 10); + + assert_eq!(RankedTier::find_rank(100, 100, 100, MAX_RANK), 0); + assert_eq!(RankedTier::find_rank(200, 100, 100, MAX_RANK), 0); + } + + #[test] + fn different_max_ranks_work() { + assert_eq!(RankedTier::find_rank(0, 100, 100, 5), 5); + assert_eq!(RankedTier::find_rank(0, 100, 100, 15), 15); } } diff --git a/runtime/astar/src/genesis_config.rs b/runtime/astar/src/genesis_config.rs index dbeaaf5f54..46d2f10186 100644 --- a/runtime/astar/src/genesis_config.rs +++ b/runtime/astar/src/genesis_config.rs @@ -17,7 +17,7 @@ // along with Astar. If not, see . use crate::*; -use astar_primitives::{evm::EVM_REVERT_CODE, genesis::GenesisAccount, parachain::ASTAR_ID}; +use astar_primitives::{dapp_staking::MAX_ENCODED_RANK, evm::EVM_REVERT_CODE, genesis::GenesisAccount, parachain::ASTAR_ID}; /// Provides the JSON representation of predefined genesis config for given `id`. pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option> { @@ -58,6 +58,12 @@ pub fn default_config(para_id: u32) -> serde_json::Value { .map(|x| (x.clone(), 1_000_000_000 * ASTR)) .collect::>(); + let slots_per_tier = vec![0, 6, 10, 0]; + let rank_points: Vec> = slots_per_tier + .iter() + .map(|&slots| (1..=slots.min(MAX_ENCODED_RANK as u16) as u8).collect()) + .collect(); + let config = RuntimeGenesisConfig { system: Default::default(), #[cfg(feature = "astar-sudo")] @@ -125,40 +131,39 @@ pub fn default_config(para_id: u32) -> serde_json::Value { transaction_payment: Default::default(), dapp_staking: DappStakingConfig { reward_portion: vec![ - Permill::from_percent(40), + Permill::from_percent(0), + Permill::from_percent(70), Permill::from_percent(30), - Permill::from_percent(20), - Permill::from_percent(10), + Permill::from_percent(0), ], slot_distribution: vec![ - Permill::from_percent(10), - Permill::from_percent(20), - Permill::from_percent(30), - Permill::from_percent(40), + Permill::from_percent(0), + Permill::from_parts(375_000), // 37.5% + Permill::from_parts(625_000), // 62.5% + Permill::from_percent(0), ], - // percentages below are calculated based on a total issuance at the time when dApp staking v3 was launched (84.3M) + // percentages below are calculated based on a total issuance at the time when dApp staking v3 was revamped (8.6B) tier_thresholds: vec![ - TierThreshold::DynamicPercentage { - percentage: Perbill::from_parts(35_700_000), // 3.57% - minimum_required_percentage: Perbill::from_parts(23_800_000), // 2.38% - maximum_possible_percentage: Perbill::from_percent(100), + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(23_200_000), // 2.32% }, - TierThreshold::DynamicPercentage { - percentage: Perbill::from_parts(8_900_000), // 0.89% - minimum_required_percentage: Perbill::from_parts(6_000_000), // 0.6% - maximum_possible_percentage: Perbill::from_percent(100), + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(11_600_000), // 1.16% }, - TierThreshold::DynamicPercentage { - percentage: Perbill::from_parts(2_380_000), // 0.238% - minimum_required_percentage: Perbill::from_parts(1_790_000), // 0.179% - maximum_possible_percentage: Perbill::from_percent(100), + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(5_800_000), // 0.58% }, + // Tier 3: unreachable dummy TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(600_000), // 0.06% + required_percentage: Perbill::from_parts(0), // 0% }, ], - slots_per_tier: vec![10, 20, 30, 40], + slots_per_tier, + // Force fixed 16 slots + slot_number_args: (0, 16), safeguard: Some(false), + rank_points, + base_reward_portion: Permill::from_percent(10), ..Default::default() }, inflation: Default::default(), diff --git a/runtime/astar/src/lib.rs b/runtime/astar/src/lib.rs index a84daa2810..d7a3abb4a8 100644 --- a/runtime/astar/src/lib.rs +++ b/runtime/astar/src/lib.rs @@ -472,7 +472,7 @@ impl pallet_dapp_staking::Config for Runtime { type BaseNativeCurrencyPrice = BaseNativeCurrencyPrice; type EraRewardSpanLength = ConstU32<16>; type RewardRetentionInPeriods = ConstU32<4>; - type MaxNumberOfContracts = ConstU32<500>; + type MaxNumberOfContracts = ConstU32<16>; type MaxUnlockingChunks = ConstU32<8>; type MinimumLockedAmount = MinimumStakingAmount; type UnlockingPeriod = ConstU32<9>; @@ -500,15 +500,15 @@ impl pallet_inflation::PayoutPerBlock> for Inflation pub struct InflationCycleConfig; impl CycleConfiguration for InflationCycleConfig { fn periods_per_cycle() -> u32 { - 3 + 1 } fn eras_per_voting_subperiod() -> u32 { - 11 + 1 } fn eras_per_build_and_earn_subperiod() -> u32 { - 111 + 364 } fn blocks_per_era() -> BlockNumber { @@ -1743,6 +1743,62 @@ pub type Executive = frame_executive::Executive< AllPalletsWithSystem, Migrations, >; +pub struct AstarTierParamsV11; +impl pallet_dapp_staking::migration::TierParamsV11Config for AstarTierParamsV11 { + fn reward_portion() -> [Permill; 4] { + [ + Permill::from_percent(0), + Permill::from_percent(70), + Permill::from_percent(30), + Permill::from_percent(0), + ] + } + + fn slot_distribution() -> [Permill; 4] { + [ + Permill::from_percent(0), + Permill::from_parts(375_000), // 37.5% + Permill::from_parts(625_000), // 62.5% + Permill::from_percent(0), + ] + } + + fn tier_thresholds() -> [pallet_dapp_staking::TierThreshold; 4] { + use pallet_dapp_staking::TierThreshold; + [ + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(23_200_000), // 2.32% + }, + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(11_600_000), // 1.16% + }, + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(5_800_000), // 0.58% + }, + // Tier 3: unreachable dummy + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(0), // 0% + }, + ] + } + + fn slot_number_args() -> (u64, u64) { + (0, 16) + } + + fn rank_points() -> [Vec; 4] { + [ + vec![], // Tier 0: dummy + vec![10, 11, 12, 13, 14, 15], // Tier 1: 6 slots + vec![1, 3, 5, 7, 9, 11, 13, 15, 17, 19], // Tier 2: 10 slots + vec![], // Tier 3: dummy + ] + } + + fn base_reward_portion() -> Permill { + Permill::from_percent(10) + } +} /// All migrations that will run on the next runtime upgrade. /// @@ -1750,7 +1806,7 @@ pub type Executive = frame_executive::Executive< pub type Migrations = (Unreleased, Permanent); /// Unreleased migrations. Add new ones here: -pub type Unreleased = (); +pub type Unreleased = (pallet_dapp_staking::migration::versioned_migrations::V10ToV11,); /// Migrations/checks that do not need to be versioned and can run on every upgrade. pub type Permanent = (pallet_xcm::migration::MigrateToLatestXcmVersion,); diff --git a/runtime/shibuya/src/genesis_config.rs b/runtime/shibuya/src/genesis_config.rs index c81e36964e..da3c9d268f 100644 --- a/runtime/shibuya/src/genesis_config.rs +++ b/runtime/shibuya/src/genesis_config.rs @@ -17,7 +17,10 @@ // along with Astar. If not, see . use crate::*; -use astar_primitives::{evm::EVM_REVERT_CODE, genesis::GenesisAccount, parachain::SHIBUYA_ID}; +use astar_primitives::{ + dapp_staking::MAX_ENCODED_RANK, evm::EVM_REVERT_CODE, genesis::GenesisAccount, + parachain::SHIBUYA_ID, +}; /// Provides the JSON representation of predefined genesis config for given `id`. pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option> { @@ -58,6 +61,12 @@ pub fn default_config(para_id: u32) -> serde_json::Value { .map(|x| (x.clone(), 1_000_000_000 * SBY)) .collect::>(); + let slots_per_tier = vec![0, 6, 10, 0]; + let rank_points: Vec> = slots_per_tier + .iter() + .map(|&slots| (1..=slots.min(MAX_ENCODED_RANK as u16) as u8).collect()) + .collect(); + let config = RuntimeGenesisConfig { system: Default::default(), sudo: SudoConfig { @@ -128,40 +137,39 @@ pub fn default_config(para_id: u32) -> serde_json::Value { transaction_payment: Default::default(), dapp_staking: DappStakingConfig { reward_portion: vec![ - Permill::from_percent(40), + Permill::from_percent(0), + Permill::from_percent(70), Permill::from_percent(30), - Permill::from_percent(20), - Permill::from_percent(10), + Permill::from_percent(0), ], slot_distribution: vec![ - Permill::from_percent(10), - Permill::from_percent(20), - Permill::from_percent(30), - Permill::from_percent(40), + Permill::from_percent(0), + Permill::from_parts(375_000), // 37.5% + Permill::from_parts(625_000), // 62.5% + Permill::from_percent(0), ], - // percentages below are calculated based on a total issuance at the time when dApp staking v3 was launched (147M) + // percentages below are calculated based on a total issuance at the time when dApp staking v3 was revamped (8.6B) tier_thresholds: vec![ - TierThreshold::DynamicPercentage { - percentage: Perbill::from_parts(20_000), // 0.0020% - minimum_required_percentage: Perbill::from_parts(17_000), // 0.0017% - maximum_possible_percentage: Perbill::from_percent(100), + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(23_200_000), // 2.32% }, - TierThreshold::DynamicPercentage { - percentage: Perbill::from_parts(13_000), // 0.0013% - minimum_required_percentage: Perbill::from_parts(10_000), // 0.0010% - maximum_possible_percentage: Perbill::from_percent(100), + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(11_600_000), // 1.16% }, - TierThreshold::DynamicPercentage { - percentage: Perbill::from_parts(5_400), // 0.00054% - minimum_required_percentage: Perbill::from_parts(3_400), // 0.00034% - maximum_possible_percentage: Perbill::from_percent(100), + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(5_800_000), // 0.58% }, + // Tier 3: unreachable dummy TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(1_400), // 0.00014% + required_percentage: Perbill::from_parts(0), // 0% }, ], - slots_per_tier: vec![10, 20, 30, 40], + slots_per_tier, + // Force fixed 16 slots + slot_number_args: (0, 16), safeguard: Some(false), + rank_points, + base_reward_portion: Permill::from_percent(10), ..Default::default() }, inflation: Default::default(), diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index 57503bef2f..f5be4587c8 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -497,7 +497,7 @@ impl pallet_dapp_staking::Config for Runtime { type BaseNativeCurrencyPrice = BaseNativeCurrencyPrice; type EraRewardSpanLength = ConstU32<16>; type RewardRetentionInPeriods = ConstU32<2>; - type MaxNumberOfContracts = ConstU32<500>; + type MaxNumberOfContracts = ConstU32<16>; type MaxUnlockingChunks = ConstU32<8>; type MinimumLockedAmount = MinimumStakingAmount; type UnlockingPeriod = ConstU32<4>; @@ -525,15 +525,15 @@ impl pallet_inflation::PayoutPerBlock> for Inflation pub struct InflationCycleConfig; impl CycleConfiguration for InflationCycleConfig { fn periods_per_cycle() -> PeriodNumber { - 2 + 1 } fn eras_per_voting_subperiod() -> EraNumber { - 8 + 1 } fn eras_per_build_and_earn_subperiod() -> EraNumber { - 20 + 27 } fn blocks_per_era() -> BlockNumber { @@ -1750,13 +1750,70 @@ pub type Executive = frame_executive::Executive< Migrations, >; +pub struct ShibuyaTierParamsV11; +impl pallet_dapp_staking::migration::TierParamsV11Config for ShibuyaTierParamsV11 { + fn reward_portion() -> [Permill; 4] { + [ + Permill::from_percent(0), + Permill::from_percent(70), + Permill::from_percent(30), + Permill::from_percent(0), + ] + } + + fn slot_distribution() -> [Permill; 4] { + [ + Permill::from_percent(0), + Permill::from_parts(375_000), // 37.5% + Permill::from_parts(625_000), // 62.5% + Permill::from_percent(0), + ] + } + + fn tier_thresholds() -> [pallet_dapp_staking::TierThreshold; 4] { + use pallet_dapp_staking::TierThreshold; + [ + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(23_200_000), // 2.32% + }, + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(11_600_000), // 1.16% + }, + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(5_800_000), // 0.58% + }, + // Tier 3: unreachable dummy + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(0), // 0% + }, + ] + } + + fn slot_number_args() -> (u64, u64) { + (0, 16) + } + + fn rank_points() -> [Vec; 4] { + [ + vec![], // Tier 0: dummy + vec![10, 11, 12, 13, 14, 15], // Tier 1: 6 slots + vec![1, 3, 5, 7, 9, 11, 13, 15, 17, 19], // Tier 2: 10 slots + vec![], // Tier 3: dummy + ] + } + + fn base_reward_portion() -> Permill { + Permill::from_percent(10) + } +} + /// All migrations that will run on the next runtime upgrade. /// /// __NOTE:__ THE ORDER IS IMPORTANT. pub type Migrations = (Unreleased, Permanent); /// Unreleased migrations. Add new ones here: -pub type Unreleased = (); +pub type Unreleased = (pallet_dapp_staking::migration::versioned_migrations::V10ToV11,); /// Migrations/checks that do not need to be versioned and can run on every upgrade. pub type Permanent = (pallet_xcm::migration::MigrateToLatestXcmVersion,); diff --git a/runtime/shiden/src/genesis_config.rs b/runtime/shiden/src/genesis_config.rs index 6c94431158..6c5c2746b5 100644 --- a/runtime/shiden/src/genesis_config.rs +++ b/runtime/shiden/src/genesis_config.rs @@ -17,7 +17,7 @@ // along with Astar. If not, see . use crate::*; -use astar_primitives::{evm::EVM_REVERT_CODE, genesis::GenesisAccount, parachain::SHIDEN_ID}; +use astar_primitives::{dapp_staking::MAX_ENCODED_RANK, evm::EVM_REVERT_CODE, genesis::GenesisAccount, parachain::SHIDEN_ID}; /// Provides the JSON representation of predefined genesis config for given `id`. pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option> { @@ -46,6 +46,12 @@ pub fn default_config(para_id: u32) -> serde_json::Value { ), ]; + let slots_per_tier = vec![0, 6, 10, 0]; + let rank_points: Vec> = slots_per_tier + .iter() + .map(|&slots| (1..=slots.min(MAX_ENCODED_RANK as u16) as u8).collect()) + .collect(); + let authorities = vec![&alice, &bob]; let config = RuntimeGenesisConfig { @@ -114,40 +120,39 @@ pub fn default_config(para_id: u32) -> serde_json::Value { transaction_payment: Default::default(), dapp_staking: DappStakingConfig { reward_portion: vec![ - Permill::from_percent(40), + Permill::from_percent(0), + Permill::from_percent(70), Permill::from_percent(30), - Permill::from_percent(20), - Permill::from_percent(10), + Permill::from_percent(0), ], slot_distribution: vec![ - Permill::from_percent(10), - Permill::from_percent(20), - Permill::from_percent(30), - Permill::from_percent(40), + Permill::from_percent(0), + Permill::from_parts(375_000), // 37.5% + Permill::from_parts(625_000), // 62.5% + Permill::from_percent(0), ], - // percentages below are calculated based on a total issuance at the time when dApp staking v3 was launched (84.3M) + // percentages below are calculated based on a total issuance at the time when dApp staking v3 was revamped (8.6B) tier_thresholds: vec![ - TierThreshold::DynamicPercentage { - percentage: Perbill::from_parts(35_700_000), // 3.57% - minimum_required_percentage: Perbill::from_parts(23_800_000), // 2.38% - maximum_possible_percentage: Perbill::from_percent(100), + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(23_200_000), // 2.32% }, - TierThreshold::DynamicPercentage { - percentage: Perbill::from_parts(8_900_000), // 0.89% - minimum_required_percentage: Perbill::from_parts(6_000_000), // 0.6% - maximum_possible_percentage: Perbill::from_percent(100), + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(11_600_000), // 1.16% }, - TierThreshold::DynamicPercentage { - percentage: Perbill::from_parts(2_380_000), // 0.238% - minimum_required_percentage: Perbill::from_parts(1_790_000), // 0.179% - maximum_possible_percentage: Perbill::from_percent(100), + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(5_800_000), // 0.58% }, + // Tier 3: unreachable dummy TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(600_000), // 0.06% + required_percentage: Perbill::from_parts(0), // 0% }, ], - slots_per_tier: vec![10, 20, 30, 40], + slots_per_tier, + // Force fixed 16 slots + slot_number_args: (0, 16), safeguard: Some(false), + rank_points, + base_reward_portion: Permill::from_percent(10), ..Default::default() }, inflation: Default::default(), diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index 5316d91f5f..b5870c2dc9 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -450,7 +450,7 @@ impl pallet_dapp_staking::Config for Runtime { type BaseNativeCurrencyPrice = BaseNativeCurrencyPrice; type EraRewardSpanLength = ConstU32<16>; type RewardRetentionInPeriods = ConstU32<3>; - type MaxNumberOfContracts = ConstU32<500>; + type MaxNumberOfContracts = ConstU32<16>; type MaxUnlockingChunks = ConstU32<8>; type MinimumLockedAmount = MinimumStakingAmount; type UnlockingPeriod = ConstU32<4>; @@ -478,15 +478,15 @@ impl pallet_inflation::PayoutPerBlock> for Inflation pub struct InflationCycleConfig; impl CycleConfiguration for InflationCycleConfig { fn periods_per_cycle() -> u32 { - 6 + 2 } fn eras_per_voting_subperiod() -> u32 { - 6 + 1 } fn eras_per_build_and_earn_subperiod() -> u32 { - 55 + 182 } fn blocks_per_era() -> BlockNumber { @@ -1313,13 +1313,71 @@ pub type Executive = frame_executive::Executive< Migrations, >; +pub struct ShidenTierParamsV11; +impl pallet_dapp_staking::migration::TierParamsV11Config for ShidenTierParamsV11 { + fn reward_portion() -> [Permill; 4] { + [ + Permill::from_percent(0), + Permill::from_percent(70), + Permill::from_percent(30), + Permill::from_percent(0), + ] + } + + fn slot_distribution() -> [Permill; 4] { + [ + Permill::from_percent(0), + Permill::from_parts(375_000), // 37.5% + Permill::from_parts(625_000), // 62.5% + Permill::from_percent(0), + ] + } + + fn tier_thresholds() -> [pallet_dapp_staking::TierThreshold; 4] { + use pallet_dapp_staking::TierThreshold; + [ + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(23_200_000), // 2.32% + }, + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(11_600_000), // 1.16% + }, + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(5_800_000), // 0.58% + }, + // Tier 3: unreachable dummy + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(0), // 0% + }, + ] + } + + fn slot_number_args() -> (u64, u64) { + (0, 16) + } + + fn rank_points() -> [Vec; 4] { + [ + vec![], // Tier 0: dummy + vec![10, 11, 12, 13, 14, 15], // Tier 1: 6 slots + vec![1, 3, 5, 7, 9, 11, 13, 15, 17, 19], // Tier 2: 10 slots + vec![], // Tier 3: dummy + ] + } + + fn base_reward_portion() -> Permill { + Permill::from_percent(10) + } +} + /// All migrations that will run on the next runtime upgrade. /// /// __NOTE:__ THE ORDER IS IMPORTANT. pub type Migrations = (Unreleased, Permanent); /// Unreleased migrations. Add new ones here: -pub type Unreleased = (); +pub type Unreleased = (pallet_dapp_staking::migration::versioned_migrations::V10ToV11,); + /// Migrations/checks that do not need to be versioned and can run on every upgrade. pub type Permanent = (pallet_xcm::migration::MigrateToLatestXcmVersion,); From 87cc1da9bbfb9f04de78150c950e1d10ea7d2ea6 Mon Sep 17 00:00:00 2001 From: Igor Papandinas <26460174+ipapandinas@users.noreply.github.com> Date: Fri, 30 Jan 2026 17:57:15 +0400 Subject: [PATCH 02/16] make CI happy --- pallets/dapp-staking/src/benchmarking/mod.rs | 15 ++++---- .../dapp-staking/src/benchmarking/utils.rs | 2 +- pallets/dapp-staking/src/migration.rs | 34 +++++++++---------- precompiles/dapp-staking/src/test/mock.rs | 13 ++++--- runtime/astar/src/genesis_config.rs | 5 ++- runtime/astar/src/lib.rs | 11 +++--- runtime/shibuya/src/lib.rs | 12 ++++--- runtime/shiden/src/genesis_config.rs | 5 ++- runtime/shiden/src/lib.rs | 13 +++---- 9 files changed, 58 insertions(+), 52 deletions(-) diff --git a/pallets/dapp-staking/src/benchmarking/mod.rs b/pallets/dapp-staking/src/benchmarking/mod.rs index 239486e16e..27eda4f84b 100644 --- a/pallets/dapp-staking/src/benchmarking/mod.rs +++ b/pallets/dapp-staking/src/benchmarking/mod.rs @@ -1145,16 +1145,13 @@ mod benchmarks { }); EraRewards::::insert(&cleanup_marker.era_reward_index, reward_span); - let rank_points: BoundedVec< - BoundedVec>, - T::NumberOfTiers, - > = (1..=T::NumberOfTiers::get()) + let rank_points: BoundedVec>, T::NumberOfTiers> = (1 + ..=T::NumberOfTiers::get()) .map(|slots| { - let inner: BoundedVec> = - (1..=slots as u8) - .collect::>() - .try_into() - .expect("Using incremental points; QED."); + let inner: BoundedVec> = (1..=slots as u8) + .collect::>() + .try_into() + .expect("Using incremental points; QED."); inner }) .collect::>() diff --git a/pallets/dapp-staking/src/benchmarking/utils.rs b/pallets/dapp-staking/src/benchmarking/utils.rs index f9915ae539..ec26bc5e10 100644 --- a/pallets/dapp-staking/src/benchmarking/utils.rs +++ b/pallets/dapp-staking/src/benchmarking/utils.rs @@ -204,7 +204,7 @@ pub(super) fn init_tier_settings() { BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]).unwrap(), BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]).unwrap(), ]) - .unwrap(), + .unwrap(), base_reward_portion: Permill::from_percent(50), }; diff --git a/pallets/dapp-staking/src/migration.rs b/pallets/dapp-staking/src/migration.rs index e411c548e7..4d5de9d297 100644 --- a/pallets/dapp-staking/src/migration.rs +++ b/pallets/dapp-staking/src/migration.rs @@ -55,9 +55,7 @@ pub trait TierParamsV11Config { mod v11 { use super::*; - use crate::migration::v10::{ - DAppTierRewards as DAppTierRewardsV10, - }; + use crate::migration::v10::DAppTierRewards as DAppTierRewardsV10; pub struct VersionMigrateV10ToV11(PhantomData<(T, P)>); @@ -93,8 +91,9 @@ mod v11 { rank_points_config .into_iter() .map(|points| BoundedVec::try_from(points).expect("rank points")) - .collect::>() - ).expect("4 tiers"), + .collect::>(), + ) + .expect("4 tiers"), base_reward_portion: P::base_reward_portion(), }; @@ -131,8 +130,9 @@ mod v11 { } reads += 1; - let maybe_old: Option> = - v10::DAppTiers::::get(era); + let maybe_old: Option< + DAppTierRewardsV10, + > = v10::DAppTiers::::get(era); match maybe_old { Some(old) => { @@ -232,14 +232,14 @@ mod v11 { ensure!(new_params.is_valid(), "New tier params invalid"); let new_count = DAppTiers::::iter().count() as u32; - ensure!( - new_count == expected_count, - "DAppTiers count mismatch" - ); + ensure!(new_count == expected_count, "DAppTiers count mismatch"); for (era, rewards) in DAppTiers::::iter() { ensure!(era >= oldest_valid_era, "Found expired entry"); - ensure!(rewards.rank_points.is_empty(), "Should have empty rank_points"); + ensure!( + rewards.rank_points.is_empty(), + "Should have empty rank_points" + ); } ensure!( @@ -269,10 +269,10 @@ mod v10 { /// v10 storage alias for DAppTiers #[storage_alias] pub type DAppTiers = StorageMap< - Pallet, - Twox64Concat, - EraNumber, - DAppTierRewards<::MaxNumberOfContracts, ::NumberOfTiers>, - OptionQuery, + Pallet, + Twox64Concat, + EraNumber, + DAppTierRewards<::MaxNumberOfContracts, ::NumberOfTiers>, + OptionQuery, >; } diff --git a/precompiles/dapp-staking/src/test/mock.rs b/precompiles/dapp-staking/src/test/mock.rs index 2ee840282e..f3b9bdf6c4 100644 --- a/precompiles/dapp-staking/src/test/mock.rs +++ b/precompiles/dapp-staking/src/test/mock.rs @@ -303,13 +303,12 @@ impl ExternalityBuilder { slot_number_args: STANDARD_TIER_SLOTS_ARGS, slots_per_tier: vec![10, 20, 30, 40], safeguard: None, - rank_points: BoundedVec::try_from(vec![ - BoundedVec::try_from(vec![1u8]).unwrap(), - BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]).unwrap(), - BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]).unwrap(), - BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]).unwrap(), - ]) - .unwrap(), + rank_points: vec![ + vec![1u8], + vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10], + vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10], + vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10], + ], base_reward_portion: Permill::from_percent(50), _config: PhantomData, }, diff --git a/runtime/astar/src/genesis_config.rs b/runtime/astar/src/genesis_config.rs index 46d2f10186..0eda2225a6 100644 --- a/runtime/astar/src/genesis_config.rs +++ b/runtime/astar/src/genesis_config.rs @@ -17,7 +17,10 @@ // along with Astar. If not, see . use crate::*; -use astar_primitives::{dapp_staking::MAX_ENCODED_RANK, evm::EVM_REVERT_CODE, genesis::GenesisAccount, parachain::ASTAR_ID}; +use astar_primitives::{ + dapp_staking::MAX_ENCODED_RANK, evm::EVM_REVERT_CODE, genesis::GenesisAccount, + parachain::ASTAR_ID, +}; /// Provides the JSON representation of predefined genesis config for given `id`. pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option> { diff --git a/runtime/astar/src/lib.rs b/runtime/astar/src/lib.rs index d7a3abb4a8..e55a5e5fd7 100644 --- a/runtime/astar/src/lib.rs +++ b/runtime/astar/src/lib.rs @@ -1788,10 +1788,10 @@ impl pallet_dapp_staking::migration::TierParamsV11Config for AstarTierParamsV11 fn rank_points() -> [Vec; 4] { [ - vec![], // Tier 0: dummy - vec![10, 11, 12, 13, 14, 15], // Tier 1: 6 slots - vec![1, 3, 5, 7, 9, 11, 13, 15, 17, 19], // Tier 2: 10 slots - vec![], // Tier 3: dummy + vec![], // Tier 0: dummy + vec![10, 11, 12, 13, 14, 15], // Tier 1: 6 slots + vec![1, 3, 5, 7, 9, 11, 13, 15, 17, 19], // Tier 2: 10 slots + vec![], // Tier 3: dummy ] } @@ -1806,7 +1806,8 @@ impl pallet_dapp_staking::migration::TierParamsV11Config for AstarTierParamsV11 pub type Migrations = (Unreleased, Permanent); /// Unreleased migrations. Add new ones here: -pub type Unreleased = (pallet_dapp_staking::migration::versioned_migrations::V10ToV11,); +pub type Unreleased = + (pallet_dapp_staking::migration::versioned_migrations::V10ToV11,); /// Migrations/checks that do not need to be versioned and can run on every upgrade. pub type Permanent = (pallet_xcm::migration::MigrateToLatestXcmVersion,); diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index f5be4587c8..e6f2f1f104 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -1795,10 +1795,10 @@ impl pallet_dapp_staking::migration::TierParamsV11Config for ShibuyaTierParamsV1 fn rank_points() -> [Vec; 4] { [ - vec![], // Tier 0: dummy - vec![10, 11, 12, 13, 14, 15], // Tier 1: 6 slots - vec![1, 3, 5, 7, 9, 11, 13, 15, 17, 19], // Tier 2: 10 slots - vec![], // Tier 3: dummy + vec![], // Tier 0: dummy + vec![10, 11, 12, 13, 14, 15], // Tier 1: 6 slots + vec![1, 3, 5, 7, 9, 11, 13, 15, 17, 19], // Tier 2: 10 slots + vec![], // Tier 3: dummy ] } @@ -1813,7 +1813,9 @@ impl pallet_dapp_staking::migration::TierParamsV11Config for ShibuyaTierParamsV1 pub type Migrations = (Unreleased, Permanent); /// Unreleased migrations. Add new ones here: -pub type Unreleased = (pallet_dapp_staking::migration::versioned_migrations::V10ToV11,); +pub type Unreleased = ( + pallet_dapp_staking::migration::versioned_migrations::V10ToV11, +); /// Migrations/checks that do not need to be versioned and can run on every upgrade. pub type Permanent = (pallet_xcm::migration::MigrateToLatestXcmVersion,); diff --git a/runtime/shiden/src/genesis_config.rs b/runtime/shiden/src/genesis_config.rs index 6c5c2746b5..6710e31ce9 100644 --- a/runtime/shiden/src/genesis_config.rs +++ b/runtime/shiden/src/genesis_config.rs @@ -17,7 +17,10 @@ // along with Astar. If not, see . use crate::*; -use astar_primitives::{dapp_staking::MAX_ENCODED_RANK, evm::EVM_REVERT_CODE, genesis::GenesisAccount, parachain::SHIDEN_ID}; +use astar_primitives::{ + dapp_staking::MAX_ENCODED_RANK, evm::EVM_REVERT_CODE, genesis::GenesisAccount, + parachain::SHIDEN_ID, +}; /// Provides the JSON representation of predefined genesis config for given `id`. pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option> { diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index b5870c2dc9..2267b67d1c 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -1358,10 +1358,10 @@ impl pallet_dapp_staking::migration::TierParamsV11Config for ShidenTierParamsV11 fn rank_points() -> [Vec; 4] { [ - vec![], // Tier 0: dummy - vec![10, 11, 12, 13, 14, 15], // Tier 1: 6 slots - vec![1, 3, 5, 7, 9, 11, 13, 15, 17, 19], // Tier 2: 10 slots - vec![], // Tier 3: dummy + vec![], // Tier 0: dummy + vec![10, 11, 12, 13, 14, 15], // Tier 1: 6 slots + vec![1, 3, 5, 7, 9, 11, 13, 15, 17, 19], // Tier 2: 10 slots + vec![], // Tier 3: dummy ] } @@ -1376,8 +1376,9 @@ impl pallet_dapp_staking::migration::TierParamsV11Config for ShidenTierParamsV11 pub type Migrations = (Unreleased, Permanent); /// Unreleased migrations. Add new ones here: -pub type Unreleased = (pallet_dapp_staking::migration::versioned_migrations::V10ToV11,); - +pub type Unreleased = ( + pallet_dapp_staking::migration::versioned_migrations::V10ToV11, +); /// Migrations/checks that do not need to be versioned and can run on every upgrade. pub type Permanent = (pallet_xcm::migration::MigrateToLatestXcmVersion,); From 026815e22cf20388034188bfd60ce99079ffd8bb Mon Sep 17 00:00:00 2001 From: Igor Papandinas <26460174+ipapandinas@users.noreply.github.com> Date: Fri, 30 Jan 2026 19:34:52 +0400 Subject: [PATCH 03/16] small adjustments --- .../dapp-staking/src/benchmarking/utils.rs | 10 +-- pallets/dapp-staking/src/test/mock.rs | 4 +- pallets/dapp-staking/src/test/tests.rs | 61 ++++++++----------- runtime/astar/src/lib.rs | 5 +- runtime/shibuya/src/lib.rs | 4 +- runtime/shiden/src/lib.rs | 8 +-- 6 files changed, 38 insertions(+), 54 deletions(-) diff --git a/pallets/dapp-staking/src/benchmarking/utils.rs b/pallets/dapp-staking/src/benchmarking/utils.rs index ec26bc5e10..6eee5a20f3 100644 --- a/pallets/dapp-staking/src/benchmarking/utils.rs +++ b/pallets/dapp-staking/src/benchmarking/utils.rs @@ -18,7 +18,7 @@ use super::{Pallet as DappStaking, *}; -use astar_primitives::{dapp_staking::STANDARD_TIER_SLOTS_ARGS, Balance}; +use astar_primitives::{dapp_staking::FIXED_TIER_SLOTS_ARGS, Balance}; use frame_system::Pallet as System; @@ -197,12 +197,12 @@ pub(super) fn init_tier_settings() { }, ]) .unwrap(), - slot_number_args: STANDARD_TIER_SLOTS_ARGS, + slot_number_args: FIXED_TIER_SLOTS_ARGS, rank_points: BoundedVec::try_from(vec![ BoundedVec::try_from(vec![1u8]).unwrap(), - BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]).unwrap(), - BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]).unwrap(), - BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]).unwrap(), + BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10]).unwrap(), + BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10]).unwrap(), + BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10]).unwrap(), ]) .unwrap(), base_reward_portion: Permill::from_percent(50), diff --git a/pallets/dapp-staking/src/test/mock.rs b/pallets/dapp-staking/src/test/mock.rs index cfb067e8ba..74ced477f7 100644 --- a/pallets/dapp-staking/src/test/mock.rs +++ b/pallets/dapp-staking/src/test/mock.rs @@ -36,7 +36,7 @@ use sp_std::cell::RefCell; use astar_primitives::{ dapp_staking::{ - Observer as DappStakingObserver, SmartContract, StandardTierSlots, STANDARD_TIER_SLOTS_ARGS, + Observer as DappStakingObserver, SmartContract, StandardTierSlots, FIXED_TIER_SLOTS_ARGS, }, Balance, BlockNumber, }; @@ -340,7 +340,7 @@ impl ExtBuilder { }, ]) .unwrap(), - slot_number_args: STANDARD_TIER_SLOTS_ARGS, + slot_number_args: FIXED_TIER_SLOTS_ARGS, rank_points: BoundedVec::try_from(vec![ BoundedVec::try_from(vec![1u8]).unwrap(), BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10]).unwrap(), diff --git a/pallets/dapp-staking/src/test/tests.rs b/pallets/dapp-staking/src/test/tests.rs index 426559e2ae..b85b12006d 100644 --- a/pallets/dapp-staking/src/test/tests.rs +++ b/pallets/dapp-staking/src/test/tests.rs @@ -42,7 +42,7 @@ use sp_runtime::{ use astar_primitives::{ dapp_staking::{ CycleConfiguration, EraNumber, RankedTier, SmartContractHandle, StakingRewardHandler, - TierSlots, + TierSlots, STANDARD_TIER_SLOTS_ARGS, }, Balance, BlockNumber, }; @@ -2685,6 +2685,13 @@ fn force_with_safeguard_on_fails() { #[test] fn tier_config_recalculation_works() { ExtBuilder::default().build_and_execute(|| { + // Setup for price based slot capacity + StaticTierParams::::mutate(|params| { + params.slot_number_args = STANDARD_TIER_SLOTS_ARGS; + }); + assert_ok!(DappStaking::force(RuntimeOrigin::root(), ForcingType::Era)); + run_for_blocks(1); + let init_price = NATIVE_PRICE.with(|v| v.borrow().clone()); let init_tier_config = TierConfig::::get(); @@ -2878,12 +2885,6 @@ fn get_dapp_tier_assignment_and_rewards_basic_example_works() { dapp_reward_pool, ); - // Debug: Print actual ranks assigned - for (dapp_id, ranked_tier) in tier_assignment.dapps.iter() { - let (tier, rank) = ranked_tier.deconstruct(); - println!("Tier {}: dApp {} has rank {}", tier, dapp_id, rank); - } - // Ranks rewards are 50% of the tier allocation // Dapp rewards allocations for tiers are: 40%, 30%, 20%, 10% // Points per tiers are: 1, 55, 55, 55 @@ -3478,6 +3479,13 @@ fn safeguard_configurable_by_genesis_config() { #[test] fn base_number_of_slots_is_respected() { ExtBuilder::default().build_and_execute(|| { + // Setup for price based slot capacity + StaticTierParams::::mutate(|params| { + params.slot_number_args = STANDARD_TIER_SLOTS_ARGS; + }); + assert_ok!(DappStaking::force(RuntimeOrigin::root(), ForcingType::Era)); + run_for_blocks(1); + // 0. Get expected number of slots for the base price let total_issuance = ::Currency::total_issuance(); let base_native_price = ::BaseNativeCurrencyPrice::get(); @@ -3589,36 +3597,17 @@ fn base_number_of_slots_is_respected() { #[test] fn ranking_with_points_calculates_reward_correctly() { ExtBuilder::default().build_and_execute(|| { - // Configure tiers with specific rank_points for predictable testing // Tier 1: 3 slots with points [5, 10, 15] (sum = 30) // Tier 2: 2 slots with points [4, 8] (sum = 12) - let tier_params = TierParameters::<::NumberOfTiers> { - reward_portion: BoundedVec::try_from(vec![ - Permill::from_percent(40), - Permill::from_percent(30), - Permill::from_percent(20), - Permill::from_percent(10), - ]) - .unwrap(), - slot_distribution: BoundedVec::try_from(vec![ - Permill::from_percent(10), - Permill::from_percent(20), - Permill::from_percent(30), - Permill::from_percent(40), - ]) - .unwrap(), - tier_thresholds: StaticTierParams::::get().tier_thresholds, - slot_number_args: (0, 16), - rank_points: BoundedVec::try_from(vec![ + StaticTierParams::::mutate(|params| { + params.rank_points = BoundedVec::try_from(vec![ BoundedVec::try_from(vec![]).unwrap(), // tier 0: no ranking BoundedVec::try_from(vec![5u8, 10, 15]).unwrap(), // tier 1: sum = 30 BoundedVec::try_from(vec![4u8, 8]).unwrap(), // tier 2: sum = 12 BoundedVec::try_from(vec![]).unwrap(), // tier 3: no ranking ]) - .unwrap(), - base_reward_portion: Permill::from_percent(50), - }; - StaticTierParams::::put(tier_params); + .unwrap(); + }); // Tier config is specially adapted for this test. TierConfig::::mutate(|config| { @@ -3680,10 +3669,10 @@ fn ranking_with_points_calculates_reward_correctly() { // Tier 3: no ranking β†’ 0 rank_rewards: BoundedVec::try_from(vec![0, 5_000, 8_333, 0]).unwrap(), rank_points: BoundedVec::try_from(vec![ - BoundedVec::try_from(vec![]).unwrap(), // tier 0: no ranking - BoundedVec::try_from(vec![5u8, 10, 15]).unwrap(), // tier 1: sum = 30 - BoundedVec::try_from(vec![4u8, 8]).unwrap(), // tier 2: sum = 12 - BoundedVec::try_from(vec![]).unwrap(), // tier 3: no ranking + BoundedVec::try_from(vec![]).unwrap(), + BoundedVec::try_from(vec![5u8, 10, 15]).unwrap(), + BoundedVec::try_from(vec![4u8, 8]).unwrap(), + BoundedVec::try_from(vec![]).unwrap(), ]) .unwrap(), } @@ -3698,8 +3687,7 @@ fn ranking_with_points_calculates_reward_correctly() { #[test] fn claim_dapp_reward_with_rank_points() { ExtBuilder::default().build_and_execute(|| { - // Configure tier 1 with rank_points for testing - // 5 slots with points [1, 5, 10, 15, 20] + // Tier-1: 5 slots with points [1, 5, 10, 15, 20] StaticTierParams::::mutate(|params| { params.rank_points = BoundedVec::try_from(vec![ BoundedVec::try_from(vec![]).unwrap(), @@ -3708,7 +3696,6 @@ fn claim_dapp_reward_with_rank_points() { BoundedVec::try_from(vec![]).unwrap(), ]) .unwrap(); - params.base_reward_portion = Permill::from_percent(50); }); let total_issuance = ::Currency::total_issuance(); diff --git a/runtime/astar/src/lib.rs b/runtime/astar/src/lib.rs index e55a5e5fd7..ccb2802425 100644 --- a/runtime/astar/src/lib.rs +++ b/runtime/astar/src/lib.rs @@ -89,7 +89,7 @@ use xcm_runtime_apis::{ use astar_primitives::{ dapp_staking::{ AccountCheck as DappStakingAccountCheck, CycleConfiguration, DAppId, EraNumber, - PeriodNumber, RankedTier, SmartContract, StandardTierSlots, + PeriodNumber, RankedTier, SmartContract, StandardTierSlots, FIXED_TIER_SLOTS_ARGS, }, evm::{EVMFungibleAdapterWrapper, EvmRevertCodeHandler}, governance::{ @@ -1743,6 +1743,7 @@ pub type Executive = frame_executive::Executive< AllPalletsWithSystem, Migrations, >; + pub struct AstarTierParamsV11; impl pallet_dapp_staking::migration::TierParamsV11Config for AstarTierParamsV11 { fn reward_portion() -> [Permill; 4] { @@ -1783,7 +1784,7 @@ impl pallet_dapp_staking::migration::TierParamsV11Config for AstarTierParamsV11 } fn slot_number_args() -> (u64, u64) { - (0, 16) + FIXED_TIER_SLOTS_ARGS } fn rank_points() -> [Vec; 4] { diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index e6f2f1f104..dc0a5c438a 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -85,7 +85,7 @@ use xcm_runtime_apis::{ use astar_primitives::{ dapp_staking::{ AccountCheck as DappStakingAccountCheck, CycleConfiguration, DAppId, EraNumber, - PeriodNumber, RankedTier, SmartContract, StandardTierSlots, + PeriodNumber, RankedTier, SmartContract, StandardTierSlots, FIXED_TIER_SLOTS_ARGS, }, evm::{EVMFungibleAdapterWrapper, EvmRevertCodeHandler, HashedDefaultMappings}, governance::{ @@ -1790,7 +1790,7 @@ impl pallet_dapp_staking::migration::TierParamsV11Config for ShibuyaTierParamsV1 } fn slot_number_args() -> (u64, u64) { - (0, 16) + FIXED_TIER_SLOTS_ARGS } fn rank_points() -> [Vec; 4] { diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index 2267b67d1c..78d6cac3fb 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -86,7 +86,7 @@ use xcm_runtime_apis::{ use astar_primitives::{ dapp_staking::{ AccountCheck as DappStakingAccountCheck, CycleConfiguration, DAppId, EraNumber, - PeriodNumber, RankedTier, SmartContract, StandardTierSlots, + PeriodNumber, RankedTier, SmartContract, StandardTierSlots, FIXED_TIER_SLOTS_ARGS, }, evm::{EVMFungibleAdapterWrapper, EvmRevertCodeHandler}, governance::OracleMembershipInst, @@ -1353,7 +1353,7 @@ impl pallet_dapp_staking::migration::TierParamsV11Config for ShidenTierParamsV11 } fn slot_number_args() -> (u64, u64) { - (0, 16) + FIXED_TIER_SLOTS_ARGS } fn rank_points() -> [Vec; 4] { @@ -1383,10 +1383,6 @@ pub type Unreleased = ( /// Migrations/checks that do not need to be versioned and can run on every upgrade. pub type Permanent = (pallet_xcm::migration::MigrateToLatestXcmVersion,); -parameter_types! { - pub const TierSlotsArgs: (u64, u64) = (100, 50); -} - type EventRecord = frame_system::EventRecord< ::RuntimeEvent, ::Hash, From abe397deff96ef936b1b5e5f37f18da444ace9fb Mon Sep 17 00:00:00 2001 From: Igor Papandinas <26460174+ipapandinas@users.noreply.github.com> Date: Mon, 2 Feb 2026 14:26:19 +0400 Subject: [PATCH 04/16] fix: migration and benchmarks --- pallets/dapp-staking/src/benchmarking/mod.rs | 2 +- .../dapp-staking/src/benchmarking/utils.rs | 47 +++---- pallets/dapp-staking/src/lib.rs | 52 +++++--- pallets/dapp-staking/src/migration.rs | 120 +++++++++++++++++- pallets/dapp-staking/src/test/mock.rs | 19 ++- pallets/dapp-staking/src/types.rs | 14 +- precompiles/dapp-staking/src/test/mock.rs | 1 + primitives/src/dapp_staking.rs | 1 + runtime/astar/src/lib.rs | 1 + runtime/local/src/lib.rs | 1 + runtime/shibuya/src/lib.rs | 1 + runtime/shiden/src/lib.rs | 1 + tests/xcm-simulator/src/mocks/parachain.rs | 1 + 13 files changed, 207 insertions(+), 54 deletions(-) diff --git a/pallets/dapp-staking/src/benchmarking/mod.rs b/pallets/dapp-staking/src/benchmarking/mod.rs index 27eda4f84b..841aca2205 100644 --- a/pallets/dapp-staking/src/benchmarking/mod.rs +++ b/pallets/dapp-staking/src/benchmarking/mod.rs @@ -999,7 +999,7 @@ mod benchmarks { let snapshot_state = ActiveProtocolState::::get(); // Advance over to the last era of the subperiod, and then again to the last block of that era. - advance_to_era::( + force_advance_to_era::( ActiveProtocolState::::get() .period_info .next_subperiod_start_era diff --git a/pallets/dapp-staking/src/benchmarking/utils.rs b/pallets/dapp-staking/src/benchmarking/utils.rs index 6eee5a20f3..6464eb2c5e 100644 --- a/pallets/dapp-staking/src/benchmarking/utils.rs +++ b/pallets/dapp-staking/src/benchmarking/utils.rs @@ -115,7 +115,7 @@ pub(super) const UNIT: Balance = 1_000_000_000_000_000_000; pub(super) const MIN_TIER_THRESHOLD: Balance = 10 * UNIT; /// Number of slots in the tier system. -pub(super) const NUMBER_OF_SLOTS: u32 = 100; +pub(super) const NUMBER_OF_SLOTS: u32 = 16; /// Random seed. pub(super) const SEED: u32 = 9000; @@ -163,49 +163,44 @@ pub(super) fn initial_config() { pub(super) fn init_tier_settings() { let tier_params = TierParameters:: { reward_portion: BoundedVec::try_from(vec![ - Permill::from_percent(40), + Permill::from_percent(0), + Permill::from_percent(70), Permill::from_percent(30), - Permill::from_percent(20), - Permill::from_percent(10), + Permill::from_percent(0), ]) .unwrap(), slot_distribution: BoundedVec::try_from(vec![ - Permill::from_percent(10), - Permill::from_percent(20), - Permill::from_percent(30), - Permill::from_percent(40), + Permill::from_percent(0), + Permill::from_parts(375_000), // 37.5% + Permill::from_parts(625_000), // 62.5% + Permill::from_percent(0), ]) .unwrap(), tier_thresholds: BoundedVec::try_from(vec![ - TierThreshold::DynamicPercentage { - percentage: Perbill::from_parts(11_112_000), // 1.1112% - minimum_required_percentage: Perbill::from_parts(8_889_000), // 0.8889% - maximum_possible_percentage: Perbill::from_percent(100), + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(23_200_000), // 2.32% }, - TierThreshold::DynamicPercentage { - percentage: Perbill::from_parts(5_556_000), // 0.5556% - minimum_required_percentage: Perbill::from_parts(4_400_000), // 0.44% - maximum_possible_percentage: Perbill::from_percent(100), + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(11_600_000), // 1.16% }, - TierThreshold::DynamicPercentage { - percentage: Perbill::from_parts(2_223_000), // 0.2223% - minimum_required_percentage: Perbill::from_parts(2_223_000), // 0.2223% - maximum_possible_percentage: Perbill::from_percent(100), + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(5_800_000), // 0.58% }, + // Tier 3: unreachable dummy TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(1_667_000), // 0.1667% + required_percentage: Perbill::from_parts(0), // 0% }, ]) .unwrap(), slot_number_args: FIXED_TIER_SLOTS_ARGS, rank_points: BoundedVec::try_from(vec![ - BoundedVec::try_from(vec![1u8]).unwrap(), - BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10]).unwrap(), - BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10]).unwrap(), + BoundedVec::try_from(vec![]).unwrap(), + BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6]).unwrap(), BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10]).unwrap(), + BoundedVec::try_from(vec![]).unwrap(), ]) .unwrap(), - base_reward_portion: Permill::from_percent(50), + base_reward_portion: Permill::from_percent(10), }; let total_issuance = 1000 * MIN_TIER_THRESHOLD; @@ -220,7 +215,7 @@ pub(super) fn init_tier_settings() { // Init tier config, based on the initial params let init_tier_config = TiersConfiguration:: { - slots_per_tier: BoundedVec::try_from(vec![10, 20, 30, 40]).unwrap(), + slots_per_tier: BoundedVec::try_from(vec![0, 6, 10, 0]).unwrap(), reward_portion: tier_params.reward_portion.clone(), tier_thresholds, _phantom: Default::default(), diff --git a/pallets/dapp-staking/src/lib.rs b/pallets/dapp-staking/src/lib.rs index b707d8bf4b..10e74d7450 100644 --- a/pallets/dapp-staking/src/lib.rs +++ b/pallets/dapp-staking/src/lib.rs @@ -186,6 +186,11 @@ pub mod pallet { #[pallet::constant] type MaxNumberOfContracts: Get; + /// Legacy bound for backward compatibility with pre-v11 DAppTierRewards. + // TODO: Can be removed to use MaxNumberOfContracts only after period 4 periods post-revamp-upgrade. + #[pallet::constant] + type MaxNumberOfContractsLegacy: Get; + /// Maximum number of unlocking chunks that can exist per account at a time. #[pallet::constant] type MaxUnlockingChunks: Get; @@ -543,7 +548,7 @@ pub mod pallet { fn default() -> Self { use sp_std::vec; let num_tiers = T::NumberOfTiers::get(); - let slots_per_tier = vec![100u16; num_tiers as usize]; + let slots_per_tier = vec![0u16, 6, 10, 0]; let rank_points: Vec> = slots_per_tier .iter() .map(|&slots| { @@ -1859,14 +1864,16 @@ pub mod pallet { /// /// 2. Sort the entries by the score, in descending order - the top score dApp comes first. /// - /// 3. Calculate rewards for each tier. - /// This is done by dividing the total reward pool into tier reward pools, - /// after which the tier reward pool is divided by the number of available slots in the tier. + /// 3. Calculate tier allocations from the total dApp reward pool using `reward_portion`. /// - /// 4. Read in tier configuration. This contains information about how many slots per tier there are, - /// as well as the threshold for each tier. Threshold is the minimum amount of stake required to be eligible for a tier. - /// Iterate over tier thresholds & capacities, starting from the top tier, and assign dApps to them. + /// 4. Calculate base rewards per tier: + /// `base_reward = base_reward_portion * tier_allocation / slots_per_tier` /// + /// 5. Calculate rank rewards per tier: + /// `rank_reward_per_point = (tier_allocation - base_pool) / sum_of_all_rank_points` + /// Where `sum_of_all_rank_points` is the sum of all configured rank points for that tier. + /// + /// 6. Assign dApps to tiers: /// ```text //// for each tier: /// for each unassigned dApp: @@ -1877,8 +1884,22 @@ pub mod pallet { /// ``` /// (Sort the entries by dApp ID, in ascending order. This is so we can efficiently search for them using binary search.) /// - /// The returned object contains information about each dApp that made it into a tier. - /// Alongside tier assignment info, number of read DB contract stake entries is returned. + /// + /// 7. Rank calculation within tier: + /// - `rank = 0` for lowest stake in tier, up to `max_rank - 1` for highest + /// - Rank maps to `rank_points[tier][rank]` for reward calculation + /// + /// ### Reward Formula + /// + /// For each dApp: + /// `total_reward = base_reward + (rank_points[tier][rank] * rank_reward_per_point)` + /// + /// ### Notes + /// + /// - Empty tier slots result in unminted rewards (by design) + /// - `rank_points` array is ascending: index 0 = lowest stake position in tier + /// - The returned object contains information about each dApp that made it into a tier. + /// Alongside tier assignment info, number of read DB contract stake entries is returned. pub(crate) fn get_dapp_tier_assignment_and_rewards( era: EraNumber, period: PeriodNumber, @@ -1931,9 +1952,8 @@ pub mod pallet { if capacity.is_zero() { Zero::zero() } else { - base_portion - .mul_floor(*allocation) - .saturating_div((*capacity).into()) + let base_pool = base_portion.mul_floor(*allocation); + base_pool.saturating_div((*capacity).into()) } }) .collect(); @@ -2001,9 +2021,9 @@ pub mod pallet { if total_points.is_zero() { Zero::zero() } else { - let rank_portion = - Permill::one().saturating_sub(tier_params.base_reward_portion); - let rank_pool = rank_portion.mul_floor(*allocation); + let base_pool = tier_params.base_reward_portion.mul_floor(*allocation); + let rank_pool = allocation.saturating_sub(base_pool); + // Note: slight reward underpayment may be expected due to integer math. rank_pool.saturating_div(total_points.into()) } }) @@ -2019,7 +2039,7 @@ pub mod pallet { // Prepare and return tier & rewards info. // In case rewards creation fails, we just write the default value. This should never happen though. ( - DAppTierRewards::::new( + DAppTierRewards::::new( dapp_tiers, base_rewards_per_tier, period, diff --git a/pallets/dapp-staking/src/migration.rs b/pallets/dapp-staking/src/migration.rs index 4d5de9d297..5f16c1446f 100644 --- a/pallets/dapp-staking/src/migration.rs +++ b/pallets/dapp-staking/src/migration.rs @@ -131,7 +131,7 @@ mod v11 { reads += 1; let maybe_old: Option< - DAppTierRewardsV10, + DAppTierRewardsV10, > = v10::DAppTiers::::get(era); match maybe_old { @@ -240,6 +240,15 @@ mod v11 { rewards.rank_points.is_empty(), "Should have empty rank_points" ); + + for (dapp_id, _) in rewards.dapps.iter() { + // Verify try_claim still works (without mutating) + let test_rewards = rewards.clone(); + assert!( + test_rewards.try_claim(*dapp_id).is_ok(), + "Legacy claim broken" + ); + } } ensure!( @@ -272,7 +281,114 @@ mod v10 { Pallet, Twox64Concat, EraNumber, - DAppTierRewards<::MaxNumberOfContracts, ::NumberOfTiers>, + DAppTierRewards<::MaxNumberOfContractsLegacy, ::NumberOfTiers>, OptionQuery, >; } + +#[cfg(test)] +mod tests { + use super::*; + use crate::test::mock::{ExtBuilder, Test}; + use astar_primitives::dapp_staking::FIXED_TIER_SLOTS_ARGS; + + pub struct TestTierParams; + impl TierParamsV11Config for TestTierParams { + fn reward_portion() -> [Permill; 4] { + [ + Permill::from_percent(0), + Permill::from_percent(70), + Permill::from_percent(30), + Permill::from_percent(0), + ] + } + + fn slot_distribution() -> [Permill; 4] { + [ + Permill::from_percent(0), + Permill::from_parts(375_000), // 37.5% + Permill::from_parts(625_000), // 62.5% + Permill::from_percent(0), + ] + } + + fn tier_thresholds() -> [TierThreshold; 4] { + use crate::TierThreshold; + [ + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(23_200_000), // 2.32% + }, + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(11_600_000), // 1.16% + }, + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(5_800_000), // 0.58% + }, + // Tier 3: unreachable dummy + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(0), // 0% + }, + ] + } + + fn slot_number_args() -> (u64, u64) { + FIXED_TIER_SLOTS_ARGS + } + + fn rank_points() -> [Vec; 4] { + [ + vec![], // Tier 0: dummy + vec![10, 11, 12, 13, 14, 15], // Tier 1: 6 slots + vec![1, 3, 5, 7, 9, 11, 13, 15, 17, 19], // Tier 2: 10 slots + vec![], // Tier 3: dummy + ] + } + + fn base_reward_portion() -> Permill { + Permill::from_percent(10) + } + } + + #[test] + fn migration_v10_to_v11_preserves_claimable_rewards() { + ExtBuilder::default() + .without_try_state() + .build_and_execute(|| { + // Setup: Create v10-style DAppTiers entry + let era = 5; + let period = 1; + let old_entry = v10::DAppTierRewards { + dapps: BoundedBTreeMap::try_from(BTreeMap::from([ + (0, RankedTier::new_saturated(1, 5, 10)), + (1, RankedTier::new_saturated(2, 3, 10)), + ])) + .unwrap(), + rewards: BoundedVec::try_from(vec![0, 100_000, 50_000, 0]).unwrap(), + period, + rank_rewards: BoundedVec::try_from(vec![0, 1_000, 500, 0]).unwrap(), + }; + + v10::DAppTiers::::insert(era, old_entry); + + // Set cleanup marker so this era is "valid" + HistoryCleanupMarker::::put(CleanupMarker { + oldest_valid_era: era, + ..Default::default() + }); + + let _weight = + v11::VersionMigrateV10ToV11::::on_runtime_upgrade(); + + let mut new_entry = DAppTiers::::get(era).expect("Entry should exist"); + assert!( + new_entry.rank_points.is_empty(), + "Migrated entries have empty rank_points" + ); + + let (reward, ranked_tier) = new_entry.try_claim(0).unwrap(); + assert_eq!(ranked_tier.rank(), 5); + // Legacy formula: base + rank * rank_reward_per_point + assert_eq!(reward, 100_000 + 5 * 1_000); + }); + } +} diff --git a/pallets/dapp-staking/src/test/mock.rs b/pallets/dapp-staking/src/test/mock.rs index 74ced477f7..bdaae141df 100644 --- a/pallets/dapp-staking/src/test/mock.rs +++ b/pallets/dapp-staking/src/test/mock.rs @@ -224,6 +224,7 @@ impl pallet_dapp_staking::Config for Test { type EraRewardSpanLength = ConstU32<8>; type RewardRetentionInPeriods = ConstU32<2>; type MaxNumberOfContracts = ConstU32<10>; + type MaxNumberOfContractsLegacy = ConstU32<10>; type MaxUnlockingChunks = ConstU32<5>; type MinimumLockedAmount = ConstU128; type UnlockingPeriod = ConstU32<2>; @@ -237,11 +238,15 @@ impl pallet_dapp_staking::Config for Test { type BenchmarkHelper = BenchmarkHelper; } -pub struct ExtBuilder {} +pub struct ExtBuilder { + run_try_state: bool, +} impl Default for ExtBuilder { fn default() -> Self { - Self {} + Self { + run_try_state: true, + } } } @@ -388,9 +393,12 @@ impl ExtBuilder { } pub fn build_and_execute(self, test: impl FnOnce() -> ()) { + let run_try_state = self.run_try_state; self.build().execute_with(|| { test(); - DappStaking::do_try_state().unwrap(); + if run_try_state { + DappStaking::do_try_state().unwrap(); + } }) } @@ -398,6 +406,11 @@ impl ExtBuilder { MAX_BONUS_SAFE_MOVES.with(|v| *v.borrow_mut() = value); self } + + pub fn without_try_state(mut self) -> Self { + self.run_try_state = false; + self + } } /// Run to the specified block number. diff --git a/pallets/dapp-staking/src/types.rs b/pallets/dapp-staking/src/types.rs index 76b273a18a..b67ea02275 100644 --- a/pallets/dapp-staking/src/types.rs +++ b/pallets/dapp-staking/src/types.rs @@ -75,19 +75,21 @@ use sp_runtime::{ }; pub use sp_std::{collections::btree_map::BTreeMap, fmt::Debug, vec::Vec}; -use crate::pallet::Config; -use astar_primitives::dapp_staking::MAX_ENCODED_RANK; use astar_primitives::{ - dapp_staking::{DAppId, EraNumber, PeriodNumber, RankedTier, TierSlots as TierSlotsFunc}, + dapp_staking::{ + DAppId, EraNumber, PeriodNumber, RankedTier, TierSlots as TierSlotsFunc, MAX_ENCODED_RANK, + }, Balance, BlockNumber, }; +use crate::pallet::Config; + // Convenience type for `AccountLedger` usage. pub type AccountLedgerFor = AccountLedger<::MaxUnlockingChunks>; // Convenience type for `DAppTierRewards` usage. pub type DAppTierRewardsFor = - DAppTierRewards<::MaxNumberOfContracts, ::NumberOfTiers>; + DAppTierRewards<::MaxNumberOfContractsLegacy, ::NumberOfTiers>; // Convenience type for `EraRewardSpan` usage. pub type EraRewardSpanFor = EraRewardSpan<::EraRewardSpanLength>; @@ -1710,7 +1712,7 @@ pub struct TierParameters> { /// This can be made more generic in the future in case more complex equations are required. /// But for now this simple tuple serves the purpose. pub(crate) slot_number_args: (u64, u64), - /// Rank points per tier in ASCENDING order, index = rank + /// Rank points per tier in ASCENDING order by rank (index 0 = rank 0 = lowest stake in tier) pub(crate) rank_points: BoundedVec>, NT>, /// Portion of tier allocation for base rewards (remainder β†’ rank rewards) /// e.g., Permill::from_percent(50) = 50% base, 50% rank @@ -1937,7 +1939,7 @@ pub struct DAppTierRewards, NT: Get> { pub(crate) period: PeriodNumber, /// Rank reward for each tier. First entry refers to the first tier, and so on. pub(crate) rank_rewards: BoundedVec, - /// Points configuration for each tier/rank in ASCENDING order. + /// Rank points per tier in ASCENDING order by rank (index 0 = rank 0 = lowest stake in tier) pub(crate) rank_points: BoundedVec>, NT>, } diff --git a/precompiles/dapp-staking/src/test/mock.rs b/precompiles/dapp-staking/src/test/mock.rs index f3b9bdf6c4..49e9ea512d 100644 --- a/precompiles/dapp-staking/src/test/mock.rs +++ b/precompiles/dapp-staking/src/test/mock.rs @@ -242,6 +242,7 @@ impl pallet_dapp_staking::Config for Test { type EraRewardSpanLength = ConstU32<8>; type RewardRetentionInPeriods = ConstU32<2>; type MaxNumberOfContracts = ConstU32<10>; + type MaxNumberOfContractsLegacy = ConstU32<10>; type MaxUnlockingChunks = ConstU32<5>; type MinimumLockedAmount = ConstU128<10>; type UnlockingPeriod = ConstU32<2>; diff --git a/primitives/src/dapp_staking.rs b/primitives/src/dapp_staking.rs index 4e847f0770..a11f186762 100644 --- a/primitives/src/dapp_staking.rs +++ b/primitives/src/dapp_staking.rs @@ -248,6 +248,7 @@ impl RankedTier { /// Create new encoded RankedTier from tier and rank with saturation. pub fn new_saturated(tier: TierId, rank: Rank, max_rank: Rank) -> Self { + let max_rank = max_rank.min(MAX_ENCODED_RANK as Rank); Self((rank.min(max_rank) << 4) | (tier.min(0x0f) & 0x0f)) } diff --git a/runtime/astar/src/lib.rs b/runtime/astar/src/lib.rs index ccb2802425..e572b104a5 100644 --- a/runtime/astar/src/lib.rs +++ b/runtime/astar/src/lib.rs @@ -473,6 +473,7 @@ impl pallet_dapp_staking::Config for Runtime { type EraRewardSpanLength = ConstU32<16>; type RewardRetentionInPeriods = ConstU32<4>; type MaxNumberOfContracts = ConstU32<16>; + type MaxNumberOfContractsLegacy = ConstU32<500>; type MaxUnlockingChunks = ConstU32<8>; type MinimumLockedAmount = MinimumStakingAmount; type UnlockingPeriod = ConstU32<9>; diff --git a/runtime/local/src/lib.rs b/runtime/local/src/lib.rs index aae135fcea..59cd1f29f0 100644 --- a/runtime/local/src/lib.rs +++ b/runtime/local/src/lib.rs @@ -487,6 +487,7 @@ impl pallet_dapp_staking::Config for Runtime { type EraRewardSpanLength = ConstU32<8>; type RewardRetentionInPeriods = ConstU32<2>; type MaxNumberOfContracts = ConstU32<100>; + type MaxNumberOfContractsLegacy = ConstU32<100>; type MaxUnlockingChunks = ConstU32<5>; type MinimumLockedAmount = ConstU128; type UnlockingPeriod = ConstU32<2>; diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index dc0a5c438a..c7411a21bb 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -498,6 +498,7 @@ impl pallet_dapp_staking::Config for Runtime { type EraRewardSpanLength = ConstU32<16>; type RewardRetentionInPeriods = ConstU32<2>; type MaxNumberOfContracts = ConstU32<16>; + type MaxNumberOfContractsLegacy = ConstU32<500>; type MaxUnlockingChunks = ConstU32<8>; type MinimumLockedAmount = MinimumStakingAmount; type UnlockingPeriod = ConstU32<4>; diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index 78d6cac3fb..3fc0e67a73 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -451,6 +451,7 @@ impl pallet_dapp_staking::Config for Runtime { type EraRewardSpanLength = ConstU32<16>; type RewardRetentionInPeriods = ConstU32<3>; type MaxNumberOfContracts = ConstU32<16>; + type MaxNumberOfContractsLegacy = ConstU32<500>; type MaxUnlockingChunks = ConstU32<8>; type MinimumLockedAmount = MinimumStakingAmount; type UnlockingPeriod = ConstU32<4>; diff --git a/tests/xcm-simulator/src/mocks/parachain.rs b/tests/xcm-simulator/src/mocks/parachain.rs index 744298f668..93c7b80d5c 100644 --- a/tests/xcm-simulator/src/mocks/parachain.rs +++ b/tests/xcm-simulator/src/mocks/parachain.rs @@ -653,6 +653,7 @@ impl pallet_dapp_staking::Config for Runtime { type EraRewardSpanLength = ConstU32<1>; type RewardRetentionInPeriods = ConstU32<2>; type MaxNumberOfContracts = ConstU32<10>; + type MaxNumberOfContractsLegacy = ConstU32<10>; type MaxUnlockingChunks = ConstU32<5>; type MinimumLockedAmount = ConstU128<3>; type UnlockingPeriod = ConstU32<2>; From 613c5e3c5d9245e81bf9a57bc2ee8ff4e8e4d625 Mon Sep 17 00:00:00 2001 From: Igor Papandinas <26460174+ipapandinas@users.noreply.github.com> Date: Mon, 2 Feb 2026 18:17:57 +0400 Subject: [PATCH 05/16] mut fix --- pallets/dapp-staking/src/migration.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/dapp-staking/src/migration.rs b/pallets/dapp-staking/src/migration.rs index 5f16c1446f..ffa1fcdf2f 100644 --- a/pallets/dapp-staking/src/migration.rs +++ b/pallets/dapp-staking/src/migration.rs @@ -243,7 +243,7 @@ mod v11 { for (dapp_id, _) in rewards.dapps.iter() { // Verify try_claim still works (without mutating) - let test_rewards = rewards.clone(); + let mut test_rewards = rewards.clone(); assert!( test_rewards.try_claim(*dapp_id).is_ok(), "Legacy claim broken" From 1a6d9de8a39d0935f6aa518eb846a74f5315c93d Mon Sep 17 00:00:00 2001 From: Igor Papandinas <26460174+ipapandinas@users.noreply.github.com> Date: Mon, 2 Feb 2026 18:35:47 +0400 Subject: [PATCH 06/16] make clippy happy --- pallets/dapp-staking/src/benchmarking/utils.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/dapp-staking/src/benchmarking/utils.rs b/pallets/dapp-staking/src/benchmarking/utils.rs index 6464eb2c5e..5b8c3fb25e 100644 --- a/pallets/dapp-staking/src/benchmarking/utils.rs +++ b/pallets/dapp-staking/src/benchmarking/utils.rs @@ -42,7 +42,7 @@ pub(super) fn run_for_blocks(n: BlockNumberFor) { /// Advance blocks until the specified era has been reached. /// /// Function has no effect if era is already passed. -pub(super) fn advance_to_era(era: EraNumber) { +pub(super) fn _advance_to_era(era: EraNumber) { assert!(era >= ActiveProtocolState::::get().era); while ActiveProtocolState::::get().era < era { run_for_blocks::(One::one()); @@ -65,7 +65,7 @@ pub(super) fn force_advance_to_era(era: EraNumber) { /// Advance blocks until next era has been reached. pub(super) fn _advance_to_next_era() { - advance_to_era::(ActiveProtocolState::::get().era + 1); + _advance_to_era::(ActiveProtocolState::::get().era + 1); } /// Advance to next era, in the next block using the `force` approach. From 1e7c40bf2f7e5a1b6307ae450bde744e81cc6440 Mon Sep 17 00:00:00 2001 From: Igor Papandinas <26460174+ipapandinas@users.noreply.github.com> Date: Mon, 2 Feb 2026 19:46:02 +0400 Subject: [PATCH 07/16] update weights --- pallets/dapp-staking/src/weights.rs | 1005 +++-------------- .../astar/src/weights/pallet_dapp_staking.rs | 522 ++------- .../src/weights/pallet_dapp_staking.rs | 522 ++------- .../shiden/src/weights/pallet_dapp_staking.rs | 524 ++------- 4 files changed, 498 insertions(+), 2075 deletions(-) diff --git a/pallets/dapp-staking/src/weights.rs b/pallets/dapp-staking/src/weights.rs index e5c0bea485..3d3b0793a6 100644 --- a/pallets/dapp-staking/src/weights.rs +++ b/pallets/dapp-staking/src/weights.rs @@ -17,36 +17,39 @@ // You should have received a copy of the GNU General Public License // along with Astar. If not, see . -//! Autogenerated weights for pallet_dapp_staking +//! Autogenerated weights for `pallet_dapp_staking` //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 42.0.1 -//! DATE: 2025-02-19, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2026-02-02, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `gh-runner-01-ovh`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` -//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("astar-dev"), DB CACHE: 1024 +//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024 // Executed Command: -// ./target/release/astar-collator +// frame-omni-bencher +// v1 // benchmark // pallet -// --chain=astar-dev +// --runtime=./target/release/wbuild/astar-runtime/astar_runtime.compact.compressed.wasm // --steps=50 // --repeat=20 // --pallet=pallet_dapp_staking // --extrinsic=* // --wasm-execution=compiled // --heap-pages=4096 -// --output=./benchmark-results/astar-dev/dapp_staking_weights.rs -// --template=./scripts/templates/weight-template.hbs +// --output=./benchmark-results/astar/pallet/dapp_staking_weights.rs +// --template=./scripts/templates/pallet-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] +#![allow(dead_code)] -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use frame_support::{traits::Get, weights::Weight}; use core::marker::PhantomData; -/// Weight functions needed for pallet_dapp_staking. +/// Weight info trait. pub trait WeightInfo { fn maintenance_mode() -> Weight; fn register() -> Weight; @@ -74,981 +77,241 @@ pub trait WeightInfo { fn on_initialize_build_and_earn_to_build_and_earn() -> Weight; fn dapp_tier_assignment(x: u32, ) -> Weight; fn on_idle_cleanup() -> Weight; - fn step() -> Weight; fn set_static_tier_params() -> Weight; } -/// Weights for pallet_dapp_staking using the Substrate node and recommended hardware. +/// Weight functions for `pallet_dapp_staking`. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn maintenance_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_160_000 picoseconds. - Weight::from_parts(6_345_000, 0) + // Minimum execution time: 8_353_000 picoseconds. + Weight::from_parts(8_607_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CounterForIntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::CounterForIntegratedDApps` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::NextDAppId` (r:1 w:1) - /// Proof: `DappStaking::NextDAppId` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) fn register() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `3086` - // Minimum execution time: 12_235_000 picoseconds. - Weight::from_parts(12_512_000, 3086) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Estimated: `0` + // Minimum execution time: 16_653_000 picoseconds. + Weight::from_parts(16_994_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) fn set_dapp_reward_beneficiary() -> Weight { // Proof Size summary in bytes: // Measured: `97` - // Estimated: `3086` - // Minimum execution time: 10_517_000 picoseconds. - Weight::from_parts(10_793_000, 3086) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Estimated: `0` + // Minimum execution time: 14_619_000 picoseconds. + Weight::from_parts(14_785_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) fn set_dapp_owner() -> Weight { // Proof Size summary in bytes: // Measured: `97` - // Estimated: `3086` - // Minimum execution time: 10_363_000 picoseconds. - Weight::from_parts(10_656_000, 3086) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Estimated: `0` + // Minimum execution time: 14_373_000 picoseconds. + Weight::from_parts(14_854_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CounterForIntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::CounterForIntegratedDApps` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::ContractStake` (r:0 w:1) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) fn unregister() -> Weight { // Proof Size summary in bytes: // Measured: `97` - // Estimated: `3086` - // Minimum execution time: 14_595_000 picoseconds. - Weight::from_parts(14_935_000, 3086) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Estimated: `0` + // Minimum execution time: 20_743_000 picoseconds. + Weight::from_parts(21_182_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `CollatorSelection::Candidates` (r:1 w:0) - /// Proof: `CollatorSelection::Candidates` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn lock_new_account() -> Weight { // Proof Size summary in bytes: // Measured: `138` - // Estimated: `4764` - // Minimum execution time: 31_874_000 picoseconds. - Weight::from_parts(32_108_000, 4764) - .saturating_add(T::DbWeight::get().reads(5_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Estimated: `0` + // Minimum execution time: 38_026_000 picoseconds. + Weight::from_parts(38_676_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn lock_existing_account() -> Weight { // Proof Size summary in bytes: // Measured: `158` - // Estimated: `4764` - // Minimum execution time: 32_204_000 picoseconds. - Weight::from_parts(32_658_000, 4764) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Estimated: `0` + // Minimum execution time: 38_830_000 picoseconds. + Weight::from_parts(39_535_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn unlock() -> Weight { // Proof Size summary in bytes: // Measured: `158` - // Estimated: `4764` - // Minimum execution time: 28_967_000 picoseconds. - Weight::from_parts(29_523_000, 4764) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Estimated: `0` + // Minimum execution time: 35_841_000 picoseconds. + Weight::from_parts(36_134_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) /// The range of component `x` is `[0, 16]`. fn claim_unlocked(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `190` - // Estimated: `4764` - // Minimum execution time: 29_887_000 picoseconds. - Weight::from_parts(31_172_595, 4764) - // Standard Error: 2_859 - .saturating_add(Weight::from_parts(124_029, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Estimated: `0` + // Minimum execution time: 38_569_000 picoseconds. + Weight::from_parts(40_971_399, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 5_564 + .saturating_add(Weight::from_parts(92_129, 0).saturating_mul(x.into())) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn relock_unlocking() -> Weight { // Proof Size summary in bytes: // Measured: `200` - // Estimated: `4764` - // Minimum execution time: 27_384_000 picoseconds. - Weight::from_parts(27_620_000, 4764) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Estimated: `0` + // Minimum execution time: 35_389_000 picoseconds. + Weight::from_parts(35_953_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StakerInfo` (r:1 w:1) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::ContractStake` (r:1 w:1) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn stake() -> Weight { // Proof Size summary in bytes: // Measured: `274` - // Estimated: `4764` - // Minimum execution time: 40_988_000 picoseconds. - Weight::from_parts(41_562_000, 4764) - .saturating_add(T::DbWeight::get().reads(7_u64)) - .saturating_add(T::DbWeight::get().writes(5_u64)) + // Estimated: `0` + // Minimum execution time: 53_218_000 picoseconds. + Weight::from_parts(53_745_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StakerInfo` (r:1 w:1) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::ContractStake` (r:1 w:1) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn unstake() -> Weight { // Proof Size summary in bytes: // Measured: `459` - // Estimated: `4764` - // Minimum execution time: 45_212_000 picoseconds. - Weight::from_parts(45_611_000, 4764) - .saturating_add(T::DbWeight::get().reads(7_u64)) - .saturating_add(T::DbWeight::get().writes(5_u64)) + // Estimated: `0` + // Minimum execution time: 58_207_000 picoseconds. + Weight::from_parts(58_707_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:0) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::PeriodEnd` (r:1 w:0) - /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 16]`. fn claim_staker_rewards_past_period(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `541` - // Estimated: `4764` - // Minimum execution time: 50_966_000 picoseconds. - Weight::from_parts(50_088_222, 4764) - // Standard Error: 4_812 - .saturating_add(Weight::from_parts(1_932_998, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(5_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + // Estimated: `0` + // Minimum execution time: 56_801_000 picoseconds. + Weight::from_parts(56_278_554, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 5_945 + .saturating_add(Weight::from_parts(1_930_726, 0).saturating_mul(x.into())) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:0) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 16]`. fn claim_staker_rewards_ongoing_period(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `519` - // Estimated: `4764` - // Minimum execution time: 48_396_000 picoseconds. - Weight::from_parts(47_718_494, 4764) - // Standard Error: 3_774 - .saturating_add(Weight::from_parts(1_922_497, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + // Estimated: `0` + // Minimum execution time: 53_936_000 picoseconds. + Weight::from_parts(53_443_943, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 6_179 + .saturating_add(Weight::from_parts(1_921_353, 0).saturating_mul(x.into())) } - /// Storage: `DappStaking::StakerInfo` (r:1 w:1) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::PeriodEnd` (r:1 w:0) - /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) fn claim_bonus_reward() -> Weight { // Proof Size summary in bytes: // Measured: `275` - // Estimated: `3775` - // Minimum execution time: 37_169_000 picoseconds. - Weight::from_parts(37_719_000, 3775) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + // Estimated: `0` + // Minimum execution time: 44_870_000 picoseconds. + Weight::from_parts(45_171_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::DAppTiers` (r:1 w:1) - /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn claim_dapp_reward() -> Weight { // Proof Size summary in bytes: - // Measured: `2672` - // Estimated: `5113` - // Minimum execution time: 54_124_000 picoseconds. - Weight::from_parts(54_932_000, 5113) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Measured: `668` + // Estimated: `0` + // Minimum execution time: 30_168_000 picoseconds. + Weight::from_parts(30_785_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StakerInfo` (r:1 w:1) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn unstake_from_unregistered() -> Weight { // Proof Size summary in bytes: // Measured: `322` - // Estimated: `4764` - // Minimum execution time: 37_145_000 picoseconds. - Weight::from_parts(37_697_000, 4764) - .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) + // Estimated: `0` + // Minimum execution time: 48_421_000 picoseconds. + Weight::from_parts(49_069_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::StakerInfo` (r:17 w:16) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 16]`. fn cleanup_expired_entries(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `257 + x * (73 Β±0)` - // Estimated: `4764 + x * (2653 Β±0)` - // Minimum execution time: 37_160_000 picoseconds. - Weight::from_parts(34_175_483, 4764) - // Standard Error: 8_747 - .saturating_add(Weight::from_parts(4_882_773, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(2_u64)) - .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(x.into()))) - .saturating_add(Weight::from_parts(0, 2653).saturating_mul(x.into())) + // Estimated: `0` + // Minimum execution time: 46_554_000 picoseconds. + Weight::from_parts(43_518_695, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 13_148 + .saturating_add(Weight::from_parts(6_189_134, 0).saturating_mul(x.into())) } - /// Storage: `DappStaking::Safeguard` (r:1 w:0) - /// Proof: `DappStaking::Safeguard` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) fn force() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `1486` - // Minimum execution time: 8_714_000 picoseconds. - Weight::from_parts(8_924_000, 1486) - .saturating_add(T::DbWeight::get().reads(1_u64)) + // Estimated: `0` + // Minimum execution time: 11_564_000 picoseconds. + Weight::from_parts(11_817_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:2 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StakerInfo` (r:2 w:2) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::ContractStake` (r:2 w:2) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn move_stake_from_registered_source() -> Weight { // Proof Size summary in bytes: // Measured: `553` - // Estimated: `6296` - // Minimum execution time: 71_782_000 picoseconds. - Weight::from_parts(72_398_000, 6296) - .saturating_add(T::DbWeight::get().reads(10_u64)) - .saturating_add(T::DbWeight::get().writes(7_u64)) + // Estimated: `0` + // Minimum execution time: 90_873_000 picoseconds. + Weight::from_parts(92_158_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:2 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StakerInfo` (r:2 w:2) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::ContractStake` (r:1 w:1) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) fn move_stake_unregistered_source() -> Weight { // Proof Size summary in bytes: // Measured: `419` - // Estimated: `6296` - // Minimum execution time: 63_766_000 picoseconds. - Weight::from_parts(64_076_000, 6296) - .saturating_add(T::DbWeight::get().reads(9_u64)) - .saturating_add(T::DbWeight::get().writes(6_u64)) + // Estimated: `0` + // Minimum execution time: 82_204_000 picoseconds. + Weight::from_parts(82_858_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:1) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) - /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(87), added: 582, mode: `MaxEncodedLen`) - /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) - /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::TierConfig` (r:1 w:1) - /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) fn on_initialize_voting_to_build_and_earn() -> Weight { // Proof Size summary in bytes: - // Measured: `212` - // Estimated: `4254` - // Minimum execution time: 26_591_000 picoseconds. - Weight::from_parts(27_310_000, 4254) - .saturating_add(T::DbWeight::get().reads(5_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `225` + // Estimated: `0` + // Minimum execution time: 25_881_000 picoseconds. + Weight::from_parts(26_282_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::PeriodEnd` (r:1 w:2) - /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::HistoryCleanupMarker` (r:1 w:1) - /// Proof: `DappStaking::HistoryCleanupMarker` (`max_values`: Some(1), `max_size`: Some(12), added: 507, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:1) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) - /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(87), added: 582, mode: `MaxEncodedLen`) - /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) - /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::TierConfig` (r:1 w:1) - /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::DAppTiers` (r:0 w:1) - /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn on_initialize_build_and_earn_to_voting() -> Weight { // Proof Size summary in bytes: - // Measured: `719` - // Estimated: `4254` - // Minimum execution time: 42_054_000 picoseconds. - Weight::from_parts(43_015_000, 4254) - .saturating_add(T::DbWeight::get().reads(7_u64)) - .saturating_add(T::DbWeight::get().writes(7_u64)) - } - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:1) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) - /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(87), added: 582, mode: `MaxEncodedLen`) - /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) - /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::TierConfig` (r:1 w:1) - /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::DAppTiers` (r:0 w:1) - /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) - fn on_initialize_build_and_earn_to_build_and_earn() -> Weight { - // Proof Size summary in bytes: - // Measured: `264` - // Estimated: `4254` - // Minimum execution time: 29_233_000 picoseconds. - Weight::from_parts(30_149_000, 4254) - .saturating_add(T::DbWeight::get().reads(5_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) - } - /// Storage: `DappStaking::ContractStake` (r:101 w:0) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::TierConfig` (r:1 w:0) - /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) - /// The range of component `x` is `[0, 100]`. - fn dapp_tier_assignment(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `98 + x * (32 Β±0)` - // Estimated: `3061 + x * (2071 Β±0)` - // Minimum execution time: 8_483_000 picoseconds. - Weight::from_parts(10_922_590, 3061) - // Standard Error: 2_388 - .saturating_add(Weight::from_parts(2_420_114, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(Weight::from_parts(0, 2071).saturating_mul(x.into())) - } - /// Storage: `DappStaking::HistoryCleanupMarker` (r:1 w:1) - /// Proof: `DappStaking::HistoryCleanupMarker` (`max_values`: Some(1), `max_size`: Some(12), added: 507, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:1) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::DAppTiers` (r:0 w:1) - /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) - fn on_idle_cleanup() -> Weight { - // Proof Size summary in bytes: - // Measured: `293` - // Estimated: `4254` - // Minimum execution time: 8_164_000 picoseconds. - Weight::from_parts(8_352_000, 4254) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) - } - /// Storage: `DappStaking::Ledger` (r:2 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - fn step() -> Weight { - // Proof Size summary in bytes: - // Measured: `76` - // Estimated: `6560` - // Minimum execution time: 13_041_000 picoseconds. - Weight::from_parts(13_375_000, 6560) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: `DappStaking::StaticTierParams` (r:0 w:1) - /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(87), added: 582, mode: `MaxEncodedLen`) - fn set_static_tier_params() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` + // Measured: `791` // Estimated: `0` - // Minimum execution time: 7_279_000 picoseconds. - Weight::from_parts(7_452_000, 0) - .saturating_add(T::DbWeight::get().writes(1_u64)) + // Minimum execution time: 48_019_000 picoseconds. + Weight::from_parts(48_471_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } -} - -// For backwards compatibility and tests -impl WeightInfo for () { - fn maintenance_mode() -> Weight { + fn on_initialize_build_and_earn_to_build_and_earn() -> Weight { // Proof Size summary in bytes: - // Measured: `0` + // Measured: `277` // Estimated: `0` - // Minimum execution time: 6_160_000 picoseconds. - Weight::from_parts(6_345_000, 0) - } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CounterForIntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::CounterForIntegratedDApps` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::NextDAppId` (r:1 w:1) - /// Proof: `DappStaking::NextDAppId` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) - fn register() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `3086` - // Minimum execution time: 12_235_000 picoseconds. - Weight::from_parts(12_512_000, 3086) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) - } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - fn set_dapp_reward_beneficiary() -> Weight { - // Proof Size summary in bytes: - // Measured: `97` - // Estimated: `3086` - // Minimum execution time: 10_517_000 picoseconds. - Weight::from_parts(10_793_000, 3086) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - fn set_dapp_owner() -> Weight { - // Proof Size summary in bytes: - // Measured: `97` - // Estimated: `3086` - // Minimum execution time: 10_363_000 picoseconds. - Weight::from_parts(10_656_000, 3086) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) + // Minimum execution time: 29_781_000 picoseconds. + Weight::from_parts(30_356_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CounterForIntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::CounterForIntegratedDApps` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::ContractStake` (r:0 w:1) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) - fn unregister() -> Weight { - // Proof Size summary in bytes: - // Measured: `97` - // Estimated: `3086` - // Minimum execution time: 14_595_000 picoseconds. - Weight::from_parts(14_935_000, 3086) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) - } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `CollatorSelection::Candidates` (r:1 w:0) - /// Proof: `CollatorSelection::Candidates` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - fn lock_new_account() -> Weight { - // Proof Size summary in bytes: - // Measured: `138` - // Estimated: `4764` - // Minimum execution time: 31_874_000 picoseconds. - Weight::from_parts(32_108_000, 4764) - .saturating_add(RocksDbWeight::get().reads(5_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) - } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - fn lock_existing_account() -> Weight { - // Proof Size summary in bytes: - // Measured: `158` - // Estimated: `4764` - // Minimum execution time: 32_204_000 picoseconds. - Weight::from_parts(32_658_000, 4764) - .saturating_add(RocksDbWeight::get().reads(4_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) - } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - fn unlock() -> Weight { - // Proof Size summary in bytes: - // Measured: `158` - // Estimated: `4764` - // Minimum execution time: 28_967_000 picoseconds. - Weight::from_parts(29_523_000, 4764) - .saturating_add(RocksDbWeight::get().reads(4_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) - } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) /// The range of component `x` is `[0, 16]`. - fn claim_unlocked(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `190` - // Estimated: `4764` - // Minimum execution time: 29_887_000 picoseconds. - Weight::from_parts(31_172_595, 4764) - // Standard Error: 2_859 - .saturating_add(Weight::from_parts(124_029, 0).saturating_mul(x.into())) - .saturating_add(RocksDbWeight::get().reads(4_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) - } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - fn relock_unlocking() -> Weight { - // Proof Size summary in bytes: - // Measured: `200` - // Estimated: `4764` - // Minimum execution time: 27_384_000 picoseconds. - Weight::from_parts(27_620_000, 4764) - .saturating_add(RocksDbWeight::get().reads(4_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) - } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StakerInfo` (r:1 w:1) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::ContractStake` (r:1 w:1) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - fn stake() -> Weight { - // Proof Size summary in bytes: - // Measured: `274` - // Estimated: `4764` - // Minimum execution time: 40_988_000 picoseconds. - Weight::from_parts(41_562_000, 4764) - .saturating_add(RocksDbWeight::get().reads(7_u64)) - .saturating_add(RocksDbWeight::get().writes(5_u64)) - } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StakerInfo` (r:1 w:1) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::ContractStake` (r:1 w:1) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - fn unstake() -> Weight { - // Proof Size summary in bytes: - // Measured: `459` - // Estimated: `4764` - // Minimum execution time: 45_212_000 picoseconds. - Weight::from_parts(45_611_000, 4764) - .saturating_add(RocksDbWeight::get().reads(7_u64)) - .saturating_add(RocksDbWeight::get().writes(5_u64)) - } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:0) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::PeriodEnd` (r:1 w:0) - /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 16]`. - fn claim_staker_rewards_past_period(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `541` - // Estimated: `4764` - // Minimum execution time: 50_966_000 picoseconds. - Weight::from_parts(50_088_222, 4764) - // Standard Error: 4_812 - .saturating_add(Weight::from_parts(1_932_998, 0).saturating_mul(x.into())) - .saturating_add(RocksDbWeight::get().reads(5_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:0) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 16]`. - fn claim_staker_rewards_ongoing_period(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `519` - // Estimated: `4764` - // Minimum execution time: 48_396_000 picoseconds. - Weight::from_parts(47_718_494, 4764) - // Standard Error: 3_774 - .saturating_add(Weight::from_parts(1_922_497, 0).saturating_mul(x.into())) - .saturating_add(RocksDbWeight::get().reads(4_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - } - /// Storage: `DappStaking::StakerInfo` (r:1 w:1) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::PeriodEnd` (r:1 w:0) - /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - fn claim_bonus_reward() -> Weight { - // Proof Size summary in bytes: - // Measured: `275` - // Estimated: `3775` - // Minimum execution time: 37_169_000 picoseconds. - Weight::from_parts(37_719_000, 3775) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::DAppTiers` (r:1 w:1) - /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) - fn claim_dapp_reward() -> Weight { - // Proof Size summary in bytes: - // Measured: `2672` - // Estimated: `5113` - // Minimum execution time: 54_124_000 picoseconds. - Weight::from_parts(54_932_000, 5113) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StakerInfo` (r:1 w:1) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - fn unstake_from_unregistered() -> Weight { - // Proof Size summary in bytes: - // Measured: `322` - // Estimated: `4764` - // Minimum execution time: 37_145_000 picoseconds. - Weight::from_parts(37_697_000, 4764) - .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().writes(4_u64)) - } - /// Storage: `DappStaking::StakerInfo` (r:17 w:16) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 16]`. - fn cleanup_expired_entries(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `257 + x * (73 Β±0)` - // Estimated: `4764 + x * (2653 Β±0)` - // Minimum execution time: 37_160_000 picoseconds. - Weight::from_parts(34_175_483, 4764) - // Standard Error: 8_747 - .saturating_add(Weight::from_parts(4_882_773, 0).saturating_mul(x.into())) - .saturating_add(RocksDbWeight::get().reads(4_u64)) - .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(x.into()))) - .saturating_add(Weight::from_parts(0, 2653).saturating_mul(x.into())) - } - /// Storage: `DappStaking::Safeguard` (r:1 w:0) - /// Proof: `DappStaking::Safeguard` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) - fn force() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `1486` - // Minimum execution time: 8_714_000 picoseconds. - Weight::from_parts(8_924_000, 1486) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - } - /// Storage: `DappStaking::IntegratedDApps` (r:2 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StakerInfo` (r:2 w:2) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::ContractStake` (r:2 w:2) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - fn move_stake_from_registered_source() -> Weight { - // Proof Size summary in bytes: - // Measured: `553` - // Estimated: `6296` - // Minimum execution time: 71_782_000 picoseconds. - Weight::from_parts(72_398_000, 6296) - .saturating_add(RocksDbWeight::get().reads(10_u64)) - .saturating_add(RocksDbWeight::get().writes(7_u64)) - } - /// Storage: `DappStaking::IntegratedDApps` (r:2 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StakerInfo` (r:2 w:2) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::ContractStake` (r:1 w:1) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) - fn move_stake_unregistered_source() -> Weight { - // Proof Size summary in bytes: - // Measured: `419` - // Estimated: `6296` - // Minimum execution time: 63_766_000 picoseconds. - Weight::from_parts(64_076_000, 6296) - .saturating_add(RocksDbWeight::get().reads(9_u64)) - .saturating_add(RocksDbWeight::get().writes(6_u64)) - } - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:1) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) - /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(87), added: 582, mode: `MaxEncodedLen`) - /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) - /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::TierConfig` (r:1 w:1) - /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) - fn on_initialize_voting_to_build_and_earn() -> Weight { - // Proof Size summary in bytes: - // Measured: `212` - // Estimated: `4254` - // Minimum execution time: 26_591_000 picoseconds. - Weight::from_parts(27_310_000, 4254) - .saturating_add(RocksDbWeight::get().reads(5_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) - } - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::PeriodEnd` (r:1 w:2) - /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::HistoryCleanupMarker` (r:1 w:1) - /// Proof: `DappStaking::HistoryCleanupMarker` (`max_values`: Some(1), `max_size`: Some(12), added: 507, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:1) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) - /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(87), added: 582, mode: `MaxEncodedLen`) - /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) - /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::TierConfig` (r:1 w:1) - /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::DAppTiers` (r:0 w:1) - /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) - fn on_initialize_build_and_earn_to_voting() -> Weight { - // Proof Size summary in bytes: - // Measured: `719` - // Estimated: `4254` - // Minimum execution time: 42_054_000 picoseconds. - Weight::from_parts(43_015_000, 4254) - .saturating_add(RocksDbWeight::get().reads(7_u64)) - .saturating_add(RocksDbWeight::get().writes(7_u64)) - } - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:1) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) - /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(87), added: 582, mode: `MaxEncodedLen`) - /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) - /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::TierConfig` (r:1 w:1) - /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::DAppTiers` (r:0 w:1) - /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) - fn on_initialize_build_and_earn_to_build_and_earn() -> Weight { - // Proof Size summary in bytes: - // Measured: `264` - // Estimated: `4254` - // Minimum execution time: 29_233_000 picoseconds. - Weight::from_parts(30_149_000, 4254) - .saturating_add(RocksDbWeight::get().reads(5_u64)) - .saturating_add(RocksDbWeight::get().writes(4_u64)) - } - /// Storage: `DappStaking::ContractStake` (r:101 w:0) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::TierConfig` (r:1 w:0) - /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) - /// The range of component `x` is `[0, 100]`. fn dapp_tier_assignment(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `98 + x * (32 Β±0)` - // Estimated: `3061 + x * (2071 Β±0)` - // Minimum execution time: 8_483_000 picoseconds. - Weight::from_parts(10_922_590, 3061) - // Standard Error: 2_388 - .saturating_add(Weight::from_parts(2_420_114, 0).saturating_mul(x.into())) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(Weight::from_parts(0, 2071).saturating_mul(x.into())) + // Measured: `218 + x * (33 Β±0)` + // Estimated: `0` + // Minimum execution time: 11_647_000 picoseconds. + Weight::from_parts(15_566_275, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 15_580 + .saturating_add(Weight::from_parts(3_037_978, 0).saturating_mul(x.into())) } - /// Storage: `DappStaking::HistoryCleanupMarker` (r:1 w:1) - /// Proof: `DappStaking::HistoryCleanupMarker` (`max_values`: Some(1), `max_size`: Some(12), added: 507, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:1) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::DAppTiers` (r:0 w:1) - /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn on_idle_cleanup() -> Weight { // Proof Size summary in bytes: // Measured: `293` - // Estimated: `4254` - // Minimum execution time: 8_164_000 picoseconds. - Weight::from_parts(8_352_000, 4254) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) - } - /// Storage: `DappStaking::Ledger` (r:2 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - fn step() -> Weight { - // Proof Size summary in bytes: - // Measured: `76` - // Estimated: `6560` - // Minimum execution time: 13_041_000 picoseconds. - Weight::from_parts(13_375_000, 6560) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) + // Estimated: `0` + // Minimum execution time: 9_856_000 picoseconds. + Weight::from_parts(10_123_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::StaticTierParams` (r:0 w:1) - /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(87), added: 582, mode: `MaxEncodedLen`) fn set_static_tier_params() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_279_000 picoseconds. - Weight::from_parts(7_452_000, 0) - .saturating_add(RocksDbWeight::get().writes(1_u64)) + // Minimum execution time: 11_255_000 picoseconds. + Weight::from_parts(11_552_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } } diff --git a/runtime/astar/src/weights/pallet_dapp_staking.rs b/runtime/astar/src/weights/pallet_dapp_staking.rs index 41f2e11127..55a9756e00 100644 --- a/runtime/astar/src/weights/pallet_dapp_staking.rs +++ b/runtime/astar/src/weights/pallet_dapp_staking.rs @@ -20,7 +20,7 @@ //! Autogenerated weights for `pallet_dapp_staking` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2025-12-19, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2026-02-02, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `gh-runner-01-ovh`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` //! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024 @@ -56,511 +56,231 @@ impl pallet_dapp_staking::WeightInfo for SubstrateWeigh // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_614_000 picoseconds. - Weight::from_parts(12_478_000, 0) + // Minimum execution time: 8_461_000 picoseconds. + Weight::from_parts(8_677_000, 0) .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CounterForIntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::CounterForIntegratedDApps` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::NextDAppId` (r:1 w:1) - /// Proof: `DappStaking::NextDAppId` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) fn register() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `3086` - // Minimum execution time: 18_271_000 picoseconds. - Weight::from_parts(18_397_000, 0) - .saturating_add(Weight::from_parts(0, 3086)) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(3)) + // Estimated: `0` + // Minimum execution time: 16_555_000 picoseconds. + Weight::from_parts(16_964_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) fn set_dapp_reward_beneficiary() -> Weight { // Proof Size summary in bytes: // Measured: `97` - // Estimated: `3086` - // Minimum execution time: 15_621_000 picoseconds. - Weight::from_parts(15_946_000, 0) - .saturating_add(Weight::from_parts(0, 3086)) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + // Estimated: `0` + // Minimum execution time: 14_462_000 picoseconds. + Weight::from_parts(14_727_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) fn set_dapp_owner() -> Weight { // Proof Size summary in bytes: // Measured: `97` - // Estimated: `3086` - // Minimum execution time: 15_482_000 picoseconds. - Weight::from_parts(15_984_000, 0) - .saturating_add(Weight::from_parts(0, 3086)) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + // Estimated: `0` + // Minimum execution time: 14_304_000 picoseconds. + Weight::from_parts(14_657_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CounterForIntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::CounterForIntegratedDApps` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::ContractStake` (r:0 w:1) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) fn unregister() -> Weight { // Proof Size summary in bytes: // Measured: `97` - // Estimated: `3086` - // Minimum execution time: 21_534_000 picoseconds. - Weight::from_parts(21_995_000, 0) - .saturating_add(Weight::from_parts(0, 3086)) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(3)) + // Estimated: `0` + // Minimum execution time: 20_132_000 picoseconds. + Weight::from_parts(20_603_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `CollatorSelection::Candidates` (r:1 w:0) - /// Proof: `CollatorSelection::Candidates` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn lock_new_account() -> Weight { // Proof Size summary in bytes: // Measured: `138` - // Estimated: `4764` - // Minimum execution time: 39_515_000 picoseconds. - Weight::from_parts(40_403_000, 0) - .saturating_add(Weight::from_parts(0, 4764)) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(3)) + // Estimated: `0` + // Minimum execution time: 38_289_000 picoseconds. + Weight::from_parts(38_691_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn lock_existing_account() -> Weight { // Proof Size summary in bytes: // Measured: `158` - // Estimated: `4764` - // Minimum execution time: 40_215_000 picoseconds. - Weight::from_parts(40_662_000, 0) - .saturating_add(Weight::from_parts(0, 4764)) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) + // Estimated: `0` + // Minimum execution time: 38_869_000 picoseconds. + Weight::from_parts(39_802_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn unlock() -> Weight { // Proof Size summary in bytes: // Measured: `158` - // Estimated: `4764` - // Minimum execution time: 36_950_000 picoseconds. - Weight::from_parts(37_450_000, 0) - .saturating_add(Weight::from_parts(0, 4764)) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) + // Estimated: `0` + // Minimum execution time: 35_328_000 picoseconds. + Weight::from_parts(35_790_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) /// The range of component `x` is `[0, 16]`. fn claim_unlocked(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `190` - // Estimated: `4764` - // Minimum execution time: 39_873_000 picoseconds. - Weight::from_parts(41_909_657, 0) - .saturating_add(Weight::from_parts(0, 4764)) - // Standard Error: 31_452 - .saturating_add(Weight::from_parts(103_521, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) + // Estimated: `0` + // Minimum execution time: 38_313_000 picoseconds. + Weight::from_parts(40_691_916, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 5_927 + .saturating_add(Weight::from_parts(101_758, 0).saturating_mul(x.into())) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn relock_unlocking() -> Weight { // Proof Size summary in bytes: // Measured: `200` - // Estimated: `4764` - // Minimum execution time: 36_949_000 picoseconds. - Weight::from_parts(37_559_000, 0) - .saturating_add(Weight::from_parts(0, 4764)) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) + // Estimated: `0` + // Minimum execution time: 35_715_000 picoseconds. + Weight::from_parts(36_117_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StakerInfo` (r:1 w:1) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::ContractStake` (r:1 w:1) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn stake() -> Weight { // Proof Size summary in bytes: // Measured: `274` - // Estimated: `4764` - // Minimum execution time: 53_841_000 picoseconds. - Weight::from_parts(54_433_000, 0) - .saturating_add(Weight::from_parts(0, 4764)) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(5)) + // Estimated: `0` + // Minimum execution time: 53_482_000 picoseconds. + Weight::from_parts(54_756_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StakerInfo` (r:1 w:1) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::ContractStake` (r:1 w:1) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn unstake() -> Weight { // Proof Size summary in bytes: // Measured: `459` - // Estimated: `4764` - // Minimum execution time: 58_602_000 picoseconds. - Weight::from_parts(59_354_000, 0) - .saturating_add(Weight::from_parts(0, 4764)) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(5)) + // Estimated: `0` + // Minimum execution time: 58_638_000 picoseconds. + Weight::from_parts(59_292_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:0) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::PeriodEnd` (r:1 w:0) - /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 16]`. fn claim_staker_rewards_past_period(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `541` - // Estimated: `4764` - // Minimum execution time: 58_417_000 picoseconds. - Weight::from_parts(58_205_826, 0) - .saturating_add(Weight::from_parts(0, 4764)) - // Standard Error: 15_677 - .saturating_add(Weight::from_parts(1_917_365, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(2)) + // Estimated: `0` + // Minimum execution time: 57_353_000 picoseconds. + Weight::from_parts(56_809_462, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 5_135 + .saturating_add(Weight::from_parts(1_956_816, 0).saturating_mul(x.into())) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:0) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 16]`. fn claim_staker_rewards_ongoing_period(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `519` - // Estimated: `4764` - // Minimum execution time: 55_597_000 picoseconds. - Weight::from_parts(54_766_735, 0) - .saturating_add(Weight::from_parts(0, 4764)) - // Standard Error: 4_643 - .saturating_add(Weight::from_parts(1_964_351, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(2)) + // Estimated: `0` + // Minimum execution time: 54_268_000 picoseconds. + Weight::from_parts(53_207_081, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 7_050 + .saturating_add(Weight::from_parts(2_073_433, 0).saturating_mul(x.into())) } - /// Storage: `DappStaking::StakerInfo` (r:1 w:1) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::PeriodEnd` (r:1 w:0) - /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) fn claim_bonus_reward() -> Weight { // Proof Size summary in bytes: // Measured: `275` - // Estimated: `3775` - // Minimum execution time: 46_511_000 picoseconds. - Weight::from_parts(46_842_000, 0) - .saturating_add(Weight::from_parts(0, 3775)) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(2)) + // Estimated: `0` + // Minimum execution time: 46_935_000 picoseconds. + Weight::from_parts(47_437_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::DAppTiers` (r:1 w:1) - /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn claim_dapp_reward() -> Weight { // Proof Size summary in bytes: - // Measured: `2672` - // Estimated: `5113` - // Minimum execution time: 70_754_000 picoseconds. - Weight::from_parts(72_647_000, 0) - .saturating_add(Weight::from_parts(0, 5113)) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) + // Measured: `668` + // Estimated: `0` + // Minimum execution time: 30_151_000 picoseconds. + Weight::from_parts(30_749_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StakerInfo` (r:1 w:1) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn unstake_from_unregistered() -> Weight { // Proof Size summary in bytes: // Measured: `322` - // Estimated: `4764` - // Minimum execution time: 49_611_000 picoseconds. - Weight::from_parts(50_156_000, 0) - .saturating_add(Weight::from_parts(0, 4764)) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(4)) + // Estimated: `0` + // Minimum execution time: 48_601_000 picoseconds. + Weight::from_parts(49_205_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::StakerInfo` (r:17 w:16) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 16]`. fn cleanup_expired_entries(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `257 + x * (73 Β±0)` - // Estimated: `4764 + x * (2653 Β±0)` - // Minimum execution time: 48_067_000 picoseconds. - Weight::from_parts(44_647_745, 0) - .saturating_add(Weight::from_parts(0, 4764)) - // Standard Error: 12_548 - .saturating_add(Weight::from_parts(6_228_123, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(2)) - .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(x.into()))) - .saturating_add(Weight::from_parts(0, 2653).saturating_mul(x.into())) + // Estimated: `0` + // Minimum execution time: 46_242_000 picoseconds. + Weight::from_parts(43_292_594, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 13_352 + .saturating_add(Weight::from_parts(6_282_784, 0).saturating_mul(x.into())) } - /// Storage: `DappStaking::Safeguard` (r:1 w:0) - /// Proof: `DappStaking::Safeguard` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) fn force() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `1486` - // Minimum execution time: 13_005_000 picoseconds. - Weight::from_parts(13_524_000, 0) - .saturating_add(Weight::from_parts(0, 1486)) - .saturating_add(T::DbWeight::get().reads(1)) + // Estimated: `0` + // Minimum execution time: 11_385_000 picoseconds. + Weight::from_parts(11_569_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:2 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StakerInfo` (r:2 w:2) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::ContractStake` (r:2 w:2) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn move_stake_from_registered_source() -> Weight { // Proof Size summary in bytes: // Measured: `553` - // Estimated: `6296` - // Minimum execution time: 92_804_000 picoseconds. - Weight::from_parts(93_355_000, 0) - .saturating_add(Weight::from_parts(0, 6296)) - .saturating_add(T::DbWeight::get().reads(10)) - .saturating_add(T::DbWeight::get().writes(7)) + // Estimated: `0` + // Minimum execution time: 91_389_000 picoseconds. + Weight::from_parts(92_244_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:2 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StakerInfo` (r:2 w:2) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::ContractStake` (r:1 w:1) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) fn move_stake_unregistered_source() -> Weight { // Proof Size summary in bytes: // Measured: `419` - // Estimated: `6296` - // Minimum execution time: 83_894_000 picoseconds. - Weight::from_parts(85_431_000, 0) - .saturating_add(Weight::from_parts(0, 6296)) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(6)) + // Estimated: `0` + // Minimum execution time: 82_041_000 picoseconds. + Weight::from_parts(83_143_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:1) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) - /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(103), added: 598, mode: `MaxEncodedLen`) - /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) - /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::TierConfig` (r:1 w:1) - /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) fn on_initialize_voting_to_build_and_earn() -> Weight { // Proof Size summary in bytes: - // Measured: `224` - // Estimated: `4254` - // Minimum execution time: 28_879_000 picoseconds. - Weight::from_parts(29_876_000, 0) - .saturating_add(Weight::from_parts(0, 4254)) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(3)) + // Measured: `225` + // Estimated: `0` + // Minimum execution time: 25_935_000 picoseconds. + Weight::from_parts(26_354_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::PeriodEnd` (r:1 w:2) - /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::HistoryCleanupMarker` (r:1 w:1) - /// Proof: `DappStaking::HistoryCleanupMarker` (`max_values`: Some(1), `max_size`: Some(12), added: 507, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:1) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) - /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(103), added: 598, mode: `MaxEncodedLen`) - /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) - /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::TierConfig` (r:1 w:1) - /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::DAppTiers` (r:0 w:1) - /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn on_initialize_build_and_earn_to_voting() -> Weight { // Proof Size summary in bytes: - // Measured: `731` - // Estimated: `4254` - // Minimum execution time: 51_988_000 picoseconds. - Weight::from_parts(53_076_000, 0) - .saturating_add(Weight::from_parts(0, 4254)) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(7)) + // Measured: `791` + // Estimated: `0` + // Minimum execution time: 48_127_000 picoseconds. + Weight::from_parts(48_815_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:1) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) - /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(103), added: 598, mode: `MaxEncodedLen`) - /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) - /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::TierConfig` (r:1 w:1) - /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::DAppTiers` (r:0 w:1) - /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn on_initialize_build_and_earn_to_build_and_earn() -> Weight { // Proof Size summary in bytes: - // Measured: `276` - // Estimated: `4254` - // Minimum execution time: 31_974_000 picoseconds. - Weight::from_parts(32_938_000, 0) - .saturating_add(Weight::from_parts(0, 4254)) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(4)) + // Measured: `277` + // Estimated: `0` + // Minimum execution time: 29_870_000 picoseconds. + Weight::from_parts(30_278_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::ContractStake` (r:101 w:0) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::TierConfig` (r:1 w:0) - /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) - /// The range of component `x` is `[0, 100]`. + /// The range of component `x` is `[0, 16]`. fn dapp_tier_assignment(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `97 + x * (32 Β±0)` - // Estimated: `3061 + x * (2071 Β±0)` - // Minimum execution time: 8_154_000 picoseconds. - Weight::from_parts(10_541_455, 0) - .saturating_add(Weight::from_parts(0, 3061)) - // Standard Error: 3_518 - .saturating_add(Weight::from_parts(2_947_593, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(Weight::from_parts(0, 2071).saturating_mul(x.into())) + // Measured: `218 + x * (33 Β±0)` + // Estimated: `0` + // Minimum execution time: 11_764_000 picoseconds. + Weight::from_parts(15_737_959, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 15_337 + .saturating_add(Weight::from_parts(3_019_595, 0).saturating_mul(x.into())) } - /// Storage: `DappStaking::HistoryCleanupMarker` (r:1 w:1) - /// Proof: `DappStaking::HistoryCleanupMarker` (`max_values`: Some(1), `max_size`: Some(12), added: 507, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:1) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::DAppTiers` (r:0 w:1) - /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn on_idle_cleanup() -> Weight { // Proof Size summary in bytes: // Measured: `293` - // Estimated: `4254` - // Minimum execution time: 11_073_000 picoseconds. - Weight::from_parts(11_380_000, 0) - .saturating_add(Weight::from_parts(0, 4254)) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(3)) - } - /// Storage: `DappStaking::Ledger` (r:2 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - fn step() -> Weight { - // Proof Size summary in bytes: - // Measured: `76` - // Estimated: `6560` - // Minimum execution time: 20_821_000 picoseconds. - Weight::from_parts(21_079_000, 0) - .saturating_add(Weight::from_parts(0, 6560)) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) + // Estimated: `0` + // Minimum execution time: 10_067_000 picoseconds. + Weight::from_parts(10_287_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::StaticTierParams` (r:0 w:1) - /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(103), added: 598, mode: `MaxEncodedLen`) fn set_static_tier_params() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 11_181_000 picoseconds. - Weight::from_parts(11_568_000, 0) + // Minimum execution time: 11_443_000 picoseconds. + Weight::from_parts(11_654_000, 0) .saturating_add(Weight::from_parts(0, 0)) - .saturating_add(T::DbWeight::get().writes(1)) } } diff --git a/runtime/shibuya/src/weights/pallet_dapp_staking.rs b/runtime/shibuya/src/weights/pallet_dapp_staking.rs index 7eece112a3..5f28819752 100644 --- a/runtime/shibuya/src/weights/pallet_dapp_staking.rs +++ b/runtime/shibuya/src/weights/pallet_dapp_staking.rs @@ -20,7 +20,7 @@ //! Autogenerated weights for `pallet_dapp_staking` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2025-12-19, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2026-02-02, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `gh-runner-01-ovh`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` //! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024 @@ -56,511 +56,231 @@ impl pallet_dapp_staking::WeightInfo for SubstrateWeigh // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_532_000 picoseconds. - Weight::from_parts(9_897_000, 0) + // Minimum execution time: 8_290_000 picoseconds. + Weight::from_parts(8_493_000, 0) .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CounterForIntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::CounterForIntegratedDApps` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::NextDAppId` (r:1 w:1) - /// Proof: `DappStaking::NextDAppId` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) fn register() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `3086` - // Minimum execution time: 18_129_000 picoseconds. - Weight::from_parts(18_554_000, 0) - .saturating_add(Weight::from_parts(0, 3086)) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(3)) + // Estimated: `0` + // Minimum execution time: 16_770_000 picoseconds. + Weight::from_parts(17_066_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) fn set_dapp_reward_beneficiary() -> Weight { // Proof Size summary in bytes: // Measured: `97` - // Estimated: `3086` - // Minimum execution time: 15_530_000 picoseconds. - Weight::from_parts(15_992_000, 0) - .saturating_add(Weight::from_parts(0, 3086)) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + // Estimated: `0` + // Minimum execution time: 14_545_000 picoseconds. + Weight::from_parts(14_908_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) fn set_dapp_owner() -> Weight { // Proof Size summary in bytes: // Measured: `97` - // Estimated: `3086` - // Minimum execution time: 15_450_000 picoseconds. - Weight::from_parts(15_816_000, 0) - .saturating_add(Weight::from_parts(0, 3086)) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + // Estimated: `0` + // Minimum execution time: 14_518_000 picoseconds. + Weight::from_parts(14_856_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CounterForIntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::CounterForIntegratedDApps` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::ContractStake` (r:0 w:1) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) fn unregister() -> Weight { // Proof Size summary in bytes: // Measured: `97` - // Estimated: `3086` - // Minimum execution time: 21_399_000 picoseconds. - Weight::from_parts(21_894_000, 0) - .saturating_add(Weight::from_parts(0, 3086)) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(3)) + // Estimated: `0` + // Minimum execution time: 20_385_000 picoseconds. + Weight::from_parts(20_858_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `CollatorSelection::Candidates` (r:1 w:0) - /// Proof: `CollatorSelection::Candidates` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn lock_new_account() -> Weight { // Proof Size summary in bytes: // Measured: `138` - // Estimated: `4764` - // Minimum execution time: 39_604_000 picoseconds. - Weight::from_parts(40_324_000, 0) - .saturating_add(Weight::from_parts(0, 4764)) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(3)) + // Estimated: `0` + // Minimum execution time: 38_845_000 picoseconds. + Weight::from_parts(39_782_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn lock_existing_account() -> Weight { // Proof Size summary in bytes: // Measured: `156` - // Estimated: `4764` - // Minimum execution time: 39_781_000 picoseconds. - Weight::from_parts(40_572_000, 0) - .saturating_add(Weight::from_parts(0, 4764)) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) + // Estimated: `0` + // Minimum execution time: 39_325_000 picoseconds. + Weight::from_parts(39_763_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn unlock() -> Weight { // Proof Size summary in bytes: // Measured: `156` - // Estimated: `4764` - // Minimum execution time: 36_894_000 picoseconds. - Weight::from_parts(37_502_000, 0) - .saturating_add(Weight::from_parts(0, 4764)) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) + // Estimated: `0` + // Minimum execution time: 36_390_000 picoseconds. + Weight::from_parts(36_779_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) /// The range of component `x` is `[0, 8]`. fn claim_unlocked(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `187` - // Estimated: `4764` - // Minimum execution time: 39_921_000 picoseconds. - Weight::from_parts(41_384_208, 0) - .saturating_add(Weight::from_parts(0, 4764)) - // Standard Error: 7_176 - .saturating_add(Weight::from_parts(139_066, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) + // Estimated: `0` + // Minimum execution time: 38_863_000 picoseconds. + Weight::from_parts(40_578_112, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 9_609 + .saturating_add(Weight::from_parts(282_019, 0).saturating_mul(x.into())) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn relock_unlocking() -> Weight { // Proof Size summary in bytes: // Measured: `182` - // Estimated: `4764` - // Minimum execution time: 37_096_000 picoseconds. - Weight::from_parts(38_049_000, 0) - .saturating_add(Weight::from_parts(0, 4764)) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) + // Estimated: `0` + // Minimum execution time: 35_361_000 picoseconds. + Weight::from_parts(35_932_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StakerInfo` (r:1 w:1) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::ContractStake` (r:1 w:1) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn stake() -> Weight { // Proof Size summary in bytes: // Measured: `272` - // Estimated: `4764` - // Minimum execution time: 54_713_000 picoseconds. - Weight::from_parts(55_369_000, 0) - .saturating_add(Weight::from_parts(0, 4764)) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(5)) + // Estimated: `0` + // Minimum execution time: 53_590_000 picoseconds. + Weight::from_parts(54_368_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StakerInfo` (r:1 w:1) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::ContractStake` (r:1 w:1) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn unstake() -> Weight { // Proof Size summary in bytes: // Measured: `453` - // Estimated: `4764` - // Minimum execution time: 58_830_000 picoseconds. - Weight::from_parts(59_364_000, 0) - .saturating_add(Weight::from_parts(0, 4764)) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(5)) + // Estimated: `0` + // Minimum execution time: 58_914_000 picoseconds. + Weight::from_parts(59_895_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:0) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::PeriodEnd` (r:1 w:0) - /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 16]`. fn claim_staker_rewards_past_period(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `522` - // Estimated: `4764` - // Minimum execution time: 58_201_000 picoseconds. - Weight::from_parts(57_727_458, 0) - .saturating_add(Weight::from_parts(0, 4764)) - // Standard Error: 5_462 - .saturating_add(Weight::from_parts(1_989_282, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(2)) + // Estimated: `0` + // Minimum execution time: 57_327_000 picoseconds. + Weight::from_parts(56_493_558, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 6_009 + .saturating_add(Weight::from_parts(1_994_730, 0).saturating_mul(x.into())) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:0) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 16]`. fn claim_staker_rewards_ongoing_period(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `501` - // Estimated: `4764` - // Minimum execution time: 55_294_000 picoseconds. - Weight::from_parts(54_610_504, 0) - .saturating_add(Weight::from_parts(0, 4764)) - // Standard Error: 4_838 - .saturating_add(Weight::from_parts(1_998_977, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(2)) + // Estimated: `0` + // Minimum execution time: 54_277_000 picoseconds. + Weight::from_parts(53_284_580, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 4_814 + .saturating_add(Weight::from_parts(2_015_560, 0).saturating_mul(x.into())) } - /// Storage: `DappStaking::StakerInfo` (r:1 w:1) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::PeriodEnd` (r:1 w:0) - /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) fn claim_bonus_reward() -> Weight { // Proof Size summary in bytes: // Measured: `271` - // Estimated: `3775` - // Minimum execution time: 46_757_000 picoseconds. - Weight::from_parts(47_194_000, 0) - .saturating_add(Weight::from_parts(0, 3775)) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(2)) + // Estimated: `0` + // Minimum execution time: 46_394_000 picoseconds. + Weight::from_parts(46_811_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::DAppTiers` (r:1 w:1) - /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn claim_dapp_reward() -> Weight { // Proof Size summary in bytes: - // Measured: `2672` - // Estimated: `5113` - // Minimum execution time: 71_261_000 picoseconds. - Weight::from_parts(72_272_000, 0) - .saturating_add(Weight::from_parts(0, 5113)) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) + // Measured: `668` + // Estimated: `0` + // Minimum execution time: 30_398_000 picoseconds. + Weight::from_parts(31_453_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StakerInfo` (r:1 w:1) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn unstake_from_unregistered() -> Weight { // Proof Size summary in bytes: // Measured: `317` - // Estimated: `4764` - // Minimum execution time: 49_203_000 picoseconds. - Weight::from_parts(49_852_000, 0) - .saturating_add(Weight::from_parts(0, 4764)) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(4)) + // Estimated: `0` + // Minimum execution time: 49_106_000 picoseconds. + Weight::from_parts(49_724_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::StakerInfo` (r:9 w:8) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 8]`. fn cleanup_expired_entries(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `255 + x * (73 Β±0)` - // Estimated: `4764 + x * (2653 Β±0)` - // Minimum execution time: 47_596_000 picoseconds. - Weight::from_parts(43_009_084, 0) - .saturating_add(Weight::from_parts(0, 4764)) - // Standard Error: 19_857 - .saturating_add(Weight::from_parts(6_633_799, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(2)) - .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(x.into()))) - .saturating_add(Weight::from_parts(0, 2653).saturating_mul(x.into())) + // Estimated: `0` + // Minimum execution time: 46_769_000 picoseconds. + Weight::from_parts(42_908_204, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 26_105 + .saturating_add(Weight::from_parts(6_690_680, 0).saturating_mul(x.into())) } - /// Storage: `DappStaking::Safeguard` (r:1 w:0) - /// Proof: `DappStaking::Safeguard` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) fn force() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `1486` - // Minimum execution time: 13_204_000 picoseconds. - Weight::from_parts(13_544_000, 0) - .saturating_add(Weight::from_parts(0, 1486)) - .saturating_add(T::DbWeight::get().reads(1)) + // Estimated: `0` + // Minimum execution time: 11_657_000 picoseconds. + Weight::from_parts(12_135_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:2 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StakerInfo` (r:2 w:2) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::ContractStake` (r:2 w:2) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn move_stake_from_registered_source() -> Weight { // Proof Size summary in bytes: // Measured: `547` - // Estimated: `6296` - // Minimum execution time: 92_603_000 picoseconds. - Weight::from_parts(93_224_000, 0) - .saturating_add(Weight::from_parts(0, 6296)) - .saturating_add(T::DbWeight::get().reads(10)) - .saturating_add(T::DbWeight::get().writes(7)) + // Estimated: `0` + // Minimum execution time: 92_997_000 picoseconds. + Weight::from_parts(93_781_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:2 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StakerInfo` (r:2 w:2) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::ContractStake` (r:1 w:1) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) fn move_stake_unregistered_source() -> Weight { // Proof Size summary in bytes: // Measured: `414` - // Estimated: `6296` - // Minimum execution time: 82_675_000 picoseconds. - Weight::from_parts(83_376_000, 0) - .saturating_add(Weight::from_parts(0, 6296)) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(6)) + // Estimated: `0` + // Minimum execution time: 83_926_000 picoseconds. + Weight::from_parts(84_700_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:1) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) - /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(103), added: 598, mode: `MaxEncodedLen`) - /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) - /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::TierConfig` (r:1 w:1) - /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) fn on_initialize_voting_to_build_and_earn() -> Weight { // Proof Size summary in bytes: - // Measured: `224` - // Estimated: `4254` - // Minimum execution time: 28_436_000 picoseconds. - Weight::from_parts(28_792_000, 0) - .saturating_add(Weight::from_parts(0, 4254)) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(3)) + // Measured: `225` + // Estimated: `0` + // Minimum execution time: 26_133_000 picoseconds. + Weight::from_parts(26_567_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::PeriodEnd` (r:1 w:2) - /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::HistoryCleanupMarker` (r:1 w:1) - /// Proof: `DappStaking::HistoryCleanupMarker` (`max_values`: Some(1), `max_size`: Some(12), added: 507, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:1) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) - /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(103), added: 598, mode: `MaxEncodedLen`) - /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) - /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::TierConfig` (r:1 w:1) - /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::DAppTiers` (r:0 w:1) - /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn on_initialize_build_and_earn_to_voting() -> Weight { // Proof Size summary in bytes: - // Measured: `539` - // Estimated: `4254` - // Minimum execution time: 48_030_000 picoseconds. - Weight::from_parts(49_088_000, 0) - .saturating_add(Weight::from_parts(0, 4254)) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(7)) + // Measured: `327` + // Estimated: `0` + // Minimum execution time: 43_212_000 picoseconds. + Weight::from_parts(43_696_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:1) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) - /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(103), added: 598, mode: `MaxEncodedLen`) - /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) - /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::TierConfig` (r:1 w:1) - /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::DAppTiers` (r:0 w:1) - /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn on_initialize_build_and_earn_to_build_and_earn() -> Weight { // Proof Size summary in bytes: - // Measured: `278` - // Estimated: `4254` - // Minimum execution time: 32_729_000 picoseconds. - Weight::from_parts(33_354_000, 0) - .saturating_add(Weight::from_parts(0, 4254)) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(4)) + // Measured: `279` + // Estimated: `0` + // Minimum execution time: 29_729_000 picoseconds. + Weight::from_parts(30_321_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::ContractStake` (r:101 w:0) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::TierConfig` (r:1 w:0) - /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) - /// The range of component `x` is `[0, 100]`. + /// The range of component `x` is `[0, 16]`. fn dapp_tier_assignment(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `97 + x * (32 Β±0)` - // Estimated: `3061 + x * (2071 Β±0)` - // Minimum execution time: 7_765_000 picoseconds. - Weight::from_parts(10_543_604, 0) - .saturating_add(Weight::from_parts(0, 3061)) - // Standard Error: 3_697 - .saturating_add(Weight::from_parts(2_956_785, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(Weight::from_parts(0, 2071).saturating_mul(x.into())) + // Measured: `218 + x * (33 Β±0)` + // Estimated: `0` + // Minimum execution time: 11_643_000 picoseconds. + Weight::from_parts(15_765_186, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 16_284 + .saturating_add(Weight::from_parts(3_069_787, 0).saturating_mul(x.into())) } - /// Storage: `DappStaking::HistoryCleanupMarker` (r:1 w:1) - /// Proof: `DappStaking::HistoryCleanupMarker` (`max_values`: Some(1), `max_size`: Some(12), added: 507, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:1) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::DAppTiers` (r:0 w:1) - /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn on_idle_cleanup() -> Weight { // Proof Size summary in bytes: // Measured: `293` - // Estimated: `4254` - // Minimum execution time: 11_087_000 picoseconds. - Weight::from_parts(11_359_000, 0) - .saturating_add(Weight::from_parts(0, 4254)) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(3)) - } - /// Storage: `DappStaking::Ledger` (r:2 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - fn step() -> Weight { - // Proof Size summary in bytes: - // Measured: `76` - // Estimated: `6560` - // Minimum execution time: 20_705_000 picoseconds. - Weight::from_parts(20_875_000, 0) - .saturating_add(Weight::from_parts(0, 6560)) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) + // Estimated: `0` + // Minimum execution time: 9_947_000 picoseconds. + Weight::from_parts(10_127_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::StaticTierParams` (r:0 w:1) - /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(103), added: 598, mode: `MaxEncodedLen`) fn set_static_tier_params() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 11_035_000 picoseconds. - Weight::from_parts(11_350_000, 0) + // Minimum execution time: 11_447_000 picoseconds. + Weight::from_parts(11_859_000, 0) .saturating_add(Weight::from_parts(0, 0)) - .saturating_add(T::DbWeight::get().writes(1)) } } diff --git a/runtime/shiden/src/weights/pallet_dapp_staking.rs b/runtime/shiden/src/weights/pallet_dapp_staking.rs index 5c4cf5983e..549c030e2a 100644 --- a/runtime/shiden/src/weights/pallet_dapp_staking.rs +++ b/runtime/shiden/src/weights/pallet_dapp_staking.rs @@ -20,7 +20,7 @@ //! Autogenerated weights for `pallet_dapp_staking` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2025-12-19, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2026-02-02, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `gh-runner-01-ovh`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` //! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024 @@ -56,511 +56,231 @@ impl pallet_dapp_staking::WeightInfo for SubstrateWeigh // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_406_000 picoseconds. - Weight::from_parts(9_780_000, 0) + // Minimum execution time: 8_284_000 picoseconds. + Weight::from_parts(8_403_000, 0) .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CounterForIntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::CounterForIntegratedDApps` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::NextDAppId` (r:1 w:1) - /// Proof: `DappStaking::NextDAppId` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) fn register() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `3086` - // Minimum execution time: 17_829_000 picoseconds. - Weight::from_parts(18_261_000, 0) - .saturating_add(Weight::from_parts(0, 3086)) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(3)) + // Estimated: `0` + // Minimum execution time: 16_715_000 picoseconds. + Weight::from_parts(16_985_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) fn set_dapp_reward_beneficiary() -> Weight { // Proof Size summary in bytes: // Measured: `97` - // Estimated: `3086` - // Minimum execution time: 15_690_000 picoseconds. - Weight::from_parts(15_934_000, 0) - .saturating_add(Weight::from_parts(0, 3086)) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + // Estimated: `0` + // Minimum execution time: 14_530_000 picoseconds. + Weight::from_parts(14_745_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) fn set_dapp_owner() -> Weight { // Proof Size summary in bytes: // Measured: `97` - // Estimated: `3086` - // Minimum execution time: 15_495_000 picoseconds. - Weight::from_parts(15_723_000, 0) - .saturating_add(Weight::from_parts(0, 3086)) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + // Estimated: `0` + // Minimum execution time: 14_716_000 picoseconds. + Weight::from_parts(15_057_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CounterForIntegratedDApps` (r:1 w:1) - /// Proof: `DappStaking::CounterForIntegratedDApps` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::ContractStake` (r:0 w:1) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) fn unregister() -> Weight { // Proof Size summary in bytes: // Measured: `97` - // Estimated: `3086` - // Minimum execution time: 21_199_000 picoseconds. - Weight::from_parts(21_590_000, 0) - .saturating_add(Weight::from_parts(0, 3086)) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(3)) + // Estimated: `0` + // Minimum execution time: 20_279_000 picoseconds. + Weight::from_parts(20_656_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `CollatorSelection::Candidates` (r:1 w:0) - /// Proof: `CollatorSelection::Candidates` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn lock_new_account() -> Weight { // Proof Size summary in bytes: // Measured: `138` - // Estimated: `4764` - // Minimum execution time: 39_236_000 picoseconds. - Weight::from_parts(39_812_000, 0) - .saturating_add(Weight::from_parts(0, 4764)) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(3)) + // Estimated: `0` + // Minimum execution time: 38_413_000 picoseconds. + Weight::from_parts(38_861_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn lock_existing_account() -> Weight { // Proof Size summary in bytes: // Measured: `158` - // Estimated: `4764` - // Minimum execution time: 39_373_000 picoseconds. - Weight::from_parts(40_217_000, 0) - .saturating_add(Weight::from_parts(0, 4764)) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) + // Estimated: `0` + // Minimum execution time: 39_039_000 picoseconds. + Weight::from_parts(39_461_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn unlock() -> Weight { // Proof Size summary in bytes: // Measured: `158` - // Estimated: `4764` - // Minimum execution time: 36_934_000 picoseconds. - Weight::from_parts(37_581_000, 0) - .saturating_add(Weight::from_parts(0, 4764)) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) + // Estimated: `0` + // Minimum execution time: 35_493_000 picoseconds. + Weight::from_parts(36_071_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) /// The range of component `x` is `[0, 16]`. fn claim_unlocked(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `191` - // Estimated: `4764` - // Minimum execution time: 39_285_000 picoseconds. - Weight::from_parts(41_007_215, 0) - .saturating_add(Weight::from_parts(0, 4764)) - // Standard Error: 3_865 - .saturating_add(Weight::from_parts(87_249, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) + // Measured: `189` + // Estimated: `0` + // Minimum execution time: 38_457_000 picoseconds. + Weight::from_parts(40_704_516, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 5_739 + .saturating_add(Weight::from_parts(119_879, 0).saturating_mul(x.into())) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn relock_unlocking() -> Weight { // Proof Size summary in bytes: // Measured: `200` - // Estimated: `4764` - // Minimum execution time: 37_235_000 picoseconds. - Weight::from_parts(37_762_000, 0) - .saturating_add(Weight::from_parts(0, 4764)) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) + // Estimated: `0` + // Minimum execution time: 35_394_000 picoseconds. + Weight::from_parts(36_170_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StakerInfo` (r:1 w:1) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::ContractStake` (r:1 w:1) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn stake() -> Weight { // Proof Size summary in bytes: // Measured: `274` - // Estimated: `4764` - // Minimum execution time: 52_461_000 picoseconds. - Weight::from_parts(52_979_000, 0) - .saturating_add(Weight::from_parts(0, 4764)) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(5)) + // Estimated: `0` + // Minimum execution time: 52_850_000 picoseconds. + Weight::from_parts(53_469_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StakerInfo` (r:1 w:1) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::ContractStake` (r:1 w:1) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn unstake() -> Weight { // Proof Size summary in bytes: // Measured: `459` - // Estimated: `4764` - // Minimum execution time: 58_337_000 picoseconds. - Weight::from_parts(58_706_000, 0) - .saturating_add(Weight::from_parts(0, 4764)) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(5)) + // Estimated: `0` + // Minimum execution time: 58_136_000 picoseconds. + Weight::from_parts(58_441_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:0) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::PeriodEnd` (r:1 w:0) - /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 16]`. fn claim_staker_rewards_past_period(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `542` - // Estimated: `4764` - // Minimum execution time: 58_460_000 picoseconds. - Weight::from_parts(57_283_269, 0) - .saturating_add(Weight::from_parts(0, 4764)) - // Standard Error: 6_506 - .saturating_add(Weight::from_parts(2_028_988, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(2)) + // Estimated: `0` + // Minimum execution time: 56_809_000 picoseconds. + Weight::from_parts(56_700_953, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 6_049 + .saturating_add(Weight::from_parts(1_919_321, 0).saturating_mul(x.into())) } - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:0) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 16]`. fn claim_staker_rewards_ongoing_period(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `519` - // Estimated: `4764` - // Minimum execution time: 55_481_000 picoseconds. - Weight::from_parts(54_617_998, 0) - .saturating_add(Weight::from_parts(0, 4764)) - // Standard Error: 3_367 - .saturating_add(Weight::from_parts(1_970_584, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(2)) + // Estimated: `0` + // Minimum execution time: 54_361_000 picoseconds. + Weight::from_parts(53_687_425, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 4_685 + .saturating_add(Weight::from_parts(1_930_615, 0).saturating_mul(x.into())) } - /// Storage: `DappStaking::StakerInfo` (r:1 w:1) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::PeriodEnd` (r:1 w:0) - /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) fn claim_bonus_reward() -> Weight { // Proof Size summary in bytes: // Measured: `276` - // Estimated: `3775` - // Minimum execution time: 46_545_000 picoseconds. - Weight::from_parts(47_014_000, 0) - .saturating_add(Weight::from_parts(0, 3775)) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(2)) + // Estimated: `0` + // Minimum execution time: 45_190_000 picoseconds. + Weight::from_parts(45_715_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::DAppTiers` (r:1 w:1) - /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn claim_dapp_reward() -> Weight { // Proof Size summary in bytes: - // Measured: `2672` - // Estimated: `5113` - // Minimum execution time: 69_501_000 picoseconds. - Weight::from_parts(71_646_000, 0) - .saturating_add(Weight::from_parts(0, 5113)) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) + // Measured: `668` + // Estimated: `0` + // Minimum execution time: 30_344_000 picoseconds. + Weight::from_parts(30_619_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StakerInfo` (r:1 w:1) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn unstake_from_unregistered() -> Weight { // Proof Size summary in bytes: // Measured: `322` - // Estimated: `4764` - // Minimum execution time: 49_089_000 picoseconds. - Weight::from_parts(49_829_000, 0) - .saturating_add(Weight::from_parts(0, 4764)) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(4)) + // Estimated: `0` + // Minimum execution time: 49_148_000 picoseconds. + Weight::from_parts(49_635_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::StakerInfo` (r:17 w:16) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 16]`. fn cleanup_expired_entries(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `256 + x * (73 Β±0)` - // Estimated: `4764 + x * (2653 Β±0)` - // Minimum execution time: 47_545_000 picoseconds. - Weight::from_parts(44_118_524, 0) - .saturating_add(Weight::from_parts(0, 4764)) - // Standard Error: 14_130 - .saturating_add(Weight::from_parts(6_063_445, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(2)) - .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(x.into()))) - .saturating_add(Weight::from_parts(0, 2653).saturating_mul(x.into())) + // Estimated: `0` + // Minimum execution time: 46_828_000 picoseconds. + Weight::from_parts(43_928_951, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 13_864 + .saturating_add(Weight::from_parts(6_099_811, 0).saturating_mul(x.into())) } - /// Storage: `DappStaking::Safeguard` (r:1 w:0) - /// Proof: `DappStaking::Safeguard` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) fn force() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `1486` - // Minimum execution time: 12_530_000 picoseconds. - Weight::from_parts(13_183_000, 0) - .saturating_add(Weight::from_parts(0, 1486)) - .saturating_add(T::DbWeight::get().reads(1)) + // Estimated: `0` + // Minimum execution time: 11_492_000 picoseconds. + Weight::from_parts(11_709_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:2 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StakerInfo` (r:2 w:2) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::ContractStake` (r:2 w:2) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn move_stake_from_registered_source() -> Weight { // Proof Size summary in bytes: // Measured: `553` - // Estimated: `6296` - // Minimum execution time: 93_462_000 picoseconds. - Weight::from_parts(93_840_000, 0) - .saturating_add(Weight::from_parts(0, 6296)) - .saturating_add(T::DbWeight::get().reads(10)) - .saturating_add(T::DbWeight::get().writes(7)) + // Estimated: `0` + // Minimum execution time: 91_791_000 picoseconds. + Weight::from_parts(92_341_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::IntegratedDApps` (r:2 w:0) - /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StakerInfo` (r:2 w:2) - /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::Ledger` (r:1 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `Balances::Freezes` (r:1 w:1) - /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) - /// Storage: `Balances::Locks` (r:1 w:0) - /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::ContractStake` (r:1 w:1) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) fn move_stake_unregistered_source() -> Weight { // Proof Size summary in bytes: // Measured: `419` - // Estimated: `6296` - // Minimum execution time: 82_467_000 picoseconds. - Weight::from_parts(83_472_000, 0) - .saturating_add(Weight::from_parts(0, 6296)) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(6)) + // Estimated: `0` + // Minimum execution time: 82_678_000 picoseconds. + Weight::from_parts(84_812_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:1) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) - /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(103), added: 598, mode: `MaxEncodedLen`) - /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) - /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::TierConfig` (r:1 w:1) - /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) fn on_initialize_voting_to_build_and_earn() -> Weight { // Proof Size summary in bytes: - // Measured: `224` - // Estimated: `4254` - // Minimum execution time: 29_054_000 picoseconds. - Weight::from_parts(29_408_000, 0) - .saturating_add(Weight::from_parts(0, 4254)) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(3)) + // Measured: `225` + // Estimated: `0` + // Minimum execution time: 25_957_000 picoseconds. + Weight::from_parts(26_266_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::PeriodEnd` (r:1 w:2) - /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::HistoryCleanupMarker` (r:1 w:1) - /// Proof: `DappStaking::HistoryCleanupMarker` (`max_values`: Some(1), `max_size`: Some(12), added: 507, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:1) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) - /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(103), added: 598, mode: `MaxEncodedLen`) - /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) - /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::TierConfig` (r:1 w:1) - /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::DAppTiers` (r:0 w:1) - /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn on_initialize_build_and_earn_to_voting() -> Weight { // Proof Size summary in bytes: - // Measured: `764` - // Estimated: `4254` - // Minimum execution time: 50_290_000 picoseconds. - Weight::from_parts(51_708_000, 0) - .saturating_add(Weight::from_parts(0, 4254)) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(7)) + // Measured: `880` + // Estimated: `0` + // Minimum execution time: 49_722_000 picoseconds. + Weight::from_parts(50_675_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) - /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:1) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) - /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(103), added: 598, mode: `MaxEncodedLen`) - /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) - /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::TierConfig` (r:1 w:1) - /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::DAppTiers` (r:0 w:1) - /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn on_initialize_build_and_earn_to_build_and_earn() -> Weight { // Proof Size summary in bytes: - // Measured: `278` - // Estimated: `4254` - // Minimum execution time: 32_677_000 picoseconds. - Weight::from_parts(33_491_000, 0) - .saturating_add(Weight::from_parts(0, 4254)) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(4)) + // Measured: `279` + // Estimated: `0` + // Minimum execution time: 30_400_000 picoseconds. + Weight::from_parts(30_884_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::ContractStake` (r:101 w:0) - /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::TierConfig` (r:1 w:0) - /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) - /// The range of component `x` is `[0, 100]`. + /// The range of component `x` is `[0, 16]`. fn dapp_tier_assignment(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `97 + x * (32 Β±0)` - // Estimated: `3061 + x * (2071 Β±0)` - // Minimum execution time: 7_676_000 picoseconds. - Weight::from_parts(10_555_931, 0) - .saturating_add(Weight::from_parts(0, 3061)) - // Standard Error: 8_246 - .saturating_add(Weight::from_parts(3_036_518, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(Weight::from_parts(0, 2071).saturating_mul(x.into())) + // Measured: `218 + x * (33 Β±0)` + // Estimated: `0` + // Minimum execution time: 11_893_000 picoseconds. + Weight::from_parts(15_926_884, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 16_911 + .saturating_add(Weight::from_parts(3_091_031, 0).saturating_mul(x.into())) } - /// Storage: `DappStaking::HistoryCleanupMarker` (r:1 w:1) - /// Proof: `DappStaking::HistoryCleanupMarker` (`max_values`: Some(1), `max_size`: Some(12), added: 507, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::EraRewards` (r:1 w:1) - /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) - /// Storage: `DappStaking::DAppTiers` (r:0 w:1) - /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn on_idle_cleanup() -> Weight { // Proof Size summary in bytes: // Measured: `293` - // Estimated: `4254` - // Minimum execution time: 10_846_000 picoseconds. - Weight::from_parts(11_054_000, 0) - .saturating_add(Weight::from_parts(0, 4254)) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(3)) - } - /// Storage: `DappStaking::Ledger` (r:2 w:1) - /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) - fn step() -> Weight { - // Proof Size summary in bytes: - // Measured: `76` - // Estimated: `6560` - // Minimum execution time: 19_955_000 picoseconds. - Weight::from_parts(20_380_000, 0) - .saturating_add(Weight::from_parts(0, 6560)) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) + // Estimated: `0` + // Minimum execution time: 9_940_000 picoseconds. + Weight::from_parts(10_091_000, 0) + .saturating_add(Weight::from_parts(0, 0)) } - /// Storage: `DappStaking::StaticTierParams` (r:0 w:1) - /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(103), added: 598, mode: `MaxEncodedLen`) fn set_static_tier_params() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 10_691_000 picoseconds. - Weight::from_parts(10_848_000, 0) + // Minimum execution time: 11_343_000 picoseconds. + Weight::from_parts(11_825_000, 0) .saturating_add(Weight::from_parts(0, 0)) - .saturating_add(T::DbWeight::get().writes(1)) } } From d0468b4103ba81bf1326b06c17b062a89fd75003 Mon Sep 17 00:00:00 2001 From: Igor Papandinas <26460174+ipapandinas@users.noreply.github.com> Date: Mon, 2 Feb 2026 20:13:42 +0400 Subject: [PATCH 08/16] fix weights --- pallets/dapp-staking/src/weights.rs | 982 ++++++++++++++++++++++++---- 1 file changed, 848 insertions(+), 134 deletions(-) diff --git a/pallets/dapp-staking/src/weights.rs b/pallets/dapp-staking/src/weights.rs index 3d3b0793a6..357ec2b1ae 100644 --- a/pallets/dapp-staking/src/weights.rs +++ b/pallets/dapp-staking/src/weights.rs @@ -17,39 +17,36 @@ // You should have received a copy of the GNU General Public License // along with Astar. If not, see . -//! Autogenerated weights for `pallet_dapp_staking` +//! Autogenerated weights for pallet_dapp_staking //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2026-02-02, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 42.0.1 +//! DATE: 2025-02-19, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `gh-runner-01-ovh`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` -//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024 +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("astar-dev"), DB CACHE: 1024 // Executed Command: -// frame-omni-bencher -// v1 +// ./target/release/astar-collator // benchmark // pallet -// --runtime=./target/release/wbuild/astar-runtime/astar_runtime.compact.compressed.wasm +// --chain=astar-dev // --steps=50 // --repeat=20 // --pallet=pallet_dapp_staking // --extrinsic=* // --wasm-execution=compiled // --heap-pages=4096 -// --output=./benchmark-results/astar/pallet/dapp_staking_weights.rs -// --template=./scripts/templates/pallet-weight-template.hbs +// --output=./benchmark-results/astar-dev/dapp_staking_weights.rs +// --template=./scripts/templates/weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] -#![allow(missing_docs)] -#![allow(dead_code)] -use frame_support::{traits::Get, weights::Weight}; +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use core::marker::PhantomData; -/// Weight info trait. +/// Weight functions needed for pallet_dapp_staking. pub trait WeightInfo { fn maintenance_mode() -> Weight; fn register() -> Weight; @@ -80,238 +77,955 @@ pub trait WeightInfo { fn set_static_tier_params() -> Weight; } -/// Weight functions for `pallet_dapp_staking`. +/// Weights for pallet_dapp_staking using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn maintenance_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_353_000 picoseconds. - Weight::from_parts(8_607_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Minimum execution time: 6_160_000 picoseconds. + Weight::from_parts(6_345_000, 0) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CounterForIntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::CounterForIntegratedDApps` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::NextDAppId` (r:1 w:1) + /// Proof: `DappStaking::NextDAppId` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) fn register() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `0` - // Minimum execution time: 16_653_000 picoseconds. - Weight::from_parts(16_994_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `3086` + // Minimum execution time: 12_235_000 picoseconds. + Weight::from_parts(12_512_000, 3086) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) fn set_dapp_reward_beneficiary() -> Weight { // Proof Size summary in bytes: // Measured: `97` - // Estimated: `0` - // Minimum execution time: 14_619_000 picoseconds. - Weight::from_parts(14_785_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `3086` + // Minimum execution time: 10_517_000 picoseconds. + Weight::from_parts(10_793_000, 3086) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) fn set_dapp_owner() -> Weight { // Proof Size summary in bytes: // Measured: `97` - // Estimated: `0` - // Minimum execution time: 14_373_000 picoseconds. - Weight::from_parts(14_854_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `3086` + // Minimum execution time: 10_363_000 picoseconds. + Weight::from_parts(10_656_000, 3086) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CounterForIntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::CounterForIntegratedDApps` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::ContractStake` (r:0 w:1) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) fn unregister() -> Weight { // Proof Size summary in bytes: // Measured: `97` - // Estimated: `0` - // Minimum execution time: 20_743_000 picoseconds. - Weight::from_parts(21_182_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `3086` + // Minimum execution time: 14_595_000 picoseconds. + Weight::from_parts(14_935_000, 3086) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `CollatorSelection::Candidates` (r:1 w:0) + /// Proof: `CollatorSelection::Candidates` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn lock_new_account() -> Weight { // Proof Size summary in bytes: // Measured: `138` - // Estimated: `0` - // Minimum execution time: 38_026_000 picoseconds. - Weight::from_parts(38_676_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 31_874_000 picoseconds. + Weight::from_parts(32_108_000, 4764) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn lock_existing_account() -> Weight { // Proof Size summary in bytes: // Measured: `158` - // Estimated: `0` - // Minimum execution time: 38_830_000 picoseconds. - Weight::from_parts(39_535_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 32_204_000 picoseconds. + Weight::from_parts(32_658_000, 4764) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn unlock() -> Weight { // Proof Size summary in bytes: // Measured: `158` - // Estimated: `0` - // Minimum execution time: 35_841_000 picoseconds. - Weight::from_parts(36_134_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 28_967_000 picoseconds. + Weight::from_parts(29_523_000, 4764) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) /// The range of component `x` is `[0, 16]`. fn claim_unlocked(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `190` - // Estimated: `0` - // Minimum execution time: 38_569_000 picoseconds. - Weight::from_parts(40_971_399, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 5_564 - .saturating_add(Weight::from_parts(92_129, 0).saturating_mul(x.into())) + // Estimated: `4764` + // Minimum execution time: 29_887_000 picoseconds. + Weight::from_parts(31_172_595, 4764) + // Standard Error: 2_859 + .saturating_add(Weight::from_parts(124_029, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn relock_unlocking() -> Weight { // Proof Size summary in bytes: // Measured: `200` - // Estimated: `0` - // Minimum execution time: 35_389_000 picoseconds. - Weight::from_parts(35_953_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 27_384_000 picoseconds. + Weight::from_parts(27_620_000, 4764) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StakerInfo` (r:1 w:1) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::ContractStake` (r:1 w:1) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn stake() -> Weight { // Proof Size summary in bytes: // Measured: `274` - // Estimated: `0` - // Minimum execution time: 53_218_000 picoseconds. - Weight::from_parts(53_745_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 40_988_000 picoseconds. + Weight::from_parts(41_562_000, 4764) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StakerInfo` (r:1 w:1) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::ContractStake` (r:1 w:1) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn unstake() -> Weight { // Proof Size summary in bytes: // Measured: `459` - // Estimated: `0` - // Minimum execution time: 58_207_000 picoseconds. - Weight::from_parts(58_707_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 45_212_000 picoseconds. + Weight::from_parts(45_611_000, 4764) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:0) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::PeriodEnd` (r:1 w:0) + /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 16]`. fn claim_staker_rewards_past_period(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `541` - // Estimated: `0` - // Minimum execution time: 56_801_000 picoseconds. - Weight::from_parts(56_278_554, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 5_945 - .saturating_add(Weight::from_parts(1_930_726, 0).saturating_mul(x.into())) + // Estimated: `4764` + // Minimum execution time: 50_966_000 picoseconds. + Weight::from_parts(50_088_222, 4764) + // Standard Error: 4_812 + .saturating_add(Weight::from_parts(1_932_998, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:0) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 16]`. fn claim_staker_rewards_ongoing_period(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `519` - // Estimated: `0` - // Minimum execution time: 53_936_000 picoseconds. - Weight::from_parts(53_443_943, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 6_179 - .saturating_add(Weight::from_parts(1_921_353, 0).saturating_mul(x.into())) + // Estimated: `4764` + // Minimum execution time: 48_396_000 picoseconds. + Weight::from_parts(47_718_494, 4764) + // Standard Error: 3_774 + .saturating_add(Weight::from_parts(1_922_497, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } + /// Storage: `DappStaking::StakerInfo` (r:1 w:1) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::PeriodEnd` (r:1 w:0) + /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) fn claim_bonus_reward() -> Weight { // Proof Size summary in bytes: // Measured: `275` - // Estimated: `0` - // Minimum execution time: 44_870_000 picoseconds. - Weight::from_parts(45_171_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `3775` + // Minimum execution time: 37_169_000 picoseconds. + Weight::from_parts(37_719_000, 3775) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::DAppTiers` (r:1 w:1) + /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn claim_dapp_reward() -> Weight { // Proof Size summary in bytes: - // Measured: `668` - // Estimated: `0` - // Minimum execution time: 30_168_000 picoseconds. - Weight::from_parts(30_785_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Measured: `2672` + // Estimated: `5113` + // Minimum execution time: 54_124_000 picoseconds. + Weight::from_parts(54_932_000, 5113) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StakerInfo` (r:1 w:1) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn unstake_from_unregistered() -> Weight { // Proof Size summary in bytes: // Measured: `322` - // Estimated: `0` - // Minimum execution time: 48_421_000 picoseconds. - Weight::from_parts(49_069_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 37_145_000 picoseconds. + Weight::from_parts(37_697_000, 4764) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } + /// Storage: `DappStaking::StakerInfo` (r:17 w:16) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 16]`. fn cleanup_expired_entries(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `257 + x * (73 Β±0)` - // Estimated: `0` - // Minimum execution time: 46_554_000 picoseconds. - Weight::from_parts(43_518_695, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 13_148 - .saturating_add(Weight::from_parts(6_189_134, 0).saturating_mul(x.into())) + // Estimated: `4764 + x * (2653 Β±0)` + // Minimum execution time: 37_160_000 picoseconds. + Weight::from_parts(34_175_483, 4764) + // Standard Error: 8_747 + .saturating_add(Weight::from_parts(4_882_773, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(x.into()))) + .saturating_add(Weight::from_parts(0, 2653).saturating_mul(x.into())) } + /// Storage: `DappStaking::Safeguard` (r:1 w:0) + /// Proof: `DappStaking::Safeguard` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) fn force() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `0` - // Minimum execution time: 11_564_000 picoseconds. - Weight::from_parts(11_817_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `1486` + // Minimum execution time: 8_714_000 picoseconds. + Weight::from_parts(8_924_000, 1486) + .saturating_add(T::DbWeight::get().reads(1_u64)) } + /// Storage: `DappStaking::IntegratedDApps` (r:2 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StakerInfo` (r:2 w:2) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::ContractStake` (r:2 w:2) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn move_stake_from_registered_source() -> Weight { // Proof Size summary in bytes: // Measured: `553` - // Estimated: `0` - // Minimum execution time: 90_873_000 picoseconds. - Weight::from_parts(92_158_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `6296` + // Minimum execution time: 71_782_000 picoseconds. + Weight::from_parts(72_398_000, 6296) + .saturating_add(T::DbWeight::get().reads(10_u64)) + .saturating_add(T::DbWeight::get().writes(7_u64)) } + /// Storage: `DappStaking::IntegratedDApps` (r:2 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StakerInfo` (r:2 w:2) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::ContractStake` (r:1 w:1) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) fn move_stake_unregistered_source() -> Weight { // Proof Size summary in bytes: // Measured: `419` - // Estimated: `0` - // Minimum execution time: 82_204_000 picoseconds. - Weight::from_parts(82_858_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `6296` + // Minimum execution time: 63_766_000 picoseconds. + Weight::from_parts(64_076_000, 6296) + .saturating_add(T::DbWeight::get().reads(9_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) } + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:1) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) + /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(87), added: 582, mode: `MaxEncodedLen`) + /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) + /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::TierConfig` (r:1 w:1) + /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) fn on_initialize_voting_to_build_and_earn() -> Weight { // Proof Size summary in bytes: - // Measured: `225` - // Estimated: `0` - // Minimum execution time: 25_881_000 picoseconds. - Weight::from_parts(26_282_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Measured: `212` + // Estimated: `4254` + // Minimum execution time: 26_591_000 picoseconds. + Weight::from_parts(27_310_000, 4254) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::PeriodEnd` (r:1 w:2) + /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::HistoryCleanupMarker` (r:1 w:1) + /// Proof: `DappStaking::HistoryCleanupMarker` (`max_values`: Some(1), `max_size`: Some(12), added: 507, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:1) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) + /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(87), added: 582, mode: `MaxEncodedLen`) + /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) + /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::TierConfig` (r:1 w:1) + /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::DAppTiers` (r:0 w:1) + /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn on_initialize_build_and_earn_to_voting() -> Weight { // Proof Size summary in bytes: - // Measured: `791` - // Estimated: `0` - // Minimum execution time: 48_019_000 picoseconds. - Weight::from_parts(48_471_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Measured: `719` + // Estimated: `4254` + // Minimum execution time: 42_054_000 picoseconds. + Weight::from_parts(43_015_000, 4254) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(7_u64)) } + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:1) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) + /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(87), added: 582, mode: `MaxEncodedLen`) + /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) + /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::TierConfig` (r:1 w:1) + /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::DAppTiers` (r:0 w:1) + /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn on_initialize_build_and_earn_to_build_and_earn() -> Weight { // Proof Size summary in bytes: - // Measured: `277` + // Measured: `264` + // Estimated: `4254` + // Minimum execution time: 29_233_000 picoseconds. + Weight::from_parts(30_149_000, 4254) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: `DappStaking::ContractStake` (r:101 w:0) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::TierConfig` (r:1 w:0) + /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) + /// The range of component `x` is `[0, 100]`. + fn dapp_tier_assignment(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `98 + x * (32 Β±0)` + // Estimated: `3061 + x * (2071 Β±0)` + // Minimum execution time: 8_483_000 picoseconds. + Weight::from_parts(10_922_590, 3061) + // Standard Error: 2_388 + .saturating_add(Weight::from_parts(2_420_114, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(Weight::from_parts(0, 2071).saturating_mul(x.into())) + } + /// Storage: `DappStaking::HistoryCleanupMarker` (r:1 w:1) + /// Proof: `DappStaking::HistoryCleanupMarker` (`max_values`: Some(1), `max_size`: Some(12), added: 507, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:1) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::DAppTiers` (r:0 w:1) + /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) + fn on_idle_cleanup() -> Weight { + // Proof Size summary in bytes: + // Measured: `293` + // Estimated: `4254` + // Minimum execution time: 8_164_000 picoseconds. + Weight::from_parts(8_352_000, 4254) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: `DappStaking::StaticTierParams` (r:0 w:1) + /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(87), added: 582, mode: `MaxEncodedLen`) + fn set_static_tier_params() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` // Estimated: `0` - // Minimum execution time: 29_781_000 picoseconds. - Weight::from_parts(30_356_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Minimum execution time: 7_279_000 picoseconds. + Weight::from_parts(7_452_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)) } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + fn maintenance_mode() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 6_160_000 picoseconds. + Weight::from_parts(6_345_000, 0) + } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CounterForIntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::CounterForIntegratedDApps` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::NextDAppId` (r:1 w:1) + /// Proof: `DappStaking::NextDAppId` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) + fn register() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `3086` + // Minimum execution time: 12_235_000 picoseconds. + Weight::from_parts(12_512_000, 3086) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + fn set_dapp_reward_beneficiary() -> Weight { + // Proof Size summary in bytes: + // Measured: `97` + // Estimated: `3086` + // Minimum execution time: 10_517_000 picoseconds. + Weight::from_parts(10_793_000, 3086) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + fn set_dapp_owner() -> Weight { + // Proof Size summary in bytes: + // Measured: `97` + // Estimated: `3086` + // Minimum execution time: 10_363_000 picoseconds. + Weight::from_parts(10_656_000, 3086) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CounterForIntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::CounterForIntegratedDApps` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::ContractStake` (r:0 w:1) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) + fn unregister() -> Weight { + // Proof Size summary in bytes: + // Measured: `97` + // Estimated: `3086` + // Minimum execution time: 14_595_000 picoseconds. + Weight::from_parts(14_935_000, 3086) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `CollatorSelection::Candidates` (r:1 w:0) + /// Proof: `CollatorSelection::Candidates` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + fn lock_new_account() -> Weight { + // Proof Size summary in bytes: + // Measured: `138` + // Estimated: `4764` + // Minimum execution time: 31_874_000 picoseconds. + Weight::from_parts(32_108_000, 4764) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + fn lock_existing_account() -> Weight { + // Proof Size summary in bytes: + // Measured: `158` + // Estimated: `4764` + // Minimum execution time: 32_204_000 picoseconds. + Weight::from_parts(32_658_000, 4764) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + fn unlock() -> Weight { + // Proof Size summary in bytes: + // Measured: `158` + // Estimated: `4764` + // Minimum execution time: 28_967_000 picoseconds. + Weight::from_parts(29_523_000, 4764) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) /// The range of component `x` is `[0, 16]`. + fn claim_unlocked(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `190` + // Estimated: `4764` + // Minimum execution time: 29_887_000 picoseconds. + Weight::from_parts(31_172_595, 4764) + // Standard Error: 2_859 + .saturating_add(Weight::from_parts(124_029, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + fn relock_unlocking() -> Weight { + // Proof Size summary in bytes: + // Measured: `200` + // Estimated: `4764` + // Minimum execution time: 27_384_000 picoseconds. + Weight::from_parts(27_620_000, 4764) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StakerInfo` (r:1 w:1) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::ContractStake` (r:1 w:1) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + fn stake() -> Weight { + // Proof Size summary in bytes: + // Measured: `274` + // Estimated: `4764` + // Minimum execution time: 40_988_000 picoseconds. + Weight::from_parts(41_562_000, 4764) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) + } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StakerInfo` (r:1 w:1) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::ContractStake` (r:1 w:1) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + fn unstake() -> Weight { + // Proof Size summary in bytes: + // Measured: `459` + // Estimated: `4764` + // Minimum execution time: 45_212_000 picoseconds. + Weight::from_parts(45_611_000, 4764) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) + } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:0) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::PeriodEnd` (r:1 w:0) + /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 16]`. + fn claim_staker_rewards_past_period(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `541` + // Estimated: `4764` + // Minimum execution time: 50_966_000 picoseconds. + Weight::from_parts(50_088_222, 4764) + // Standard Error: 4_812 + .saturating_add(Weight::from_parts(1_932_998, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:0) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 16]`. + fn claim_staker_rewards_ongoing_period(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `519` + // Estimated: `4764` + // Minimum execution time: 48_396_000 picoseconds. + Weight::from_parts(47_718_494, 4764) + // Standard Error: 3_774 + .saturating_add(Weight::from_parts(1_922_497, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: `DappStaking::StakerInfo` (r:1 w:1) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::PeriodEnd` (r:1 w:0) + /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + fn claim_bonus_reward() -> Weight { + // Proof Size summary in bytes: + // Measured: `275` + // Estimated: `3775` + // Minimum execution time: 37_169_000 picoseconds. + Weight::from_parts(37_719_000, 3775) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::DAppTiers` (r:1 w:1) + /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) + fn claim_dapp_reward() -> Weight { + // Proof Size summary in bytes: + // Measured: `2672` + // Estimated: `5113` + // Minimum execution time: 54_124_000 picoseconds. + Weight::from_parts(54_932_000, 5113) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StakerInfo` (r:1 w:1) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + fn unstake_from_unregistered() -> Weight { + // Proof Size summary in bytes: + // Measured: `322` + // Estimated: `4764` + // Minimum execution time: 37_145_000 picoseconds. + Weight::from_parts(37_697_000, 4764) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: `DappStaking::StakerInfo` (r:17 w:16) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 16]`. + fn cleanup_expired_entries(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `257 + x * (73 Β±0)` + // Estimated: `4764 + x * (2653 Β±0)` + // Minimum execution time: 37_160_000 picoseconds. + Weight::from_parts(34_175_483, 4764) + // Standard Error: 8_747 + .saturating_add(Weight::from_parts(4_882_773, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(x.into()))) + .saturating_add(Weight::from_parts(0, 2653).saturating_mul(x.into())) + } + /// Storage: `DappStaking::Safeguard` (r:1 w:0) + /// Proof: `DappStaking::Safeguard` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + fn force() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `1486` + // Minimum execution time: 8_714_000 picoseconds. + Weight::from_parts(8_924_000, 1486) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + } + /// Storage: `DappStaking::IntegratedDApps` (r:2 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StakerInfo` (r:2 w:2) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::ContractStake` (r:2 w:2) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + fn move_stake_from_registered_source() -> Weight { + // Proof Size summary in bytes: + // Measured: `553` + // Estimated: `6296` + // Minimum execution time: 71_782_000 picoseconds. + Weight::from_parts(72_398_000, 6296) + .saturating_add(RocksDbWeight::get().reads(10_u64)) + .saturating_add(RocksDbWeight::get().writes(7_u64)) + } + /// Storage: `DappStaking::IntegratedDApps` (r:2 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StakerInfo` (r:2 w:2) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::ContractStake` (r:1 w:1) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) + fn move_stake_unregistered_source() -> Weight { + // Proof Size summary in bytes: + // Measured: `419` + // Estimated: `6296` + // Minimum execution time: 63_766_000 picoseconds. + Weight::from_parts(64_076_000, 6296) + .saturating_add(RocksDbWeight::get().reads(9_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) + } + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:1) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) + /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(87), added: 582, mode: `MaxEncodedLen`) + /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) + /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::TierConfig` (r:1 w:1) + /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) + fn on_initialize_voting_to_build_and_earn() -> Weight { + // Proof Size summary in bytes: + // Measured: `212` + // Estimated: `4254` + // Minimum execution time: 26_591_000 picoseconds. + Weight::from_parts(27_310_000, 4254) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::PeriodEnd` (r:1 w:2) + /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::HistoryCleanupMarker` (r:1 w:1) + /// Proof: `DappStaking::HistoryCleanupMarker` (`max_values`: Some(1), `max_size`: Some(12), added: 507, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:1) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) + /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(87), added: 582, mode: `MaxEncodedLen`) + /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) + /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::TierConfig` (r:1 w:1) + /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::DAppTiers` (r:0 w:1) + /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) + fn on_initialize_build_and_earn_to_voting() -> Weight { + // Proof Size summary in bytes: + // Measured: `719` + // Estimated: `4254` + // Minimum execution time: 42_054_000 picoseconds. + Weight::from_parts(43_015_000, 4254) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(7_u64)) + } + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:1) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) + /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(87), added: 582, mode: `MaxEncodedLen`) + /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) + /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::TierConfig` (r:1 w:1) + /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::DAppTiers` (r:0 w:1) + /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) + fn on_initialize_build_and_earn_to_build_and_earn() -> Weight { + // Proof Size summary in bytes: + // Measured: `264` + // Estimated: `4254` + // Minimum execution time: 29_233_000 picoseconds. + Weight::from_parts(30_149_000, 4254) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: `DappStaking::ContractStake` (r:101 w:0) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::TierConfig` (r:1 w:0) + /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) + /// The range of component `x` is `[0, 100]`. fn dapp_tier_assignment(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `218 + x * (33 Β±0)` - // Estimated: `0` - // Minimum execution time: 11_647_000 picoseconds. - Weight::from_parts(15_566_275, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 15_580 - .saturating_add(Weight::from_parts(3_037_978, 0).saturating_mul(x.into())) + // Measured: `98 + x * (32 Β±0)` + // Estimated: `3061 + x * (2071 Β±0)` + // Minimum execution time: 8_483_000 picoseconds. + Weight::from_parts(10_922_590, 3061) + // Standard Error: 2_388 + .saturating_add(Weight::from_parts(2_420_114, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(Weight::from_parts(0, 2071).saturating_mul(x.into())) } + /// Storage: `DappStaking::HistoryCleanupMarker` (r:1 w:1) + /// Proof: `DappStaking::HistoryCleanupMarker` (`max_values`: Some(1), `max_size`: Some(12), added: 507, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:1) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::DAppTiers` (r:0 w:1) + /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn on_idle_cleanup() -> Weight { // Proof Size summary in bytes: // Measured: `293` - // Estimated: `0` - // Minimum execution time: 9_856_000 picoseconds. - Weight::from_parts(10_123_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4254` + // Minimum execution time: 8_164_000 picoseconds. + Weight::from_parts(8_352_000, 4254) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } + /// Storage: `DappStaking::StaticTierParams` (r:0 w:1) + /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(87), added: 582, mode: `MaxEncodedLen`) fn set_static_tier_params() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 11_255_000 picoseconds. - Weight::from_parts(11_552_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Minimum execution time: 7_279_000 picoseconds. + Weight::from_parts(7_452_000, 0) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } } From d6b299aa56f1a55f8f08e52f05935b533c3901f4 Mon Sep 17 00:00:00 2001 From: Igor Papandinas <26460174+ipapandinas@users.noreply.github.com> Date: Thu, 5 Feb 2026 20:43:03 +0400 Subject: [PATCH 09/16] simplification --- pallets/dapp-staking/src/benchmarking/mod.rs | 16 +- .../dapp-staking/src/benchmarking/utils.rs | 14 +- pallets/dapp-staking/src/lib.rs | 275 ++++++----- pallets/dapp-staking/src/migration.rs | 460 ++++++++---------- pallets/dapp-staking/src/test/mock.rs | 27 +- pallets/dapp-staking/src/test/tests.rs | 252 +++++----- pallets/dapp-staking/src/test/tests_types.rs | 290 ++--------- pallets/dapp-staking/src/types.rs | 52 +- precompiles/dapp-staking/src/test/mock.rs | 16 +- primitives/src/dapp_staking.rs | 127 ++--- runtime/astar/src/genesis_config.rs | 17 +- runtime/astar/src/lib.rs | 68 +-- runtime/shibuya/src/genesis_config.rs | 17 +- runtime/shibuya/src/lib.rs | 65 +-- runtime/shiden/src/genesis_config.rs | 17 +- runtime/shiden/src/lib.rs | 65 +-- 16 files changed, 609 insertions(+), 1169 deletions(-) diff --git a/pallets/dapp-staking/src/benchmarking/mod.rs b/pallets/dapp-staking/src/benchmarking/mod.rs index 841aca2205..f7b3aee839 100644 --- a/pallets/dapp-staking/src/benchmarking/mod.rs +++ b/pallets/dapp-staking/src/benchmarking/mod.rs @@ -1145,25 +1145,12 @@ mod benchmarks { }); EraRewards::::insert(&cleanup_marker.era_reward_index, reward_span); - let rank_points: BoundedVec>, T::NumberOfTiers> = (1 - ..=T::NumberOfTiers::get()) - .map(|slots| { - let inner: BoundedVec> = (1..=slots as u8) - .collect::>() - .try_into() - .expect("Using incremental points; QED."); - inner - }) - .collect::>() - .try_into() - .expect("Using `NumberOfTiers` as length; QED."); - // Prepare completely filled up tier rewards and insert it into storage. DAppTiers::::insert( &cleanup_marker.dapp_tiers_index, DAppTierRewardsFor:: { dapps: (0..T::MaxNumberOfContracts::get()) - .map(|dapp_id| (dapp_id as DAppId, RankedTier::new_saturated(0, 0, 10))) + .map(|dapp_id| (dapp_id as DAppId, RankedTier::new_saturated(0, 0))) .collect::>() .try_into() .expect("Using `MaxNumberOfContracts` as length; QED."), @@ -1174,7 +1161,6 @@ mod benchmarks { rank_rewards: vec![0; T::NumberOfTiers::get() as usize] .try_into() .expect("Using `NumberOfTiers` as length; QED."), - rank_points, }, ); diff --git a/pallets/dapp-staking/src/benchmarking/utils.rs b/pallets/dapp-staking/src/benchmarking/utils.rs index 5b8c3fb25e..d4213260da 100644 --- a/pallets/dapp-staking/src/benchmarking/utils.rs +++ b/pallets/dapp-staking/src/benchmarking/utils.rs @@ -21,6 +21,7 @@ use super::{Pallet as DappStaking, *}; use astar_primitives::{dapp_staking::FIXED_TIER_SLOTS_ARGS, Balance}; use frame_system::Pallet as System; +use sp_arithmetic::Permill; /// Run to the specified block number. /// Function assumes first block has been initialized. @@ -181,10 +182,10 @@ pub(super) fn init_tier_settings() { required_percentage: Perbill::from_parts(23_200_000), // 2.32% }, TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(11_600_000), // 1.16% + required_percentage: Perbill::from_parts(9_300_000), // 0.93% }, TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(5_800_000), // 0.58% + required_percentage: Perbill::from_parts(3_500_000), // 0.35% }, // Tier 3: unreachable dummy TierThreshold::FixedPercentage { @@ -193,14 +194,7 @@ pub(super) fn init_tier_settings() { ]) .unwrap(), slot_number_args: FIXED_TIER_SLOTS_ARGS, - rank_points: BoundedVec::try_from(vec![ - BoundedVec::try_from(vec![]).unwrap(), - BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6]).unwrap(), - BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10]).unwrap(), - BoundedVec::try_from(vec![]).unwrap(), - ]) - .unwrap(), - base_reward_portion: Permill::from_percent(10), + tier_rank_multipliers: BoundedVec::try_from(vec![0, 24_000, 46_700, 0]).unwrap(), }; let total_issuance = 1000 * MIN_TIER_THRESHOLD; diff --git a/pallets/dapp-staking/src/lib.rs b/pallets/dapp-staking/src/lib.rs index 10e74d7450..4f881eb123 100644 --- a/pallets/dapp-staking/src/lib.rs +++ b/pallets/dapp-staking/src/lib.rs @@ -58,7 +58,7 @@ use astar_primitives::{ dapp_staking::{ AccountCheck, CycleConfiguration, DAppId, EraNumber, Observer as DAppStakingObserver, PeriodNumber, Rank, RankedTier, SmartContractHandle, StakingRewardHandler, TierId, - TierSlots as TierSlotFunc, MAX_ENCODED_RANK, STANDARD_TIER_SLOTS_ARGS, + TierSlots as TierSlotFunc, FIXED_TIER_SLOTS_ARGS, }, oracle::PriceProvider, Balance, BlockNumber, @@ -538,39 +538,50 @@ pub mod pallet { pub slot_number_args: (u64, u64), pub slots_per_tier: Vec, pub safeguard: Option, - pub rank_points: Vec>, - pub base_reward_portion: Permill, + pub tier_rank_multipliers: Vec, #[serde(skip)] pub _config: PhantomData, } impl Default for GenesisConfig { fn default() -> Self { - use sp_std::vec; - let num_tiers = T::NumberOfTiers::get(); let slots_per_tier = vec![0u16, 6, 10, 0]; - let rank_points: Vec> = slots_per_tier + let tier_rank_multipliers: Vec = slots_per_tier .iter() - .map(|&slots| { - let capped = slots.min(MAX_ENCODED_RANK as u16); - (1..=capped as u8).collect() - }) + .map(|&slots| if slots == 0 { 10_000 } else { 20_000 }) .collect(); Self { - reward_portion: vec![Permill::from_percent(100 / num_tiers); num_tiers as usize], - slot_distribution: vec![Permill::from_percent(100 / num_tiers); num_tiers as usize], - tier_thresholds: (0..num_tiers) - .rev() - .map(|i| TierThreshold::FixedPercentage { - required_percentage: Perbill::from_percent(i), - }) - .collect(), - slot_number_args: STANDARD_TIER_SLOTS_ARGS, + reward_portion: vec![ + Permill::zero(), // Tier 0: dummy + Permill::from_percent(70), // Tier 1: 70% + Permill::from_percent(30), // Tier 2: 30% + Permill::zero(), // Tier 3: dummy + ], + slot_distribution: vec![ + Permill::zero(), + Permill::from_parts(375_000), // 37.5% + Permill::from_parts(625_000), // 62.5% + Permill::zero(), + ], + tier_thresholds: vec![ + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_percent(3), + }, + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_percent(2), + }, + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_percent(1), + }, + TierThreshold::FixedPercentage { + required_percentage: Perbill::zero(), + }, + ], + slot_number_args: FIXED_TIER_SLOTS_ARGS, slots_per_tier, safeguard: None, - rank_points, - base_reward_portion: Permill::from_percent(50), + tier_rank_multipliers, _config: Default::default(), } } @@ -579,12 +590,6 @@ pub mod pallet { #[pallet::genesis_build] impl BuildGenesisConfig for GenesisConfig { fn build(&self) { - let rank_points: Vec>> = self - .rank_points - .iter() - .map(|inner| BoundedVec::try_from(inner.clone()).expect("Too many rank points")) - .collect(); - // Prepare tier parameters & verify their correctness let tier_params = TierParameters:: { reward_portion: BoundedVec::::try_from( @@ -600,8 +605,10 @@ pub mod pallet { ) .expect("Invalid number of tier thresholds provided."), slot_number_args: self.slot_number_args, - rank_points: BoundedVec::try_from(rank_points).expect("Too many tiers"), - base_reward_portion: self.base_reward_portion, + tier_rank_multipliers: BoundedVec::::try_from( + self.tier_rank_multipliers.clone(), + ) + .expect("Invalid number of tier points"), }; assert!( tier_params.is_valid(), @@ -1863,43 +1870,30 @@ pub mod pallet { /// This information is used to calculate 'score' per dApp, which is used to determine the tier. /// /// 2. Sort the entries by the score, in descending order - the top score dApp comes first. + /// Ties are broken by dApp ID (ascending). /// - /// 3. Calculate tier allocations from the total dApp reward pool using `reward_portion`. + /// 3. Assign dApps to tiers based on stake thresholds, calculating ratio-based ranks within each tier. /// - /// 4. Calculate base rewards per tier: - /// `base_reward = base_reward_portion * tier_allocation / slots_per_tier` + /// 4. Calculate reward components per tier using the **rank multiplier model**: /// - /// 5. Calculate rank rewards per tier: - /// `rank_reward_per_point = (tier_allocation - base_pool) / sum_of_all_rank_points` - /// Where `sum_of_all_rank_points` is the sum of all configured rank points for that tier. - /// - /// 6. Assign dApps to tiers: /// ```text - //// for each tier: - /// for each unassigned dApp: - /// if tier has capacity && dApp satisfies the tier threshold: - /// add dapp to the tier - /// else: - /// exit loop since no more dApps will satisfy the threshold since they are sorted by score - /// ``` - /// (Sort the entries by dApp ID, in ascending order. This is so we can efficiently search for them using binary search.) - /// + /// Step 1: Calculate weights + /// increment = (multiplier - 100%) Γ· MAX_RANK + /// dApp_weight = 100% + rank Γ— increment /// - /// 7. Rank calculation within tier: - /// - `rank = 0` for lowest stake in tier, up to `max_rank - 1` for highest - /// - Rank maps to `rank_points[tier][rank]` for reward calculation + /// Step 2: Find reward rate (with overflow cap) + /// target_weight = max_slots Γ— avg_weight (calibrated for avg rank = 5) + /// actual_weight = filled_slots Γ— 100% + ranks_sum Γ— increment + /// reward_per_% = tier_allocation Γ· max(actual_weight, target_weight) /// - /// ### Reward Formula - /// - /// For each dApp: - /// `total_reward = base_reward + (rank_points[tier][rank] * rank_reward_per_point)` - /// - /// ### Notes + /// Step 3: Pre-compute claim values + /// tier_reward = 100% Γ— reward_per_% + /// rank_reward = increment Γ— reward_per_% + /// ``` + /// (Sort the entries by dApp ID, in ascending order. This is so we can efficiently search for them using binary search.) /// - /// - Empty tier slots result in unminted rewards (by design) - /// - `rank_points` array is ascending: index 0 = lowest stake position in tier - /// - The returned object contains information about each dApp that made it into a tier. - /// Alongside tier assignment info, number of read DB contract stake entries is returned. + /// The returned object contains information about each dApp that made it into a tier. + /// Alongside tier assignment info, number of read DB contract stake entries is returned. pub(crate) fn get_dapp_tier_assignment_and_rewards( era: EraNumber, period: PeriodNumber, @@ -1923,8 +1917,10 @@ pub mod pallet { } // 2. - // Sort by amount staked, in reverse - top dApp will end in the first place, 0th index. - dapp_stakes.sort_unstable_by(|(_, amount_1), (_, amount_2)| amount_2.cmp(amount_1)); + // Sort descending by stake, ascending by dApp ID for ties - top dApp will end in the first place, 0th index. + dapp_stakes.sort_unstable_by(|(id_a, amount_a), (id_b, amount_b)| { + amount_b.cmp(amount_a).then_with(|| id_a.cmp(id_b)) + }); let tier_config = TierConfig::::get(); let tier_params = StaticTierParams::::get(); @@ -1936,33 +1932,14 @@ pub mod pallet { // There is no guarantee this will persist in the future, so it's best for dApps to do their // best to avoid getting themselves into such situations. - // 3. Calculate tier allocations - let tier_allocations: Vec = tier_config - .reward_portion - .iter() - .map(|percent| *percent * dapp_reward_pool) - .collect(); - - // 4. Base rewards = base_reward_portion% of allocation / slots capacity - let base_portion = tier_params.base_reward_portion; - let base_rewards_per_tier: Vec = tier_allocations - .iter() - .zip(tier_config.slots_per_tier.iter()) - .map(|(allocation, capacity)| { - if capacity.is_zero() { - Zero::zero() - } else { - let base_pool = base_portion.mul_floor(*allocation); - base_pool.saturating_div((*capacity).into()) - } - }) - .collect(); - - // 5. + // 3. // Iterate over configured tier and potential dApps. // Each dApp will be assigned to the best possible tier if it satisfies the required condition, // and tier capacity hasn't been filled yet. let mut dapp_tiers = BTreeMap::new(); + let mut tier_rewards = Vec::with_capacity(tier_config.slots_per_tier.len()); + let mut rank_rewards = Vec::with_capacity(tier_config.slots_per_tier.len()); + let mut upper_bound = Balance::zero(); for (tier_id, (tier_capacity, lower_bound)) in tier_config @@ -1971,6 +1948,8 @@ pub mod pallet { .zip(tier_config.tier_thresholds.iter()) .enumerate() { + let mut tier_slots = BTreeMap::new(); + // Iterate over dApps until one of two conditions has been met: // 1. Tier has no more capacity // 2. dApp doesn't satisfy the tier threshold (since they're sorted, none of the following dApps will satisfy the condition either) @@ -1980,71 +1959,54 @@ pub mod pallet { .take_while(|(_, amount)| amount.ge(lower_bound)) .take(*tier_capacity as usize) { - let max_rank = tier_params - .rank_points - .get(tier_id) - .map(|v| v.len().saturating_sub(1) as u8) // ranks 0 to len-1, never exceed valid indices - .unwrap_or(0); - let rank = if T::RankingEnabled::get() { - RankedTier::find_rank(*lower_bound, upper_bound, *staked_amount, max_rank) + RankedTier::find_rank(*lower_bound, upper_bound, *staked_amount) } else { 0 }; - - let ranked_tier = RankedTier::new_saturated(tier_id as u8, rank, max_rank); - dapp_tiers.insert(*dapp_id, ranked_tier); + tier_slots.insert(*dapp_id, RankedTier::new_saturated(tier_id as u8, rank)); } + // 4. Compute tier rewards using rank multiplier + let filled_slots = tier_slots.len() as u32; + let ranks_sum: u32 = tier_slots.values().map(|rt| rt.rank() as u32).sum(); + + let multiplier_bips = tier_params + .tier_rank_multipliers + .get(tier_id) + .copied() + .unwrap_or(10_000); + + let tier_allocation = tier_config + .reward_portion + .get(tier_id) + .copied() + .unwrap_or(Permill::zero()) + * dapp_reward_pool; + + let (tier_reward, rank_reward) = Self::compute_tier_rewards( + tier_allocation, + *tier_capacity, + filled_slots, + ranks_sum, + multiplier_bips, + ); + + tier_rewards.push(tier_reward); + rank_rewards.push(rank_reward); + dapp_tiers.append(&mut tier_slots); upper_bound = *lower_bound; // current threshold becomes upper bound for next tier } - // 6. Calculate rank_rewards (reward per rank point for each tier) - // rank_rewards[tier] = (remainder portion of base% of tier allocation) / sum_of_all_rank_points_in_tier - let rank_rewards: Vec = tier_allocations - .iter() - .zip(tier_config.slots_per_tier.iter()) - .enumerate() - .map(|(tier_id, (allocation, slots))| { - // If tier has no slots, no rank rewards can be claimed - if slots.is_zero() { - return Zero::zero(); - } - - // Sum ALL configured rank_points for this tier - let total_points: u32 = tier_params - .rank_points - .get(tier_id) - .map(|points| points.iter().map(|&p| p as u32).sum()) - .unwrap_or(0); - - if total_points.is_zero() { - Zero::zero() - } else { - let base_pool = tier_params.base_reward_portion.mul_floor(*allocation); - let rank_pool = allocation.saturating_sub(base_pool); - // Note: slight reward underpayment may be expected due to integer math. - rank_pool.saturating_div(total_points.into()) - } - }) - .collect(); - - let rank_points_vec: Vec> = tier_params - .rank_points - .iter() - .map(|inner_bv| inner_bv.clone().into_inner()) - .collect(); - - // 7. + // 5. // Prepare and return tier & rewards info. // In case rewards creation fails, we just write the default value. This should never happen though. ( DAppTierRewards::::new( dapp_tiers, - base_rewards_per_tier, + tier_rewards, period, rank_rewards, - rank_points_vec, ) .unwrap_or_default(), counter, @@ -2514,6 +2476,53 @@ pub mod pallet { Ok(()) } + /// Compute deterministic tier rewards params (base-0 reward and per-rank-step reward) + /// using rank-multiplier in bips (10_000 = 100%) + pub(crate) fn compute_tier_rewards( + tier_allocation: Balance, + tier_capacity: u16, + filled_slots: u32, + ranks_sum: u32, + multiplier_bips: u32, + ) -> (Balance, Balance) { + const WEIGHT_UNIT: u128 = 10_000; // 100% in bips + let max_rank: u128 = RankedTier::MAX_RANK as u128; // 10 + let avg_rank: u128 = max_rank / 2; // 5 + + if tier_allocation.is_zero() || tier_capacity == 0 || filled_slots == 0 { + return (Balance::zero(), Balance::zero()); + } + + // weight(rank) = WEIGHT_UNIT + rank * inc_w, where: + // inc_w = (multiplier_bips - WEIGHT_UNIT) / MAX_RANK + let inc_w: u128 = (multiplier_bips as u128) + .saturating_sub(WEIGHT_UNIT) + .saturating_div(max_rank); + + // actual_weight = filled_slots * WEIGHT_UNIT + inc_w * ranks_sum + let actual_weight: u128 = (filled_slots as u128) + .saturating_mul(WEIGHT_UNIT) + .saturating_add((ranks_sum as u128).saturating_mul(inc_w)); + + // target_weight = tier_capacity * avg_weight, avg_weight = WEIGHT_UNIT + avg_rank * inc_w + let avg_weight: u128 = WEIGHT_UNIT.saturating_add(avg_rank.saturating_mul(inc_w)); + let target_weight: u128 = (tier_capacity as u128).saturating_mul(avg_weight); + + let denom: u128 = actual_weight.max(target_weight); + if denom == 0 { + return (Balance::zero(), Balance::zero()); + } + + let alloc: u128 = tier_allocation.into(); + let tier_reward0_u128 = alloc.saturating_mul(WEIGHT_UNIT) / denom; + let rank_reward_u128 = alloc.saturating_mul(inc_w) / denom; + + ( + tier_reward0_u128.saturated_into::(), + rank_reward_u128.saturated_into::(), + ) + } + /// Internal function to transition the dApp staking protocol maintenance mode. /// Ensure this method is **not exposed publicly** and is only used for legitimate maintenance mode transitions invoked by privileged or trusted logic, /// such as `T::ManagerOrigin` or a safe-mode enter/exit notification. diff --git a/pallets/dapp-staking/src/migration.rs b/pallets/dapp-staking/src/migration.rs index ffa1fcdf2f..351ca6c0b0 100644 --- a/pallets/dapp-staking/src/migration.rs +++ b/pallets/dapp-staking/src/migration.rs @@ -17,6 +17,7 @@ // along with Astar. If not, see . use super::*; +use astar_primitives::dapp_staking::FIXED_TIER_SLOTS_ARGS; use core::marker::PhantomData; use frame_support::traits::UncheckedOnRuntimeUpgrade; @@ -34,10 +35,10 @@ pub mod versioned_migrations { /// Migration V10 to V11 wrapped in a [`frame_support::migrations::VersionedMigration`], ensuring /// the migration is only performed when on-chain version is 10. - pub type V10ToV11 = frame_support::migrations::VersionedMigration< + pub type V10ToV11 = frame_support::migrations::VersionedMigration< 10, 11, - v11::VersionMigrateV10ToV11, + v11::VersionMigrateV10ToV11, Pallet, ::DbWeight, >; @@ -49,52 +50,79 @@ pub trait TierParamsV11Config { fn slot_distribution() -> [Permill; 4]; fn tier_thresholds() -> [TierThreshold; 4]; fn slot_number_args() -> (u64, u64); - fn rank_points() -> [Vec; 4]; - fn base_reward_portion() -> Permill; + fn tier_rank_multipliers() -> [u32; 4]; +} + +pub struct DefaultTierParamsV11; +impl TierParamsV11Config for DefaultTierParamsV11 { + fn reward_portion() -> [Permill; 4] { + [ + Permill::from_percent(0), + Permill::from_percent(70), + Permill::from_percent(30), + Permill::from_percent(0), + ] + } + + fn slot_distribution() -> [Permill; 4] { + [ + Permill::from_percent(0), + Permill::from_parts(375_000), // 37.5% + Permill::from_parts(625_000), // 62.5% + Permill::from_percent(0), + ] + } + + fn tier_thresholds() -> [TierThreshold; 4] { + [ + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(23_200_000), // 2.32% + }, + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(9_300_000), // 0.93% + }, + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(3_500_000), // 0.35% + }, + // Tier 3: unreachable dummy + TierThreshold::FixedPercentage { + required_percentage: Perbill::from_parts(0), // 0% + }, + ] + } + + fn slot_number_args() -> (u64, u64) { + FIXED_TIER_SLOTS_ARGS + } + + fn tier_rank_multipliers() -> [u32; 4] { + [0, 24_000, 46_700, 0] + } } mod v11 { use super::*; - use crate::migration::v10::DAppTierRewards as DAppTierRewardsV10; - pub struct VersionMigrateV10ToV11(PhantomData<(T, P)>); + pub struct VersionMigrateV10ToV11(PhantomData<(T, P, OldErasBnE)>); - impl UncheckedOnRuntimeUpgrade for VersionMigrateV10ToV11 { + impl> UncheckedOnRuntimeUpgrade for VersionMigrateV10ToV11 { fn on_runtime_upgrade() -> Weight { - let mut reads = 1u64; // HistoryCleanupMarker - let mut writes = 0u64; - - let cleanup_marker = HistoryCleanupMarker::::get(); - let oldest_valid_era = cleanup_marker.oldest_valid_era; + let old_eras_bne = OldErasBnE::get(); - log::info!( - target: LOG_TARGET, - "Migration v11: oldest_valid_era = {}, will skip expired entries", - oldest_valid_era - ); + let mut reads: u64 = 0; + let mut writes: u64 = 0; // 1. Migrate StaticTierParams - let reward_portion = P::reward_portion(); - let slot_distribution = P::slot_distribution(); - let tier_thresholds = P::tier_thresholds(); - let rank_points_config = P::rank_points(); - let new_params = TierParameters:: { - reward_portion: BoundedVec::try_from(reward_portion.to_vec()) + reward_portion: BoundedVec::try_from(P::reward_portion().to_vec()) .expect("4 tiers configured"), - slot_distribution: BoundedVec::try_from(slot_distribution.to_vec()) + slot_distribution: BoundedVec::try_from(P::slot_distribution().to_vec()) .expect("4 tiers configured"), - tier_thresholds: BoundedVec::try_from(tier_thresholds.to_vec()) + tier_thresholds: BoundedVec::try_from(P::tier_thresholds().to_vec()) .expect("4 tiers configured"), slot_number_args: P::slot_number_args(), - rank_points: BoundedVec::try_from( - rank_points_config - .into_iter() - .map(|points| BoundedVec::try_from(points).expect("rank points")) - .collect::>(), - ) - .expect("4 tiers"), - base_reward_portion: P::base_reward_portion(), + tier_rank_multipliers: BoundedVec::try_from(P::tier_rank_multipliers().to_vec()) + .expect("4 tiers configured"), }; if !new_params.is_valid() { @@ -102,293 +130,185 @@ mod v11 { target: LOG_TARGET, "New TierParameters validation failed. Enabling maintenance mode." ); + + // ActiveProtocolState::mutate => 1 read + 1 write ActiveProtocolState::::mutate(|state| { state.maintenance = true; }); - return T::DbWeight::get().reads_writes(reads, 1); + reads += 1; + writes += 1; + + return T::DbWeight::get().reads_writes(reads, writes); } + // StaticTierParams::put => 1 write StaticTierParams::::put(new_params); writes += 1; log::info!(target: LOG_TARGET, "StaticTierParams updated successfully"); - // 2. Migrate DAppTiers entries - only valid ones - let mut migrated_count = 0u32; - let mut deleted_count = 0u32; - let mut migration_failed = false; - - let all_eras: Vec = v10::DAppTiers::::iter_keys().collect(); - reads += all_eras.len() as u64; - - for era in all_eras { - // Delete expired entries - if era < oldest_valid_era { - v10::DAppTiers::::remove(era); - deleted_count += 1; - writes += 1; - continue; - } + // 2. Update ActiveProtocolState in a SINGLE mutate (avoid extra .get() read) + // ActiveProtocolState::mutate => 1 read + 1 write + ActiveProtocolState::::mutate(|state| { + if state.period_info.subperiod == Subperiod::Voting { + // Recalculate next_era_start block + let current_block: u32 = + frame_system::Pallet::::block_number().saturated_into(); + let new_voting_length: u32 = Pallet::::blocks_per_voting_period(); - reads += 1; - let maybe_old: Option< - DAppTierRewardsV10, - > = v10::DAppTiers::::get(era); - - match maybe_old { - Some(old) => { - let new = DAppTierRewards { - dapps: old.dapps, - rewards: old.rewards, - period: old.period, - rank_rewards: old.rank_rewards, - rank_points: BoundedVec::default(), // Empty = legacy formula - }; - DAppTiers::::insert(era, new); - migrated_count += 1; - writes += 1; - } - None => { - log::error!( - target: LOG_TARGET, - "Failed to decode DAppTiers for valid era {}", - era - ); - migration_failed = true; - break; - } - } - } + state.next_era_start = current_block.saturating_add(new_voting_length); - if migration_failed { - log::error!( - target: LOG_TARGET, - "DAppTiers migration failed. Enabling maintenance mode." - ); - ActiveProtocolState::::mutate(|state| { - state.maintenance = true; - }); - return T::DbWeight::get().reads_writes(reads, writes + 1); - } + log::info!(target: LOG_TARGET, "ActiveProtocolState updated: next_era_start"); + } else { + // Build&Earn: adjust remainder for next_subperiod_start_era + let new_eras_total: EraNumber = + T::CycleConfiguration::eras_per_build_and_earn_subperiod(); - // 3. Update cleanup marker - if deleted_count > 0 { - HistoryCleanupMarker::::mutate(|marker| { - marker.dapp_tiers_index = marker.dapp_tiers_index.max(oldest_valid_era); - }); - writes += 1; - } + // "only the remainder" logic + let current_era: EraNumber = state.era; + let old_end: EraNumber = state.period_info.next_subperiod_start_era; - log::info!( - target: LOG_TARGET, - "Migration v11 complete: migrated={}, deleted_expired={}", - migrated_count, - deleted_count - ); + let remaining_old: EraNumber = old_end.saturating_sub(current_era); + let elapsed: EraNumber = + old_eras_bne.saturating_sub(remaining_old); + + let remaining_new: EraNumber = new_eras_total.saturating_sub(elapsed); + + state.period_info.next_subperiod_start_era = + current_era.saturating_add(remaining_new); + + log::info!( + target: LOG_TARGET, + "ActiveProtocolState updated: next_subperiod_start_era (remainder-adjusted)" + ); + } + }); + reads += 1; + writes += 1; T::DbWeight::get().reads_writes(reads, writes) } #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, TryRuntimeError> { - let cleanup_marker = HistoryCleanupMarker::::get(); - let oldest_valid_era = cleanup_marker.oldest_valid_era; - - let valid_count = v10::DAppTiers::::iter_keys() - .filter(|era| *era >= oldest_valid_era) - .count() as u32; + let protocol_state = ActiveProtocolState::::get(); + let subperiod = protocol_state.period_info.subperiod; + let current_era = protocol_state.era; + let next_era_start = protocol_state.next_era_start; + let old_next_subperiod_era = protocol_state.period_info.next_subperiod_start_era; + let current_block: u32 = frame_system::Pallet::::block_number().saturated_into(); log::info!( target: LOG_TARGET, - "Pre-upgrade: {} valid DAppTiers entries (era >= {})", - valid_count, - oldest_valid_era + "Pre-upgrade: era={}, subperiod={:?}, next_era_start={}, next_subperiod_era={}, block={}", + current_era, + subperiod, + next_era_start, + old_next_subperiod_era, + current_block ); - // Verify all valid entries can be decoded - for era in v10::DAppTiers::::iter_keys() { - if era >= oldest_valid_era { - ensure!( - v10::DAppTiers::::get(era).is_some(), - "Failed to decode DAppTiers for era {}", - ); - } - } - - Ok((valid_count, oldest_valid_era).encode()) + // Verify current StaticTierParams can be read + let old_params = StaticTierParams::::get(); + ensure!(old_params.is_valid(), "Old tier params invalid"); + + Ok(( + subperiod, + current_era, + next_era_start, + old_next_subperiod_era, + current_block, + ) + .encode()) } #[cfg(feature = "try-runtime")] fn post_upgrade(data: Vec) -> Result<(), TryRuntimeError> { - let (expected_count, oldest_valid_era): (u32, EraNumber) = - Decode::decode(&mut &data[..]) - .map_err(|_| TryRuntimeError::Other("Failed to decode pre-upgrade data"))?; - + let (old_subperiod, old_era, old_next_era_start, old_next_subperiod_era, pre_block): ( + Subperiod, + EraNumber, + u32, + EraNumber, + u32, + ) = Decode::decode(&mut &data[..]) + .map_err(|_| TryRuntimeError::Other("Failed to decode pre-upgrade data"))?; + let old_eras_bne = OldErasBnE::get(); + + // Verify storage version ensure!( Pallet::::on_chain_storage_version() == StorageVersion::new(11), "Version should be 11" ); + // Verify new params are valid let new_params = StaticTierParams::::get(); ensure!(new_params.is_valid(), "New tier params invalid"); + ensure!( + new_params.tier_rank_multipliers.len() == 4, + "Should have 4 tier_rank_multipliers entries" + ); + + // Verify ActiveProtocolState update + let protocol_state = ActiveProtocolState::::get(); - let new_count = DAppTiers::::iter().count() as u32; - ensure!(new_count == expected_count, "DAppTiers count mismatch"); + if old_subperiod == Subperiod::Voting { + // expected_end = pre_block + new_voting_length + let new_voting_length: u32 = Pallet::::blocks_per_voting_period(); + let expected_end = pre_block.saturating_add(new_voting_length); - for (era, rewards) in DAppTiers::::iter() { - ensure!(era >= oldest_valid_era, "Found expired entry"); ensure!( - rewards.rank_points.is_empty(), - "Should have empty rank_points" + protocol_state.next_era_start == expected_end, + "next_era_start should be pre_block + new_voting_length" ); - for (dapp_id, _) in rewards.dapps.iter() { - // Verify try_claim still works (without mutating) - let mut test_rewards = rewards.clone(); - assert!( - test_rewards.try_claim(*dapp_id).is_ok(), - "Legacy claim broken" - ); - } - } + // Optional sanity: should have changed (unless it already matched) + ensure!( + protocol_state.next_era_start != old_next_era_start + || old_next_era_start == expected_end, + "next_era_start did not update as expected" + ); - ensure!( - !ActiveProtocolState::::get().maintenance, - "Maintenance mode should not be enabled" - ); + // We did NOT change next_subperiod_start_era in voting branch (in this migration) + ensure!( + protocol_state.period_info.next_subperiod_start_era == old_next_subperiod_era, + "next_subperiod_start_era should be unchanged in Voting branch" + ); - Ok(()) - } - } -} + log::info!(target: LOG_TARGET, "Post-upgrade: Voting branch OK"); + } else { + // Build&Earn branch: remainder-adjusted next_subperiod_start_era + let new_total: EraNumber = + T::CycleConfiguration::eras_per_build_and_earn_subperiod(); -mod v10 { - use super::*; - use frame_support::storage_alias; - - /// v10 DAppTierRewards (without rank_points) - #[derive(Encode, Decode, Clone)] - pub struct DAppTierRewards, NT: Get> { - pub dapps: BoundedBTreeMap, - pub rewards: BoundedVec, - #[codec(compact)] - pub period: PeriodNumber, - pub rank_rewards: BoundedVec, - } + let current_era: EraNumber = old_era; + let old_end: EraNumber = old_next_subperiod_era; - /// v10 storage alias for DAppTiers - #[storage_alias] - pub type DAppTiers = StorageMap< - Pallet, - Twox64Concat, - EraNumber, - DAppTierRewards<::MaxNumberOfContractsLegacy, ::NumberOfTiers>, - OptionQuery, - >; -} + let remaining_old: EraNumber = old_end.saturating_sub(current_era); + let elapsed: EraNumber = old_eras_bne.saturating_sub(remaining_old); + let remaining_new: EraNumber = new_total.saturating_sub(elapsed); -#[cfg(test)] -mod tests { - use super::*; - use crate::test::mock::{ExtBuilder, Test}; - use astar_primitives::dapp_staking::FIXED_TIER_SLOTS_ARGS; - - pub struct TestTierParams; - impl TierParamsV11Config for TestTierParams { - fn reward_portion() -> [Permill; 4] { - [ - Permill::from_percent(0), - Permill::from_percent(70), - Permill::from_percent(30), - Permill::from_percent(0), - ] - } + let expected_new_end: EraNumber = current_era.saturating_add(remaining_new); - fn slot_distribution() -> [Permill; 4] { - [ - Permill::from_percent(0), - Permill::from_parts(375_000), // 37.5% - Permill::from_parts(625_000), // 62.5% - Permill::from_percent(0), - ] - } + ensure!( + protocol_state.period_info.next_subperiod_start_era == expected_new_end, + "next_subperiod_start_era should be remainder-adjusted to the new schedule" + ); - fn tier_thresholds() -> [TierThreshold; 4] { - use crate::TierThreshold; - [ - TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(23_200_000), // 2.32% - }, - TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(11_600_000), // 1.16% - }, - TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(5_800_000), // 0.58% - }, - // Tier 3: unreachable dummy - TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(0), // 0% - }, - ] - } + // next_era_start was not modified by this branch in this migration + ensure!( + protocol_state.next_era_start == old_next_era_start, + "next_era_start should be unchanged in Build&Earn branch" + ); - fn slot_number_args() -> (u64, u64) { - FIXED_TIER_SLOTS_ARGS - } + log::info!(target: LOG_TARGET, "Post-upgrade: Build&Earn branch OK"); + } - fn rank_points() -> [Vec; 4] { - [ - vec![], // Tier 0: dummy - vec![10, 11, 12, 13, 14, 15], // Tier 1: 6 slots - vec![1, 3, 5, 7, 9, 11, 13, 15, 17, 19], // Tier 2: 10 slots - vec![], // Tier 3: dummy - ] - } + // Verify not in maintenance mode + ensure!( + !protocol_state.maintenance, + "Maintenance mode should not be enabled" + ); - fn base_reward_portion() -> Permill { - Permill::from_percent(10) + Ok(()) } } - - #[test] - fn migration_v10_to_v11_preserves_claimable_rewards() { - ExtBuilder::default() - .without_try_state() - .build_and_execute(|| { - // Setup: Create v10-style DAppTiers entry - let era = 5; - let period = 1; - let old_entry = v10::DAppTierRewards { - dapps: BoundedBTreeMap::try_from(BTreeMap::from([ - (0, RankedTier::new_saturated(1, 5, 10)), - (1, RankedTier::new_saturated(2, 3, 10)), - ])) - .unwrap(), - rewards: BoundedVec::try_from(vec![0, 100_000, 50_000, 0]).unwrap(), - period, - rank_rewards: BoundedVec::try_from(vec![0, 1_000, 500, 0]).unwrap(), - }; - - v10::DAppTiers::::insert(era, old_entry); - - // Set cleanup marker so this era is "valid" - HistoryCleanupMarker::::put(CleanupMarker { - oldest_valid_era: era, - ..Default::default() - }); - - let _weight = - v11::VersionMigrateV10ToV11::::on_runtime_upgrade(); - - let mut new_entry = DAppTiers::::get(era).expect("Entry should exist"); - assert!( - new_entry.rank_points.is_empty(), - "Migrated entries have empty rank_points" - ); - - let (reward, ranked_tier) = new_entry.try_claim(0).unwrap(); - assert_eq!(ranked_tier.rank(), 5); - // Legacy formula: base + rank * rank_reward_per_point - assert_eq!(reward, 100_000 + 5 * 1_000); - }); - } } diff --git a/pallets/dapp-staking/src/test/mock.rs b/pallets/dapp-staking/src/test/mock.rs index bdaae141df..f10428f2f6 100644 --- a/pallets/dapp-staking/src/test/mock.rs +++ b/pallets/dapp-staking/src/test/mock.rs @@ -238,15 +238,11 @@ impl pallet_dapp_staking::Config for Test { type BenchmarkHelper = BenchmarkHelper; } -pub struct ExtBuilder { - run_try_state: bool, -} +pub struct ExtBuilder {} impl Default for ExtBuilder { fn default() -> Self { - Self { - run_try_state: true, - } + Self {} } } @@ -346,14 +342,7 @@ impl ExtBuilder { ]) .unwrap(), slot_number_args: FIXED_TIER_SLOTS_ARGS, - rank_points: BoundedVec::try_from(vec![ - BoundedVec::try_from(vec![1u8]).unwrap(), - BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10]).unwrap(), - BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10]).unwrap(), - BoundedVec::try_from(vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10]).unwrap(), - ]) - .unwrap(), - base_reward_portion: Permill::from_percent(50), + tier_rank_multipliers: BoundedVec::try_from(vec![0, 24_000, 46_700, 0]).unwrap(), }; let total_issuance = ::Currency::total_issuance(); @@ -393,12 +382,9 @@ impl ExtBuilder { } pub fn build_and_execute(self, test: impl FnOnce() -> ()) { - let run_try_state = self.run_try_state; self.build().execute_with(|| { test(); - if run_try_state { - DappStaking::do_try_state().unwrap(); - } + DappStaking::do_try_state().unwrap(); }) } @@ -406,11 +392,6 @@ impl ExtBuilder { MAX_BONUS_SAFE_MOVES.with(|v| *v.borrow_mut() = value); self } - - pub fn without_try_state(mut self) -> Self { - self.run_try_state = false; - self - } } /// Run to the specified block number. diff --git a/pallets/dapp-staking/src/test/tests.rs b/pallets/dapp-staking/src/test/tests.rs index b85b12006d..a33808a968 100644 --- a/pallets/dapp-staking/src/test/tests.rs +++ b/pallets/dapp-staking/src/test/tests.rs @@ -2802,21 +2802,20 @@ fn get_dapp_tier_assignment_and_rewards_basic_example_works() { ExtBuilder::default().build_and_execute(|| { // Tier config is specially adapted for this test. TierConfig::::mutate(|config| { - config.slots_per_tier = BoundedVec::try_from(vec![2, 5, 13, 20]).unwrap(); + config.slots_per_tier = BoundedVec::try_from(vec![0, 6, 10, 0]).unwrap(); }); - let tier_params = StaticTierParams::::get(); - // Scenario: - // - 1st tier is filled up, with one dApp satisfying the threshold but not making it due to lack of tier capacity - // - 2nd tier has 2 dApps - 1 that could make it into the 1st tier and one that's supposed to be in the 2nd tier + // - 1st tier is empty, with 3 dApps satisfying the threshold but not making it due to lack of tier capacity + // - 2nd tier has 5 dApps - 3 that could make it into the 1st tier (expected to be rank 10) and 2 that are supposed to be in the 2nd tier // - 3rd tier has no dApps - // - 4th tier has 2 dApps + // - 4th tier has no dApps due to lack of tier capacity // - 1 dApp doesn't make it into any tier // Register smart contracts + let tier_params = StaticTierParams::::get(); let tier_config = TierConfig::::get(); - let number_of_smart_contracts = tier_config.slots_per_tier[0] + 1 + 1 + 0 + 2 + 1; + let number_of_smart_contracts = 0 + 5 + 0 + 2 + 1; let smart_contracts: Vec<_> = (1..=number_of_smart_contracts) .map(|x| { let smart_contract = MockSmartContract::Wasm(x.into()); @@ -2833,16 +2832,19 @@ fn get_dapp_tier_assignment_and_rewards_basic_example_works() { assert_stake(account, smart_contract, amount); } - // 1st tier is completely filled up, with 1 more dApp not making it inside - for x in 0..tier_config.slots_per_tier[0] as Balance { - lock_and_stake( - dapp_index, - &smart_contracts[dapp_index], - tier_config.tier_thresholds[0] + x + 1, - ); - dapp_index += 1; - } - // One that won't make it into the 1st tier. + // 2nd tier - 3 that won't make it into the 1st tier due to lack of tier capacity. + lock_and_stake( + dapp_index, + &smart_contracts[dapp_index], + tier_config.tier_thresholds[0] + 2, + ); + dapp_index += 1; + lock_and_stake( + dapp_index, + &smart_contracts[dapp_index], + tier_config.tier_thresholds[0] + 1, + ); + dapp_index += 1; lock_and_stake( dapp_index, &smart_contracts[dapp_index], @@ -2850,13 +2852,19 @@ fn get_dapp_tier_assignment_and_rewards_basic_example_works() { ); dapp_index += 1; - // 2nd tier - 1 dedicated dApp + // 2nd tier - 2 dedicated dApp lock_and_stake( dapp_index, &smart_contracts[dapp_index], tier_config.tier_thresholds[0] - 1, ); dapp_index += 1; + lock_and_stake( + dapp_index, + &smart_contracts[dapp_index], + tier_config.tier_thresholds[0] - 2, + ); + dapp_index += 1; // 3rd tier is empty // 4th tier has 2 dApps @@ -2878,19 +2886,16 @@ fn get_dapp_tier_assignment_and_rewards_basic_example_works() { // Finally, the actual test let protocol_state = ActiveProtocolState::::get(); - let dapp_reward_pool = 1_000_000; + let dapp_reward_pool: Balance = 1_000_000; let (tier_assignment, counter) = DappStaking::get_dapp_tier_assignment_and_rewards( protocol_state.era + 1, protocol_state.period_number(), dapp_reward_pool, ); - // Ranks rewards are 50% of the tier allocation - // Dapp rewards allocations for tiers are: 40%, 30%, 20%, 10% - // Points per tiers are: 1, 55, 55, 55 assert_eq!( tier_assignment.rank_rewards, - BoundedVec::>::try_from(vec![200_000, 2_727, 1_818, 909]).unwrap() + BoundedVec::>::try_from(vec![0, 3583, 0, 0]).unwrap() ); // Basic checks @@ -2899,47 +2904,77 @@ fn get_dapp_tier_assignment_and_rewards_basic_example_works() { assert_eq!(tier_assignment.rewards.len(), number_of_tiers as usize); assert_eq!( tier_assignment.dapps.len(), - number_of_smart_contracts as usize - 1, - "One contract doesn't make it into any tier." + number_of_smart_contracts as usize - 3, + "Three contract doesn't make it into any tier." ); assert_eq!(counter, number_of_smart_contracts); - // 1st tier checks - let (dapp_1_tier, dapp_2_tier) = (tier_assignment.dapps[&0], tier_assignment.dapps[&1]); - assert_eq!(dapp_1_tier, RankedTier::new_saturated(0, 0, 9)); - assert_eq!(dapp_2_tier, RankedTier::new_saturated(0, 0, 9)); - // 2nd tier checks - let (dapp_3_tier, dapp_4_tier) = (tier_assignment.dapps[&2], tier_assignment.dapps[&3]); - assert_eq!(dapp_3_tier, RankedTier::new_saturated(1, 9, 9)); - assert_eq!(dapp_4_tier, RankedTier::new_saturated(1, 9, 9)); - - // 4th tier checks - let (dapp_5_tier, dapp_6_tier) = (tier_assignment.dapps[&4], tier_assignment.dapps[&5]); - assert_eq!(dapp_5_tier, RankedTier::new_saturated(3, 0, 9)); - assert_eq!(dapp_6_tier, RankedTier::new_saturated(3, 0, 9)); - - // Sanity check - last dapp should not exists in the tier assignment - assert!(tier_assignment - .dapps - .get(&dapp_index.try_into().unwrap()) - .is_none()); - - // Check that rewards are calculated correctly - tier_config - .reward_portion - .iter() - .zip(tier_config.slots_per_tier.iter()) - .enumerate() - .for_each(|(idx, (reward_portion, slots))| { - let total_tier_allocation = *reward_portion * dapp_reward_pool; - let base_portion = tier_params.base_reward_portion; - let tier_reward: Balance = base_portion - .mul_floor(total_tier_allocation) - .saturating_div((*slots).into()); - - assert_eq!(tier_assignment.rewards[idx], tier_reward,); - }); + let (dapp_1_tier, dapp_2_tier, dapp_3_tier, dapp_4_tier, dapp_5_tier) = ( + tier_assignment.dapps[&0], + tier_assignment.dapps[&1], + tier_assignment.dapps[&2], + tier_assignment.dapps[&3], + tier_assignment.dapps[&4], + ); + assert_eq!(dapp_1_tier, RankedTier::new_saturated(1, 10)); + assert_eq!(dapp_2_tier, RankedTier::new_saturated(1, 10)); + assert_eq!(dapp_3_tier, RankedTier::new_saturated(1, 10)); + assert_eq!(dapp_4_tier, RankedTier::new_saturated(1, 9)); + assert_eq!(dapp_5_tier, RankedTier::new_saturated(1, 9)); + + // === Verify reward calculations === + // Tier 0: 40% of 1M = 400,000 ASTR + // multiplier = 0% β†’ compute_tier_rewards returns (0, 0) + assert_eq!(tier_assignment.rewards[0], 0); + assert_eq!(tier_assignment.rank_rewards[0], 0); + + // Tier 1: 30% of 1M = 300,000 ASTR + let tier_1_allocation = Permill::from_percent(30) * dapp_reward_pool; + let tier_1_slots = tier_config.slots_per_tier[1]; + let tier_1_filled = 5u32; + let tier_1_ranks_sum = 10u32 + 10 + 10 + 9 + 9; // 48 + let tier_1_multiplier = tier_params.tier_rank_multipliers[1]; + let (expected_reward_1, expected_rank_reward_1) = DappStaking::compute_tier_rewards( + tier_1_allocation, + tier_1_slots, + tier_1_filled, + tier_1_ranks_sum, + tier_1_multiplier, + ); + assert_eq!(tier_assignment.rewards[1], expected_reward_1); + assert_eq!(tier_assignment.rank_rewards[1], expected_rank_reward_1); + + // Tier 2: 20% of 1M = 200,000 ASTR + // empty tier (unminted rewards) + assert_eq!(tier_assignment.rewards[2], 0); + assert_eq!(tier_assignment.rank_rewards[2], 0); + + // Tier 3: 10% of 1M = 100,000 ASTR + let tier_3_allocation = Permill::from_percent(10) * dapp_reward_pool; + let tier_3_slots = tier_config.slots_per_tier[3]; + let tier_3_filled = 2u32; + let tier_3_ranks_sum = 0u32; + let tier_3_multiplier = tier_params.tier_rank_multipliers[3]; + let (expected_reward_3, expected_rank_reward_3) = DappStaking::compute_tier_rewards( + tier_3_allocation, + tier_3_slots, + tier_3_filled, + tier_3_ranks_sum, + tier_3_multiplier, + ); + assert_eq!(tier_assignment.rewards[3], expected_reward_3); + assert_eq!(tier_assignment.rank_rewards[3], expected_rank_reward_3); + + // === Verify claim formula produces capped total rewards === + let dapp_0_reward = tier_assignment.rewards[1] + 10 * tier_assignment.rank_rewards[1]; + let dapp_1_reward = tier_assignment.rewards[1] + 10 * tier_assignment.rank_rewards[1]; + let dapp_2_reward = tier_assignment.rewards[1] + 10 * tier_assignment.rank_rewards[1]; + let dapp_3_reward = tier_assignment.rewards[1] + 9 * tier_assignment.rank_rewards[1]; + let dapp_4_reward = tier_assignment.rewards[1] + 9 * tier_assignment.rank_rewards[1]; + let tier_1_total_disbursed = + dapp_0_reward + dapp_1_reward + dapp_2_reward + dapp_3_reward + dapp_4_reward; + assert!(tier_1_total_disbursed <= tier_1_allocation); }) } @@ -3595,26 +3630,14 @@ fn base_number_of_slots_is_respected() { } #[test] -fn ranking_with_points_calculates_reward_correctly() { +fn ranking_will_calc_reward_correctly() { ExtBuilder::default().build_and_execute(|| { - // Tier 1: 3 slots with points [5, 10, 15] (sum = 30) - // Tier 2: 2 slots with points [4, 8] (sum = 12) - StaticTierParams::::mutate(|params| { - params.rank_points = BoundedVec::try_from(vec![ - BoundedVec::try_from(vec![]).unwrap(), // tier 0: no ranking - BoundedVec::try_from(vec![5u8, 10, 15]).unwrap(), // tier 1: sum = 30 - BoundedVec::try_from(vec![4u8, 8]).unwrap(), // tier 2: sum = 12 - BoundedVec::try_from(vec![]).unwrap(), // tier 3: no ranking - ]) - .unwrap(); - }); - // Tier config is specially adapted for this test. TierConfig::::mutate(|config| { config.slots_per_tier = BoundedVec::try_from(vec![2, 3, 2, 20]).unwrap(); }); - // Register 8 smart contracts + // Register smart contracts let smart_contracts: Vec<_> = (1..=8u32) .map(|x| { let smart_contract = MockSmartContract::Wasm(x.into()); @@ -3642,74 +3665,48 @@ fn ranking_with_points_calculates_reward_correctly() { 1_000_000, ); - // Verify rank_points are stored - assert_eq!(tier_assignment.rank_points[1], vec![5u8, 10, 15]); - assert_eq!(tier_assignment.rank_points[2], vec![4u8, 8]); - assert_eq!( tier_assignment, DAppTierRewardsFor:: { dapps: BoundedBTreeMap::try_from(BTreeMap::from([ - (0, RankedTier::new_saturated(0, 0, 0)), - (1, RankedTier::new_saturated(0, 0, 0)), - (2, RankedTier::new_saturated(1, 2, 3)), - (3, RankedTier::new_saturated(1, 1, 3)), - (5, RankedTier::new_saturated(2, 0, 2)), - (6, RankedTier::new_saturated(2, 0, 2)), - (4, RankedTier::new_saturated(3, 0, 0)), + (0, RankedTier::new_saturated(0, 0)), + (1, RankedTier::new_saturated(0, 0)), + (2, RankedTier::new_saturated(1, 10)), + (3, RankedTier::new_saturated(1, 9)), + (5, RankedTier::new_saturated(2, 9)), + (6, RankedTier::new_saturated(2, 5)), + (4, RankedTier::new_saturated(3, 0)), ])) .unwrap(), - // Verify base rewards (50% of tier allocation / slots) - rewards: BoundedVec::try_from(vec![100_000, 50_000, 50_000, 2_500]).unwrap(), + rewards: BoundedVec::try_from(vec![200_000, 58_823, 28_019, 5_000]).unwrap(), period: 1, - // Verify rank rewards (50% of tier allocation / total_points) - // Tier 0: no ranking β†’ 0 - // Tier 1: 150k / 30 points = 5k per point - // Tier 2: 100k / 12 points = 8,333 per point - // Tier 3: no ranking β†’ 0 - rank_rewards: BoundedVec::try_from(vec![0, 5_000, 8_333, 0]).unwrap(), - rank_points: BoundedVec::try_from(vec![ - BoundedVec::try_from(vec![]).unwrap(), - BoundedVec::try_from(vec![5u8, 10, 15]).unwrap(), - BoundedVec::try_from(vec![4u8, 8]).unwrap(), - BoundedVec::try_from(vec![]).unwrap(), - ]) - .unwrap(), + // Tier 0 has no ranking multiplier therefore no rank reward. + // Tier 3 has no ranking multiplier therefore no rank reward. + rank_rewards: BoundedVec::try_from(vec![0, 8_235, 10_282, 0]).unwrap() } ); // one didn't make it assert_eq!(counter, 8); - assert_eq!(tier_assignment.dapps.len(), 7); }) } #[test] -fn claim_dapp_reward_with_rank_points() { +fn claim_dapp_reward_with_rank() { ExtBuilder::default().build_and_execute(|| { - // Tier-1: 5 slots with points [1, 5, 10, 15, 20] - StaticTierParams::::mutate(|params| { - params.rank_points = BoundedVec::try_from(vec![ - BoundedVec::try_from(vec![]).unwrap(), - BoundedVec::try_from(vec![1, 5, 10, 15, 20]).unwrap(), - BoundedVec::try_from(vec![]).unwrap(), - BoundedVec::try_from(vec![]).unwrap(), - ]) - .unwrap(); - }); - - let total_issuance = ::Currency::total_issuance(); - - // Register smart contract, lock&stake some amount + // Register smart contract let smart_contract = MockSmartContract::wasm(1 as AccountId); assert_register(1, &smart_contract); let alice = 2; - let amount = Perbill::from_parts(11_000_000) * total_issuance; // very close to tier 0 so will enter tier 1 with rank 4 + // Stake amount that puts dApp in Tier 1 with a specific rank + // Assuming tier_0=100, tier_1=50 + // Stake 75 β†’ rank = (75-50)/5 = 5 + let amount = 75; assert_lock(alice, amount); assert_stake(alice, &smart_contract, amount); - // Advance 2 eras so we have an entry for reward claiming + // Advance 2 eras for reward claiming advance_to_era(ActiveProtocolState::::get().era + 2); let era = ActiveProtocolState::::get().era - 1; @@ -3718,18 +3715,17 @@ fn claim_dapp_reward_with_rank_points() { // Verify tier assignment let ranked_tier = tiers.dapps.get(&0).unwrap(); assert_eq!(ranked_tier.tier(), 1, "Should be in tier 1"); - let (tier_id, rank) = ranked_tier.deconstruct(); - // Get reward components - let base_reward = tiers.rewards[tier_id as usize]; - let rank_reward_per_point = tiers.rank_rewards[tier_id as usize]; - let points = tiers.rank_points[tier_id as usize][rank as usize]; + let expected_rank = 5; // (75-50)/(50/10) = 25/5 = 5 + assert_eq!(ranked_tier.rank(), expected_rank); + + let base_reward = tiers.rewards[1]; + let rank_reward = tiers.rank_rewards[1]; - // Calculate expected reward: base + (rank_reward_per_point * points) - let expected_rank_reward = rank_reward_per_point * (points as Balance); - let expected_total_reward = base_reward + expected_rank_reward; + // Calculate expected total reward + let expected_total_reward = base_reward + expected_rank as Balance * rank_reward; - // Claim dApp reward & verify event + // Claim dApp reward assert_ok!(DappStaking::claim_dapp_reward( RuntimeOrigin::signed(alice), smart_contract.clone(), @@ -3740,7 +3736,7 @@ fn claim_dapp_reward_with_rank_points() { beneficiary: 1, smart_contract: smart_contract.clone(), tier_id: 1, - rank: 4, + rank: expected_rank, era, amount: expected_total_reward, })); diff --git a/pallets/dapp-staking/src/test/tests_types.rs b/pallets/dapp-staking/src/test/tests_types.rs index 7404ec9a33..8bd4374467 100644 --- a/pallets/dapp-staking/src/test/tests_types.rs +++ b/pallets/dapp-staking/src/test/tests_types.rs @@ -17,7 +17,7 @@ // along with Astar. If not, see . use astar_primitives::{ - dapp_staking::{RankedTier, StandardTierSlots, STANDARD_TIER_SLOTS_ARGS}, + dapp_staking::{RankedTier, StandardTierSlots, STANDARD_TIER_SLOTS_ARGS, FIXED_TIER_SLOTS_ARGS}, Balance, }; use frame_support::{assert_ok, parameter_types}; @@ -3487,14 +3487,8 @@ fn tier_params_check_is_ok() { }, ]) .unwrap(), - slot_number_args: STANDARD_TIER_SLOTS_ARGS, - rank_points: BoundedVec::try_from(vec![ - BoundedVec::try_from(vec![6u8, 8, 10]).unwrap(), - BoundedVec::try_from(vec![1u8, 3, 5]).unwrap(), - BoundedVec::try_from(vec![1u8, 2]).unwrap(), - ]) - .unwrap(), - base_reward_portion: Permill::from_percent(50), + slot_number_args: FIXED_TIER_SLOTS_ARGS, + tier_rank_multipliers: BoundedVec::try_from(vec![10_000, 24_000, 46_700]).unwrap(), }; assert!(params.is_valid()); @@ -3580,24 +3574,29 @@ fn tier_params_check_is_ok() { .unwrap(); assert!(!invalid_dynamic_params.is_valid()); - // 7th scenario - rank_points length mismatch with number of tiers - let mut invalid_rank_points = params.clone(); - invalid_rank_points.rank_points = BoundedVec::try_from(vec![ - BoundedVec::try_from(vec![8u8, 10]).unwrap(), - BoundedVec::try_from(vec![3u8, 5]).unwrap(), - // Missing 3rd tier rank_points + // 7th scenario - tier_rank_multipliers length mismatch with number of tiers + let mut invalid_tier_points = params.clone(); + invalid_tier_points.tier_rank_multipliers = BoundedVec::try_from(vec![ + 10_000, 24_000, + // Missing 3rd tier multiplier ]) .unwrap(); - assert!(!invalid_rank_points.is_valid()); + assert!(!invalid_tier_points.is_valid()); - // 8th scenario - base_reward_portion at extremes (0% and 100% are valid) - let mut zero_base = params.clone(); - zero_base.base_reward_portion = Permill::from_percent(0); - assert!(zero_base.is_valid(), "0% base (100% rank) is valid"); + // 8th scenario - multiplier is capped + let mut valid_tier_points = params.clone(); + valid_tier_points.tier_rank_multipliers = BoundedVec::try_from(vec![ + 10_000, 100_000, 100_000 + ]) + .unwrap(); + assert!(valid_tier_points.is_valid()); - let mut full_base = params.clone(); - full_base.base_reward_portion = Permill::from_percent(100); - assert!(full_base.is_valid(), "100% base (0% rank) is valid"); + let mut invalid_tier_points = params.clone(); + invalid_tier_points.tier_rank_multipliers = BoundedVec::try_from(vec![ + 10_000, 100_001, 100_000 + ]) + .unwrap(); + assert!(!invalid_tier_points.is_valid()); } #[test] @@ -3640,15 +3639,8 @@ fn tier_configuration_basic_tests() { }, ]) .unwrap(), - slot_number_args: STANDARD_TIER_SLOTS_ARGS, - rank_points: BoundedVec::try_from(vec![ - BoundedVec::try_from(vec![6u8, 9, 12, 15]).unwrap(), - BoundedVec::try_from(vec![4u8, 7, 10]).unwrap(), - BoundedVec::try_from(vec![1u8, 3, 5]).unwrap(), - BoundedVec::try_from(vec![1u8]).unwrap(), - ]) - .unwrap(), - base_reward_portion: Permill::from_percent(50), + slot_number_args: FIXED_TIER_SLOTS_ARGS, + tier_rank_multipliers: BoundedVec::try_from(vec![0, 24_000, 46_700, 0]).unwrap(), }; assert!(params.is_valid(), "Example params must be valid!"); @@ -3692,11 +3684,11 @@ fn dapp_tier_rewards_basic_tests() { // Example dApps & rewards let dapps = BTreeMap::::from([ - (1, RankedTier::new_saturated(0, 0, 10)), - (2, RankedTier::new_saturated(0, 0, 10)), - (3, RankedTier::new_saturated(1, 0, 10)), - (5, RankedTier::new_saturated(1, 0, 10)), - (6, RankedTier::new_saturated(2, 0, 10)), + (1, RankedTier::new_saturated(0, 0)), + (2, RankedTier::new_saturated(0, 0)), + (3, RankedTier::new_saturated(1, 0)), + (5, RankedTier::new_saturated(1, 0)), + (6, RankedTier::new_saturated(2, 0)), ]); let tier_rewards = vec![300, 20, 1]; let period = 2; @@ -3706,7 +3698,6 @@ fn dapp_tier_rewards_basic_tests() { tier_rewards.clone(), period, vec![0, 0, 0], - vec![], ) .expect("Bounds are respected."); @@ -3781,11 +3772,11 @@ fn dapp_tier_rewards_with_rank() { // Example dApps & rewards let dapps = BTreeMap::::from([ - (1, RankedTier::new_saturated(0, 5, 10)), - (2, RankedTier::new_saturated(0, 0, 10)), - (3, RankedTier::new_saturated(1, 10, 10)), - (5, RankedTier::new_saturated(1, 5, 10)), - (6, RankedTier::new_saturated(2, 0, 10)), + (1, RankedTier::new_saturated(0, 5)), + (2, RankedTier::new_saturated(0, 0)), + (3, RankedTier::new_saturated(1, 10)), + (5, RankedTier::new_saturated(1, 5)), + (6, RankedTier::new_saturated(2, 0)), ]); let tier_rewards = vec![300, 20, 1]; let rank_rewards = vec![0, 2, 0]; @@ -3796,7 +3787,6 @@ fn dapp_tier_rewards_with_rank() { tier_rewards.clone(), period, rank_rewards.clone(), - vec![], ) .expect("Bounds are respected."); @@ -3827,212 +3817,6 @@ fn dapp_tier_rewards_with_rank() { ); } -#[test] -fn dapp_tier_rewards_with_rank_points() { - get_u32_type!(NumberOfDApps, 8); - get_u32_type!(NumberOfTiers, 3); - - // New behavior: rank_points populated, uses points * rank_rewards - // Tier 0: positions 0,1,2 have points [15, 12, 9] - // Tier 1: positions 0,1,2,3 have points [10, 7, 4, 1] - // Tier 2: positions 0,1 have points [5, 2] - let dapps = BTreeMap::::from([ - (1, RankedTier::new_saturated(0, 0, 10)), // tier 0, rank 0 β†’ points 15 - (2, RankedTier::new_saturated(0, 2, 10)), // tier 0, rank 2 β†’ points 9 - (3, RankedTier::new_saturated(1, 1, 10)), // tier 1, rank 1 β†’ points 7 - (4, RankedTier::new_saturated(1, 3, 10)), // tier 1, rank 3 β†’ points 1 - (5, RankedTier::new_saturated(2, 0, 10)), // tier 2, rank 0 β†’ points 5 - ]); - let tier_rewards = vec![100, 50, 10]; // base reward per tier - let rank_rewards = vec![10, 5, 2]; // reward per point per tier - let period = 2; - let rank_points = vec![ - vec![9u8, 12, 15], // tier 0 - vec![1u8, 4, 7, 10], // tier 1 - vec![2u8, 5], // tier 2 - ]; - - let mut dapp_tier_rewards = DAppTierRewards::::new( - dapps.clone(), - tier_rewards.clone(), - period, - rank_rewards.clone(), - rank_points.clone(), - ) - .expect("Bounds are respected."); - - // dApp 1: tier 0, rank 0, points 9 β†’ 100 + (10 * 9) = 190 - let ranked_tier = dapps[&1]; - assert_eq!( - dapp_tier_rewards.try_claim(1), - Ok((100 + 10 * 9, ranked_tier)) - ); - - // dApp 2: tier 0, rank 2, points 15 β†’ 100 + (10 * 15) = 250 - let ranked_tier = dapps[&2]; - assert_eq!( - dapp_tier_rewards.try_claim(2), - Ok((100 + 10 * 15, ranked_tier)) - ); - - // dApp 3: tier 1, rank 1, points 4 β†’ 50 + (5 * 4) = 70 - let ranked_tier = dapps[&3]; - assert_eq!( - dapp_tier_rewards.try_claim(3), - Ok((50 + 5 * 4, ranked_tier)) - ); - - // dApp 4: tier 1, rank 3, points 10 β†’ 50 + (5 * 10) = 100 - let ranked_tier = dapps[&4]; - assert_eq!( - dapp_tier_rewards.try_claim(4), - Ok((50 + 5 * 10, ranked_tier)) - ); - - // dApp 5: tier 2, rank 0, points 2 β†’ 10 + (2 * 2) = 14 - let ranked_tier = dapps[&5]; - assert_eq!( - dapp_tier_rewards.try_claim(5), - Ok((10 + 2 * 2, ranked_tier)) - ); -} - -#[test] -fn dapp_tier_rewards_rank_out_of_bounds() { - get_u32_type!(NumberOfDApps, 4); - get_u32_type!(NumberOfTiers, 2); - - // rank_points only has 2 entries per tier, but dApp has rank 5 - let dapps = BTreeMap::::from([ - (1, RankedTier::new_saturated(0, 5, 10)), // rank 5, but only points[0..2] exist - ]); - let tier_rewards = vec![100, 50]; - let rank_rewards = vec![10, 5]; - let rank_points = vec![ - vec![12u8, 15], // only 2 entries - vec![7u8, 10], - ]; - - let mut dapp_tier_rewards = DAppTierRewards::::new( - dapps.clone(), - tier_rewards.clone(), - 2, - rank_rewards.clone(), - rank_points, - ) - .expect("Bounds are respected."); - - // rank 5 is out of bounds β†’ points = 0 β†’ only base reward - let ranked_tier = dapps[&1]; - assert_eq!( - dapp_tier_rewards.try_claim(1), - Ok((100, ranked_tier)), // base only, no rank reward - ); -} - -#[test] -fn dapp_tier_rewards_base_portion_allocation() { - get_u32_type!(NumberOfDApps, 8); - get_u32_type!(NumberOfTiers, 3); - - // rank_points for tier 1 (ascending): [2, 4, 6, 8, 10] (5 elements, indices 0-4) - let rank_points_tier1 = vec![2u8, 4, 6, 8, 10]; - let max_rank: u8 = rank_points_tier1.len() as u8; // 5 - - // Scenario 1: 50% base / 50% rank, dApp at rank 3 (8 points) - { - let dapps = BTreeMap::from([ - (1, RankedTier::new_saturated(1, 3, max_rank)), // tier 1, rank 3 - ]); - let mut entry = DAppTierRewards::::new( - dapps, - vec![0, 500, 0], // base reward per tier - 1, - vec![0, 16, 0], // reward per point - vec![vec![], rank_points_tier1.clone(), vec![]], - ) - .unwrap(); - - let (reward, rt) = entry.try_claim(1).unwrap(); - let (_, rank) = rt.deconstruct(); - - assert_eq!(rank, 3); - let points = rank_points_tier1[rank as usize]; - assert_eq!(points, 8, "rank 3 β†’ index 3 β†’ 8 points"); - assert_eq!(reward, 500 + 16 * 8, "base=500 + rank=128 = 628"); - } - - // Scenario 2: Compare all ranks in tier 1 - { - let dapps = BTreeMap::from([ - (0, RankedTier::new_saturated(1, 0, max_rank)), // rank 0 β†’ 2 points - (1, RankedTier::new_saturated(1, 1, max_rank)), // rank 1 β†’ 4 points - (2, RankedTier::new_saturated(1, 2, max_rank)), // rank 2 β†’ 6 points - (3, RankedTier::new_saturated(1, 3, max_rank)), // rank 3 β†’ 8 points - (4, RankedTier::new_saturated(1, 4, max_rank)), // rank 4 β†’ 10 points - ]); - let mut entry = DAppTierRewards::::new( - dapps, - vec![0, 100, 0], // base = 100 - 1, - vec![0, 10, 0], // 10 per point - vec![vec![], rank_points_tier1.clone(), vec![]], - ) - .unwrap(); - - // Claim in order and verify rewards increase with rank - let (r0, _) = entry.try_claim(0).unwrap(); - let (r1, _) = entry.try_claim(1).unwrap(); - let (r2, _) = entry.try_claim(2).unwrap(); - let (r3, _) = entry.try_claim(3).unwrap(); - let (r4, _) = entry.try_claim(4).unwrap(); - - assert_eq!(r0, 100 + 10 * 2, "rank 0: 100 + 20 = 120"); - assert_eq!(r1, 100 + 10 * 4, "rank 1: 100 + 40 = 140"); - assert_eq!(r2, 100 + 10 * 6, "rank 2: 100 + 60 = 160"); - assert_eq!(r3, 100 + 10 * 8, "rank 3: 100 + 80 = 180"); - assert_eq!(r4, 100 + 10 * 10, "rank 4: 100 + 100 = 200"); - - assert!( - r0 < r1 && r1 < r2 && r2 < r3 && r3 < r4, - "Higher rank (higher stake) should earn more" - ); - } - - // Scenario 3: 100% base (no rank bonus) - { - let dapps = BTreeMap::from([(1, RankedTier::new_saturated(1, 4, max_rank))]); - let mut entry = DAppTierRewards::::new( - dapps, - vec![0, 1000, 0], // 100% to base - 1, - vec![0, 0, 0], // 0% to rank - vec![vec![], rank_points_tier1.clone(), vec![]], - ) - .unwrap(); - - let (reward, _) = entry.try_claim(1).unwrap(); - assert_eq!(reward, 1000, "100% base: only base reward, no rank bonus"); - } - - // Scenario 4: 0% base (all rank) - { - let dapps = BTreeMap::from([(1, RankedTier::new_saturated(1, 4, max_rank))]); - let mut entry = DAppTierRewards::::new( - dapps, - vec![0, 0, 0], // 0% base - 1, - vec![0, 33, 0], // all to rank - vec![vec![], rank_points_tier1.clone(), vec![]], - ) - .unwrap(); - - let (reward, _) = entry.try_claim(1).unwrap(); - // rank 4 β†’ 10 points β†’ 33 * 10 = 330 - assert_eq!(reward, 33 * 10, "0% base: only rank reward = 330"); - } -} - #[test] fn tier_thresholds_conversion_test() { get_u32_type!(TiersNum, 2); @@ -4132,8 +3916,7 @@ fn tier_configuration_calculate_new_with_maximum_threshold() { tier_thresholds: tier_thresholds_legacy, reward_portion: reward_portion.clone(), slot_number_args: STANDARD_TIER_SLOTS_ARGS, - rank_points: Default::default(), - base_reward_portion: Default::default(), + tier_rank_multipliers: BoundedVec::try_from(vec![0, 24_000, 46_700, 0]).unwrap(), }; let params_with_max = TierParameters:: { @@ -4141,8 +3924,7 @@ fn tier_configuration_calculate_new_with_maximum_threshold() { tier_thresholds: tier_thresholds_with_max, reward_portion: reward_portion.clone(), slot_number_args: STANDARD_TIER_SLOTS_ARGS, - rank_points: Default::default(), - base_reward_portion: Default::default(), + tier_rank_multipliers: BoundedVec::try_from(vec![0, 24_000, 46_700, 0]).unwrap(), }; // Create a starting configuration with some values diff --git a/pallets/dapp-staking/src/types.rs b/pallets/dapp-staking/src/types.rs index b67ea02275..b64e6b85a2 100644 --- a/pallets/dapp-staking/src/types.rs +++ b/pallets/dapp-staking/src/types.rs @@ -76,9 +76,7 @@ use sp_runtime::{ pub use sp_std::{collections::btree_map::BTreeMap, fmt::Debug, vec::Vec}; use astar_primitives::{ - dapp_staking::{ - DAppId, EraNumber, PeriodNumber, RankedTier, TierSlots as TierSlotsFunc, MAX_ENCODED_RANK, - }, + dapp_staking::{DAppId, EraNumber, PeriodNumber, RankedTier, TierSlots as TierSlotsFunc}, Balance, BlockNumber, }; @@ -1712,11 +1710,8 @@ pub struct TierParameters> { /// This can be made more generic in the future in case more complex equations are required. /// But for now this simple tuple serves the purpose. pub(crate) slot_number_args: (u64, u64), - /// Rank points per tier in ASCENDING order by rank (index 0 = rank 0 = lowest stake in tier) - pub(crate) rank_points: BoundedVec>, NT>, - /// Portion of tier allocation for base rewards (remainder β†’ rank rewards) - /// e.g., Permill::from_percent(50) = 50% base, 50% rank - pub(crate) base_reward_portion: Permill, + /// Rank multiplier per tier in bips (100% = 10_000 bips): rank 10 reward as percentage of rank 0 reward. + pub(crate) tier_rank_multipliers: BoundedVec, } impl> TierParameters { @@ -1763,11 +1758,22 @@ impl> TierParameters { } } + // - Tier 0: must be <= 100% (no rank bonus for the top tier) + match self.tier_rank_multipliers.first() { + Some(m0) if *m0 <= 10_000 => {} + _ => return false, + } + + // Safety cap + if self.tier_rank_multipliers.iter().any(|m| *m > 100_000) { + return false; + } + let number_of_tiers: usize = NT::get() as usize; number_of_tiers == self.reward_portion.len() && number_of_tiers == self.slot_distribution.len() && number_of_tiers == self.tier_thresholds.len() - && number_of_tiers == self.rank_points.len() + && number_of_tiers == self.tier_rank_multipliers.len() } } @@ -1939,8 +1945,6 @@ pub struct DAppTierRewards, NT: Get> { pub(crate) period: PeriodNumber, /// Rank reward for each tier. First entry refers to the first tier, and so on. pub(crate) rank_rewards: BoundedVec, - /// Rank points per tier in ASCENDING order by rank (index 0 = rank 0 = lowest stake in tier) - pub(crate) rank_points: BoundedVec>, NT>, } impl, NT: Get> DAppTierRewards { @@ -1951,24 +1955,15 @@ impl, NT: Get> DAppTierRewards { rewards: Vec, period: PeriodNumber, rank_rewards: Vec, - rank_points: Vec>, ) -> Result { let dapps = BoundedBTreeMap::try_from(dapps).map_err(|_| ())?; let rewards = BoundedVec::try_from(rewards).map_err(|_| ())?; let rank_rewards = BoundedVec::try_from(rank_rewards).map_err(|_| ())?; - - let rank_points: Vec>> = rank_points - .into_iter() - .map(|inner| BoundedVec::try_from(inner).map_err(|_| ())) - .collect::, ()>>()?; - let rank_points = BoundedVec::try_from(rank_points).map_err(|_| ())?; - Ok(Self { dapps, rewards, period, rank_rewards, - rank_points, }) } @@ -1987,25 +1982,12 @@ impl, NT: Get> DAppTierRewards { .get(tier_id as usize) .map_or(Balance::zero(), |x| *x); - let reward_per_point = self + let reward_per_rank = self .rank_rewards .get(tier_id as usize) .map_or(Balance::zero(), |x| *x); - let additional_reward = if self.rank_points.is_empty() { - // Legacy formula: reward_per_point * rank - reward_per_point.saturating_mul(rank.into()) - } else { - let points: u32 = self - .rank_points - .get(tier_id as usize) - .and_then(|tier_points| tier_points.get(rank as usize)) - .copied() - .unwrap_or(0) - .into(); - reward_per_point.saturating_mul(points.into()) - }; - + let additional_reward = reward_per_rank.saturating_mul(rank.into()); amount = amount.saturating_add(additional_reward); Ok((amount, ranked_tier)) diff --git a/precompiles/dapp-staking/src/test/mock.rs b/precompiles/dapp-staking/src/test/mock.rs index 49e9ea512d..10d21558bd 100644 --- a/precompiles/dapp-staking/src/test/mock.rs +++ b/precompiles/dapp-staking/src/test/mock.rs @@ -273,6 +273,12 @@ impl ExternalityBuilder { .build_storage() .unwrap(); + let slots_per_tier = vec![10, 20, 30, 40]; + let tier_rank_multipliers: Vec = slots_per_tier + .iter() + .map(|&slots| if slots == 0 { 10_000 } else { 20_000 }) + .collect(); + pallet_dapp_staking::GenesisConfig::::assimilate_storage( &pallet_dapp_staking::GenesisConfig:: { reward_portion: vec![ @@ -302,15 +308,9 @@ impl ExternalityBuilder { }, ], slot_number_args: STANDARD_TIER_SLOTS_ARGS, - slots_per_tier: vec![10, 20, 30, 40], + slots_per_tier, safeguard: None, - rank_points: vec![ - vec![1u8], - vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10], - vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10], - vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10], - ], - base_reward_portion: Permill::from_percent(50), + tier_rank_multipliers, _config: PhantomData, }, &mut storage, diff --git a/primitives/src/dapp_staking.rs b/primitives/src/dapp_staking.rs index a11f186762..4fdd997e67 100644 --- a/primitives/src/dapp_staking.rs +++ b/primitives/src/dapp_staking.rs @@ -40,11 +40,6 @@ pub type TierId = u8; /// Tier Rank type pub type Rank = u8; -/// Maximum encodable rank (4 bits) -pub const MAX_ENCODED_RANK: u32 = 0x0f; -/// Maximum encodable tier (4 bits) -pub const MAX_ENCODED_TIER: u8 = 0x0f; - /// Configuration for cycles, periods, subperiods & eras. /// /// * `cycle` - Time unit similar to 'year' in the real world. Consists of one or more periods. At the beginning of each cycle, inflation is recalculated. @@ -213,6 +208,7 @@ impl TierSlots for StandardTierSlots { /// Standard tier slots arguments. /// Initially decided for Astar, during the Tokenomics 2.0 work. pub const STANDARD_TIER_SLOTS_ARGS: (u64, u64) = (1000, 50); +/// Decided for Astar, during the Tokenomics 3.0 revamp. pub const FIXED_TIER_SLOTS_ARGS: (u64, u64) = (0, 16); /// RankedTier is wrapper around u8 to hold both tier and rank. u8 has 2 bytes (8bits) and they're using in this order `0xrank_tier`. @@ -222,44 +218,30 @@ pub const FIXED_TIER_SLOTS_ARGS: (u64, u64) = (0, 16); pub struct RankedTier(u8); impl RankedTier { - /// Validate max_rank fits in 4 bits - /// Returns Err(ArithmeticError::Overflow) if max value is not respected. - #[inline(always)] - fn validate_max_rank(max_rank: Rank) -> Result<(), ArithmeticError> { - if (max_rank as u32) > MAX_ENCODED_RANK { - Err(ArithmeticError::Overflow) - } else { - Ok(()) - } - } + pub const MAX_RANK: u8 = 10; /// Create new encoded RankedTier from tier and rank. - /// `max_rank` defines how many ranks this tier supports. - /// Returns Err(ArithmeticError::Overflow) if max values are not respected. - pub fn new(tier: TierId, rank: Rank, max_rank: Rank) -> Result { - Self::validate_max_rank(max_rank)?; - - if tier > MAX_ENCODED_TIER || rank > max_rank { + /// Returns Err(ArithmeticError::Overflow) if max value is not respected. + pub fn new(tier: TierId, rank: Rank) -> Result { + if rank > Self::MAX_RANK || tier > 0xf { return Err(ArithmeticError::Overflow); } - - Ok(Self((rank << 4) | (tier & 0x0f))) + Ok(Self(rank << 4 | tier & 0x0f)) } /// Create new encoded RankedTier from tier and rank with saturation. - pub fn new_saturated(tier: TierId, rank: Rank, max_rank: Rank) -> Self { - let max_rank = max_rank.min(MAX_ENCODED_RANK as Rank); - Self((rank.min(max_rank) << 4) | (tier.min(0x0f) & 0x0f)) + pub fn new_saturated(tier: TierId, rank: Rank) -> Self { + Self(rank.min(Self::MAX_RANK) << 4 | tier.min(0xf) & 0x0f) } #[inline(always)] pub fn tier(&self) -> TierId { - self.0 & MAX_ENCODED_TIER + self.0 & 0x0f } #[inline(always)] pub fn rank(&self) -> Rank { - (self.0 >> 4).min(MAX_ENCODED_RANK as u8) + (self.0 >> 4).min(Self::MAX_RANK) } #[inline(always)] @@ -278,35 +260,30 @@ impl core::fmt::Debug for RankedTier { } impl RankedTier { - /// Find rank based on lower/upper bounds, stake amount and number of ranks. - /// Delta between upper and lower bound is divided in `max_rank` and will increase rank + /// Find rank based on lower/upper bounds and staked amount. + /// Delta between upper and lower bound is divided in 10 and will increase rank /// by one for each threshold staked amount will reach. - /// - /// `max_rank` is the maximum rank for the tier (≀ 15). - pub fn find_rank( - lower_bound: Balance, - upper_bound: Balance, - stake_amount: Balance, - max_rank: Rank, - ) -> Rank { - if upper_bound.is_zero() || max_rank == 0 || (max_rank as u32) > MAX_ENCODED_RANK { + /// i.e. find_rank(10, 20, 10) -> 0 + /// i.e. find_rank(10, 20, 15) -> 5 + /// i.e. find_rank(10, 20, 20) -> 10 + pub fn find_rank(lower_bound: Balance, upper_bound: Balance, stake_amount: Balance) -> Rank { + if upper_bound.is_zero() { return 0; } - let rank_threshold = upper_bound .saturating_sub(lower_bound) - .saturating_div(max_rank.into()); + .saturating_div(RankedTier::MAX_RANK.into()); if rank_threshold.is_zero() { - return 0; + 0 + } else { + >::try_into( + stake_amount + .saturating_sub(lower_bound) + .saturating_div(rank_threshold), + ) + .unwrap_or_default() + .min(RankedTier::MAX_RANK) } - - >::try_into( - stake_amount - .saturating_sub(lower_bound) - .saturating_div(rank_threshold), - ) - .unwrap_or_default() - .min(max_rank) } } @@ -314,56 +291,42 @@ impl RankedTier { mod tests { use super::*; - const MAX_RANK: u8 = 10; - #[test] fn tier_and_rank() { - let t = RankedTier::new(0, 0, MAX_RANK).unwrap(); + let t = RankedTier::new(0, 0).unwrap(); assert_eq!(t.deconstruct(), (0, 0)); - let t = RankedTier::new(15, 10, MAX_RANK).unwrap(); + let t = RankedTier::new(15, 10).unwrap(); assert_eq!(t.deconstruct(), (15, 10)); - assert_eq!( - RankedTier::new(16, 10, MAX_RANK), - Err(ArithmeticError::Overflow) - ); - assert_eq!( - RankedTier::new(15, 11, MAX_RANK), - Err(ArithmeticError::Overflow) - ); + assert_eq!(RankedTier::new(16, 10), Err(ArithmeticError::Overflow)); + assert_eq!(RankedTier::new(15, 11), Err(ArithmeticError::Overflow)); - let t = RankedTier::new_saturated(0, 0, MAX_RANK); + let t = RankedTier::new_saturated(0, 0); assert_eq!(t.deconstruct(), (0, 0)); - let t = RankedTier::new_saturated(1, 1, MAX_RANK); + let t = RankedTier::new_saturated(1, 1); assert_eq!(t.deconstruct(), (1, 1)); - let t = RankedTier::new_saturated(3, 15, MAX_RANK); + let t = RankedTier::new_saturated(3, 15); assert_eq!(t.deconstruct(), (3, 10)); // max value for tier and rank - let t = RankedTier::new_saturated(16, 16, MAX_RANK); + let t = RankedTier::new_saturated(16, 16); assert_eq!(t.deconstruct(), (15, 10)); } #[test] fn find_rank() { - assert_eq!(RankedTier::find_rank(0, 0, 0, MAX_RANK), 0); - assert_eq!(RankedTier::find_rank(0, 100, 9, MAX_RANK), 0); - assert_eq!(RankedTier::find_rank(0, 100, 10, MAX_RANK), 1); - assert_eq!(RankedTier::find_rank(0, 100, 49, MAX_RANK), 4); - assert_eq!(RankedTier::find_rank(0, 100, 50, MAX_RANK), 5); - assert_eq!(RankedTier::find_rank(0, 100, 51, MAX_RANK), 5); - assert_eq!(RankedTier::find_rank(0, 100, 101, MAX_RANK), 10); - - assert_eq!(RankedTier::find_rank(100, 100, 100, MAX_RANK), 0); - assert_eq!(RankedTier::find_rank(200, 100, 100, MAX_RANK), 0); - } - - #[test] - fn different_max_ranks_work() { - assert_eq!(RankedTier::find_rank(0, 100, 100, 5), 5); - assert_eq!(RankedTier::find_rank(0, 100, 100, 15), 15); + assert_eq!(RankedTier::find_rank(0, 0, 0), 0); + assert_eq!(RankedTier::find_rank(0, 100, 9), 0); + assert_eq!(RankedTier::find_rank(0, 100, 10), 1); + assert_eq!(RankedTier::find_rank(0, 100, 49), 4); + assert_eq!(RankedTier::find_rank(0, 100, 50), 5); + assert_eq!(RankedTier::find_rank(0, 100, 51), 5); + assert_eq!(RankedTier::find_rank(0, 100, 101), 10); + + assert_eq!(RankedTier::find_rank(100, 100, 100), 0); + assert_eq!(RankedTier::find_rank(200, 100, 100), 0); } } diff --git a/runtime/astar/src/genesis_config.rs b/runtime/astar/src/genesis_config.rs index 0eda2225a6..1476e1375e 100644 --- a/runtime/astar/src/genesis_config.rs +++ b/runtime/astar/src/genesis_config.rs @@ -18,7 +18,7 @@ use crate::*; use astar_primitives::{ - dapp_staking::MAX_ENCODED_RANK, evm::EVM_REVERT_CODE, genesis::GenesisAccount, + dapp_staking::FIXED_TIER_SLOTS_ARGS, evm::EVM_REVERT_CODE, genesis::GenesisAccount, parachain::ASTAR_ID, }; @@ -62,10 +62,7 @@ pub fn default_config(para_id: u32) -> serde_json::Value { .collect::>(); let slots_per_tier = vec![0, 6, 10, 0]; - let rank_points: Vec> = slots_per_tier - .iter() - .map(|&slots| (1..=slots.min(MAX_ENCODED_RANK as u16) as u8).collect()) - .collect(); + let tier_rank_multipliers: Vec = vec![0, 24_000, 46_700, 0]; let config = RuntimeGenesisConfig { system: Default::default(), @@ -151,10 +148,10 @@ pub fn default_config(para_id: u32) -> serde_json::Value { required_percentage: Perbill::from_parts(23_200_000), // 2.32% }, TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(11_600_000), // 1.16% + required_percentage: Perbill::from_parts(9_300_000), // 0.93% }, TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(5_800_000), // 0.58% + required_percentage: Perbill::from_parts(3_500_000), // 0.35% }, // Tier 3: unreachable dummy TierThreshold::FixedPercentage { @@ -162,11 +159,9 @@ pub fn default_config(para_id: u32) -> serde_json::Value { }, ], slots_per_tier, - // Force fixed 16 slots - slot_number_args: (0, 16), + slot_number_args: FIXED_TIER_SLOTS_ARGS, safeguard: Some(false), - rank_points, - base_reward_portion: Permill::from_percent(10), + tier_rank_multipliers, ..Default::default() }, inflation: Default::default(), diff --git a/runtime/astar/src/lib.rs b/runtime/astar/src/lib.rs index e572b104a5..9ff3aa1a77 100644 --- a/runtime/astar/src/lib.rs +++ b/runtime/astar/src/lib.rs @@ -89,7 +89,7 @@ use xcm_runtime_apis::{ use astar_primitives::{ dapp_staking::{ AccountCheck as DappStakingAccountCheck, CycleConfiguration, DAppId, EraNumber, - PeriodNumber, RankedTier, SmartContract, StandardTierSlots, FIXED_TIER_SLOTS_ARGS, + PeriodNumber, RankedTier, SmartContract, StandardTierSlots, }, evm::{EVMFungibleAdapterWrapper, EvmRevertCodeHandler}, governance::{ @@ -1745,71 +1745,19 @@ pub type Executive = frame_executive::Executive< Migrations, >; -pub struct AstarTierParamsV11; -impl pallet_dapp_staking::migration::TierParamsV11Config for AstarTierParamsV11 { - fn reward_portion() -> [Permill; 4] { - [ - Permill::from_percent(0), - Permill::from_percent(70), - Permill::from_percent(30), - Permill::from_percent(0), - ] - } - - fn slot_distribution() -> [Permill; 4] { - [ - Permill::from_percent(0), - Permill::from_parts(375_000), // 37.5% - Permill::from_parts(625_000), // 62.5% - Permill::from_percent(0), - ] - } - - fn tier_thresholds() -> [pallet_dapp_staking::TierThreshold; 4] { - use pallet_dapp_staking::TierThreshold; - [ - TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(23_200_000), // 2.32% - }, - TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(11_600_000), // 1.16% - }, - TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(5_800_000), // 0.58% - }, - // Tier 3: unreachable dummy - TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(0), // 0% - }, - ] - } - - fn slot_number_args() -> (u64, u64) { - FIXED_TIER_SLOTS_ARGS - } - - fn rank_points() -> [Vec; 4] { - [ - vec![], // Tier 0: dummy - vec![10, 11, 12, 13, 14, 15], // Tier 1: 6 slots - vec![1, 3, 5, 7, 9, 11, 13, 15, 17, 19], // Tier 2: 10 slots - vec![], // Tier 3: dummy - ] - } - - fn base_reward_portion() -> Permill { - Permill::from_percent(10) - } -} - /// All migrations that will run on the next runtime upgrade. /// /// __NOTE:__ THE ORDER IS IMPORTANT. pub type Migrations = (Unreleased, Permanent); /// Unreleased migrations. Add new ones here: -pub type Unreleased = - (pallet_dapp_staking::migration::versioned_migrations::V10ToV11,); +pub type Unreleased = ( + pallet_dapp_staking::migration::versioned_migrations::V10ToV11< + Runtime, + pallet_dapp_staking::migration::DefaultTierParamsV11, + ConstU32<111> + >, +); /// Migrations/checks that do not need to be versioned and can run on every upgrade. pub type Permanent = (pallet_xcm::migration::MigrateToLatestXcmVersion,); diff --git a/runtime/shibuya/src/genesis_config.rs b/runtime/shibuya/src/genesis_config.rs index da3c9d268f..5c35c868cb 100644 --- a/runtime/shibuya/src/genesis_config.rs +++ b/runtime/shibuya/src/genesis_config.rs @@ -18,7 +18,7 @@ use crate::*; use astar_primitives::{ - dapp_staking::MAX_ENCODED_RANK, evm::EVM_REVERT_CODE, genesis::GenesisAccount, + dapp_staking::FIXED_TIER_SLOTS_ARGS, evm::EVM_REVERT_CODE, genesis::GenesisAccount, parachain::SHIBUYA_ID, }; @@ -62,10 +62,7 @@ pub fn default_config(para_id: u32) -> serde_json::Value { .collect::>(); let slots_per_tier = vec![0, 6, 10, 0]; - let rank_points: Vec> = slots_per_tier - .iter() - .map(|&slots| (1..=slots.min(MAX_ENCODED_RANK as u16) as u8).collect()) - .collect(); + let tier_rank_multipliers: Vec = vec![0, 24_000, 46_700, 0]; let config = RuntimeGenesisConfig { system: Default::default(), @@ -154,10 +151,10 @@ pub fn default_config(para_id: u32) -> serde_json::Value { required_percentage: Perbill::from_parts(23_200_000), // 2.32% }, TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(11_600_000), // 1.16% + required_percentage: Perbill::from_parts(9_300_000), // 0.93% }, TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(5_800_000), // 0.58% + required_percentage: Perbill::from_parts(3_500_000), // 0.35% }, // Tier 3: unreachable dummy TierThreshold::FixedPercentage { @@ -165,11 +162,9 @@ pub fn default_config(para_id: u32) -> serde_json::Value { }, ], slots_per_tier, - // Force fixed 16 slots - slot_number_args: (0, 16), + slot_number_args: FIXED_TIER_SLOTS_ARGS, safeguard: Some(false), - rank_points, - base_reward_portion: Permill::from_percent(10), + tier_rank_multipliers, ..Default::default() }, inflation: Default::default(), diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index c7411a21bb..1cca801fc0 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -85,7 +85,7 @@ use xcm_runtime_apis::{ use astar_primitives::{ dapp_staking::{ AccountCheck as DappStakingAccountCheck, CycleConfiguration, DAppId, EraNumber, - PeriodNumber, RankedTier, SmartContract, StandardTierSlots, FIXED_TIER_SLOTS_ARGS, + PeriodNumber, RankedTier, SmartContract, StandardTierSlots, }, evm::{EVMFungibleAdapterWrapper, EvmRevertCodeHandler, HashedDefaultMappings}, governance::{ @@ -1751,63 +1751,6 @@ pub type Executive = frame_executive::Executive< Migrations, >; -pub struct ShibuyaTierParamsV11; -impl pallet_dapp_staking::migration::TierParamsV11Config for ShibuyaTierParamsV11 { - fn reward_portion() -> [Permill; 4] { - [ - Permill::from_percent(0), - Permill::from_percent(70), - Permill::from_percent(30), - Permill::from_percent(0), - ] - } - - fn slot_distribution() -> [Permill; 4] { - [ - Permill::from_percent(0), - Permill::from_parts(375_000), // 37.5% - Permill::from_parts(625_000), // 62.5% - Permill::from_percent(0), - ] - } - - fn tier_thresholds() -> [pallet_dapp_staking::TierThreshold; 4] { - use pallet_dapp_staking::TierThreshold; - [ - TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(23_200_000), // 2.32% - }, - TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(11_600_000), // 1.16% - }, - TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(5_800_000), // 0.58% - }, - // Tier 3: unreachable dummy - TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(0), // 0% - }, - ] - } - - fn slot_number_args() -> (u64, u64) { - FIXED_TIER_SLOTS_ARGS - } - - fn rank_points() -> [Vec; 4] { - [ - vec![], // Tier 0: dummy - vec![10, 11, 12, 13, 14, 15], // Tier 1: 6 slots - vec![1, 3, 5, 7, 9, 11, 13, 15, 17, 19], // Tier 2: 10 slots - vec![], // Tier 3: dummy - ] - } - - fn base_reward_portion() -> Permill { - Permill::from_percent(10) - } -} - /// All migrations that will run on the next runtime upgrade. /// /// __NOTE:__ THE ORDER IS IMPORTANT. @@ -1815,7 +1758,11 @@ pub type Migrations = (Unreleased, Permanent); /// Unreleased migrations. Add new ones here: pub type Unreleased = ( - pallet_dapp_staking::migration::versioned_migrations::V10ToV11, + pallet_dapp_staking::migration::versioned_migrations::V10ToV11< + Runtime, + pallet_dapp_staking::migration::DefaultTierParamsV11, + ConstU32<20> + >, ); /// Migrations/checks that do not need to be versioned and can run on every upgrade. diff --git a/runtime/shiden/src/genesis_config.rs b/runtime/shiden/src/genesis_config.rs index 6710e31ce9..b8f911f901 100644 --- a/runtime/shiden/src/genesis_config.rs +++ b/runtime/shiden/src/genesis_config.rs @@ -18,7 +18,7 @@ use crate::*; use astar_primitives::{ - dapp_staking::MAX_ENCODED_RANK, evm::EVM_REVERT_CODE, genesis::GenesisAccount, + dapp_staking::FIXED_TIER_SLOTS_ARGS, evm::EVM_REVERT_CODE, genesis::GenesisAccount, parachain::SHIDEN_ID, }; @@ -50,10 +50,7 @@ pub fn default_config(para_id: u32) -> serde_json::Value { ]; let slots_per_tier = vec![0, 6, 10, 0]; - let rank_points: Vec> = slots_per_tier - .iter() - .map(|&slots| (1..=slots.min(MAX_ENCODED_RANK as u16) as u8).collect()) - .collect(); + let tier_rank_multipliers: Vec = vec![0, 24_000, 46_700, 0]; let authorities = vec![&alice, &bob]; @@ -140,10 +137,10 @@ pub fn default_config(para_id: u32) -> serde_json::Value { required_percentage: Perbill::from_parts(23_200_000), // 2.32% }, TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(11_600_000), // 1.16% + required_percentage: Perbill::from_parts(9_300_000), // 0.93% }, TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(5_800_000), // 0.58% + required_percentage: Perbill::from_parts(3_500_000), // 0.35% }, // Tier 3: unreachable dummy TierThreshold::FixedPercentage { @@ -151,11 +148,9 @@ pub fn default_config(para_id: u32) -> serde_json::Value { }, ], slots_per_tier, - // Force fixed 16 slots - slot_number_args: (0, 16), + slot_number_args: FIXED_TIER_SLOTS_ARGS, safeguard: Some(false), - rank_points, - base_reward_portion: Permill::from_percent(10), + tier_rank_multipliers, ..Default::default() }, inflation: Default::default(), diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index 3fc0e67a73..7663eb8773 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -86,7 +86,7 @@ use xcm_runtime_apis::{ use astar_primitives::{ dapp_staking::{ AccountCheck as DappStakingAccountCheck, CycleConfiguration, DAppId, EraNumber, - PeriodNumber, RankedTier, SmartContract, StandardTierSlots, FIXED_TIER_SLOTS_ARGS, + PeriodNumber, RankedTier, SmartContract, StandardTierSlots, }, evm::{EVMFungibleAdapterWrapper, EvmRevertCodeHandler}, governance::OracleMembershipInst, @@ -1314,63 +1314,6 @@ pub type Executive = frame_executive::Executive< Migrations, >; -pub struct ShidenTierParamsV11; -impl pallet_dapp_staking::migration::TierParamsV11Config for ShidenTierParamsV11 { - fn reward_portion() -> [Permill; 4] { - [ - Permill::from_percent(0), - Permill::from_percent(70), - Permill::from_percent(30), - Permill::from_percent(0), - ] - } - - fn slot_distribution() -> [Permill; 4] { - [ - Permill::from_percent(0), - Permill::from_parts(375_000), // 37.5% - Permill::from_parts(625_000), // 62.5% - Permill::from_percent(0), - ] - } - - fn tier_thresholds() -> [pallet_dapp_staking::TierThreshold; 4] { - use pallet_dapp_staking::TierThreshold; - [ - TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(23_200_000), // 2.32% - }, - TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(11_600_000), // 1.16% - }, - TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(5_800_000), // 0.58% - }, - // Tier 3: unreachable dummy - TierThreshold::FixedPercentage { - required_percentage: Perbill::from_parts(0), // 0% - }, - ] - } - - fn slot_number_args() -> (u64, u64) { - FIXED_TIER_SLOTS_ARGS - } - - fn rank_points() -> [Vec; 4] { - [ - vec![], // Tier 0: dummy - vec![10, 11, 12, 13, 14, 15], // Tier 1: 6 slots - vec![1, 3, 5, 7, 9, 11, 13, 15, 17, 19], // Tier 2: 10 slots - vec![], // Tier 3: dummy - ] - } - - fn base_reward_portion() -> Permill { - Permill::from_percent(10) - } -} - /// All migrations that will run on the next runtime upgrade. /// /// __NOTE:__ THE ORDER IS IMPORTANT. @@ -1378,7 +1321,11 @@ pub type Migrations = (Unreleased, Permanent); /// Unreleased migrations. Add new ones here: pub type Unreleased = ( - pallet_dapp_staking::migration::versioned_migrations::V10ToV11, + pallet_dapp_staking::migration::versioned_migrations::V10ToV11< + Runtime, + pallet_dapp_staking::migration::DefaultTierParamsV11, + ConstU32<55> + >, ); /// Migrations/checks that do not need to be versioned and can run on every upgrade. From 05573f22498d374d5ee11335a012d708bfe09af3 Mon Sep 17 00:00:00 2001 From: Igor Papandinas <26460174+ipapandinas@users.noreply.github.com> Date: Mon, 9 Feb 2026 10:35:54 +0400 Subject: [PATCH 10/16] fmt --- pallets/dapp-staking/src/migration.rs | 22 +++++++++++--------- pallets/dapp-staking/src/test/tests_types.rs | 16 +++++++------- runtime/astar/src/lib.rs | 2 +- runtime/shibuya/src/lib.rs | 2 +- runtime/shiden/src/lib.rs | 2 +- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/pallets/dapp-staking/src/migration.rs b/pallets/dapp-staking/src/migration.rs index 351ca6c0b0..462b81745c 100644 --- a/pallets/dapp-staking/src/migration.rs +++ b/pallets/dapp-staking/src/migration.rs @@ -35,13 +35,14 @@ pub mod versioned_migrations { /// Migration V10 to V11 wrapped in a [`frame_support::migrations::VersionedMigration`], ensuring /// the migration is only performed when on-chain version is 10. - pub type V10ToV11 = frame_support::migrations::VersionedMigration< - 10, - 11, - v11::VersionMigrateV10ToV11, - Pallet, - ::DbWeight, - >; + pub type V10ToV11 = + frame_support::migrations::VersionedMigration< + 10, + 11, + v11::VersionMigrateV10ToV11, + Pallet, + ::DbWeight, + >; } /// Configuration for V11 tier parameters @@ -105,7 +106,9 @@ mod v11 { pub struct VersionMigrateV10ToV11(PhantomData<(T, P, OldErasBnE)>); - impl> UncheckedOnRuntimeUpgrade for VersionMigrateV10ToV11 { + impl> UncheckedOnRuntimeUpgrade + for VersionMigrateV10ToV11 + { fn on_runtime_upgrade() -> Weight { let old_eras_bne = OldErasBnE::get(); @@ -168,8 +171,7 @@ mod v11 { let old_end: EraNumber = state.period_info.next_subperiod_start_era; let remaining_old: EraNumber = old_end.saturating_sub(current_era); - let elapsed: EraNumber = - old_eras_bne.saturating_sub(remaining_old); + let elapsed: EraNumber = old_eras_bne.saturating_sub(remaining_old); let remaining_new: EraNumber = new_eras_total.saturating_sub(elapsed); diff --git a/pallets/dapp-staking/src/test/tests_types.rs b/pallets/dapp-staking/src/test/tests_types.rs index 8bd4374467..edd1a86cce 100644 --- a/pallets/dapp-staking/src/test/tests_types.rs +++ b/pallets/dapp-staking/src/test/tests_types.rs @@ -17,7 +17,9 @@ // along with Astar. If not, see . use astar_primitives::{ - dapp_staking::{RankedTier, StandardTierSlots, STANDARD_TIER_SLOTS_ARGS, FIXED_TIER_SLOTS_ARGS}, + dapp_staking::{ + RankedTier, StandardTierSlots, FIXED_TIER_SLOTS_ARGS, STANDARD_TIER_SLOTS_ARGS, + }, Balance, }; use frame_support::{assert_ok, parameter_types}; @@ -3585,17 +3587,13 @@ fn tier_params_check_is_ok() { // 8th scenario - multiplier is capped let mut valid_tier_points = params.clone(); - valid_tier_points.tier_rank_multipliers = BoundedVec::try_from(vec![ - 10_000, 100_000, 100_000 - ]) - .unwrap(); + valid_tier_points.tier_rank_multipliers = + BoundedVec::try_from(vec![10_000, 100_000, 100_000]).unwrap(); assert!(valid_tier_points.is_valid()); let mut invalid_tier_points = params.clone(); - invalid_tier_points.tier_rank_multipliers = BoundedVec::try_from(vec![ - 10_000, 100_001, 100_000 - ]) - .unwrap(); + invalid_tier_points.tier_rank_multipliers = + BoundedVec::try_from(vec![10_000, 100_001, 100_000]).unwrap(); assert!(!invalid_tier_points.is_valid()); } diff --git a/runtime/astar/src/lib.rs b/runtime/astar/src/lib.rs index 9ff3aa1a77..18f38443b7 100644 --- a/runtime/astar/src/lib.rs +++ b/runtime/astar/src/lib.rs @@ -1755,7 +1755,7 @@ pub type Unreleased = ( pallet_dapp_staking::migration::versioned_migrations::V10ToV11< Runtime, pallet_dapp_staking::migration::DefaultTierParamsV11, - ConstU32<111> + ConstU32<111>, >, ); diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index 1cca801fc0..c1a1245a54 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -1761,7 +1761,7 @@ pub type Unreleased = ( pallet_dapp_staking::migration::versioned_migrations::V10ToV11< Runtime, pallet_dapp_staking::migration::DefaultTierParamsV11, - ConstU32<20> + ConstU32<20>, >, ); diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index 7663eb8773..d2a07202d5 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -1324,7 +1324,7 @@ pub type Unreleased = ( pallet_dapp_staking::migration::versioned_migrations::V10ToV11< Runtime, pallet_dapp_staking::migration::DefaultTierParamsV11, - ConstU32<55> + ConstU32<55>, >, ); From 79cd9d51682d577a9f6bf69fc7d07e34ba9a20be Mon Sep 17 00:00:00 2001 From: Igor Papandinas <26460174+ipapandinas@users.noreply.github.com> Date: Mon, 9 Feb 2026 14:57:06 +0400 Subject: [PATCH 11/16] fix tests --- pallets/dapp-staking/src/lib.rs | 11 +++-------- precompiles/dapp-staking/src/test/mock.rs | 10 ++-------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/pallets/dapp-staking/src/lib.rs b/pallets/dapp-staking/src/lib.rs index 4f881eb123..d63caea935 100644 --- a/pallets/dapp-staking/src/lib.rs +++ b/pallets/dapp-staking/src/lib.rs @@ -545,12 +545,7 @@ pub mod pallet { impl Default for GenesisConfig { fn default() -> Self { - let slots_per_tier = vec![0u16, 6, 10, 0]; - let tier_rank_multipliers: Vec = slots_per_tier - .iter() - .map(|&slots| if slots == 0 { 10_000 } else { 20_000 }) - .collect(); - + let num_tiers = T::NumberOfTiers::get(); Self { reward_portion: vec![ Permill::zero(), // Tier 0: dummy @@ -579,9 +574,9 @@ pub mod pallet { }, ], slot_number_args: FIXED_TIER_SLOTS_ARGS, - slots_per_tier, + slots_per_tier: vec![100; num_tiers as usize], safeguard: None, - tier_rank_multipliers, + tier_rank_multipliers: vec![0u32, 24_000, 46_700, 0], _config: Default::default(), } } diff --git a/precompiles/dapp-staking/src/test/mock.rs b/precompiles/dapp-staking/src/test/mock.rs index 10d21558bd..2a9af5446b 100644 --- a/precompiles/dapp-staking/src/test/mock.rs +++ b/precompiles/dapp-staking/src/test/mock.rs @@ -273,12 +273,6 @@ impl ExternalityBuilder { .build_storage() .unwrap(); - let slots_per_tier = vec![10, 20, 30, 40]; - let tier_rank_multipliers: Vec = slots_per_tier - .iter() - .map(|&slots| if slots == 0 { 10_000 } else { 20_000 }) - .collect(); - pallet_dapp_staking::GenesisConfig::::assimilate_storage( &pallet_dapp_staking::GenesisConfig:: { reward_portion: vec![ @@ -308,9 +302,9 @@ impl ExternalityBuilder { }, ], slot_number_args: STANDARD_TIER_SLOTS_ARGS, - slots_per_tier, + slots_per_tier: vec![10, 20, 30, 40], safeguard: None, - tier_rank_multipliers, + tier_rank_multipliers: vec![10_000u32, 20_000, 20_000, 20_000], _config: PhantomData, }, &mut storage, From fc992714730b6160b0790c833c7b22d7cff1c041 Mon Sep 17 00:00:00 2001 From: Igor Papandinas <26460174+ipapandinas@users.noreply.github.com> Date: Mon, 9 Feb 2026 18:16:36 +0400 Subject: [PATCH 12/16] extra documentation --- pallets/dapp-staking/src/lib.rs | 76 ++- pallets/dapp-staking/src/types.rs | 9 +- .../astar/src/weights/pallet_dapp_staking.rs | 510 +++++++++++++----- .../src/weights/pallet_dapp_staking.rs | 510 +++++++++++++----- .../shiden/src/weights/pallet_dapp_staking.rs | 510 +++++++++++++----- 5 files changed, 1227 insertions(+), 388 deletions(-) diff --git a/pallets/dapp-staking/src/lib.rs b/pallets/dapp-staking/src/lib.rs index d63caea935..eade51c4c3 100644 --- a/pallets/dapp-staking/src/lib.rs +++ b/pallets/dapp-staking/src/lib.rs @@ -1865,7 +1865,6 @@ pub mod pallet { /// This information is used to calculate 'score' per dApp, which is used to determine the tier. /// /// 2. Sort the entries by the score, in descending order - the top score dApp comes first. - /// Ties are broken by dApp ID (ascending). /// /// 3. Assign dApps to tiers based on stake thresholds, calculating ratio-based ranks within each tier. /// @@ -1912,10 +1911,8 @@ pub mod pallet { } // 2. - // Sort descending by stake, ascending by dApp ID for ties - top dApp will end in the first place, 0th index. - dapp_stakes.sort_unstable_by(|(id_a, amount_a), (id_b, amount_b)| { - amount_b.cmp(amount_a).then_with(|| id_a.cmp(id_b)) - }); + // Sort by amount staked, in reverse - top dApp will end in the first place, 0th index. + dapp_stakes.sort_unstable_by(|(_, amount_1), (_, amount_2)| amount_2.cmp(amount_1)); let tier_config = TierConfig::::get(); let tier_params = StaticTierParams::::get(); @@ -1964,7 +1961,10 @@ pub mod pallet { // 4. Compute tier rewards using rank multiplier let filled_slots = tier_slots.len() as u32; - let ranks_sum: u32 = tier_slots.values().map(|rt| rt.rank() as u32).sum(); + // sum of all ranks for this tier + let ranks_sum = tier_slots + .iter() + .fold(0u32, |accum, (_, x)| accum.saturating_add(x.rank().into())); let multiplier_bips = tier_params .tier_rank_multipliers @@ -2472,49 +2472,71 @@ pub mod pallet { } /// Compute deterministic tier rewards params (base-0 reward and per-rank-step reward) - /// using rank-multiplier in bips (10_000 = 100%) + /// - `tier_base_reward0`: reward for rank 0 (base component) + /// - `reward_per_rank_step`: additional reward per +1 rank + /// `rank10_multiplier_bips` defines the weight at MAX_RANK relative to rank 0 (in bips, 10_000 = 100%) pub(crate) fn compute_tier_rewards( tier_allocation: Balance, tier_capacity: u16, filled_slots: u32, ranks_sum: u32, - multiplier_bips: u32, + rank10_multiplier_bips: u32, ) -> (Balance, Balance) { - const WEIGHT_UNIT: u128 = 10_000; // 100% in bips + const BASE_WEIGHT_BIPS: u128 = 10_000; // 100% in bips + let max_rank: u128 = RankedTier::MAX_RANK as u128; // 10 let avg_rank: u128 = max_rank / 2; // 5 + // If there is nothing to distribute or no participants, return zero components. if tier_allocation.is_zero() || tier_capacity == 0 || filled_slots == 0 { return (Balance::zero(), Balance::zero()); } - // weight(rank) = WEIGHT_UNIT + rank * inc_w, where: - // inc_w = (multiplier_bips - WEIGHT_UNIT) / MAX_RANK - let inc_w: u128 = (multiplier_bips as u128) - .saturating_sub(WEIGHT_UNIT) + // Convert "Rank 10 earns X% of Rank 0" into a linear per-rank-step extra weight: + // + // step_weight = (weight(MAX_RANK) - weight(0)) / MAX_RANK + // = (rank10_multiplier_bips - BASE_WEIGHT_BIPS) / MAX_RANK + let step_weight_bips: u128 = (rank10_multiplier_bips as u128) + .saturating_sub(BASE_WEIGHT_BIPS) .saturating_div(max_rank); - // actual_weight = filled_slots * WEIGHT_UNIT + inc_w * ranks_sum - let actual_weight: u128 = (filled_slots as u128) - .saturating_mul(WEIGHT_UNIT) - .saturating_add((ranks_sum as u128).saturating_mul(inc_w)); - - // target_weight = tier_capacity * avg_weight, avg_weight = WEIGHT_UNIT + avg_rank * inc_w - let avg_weight: u128 = WEIGHT_UNIT.saturating_add(avg_rank.saturating_mul(inc_w)); - let target_weight: u128 = (tier_capacity as u128).saturating_mul(avg_weight); + // Total weight contributed by currently occupied slots: + // + // Each slot contributes BASE_WEIGHT_BIPS + // Each rank point contributes step_weight_bips + // + // total_weight = filled_slots * BASE_WEIGHT_BIPS + sum(rank_i) * step_weight_bips + let observed_total_weight: u128 = (filled_slots as u128) + .saturating_mul(BASE_WEIGHT_BIPS) + .saturating_add((ranks_sum as u128).saturating_mul(step_weight_bips)); - let denom: u128 = actual_weight.max(target_weight); - if denom == 0 { + // "Normally filled tier" cap (prevents over-distribution when ranks collide, e.g. all MAX_RANK): + // + // Expected average slot weight if ranks are roughly evenly spread: + // avg_slot_weight = BASE_WEIGHT_BIPS + avg_rank * step_weight_bips + // expected_full_weight = tier_capacity * avg_slot_weight + let avg_slot_weight_bips: u128 = + BASE_WEIGHT_BIPS.saturating_add(avg_rank.saturating_mul(step_weight_bips)); + let expected_full_weight: u128 = + (tier_capacity as u128).saturating_mul(avg_slot_weight_bips); + + // Normalize by the larger of: + // - observed_total_weight: proportional distribution for partially filled tiers + // - expected_full_weight: cap for extreme rank distributions / collisions + let normalization_weight: u128 = observed_total_weight.max(expected_full_weight); + if normalization_weight == 0 { return (Balance::zero(), Balance::zero()); } let alloc: u128 = tier_allocation.into(); - let tier_reward0_u128 = alloc.saturating_mul(WEIGHT_UNIT) / denom; - let rank_reward_u128 = alloc.saturating_mul(inc_w) / denom; + let tier_base_reward0_u128 = + alloc.saturating_mul(BASE_WEIGHT_BIPS) / normalization_weight; + let reward_per_rank_step_u128 = + alloc.saturating_mul(step_weight_bips) / normalization_weight; ( - tier_reward0_u128.saturated_into::(), - rank_reward_u128.saturated_into::(), + tier_base_reward0_u128.saturated_into::(), + reward_per_rank_step_u128.saturated_into::(), ) } diff --git a/pallets/dapp-staking/src/types.rs b/pallets/dapp-staking/src/types.rs index b64e6b85a2..cb41f0b6af 100644 --- a/pallets/dapp-staking/src/types.rs +++ b/pallets/dapp-staking/src/types.rs @@ -1710,7 +1710,14 @@ pub struct TierParameters> { /// This can be made more generic in the future in case more complex equations are required. /// But for now this simple tuple serves the purpose. pub(crate) slot_number_args: (u64, u64), - /// Rank multiplier per tier in bips (100% = 10_000 bips): rank 10 reward as percentage of rank 0 reward. + /// Rank multiplier per tier in bips (100% = 10_000 bips): + /// defines how much rank 10 earns relative to rank 0. + /// + /// Example: + /// - `24_000` β†’ rank 10 earns 2.4Γ— rank 0 + /// β‡’ per-rank increment = (240% βˆ’ 100%) / 10 = +14% per rank + /// - `10_000` β†’ rank rewards disabled (rank 0..10 all earn the same) + /// - `0` β†’ no rewards for all slots pub(crate) tier_rank_multipliers: BoundedVec, } diff --git a/runtime/astar/src/weights/pallet_dapp_staking.rs b/runtime/astar/src/weights/pallet_dapp_staking.rs index 55a9756e00..027007d39c 100644 --- a/runtime/astar/src/weights/pallet_dapp_staking.rs +++ b/runtime/astar/src/weights/pallet_dapp_staking.rs @@ -20,7 +20,7 @@ //! Autogenerated weights for `pallet_dapp_staking` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2026-02-02, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2026-02-09, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `gh-runner-01-ovh`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` //! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024 @@ -56,231 +56,501 @@ impl pallet_dapp_staking::WeightInfo for SubstrateWeigh // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_461_000 picoseconds. - Weight::from_parts(8_677_000, 0) + // Minimum execution time: 8_359_000 picoseconds. + Weight::from_parts(8_596_000, 0) .saturating_add(Weight::from_parts(0, 0)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CounterForIntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::CounterForIntegratedDApps` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::NextDAppId` (r:1 w:1) + /// Proof: `DappStaking::NextDAppId` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) fn register() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `0` - // Minimum execution time: 16_555_000 picoseconds. - Weight::from_parts(16_964_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `3086` + // Minimum execution time: 16_561_000 picoseconds. + Weight::from_parts(16_759_000, 0) + .saturating_add(Weight::from_parts(0, 3086)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) fn set_dapp_reward_beneficiary() -> Weight { // Proof Size summary in bytes: // Measured: `97` - // Estimated: `0` - // Minimum execution time: 14_462_000 picoseconds. - Weight::from_parts(14_727_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `3086` + // Minimum execution time: 14_619_000 picoseconds. + Weight::from_parts(15_003_000, 0) + .saturating_add(Weight::from_parts(0, 3086)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) fn set_dapp_owner() -> Weight { // Proof Size summary in bytes: // Measured: `97` - // Estimated: `0` - // Minimum execution time: 14_304_000 picoseconds. - Weight::from_parts(14_657_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `3086` + // Minimum execution time: 14_892_000 picoseconds. + Weight::from_parts(15_238_000, 0) + .saturating_add(Weight::from_parts(0, 3086)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CounterForIntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::CounterForIntegratedDApps` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::ContractStake` (r:0 w:1) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) fn unregister() -> Weight { // Proof Size summary in bytes: // Measured: `97` - // Estimated: `0` - // Minimum execution time: 20_132_000 picoseconds. - Weight::from_parts(20_603_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `3086` + // Minimum execution time: 20_368_000 picoseconds. + Weight::from_parts(20_675_000, 0) + .saturating_add(Weight::from_parts(0, 3086)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `CollatorSelection::Candidates` (r:1 w:0) + /// Proof: `CollatorSelection::Candidates` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn lock_new_account() -> Weight { // Proof Size summary in bytes: // Measured: `138` - // Estimated: `0` - // Minimum execution time: 38_289_000 picoseconds. - Weight::from_parts(38_691_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 38_020_000 picoseconds. + Weight::from_parts(38_509_000, 0) + .saturating_add(Weight::from_parts(0, 4764)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn lock_existing_account() -> Weight { // Proof Size summary in bytes: // Measured: `158` - // Estimated: `0` - // Minimum execution time: 38_869_000 picoseconds. - Weight::from_parts(39_802_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 38_720_000 picoseconds. + Weight::from_parts(39_343_000, 0) + .saturating_add(Weight::from_parts(0, 4764)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn unlock() -> Weight { // Proof Size summary in bytes: // Measured: `158` - // Estimated: `0` - // Minimum execution time: 35_328_000 picoseconds. - Weight::from_parts(35_790_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 35_583_000 picoseconds. + Weight::from_parts(35_990_000, 0) + .saturating_add(Weight::from_parts(0, 4764)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) /// The range of component `x` is `[0, 16]`. fn claim_unlocked(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `190` - // Estimated: `0` - // Minimum execution time: 38_313_000 picoseconds. - Weight::from_parts(40_691_916, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 5_927 - .saturating_add(Weight::from_parts(101_758, 0).saturating_mul(x.into())) + // Estimated: `4764` + // Minimum execution time: 38_158_000 picoseconds. + Weight::from_parts(40_394_137, 0) + .saturating_add(Weight::from_parts(0, 4764)) + // Standard Error: 5_223 + .saturating_add(Weight::from_parts(92_010, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn relock_unlocking() -> Weight { // Proof Size summary in bytes: // Measured: `200` - // Estimated: `0` - // Minimum execution time: 35_715_000 picoseconds. - Weight::from_parts(36_117_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 35_034_000 picoseconds. + Weight::from_parts(35_760_000, 0) + .saturating_add(Weight::from_parts(0, 4764)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StakerInfo` (r:1 w:1) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::ContractStake` (r:1 w:1) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn stake() -> Weight { // Proof Size summary in bytes: // Measured: `274` - // Estimated: `0` - // Minimum execution time: 53_482_000 picoseconds. - Weight::from_parts(54_756_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 52_917_000 picoseconds. + Weight::from_parts(53_368_000, 0) + .saturating_add(Weight::from_parts(0, 4764)) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(5)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StakerInfo` (r:1 w:1) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::ContractStake` (r:1 w:1) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn unstake() -> Weight { // Proof Size summary in bytes: // Measured: `459` - // Estimated: `0` - // Minimum execution time: 58_638_000 picoseconds. - Weight::from_parts(59_292_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 57_250_000 picoseconds. + Weight::from_parts(59_104_000, 0) + .saturating_add(Weight::from_parts(0, 4764)) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(5)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:0) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::PeriodEnd` (r:1 w:0) + /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 16]`. fn claim_staker_rewards_past_period(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `541` - // Estimated: `0` - // Minimum execution time: 57_353_000 picoseconds. - Weight::from_parts(56_809_462, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 5_135 - .saturating_add(Weight::from_parts(1_956_816, 0).saturating_mul(x.into())) + // Estimated: `4764` + // Minimum execution time: 56_364_000 picoseconds. + Weight::from_parts(55_482_121, 0) + .saturating_add(Weight::from_parts(0, 4764)) + // Standard Error: 3_957 + .saturating_add(Weight::from_parts(1_941_267, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(2)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:0) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 16]`. fn claim_staker_rewards_ongoing_period(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `519` - // Estimated: `0` - // Minimum execution time: 54_268_000 picoseconds. - Weight::from_parts(53_207_081, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 7_050 - .saturating_add(Weight::from_parts(2_073_433, 0).saturating_mul(x.into())) + // Estimated: `4764` + // Minimum execution time: 53_777_000 picoseconds. + Weight::from_parts(52_564_857, 0) + .saturating_add(Weight::from_parts(0, 4764)) + // Standard Error: 7_719 + .saturating_add(Weight::from_parts(1_981_413, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) } + /// Storage: `DappStaking::StakerInfo` (r:1 w:1) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::PeriodEnd` (r:1 w:0) + /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) fn claim_bonus_reward() -> Weight { // Proof Size summary in bytes: // Measured: `275` - // Estimated: `0` - // Minimum execution time: 46_935_000 picoseconds. - Weight::from_parts(47_437_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `3775` + // Minimum execution time: 44_969_000 picoseconds. + Weight::from_parts(45_458_000, 0) + .saturating_add(Weight::from_parts(0, 3775)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::DAppTiers` (r:1 w:1) + /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn claim_dapp_reward() -> Weight { // Proof Size summary in bytes: - // Measured: `668` - // Estimated: `0` - // Minimum execution time: 30_151_000 picoseconds. - Weight::from_parts(30_749_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Measured: `647` + // Estimated: `5113` + // Minimum execution time: 29_381_000 picoseconds. + Weight::from_parts(30_312_000, 0) + .saturating_add(Weight::from_parts(0, 5113)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StakerInfo` (r:1 w:1) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn unstake_from_unregistered() -> Weight { // Proof Size summary in bytes: // Measured: `322` - // Estimated: `0` - // Minimum execution time: 48_601_000 picoseconds. - Weight::from_parts(49_205_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 48_616_000 picoseconds. + Weight::from_parts(49_290_000, 0) + .saturating_add(Weight::from_parts(0, 4764)) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: `DappStaking::StakerInfo` (r:17 w:16) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 16]`. fn cleanup_expired_entries(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `257 + x * (73 Β±0)` - // Estimated: `0` - // Minimum execution time: 46_242_000 picoseconds. - Weight::from_parts(43_292_594, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 13_352 - .saturating_add(Weight::from_parts(6_282_784, 0).saturating_mul(x.into())) + // Estimated: `4764 + x * (2653 Β±0)` + // Minimum execution time: 46_102_000 picoseconds. + Weight::from_parts(43_349_342, 0) + .saturating_add(Weight::from_parts(0, 4764)) + // Standard Error: 11_849 + .saturating_add(Weight::from_parts(6_251_196, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(x.into()))) + .saturating_add(Weight::from_parts(0, 2653).saturating_mul(x.into())) } + /// Storage: `DappStaking::Safeguard` (r:1 w:0) + /// Proof: `DappStaking::Safeguard` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) fn force() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `0` - // Minimum execution time: 11_385_000 picoseconds. - Weight::from_parts(11_569_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `1486` + // Minimum execution time: 11_945_000 picoseconds. + Weight::from_parts(12_232_000, 0) + .saturating_add(Weight::from_parts(0, 1486)) + .saturating_add(T::DbWeight::get().reads(1)) } + /// Storage: `DappStaking::IntegratedDApps` (r:2 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StakerInfo` (r:2 w:2) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::ContractStake` (r:2 w:2) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn move_stake_from_registered_source() -> Weight { // Proof Size summary in bytes: // Measured: `553` - // Estimated: `0` - // Minimum execution time: 91_389_000 picoseconds. - Weight::from_parts(92_244_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `6296` + // Minimum execution time: 91_271_000 picoseconds. + Weight::from_parts(91_921_000, 0) + .saturating_add(Weight::from_parts(0, 6296)) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().writes(7)) } + /// Storage: `DappStaking::IntegratedDApps` (r:2 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StakerInfo` (r:2 w:2) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::ContractStake` (r:1 w:1) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) fn move_stake_unregistered_source() -> Weight { // Proof Size summary in bytes: // Measured: `419` - // Estimated: `0` - // Minimum execution time: 82_041_000 picoseconds. - Weight::from_parts(83_143_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `6296` + // Minimum execution time: 82_417_000 picoseconds. + Weight::from_parts(83_201_000, 0) + .saturating_add(Weight::from_parts(0, 6296)) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(6)) } + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:1) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) + /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(120), added: 615, mode: `MaxEncodedLen`) + /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) + /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::TierConfig` (r:1 w:1) + /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) fn on_initialize_voting_to_build_and_earn() -> Weight { // Proof Size summary in bytes: - // Measured: `225` - // Estimated: `0` - // Minimum execution time: 25_935_000 picoseconds. - Weight::from_parts(26_354_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Measured: `217` + // Estimated: `4254` + // Minimum execution time: 26_079_000 picoseconds. + Weight::from_parts(26_756_000, 0) + .saturating_add(Weight::from_parts(0, 4254)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::PeriodEnd` (r:1 w:2) + /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::HistoryCleanupMarker` (r:1 w:1) + /// Proof: `DappStaking::HistoryCleanupMarker` (`max_values`: Some(1), `max_size`: Some(12), added: 507, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:1) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) + /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(120), added: 615, mode: `MaxEncodedLen`) + /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) + /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::TierConfig` (r:1 w:1) + /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::DAppTiers` (r:0 w:1) + /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn on_initialize_build_and_earn_to_voting() -> Weight { // Proof Size summary in bytes: - // Measured: `791` - // Estimated: `0` - // Minimum execution time: 48_127_000 picoseconds. - Weight::from_parts(48_815_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Measured: `783` + // Estimated: `4254` + // Minimum execution time: 49_334_000 picoseconds. + Weight::from_parts(50_631_000, 0) + .saturating_add(Weight::from_parts(0, 4254)) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(7)) } + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:1) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) + /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(120), added: 615, mode: `MaxEncodedLen`) + /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) + /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::TierConfig` (r:1 w:1) + /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::DAppTiers` (r:0 w:1) + /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn on_initialize_build_and_earn_to_build_and_earn() -> Weight { // Proof Size summary in bytes: - // Measured: `277` - // Estimated: `0` - // Minimum execution time: 29_870_000 picoseconds. - Weight::from_parts(30_278_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Measured: `269` + // Estimated: `4254` + // Minimum execution time: 30_195_000 picoseconds. + Weight::from_parts(30_873_000, 0) + .saturating_add(Weight::from_parts(0, 4254)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: `DappStaking::ContractStake` (r:17 w:0) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::TierConfig` (r:1 w:0) + /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) + /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(120), added: 615, mode: `MaxEncodedLen`) /// The range of component `x` is `[0, 16]`. fn dapp_tier_assignment(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `218 + x * (33 Β±0)` - // Estimated: `0` - // Minimum execution time: 11_764_000 picoseconds. - Weight::from_parts(15_737_959, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 15_337 - .saturating_add(Weight::from_parts(3_019_595, 0).saturating_mul(x.into())) + // Measured: `210 + x * (33 Β±0)` + // Estimated: `3061 + x * (2071 Β±0)` + // Minimum execution time: 10_336_000 picoseconds. + Weight::from_parts(14_531_778, 0) + .saturating_add(Weight::from_parts(0, 3061)) + // Standard Error: 16_087 + .saturating_add(Weight::from_parts(3_114_631, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(Weight::from_parts(0, 2071).saturating_mul(x.into())) } + /// Storage: `DappStaking::HistoryCleanupMarker` (r:1 w:1) + /// Proof: `DappStaking::HistoryCleanupMarker` (`max_values`: Some(1), `max_size`: Some(12), added: 507, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:1) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::DAppTiers` (r:0 w:1) + /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn on_idle_cleanup() -> Weight { // Proof Size summary in bytes: // Measured: `293` - // Estimated: `0` - // Minimum execution time: 10_067_000 picoseconds. - Weight::from_parts(10_287_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4254` + // Minimum execution time: 9_785_000 picoseconds. + Weight::from_parts(10_057_000, 0) + .saturating_add(Weight::from_parts(0, 4254)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::StaticTierParams` (r:0 w:1) + /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(120), added: 615, mode: `MaxEncodedLen`) fn set_static_tier_params() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 11_443_000 picoseconds. - Weight::from_parts(11_654_000, 0) + // Minimum execution time: 10_291_000 picoseconds. + Weight::from_parts(10_454_000, 0) .saturating_add(Weight::from_parts(0, 0)) + .saturating_add(T::DbWeight::get().writes(1)) } } diff --git a/runtime/shibuya/src/weights/pallet_dapp_staking.rs b/runtime/shibuya/src/weights/pallet_dapp_staking.rs index 5f28819752..9fcb2939c5 100644 --- a/runtime/shibuya/src/weights/pallet_dapp_staking.rs +++ b/runtime/shibuya/src/weights/pallet_dapp_staking.rs @@ -20,7 +20,7 @@ //! Autogenerated weights for `pallet_dapp_staking` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2026-02-02, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2026-02-09, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `gh-runner-01-ovh`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` //! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024 @@ -56,231 +56,501 @@ impl pallet_dapp_staking::WeightInfo for SubstrateWeigh // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_290_000 picoseconds. - Weight::from_parts(8_493_000, 0) + // Minimum execution time: 8_218_000 picoseconds. + Weight::from_parts(8_408_000, 0) .saturating_add(Weight::from_parts(0, 0)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CounterForIntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::CounterForIntegratedDApps` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::NextDAppId` (r:1 w:1) + /// Proof: `DappStaking::NextDAppId` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) fn register() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `0` - // Minimum execution time: 16_770_000 picoseconds. - Weight::from_parts(17_066_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `3086` + // Minimum execution time: 16_500_000 picoseconds. + Weight::from_parts(16_772_000, 0) + .saturating_add(Weight::from_parts(0, 3086)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) fn set_dapp_reward_beneficiary() -> Weight { // Proof Size summary in bytes: // Measured: `97` - // Estimated: `0` - // Minimum execution time: 14_545_000 picoseconds. - Weight::from_parts(14_908_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `3086` + // Minimum execution time: 14_766_000 picoseconds. + Weight::from_parts(14_967_000, 0) + .saturating_add(Weight::from_parts(0, 3086)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) fn set_dapp_owner() -> Weight { // Proof Size summary in bytes: // Measured: `97` - // Estimated: `0` - // Minimum execution time: 14_518_000 picoseconds. - Weight::from_parts(14_856_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `3086` + // Minimum execution time: 14_077_000 picoseconds. + Weight::from_parts(14_713_000, 0) + .saturating_add(Weight::from_parts(0, 3086)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CounterForIntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::CounterForIntegratedDApps` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::ContractStake` (r:0 w:1) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) fn unregister() -> Weight { // Proof Size summary in bytes: // Measured: `97` - // Estimated: `0` - // Minimum execution time: 20_385_000 picoseconds. - Weight::from_parts(20_858_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `3086` + // Minimum execution time: 20_011_000 picoseconds. + Weight::from_parts(20_465_000, 0) + .saturating_add(Weight::from_parts(0, 3086)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `CollatorSelection::Candidates` (r:1 w:0) + /// Proof: `CollatorSelection::Candidates` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn lock_new_account() -> Weight { // Proof Size summary in bytes: // Measured: `138` - // Estimated: `0` - // Minimum execution time: 38_845_000 picoseconds. - Weight::from_parts(39_782_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 38_183_000 picoseconds. + Weight::from_parts(38_650_000, 0) + .saturating_add(Weight::from_parts(0, 4764)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn lock_existing_account() -> Weight { // Proof Size summary in bytes: // Measured: `156` - // Estimated: `0` - // Minimum execution time: 39_325_000 picoseconds. - Weight::from_parts(39_763_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 39_542_000 picoseconds. + Weight::from_parts(40_046_000, 0) + .saturating_add(Weight::from_parts(0, 4764)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn unlock() -> Weight { // Proof Size summary in bytes: // Measured: `156` - // Estimated: `0` - // Minimum execution time: 36_390_000 picoseconds. - Weight::from_parts(36_779_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 35_821_000 picoseconds. + Weight::from_parts(36_591_000, 0) + .saturating_add(Weight::from_parts(0, 4764)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) /// The range of component `x` is `[0, 8]`. fn claim_unlocked(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `187` - // Estimated: `0` - // Minimum execution time: 38_863_000 picoseconds. - Weight::from_parts(40_578_112, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 9_609 - .saturating_add(Weight::from_parts(282_019, 0).saturating_mul(x.into())) + // Estimated: `4764` + // Minimum execution time: 38_015_000 picoseconds. + Weight::from_parts(40_043_292, 0) + .saturating_add(Weight::from_parts(0, 4764)) + // Standard Error: 9_733 + .saturating_add(Weight::from_parts(252_507, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn relock_unlocking() -> Weight { // Proof Size summary in bytes: // Measured: `182` - // Estimated: `0` - // Minimum execution time: 35_361_000 picoseconds. - Weight::from_parts(35_932_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 35_172_000 picoseconds. + Weight::from_parts(35_870_000, 0) + .saturating_add(Weight::from_parts(0, 4764)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StakerInfo` (r:1 w:1) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::ContractStake` (r:1 w:1) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn stake() -> Weight { // Proof Size summary in bytes: // Measured: `272` - // Estimated: `0` - // Minimum execution time: 53_590_000 picoseconds. - Weight::from_parts(54_368_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 53_682_000 picoseconds. + Weight::from_parts(54_348_000, 0) + .saturating_add(Weight::from_parts(0, 4764)) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(5)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StakerInfo` (r:1 w:1) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::ContractStake` (r:1 w:1) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn unstake() -> Weight { // Proof Size summary in bytes: // Measured: `453` - // Estimated: `0` - // Minimum execution time: 58_914_000 picoseconds. - Weight::from_parts(59_895_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 58_426_000 picoseconds. + Weight::from_parts(59_415_000, 0) + .saturating_add(Weight::from_parts(0, 4764)) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(5)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:0) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::PeriodEnd` (r:1 w:0) + /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 16]`. fn claim_staker_rewards_past_period(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `522` - // Estimated: `0` - // Minimum execution time: 57_327_000 picoseconds. - Weight::from_parts(56_493_558, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 6_009 - .saturating_add(Weight::from_parts(1_994_730, 0).saturating_mul(x.into())) + // Estimated: `4764` + // Minimum execution time: 56_624_000 picoseconds. + Weight::from_parts(55_677_682, 0) + .saturating_add(Weight::from_parts(0, 4764)) + // Standard Error: 5_007 + .saturating_add(Weight::from_parts(1_950_486, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(2)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:0) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 16]`. fn claim_staker_rewards_ongoing_period(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `501` - // Estimated: `0` - // Minimum execution time: 54_277_000 picoseconds. - Weight::from_parts(53_284_580, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 4_814 - .saturating_add(Weight::from_parts(2_015_560, 0).saturating_mul(x.into())) + // Estimated: `4764` + // Minimum execution time: 52_994_000 picoseconds. + Weight::from_parts(52_316_116, 0) + .saturating_add(Weight::from_parts(0, 4764)) + // Standard Error: 6_182 + .saturating_add(Weight::from_parts(1_999_131, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) } + /// Storage: `DappStaking::StakerInfo` (r:1 w:1) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::PeriodEnd` (r:1 w:0) + /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) fn claim_bonus_reward() -> Weight { // Proof Size summary in bytes: // Measured: `271` - // Estimated: `0` - // Minimum execution time: 46_394_000 picoseconds. - Weight::from_parts(46_811_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `3775` + // Minimum execution time: 45_018_000 picoseconds. + Weight::from_parts(45_523_000, 0) + .saturating_add(Weight::from_parts(0, 3775)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::DAppTiers` (r:1 w:1) + /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn claim_dapp_reward() -> Weight { // Proof Size summary in bytes: - // Measured: `668` - // Estimated: `0` - // Minimum execution time: 30_398_000 picoseconds. - Weight::from_parts(31_453_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Measured: `647` + // Estimated: `5113` + // Minimum execution time: 29_934_000 picoseconds. + Weight::from_parts(30_849_000, 0) + .saturating_add(Weight::from_parts(0, 5113)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StakerInfo` (r:1 w:1) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn unstake_from_unregistered() -> Weight { // Proof Size summary in bytes: // Measured: `317` - // Estimated: `0` - // Minimum execution time: 49_106_000 picoseconds. - Weight::from_parts(49_724_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 48_491_000 picoseconds. + Weight::from_parts(49_049_000, 0) + .saturating_add(Weight::from_parts(0, 4764)) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: `DappStaking::StakerInfo` (r:9 w:8) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 8]`. fn cleanup_expired_entries(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `255 + x * (73 Β±0)` - // Estimated: `0` - // Minimum execution time: 46_769_000 picoseconds. - Weight::from_parts(42_908_204, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 26_105 - .saturating_add(Weight::from_parts(6_690_680, 0).saturating_mul(x.into())) + // Estimated: `4764 + x * (2653 Β±0)` + // Minimum execution time: 45_909_000 picoseconds. + Weight::from_parts(42_688_809, 0) + .saturating_add(Weight::from_parts(0, 4764)) + // Standard Error: 25_553 + .saturating_add(Weight::from_parts(6_474_373, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(x.into()))) + .saturating_add(Weight::from_parts(0, 2653).saturating_mul(x.into())) } + /// Storage: `DappStaking::Safeguard` (r:1 w:0) + /// Proof: `DappStaking::Safeguard` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) fn force() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `0` - // Minimum execution time: 11_657_000 picoseconds. - Weight::from_parts(12_135_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `1486` + // Minimum execution time: 11_725_000 picoseconds. + Weight::from_parts(11_947_000, 0) + .saturating_add(Weight::from_parts(0, 1486)) + .saturating_add(T::DbWeight::get().reads(1)) } + /// Storage: `DappStaking::IntegratedDApps` (r:2 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StakerInfo` (r:2 w:2) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::ContractStake` (r:2 w:2) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn move_stake_from_registered_source() -> Weight { // Proof Size summary in bytes: // Measured: `547` - // Estimated: `0` - // Minimum execution time: 92_997_000 picoseconds. - Weight::from_parts(93_781_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `6296` + // Minimum execution time: 91_825_000 picoseconds. + Weight::from_parts(93_938_000, 0) + .saturating_add(Weight::from_parts(0, 6296)) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().writes(7)) } + /// Storage: `DappStaking::IntegratedDApps` (r:2 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StakerInfo` (r:2 w:2) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::ContractStake` (r:1 w:1) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) fn move_stake_unregistered_source() -> Weight { // Proof Size summary in bytes: // Measured: `414` - // Estimated: `0` - // Minimum execution time: 83_926_000 picoseconds. - Weight::from_parts(84_700_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `6296` + // Minimum execution time: 82_364_000 picoseconds. + Weight::from_parts(83_002_000, 0) + .saturating_add(Weight::from_parts(0, 6296)) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(6)) } + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:1) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) + /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(120), added: 615, mode: `MaxEncodedLen`) + /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) + /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::TierConfig` (r:1 w:1) + /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) fn on_initialize_voting_to_build_and_earn() -> Weight { // Proof Size summary in bytes: - // Measured: `225` - // Estimated: `0` - // Minimum execution time: 26_133_000 picoseconds. - Weight::from_parts(26_567_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Measured: `217` + // Estimated: `4254` + // Minimum execution time: 26_215_000 picoseconds. + Weight::from_parts(26_804_000, 0) + .saturating_add(Weight::from_parts(0, 4254)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::PeriodEnd` (r:1 w:2) + /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::HistoryCleanupMarker` (r:1 w:1) + /// Proof: `DappStaking::HistoryCleanupMarker` (`max_values`: Some(1), `max_size`: Some(12), added: 507, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:1) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) + /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(120), added: 615, mode: `MaxEncodedLen`) + /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) + /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::TierConfig` (r:1 w:1) + /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::DAppTiers` (r:0 w:1) + /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn on_initialize_build_and_earn_to_voting() -> Weight { // Proof Size summary in bytes: - // Measured: `327` - // Estimated: `0` - // Minimum execution time: 43_212_000 picoseconds. - Weight::from_parts(43_696_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Measured: `319` + // Estimated: `4254` + // Minimum execution time: 43_593_000 picoseconds. + Weight::from_parts(44_523_000, 0) + .saturating_add(Weight::from_parts(0, 4254)) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(7)) } + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:1) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) + /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(120), added: 615, mode: `MaxEncodedLen`) + /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) + /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::TierConfig` (r:1 w:1) + /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::DAppTiers` (r:0 w:1) + /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn on_initialize_build_and_earn_to_build_and_earn() -> Weight { // Proof Size summary in bytes: - // Measured: `279` - // Estimated: `0` - // Minimum execution time: 29_729_000 picoseconds. - Weight::from_parts(30_321_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Measured: `271` + // Estimated: `4254` + // Minimum execution time: 30_321_000 picoseconds. + Weight::from_parts(30_746_000, 0) + .saturating_add(Weight::from_parts(0, 4254)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: `DappStaking::ContractStake` (r:17 w:0) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::TierConfig` (r:1 w:0) + /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) + /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(120), added: 615, mode: `MaxEncodedLen`) /// The range of component `x` is `[0, 16]`. fn dapp_tier_assignment(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `218 + x * (33 Β±0)` - // Estimated: `0` - // Minimum execution time: 11_643_000 picoseconds. - Weight::from_parts(15_765_186, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 16_284 - .saturating_add(Weight::from_parts(3_069_787, 0).saturating_mul(x.into())) + // Measured: `210 + x * (33 Β±0)` + // Estimated: `3061 + x * (2071 Β±0)` + // Minimum execution time: 10_351_000 picoseconds. + Weight::from_parts(14_594_020, 0) + .saturating_add(Weight::from_parts(0, 3061)) + // Standard Error: 16_557 + .saturating_add(Weight::from_parts(3_096_286, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(Weight::from_parts(0, 2071).saturating_mul(x.into())) } + /// Storage: `DappStaking::HistoryCleanupMarker` (r:1 w:1) + /// Proof: `DappStaking::HistoryCleanupMarker` (`max_values`: Some(1), `max_size`: Some(12), added: 507, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:1) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::DAppTiers` (r:0 w:1) + /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn on_idle_cleanup() -> Weight { // Proof Size summary in bytes: // Measured: `293` - // Estimated: `0` - // Minimum execution time: 9_947_000 picoseconds. - Weight::from_parts(10_127_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4254` + // Minimum execution time: 10_116_000 picoseconds. + Weight::from_parts(10_358_000, 0) + .saturating_add(Weight::from_parts(0, 4254)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::StaticTierParams` (r:0 w:1) + /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(120), added: 615, mode: `MaxEncodedLen`) fn set_static_tier_params() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 11_447_000 picoseconds. - Weight::from_parts(11_859_000, 0) + // Minimum execution time: 10_305_000 picoseconds. + Weight::from_parts(10_688_000, 0) .saturating_add(Weight::from_parts(0, 0)) + .saturating_add(T::DbWeight::get().writes(1)) } } diff --git a/runtime/shiden/src/weights/pallet_dapp_staking.rs b/runtime/shiden/src/weights/pallet_dapp_staking.rs index 549c030e2a..ab99285af2 100644 --- a/runtime/shiden/src/weights/pallet_dapp_staking.rs +++ b/runtime/shiden/src/weights/pallet_dapp_staking.rs @@ -20,7 +20,7 @@ //! Autogenerated weights for `pallet_dapp_staking` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2026-02-02, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2026-02-09, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `gh-runner-01-ovh`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` //! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024 @@ -56,231 +56,501 @@ impl pallet_dapp_staking::WeightInfo for SubstrateWeigh // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_284_000 picoseconds. - Weight::from_parts(8_403_000, 0) + // Minimum execution time: 8_280_000 picoseconds. + Weight::from_parts(8_456_000, 0) .saturating_add(Weight::from_parts(0, 0)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CounterForIntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::CounterForIntegratedDApps` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::NextDAppId` (r:1 w:1) + /// Proof: `DappStaking::NextDAppId` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) fn register() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `0` - // Minimum execution time: 16_715_000 picoseconds. - Weight::from_parts(16_985_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `3086` + // Minimum execution time: 16_622_000 picoseconds. + Weight::from_parts(16_904_000, 0) + .saturating_add(Weight::from_parts(0, 3086)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) fn set_dapp_reward_beneficiary() -> Weight { // Proof Size summary in bytes: // Measured: `97` - // Estimated: `0` - // Minimum execution time: 14_530_000 picoseconds. - Weight::from_parts(14_745_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `3086` + // Minimum execution time: 14_462_000 picoseconds. + Weight::from_parts(14_739_000, 0) + .saturating_add(Weight::from_parts(0, 3086)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) fn set_dapp_owner() -> Weight { // Proof Size summary in bytes: // Measured: `97` - // Estimated: `0` - // Minimum execution time: 14_716_000 picoseconds. - Weight::from_parts(15_057_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `3086` + // Minimum execution time: 14_468_000 picoseconds. + Weight::from_parts(14_671_000, 0) + .saturating_add(Weight::from_parts(0, 3086)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CounterForIntegratedDApps` (r:1 w:1) + /// Proof: `DappStaking::CounterForIntegratedDApps` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::ContractStake` (r:0 w:1) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) fn unregister() -> Weight { // Proof Size summary in bytes: // Measured: `97` - // Estimated: `0` - // Minimum execution time: 20_279_000 picoseconds. - Weight::from_parts(20_656_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `3086` + // Minimum execution time: 20_495_000 picoseconds. + Weight::from_parts(20_964_000, 0) + .saturating_add(Weight::from_parts(0, 3086)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `CollatorSelection::Candidates` (r:1 w:0) + /// Proof: `CollatorSelection::Candidates` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn lock_new_account() -> Weight { // Proof Size summary in bytes: // Measured: `138` - // Estimated: `0` - // Minimum execution time: 38_413_000 picoseconds. - Weight::from_parts(38_861_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 38_428_000 picoseconds. + Weight::from_parts(38_798_000, 0) + .saturating_add(Weight::from_parts(0, 4764)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn lock_existing_account() -> Weight { // Proof Size summary in bytes: // Measured: `158` - // Estimated: `0` - // Minimum execution time: 39_039_000 picoseconds. - Weight::from_parts(39_461_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 38_829_000 picoseconds. + Weight::from_parts(39_266_000, 0) + .saturating_add(Weight::from_parts(0, 4764)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn unlock() -> Weight { // Proof Size summary in bytes: // Measured: `158` - // Estimated: `0` - // Minimum execution time: 35_493_000 picoseconds. - Weight::from_parts(36_071_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 35_863_000 picoseconds. + Weight::from_parts(36_365_000, 0) + .saturating_add(Weight::from_parts(0, 4764)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) /// The range of component `x` is `[0, 16]`. fn claim_unlocked(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `189` - // Estimated: `0` - // Minimum execution time: 38_457_000 picoseconds. - Weight::from_parts(40_704_516, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 5_739 - .saturating_add(Weight::from_parts(119_879, 0).saturating_mul(x.into())) + // Estimated: `4764` + // Minimum execution time: 38_247_000 picoseconds. + Weight::from_parts(40_280_703, 0) + .saturating_add(Weight::from_parts(0, 4764)) + // Standard Error: 5_227 + .saturating_add(Weight::from_parts(125_927, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) fn relock_unlocking() -> Weight { // Proof Size summary in bytes: // Measured: `200` - // Estimated: `0` - // Minimum execution time: 35_394_000 picoseconds. - Weight::from_parts(36_170_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 35_717_000 picoseconds. + Weight::from_parts(36_019_000, 0) + .saturating_add(Weight::from_parts(0, 4764)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StakerInfo` (r:1 w:1) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::ContractStake` (r:1 w:1) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn stake() -> Weight { // Proof Size summary in bytes: // Measured: `274` - // Estimated: `0` - // Minimum execution time: 52_850_000 picoseconds. - Weight::from_parts(53_469_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 52_590_000 picoseconds. + Weight::from_parts(53_038_000, 0) + .saturating_add(Weight::from_parts(0, 4764)) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(5)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StakerInfo` (r:1 w:1) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::ContractStake` (r:1 w:1) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn unstake() -> Weight { // Proof Size summary in bytes: // Measured: `459` - // Estimated: `0` - // Minimum execution time: 58_136_000 picoseconds. - Weight::from_parts(58_441_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 57_593_000 picoseconds. + Weight::from_parts(58_246_000, 0) + .saturating_add(Weight::from_parts(0, 4764)) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(5)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:0) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::PeriodEnd` (r:1 w:0) + /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 16]`. fn claim_staker_rewards_past_period(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `542` - // Estimated: `0` - // Minimum execution time: 56_809_000 picoseconds. - Weight::from_parts(56_700_953, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 6_049 - .saturating_add(Weight::from_parts(1_919_321, 0).saturating_mul(x.into())) + // Estimated: `4764` + // Minimum execution time: 56_652_000 picoseconds. + Weight::from_parts(55_962_135, 0) + .saturating_add(Weight::from_parts(0, 4764)) + // Standard Error: 5_616 + .saturating_add(Weight::from_parts(1_951_061, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(2)) } + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:0) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 16]`. fn claim_staker_rewards_ongoing_period(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `519` - // Estimated: `0` - // Minimum execution time: 54_361_000 picoseconds. - Weight::from_parts(53_687_425, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 4_685 - .saturating_add(Weight::from_parts(1_930_615, 0).saturating_mul(x.into())) + // Estimated: `4764` + // Minimum execution time: 54_015_000 picoseconds. + Weight::from_parts(52_814_143, 0) + .saturating_add(Weight::from_parts(0, 4764)) + // Standard Error: 4_824 + .saturating_add(Weight::from_parts(1_967_369, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) } + /// Storage: `DappStaking::StakerInfo` (r:1 w:1) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::PeriodEnd` (r:1 w:0) + /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) fn claim_bonus_reward() -> Weight { // Proof Size summary in bytes: // Measured: `276` - // Estimated: `0` - // Minimum execution time: 45_190_000 picoseconds. - Weight::from_parts(45_715_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `3775` + // Minimum execution time: 44_776_000 picoseconds. + Weight::from_parts(45_395_000, 0) + .saturating_add(Weight::from_parts(0, 3775)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::DAppTiers` (r:1 w:1) + /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn claim_dapp_reward() -> Weight { // Proof Size summary in bytes: - // Measured: `668` - // Estimated: `0` - // Minimum execution time: 30_344_000 picoseconds. - Weight::from_parts(30_619_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Measured: `647` + // Estimated: `5113` + // Minimum execution time: 29_711_000 picoseconds. + Weight::from_parts(30_057_000, 0) + .saturating_add(Weight::from_parts(0, 5113)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: `DappStaking::IntegratedDApps` (r:1 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StakerInfo` (r:1 w:1) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn unstake_from_unregistered() -> Weight { // Proof Size summary in bytes: // Measured: `322` - // Estimated: `0` - // Minimum execution time: 49_148_000 picoseconds. - Weight::from_parts(49_635_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4764` + // Minimum execution time: 48_660_000 picoseconds. + Weight::from_parts(49_341_000, 0) + .saturating_add(Weight::from_parts(0, 4764)) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: `DappStaking::StakerInfo` (r:17 w:16) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 16]`. fn cleanup_expired_entries(x: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `256 + x * (73 Β±0)` - // Estimated: `0` - // Minimum execution time: 46_828_000 picoseconds. - Weight::from_parts(43_928_951, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 13_864 - .saturating_add(Weight::from_parts(6_099_811, 0).saturating_mul(x.into())) + // Estimated: `4764 + x * (2653 Β±0)` + // Minimum execution time: 46_407_000 picoseconds. + Weight::from_parts(43_255_547, 0) + .saturating_add(Weight::from_parts(0, 4764)) + // Standard Error: 12_717 + .saturating_add(Weight::from_parts(6_228_978, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(x.into()))) + .saturating_add(Weight::from_parts(0, 2653).saturating_mul(x.into())) } + /// Storage: `DappStaking::Safeguard` (r:1 w:0) + /// Proof: `DappStaking::Safeguard` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) fn force() -> Weight { // Proof Size summary in bytes: // Measured: `0` - // Estimated: `0` - // Minimum execution time: 11_492_000 picoseconds. - Weight::from_parts(11_709_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `1486` + // Minimum execution time: 11_856_000 picoseconds. + Weight::from_parts(11_948_000, 0) + .saturating_add(Weight::from_parts(0, 1486)) + .saturating_add(T::DbWeight::get().reads(1)) } + /// Storage: `DappStaking::IntegratedDApps` (r:2 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StakerInfo` (r:2 w:2) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::ContractStake` (r:2 w:2) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) fn move_stake_from_registered_source() -> Weight { // Proof Size summary in bytes: // Measured: `553` - // Estimated: `0` - // Minimum execution time: 91_791_000 picoseconds. - Weight::from_parts(92_341_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `6296` + // Minimum execution time: 91_206_000 picoseconds. + Weight::from_parts(93_356_000, 0) + .saturating_add(Weight::from_parts(0, 6296)) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().writes(7)) } + /// Storage: `DappStaking::IntegratedDApps` (r:2 w:0) + /// Proof: `DappStaking::IntegratedDApps` (`max_values`: Some(65535), `max_size`: Some(116), added: 2096, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StakerInfo` (r:2 w:2) + /// Proof: `DappStaking::StakerInfo` (`max_values`: None, `max_size`: Some(178), added: 2653, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::Ledger` (r:1 w:1) + /// Proof: `DappStaking::Ledger` (`max_values`: None, `max_size`: Some(310), added: 2785, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Freezes` (r:1 w:1) + /// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`) + /// Storage: `Balances::Locks` (r:1 w:0) + /// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::ContractStake` (r:1 w:1) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) fn move_stake_unregistered_source() -> Weight { // Proof Size summary in bytes: // Measured: `419` - // Estimated: `0` - // Minimum execution time: 82_678_000 picoseconds. - Weight::from_parts(84_812_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `6296` + // Minimum execution time: 81_729_000 picoseconds. + Weight::from_parts(82_562_000, 0) + .saturating_add(Weight::from_parts(0, 6296)) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(6)) } + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:1) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) + /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(120), added: 615, mode: `MaxEncodedLen`) + /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) + /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::TierConfig` (r:1 w:1) + /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) fn on_initialize_voting_to_build_and_earn() -> Weight { // Proof Size summary in bytes: - // Measured: `225` - // Estimated: `0` - // Minimum execution time: 25_957_000 picoseconds. - Weight::from_parts(26_266_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Measured: `217` + // Estimated: `4254` + // Minimum execution time: 25_962_000 picoseconds. + Weight::from_parts(26_436_000, 0) + .saturating_add(Weight::from_parts(0, 4254)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::PeriodEnd` (r:1 w:2) + /// Proof: `DappStaking::PeriodEnd` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::HistoryCleanupMarker` (r:1 w:1) + /// Proof: `DappStaking::HistoryCleanupMarker` (`max_values`: Some(1), `max_size`: Some(12), added: 507, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:1) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) + /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(120), added: 615, mode: `MaxEncodedLen`) + /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) + /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::TierConfig` (r:1 w:1) + /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::DAppTiers` (r:0 w:1) + /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn on_initialize_build_and_earn_to_voting() -> Weight { // Proof Size summary in bytes: - // Measured: `880` - // Estimated: `0` - // Minimum execution time: 49_722_000 picoseconds. - Weight::from_parts(50_675_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Measured: `872` + // Estimated: `4254` + // Minimum execution time: 50_891_000 picoseconds. + Weight::from_parts(51_993_000, 0) + .saturating_add(Weight::from_parts(0, 4254)) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(7)) } + /// Storage: `DappStaking::CurrentEraInfo` (r:1 w:1) + /// Proof: `DappStaking::CurrentEraInfo` (`max_values`: Some(1), `max_size`: Some(112), added: 607, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:1) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) + /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(120), added: 615, mode: `MaxEncodedLen`) + /// Storage: `PriceAggregator::ValuesCircularBuffer` (r:1 w:0) + /// Proof: `PriceAggregator::ValuesCircularBuffer` (`max_values`: Some(1), `max_size`: Some(117), added: 612, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::TierConfig` (r:1 w:1) + /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::DAppTiers` (r:0 w:1) + /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn on_initialize_build_and_earn_to_build_and_earn() -> Weight { // Proof Size summary in bytes: - // Measured: `279` - // Estimated: `0` - // Minimum execution time: 30_400_000 picoseconds. - Weight::from_parts(30_884_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Measured: `271` + // Estimated: `4254` + // Minimum execution time: 29_688_000 picoseconds. + Weight::from_parts(30_217_000, 0) + .saturating_add(Weight::from_parts(0, 4254)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: `DappStaking::ContractStake` (r:17 w:0) + /// Proof: `DappStaking::ContractStake` (`max_values`: Some(65535), `max_size`: Some(91), added: 2071, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::TierConfig` (r:1 w:0) + /// Proof: `DappStaking::TierConfig` (`max_values`: Some(1), `max_size`: Some(91), added: 586, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::StaticTierParams` (r:1 w:0) + /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(120), added: 615, mode: `MaxEncodedLen`) /// The range of component `x` is `[0, 16]`. fn dapp_tier_assignment(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `218 + x * (33 Β±0)` - // Estimated: `0` - // Minimum execution time: 11_893_000 picoseconds. - Weight::from_parts(15_926_884, 0) - .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 16_911 - .saturating_add(Weight::from_parts(3_091_031, 0).saturating_mul(x.into())) + // Measured: `210 + x * (33 Β±0)` + // Estimated: `3061 + x * (2071 Β±0)` + // Minimum execution time: 10_061_000 picoseconds. + Weight::from_parts(14_133_143, 0) + .saturating_add(Weight::from_parts(0, 3061)) + // Standard Error: 15_779 + .saturating_add(Weight::from_parts(3_146_293, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(Weight::from_parts(0, 2071).saturating_mul(x.into())) } + /// Storage: `DappStaking::HistoryCleanupMarker` (r:1 w:1) + /// Proof: `DappStaking::HistoryCleanupMarker` (`max_values`: Some(1), `max_size`: Some(12), added: 507, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::EraRewards` (r:1 w:1) + /// Proof: `DappStaking::EraRewards` (`max_values`: None, `max_size`: Some(789), added: 3264, mode: `MaxEncodedLen`) + /// Storage: `DappStaking::DAppTiers` (r:0 w:1) + /// Proof: `DappStaking::DAppTiers` (`max_values`: None, `max_size`: Some(1648), added: 4123, mode: `MaxEncodedLen`) fn on_idle_cleanup() -> Weight { // Proof Size summary in bytes: // Measured: `293` - // Estimated: `0` - // Minimum execution time: 9_940_000 picoseconds. - Weight::from_parts(10_091_000, 0) - .saturating_add(Weight::from_parts(0, 0)) + // Estimated: `4254` + // Minimum execution time: 9_736_000 picoseconds. + Weight::from_parts(9_989_000, 0) + .saturating_add(Weight::from_parts(0, 4254)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `DappStaking::StaticTierParams` (r:0 w:1) + /// Proof: `DappStaking::StaticTierParams` (`max_values`: Some(1), `max_size`: Some(120), added: 615, mode: `MaxEncodedLen`) fn set_static_tier_params() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 11_343_000 picoseconds. - Weight::from_parts(11_825_000, 0) + // Minimum execution time: 9_985_000 picoseconds. + Weight::from_parts(10_242_000, 0) .saturating_add(Weight::from_parts(0, 0)) + .saturating_add(T::DbWeight::get().writes(1)) } } From 7bac318a7b95ece2eff81559e554e4b23fce3012 Mon Sep 17 00:00:00 2001 From: Igor Papandinas <26460174+ipapandinas@users.noreply.github.com> Date: Mon, 9 Feb 2026 19:36:03 +0400 Subject: [PATCH 13/16] migration enhancements --- pallets/dapp-staking/src/migration.rs | 31 ++++++++++++++++++--------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/pallets/dapp-staking/src/migration.rs b/pallets/dapp-staking/src/migration.rs index 462b81745c..34598b4f0e 100644 --- a/pallets/dapp-staking/src/migration.rs +++ b/pallets/dapp-staking/src/migration.rs @@ -116,16 +116,17 @@ mod v11 { let mut writes: u64 = 0; // 1. Migrate StaticTierParams + let reward_portion = BoundedVec::::truncate_from(P::reward_portion().to_vec()); + let slot_distribution = BoundedVec::::truncate_from(P::slot_distribution().to_vec()); + let tier_thresholds = BoundedVec::::truncate_from(P::tier_thresholds().to_vec()); + let tier_rank_multipliers = BoundedVec::::truncate_from(P::tier_rank_multipliers().to_vec()); + let new_params = TierParameters:: { - reward_portion: BoundedVec::try_from(P::reward_portion().to_vec()) - .expect("4 tiers configured"), - slot_distribution: BoundedVec::try_from(P::slot_distribution().to_vec()) - .expect("4 tiers configured"), - tier_thresholds: BoundedVec::try_from(P::tier_thresholds().to_vec()) - .expect("4 tiers configured"), + reward_portion, + slot_distribution, + tier_thresholds, slot_number_args: P::slot_number_args(), - tier_rank_multipliers: BoundedVec::try_from(P::tier_rank_multipliers().to_vec()) - .expect("4 tiers configured"), + tier_rank_multipliers, }; if !new_params.is_valid() { @@ -156,11 +157,21 @@ mod v11 { // Recalculate next_era_start block let current_block: u32 = frame_system::Pallet::::block_number().saturated_into(); - let new_voting_length: u32 = Pallet::::blocks_per_voting_period(); + let new_voting_length: u32 = Pallet::::blocks_per_voting_period() + .max(T::CycleConfiguration::blocks_per_era()); + let remaining_old: u32 = state.next_era_start.saturating_sub(current_block); + // Carry over remaining time, but never extend beyond the new voting length. + // If already overdue, schedule for the next block. + let remaining_new: u32 = remaining_old.min(new_voting_length).max(1); state.next_era_start = current_block.saturating_add(new_voting_length); - log::info!(target: LOG_TARGET, "ActiveProtocolState updated: next_era_start"); + log::info!( + target: LOG_TARGET, + "ActiveProtocolState updated: next_era_start (remaining_old={}, remaining_new={})", + remaining_old, + remaining_new + ); } else { // Build&Earn: adjust remainder for next_subperiod_start_era let new_eras_total: EraNumber = From b8d246808e846545d07e6aaff48c47b83b3888e4 Mon Sep 17 00:00:00 2001 From: Igor Papandinas <26460174+ipapandinas@users.noreply.github.com> Date: Tue, 10 Feb 2026 00:55:48 +0400 Subject: [PATCH 14/16] fmt --- pallets/dapp-staking/src/migration.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pallets/dapp-staking/src/migration.rs b/pallets/dapp-staking/src/migration.rs index 34598b4f0e..dff136e500 100644 --- a/pallets/dapp-staking/src/migration.rs +++ b/pallets/dapp-staking/src/migration.rs @@ -116,10 +116,18 @@ mod v11 { let mut writes: u64 = 0; // 1. Migrate StaticTierParams - let reward_portion = BoundedVec::::truncate_from(P::reward_portion().to_vec()); - let slot_distribution = BoundedVec::::truncate_from(P::slot_distribution().to_vec()); - let tier_thresholds = BoundedVec::::truncate_from(P::tier_thresholds().to_vec()); - let tier_rank_multipliers = BoundedVec::::truncate_from(P::tier_rank_multipliers().to_vec()); + let reward_portion = BoundedVec::::truncate_from( + P::reward_portion().to_vec(), + ); + let slot_distribution = BoundedVec::::truncate_from( + P::slot_distribution().to_vec(), + ); + let tier_thresholds = BoundedVec::::truncate_from( + P::tier_thresholds().to_vec(), + ); + let tier_rank_multipliers = BoundedVec::::truncate_from( + P::tier_rank_multipliers().to_vec(), + ); let new_params = TierParameters:: { reward_portion, From 5e1fb85efa7792308a4e3d7945a6a2a4077412c9 Mon Sep 17 00:00:00 2001 From: Igor Papandinas <26460174+ipapandinas@users.noreply.github.com> Date: Wed, 11 Feb 2026 19:43:00 +0400 Subject: [PATCH 15/16] integration test + migration checks --- pallets/dapp-staking/src/migration.rs | 263 +++++++++++++++++------- pallets/dapp-staking/src/types.rs | 15 ++ runtime/astar/src/lib.rs | 1 + runtime/shibuya/src/lib.rs | 1 + runtime/shiden/src/lib.rs | 1 + tests/integration/src/dapp_staking.rs | 283 ++++++++++++++++++++++++++ 6 files changed, 488 insertions(+), 76 deletions(-) diff --git a/pallets/dapp-staking/src/migration.rs b/pallets/dapp-staking/src/migration.rs index dff136e500..f72b35d66c 100644 --- a/pallets/dapp-staking/src/migration.rs +++ b/pallets/dapp-staking/src/migration.rs @@ -35,11 +35,11 @@ pub mod versioned_migrations { /// Migration V10 to V11 wrapped in a [`frame_support::migrations::VersionedMigration`], ensuring /// the migration is only performed when on-chain version is 10. - pub type V10ToV11 = + pub type V10ToV11 = frame_support::migrations::VersionedMigration< 10, 11, - v11::VersionMigrateV10ToV11, + v11::VersionMigrateV10ToV11, Pallet, ::DbWeight, >; @@ -104,17 +104,66 @@ impl TierParamsV11Config for DefaultTierParamsV11 { mod v11 { use super::*; - pub struct VersionMigrateV10ToV11(PhantomData<(T, P, OldErasBnE)>); + pub struct VersionMigrateV10ToV11( + PhantomData<(T, P, OldErasVoting, OldErasBnE)>, + ); - impl> UncheckedOnRuntimeUpgrade - for VersionMigrateV10ToV11 + impl, OldErasBnE: Get> + UncheckedOnRuntimeUpgrade for VersionMigrateV10ToV11 { fn on_runtime_upgrade() -> Weight { + let old_eras_voting = OldErasVoting::get(); let old_eras_bne = OldErasBnE::get(); let mut reads: u64 = 0; let mut writes: u64 = 0; + // 0. Safety: remove excess dApps if count exceeds new limit + let current_integrated_dapps = IntegratedDApps::::count(); + reads += 1; + + let max_dapps_allowed = T::MaxNumberOfContracts::get(); + + if current_integrated_dapps > max_dapps_allowed { + log::warn!( + target: LOG_TARGET, + "Safety net triggered: {} dApps exceed limit of {}. Removing {} excess dApps.", + current_integrated_dapps, + max_dapps_allowed, + current_integrated_dapps - max_dapps_allowed + ); + + let excess = current_integrated_dapps.saturating_sub(max_dapps_allowed); + let victims: Vec<_> = IntegratedDApps::::iter() + .take(excess as usize) + .map(|(contract, dapp_info)| (contract, dapp_info.id)) + .collect(); + + reads += excess as u64; + + for (contract, dapp_id) in victims { + ContractStake::::remove(&dapp_id); + IntegratedDApps::::remove(&contract); + reads += 2; + writes += 2; + + let current_era = ActiveProtocolState::::get().era; + Pallet::::deposit_event(Event::::DAppUnregistered { + smart_contract: contract, + era: current_era, + }); + log::info!( + target: LOG_TARGET, + "Safety net removed dApp ID {} (contract: {:?})", + dapp_id, + core::any::type_name::() + ); + } + + // ActiveProtocolState::get() for era => 1 read (done once for all events) + reads += 1; + } + // 1. Migrate StaticTierParams let reward_portion = BoundedVec::::truncate_from( P::reward_portion().to_vec(), @@ -161,6 +210,40 @@ mod v11 { // 2. Update ActiveProtocolState in a SINGLE mutate (avoid extra .get() read) // ActiveProtocolState::mutate => 1 read + 1 write ActiveProtocolState::::mutate(|state| { + if state.period_info.subperiod == Subperiod::Voting { + let current_block: u32 = + frame_system::Pallet::::block_number().saturated_into(); + + // Old/new voting period lengths (in blocks) + let old_voting_length: u32 = + old_eras_voting.saturating_mul(T::CycleConfiguration::blocks_per_era()); + let new_voting_length: u32 = Pallet::::blocks_per_voting_period() + .max(T::CycleConfiguration::blocks_per_era()); + + // Old schedule + let remaining_old: u32 = state.next_era_start.saturating_sub(current_block); + let elapsed: u32 = old_voting_length.saturating_sub(remaining_old); + + // New schedule + let remaining_new: u32 = new_voting_length.saturating_sub(elapsed); + + // If new period has already passed (elapsed >= new_voting_length), + // schedule for next block. Otherwise, use the calculated remainder. + state.next_era_start = if remaining_new == 0 { + current_block.saturating_add(1) + } else { + current_block.saturating_add(remaining_new) + }; + + log::info!( + target: LOG_TARGET, + "ActiveProtocolState updated: next_era_start (old_length={}, new_length={}, elapsed={}, remaining_new={})", + old_voting_length, + new_voting_length, + elapsed, + remaining_new + ); + } if state.period_info.subperiod == Subperiod::Voting { // Recalculate next_era_start block let current_block: u32 = @@ -172,7 +255,7 @@ mod v11 { // If already overdue, schedule for the next block. let remaining_new: u32 = remaining_old.min(new_voting_length).max(1); - state.next_era_start = current_block.saturating_add(new_voting_length); + state.next_era_start = current_block.saturating_add(remaining_new); log::info!( target: LOG_TARGET, @@ -212,124 +295,152 @@ mod v11 { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, TryRuntimeError> { let protocol_state = ActiveProtocolState::::get(); - let subperiod = protocol_state.period_info.subperiod; - let current_era = protocol_state.era; - let next_era_start = protocol_state.next_era_start; - let old_next_subperiod_era = protocol_state.period_info.next_subperiod_start_era; let current_block: u32 = frame_system::Pallet::::block_number().saturated_into(); + let pre_dapp_count = IntegratedDApps::::count(); + let max_allowed = T::MaxNumberOfContracts::get(); + log::info!( target: LOG_TARGET, - "Pre-upgrade: era={}, subperiod={:?}, next_era_start={}, next_subperiod_era={}, block={}", - current_era, - subperiod, - next_era_start, - old_next_subperiod_era, - current_block + "Pre-upgrade: dApp count={}, max={}, cleanup_needed={}", + pre_dapp_count, + max_allowed, + pre_dapp_count > max_allowed ); - // Verify current StaticTierParams can be read - let old_params = StaticTierParams::::get(); - ensure!(old_params.is_valid(), "Old tier params invalid"); - Ok(( - subperiod, - current_era, - next_era_start, - old_next_subperiod_era, + protocol_state.period_info.subperiod, + protocol_state.era, + protocol_state.next_era_start, + protocol_state.period_info.next_subperiod_start_era, current_block, + pre_dapp_count, + max_allowed, ) .encode()) } #[cfg(feature = "try-runtime")] fn post_upgrade(data: Vec) -> Result<(), TryRuntimeError> { - let (old_subperiod, old_era, old_next_era_start, old_next_subperiod_era, pre_block): ( - Subperiod, - EraNumber, - u32, - EraNumber, - u32, - ) = Decode::decode(&mut &data[..]) - .map_err(|_| TryRuntimeError::Other("Failed to decode pre-upgrade data"))?; + let ( + old_subperiod, + old_era, + old_next_era_start, + old_next_subperiod_era, + pre_block, + pre_dapp_count, + max_allowed, + ): (Subperiod, EraNumber, u32, EraNumber, u32, u32, u32) = + Decode::decode(&mut &data[..]) + .map_err(|_| TryRuntimeError::Other("Failed to decode pre-upgrade data"))?; + let old_eras_voting = OldErasVoting::get(); let old_eras_bne = OldErasBnE::get(); // Verify storage version ensure!( Pallet::::on_chain_storage_version() == StorageVersion::new(11), - "Version should be 11" + "Storage version should be 11" + ); + + // 1. Verify cleanup worked + let post_dapp_count = IntegratedDApps::::count(); + log::debug!( + "post_dapp_count={}, max_allowed={}", + post_dapp_count, + max_allowed + ); + ensure!( + post_dapp_count <= max_allowed, + "dApp count still exceeds limit", ); - // Verify new params are valid + if pre_dapp_count > max_allowed { + let expected_removed = pre_dapp_count - max_allowed; + let actual_removed = pre_dapp_count - post_dapp_count; + log::debug!( + "Removed {} dApps, expected to remove {}", + actual_removed, + expected_removed + ); + ensure!( + actual_removed == expected_removed, + "Mismatch in the expected dApps to be unregistered" + ); + } + + // 2. Verify new StaticTierParams are valid let new_params = StaticTierParams::::get(); ensure!(new_params.is_valid(), "New tier params invalid"); ensure!( - new_params.tier_rank_multipliers.len() == 4, - "Should have 4 tier_rank_multipliers entries" + new_params.reward_portion.as_slice() == P::reward_portion(), + "reward_portion mismatch" + ); + ensure!( + new_params.tier_rank_multipliers.as_slice() == P::tier_rank_multipliers(), + "tier_rank_multipliers mismatch" ); - // Verify ActiveProtocolState update + // 3. Verify ActiveProtocolState update let protocol_state = ActiveProtocolState::::get(); + ensure!(!protocol_state.maintenance, "Maintenance mode enabled"); if old_subperiod == Subperiod::Voting { - // expected_end = pre_block + new_voting_length + let old_voting_length: u32 = + old_eras_voting.saturating_mul(T::CycleConfiguration::blocks_per_era()); let new_voting_length: u32 = Pallet::::blocks_per_voting_period(); - let expected_end = pre_block.saturating_add(new_voting_length); - ensure!( - protocol_state.next_era_start == expected_end, - "next_era_start should be pre_block + new_voting_length" - ); + let remaining_old: u32 = old_next_era_start.saturating_sub(pre_block); + let elapsed: u32 = old_voting_length.saturating_sub(remaining_old); + let remaining_new: u32 = new_voting_length.saturating_sub(elapsed); - // Optional sanity: should have changed (unless it already matched) - ensure!( - protocol_state.next_era_start != old_next_era_start - || old_next_era_start == expected_end, - "next_era_start did not update as expected" - ); + let expected = if remaining_new == 0 { + pre_block.saturating_add(1) + } else { + pre_block.saturating_add(remaining_new) + }; - // We did NOT change next_subperiod_start_era in voting branch (in this migration) ensure!( - protocol_state.period_info.next_subperiod_start_era == old_next_subperiod_era, - "next_subperiod_start_era should be unchanged in Voting branch" + protocol_state.next_era_start == expected, + "Voting: next_era_start incorrect" ); - - log::info!(target: LOG_TARGET, "Post-upgrade: Voting branch OK"); } else { - // Build&Earn branch: remainder-adjusted next_subperiod_start_era let new_total: EraNumber = T::CycleConfiguration::eras_per_build_and_earn_subperiod(); - - let current_era: EraNumber = old_era; - let old_end: EraNumber = old_next_subperiod_era; - - let remaining_old: EraNumber = old_end.saturating_sub(current_era); + let remaining_old: EraNumber = old_next_subperiod_era.saturating_sub(old_era); let elapsed: EraNumber = old_eras_bne.saturating_sub(remaining_old); let remaining_new: EraNumber = new_total.saturating_sub(elapsed); - - let expected_new_end: EraNumber = current_era.saturating_add(remaining_new); + let expected: EraNumber = old_era.saturating_add(remaining_new); ensure!( - protocol_state.period_info.next_subperiod_start_era == expected_new_end, - "next_subperiod_start_era should be remainder-adjusted to the new schedule" + protocol_state.period_info.next_subperiod_start_era == expected, + "BuildEarn: next_subperiod_start_era incorrect" ); - - // next_era_start was not modified by this branch in this migration ensure!( - protocol_state.next_era_start == old_next_era_start, - "next_era_start should be unchanged in Build&Earn branch" + old_next_era_start > expected, + "next_era_start did not update as expected" ); - - log::info!(target: LOG_TARGET, "Post-upgrade: Build&Earn branch OK"); } - // Verify not in maintenance mode - ensure!( - !protocol_state.maintenance, - "Maintenance mode should not be enabled" - ); - + log::info!(target: LOG_TARGET, "Post-upgrade: All checks passed"); Ok(()) } } } + +mod v10 { + use super::*; + use frame_support::storage_alias; + + /// v10 TierParameters (without tier_rank_multipliers) + #[derive(Encode, Decode, Clone)] + pub struct TierParameters> { + pub reward_portion: BoundedVec, + pub slot_distribution: BoundedVec, + pub tier_thresholds: BoundedVec, + pub slot_number_args: (u64, u64), + } + + #[storage_alias] + pub type StaticTierParams = + StorageValue, TierParameters<::NumberOfTiers>, OptionQuery>; +} diff --git a/pallets/dapp-staking/src/types.rs b/pallets/dapp-staking/src/types.rs index cb41f0b6af..bbceaee1a6 100644 --- a/pallets/dapp-staking/src/types.rs +++ b/pallets/dapp-staking/src/types.rs @@ -1828,6 +1828,21 @@ impl, T: TierSlotsFunc, P: Get> TiersConfiguration &BoundedVec { + &self.tier_thresholds + } + + /// Returns the number of available slots for each tier. + pub fn slots_per_tier(&self) -> &BoundedVec { + &self.slots_per_tier + } + + /// Returns the reward distribution portion assigned to each tier. + pub fn reward_portion(&self) -> &BoundedVec { + &self.reward_portion + } + /// Calculate new `TiersConfiguration`, based on the old settings, current native currency price and tier configuration. pub fn calculate_new( &self, diff --git a/runtime/astar/src/lib.rs b/runtime/astar/src/lib.rs index 18f38443b7..f67dbc1402 100644 --- a/runtime/astar/src/lib.rs +++ b/runtime/astar/src/lib.rs @@ -1755,6 +1755,7 @@ pub type Unreleased = ( pallet_dapp_staking::migration::versioned_migrations::V10ToV11< Runtime, pallet_dapp_staking::migration::DefaultTierParamsV11, + ConstU32<11>, ConstU32<111>, >, ); diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index c1a1245a54..362dd91a90 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -1761,6 +1761,7 @@ pub type Unreleased = ( pallet_dapp_staking::migration::versioned_migrations::V10ToV11< Runtime, pallet_dapp_staking::migration::DefaultTierParamsV11, + ConstU32<8>, ConstU32<20>, >, ); diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index d2a07202d5..b0e245b96c 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -1324,6 +1324,7 @@ pub type Unreleased = ( pallet_dapp_staking::migration::versioned_migrations::V10ToV11< Runtime, pallet_dapp_staking::migration::DefaultTierParamsV11, + ConstU32<6>, ConstU32<55>, >, ); diff --git a/tests/integration/src/dapp_staking.rs b/tests/integration/src/dapp_staking.rs index 597c7de163..7e7a2fcf9c 100644 --- a/tests/integration/src/dapp_staking.rs +++ b/tests/integration/src/dapp_staking.rs @@ -19,6 +19,8 @@ #![cfg(test)] use crate::setup::*; +use astar_primitives::dapp_staking::{DAppId, RankedTier, SmartContract}; +use frame_support::traits::BuildGenesisConfig; use sp_runtime::Perquintill; use pallet_collator_selection::{CandidateInfo, Candidates}; @@ -191,3 +193,284 @@ fn no_inflation_rewards_with_zero_decay() { ); }); } + +// During Voting subperiod +// - Initialize TierConfig for the cycle: Tier0/3 disabled, Tier1 has 6 slots, Tier2 has 10 slots (with rank multipliers) +// - Set inflation params with bonus rewards = 0% (fully redistributed away from bonus), force an inflation recalculation, +// and snapshot the active inflation config (used as the β€œbaseline” for the rest of the cycle) +// Collator and Treasury are also set to 0 for no perturbation of the tier threshold estimation. +// - Register 16 dApps and stake so that: +// - Tier1 is fully occupied with ranks [10, 8, 6, 4, 2, 0] (6 dApps) +// - Tier2 is occupied with ranks [9, 8, 7, 6, 5, 4, 3, 2, 1] (9 dApps) +// - 1 extra dApp is staked just below Tier2 threshold and is excluded from tiers (no rewards) +// +// Advance to Build&Earn subperiod +// - Force an era transition into Build&Earn and capture the era that got assigned tiers +// - Ensure TierConfig is carried correctly into the active cycle (slots per tier unchanged) +// - Ensure the dApps occupy the expected tiers and ranks for the assigned era, and the excluded dApp is not in tiers +// - Snapshot inflation active config again and ensure it has NOT recalculated within the same cycle +// +// Still within the same cycle (before the recalculation boundary) +// - Claim dApp rewards for representative Tier1 and Tier2 dApps and verify the emitted event contains the expected tier/rank +// - Ensure double-claim fails and excluded dApp has no claimable rewards +// +// Recalculation boundary (next recalculation era) +// - Force era advancement up to the era right before recalculation and ensure the active inflation config is still the baseline +// - Advance one more era to cross the recalculation boundary and fetch the new active inflation config +// - Ensure recalculation occurred (recalculation_era bumped) and bonus/collator/treasury rewards remain zero +// - Ensure reward pools are >= previous values (issuance increased via minted dApp rewards, so pools should grow or stay equal) + +#[test] +fn full_period_transition_recalculation_and_reward_distribution() { + new_test_ext().execute_with(|| { + // 1. Setup: Tier0/3 empty, Tier1=6 slots, Tier2=10 slots ─── + pallet_dapp_staking::GenesisConfig:: { + slots_per_tier: vec![0, 6, 10, 0], + safeguard: Some(false), + ..Default::default() + } + .build(); + + // Inflation: bonus=treasury=collators=0%, redistributed to dapps + assert_ok!(Inflation::force_set_inflation_params( + RuntimeOrigin::root(), + pallet_inflation::InflationParameters { + max_inflation_rate: Perquintill::from_percent(7), + treasury_part: Perquintill::from_percent(0), + collators_part: Perquintill::from_percent(0), + dapps_part: Perquintill::from_percent(40), + base_stakers_part: Perquintill::from_percent(25), + adjustable_stakers_part: Perquintill::from_percent(35), + bonus_part: Perquintill::zero(), + ideal_staking_rate: Perquintill::from_percent(50), + decay_rate: Perquintill::one(), + }, + )); + assert_ok!(Inflation::force_inflation_recalculation( + RuntimeOrigin::root(), + ActiveProtocolState::::get().era(), + )); + let init_config = pallet_inflation::ActiveInflationConfig::::get(); + assert_eq!( + init_config.bonus_reward_pool_per_period, 0, + "Bonus pool must be zero" + ); + + // ─── 2. Register 16 dApps ─── + let base_id = NextDAppId::::get(); + let contracts: Vec<_> = (0u8..16) + .map(|i| { + let c = AccountId32::new([20 + i; 32]); + assert_ok!(DappStaking::register( + RuntimeOrigin::root(), + ALICE, + SmartContract::Wasm(c.clone()) + )); + c + }) + .collect(); + + let tc = TierConfig::::get(); + let t0 = *tc.tier_thresholds().get(0).unwrap(); + let t1 = *tc.tier_thresholds().get(1).unwrap(); + let t2 = *tc.tier_thresholds().get(2).unwrap(); + + fn stake_for_rank(lo: Balance, hi: Balance, r: u8) -> Balance { + if r == 10 { + return hi; + } + let find_min = |target: u8| -> Balance { + let (mut a, mut b) = (lo, hi); + while a < b { + let m = a + (b - a) / 2; + if RankedTier::find_rank(lo, hi, m) >= target { + b = m; + } else { + a = m + 1; + } + } + a + }; + let s = find_min(r + 1).saturating_sub(1).max(find_min(r)); + assert_eq!(RankedTier::find_rank(lo, hi, s), r); + s + } + + let tier1_ranks: [u8; 6] = [10, 8, 6, 4, 2, 0]; + let tier2_ranks: [u8; 9] = [9, 8, 7, 6, 5, 4, 3, 2, 1]; + + let mut stakes: Vec = tier1_ranks + .iter() + .map(|&r| stake_for_rank(t1, t0, r)) + .collect(); + stakes.extend(tier2_ranks.iter().map(|&r| { + let s = stake_for_rank(t2, t1, r); + assert!(s < t1); + s + })); + stakes.push(t2.saturating_sub(1)); // 16th: excluded + + assert_ok!(DappStaking::lock( + RuntimeOrigin::signed(ALICE.clone()), + stakes.iter().sum() + )); + for (i, &s) in stakes.iter().enumerate() { + assert_ok!(DappStaking::stake( + RuntimeOrigin::signed(ALICE.clone()), + SmartContract::Wasm(contracts[i].clone()), + s, + )); + } + + // ── 3. Voting β†’ Build&Earn ── + assert_ok!(DappStaking::force(RuntimeOrigin::root(), ForcingType::Era)); + run_for_blocks(1); + assert_eq!( + ActiveProtocolState::::get().subperiod(), + Subperiod::BuildAndEarn + ); + + // ─── 4. Verify TierConfig recalculated correctly ─── + let new_tier_config = TierConfig::::get(); + assert_eq!( + new_tier_config + .slots_per_tier() + .get(0) + .copied() + .unwrap_or(0), + 0 + ); + assert_eq!( + new_tier_config + .slots_per_tier() + .get(1) + .copied() + .unwrap_or(0), + 6 + ); + assert_eq!( + new_tier_config + .slots_per_tier() + .get(2) + .copied() + .unwrap_or(0), + 10 + ); + assert_eq!( + new_tier_config + .slots_per_tier() + .get(3) + .copied() + .unwrap_or(0), + 0 + ); + + // Finalize 1 era for dapps assignation in DAppTiers + assert_ok!(DappStaking::force(RuntimeOrigin::root(), ForcingType::Era)); + run_for_blocks(1); + let assigned_era = ActiveProtocolState::::get().era() - 1; + + // ── 5. Verify tier/rank assignments ── + let mut tiers = DAppTiers::::get(assigned_era).expect("tiers must exist"); + + for (i, &r) in tier1_ranks.iter().enumerate() { + let (amt, ranked) = tiers.try_claim(base_id + i as DAppId).unwrap(); + assert!(amt > 0); + assert_eq!((ranked.tier(), ranked.rank()), (1, r)); + } + for (i, &r) in tier2_ranks.iter().enumerate() { + let (amt, ranked) = tiers.try_claim(base_id + (6 + i) as DAppId).unwrap(); + assert!(amt > 0); + assert_eq!((ranked.tier(), ranked.rank()), (2, r)); + } + assert_eq!( + tiers.try_claim(base_id + 15), + Err(DAppTierError::NoDAppInTiers) + ); + + // ── 6. Inflation stable within cycle ── + assert_eq!( + pallet_inflation::ActiveInflationConfig::::get().recalculation_era, + init_config.recalculation_era, + ); + + // ── 7. Claim rewards BEFORE recalculation ── + let claim_and_check = |idx: usize, exp_tier: u8, exp_rank: u8| { + let sc = SmartContract::Wasm(contracts[idx].clone()); + assert_ok!(DappStaking::claim_dapp_reward( + RuntimeOrigin::signed(ALICE.clone()), + sc.clone(), + assigned_era, + )); + assert!(frame_system::Pallet::::events() + .iter() + .rev() + .any(|r| matches!( + &r.event, + RuntimeEvent::DappStaking( + pallet_dapp_staking::Event::::DAppReward { + smart_contract, + tier_id, + rank, + .. + } + ) if *smart_contract == sc + && *tier_id == exp_tier + && *rank == exp_rank + ))); + }; + + claim_and_check(0, 1, tier1_ranks[0]); + claim_and_check(6, 2, tier2_ranks[0]); + + // Excluded dApp has no rewards + assert_noop!( + DappStaking::claim_dapp_reward( + RuntimeOrigin::signed(ALICE.clone()), + SmartContract::Wasm(contracts[15].clone()), + assigned_era, + ), + pallet_dapp_staking::Error::::NoClaimableRewards + ); + + // ── 8. Force to recalculation boundary ── + while ActiveProtocolState::::get().era() < init_config.recalculation_era - 1 { + assert_ok!(DappStaking::force(RuntimeOrigin::root(), ForcingType::Era)); + run_for_blocks(1); + } + assert_eq!( + pallet_inflation::ActiveInflationConfig::::get().recalculation_era, + init_config.recalculation_era, + "not yet recalculated" + ); + assert_eq!( + pallet_inflation::ActiveInflationConfig::::get().dapp_reward_pool_per_era, + init_config.dapp_reward_pool_per_era, + "no pool inflation" + ); + + assert_ok!(DappStaking::force(RuntimeOrigin::root(), ForcingType::Era)); + run_for_blocks(1); + let new_config = pallet_inflation::ActiveInflationConfig::::get(); + + // ── 9. Verify recalculation happened and pool increased ── + assert!( + new_config.recalculation_era > init_config.recalculation_era, + "Recalculation era must have bumped" + ); + assert_eq!(new_config.bonus_reward_pool_per_period, 0); + assert_eq!(new_config.collator_reward_per_block, 0); + assert_eq!(new_config.treasury_reward_per_block, 0); + + // Rewards were minted via claim_dapp_reward (increasing issuance). + assert!( + new_config.dapp_reward_pool_per_era >= init_config.dapp_reward_pool_per_era, + "dApp reward pool must grow (or stay equal) after recalculation on higher issuance" + ); + assert!( + new_config.base_staker_reward_pool_per_era + >= init_config.base_staker_reward_pool_per_era, + "Base staker pool must grow (or stay equal) after recalculation" + ); + }); +} From 0a7ab8581dccd822923d1ba214c13dbc5fcf9632 Mon Sep 17 00:00:00 2001 From: Igor Papandinas <26460174+ipapandinas@users.noreply.github.com> Date: Wed, 11 Feb 2026 22:53:16 +0400 Subject: [PATCH 16/16] fix test for shibuya --- pallets/dapp-staking/src/migration.rs | 1 - tests/integration/src/dapp_staking.rs | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pallets/dapp-staking/src/migration.rs b/pallets/dapp-staking/src/migration.rs index f72b35d66c..400dcdb34c 100644 --- a/pallets/dapp-staking/src/migration.rs +++ b/pallets/dapp-staking/src/migration.rs @@ -144,7 +144,6 @@ mod v11 { for (contract, dapp_id) in victims { ContractStake::::remove(&dapp_id); IntegratedDApps::::remove(&contract); - reads += 2; writes += 2; let current_era = ActiveProtocolState::::get().era; diff --git a/tests/integration/src/dapp_staking.rs b/tests/integration/src/dapp_staking.rs index 7e7a2fcf9c..956cbd5c26 100644 --- a/tests/integration/src/dapp_staking.rs +++ b/tests/integration/src/dapp_staking.rs @@ -314,9 +314,14 @@ fn full_period_transition_recalculation_and_reward_distribution() { RuntimeOrigin::signed(ALICE.clone()), stakes.iter().sum() )); + assert_ok!(DappStaking::lock( + RuntimeOrigin::signed(BOB.clone()), + stakes.iter().sum() + )); + let stakers = [ALICE.clone(), BOB.clone()]; for (i, &s) in stakes.iter().enumerate() { assert_ok!(DappStaking::stake( - RuntimeOrigin::signed(ALICE.clone()), + RuntimeOrigin::signed(stakers[i % 2].clone()), SmartContract::Wasm(contracts[i].clone()), s, ));