Skip to content

Conversation

@technicallyty
Copy link
Collaborator

@technicallyty technicallyty commented Dec 11, 2025

validates voting power and returns an error instead of panicking


PR checklist

  • Tests written/updated
  • Changelog entry added in .changelog (we use unclog to manage our changelog)
  • Updated relevant documentation (docs/ or spec/) and code comments

Note

Switch total voting power computation to return errors instead of panicking, add a safe accessor, and update callers/tests accordingly.

  • Types (types/validator_set.go):
    • Change updateTotalVotingPower() to return error instead of panicking on overflow and set totalVotingPower.
    • Add TotalVotingPowerSafe() to get TVP with error handling.
    • Update TotalVotingPower() to panic only if updateTotalVotingPower() returns an error.
    • Use error-based TVP validation in updateWithChangeSet(), ValidatorSetFromProto() (now returns error on bad input), and ValidatorSetFromExistingValidators().
  • Tests (types/validator_set_test.go):
    • Add TestValidatorSetFromProtoReturnsErrorOnOverflow to assert error on TVP overflow from proto input.
    • Update verifyValidatorSet() to handle updateTotalVotingPower() error.
    • Minor import addition for crypto key encoding.

Written by Cursor Bugbot for commit a66f19f. This will update automatically on new commits. Configure here.

@technicallyty technicallyty requested a review from a team as a code owner December 11, 2025 22:57
@technicallyty technicallyty changed the title chore: add voting power validation chore: add voting power validation (v0.38.x) Dec 11, 2025
@technicallyty technicallyty merged commit c96f265 into v0.38.x Dec 12, 2025
23 of 24 checks passed
@technicallyty technicallyty deleted the technicallyty/no-panic-v0.38.x branch December 12, 2025 01:09
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.

3 participants