fix(conflict): assign result of bail.Quo so non-voters are bailed at 1/5 stake#2293
Open
Tsunami43 wants to merge 1 commit into
Open
fix(conflict): assign result of bail.Quo so non-voters are bailed at 1/5 stake#2293Tsunami43 wants to merge 1 commit into
Tsunami43 wants to merge 1 commit into
Conversation
…1/5 stake
In HandleAndCloseVote, the bail amount for providers that failed to vote
was computed as:
bail := stake
bail.Quo(sdk.NewIntFromUint64(BailStakeDiv))
sdk.Int (cosmossdk.io/math v1.3.0) is immutable: Quo has a value
receiver and returns a freshly allocated Int (div() does
new(big.Int).Quo(...)). The receiver is never mutated, so the return
value here was discarded and `bail` stayed equal to the full `stake`.
As a result JailEntry received the entire stake as bail instead of
stake / BailStakeDiv (BailStakeDiv = 5, i.e. 20%). The contract just
below at line ~137 (totalVotes.Quo(...)) uses the correct assigning
form, confirming this was an oversight.
Note on current blast radius: pairingKeeper.JailEntry is still a TODO
stub that does not consume the bail coin, so this bug has no on-chain
effect today. It is a latent correctness bug that would surface as a
5x over-bail for non-voting providers the moment JailEntry is
implemented. Fixing now so the implementation lands against correct
input.
Fix: assign the division result.
bail := stake.Quo(sdk.NewIntFromUint64(BailStakeDiv))
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
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
Issue: #2292
In
HandleAndCloseVote(x/conflict/keeper/vote.go), the bail amount for providers that failed to vote was computed as:sdk.Int (cosmossdk.io/math v1.3.0) is immutable: Quo has a value receiver and returns a freshly allocated Int (SafeQuo → div() does new(big.Int).Quo(...)). The receiver is never mutated, so the return value here was discarded and bail stayed equal to the full stake.
As a result JailEntry received the entire stake as bail instead of stake / BailStakeDiv (BailStakeDiv = 5, i.e. 20%). The call just below at line ~137 (halfTotalVotes := totalVotes.Quo(...)) uses the correct assigning form, confirming this was an oversight.
Current blast radius: pairingKeeper.JailEntry is still a // todo stub that does not consume the bail coin, so this bug has no on chain effect today and the change is not consensus-breaking. It is a latent correctness bug that would surface as a 5x over bail for non-voting providers the moment JailEntry is implemented. Fixing now so that implementation lands against correct input.
Fix: assign the division result.
bail := stake.Quo(sdk.NewIntFromUint64(BailStakeDiv))
Files to review