Skip to content

Commit 87344e7

Browse files
:q
Merge branch 'main' of https://github.com/0xPolygon/polygon-docs into cdk/agglayer-fix
2 parents 3ccd86a + b03dc74 commit 87344e7

File tree

3 files changed

+30
-25
lines changed

3 files changed

+30
-25
lines changed

docs/cdk/version-matrix.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ The table below shows the version compatibility for CDK releases and related com
3737
<td><a href="https://github.com/0xPolygonHermez/zkevm-node/releases/tag/v0.5.13">v0.5.13 </a>(Etrog+uLxLy)</td>
3838
<td><a href="https://hub.docker.com/layers/0xpolygon/cdk-validium-node/0.5.13-cdk.3/images/sha256-b83a0dbf954cc514fa129b8eff4d74e61a46cacbfbd70dce9780ee31d9b62770?context=explore">v0.5.13+cdk.3</a> </td>
3939
<td><a href="https://github.com/0xPolygon/cdk-data-availability/releases/tag/v0.0.5">v0.0.5</a></td>
40-
<td>Prover: <a href="https://github.com/0xPolygonHermez/zkevm-prover/releases/tag/v4.0.19">v4.0.19</a></td>
41-
<td> <a href="https://github.com/0xPolygonHermez/zkevm-rom/tree/v4.0.0-fork.7">v4.0.0-fork.7</a></td>
42-
<td>Bridge: <a href="https://github.com/0xPolygonHermez/zkevm-bridge-service/releases/tag/v0.4.2">v0.4.2</a></td>
40+
<td><a href="https://github.com/0xPolygonHermez/zkevm-prover/releases/tag/v4.0.19">v4.0.19</a></td>
41+
<td> <a href="https://github.com/0xPolygonHermez/zkevm-rom/tree/v4.0.0-fork.7">v4.0.0</a></td>
42+
<td><a href="https://github.com/0xPolygonHermez/zkevm-bridge-service/releases/tag/v0.4.2">v0.4.2</a></td>
4343
</tr>
4444
</tbody>
4545
</table>

docs/zkEVM/architecture/user-fees.md

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The aim with this document is to describe the Effective Gas Price (EGP), a mecha
55

66
Let's make a quick recollection of the basic fee schema used in Ethereum.
77

8-
Firstly, gas is a unit that accounts for resources used when processing a transaction. At the time of sending a transaction, the user can decide two parameters; $\texttt{gasLimit}$ and $\texttt{gasPrice}$:
8+
Firstly, gas is a unit that accounts for resources used when processing a transaction. At the time of sending a transaction, the user can decide on two parameters; $\texttt{gasLimit}$ and $\texttt{gasPrice}$:
99

1010
- $\texttt{gasLimit}$ is the maximum amount of gas units that a user is willing to buy in order to complete a transaction.
1111

@@ -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,15 +854,15 @@ 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

860-
4. We have to paths:
863+
4. We have two paths:
861864

862-
- If the percentage deviation between $\texttt{EEGP}$ and $\texttt{NEGP}$ is higher than a fixed deviation parameter $\texttt{FinalDeviationPct}$, which is $10$ in the actual configuration, that is
865+
- If the percentage deviation between $\texttt{EEGP}$ and $\texttt{NEGP}$ is higher than a fixed deviation parameter $\texttt{FinalDeviationParameter}$, which is $10$ in the actual configuration, that is
863866

864867
$$
865868
\frac{|\texttt{NEGP} − \texttt{EEGP}|}{\texttt{EEGP}} \cdot 100 < \texttt{FinalDeviationParameter}
@@ -877,21 +880,21 @@ Let’s examine the above figure in more detail.
877880
\frac{|\texttt{NEGP} − \texttt{EEGP}|}{\texttt{EEGP}} \cdot 100 ≥ \texttt{FinalDeviationParameter}
878881
$$
879882

880-
there is a big difference between executions and we may better adjust gas price due to potential (and quite big) losses to the network or the user.
883+
there is a big difference between executions and we may want to adjust gas price due to potential losses to the network or the user.
881884

882885
5. In the latter case, two options arise:
883886

884-
- If the gas price signed is less or equal than the accurate effective gas price computed with the correct state root
887+
- If the gas price signed is less than or equal to the accurately computed effective gas price, with the correct state root, and
885888

886889
$$
887890
\texttt{SignedGasPrice} \leq \texttt{NEGP}
888891
$$
889892

890-
the network suffers again a risk of loss.
893+
the network runs the risk of incurring a loss.
891894

892-
Henceforth, the user is charged the full $\texttt{SignedGasPrice}$, so the Executor will execute the transaction using it, concluding the sequencing process.
895+
Hence the user is charged the full $\texttt{SignedGasPrice}$, and the executor therefore executes the transaction using the $\texttt{SignedGasPrice}$. And the sequencing process is concluded.
893896

894-
- Otherwise, if $\texttt{SignedGasPrice} > \texttt{NEGP}$, then it means we have margin to adjust the gas price that is charged to the user.
897+
- Otherwise, if $\texttt{SignedGasPrice} > \texttt{NEGP}$, then there's sufficient margin to adjust the gas price and thus charge the user less than their $\texttt{SignedGasPrice}$.
895898

896899
However, in order to save executions, we end the adjustment process in this iteration, so that we conclude the flow using a trick explained in the next point.
897900

@@ -908,7 +911,7 @@ Let’s examine the above figure in more detail.
908911

909912
This precaution is employed to mitigate potential vulnerabilities in deployed Smart Contracts, that arise from creating a specific condition based on the gas price, for example, to manipulate execution costs.
910913

911-
- If the transaction does not make use of the gas price-related opcodes, the Executor executes the transaction with the more adjusted gas price up to this point which is $\texttt{NEGP}$ and end up the sequencing process.
914+
- If the transaction does not make use of the gas-price-related opcodes, the executor executes the transaction with the more adjusted gas price, which is $\texttt{NEGP}$, and ends the sequencing process.
912915

913916

914917
### Numerical Example: Sequencer Flow

docs/zkEVM/get-started/deploy-zkevm/install-dependencies.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ urls=(
6161
"https://storage.googleapis.com/zkevm/zkproverc/v2.0.0-RC4-fork.5.tgz"
6262
"https://storage.googleapis.com/zkevm/zkproverc/v3.0.0-RC2-fork.6.tgz"
6363
"https://storage.googleapis.com/zkevm/zkproverc/v3.0.0-RC3-fork.6.tgz"
64+
"https://storage.googleapis.com/zkevm/zkproverc/v4.0.0-rc.6-fork.7.tgz"
65+
"https://storage.googleapis.com/zkevm/zkproverc/v5.0.0-rc.4-fork.8.tgz"
6466
)
6567

6668
for url in "${urls[@]}"; do

0 commit comments

Comments
 (0)