Skip to content

Commit 738f936

Browse files
Merge pull request 0xPolygon#293 from 0xPolygon/empieichO-docs-review
Draft: Review zkEVM - minor typos
2 parents fc90a5b + 281c55b commit 738f936

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

docs/zkEVM/architecture/user-fees.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,6 @@ Their corresponding pertinent questions are:
8080
- How do L2 solutions address and reconcile any discrepancies between the L1 gas schema and the real resource utilization on L2?
8181

8282

83-
### Time-related variations
84-
85-
So, how can the fact that the L1 $\texttt{gasPrice}$ varies with time be taken into account?
86-
87-
In order to obtain L1 gas prices, we can poll for it every 5 seconds. As shown in the timeline below, gas prices vary with time.
88-
89-
![Figure: Gas price timeline](../../img/zkEVM/gas-timeline-001.png)
90-
91-
9283
## Gas price suggester
9384

9485
Let's take a quick view of the initial phase of the process, which involves the RPC component of zkEVM.
@@ -104,6 +95,15 @@ See the the picture below for an overview of the pre-execution process.
10495
![Figure: RPC tx pre-execution](../../img/zkEVM/rpc-tx-preexec.png)
10596

10697

98+
### Time-related variations
99+
100+
So, how can the fact that the L1 $\texttt{gasPrice}$ varies with time be taken into account?
101+
102+
In order to obtain L1 gas prices, we can poll for it every 5 seconds. As shown in the timeline below, gas prices vary with time.
103+
104+
![Figure: Gas price timeline](../../img/zkEVM/gas-timeline-001.png)
105+
106+
107107
### Naïve approach
108108

109109
Let's look at this in two parts; gasPrice suggestion, and transaction sending.
@@ -512,7 +512,10 @@ Recall that, since we are using a "wrong" state root, this gas is only an estima
512512
Hence, using the previously explained formulas, the total transaction cost is:
513513

514514
$$
515-
\texttt{TotalTxPrice} = \texttt{DataCost} \cdot \texttt{L1GasPrice} + \texttt{GasUsed} \cdot \texttt{L1GasPrice} \cdot \texttt{L1GasPriceFactor}\\ \implies \texttt{TotalTxPrice} = (200 · 16 + 100 · 4) · 21 + 60, 000 · 21 · 0.04 = 126, 000\ \texttt{GWei}
515+
\begin{aligned}
516+
&\texttt{TotalTxPrice} = \texttt{DataCost} \cdot \texttt{L1GasPrice} + \texttt{GasUsed} \cdot \texttt{L1GasPrice} \cdot \texttt{L1GasPriceFactor}\\
517+
&\implies \texttt{TotalTxPrice} = (200 · 16 + 100 · 4) · 21 + 60, 000 · 21 · 0.04 = 126, 000\ \texttt{GWei}
518+
\end{aligned}
516519
$$
517520

518521
Observe that the $21$ appearing in the substitution is the $\texttt{L1GasPrice}$ at the time of sending the transaction.
@@ -750,7 +753,7 @@ Hence, if something goes bad in later steps, and the gas consumption deviates si
750753

751754
On the contrary, if the process goes as estimated and the consumed gas is similar to the estimated one, we can reward the user by modifying the previously introduced $\texttt{effectivePercentage}$.
752755

753-
It's important to observe that, among all the transactions stored in the Pool, those that are prioritized at the time of sequencing are the ones with higher $\texttt{effectiveGasPrice}$, due to the prioritization introduced with $\texttt{ratioPriority}$.
756+
It's important to observe that, among all the transactions stored in the Pool, those that are prioritized at the time of sequencing are the ones with higher $\texttt{effectiveGasPrice}$, due to the prioritization introduced with $\texttt{PriorityRatio}$.
754757

755758
Observe that $\texttt{effectiveGasPrice}$ is not computed in the RPC but in the sequencer. So, it is possible that the suggested gas price at this moment, differs from the one suggested when the user sent the transaction.
756759

@@ -851,9 +854,9 @@ Let’s examine the above figure in more detail.
851854

852855
Henceforth, the user is charged the full $\texttt{SignedGasPrice}$, so the Executor will execute the transaction using it, concluding the sequencing process.
853856

854-
- Conversely, if $\texttt{SignedGasPrice} > \texttt{EEGP}$, there is a room for further adjustment of the gas price that will be charged to the user.
857+
- Conversely, if $\texttt{SignedGasPrice} > \texttt{EEGP}$, there's room for further adjustment of the gas price that will be charged to the user.
855858

856-
3. In the previous case, it was necessary to compute a more precise effective gas price based on the accurate amount of gas, denoted as $\texttt{GasUsedNew}$, obtained during the transaction’s execution using the correct state root at the time of sequencing transactions (which was not known earlier for straightforward reasons).
859+
3. In the previous case, it was necessary to compute a more precise effective gas price based on the accurate amount of gas, denoted as $\texttt{GasUsedNew}$, obtained during the transaction’s execution using the correct state root at the time of sequencing transactions.
857860

858861
Henceforth, the Executor executes the transaction using $\texttt{EEGP}$, obtaining $\texttt{GasUsedNew}$, which the sequencer utilizes to compute a new effective gas price, referred to as $\texttt{NEGP}$.
859862

0 commit comments

Comments
 (0)