Inconsistent Transferable Balance Calculation Logic #1833
Description
An inconsistency has been identified in the Polkadot SDK concerning the logic used for computing transferable balances. This divergence may mislead users about the actual spendable balance, potentially leading to transaction failures due to inadequate fee coverage.
The inconsistency arises from the utilization of different formulas:
- Old Formula:
transferable = free - max(frozen, reserved)
. - New Formula:
transferable = free - (frozen - reserved)
.
This originates from the CurrencyAdapter
, which relies on the outdated Currency
trait as illustrated here. The new transferable balance is computed utilizing the reducible_balances
function defined here.
The discrepancy is particularly noticeable in the eth.getBalance
method in Frontier, where the new formula is employed. Under certain circumstances, a positive balance may be displayed, indicating available funds. However, transactions may fail due to an insufficient balance to cover the fees, given that the old formula is utilized for fee calculations.
- Is the discrepancy in the logic for calculating "transferable balance" concerning fees a deliberate design or an oversight?
- Is there a rationale behind not extending the new logic to fee calculations, and if so, what is the reasoning behind this approach?