diff --git a/pallets/dapp-staking/src/test/tests_types.rs b/pallets/dapp-staking/src/test/tests_types.rs index 416985eb8..c655141e1 100644 --- a/pallets/dapp-staking/src/test/tests_types.rs +++ b/pallets/dapp-staking/src/test/tests_types.rs @@ -86,17 +86,6 @@ fn period_info_basic_checks() { assert!(info.is_next_period(next_subperiod_start_era + 1)); } -#[test] -fn protocol_state_default() { - let protocol_state = ProtocolState::default(); - - assert_eq!(protocol_state.era, 0); - assert_eq!( - protocol_state.next_era_start, 1, - "Era should start immediately on the first block" - ); -} - #[test] fn protocol_state_basic_checks() { let mut protocol_state = ProtocolState::default(); diff --git a/pallets/dapp-staking/src/types.rs b/pallets/dapp-staking/src/types.rs index 90322a45e..d49720865 100644 --- a/pallets/dapp-staking/src/types.rs +++ b/pallets/dapp-staking/src/types.rs @@ -64,7 +64,7 @@ //! * `DAppTierRewards` - composite of `DAppTier` objects, describing the entire reward distribution for a particular era. //! -use frame_support::{pallet_prelude::*, BoundedBTreeMap, BoundedVec}; +use frame_support::{pallet_prelude::*, BoundedBTreeMap, BoundedVec, DefaultNoBound}; use parity_scale_codec::{Decode, Encode}; use serde::{Deserialize, Serialize}; use sp_arithmetic::fixed_point::FixedU128; @@ -137,12 +137,12 @@ impl Subperiod { pub struct PeriodInfo { /// Period number. #[codec(compact)] - pub number: PeriodNumber, + pub(crate) number: PeriodNumber, /// Subperiod type. - pub subperiod: Subperiod, + pub(crate) subperiod: Subperiod, /// Era in which the new subperiod starts. #[codec(compact)] - pub next_subperiod_start_era: EraNumber, + pub(crate) next_subperiod_start_era: EraNumber, } impl PeriodInfo { @@ -158,13 +158,13 @@ impl PeriodInfo { pub struct PeriodEndInfo { /// Bonus reward pool allocated for 'loyal' stakers #[codec(compact)] - pub bonus_reward_pool: Balance, + pub(crate) bonus_reward_pool: Balance, /// Total amount staked (remaining) from the voting subperiod. #[codec(compact)] - pub total_vp_stake: Balance, + pub(crate) total_vp_stake: Balance, /// Final era, inclusive, in which the period ended. #[codec(compact)] - pub final_era: EraNumber, + pub(crate) final_era: EraNumber, } /// Force types to speed up the next era, and even period. @@ -181,23 +181,23 @@ pub enum ForcingType { pub struct ProtocolState { /// Ongoing era number. #[codec(compact)] - pub era: EraNumber, + pub(crate) era: EraNumber, /// Block number at which the next era should start. #[codec(compact)] - pub next_era_start: BlockNumber, + pub(crate) next_era_start: BlockNumber, /// Information about the ongoing period. - pub period_info: PeriodInfo, + pub(crate) period_info: PeriodInfo, /// `true` if pallet is in maintenance mode (disabled), `false` otherwise. - pub maintenance: bool, + pub(crate) maintenance: bool, } impl Default for ProtocolState { fn default() -> Self { Self { - era: 0, - next_era_start: 1, + era: 1, + next_era_start: 2, period_info: PeriodInfo { - number: 0, + number: 1, subperiod: Subperiod::Voting, next_subperiod_start_era: 2, }, @@ -207,6 +207,22 @@ impl Default for ProtocolState { } impl ProtocolState { + /// Ongoing era. + pub fn era(&self) -> EraNumber { + self.era + } + + /// Block number at which the next era should start. + pub fn next_era_start(&self) -> BlockNumber { + self.next_era_start + } + + /// Set the next era start block number. + /// Not perfectly clean approach but helps speed up integration tests significantly. + pub fn set_next_era_start(&mut self, next_era_start: BlockNumber) { + self.next_era_start = next_era_start; + } + /// Current subperiod. pub fn subperiod(&self) -> Subperiod { self.period_info.subperiod @@ -252,15 +268,20 @@ impl ProtocolState { #[derive(Encode, Decode, MaxEncodedLen, Clone, Copy, Debug, PartialEq, Eq, TypeInfo)] pub struct DAppInfo { /// Owner of the dApp, default reward beneficiary. - pub owner: AccountId, + pub(crate) owner: AccountId, /// dApp's unique identifier in dApp staking. #[codec(compact)] - pub id: DAppId, + pub(crate) id: DAppId, // If `None`, rewards goes to the developer account, otherwise to the account Id in `Some`. - pub reward_beneficiary: Option, + pub(crate) reward_beneficiary: Option, } impl DAppInfo { + /// dApp's unique identifier. + pub fn id(&self) -> DAppId { + self.id + } + /// Reward destination account for this dApp. pub fn reward_beneficiary(&self) -> &AccountId { match &self.reward_beneficiary { @@ -341,6 +362,7 @@ pub struct UnlockingChunk { MaxEncodedLen, RuntimeDebugNoBound, PartialEqNoBound, + DefaultNoBound, EqNoBound, CloneNoBound, TypeInfo, @@ -349,41 +371,36 @@ pub struct UnlockingChunk { pub struct AccountLedger> { /// How much active locked amount an account has. This can be used for staking. #[codec(compact)] - pub locked: Balance, + pub(crate) locked: Balance, /// Vector of all the unlocking chunks. This is also considered _locked_ but cannot be used for staking. - pub unlocking: BoundedVec, + pub(crate) unlocking: BoundedVec, /// Primary field used to store how much was staked in a particular era. - pub staked: StakeAmount, + pub(crate) staked: StakeAmount, /// Secondary field used to store 'stake' information for the 'next era'. /// This is needed since stake amount is only applicable from the next era after it's been staked. /// /// Both `stake` and `staked_future` must ALWAYS refer to the same period. /// If `staked_future` is `Some`, it will always be **EXACTLY** one era after the `staked` field era. - pub staked_future: Option, + pub(crate) staked_future: Option, /// Number of contract stake entries in storage. #[codec(compact)] - pub contract_stake_count: u32, + pub(crate) contract_stake_count: u32, } -impl Default for AccountLedger +impl AccountLedger where UnlockingLen: Get, { - fn default() -> Self { - Self { - locked: Balance::zero(), - unlocking: BoundedVec::default(), - staked: StakeAmount::default(), - staked_future: None, - contract_stake_count: Zero::zero(), - } + /// How much active locked amount an account has. This can be used for staking. + pub fn locked(&self) -> Balance { + self.locked + } + + /// Unlocking chunks. + pub fn unlocking_chunks(&self) -> &[UnlockingChunk] { + &self.unlocking } -} -impl AccountLedger -where - UnlockingLen: Get, -{ /// Empty if no locked/unlocking/staked info exists. pub fn is_empty(&self) -> bool { self.locked.is_zero() @@ -819,16 +836,16 @@ impl Iterator for EraStakePairIter { pub struct StakeAmount { /// Amount of staked funds accounting for the voting subperiod. #[codec(compact)] - pub voting: Balance, + pub(crate) voting: Balance, /// Amount of staked funds accounting for the build&earn subperiod. #[codec(compact)] - pub build_and_earn: Balance, + pub(crate) build_and_earn: Balance, /// Era to which this stake amount refers to. #[codec(compact)] - pub era: EraNumber, + pub(crate) era: EraNumber, /// Period to which this stake amount refers to. #[codec(compact)] - pub period: PeriodNumber, + pub(crate) period: PeriodNumber, } impl StakeAmount { @@ -884,18 +901,28 @@ pub struct EraInfo { /// How much balance is locked in dApp staking. /// Does not include the amount that is undergoing the unlocking period. #[codec(compact)] - pub total_locked: Balance, + pub(crate) total_locked: Balance, /// How much balance is undergoing unlocking process. /// This amount still counts into locked amount. #[codec(compact)] - pub unlocking: Balance, + pub(crate) unlocking: Balance, /// Stake amount valid for the ongoing era. - pub current_stake_amount: StakeAmount, + pub(crate) current_stake_amount: StakeAmount, /// Stake amount valid from the next era. - pub next_stake_amount: StakeAmount, + pub(crate) next_stake_amount: StakeAmount, } impl EraInfo { + /// Stake amount valid for the ongoing era. + pub fn current_stake_amount(&self) -> StakeAmount { + self.current_stake_amount + } + + /// Stake amount valid from the next era. + pub fn next_stake_amount(&self) -> StakeAmount { + self.next_stake_amount + } + /// Update with the new amount that has just been locked. pub fn add_locked(&mut self, amount: Balance) { self.total_locked.saturating_accrue(amount); @@ -986,7 +1013,7 @@ impl SingularStakingInfo { /// /// `period` - period number for which this entry is relevant. /// `subperiod` - subperiod during which this entry is created. - pub fn new(period: PeriodNumber, subperiod: Subperiod) -> Self { + pub(crate) fn new(period: PeriodNumber, subperiod: Subperiod) -> Self { Self { previous_staked: Default::default(), staked: StakeAmount { @@ -1152,9 +1179,9 @@ impl SingularStakingInfo { #[derive(Encode, Decode, MaxEncodedLen, RuntimeDebug, PartialEq, Eq, Clone, TypeInfo, Default)] pub struct ContractStakeAmount { /// Staked amount in the 'current' era. - pub staked: StakeAmount, + pub(crate) staked: StakeAmount, /// Staked amount in the next or 'future' era. - pub staked_future: Option, + pub(crate) staked_future: Option, } impl ContractStakeAmount { @@ -1327,13 +1354,30 @@ impl ContractStakeAmount { pub struct EraReward { /// Total reward pool for staker rewards #[codec(compact)] - pub staker_reward_pool: Balance, + pub(crate) staker_reward_pool: Balance, /// Total amount which was staked at the end of an era #[codec(compact)] - pub staked: Balance, + pub(crate) staked: Balance, /// Total reward pool for dApp rewards #[codec(compact)] - pub dapp_reward_pool: Balance, + pub(crate) dapp_reward_pool: Balance, +} + +impl EraReward { + /// Total reward pool for staker rewards. + pub fn staker_reward_pool(&self) -> Balance { + self.staker_reward_pool + } + + /// Total amount which was staked at the end of an era. + pub fn staked(&self) -> Balance { + self.staked + } + + /// Total reward pool for dApp rewards + pub fn dapp_reward_pool(&self) -> Balance { + self.dapp_reward_pool + } } #[derive(Encode, Decode, MaxEncodedLen, Clone, Copy, Debug, PartialEq, Eq, TypeInfo)] @@ -1351,6 +1395,7 @@ pub enum EraRewardSpanError { MaxEncodedLen, RuntimeDebugNoBound, PartialEqNoBound, + DefaultNoBound, EqNoBound, CloneNoBound, TypeInfo, @@ -1358,7 +1403,7 @@ pub enum EraRewardSpanError { #[scale_info(skip_type_params(SL))] pub struct EraRewardSpan> { /// Span of EraRewardInfo entries. - pub span: BoundedVec, + pub(crate) span: BoundedVec, /// The first era in the span. #[codec(compact)] first_era: EraNumber, @@ -1372,7 +1417,7 @@ where SL: Get, { /// Create new instance of the `EraRewardSpan` - pub fn new() -> Self { + pub(crate) fn new() -> Self { Self { span: Default::default(), first_era: 0, @@ -1485,6 +1530,7 @@ impl TierThreshold { MaxEncodedLen, RuntimeDebugNoBound, PartialEqNoBound, + DefaultNoBound, EqNoBound, CloneNoBound, TypeInfo, @@ -1495,15 +1541,15 @@ pub struct TierParameters> { /// First entry refers to the first tier, and so on. /// The sum of all values must not exceed 100%. /// In case it is less, portion of rewards will never be distributed. - pub reward_portion: BoundedVec, + pub(crate) reward_portion: BoundedVec, /// Distribution of number of slots per tier, in percentage. /// First entry refers to the first tier, and so on. /// The sum of all values must not exceed 100%. /// In case it is less, slot capacity will never be fully filled. - pub slot_distribution: BoundedVec, + pub(crate) slot_distribution: BoundedVec, /// Requirements for entry into each tier. /// First entry refers to the first tier, and so on. - pub tier_thresholds: BoundedVec, + pub(crate) tier_thresholds: BoundedVec, } impl> TierParameters { @@ -1543,16 +1589,6 @@ impl> TierParameters { } } -impl> Default for TierParameters { - fn default() -> Self { - Self { - reward_portion: BoundedVec::default(), - slot_distribution: BoundedVec::default(), - tier_thresholds: BoundedVec::default(), - } - } -} - /// Configuration of dApp tiers. #[derive( Encode, @@ -1560,6 +1596,7 @@ impl> Default for TierParameters { MaxEncodedLen, RuntimeDebugNoBound, PartialEqNoBound, + DefaultNoBound, EqNoBound, CloneNoBound, TypeInfo, @@ -1568,30 +1605,19 @@ impl> Default for TierParameters { pub struct TiersConfiguration, T: TierSlotsFunc, P: Get> { /// Number of slots per tier. /// First entry refers to the first tier, and so on. - pub slots_per_tier: BoundedVec, + pub(crate) slots_per_tier: BoundedVec, /// Reward distribution per tier, in percentage. /// First entry refers to the first tier, and so on. /// The sum of all values must be exactly equal to 1. - pub reward_portion: BoundedVec, + pub(crate) reward_portion: BoundedVec, /// Requirements for entry into each tier. /// First entry refers to the first tier, and so on. - pub tier_thresholds: BoundedVec, + pub(crate) tier_thresholds: BoundedVec, /// Phantom data to keep track of the tier slots function. #[codec(skip)] pub(crate) _phantom: PhantomData<(T, P)>, } -impl, T: TierSlotsFunc, P: Get> Default for TiersConfiguration { - fn default() -> Self { - Self { - slots_per_tier: BoundedVec::default(), - reward_portion: BoundedVec::default(), - tier_thresholds: BoundedVec::default(), - _phantom: Default::default(), - } - } -} - // Some TODOs: // Some parts regarding tiers should be refactored. // * There's no need to keep thresholds in two separate storage items since the calculation can always be done compared to the @@ -1718,6 +1744,7 @@ impl, T: TierSlotsFunc, P: Get> TiersConfiguration, T: TierSlotsFunc, P: Get> TiersConfiguration, NT: Get> { /// DApps and their corresponding tiers (or `None` if they have been claimed in the meantime) - pub dapps: BoundedBTreeMap, + pub(crate) dapps: BoundedBTreeMap, /// Rewards for each tier. First entry refers to the first tier, and so on. - pub rewards: BoundedVec, + pub(crate) rewards: BoundedVec, /// Period during which this struct was created. #[codec(compact)] - pub period: PeriodNumber, + pub(crate) period: PeriodNumber, /// Rank reward for each tier. First entry refers to the first tier, and so on. - pub rank_rewards: BoundedVec, -} - -impl, NT: Get> Default for DAppTierRewards { - fn default() -> Self { - Self { - dapps: BoundedBTreeMap::default(), - rewards: BoundedVec::default(), - period: 0, - rank_rewards: BoundedVec::default(), - } - } + pub(crate) rank_rewards: BoundedVec, } impl, NT: Get> DAppTierRewards { /// Attempt to construct `DAppTierRewards` struct. /// If the provided arguments exceed the allowed capacity, return an error. - pub fn new( + pub(crate) fn new( dapps: BTreeMap, rewards: Vec, period: PeriodNumber, diff --git a/precompiles/dapp-staking/src/lib.rs b/precompiles/dapp-staking/src/lib.rs index c1750f223..b60a8270e 100644 --- a/precompiles/dapp-staking/src/lib.rs +++ b/precompiles/dapp-staking/src/lib.rs @@ -134,7 +134,7 @@ where // Twox64(8) + ProtocolState::max_encoded_len handle.record_db_read::(8 + ProtocolState::max_encoded_len())?; - let current_era = ActiveProtocolState::::get().era; + let current_era = ActiveProtocolState::::get().era(); Ok(current_era.into()) } @@ -160,12 +160,11 @@ where // Get the appropriate era reward span let era_span_index = DAppStaking::::era_reward_span_index(era); - let reward_span = - EraRewards::::get(&era_span_index).unwrap_or(EraRewardSpanFor::::new()); + let reward_span = EraRewards::::get(&era_span_index).unwrap_or_default(); // Sum up staker & dApp reward pools for the era let reward = reward_span.get(era).map_or(Zero::zero(), |r| { - r.staker_reward_pool.saturating_add(r.dapp_reward_pool) + r.staker_reward_pool().saturating_add(r.dapp_reward_pool()) }); Ok(reward) @@ -185,9 +184,9 @@ where // Twox64(8) + ProtocolState::max_encoded_len handle.record_db_read::(8 + ProtocolState::max_encoded_len())?; - let current_era = ActiveProtocolState::::get().era; + let current_era = ActiveProtocolState::::get().era(); - // There are few distinct scenenarios: + // There are few distinct scenarios: // 1. Era is in the past so the value might exist. // 2. Era is current or the next one, in which case we definitely have that information. // 3. Era is from the future (more than the next era), in which case we don't have that information. @@ -198,10 +197,9 @@ where handle.record_db_read::(20 + EraRewardSpanFor::::max_encoded_len())?; let era_span_index = DAppStaking::::era_reward_span_index(era); - let reward_span = - EraRewards::::get(&era_span_index).unwrap_or(EraRewardSpanFor::::new()); + let reward_span = EraRewards::::get(&era_span_index).unwrap_or_default(); - let staked = reward_span.get(era).map_or(Zero::zero(), |r| r.staked); + let staked = reward_span.get(era).map_or(Zero::zero(), |r| r.staked()); Ok(staked.into()) } else if era == current_era || era == current_era.saturating_add(1) { @@ -213,9 +211,9 @@ where let current_era_info = CurrentEraInfo::::get(); if era == current_era { - Ok(current_era_info.current_stake_amount.total()) + Ok(current_era_info.current_stake_amount().total()) } else { - Ok(current_era_info.next_stake_amount.total()) + Ok(current_era_info.next_stake_amount().total()) } } else { Err(RevertReason::custom("Era is in the future").into()) @@ -325,7 +323,7 @@ where }; // call pallet-dapps-staking - let contract_stake = ContractStake::::get(&dapp_info.id); + let contract_stake = ContractStake::::get(&dapp_info.id()); Ok(contract_stake.total_staked_amount(current_period_number)) } @@ -592,7 +590,7 @@ where let protocol_state = ActiveProtocolState::::get(); Ok(PrecompileProtocolState { - era: protocol_state.era.into(), + era: protocol_state.era().into(), period: protocol_state.period_number().into(), subperiod: subperiod_id(&protocol_state.subperiod()), }) diff --git a/precompiles/dapp-staking/src/test/mock.rs b/precompiles/dapp-staking/src/test/mock.rs index bc0ad4e1d..04db72aa5 100644 --- a/precompiles/dapp-staking/src/test/mock.rs +++ b/precompiles/dapp-staking/src/test/mock.rs @@ -431,15 +431,15 @@ pub(crate) fn run_for_blocks(n: BlockNumber) { /// /// Function has no effect if era is already passed. pub(crate) fn advance_to_era(era: EraNumber) { - assert!(era >= ActiveProtocolState::::get().era); - while ActiveProtocolState::::get().era < era { + assert!(era >= ActiveProtocolState::::get().era()); + while ActiveProtocolState::::get().era() < era { run_for_blocks(1); } } /// Advance blocks until next era has been reached. pub(crate) fn advance_to_next_era() { - advance_to_era(ActiveProtocolState::::get().era + 1); + advance_to_era(ActiveProtocolState::::get().era() + 1); } /// Advance blocks until next period type has been reached. diff --git a/precompiles/dapp-staking/src/test/tests_v2.rs b/precompiles/dapp-staking/src/test/tests_v2.rs index df47e7b3f..5e358f35f 100644 --- a/precompiles/dapp-staking/src/test/tests_v2.rs +++ b/precompiles/dapp-staking/src/test/tests_v2.rs @@ -41,7 +41,7 @@ fn read_current_era_is_ok() { PrecompileCall::read_current_era {}, ) .expect_no_logs() - .execute_returns(ActiveProtocolState::::get().era); + .execute_returns(ActiveProtocolState::::get().era()); // advance a few eras, check value again advance_to_era(7); @@ -52,7 +52,7 @@ fn read_current_era_is_ok() { PrecompileCall::read_current_era {}, ) .expect_no_logs() - .execute_returns(ActiveProtocolState::::get().era); + .execute_returns(ActiveProtocolState::::get().era()); }); } @@ -89,7 +89,7 @@ fn read_era_reward_is_ok() { let era_rewards_span = EraRewards::::get(span_index).expect("Entry must exist."); let expected_reward = era_rewards_span .get(era) - .map(|r| r.staker_reward_pool + r.dapp_reward_pool) + .map(|r| r.staker_reward_pool() + r.dapp_reward_pool()) .expect("It's history era so it must exist."); assert!(expected_reward > 0, "Sanity check."); @@ -125,7 +125,7 @@ fn read_era_staked_is_ok() { ::SmartContract::evm(smart_contract_address); let amount = 1_000_000_000_000; register_and_stake(staker_h160, smart_contract.clone(), amount); - let anchor_era = ActiveProtocolState::::get().era; + let anchor_era = ActiveProtocolState::::get().era(); // 1. Current era stake must be zero, since stake is only valid from the next era. precompiles() @@ -167,7 +167,7 @@ fn read_era_staked_is_ok() { staker_h160, precompile_address(), PrecompileCall::read_era_staked { - era: ActiveProtocolState::::get().era + 2, + era: ActiveProtocolState::::get().era() + 2, }, ) .expect_no_logs() @@ -605,7 +605,7 @@ fn withdraw_unbonded_is_ok() { )); // Advance enough into time so unlocking chunk can be claimed - let unlock_block = Ledger::::get(&staker_native).unlocking[0].unlock_block; + let unlock_block = Ledger::::get(&staker_native).unlocking_chunks()[0].unlock_block; run_to_block(unlock_block); // Execute legacy call, expect unlocked funds to be claimed back diff --git a/precompiles/dapp-staking/src/test/tests_v3.rs b/precompiles/dapp-staking/src/test/tests_v3.rs index 522f1fb76..df2f420f5 100644 --- a/precompiles/dapp-staking/src/test/tests_v3.rs +++ b/precompiles/dapp-staking/src/test/tests_v3.rs @@ -43,7 +43,7 @@ fn protocol_state_is_ok() { let state = ActiveProtocolState::::get(); let expected_outcome = PrecompileProtocolState { - era: state.era.into(), + era: state.era().into(), period: state.period_number().into(), subperiod: subperiod_id(&state.subperiod()), }; @@ -161,8 +161,9 @@ fn claim_unlocked_is_ok() { )); // Advance enough into time so unlocking chunk can be claimed - let unlock_block = - Ledger::::get(&AddressMapper::into_account_id(ALICE)).unlocking[0].unlock_block; + let unlock_block = Ledger::::get(&AddressMapper::into_account_id(ALICE)) + .unlocking_chunks()[0] + .unlock_block; run_to_block(unlock_block); // Claim unlocked chunk and verify event diff --git a/tests/integration/src/dapp_staking.rs b/tests/integration/src/dapp_staking.rs index bff9c14ce..e991141fa 100644 --- a/tests/integration/src/dapp_staking.rs +++ b/tests/integration/src/dapp_staking.rs @@ -31,7 +31,7 @@ fn dapp_staking_triggers_inflation_recalculation() { // It's not feasible to run through all the blocks needed to trigger all the eras. // Instead, we force the era to change on a block by block basis. - while ActiveProtocolState::::get().era < recalculation_era - 1 { + while ActiveProtocolState::::get().era() < recalculation_era - 1 { assert_ok!(DappStaking::force(RuntimeOrigin::root(), ForcingType::Era,)); run_for_blocks(1); assert_eq!( @@ -49,11 +49,11 @@ fn dapp_staking_triggers_inflation_recalculation() { // Again, hacky approach to speed things up. // This doesn't influence anything in the protocol essentially. ActiveProtocolState::::mutate(|state| { - state.next_era_start = System::block_number() + 5; + state.set_next_era_start(System::block_number() + 5); }); // Another sanity check, move block by block and ensure protocol works as expected. - let target_block = ActiveProtocolState::::get().next_era_start; + let target_block = ActiveProtocolState::::get().next_era_start(); run_to_block(target_block - 2); assert_eq!( init_inflation_config, diff --git a/tests/integration/src/governance.rs b/tests/integration/src/governance.rs index ac8667b5f..746a5e99a 100644 --- a/tests/integration/src/governance.rs +++ b/tests/integration/src/governance.rs @@ -162,7 +162,7 @@ fn community_council_can_execute_dapp_staking_calls() { // Check that the lock was successful assert_eq!( - pallet_dapp_staking::Ledger::::get(&proxy_account).locked, + pallet_dapp_staking::Ledger::::get(&proxy_account).locked(), lock_amount ); }) diff --git a/tests/integration/src/setup.rs b/tests/integration/src/setup.rs index 8b555ae23..7fcf40649 100644 --- a/tests/integration/src/setup.rs +++ b/tests/integration/src/setup.rs @@ -32,7 +32,6 @@ use cumulus_primitives_parachain_inherent::ParachainInherentData; use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder; pub use astar_primitives::{ - dapp_staking::CycleConfiguration, governance::{ CommunityCouncilMembershipInst, MainCouncilMembershipInst, OracleMembershipInst, TechnicalCommitteeMembershipInst, @@ -195,20 +194,6 @@ impl ExtBuilder { ext.execute_with(|| { System::set_block_number(1); - let era_length = ::CycleConfiguration::blocks_per_era(); - let voting_period_length_in_eras = - ::CycleConfiguration::eras_per_voting_subperiod(); - - pallet_dapp_staking::ActiveProtocolState::::put(pallet_dapp_staking::ProtocolState { - era: 1, - next_era_start: era_length.saturating_mul(voting_period_length_in_eras.into()) + 1, - period_info: pallet_dapp_staking::PeriodInfo { - number: 1, - subperiod: pallet_dapp_staking::Subperiod::Voting, - next_subperiod_start_era: 2, - }, - maintenance: false, - }); pallet_dapp_staking::Safeguard::::put(false); // Ensure the initial state is set for the first block diff --git a/tests/xcm-simulator/src/tests/general.rs b/tests/xcm-simulator/src/tests/general.rs index 6c1f3253c..b586ea35a 100644 --- a/tests/xcm-simulator/src/tests/general.rs +++ b/tests/xcm-simulator/src/tests/general.rs @@ -220,7 +220,7 @@ fn remote_dapps_staking_staker_claim() { )); // advance enough blocks so we at least get to era 5 - this gives us era 2, 3 and 4 for claiming - while pallet_dapp_staking::ActiveProtocolState::::get().era < 5 { + while pallet_dapp_staking::ActiveProtocolState::::get().era() < 5 { advance_parachain_block_to(parachain::System::block_number() + 1); } // Ensure it's not first block so event storage is clear