Skip to content

Conversation

paritytech-release-backport-bot[bot]

Backport #8108 into stable2509 from RomarQ.

See the documentation on how to use this bot.

…s for a new reserve (#8108)

# Description

Solves: #8099

Based on the documentation and existing code, the usable balance is
computed with the following formula:

```rs
// If Fortitude == Polite
let usable_balance = free - max(frozen - reserved, existential balance)
```

### The problem:

If an account's `free balance` is lower than `frozen balance`, no
reserves will be allowed even though the `usable balance` is enough to
cover the reserve, resulting in a `LiquidityRestrictions` error, which
should not happen.

### Visual example of how `usable/spendable` balance works:
```bash
|__total__________________________________|
|__on_hold__|_____________free____________|
|__________frozen___________|
|__on_hold__|__ed__|
            |__untouchable__|__spendable__|
```

## Integration

No action is required, the changes only change existing code, it does
not add or change any API.

## Review Notes

From my understanding, the function `ensure_can_withdraw` is incorrect,
and instead of checking that the new `free` balance is higher or equal
to the `frozen` balance, it should make sure the `new free` balance is
higher or equal to the `usable` balance.

---------

Co-authored-by: Kian Paimani <[email protected]>
(cherry picked from commit 7c2642d)
Copy link
Contributor

This pull request is amending an existing release. Please proceed with extreme caution,
as to not impact downstream teams that rely on the stability of it. Some things to consider:

  • Backports are only for 'patch' or 'minor' changes. No 'major' or other breaking change.
  • Should be a legit fix for some bug, not adding tons of new features.
  • Must either be already audited or not need an audit.
Emergency Bypass

If you really need to bypass this check: add validate: false to each crate
in the Prdoc where a breaking change is introduced. This will release a new major
version of that crate and all its reverse dependencies and basically break the release.

@sigurpol sigurpol enabled auto-merge (squash) September 19, 2025 13:31
@sigurpol sigurpol merged commit 9b30fca into stable2509 Sep 19, 2025
242 of 247 checks passed
@sigurpol sigurpol deleted the backport-8108-to-stable2509 branch September 19, 2025 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A3-backport Pull request is already reviewed well in another branch.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants