RPC transaction flow
The RPC flow phase of transactions consists of two stages: - The gas price suggestion. - Pre-execution of transactions. This flow ends with transactions being s
The RPC flow phase of transactions consists of two stages:
- The gas price suggestion.
- Pre-execution of transactions.
This flow ends with transactions being stored in a pool waiting to be executed by the sequencer.
Gas price suggestion
The L2 network (the zkEVM) polls for L1 gas price values and uses them to:
- Suggest L2 gas price to users as per user requests.
- Sets the minimum acceptable L2 gas price, denoted by .
The user then signs transactions with the appropriate gas price, called , based on the suggested L2 gas price, .
Transactions are accepted for pre-execution only if
Pre-execution of transactions
Pre-execution of transactions, which happens at the RPC level, involves estimating the gas required for processing the transactions submitted by the users.
This is internally measured (internal to the zkEVM) in terms of resources spent to execute the transactions. These resources are the numbers of counters used up in the zkEVM ROM.
A transaction is said to be out of counters (OOC) if the signed gas price is insufficient to pay for the required gas units.
OOC transactions get rejected straight away, while those with no OOC stand a chance to be added to the pool.
At this stage of the flow, the RPC also computes the "breakeven gas price", denoted by . That is,
where is the L2's marginal profit for transaction processing.
Transactions with no OOC get added to the pool of transactions if,
-
Either .
where is the RPC's estimated gas cost.
-
Or .
The total fees paid by the user is given by:
The RPC flow is summarized in the figure below.

Example (RPC tx flow)
Consider a scenario where a user sends a query for a suggested gas price during a 5-minute interval, as shown in the figure below.
Values of L1 gas prices, polled every 5 seconds, are displayed above the timeline, while the corresponding L2 gas prices are depicted below the timeline. See the figure below.

-
Observe that, in the above timeline, the user sends a query at the time indicated by the dotted-arrow on the left. And that's when is .
The RPC node responds with a , as the value of the suggested L2 gas price.
This value is obtained as follows:
where is the zkEVM's suggested factor.
-
Let's suppose the user sends a transaction signed with a gas price of . That is, .
However, by the time the user sends the signed transaction, the L1 gas price is no longer but . And its correponding suggested gas price is .
Note that the minimum suggested L2 gas price, in the 5-min time interval, is . And since
the transaction gets accepted for pre-execution.
-
At this point, the RPC makes a request for pre-execution. That is, getting an estimation for the gas used, computed with a state root that differs from the one used when the transaction is sequenced.
In this case, suppose an estimation of gas used is , without an out of counters (OOC) error.
-
Since there's no out of counters (OOC) error, the next step is to compute the .
Suppose it works out to be:
(Details on how this calculation are covered later in the Implementing EGP strategy section.)
-
As noted in the outline of the RPC transaction flow, one more check needs to be done. That is, testing whether:
Using the yields:
And since , the transaction is not immediately stored in the transaction pool.
-
However, since
and despite the risk of the network sponsoring the transaction, it is included in the transaction pool.
Last updated on
User transaction flow
Next, we provide a concise description of Polygon zkEVM's approach to calculating the effective gas price. It's an overview of the end-to-end flow of transactio
Sequencer transaction flow
In this phase of the end-to-end transaction flow, transactions go through different stages, depending on the user's $ exttt $: 1. Sequencing transactions comin