Skip to content

Conversation

@notJoon
Copy link
Member

@notJoon notJoon commented Aug 25, 2025

Descrption

removeStake updated/created an EmissionRewardState but did not write it back into rewardStates (AVL tree). For new addresses this meant the state was never persisted; for existing ones it could rely on pointer aliasing by accident.

Changes

Persist the updated state by calling:

e.rewardStates.Set(address, rewardState)

at the end of removeStake.

Also, changed the file name which was a typo.

Without persistence, per-address stake and reward debt can become out of sync with totalStakedAmount, leading to incorrect future rewards/claims.

Tests

Added regression tests:

  • TestEmissionRewardManager_removeStake_persistsStateForNewAddress
  • TestEmissionRewardManager_removeStake_updatesPersistedState

@notJoon notJoon self-assigned this Aug 25, 2025
@notJoon notJoon added the bug Something isn't working label Aug 25, 2025
@notJoon notJoon changed the title fix(gno/staker): removeStake not persisting updated reward state fix(gov/staker): removeStake not persisting updated reward state Aug 25, 2025
@sonarqubecloud
Copy link

@notJoon notJoon merged commit 9f02687 into main Aug 25, 2025
48 checks passed
@notJoon notJoon deleted the fix/gov-staker-removestake branch August 25, 2025 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants