Dynamic Multidimensional Fees for P-chain and X-chain #69
Replies: 5 comments 1 reply
-
The update fee rates formula outlined above has a flaw: it does not account for a time elapsed among parent and child blocks. We'd expect that the largest the time elapsed among them, the less should be the effect of parent block complexity in setting the child block fee rates. This does not happen above, since only block complexity is considered, not the elapsed time. We consider the following improvement over the formula: where:
Note that technically two consecutive blocks can have the same timestamp. In such a case we may consider I'll comment later on about sizing these parameters. |
Beta Was this translation helpful? Give feedback.
-
We proposed above the following formula to update fees: The main features of the exponential update are:
From an implementation standpoint, we would like to implement the update formula using only integer math. where The approximation keeps the two properties listed above and it's much easier to implement with interger math |
Beta Was this translation helpful? Give feedback.
-
P-chain_complexities.tar.gz collects the historical complexities of P-chain blocks as measure by the current implementation.
This data can be used to tune the dynamic fees parameters. |
Beta Was this translation helpful? Give feedback.
-
I very much like the use of market based Dynamic Multidimensional Fees in these chains. The math is beyond my capacity to comment. It is definitely the right direction to head. |
Beta Was this translation helpful? Give feedback.
-
This discussion resulted in the creation of ACP-83. Please refer to the ACP-83 Discussion for continued debate. |
Beta Was this translation helpful? Give feedback.
-
Abstract
Introduce a dynamic and multidimensional fees scheme for both P-chain and X-chain.
A dynamic fee scheme helps to preserve the stability of the chains as it provides an economic incentive for users to hold their transactions issuance in times of high load.
A multidimensional fee scheme ensures that different resources consumed during transaction processing, like bandwidth, chain state occupation and cpu needed to verify cryptographic signatures, are metered and priced differently, according to their different capacities. When network resources are independently metered, they can be granularly priced and thus optimally utilized by the network participants.
Motivation
P-chain and X-chain fees have currently fixed values and in some cases they are zero.
This makes transaction issuance very predictable but it does not help preserving stability of the chains in high load situations. In fact, users do not have any economic incentive to delay their transaction issuances when chains are loaded, thus contributing to sustaining the load.
The C-chain is the Primary Network chain with the heaviest traffic, and it already has a dynamic fees scheme. We should introduce a dynamic fees scheme for P-chain and X-chain as well to improve Primary Network stability in anticipation of an increase in the network activity.
Unlike the C-chain, however, we propose a multidimensional fee scheme with exponential updates. A multidimensional fee scheme with optional priority fees is already in use in our HyperSDK and its efficiency is backed by academic research. We propose to adopt the same scheme for the P-chain and X-chain with a single change: the use of an exponential update scheme which is proven to have nicer stability properties than the scheme currently used by the HyperSDK.
Specification
First a few definitions:
We define four fee dimensions,
Bandwidth
,UXTOsReads
,UTXOsWrites
,Compute
, along which metering transactions impact over the P-chain and X-chain. In more details:Bandwidth
measures the transaction size in bytes, a proxy for the network resources needed to disseminate the transaction.UXTOsReads
measures the number of UTXOs referenced as inputs of the transactions, a proxy for the chain state reads needed to verify the transaction.UTXOsWrites
measures the number of UTXOs generated as outputs of the transactions, a proxy for the chain state writes needed to store the transaction.Compute
meters the complexity of signatures verifications, both UTXOs ones and those related to authorization of specific operations.For each fee dimension$i$ , we define a fee rate $r_i$ as the price, denominated in Avax, to be paid if the transaction consumed a unit $u_i$ of fee dimension $i$ .$$fee = \sum_{i=0}^3 r_i \times u_i$$ where $u_i$ is the number of units metered for dimension $i$ .$i$ , we define:
We define the base fee needed to accept a transaction as
We define as priority fee an optional fee paid on top of the base fee to allow speeding up the transaction inclusion in a block.
Finally, for each fee dimension
The dynamic fee algorithm will try to modify fee rates to steer units consumed towards the block target complexity.
Upon activation of the dynamic multidimensional fees scheme we modify block processing as follows:
Backwards Compatibility
Modifying the fee scheme for P-chain and X-chain requires a mandatory upgrade for activation.
Wallet implementations must be modified to handle the new fee scheme to be able to properly finance transactions once the upgrade is activated.
Reference Implementation
For AvalancheGo:
Security Considerations
The new fee scheme is expected to help network stability as it offers economic incentives to users to hold transactions issuance in times of high load. While fees are expected to remain generally low when the system is not loaded, a sudden load increase, with fuller blocks, would push the dynamic fees algo to increase fee rates. The increase is expected to continue until the load is reduced. Load reduction happens by both dropping unconfirmed transactions whose fee-rate is not sufficient anymore and by pushing users that optimize their transactions costs to delay transaction issuance until the fee rate goes down to an acceptable level.
Note finally that the exponential fee update mechanism detailed above is proven to be robust against strategic behaviors of users delaying transactions issuance and then suddenly push a bulk of transactions once the fee rate is low enough.
Open Questions
How will the wallets estimate the fees?
AvalancheGo nodes will provide new APIs exposing the current fee rates, as they are likely to change block by block. Wallets can then use the fees rates to select UTXOs to pay the transaction fees. Moreover Avalanchego implementation proposed above offers a fees.Calculator struct that can be reused by wallets and downstreams to evaluate calculate fees
How will wallets be able to re-issue TXs at a higher fee?
Wallets should be able to simply re-issue the transaction since current AvalancheGo implementation drops mempool transactions whose fee rate is lower than current one. More specifically a transaction may be valid the moment it enters the mempool and it won’t be re-verified as long as it stays in there. However as soon as the transaction is selected to be included in the next block, it is re-verified against the latest preferred tip. If fees are not enough by this time, the transaction is dropped and the wallet can simply re-issue it at a higher fee, or wait for the fee rate to go down. Note that priority fees offer an edge against fee rate spike. A transaction paying just the base fee will be evicted from the mempool in thel face of a fee rate increase, while a transaction paying some extra priority fee may pay enough overall fees to still be accepted despite the fee rate increase.
How does priority fees guarantee a faster block inclusion?
AvalancheGo mempool will be restructured to order transactions by priority fees. Transactions paying priority fees will be selected for block inclusion first, without violating any spend dependency.
Beta Was this translation helpful? Give feedback.
All reactions