Conversation
Contributor
|
PR author is not in the allowed authors list. |
kriss39
force-pushed
the
fix/poa-fee-rounding-overshoot
branch
from
September 13, 2026 20:13
229a13f to
1b9a839
Compare
kriss39
force-pushed
the
fix/poa-fee-rounding-overshoot
branch
from
September 14, 2026 08:47
1b9a839 to
8f265eb
Compare
…ce by dust calculateValidatorPendingFees rounds each validator's share, so the sum of the shares can exceed the unallocated amount by a few units of dust (six equal-power validators splitting 1 unit allocate 1.000000000000000002). getUnallocatedFees then computed balance - totalAllocated with DecCoins.Sub, which panics on a negative result, so every subsequent checkpoint (fee withdrawals, validator power updates, key rotations and the WithdrawableFees query) panicked until new fees landed in the module account. The IsAllPositive guard after the subtraction was unreachable. Subtract with SafeSub and keep only the denoms with a positive remainder.
Author
|
Replaced the commit with a signed one (396760f, same content) so it shows as Verified; the force-push briefly auto-closed the PR, reopened. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
calculateValidatorPendingFeesrounds each validator's share of the unallocated fees (QuoDecrounds half-even at 18 decimals), so the sum of the shares can exceed the amount that was split by a few units of dust. Six equal-power validators splitting 1 unit each get0.166666666666666667, andtotalAllocatedFeesbecomes1.000000000000000002while the module balance is1.getUnallocatedFeesthen computesbalance - totalAllocatedwithDecCoins.Sub, which panics on a negative result (negative coin amount). The!unallocated.IsAllPositive()guard right after it is unreachable. Every call site ofcheckpointAllValidatorspanics until new fees land in the module account:WithdrawValidatorFees(MsgWithdrawValidatorFees)UpdateValidator),AddValidator,RotateConsPubKeyWithdrawableFeesqueryOn a chain with zero-fee txs, or with fees in a denom other than the one that overshot, the state does not recover by itself.
Changes
SafeSuband keep only the denoms that still have a positive remainder, so an overshoot in one denom neither panics nor blocks allocation of new fees in other denoms.TestGetUnallocatedFeesRoundingOvershoot(panics onmain). It also checks the query and withdraw paths and that new fees in another denom are still allocated.The rounding itself is left unchanged (switching to
QuoDecTruncatewould change existing allocations by 1e-18 and the expectations inTestProportionalDistribution); the dust-level overshoot is harmless once it can no longer panic. Happy to switch to truncation instead if you prefer a hard "allocated ≤ balance" invariant.enterprise/poatests pass.