From 433f5d0426c476e6cedeafbc1691509e72138620 Mon Sep 17 00:00:00 2001 From: Igor Papandinas <26460174+ipapandinas@users.noreply.github.com> Date: Thu, 13 Feb 2025 16:22:14 +0400 Subject: [PATCH] misc: nomenclature consistency & comment cleanup --- pallets/dapp-staking/src/benchmarking/mod.rs | 4 ++-- pallets/dapp-staking/src/lib.rs | 10 ++++------ pallets/dapp-staking/src/test/tests.rs | 4 ++-- pallets/dapp-staking/src/types.rs | 2 +- pallets/inflation/src/lib.rs | 2 +- precompiles/dapp-staking/src/lib.rs | 2 +- 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/pallets/dapp-staking/src/benchmarking/mod.rs b/pallets/dapp-staking/src/benchmarking/mod.rs index 86cfbda878..ff07026736 100644 --- a/pallets/dapp-staking/src/benchmarking/mod.rs +++ b/pallets/dapp-staking/src/benchmarking/mod.rs @@ -259,7 +259,7 @@ mod benchmarks { amount, )); - // Move over to the build&earn subperiod to ensure 'non-loyal' staking. + // Move over to the build&earn subperiod to ensure staking without a bonus status. // This is needed so we can achieve staker entry cleanup after claiming unlocked tokens. force_advance_to_next_subperiod::(); assert_eq!( @@ -782,7 +782,7 @@ mod benchmarks { fn cleanup_expired_entries(x: Linear<1, { T::MaxNumberOfStakedContracts::get() }>) { initial_config::(); - // Move over to the build&earn subperiod to ensure 'non-loyal' staking. + // Move over to the build&earn subperiod to ensure staking without a bonus status. force_advance_to_next_subperiod::(); // Prepare staker & lock some amount diff --git a/pallets/dapp-staking/src/lib.rs b/pallets/dapp-staking/src/lib.rs index 24867e42b6..9b41940244 100644 --- a/pallets/dapp-staking/src/lib.rs +++ b/pallets/dapp-staking/src/lib.rs @@ -297,7 +297,7 @@ pub mod pallet { era: EraNumber, amount: Balance, }, - /// Bonus reward has been paid out to a loyal staker. + /// Bonus reward has been paid out to a staker with an eligible bonus status. BonusReward { account: T::AccountId, smart_contract: T::SmartContract, @@ -1217,8 +1217,8 @@ pub mod pallet { /// Cleanup expired stake entries for the contract. /// /// Entry is considered to be expired if: - /// 1. It's from a past period & the account wasn't a loyal staker, meaning there's no claimable bonus reward. - /// 2. It's from a period older than the oldest claimable period, regardless whether the account was loyal or not. + /// 1. It's from a past period & the account did not maintain an eligible bonus status, meaning there's no claimable bonus reward. + /// 2. It's from a period older than the oldest claimable period, regardless of whether the account had an eligible bonus status or not. #[pallet::call_index(17)] #[pallet::weight(T::WeightInfo::cleanup_expired_entries( T::MaxNumberOfStakedContracts::get() @@ -1529,8 +1529,6 @@ pub mod pallet { Self::update_ledger(&account, ledger)?; - // Implementation comment, remove once production code is ready: - // We need to know what & how much was unstaked. The code can be made cleaner later, maybe there are redundant parts now. // Return the `StakeAmount` that has max total value - that's the one that is equal to the `amount` parameter. let unstake_amount = stake_amount_iter .iter() @@ -2373,7 +2371,7 @@ pub mod pallet { // Ensure: // 1. Period for which rewards are being claimed has ended. - // 2. Account has been a loyal staker. + // 2. Account has maintained an eligible bonus status. // 3. Rewards haven't expired. let staked_period = staker_info.period_number(); ensure!( diff --git a/pallets/dapp-staking/src/test/tests.rs b/pallets/dapp-staking/src/test/tests.rs index ed64f4ef13..a7e94468e8 100644 --- a/pallets/dapp-staking/src/test/tests.rs +++ b/pallets/dapp-staking/src/test/tests.rs @@ -1285,7 +1285,7 @@ fn stake_fails_due_to_too_many_staked_contracts() { let account = 1; assert_lock(account, 100 as Balance * max_number_of_contracts as Balance); - // Advance to build&earn subperiod so we ensure 'non-loyal' staking + // Advance to the build&earn subperiod to ensure staking without a bonus status. advance_to_next_subperiod(); // Register smart contracts up to the max allowed number @@ -1333,7 +1333,7 @@ fn move_fails_due_to_too_many_staked_contracts() { let account = 1; assert_lock(account, 100 as Balance * max_number_of_contracts as Balance); - // Advance to build&earn subperiod so we ensure 'non-loyal' staking + // Advance to the build&earn subperiod to ensure staking without a bonus status. advance_to_next_subperiod(); let source_contract = MockSmartContract::Wasm(1); diff --git a/pallets/dapp-staking/src/types.rs b/pallets/dapp-staking/src/types.rs index 9bcf057228..2efeced69b 100644 --- a/pallets/dapp-staking/src/types.rs +++ b/pallets/dapp-staking/src/types.rs @@ -159,7 +159,7 @@ impl PeriodInfo { /// Struct with relevant information for a finished period. #[derive(Encode, Decode, MaxEncodedLen, Clone, Copy, Debug, PartialEq, Eq, TypeInfo)] pub struct PeriodEndInfo { - /// Bonus reward pool allocated for 'loyal' stakers + /// Bonus reward pool allocated for eligible stakers with a non-null bonus status #[codec(compact)] pub(crate) bonus_reward_pool: Balance, /// Total amount staked (remaining) from the voting subperiod. diff --git a/pallets/inflation/src/lib.rs b/pallets/inflation/src/lib.rs index c9baf754a0..29188fcd8a 100644 --- a/pallets/inflation/src/lib.rs +++ b/pallets/inflation/src/lib.rs @@ -494,7 +494,7 @@ pub struct InflationConfiguration { /// This is provided to the stakers according to formula: 'pool * min(1, total_staked / ideal_staked)'. #[codec(compact)] pub adjustable_staker_reward_pool_per_era: Balance, - /// Bonus reward pool per period, for loyal stakers. + /// Bonus reward pool per period, for eligible stakers. #[codec(compact)] pub bonus_reward_pool_per_period: Balance, /// The ideal staking rate, in respect to total issuance. diff --git a/precompiles/dapp-staking/src/lib.rs b/precompiles/dapp-staking/src/lib.rs index 6b40f93c97..1ac9f53ecb 100644 --- a/precompiles/dapp-staking/src/lib.rs +++ b/precompiles/dapp-staking/src/lib.rs @@ -688,7 +688,7 @@ where Ok(true) } - /// Attempts to claim bonus reward for being a loyal staker of the given dApp. + /// Attempts to claim a bonus reward for maintaining an eligible bonus status with the given dApp. #[precompile::public("claim_bonus_reward((uint8,bytes))")] fn claim_bonus_reward( handle: &mut impl PrecompileHandle,