From b1f57b2eb5ef92315413bdc6762486e8cf1f3885 Mon Sep 17 00:00:00 2001 From: Igor Papandinas <26460174+ipapandinas@users.noreply.github.com> Date: Thu, 22 Aug 2024 16:32:39 +0200 Subject: [PATCH] remove invariant check --- pallets/dapp-staking-v3/src/lib.rs | 16 ++-------------- pallets/dapp-staking-v3/src/test/tests.rs | 4 ---- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/pallets/dapp-staking-v3/src/lib.rs b/pallets/dapp-staking-v3/src/lib.rs index c07d7eadf..63f061602 100644 --- a/pallets/dapp-staking-v3/src/lib.rs +++ b/pallets/dapp-staking-v3/src/lib.rs @@ -2458,22 +2458,15 @@ pub mod pallet { /// ### Invariants of ContractStake /// - /// 1. Iterating over all contracts in [`ContractStake`] should yield the correct staked amounts compared to current era in [`CurrentEraInfo`] - /// 2. Each staking entry in [`ContractStake`] should be greater than or equal to the [`T::MinimumStakeAmount`] constant. + /// 1. Each staking entry in [`ContractStake`] should be greater than or equal to the [`T::MinimumStakeAmount`] constant. #[cfg(any(feature = "try-runtime", test))] pub fn try_state_contract_stake() -> Result<(), sp_runtime::TryRuntimeError> { let current_period_number = ActiveProtocolState::::get().period_number(); - let current_era_info = CurrentEraInfo::::get(); - let current_era_total_stake = current_era_info.total_staked_amount_next_era(); - - let mut total_staked = Balance::zero(); for (_, contract) in ContractStake::::iter() { let contract_stake = contract.total_staked_amount(current_period_number); - total_staked += contract_stake; - - // Invariant 2 + // Invariant 1 if contract_stake > Balance::zero() && contract_stake < T::MinimumStakeAmount::get() { return Err( @@ -2482,11 +2475,6 @@ pub mod pallet { } } - // Invariant 1 - if total_staked != current_era_total_stake { - return Err("Mismatch between ContractStake totals and CurrentEraInfo.".into()); - } - Ok(()) } diff --git a/pallets/dapp-staking-v3/src/test/tests.rs b/pallets/dapp-staking-v3/src/test/tests.rs index a97ce3896..28e863633 100644 --- a/pallets/dapp-staking-v3/src/test/tests.rs +++ b/pallets/dapp-staking-v3/src/test/tests.rs @@ -483,8 +483,6 @@ fn unregister_no_stake_is_ok() { } #[test] -#[ignore] -/// TODO - Reestablish this test once this bug is fixed: fn unregister_with_active_stake_is_ok() { ExtBuilder::default().build_and_execute(|| { // Prepare dApp @@ -1324,9 +1322,7 @@ fn unstake_with_zero_amount_fails() { }) } -/// TODO - Reestablish this test once this bug is fixed: #[test] -#[ignore] fn unstake_on_invalid_dapp_fails() { ExtBuilder::default().build_and_execute(|| { let account = 2;