next_stake_amount
in CurrentEraInfo
storage is not updated on contract unregistration
#1333
Labels
next_stake_amount
in CurrentEraInfo
storage is not updated on contract unregistration
#1333
Description
A storage invariant issue was detected through
try-state
checks on theCurrentEraInfo
item.The
next_stake_amount
inCurrentEraInfo
is not updated when a contract is unregistered. This is a problem because the next stake amount does not accurately reflect the total amount staked when iterating over all contracts inContractStake
.Steps to Reproduce
This issue can be reproduced by executing the tests
unstake_on_invalid_dapp_fails
&unregister_with_active_stake_is_ok
.Suggested Solution
Before removing the contract, use the
total_staked_amount
helper function along with the current period number to retrieve the contract's staked amount. Then, adjust thenext_stake_amount
inCurrentEraInfo
by subtracting the unregistered contract staked amount.The text was updated successfully, but these errors were encountered: