Transparency Report 6: Migrated to FungibleAdapter

Report Author: Toufeeq from the Avail Technical Committee [5CoVaWrZnaV3BSeUJCA8Ca3SPMJDtjT1zPvZkzovkxJU7dkr]
Change Executed: Changes will be applied at block #470,242
Technical Committee Consensus: 5/7 signers https://avail.subscan.io/tech/15?tab=votes

Introduction:
This report aims to provide transparency to the Avail community regarding upcoming and executed network changes. The Avail Technical Committee (TC) has approved a runtime upgrade on Avail Mainnet, addressing an inconsistency identified in the upstream Polkadot SDK related to transferable balance calculations. This issue has been resolved by migrating to the FungibleAdapter in the transaction payment pallet. After a detailed review of the effectiveness, impact, and security of the upgrade, the TC reached a majority consensus (5/7) to proceed with the changes.

Proposed / Executed Changes:

The inconsistency was identified in the Polkadot SDK’s logic for computing transferable balances. This led to misleading calculations for users, potentially resulting in failed transactions due to insufficient balance to cover fees.

Previously, the formula for transferable balances was:

Old Formula: transferable = free - max(frozen, reserved)

The new formula is:

New Formula: transferable = free - (frozen - reserved)

The old formula, used by the CurrencyAdapter, did not accurately account for certain scenarios where frozen and reserved balances overlapped, leading to discrepancies. The migration to the FungibleAdapter, which uses the reducible_balances function (as outlined here), corrects this issue.

Additionally, this upgrade includes improvements to optimize election phragmen bounds.

Code Modifications:
For those interested, you can review the necessary code modifications in the following PRs:

Potential Merits to the Network:

This change brings clarity and precision to balance calculations, ensuring users are accurately informed of their available spendable balance, thus preventing transaction failures. This correction improves the user experience by reducing confusion and avoiding unnecessary errors when covering transaction fees. Furthermore, the optimizations in the election process provide a more efficient and stable staking and governance experience

If you require any additional resources or information, please feel free to drop comments.

Thank you.

1 Like

Great to see the reported issue solved :handshake:

I originally reported this balance issue, which was primarily seen in the .js implementation, sometime in late August. The team did a fantastic job by quickly issuing a fix at the time. However, with the latest runtime upgrade and the changes described in this AIP, it appears that the bug has resurfaced. It seems the problem is mostly related to locked identity deposits, which are now being counted as transferable again despite being locked. Balance discrepancy is visible in the picture

After additional checks, it seems the new transferable balance formula works as intended. In the previous Polkadot SDK, locked and reserved balances never overlapped, which caused users to lock extra tokens for certain actions.

Now, in Avail, locked and reserved tokens can overlap, which is a good change. :handshake: