Transaction prioritization
Users can sign transactions with gas prices higher than the suggested gas price for prioritized sequencing. That is, $$ exttt > exttt $$ The priority ratio
Users can sign transactions with gas prices higher than the suggested gas price for prioritized sequencing. That is,
The priority ratio is defined as:
Any transaction with , implies that the user has chosen not to have the transaction prioritized.
Computing effective gas price
The computation of the effective gas price (or EGP) involves both the break even gas price and the priority ratio:
Among the transactions stored in the pool database, the transactions with higher are prioritized at the time of sequencing due to the added .
Gas consumption deviations
Since the actual gas consumed can deviate from the estimated gas consumption, we denote the estimated and the 'new' as and , respectively.
The extent of the deviation can be computed as a percentage:
The deviation percentage is compared to a parameter called , which is set to .
This presents 2 scenarios and their corresponding consequences:
-
If the percentage deviation is lower than the final deviation parameter,
it indicates that there is minimal distinction between charging the user with compared to .
Despite potential losses to the network, the user gets charged the amount as the gas price.
-
On the contrary, if the percentage deviation equals or exceeds the deviation parameter,
the difference between executions can be so big it warrants adjustment of the gas price to be , and thus mitigate for potential losses to the network.
Effective percentage
The last parameter called the is used to measure the unused portion of the user's signed gas price.
In order to calculate the , one option is to consider pricing resources based on the number of consumed counters within the Polygon zkEVM's proving system.
However, understanding this metric can be challenging for users because stating the efficiency through counters is a bit complicated.
In favor of better UX, a formula involving gas is applied as it is more user-friendly.
The primary objective is to compute exclusively using gas, while allowing users to prioritize their transactions through the use of gas price, without the need for complex considerations such as used ROM counters.
The effective percentage is computed as follows:
where is the gas price charged at the end of the entire processing by the sequencer.
Note that the amount of wei that the user is charged for processing their transactions can be adjusted by modifying .
This is provided by the sequencer as a single byte:
which is computed from the as follows:
Since having implies having and vice versa, the two terms are used interchangeably.
So, is often referred to as .
Example (Effective percentage)
Setting an of means the .
In which case the user would pay the gas price they signed with, when sending the transaction, in total. That is:
In contrast, setting to means:
Thus, only half of the gas price the user signed with gets charged as the transaction cost:
The transaction execution incurs only half of the signed gas price.
Concluding remarks
The effective gas price scheme, as outlined above, although steeped in details, takes all necessary factors and eventualities into consideration.
Ultimately, the scheme is accurate and fair to both the users and the zkEVM network.
Check out this repo for a detailed example of how the effective gas price is calculated.
The content of this document series was sourced from the User fees document.
Last updated on
Implementing EGP strategy
In this section we provide an elaborate discussion on how Polygon zkEVM network ensures transactions are executed with the best gas price for the user, while in
Index
This section contains specifications of other zkEVM features not covered in the Architecture section of this documentation. First are the two novel languages: T