You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/zkEVM/architecture/effective-gas/implement-egp-strat.md
+17-17Lines changed: 17 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -74,16 +74,16 @@ $$
74
74
75
75
where $\texttt{DataCost}$ is the cost in gas for data stored in L1.
76
76
77
-
The cost of data in Ethereum varies according to whether it involves zero bytes or non-zero bytes. In particular, non-zero bytes cost $16$ gas units, while zero bytes cost $4$ gas unints.
77
+
The cost of data in Ethereum varies according to whether it involves zero bytes or non-zero bytes. In particular, non-zero bytes cost $16$ gas units, while zero bytes cost $4$ gas units.
78
78
79
-
Also, recall that the computation of the cost for _non-zero bytes_ must take into account the constant data which always appear in a transaction but not included in the RLP:
79
+
Also, recall that the computation of the cost for _non-zero bytes_ must take into account constants that appear in transactions but are not included in the RLP, which includes:
80
80
81
81
- The signature, which consists of $65$ bytes.
82
-
- The previously defined $\texttt{EffectivePercentageByte}$, which consists in a single byte.
82
+
- The previously defined $\texttt{EffectivePercentageByte}$, which consists of a single byte.
83
83
84
84
This results in a total of $66$ constantly present bytes.
85
85
86
-
Taking all in consideration, $\texttt{DataCost}$ can be computed as:
86
+
Taking everything into consideration, $\texttt{DataCost}$ can be computed as:
In the RPC component, we’re only pre-executing the transaction, meaning we’re using an incorrect state root. Consequently, the $\texttt{GasUsed}$ is only an approximation.
150
150
151
-
This implies that we need to multiply the result by a chosen factor before comparing it to the signed price.
151
+
This implies that we need to multiply the result by a chosen factor before comparing it to the signed price to hedge against unforeseen costs.
152
152
153
153
This ensures that the costs are covered in case more gas is ultimately required to execute the transaction. This factor is named $\texttt{BreakEvenFactor}$.
154
154
@@ -160,7 +160,7 @@ $$
160
160
161
161
then it is safe to accept the transaction.
162
162
163
-
Observe that we still need to introduce gas price prioritization, which will be covered later on.
163
+
Observe that we still need to introduce gas price prioritization, which we explain later.
164
164
165
165
### Example (Breakeven gas price)
166
166
@@ -170,11 +170,11 @@ The figure below depicts the current situation.
170
170
171
171

172
172
173
-
Suppose the user sends a transaction that has $200$ non-zero bytes, including the constant ones and $100$ zero bytes.
173
+
Suppose the user sends a transaction that has $200$ non-zero bytes, including the constants and $100$ zero bytes.
174
174
175
-
Moreover, at the time of pre-executing the transaction, which is done without getting an out-of-counters (OOC) error, $60,000$ gas units are consumed.
175
+
Moreover, on pre-executing the transactionwithout an out-of-counters (OOC) error, $60,000$ gas units are consumed.
176
176
177
-
Recall that, since we are using a "wrong" state root, this gas is only an estimation.
177
+
Recall that, since we are using a "wrong" state root, this amount is only an estimation.
178
178
179
179
Hence, using the previously explained formulas, the total transaction cost is:
180
180
@@ -195,7 +195,7 @@ $$
195
195
196
196
We have introduced a $\texttt{NetProfit}$ value of $1.2$, indicating a target of a $20\%$ gain in this process.
197
197
198
-
At a first glance, we might conclude acceptance since:
198
+
At first glance, we might conclude the transaction has been accepted:
Consequently, we decide to accept the transaction.
212
+
Consequently, the system accepts the transaction.
213
213
214
214
### Example (Breakeven factor)
215
215
@@ -223,11 +223,11 @@ $$
223
223
224
224
However, let's assume the correct execution at the time of sequencing consumes $35,000$ gas.
225
225
226
-
If we recompute $\texttt{BreakEvenGasPrice}$ using this updated used gas, we get $3.6\ \texttt{GWei/Gas}$, which is way higher than the original one.
226
+
If we recompute $\texttt{BreakEvenGasPrice}$ using this updated used gas, we get $3.6\ \texttt{GWei/Gas}$, which is way higher than the original estimation.
227
227
228
228
That means we should have charged the user a higher gas price in order to cover the whole transaction cost, standing at $105,000\ \texttt{GWei}$.
229
229
230
-
But, since we are accepting all the transactions that sign more than $2.85$ of gas price, we do not have any margin to increase more.
230
+
But, since we are accepting all the transactions that sign more than $2.85$ of gas price, we do not have any margin to increase it.
231
231
232
232
In the worst case we are losing:
233
233
@@ -249,4 +249,4 @@ $$
249
249
105, 000 − 35, 000 · 3.27 < 0
250
250
$$
251
251
252
-
**Final Note**: In the above example, even though we assumed that a decrease in the $\texttt{BreakEvenGasPrice}$ is a result of executing with a correct state root, it can also decrease significantly due to a substantial reduction in $\texttt{L1GasPrice}$.
252
+
**Final Note**: In the above example, even though we assume that a decrease in the $\texttt{BreakEvenGasPrice}$ is a result of executing with a correct state root, it can also decrease significantly due to a substantial reduction in $\texttt{L1GasPrice}$.
Copy file name to clipboardExpand all lines: docs/zkEVM/architecture/effective-gas/index.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ Now that the EGP is in place, you can reduce any chance for a transaction revert
6
6
7
7
## How gas fees work in Ethereum
8
8
9
-
There are two adjustable parameters, in Ethereum, that have a direct impact on transaction gas fees:
9
+
In Ethereum, there are two adjustable parameters that have a direct impact on transaction gas fees:
10
10
11
11
- The $\texttt{gasLimit}$, which is the maximum amount of gas units the user is willing to buy in order for their transactions to be included in a block and processed on chain.
12
12
- The $\texttt{gasPrice}$, that is, the amount of ETH a user is willing to pay for 1 gas unit. For instance, a gas price of 10 Gwei means the user is willing to pay 0.00000001 ETH for each unit of gas.
Copy file name to clipboardExpand all lines: docs/zkEVM/architecture/effective-gas/user-tx-flow/rpc-flow-egp.md
+6-7Lines changed: 6 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,16 +59,15 @@ The RPC flow is summarized in the figure below.
59
59
60
60
## Example (RPC tx flow)
61
61
62
-
Consider a scenario where a user sends a query for a suggested gas price during a certain 5-minute interval, as shown in the figure below.
62
+
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.
63
63
64
-
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.
64
+
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.
65
65
66
66

67
67
68
-
69
68
1. 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 $\texttt{L1GasPrice}$ is $19$.
70
69
71
-
The RPC node therefore responds with a $2.85 \texttt{ GWei/Gas}$, as the value of the suggested L2 gas price.
70
+
The RPC node responds with a $2.85 \texttt{ GWei/Gas}$, as the value of the suggested L2 gas price.
72
71
73
72
This value is obtained as follows:
74
73
@@ -78,7 +77,7 @@ Values of L1 gas prices polled every 5 seconds are displayed above the timeline,
78
77
79
78
where $0.15$ is the zkEVM's suggested factor.
80
79
81
-
2. Let's suppose the user sends a transaction signed with a gas price of $3$. That is, $\texttt{SignedGasPrice} = 3$
80
+
2. Let's suppose the user sends a transaction signed with a gas price of $3$. That is, $\texttt{SignedGasPrice} = 3$.
82
81
83
82
However, by the time the user sends the signed transaction, the L1 gas price is no longer $19$ but $21$. And its correponding suggested gas price is $\mathtt{3.15 = 21 \cdot 0.15}$.
84
83
@@ -116,13 +115,13 @@ Values of L1 gas prices polled every 5 seconds are displayed above the timeline,
It is assumed that the transaction has 200 non-zero bytes and 100 zero bytes.
104
+
We assume that the transaction has 200 non-zero bytes and 100 zero bytes.
105
105
106
106
Secondly, the new breakeven gas price:
107
107
@@ -122,7 +122,7 @@ $$
122
122
\end{aligned}
123
123
$$
124
124
125
-
Observe that the transaction cost is way higher than the RPC-estimated one of $126,000$ even when the L1 gas price has decreased from 21 to 20 due to a huge increase in gas.
125
+
Observe that the transaction cost is much higher than the RPC-estimation of $126,000$, even when the L1 gas price has decreased from 21 to 20 due to a huge increase in gas.
126
126
127
127
5. Observe that there is a significant deviation between both effective gas prices:
0 commit comments