-
Notifications
You must be signed in to change notification settings - Fork 4.1k
fix(x/staking): validate bond_denom exists before updating params #25739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(x/staking): validate bond_denom exists before updating params #25739
Conversation
Fixes cosmos#25724 Add validation in MsgUpdateParams handler to check that bond_denom has non-zero supply before allowing governance to update it. This prevents governance from setting bond_denom to a non-existent denom which would place the chain in an unsafe state. The fix queries the bank module's GetSupply to verify the denom exists on-chain. If supply is zero, the handler returns ErrInvalidDenom. Changes: - Add supply check in UpdateParams handler using bankKeeper.GetSupply - Return ErrInvalidDenom if bond_denom has zero supply - Add test case for non-existent denom validation - Add ErrInvalidDenom error constant (error code 46) - Fix autocli help message golden file (TimeoutTimestamp -> TimeoutDuration) Signed-off-by: bit2swaz <[email protected]>
|
@aljo242 this PR is updated with signed commits (DCO + Verified). Hope it helps :) |
b2f1a2b to
41705cd
Compare
Addresses issue cosmos#25724 by validating that the bond_denom has a non-zero supply before allowing MsgUpdateParams to update the staking parameters. Changes based on PR review feedback: - Use sdkerrors.ErrInvalidRequest instead of custom error - Remove brittle mock-based test case - Add comprehensive integration test using real keepers The validation checks bankKeeper.GetSupply() to ensure the denom exists with non-zero supply, preventing invalid denom configuration. Signed-off-by: bit2swaz <[email protected]>
41705cd to
9115824
Compare
|
@aljo242 thanks for the feedback :)
All tests are passing and commits are signed. Ready and waiting for re-review :) |
aljo242
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a changelog entry for this indicating that it is a breaking change
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #25739 +/- ##
=======================================
Coverage 68.22% 68.23%
=======================================
Files 894 894
Lines 58146 58149 +3
=======================================
+ Hits 39671 39677 +6
+ Misses 18475 18472 -3
🚀 New features to boost your workflow:
|
- Refactor integration tests to use testify/require instead of gotest.tools/assert - Add breaking change entry to CHANGELOG.md for bond_denom validation - This addresses reviewer feedback for strict failure modes in tests Signed-off-by: bit2swaz <[email protected]>
d256b0b to
a968cff
Compare
|
@aljo242 updated based on the latest feedback:
commit is fully signed (-s) and verified (-S). Again ready for re-review :) |
|
@aljo242 thanks for the merge from main. looks like the CI workflows are currently "awaiting approval" to run. could you trigger those when you have a moment? also, please feel free to let me know if there's anything else needed from me to get this landed :) |
Moves the bond denom supply validation test from integration to the msg_server unit test suite using mocks, as requested.
|
@technicallyty ive removed the extra integration test file and moved the test case into Validated with: |
technicallyty
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the PR.
Description
Closes #25724
Adds validation to prevent governance from setting
bond_denomto a non-existent denom viaMsgUpdateParams.Problem
The staking module currently allows governance to update
bond_denomwithout validating that the denom exists on-chain. This creates a governance footgun where:bond_denomto a non-existent denom places the chain in an unsafe stateSolution
Add validation in the
UpdateParamshandler to check that the newbond_denomhas non-zero supply in the bank module before allowing the update.Changes
UpdateParamshandler usingbankKeeper.GetSupplyErrInvalidDenomifbond_denomhas zero supplyErrInvalidDenomerror constant (code 46)Testing