Tags: cometbft/cometbft
Tags
chore: add voting power validation (v0.38.x) (#5520) validates voting power and returns an error instead of panicking --- #### PR checklist - [ ] Tests written/updated - [ ] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog) - [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments <!-- CURSOR_SUMMARY --> --- > [!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. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit a66f19f. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
chore: remove panic (#5525) removes a panic from code #### PR checklist - [ ] Tests written/updated - [ ] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog) - [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Replaces panics on total voting power overflow with error returns, adds a safe accessor, and updates callers and tests accordingly. > > - **types/validator_set.go**: > - `updateTotalVotingPower` now returns `error` instead of panicking on overflow; propagates error where applicable. > - Added `TotalVotingPowerSafe()` to compute/return total voting power or an error. > - `TotalVotingPower()` now panics only if `updateTotalVotingPower()` returns an error. > - Updated callers: `updateWithChangeSet`, `ValidatorSetFromProto`, and `ValidatorSetFromExistingValidators` to handle/propagate errors. > - **tests** (`types/validator_set_test.go`): > - Added `TestValidatorSetFromProtoReturnsErrorOnOverflow`. > - Adjusted tests to handle new error-returning behavior (e.g., checking `require.NoError` from `updateTotalVotingPower`). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit d7d7ae4. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
Merge commit from fork * add VaidateBasic to BitArray to ensure Bits and len(Elems) are valid * call ValidateBasic on BitArrays when receiving as a msg from exteranl nodes * enfore SetIndex is not setting out of bounds * add guard to getNumTrueIndices getNumTrueIndices will index out of bounds if Bits and Elems have a mismatch where len(elems) != (bits+63)/64, this guard makes it simply return 0 if this mismatch is present * changelog * fix missing import for v0.38.x * update changelog for release of v0.38.19 * remove duplicate bug fixes from unreleased * fix changelog date * fix lint * fix expected error string in test
Merge commit from fork * add VaidateBasic to BitArray to ensure Bits and len(Elems) are valid * call ValidateBasic on BitArrays when receiving as a msg from exteranl nodes * enfore SetIndex is not setting out of bounds * add guard to getNumTrueIndices getNumTrueIndices will index out of bounds if Bits and Elems have a mismatch where len(elems) != (bits+63)/64, this guard makes it simply return 0 if this mismatch is present * changelog * fix missing import for v0.38.x * update chagnelog for release * fix changelog date * bump version.go to 0.37.16 as default * lint * fix expected error string in test
PreviousNext