Skip to content

Commit

Permalink
remove invariant check
Browse files Browse the repository at this point in the history
  • Loading branch information
ipapandinas committed Aug 22, 2024
1 parent 87e4044 commit b1f57b2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
16 changes: 2 additions & 14 deletions pallets/dapp-staking-v3/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<T>::get().period_number();
let current_era_info = CurrentEraInfo::<T>::get();
let current_era_total_stake = current_era_info.total_staked_amount_next_era();

let mut total_staked = Balance::zero();

for (_, contract) in ContractStake::<T>::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(
Expand All @@ -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(())
}

Expand Down
4 changes: 0 additions & 4 deletions pallets/dapp-staking-v3/src/test/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,6 @@ fn unregister_no_stake_is_ok() {
}

#[test]
#[ignore]
/// TODO - Reestablish this test once this bug is fixed: <https://github.com/AstarNetwork/Astar/issues/1333>
fn unregister_with_active_stake_is_ok() {
ExtBuilder::default().build_and_execute(|| {
// Prepare dApp
Expand Down Expand Up @@ -1324,9 +1322,7 @@ fn unstake_with_zero_amount_fails() {
})
}

/// TODO - Reestablish this test once this bug is fixed: <https://github.com/AstarNetwork/Astar/issues/1333>
#[test]
#[ignore]
fn unstake_on_invalid_dapp_fails() {
ExtBuilder::default().build_and_execute(|| {
let account = 2;
Expand Down

0 comments on commit b1f57b2

Please sign in to comment.