Skip to content

fix(fsm): check closure error 'e' not outer 'err' in ConformStateToParamUpdate - #494

Open
Sertug17 wants to merge 1 commit into
canopy-network:mainfrom
Sertug17:fix/conform-state-error-check
Open

fix(fsm): check closure error 'e' not outer 'err' in ConformStateToParamUpdate#494
Sertug17 wants to merge 1 commit into
canopy-network:mainfrom
Sertug17:fix/conform-state-error-check

Conversation

@Sertug17

@Sertug17 Sertug17 commented Aug 4, 2026

Copy link
Copy Markdown

Closes #493

Problem

In ConformStateToParamUpdate() (fsm/gov.go), the error returned by SetValidatorUnstakingIfBelowMinimum was assigned to the closure's named return variable e, but the condition checked the outer function-scope variable err which is always nil inside the closure (it only gets assigned when IterateAndExecute returns).

This caused errors to be silently discarded, potentially leaving validators below the new minimum stake active in committees after a governance parameter update.

Fix

One-line change: err != nile != nil

// Before (buggy):
if _, e = s.SetValidatorUnstakingIfBelowMinimum(v, params.Validator); err != nil {

// After (correct):
if _, e = s.SetValidatorUnstakingIfBelowMinimum(v, params.Validator); e != nil {

…teToParamUpdate

In ConformStateToParamUpdate(), after calling SetValidatorUnstakingIfBelowMinimum,
the code checked the outer 'err' variable (still nil inside the closure) instead
of the closure's own named return variable 'e'. This caused errors from
SetValidatorUnstakingIfBelowMinimum to be silently discarded, potentially leaving
validators below minimum stake active after a governance parameter update.

Fixes canopy-network#493
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Silent error discard in ConformStateToParamUpdate: wrong variable checked after SetValidatorUnstakingIfBelowMinimum

1 participant