Repository navigation
[STF] Saturate balances on incoming deferred transfers - #378
Merged
Merged
Conversation
- caps a balance at `2^64-1` when the deferred transfers received in one `Ψ_A` take it above that value, following Polkajam in the 0.8.0 fuzz campaign since no GP version defines this case - adds `saturating_add_account_balance` for `receive_deferred_transfer`, while `eject` keeps the `AccountBalanceOverflow` error - sums the amounts in `AccumulateInputs::new` with saturation, which silently wrapped in release builds before - shares `update_account_balance` among the balance helpers and tests both saturations and the kept overflow error
0xjunha
force-pushed
the
saturate-balance
branch
from
November 20, 2026 04:46
17ea155 to
e975594
Compare
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.
Summary
Saturates a service balance at
2^64−1when the deferred transfers it receives in one accumulation would take it higher. No GP version defines this case. FastRoll follows the 0.8.0 fuzz campaign here.Deviation from GP 0.8.0
2^64−1, listed in the Deviations of jam-fuzzing#212. GP doesn't describe this.AccountBalanceOverflow, so the block was rejected. In release builds the amounts were also summed with a wrapping.sum()before that check.Changes
receive_deferred_transfer(Psi_A) uses the newAccumulatePartialState::saturating_add_account_balance.AccumulateInputs::newsums the transfer amounts with saturation.add_account_balance,subtract_account_balanceand the new method shareupdate_account_balance.ejectkeepsadd_account_balanceand itsAccountBalanceOverflowerror, since the deviation covers only received transfers.Tests
add_account_balance(theejectpath) still failing withAccountBalanceOverflow.