Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs]:effective-gas-price #316

Open
krlosMata opened this issue Dec 20, 2023 · 0 comments
Open

[docs]:effective-gas-price #316

krlosMata opened this issue Dec 20, 2023 · 0 comments
Labels
documentation Improvements or additions to documentation

Comments

@krlosMata
Copy link
Contributor

krlosMata commented Dec 20, 2023

Effective Gas Price (EGP)

Motivation

  • Add a mechanism to compute and charge L1 data-availability costs in L2 transactions
  • The user signs a gasPrice (provided by the RPC) which must cover the L1 data-availability and L2 execution costs
  • Mechanism will charge the user fair gasPrice to cover above costs
  • Therefore, a reduction in the user signed gasPrice will be applied

Specification

  • Single byte [0 - 255] to indicate reduction in the gasPrice by a percentage

Formula

effectiveGasPrice = Floor((signedGasPrice * (effectivePercentage + 1)) / 256)

where:

  • effectiveGasPRice: the gas price applied when executing the transaction
  • signedGasPrice: gas price signed by the user
  • effectivePercentage: percenttage index to apply that specifies the reduction

Table

note that no reduction is achieved with 0xff byte. Therefore, effectiveGasPRice = signedGasPrice

index Reduction applied (%)
0 99.61
1 99.22
2 98.83
3 98.44
4 98.05
5 97.66
6 97.27
7 96.88
8 96.48
9 96.09
10 95.70
11 95.31
12 94.92
13 94.53
14 94.14
15 93.75
16 93.36
17 92.97
18 92.58
19 92.19
20 91.80
21 91.41
22 91.02
23 90.63
24 90.23
25 89.84
26 89.45
27 89.06
28 88.67
29 88.28
30 87.89
31 87.50
32 87.11
33 86.72
34 86.33
35 85.94
36 85.55
37 85.16
38 84.77
39 84.38
40 83.98
41 83.59
42 83.20
43 82.81
44 82.42
45 82.03
46 81.64
47 81.25
48 80.86
49 80.47
50 80.08
51 79.69
52 79.30
53 78.91
54 78.52
55 78.13
56 77.73
57 77.34
58 76.95
59 76.56
60 76.17
61 75.78
62 75.39
63 75.00
64 74.61
65 74.22
66 73.83
67 73.44
68 73.05
69 72.66
70 72.27
71 71.88
72 71.48
73 71.09
74 70.70
75 70.31
76 69.92
77 69.53
78 69.14
79 68.75
80 68.36
81 67.97
82 67.58
83 67.19
84 66.80
85 66.41
86 66.02
87 65.63
88 65.23
89 64.84
90 64.45
91 64.06
92 63.67
93 63.28
94 62.89
95 62.50
96 62.11
97 61.72
98 61.33
99 60.94
100 60.55
101 60.16
102 59.77
103 59.38
104 58.98
105 58.59
106 58.20
107 57.81
108 57.42
109 57.03
110 56.64
111 56.25
112 55.86
113 55.47
114 55.08
115 54.69
116 54.30
117 53.91
118 53.52
119 53.13
120 52.73
121 52.34
122 51.95
123 51.56
124 51.17
125 50.78
126 50.39
127 50.00
128 49.61
129 49.22
130 48.83
131 48.44
132 48.05
133 47.66
134 47.27
135 46.88
136 46.48
137 46.09
138 45.70
139 45.31
140 44.92
141 44.53
142 44.14
143 43.75
144 43.36
145 42.97
146 42.58
147 42.19
148 41.80
149 41.41
150 41.02
151 40.63
152 40.23
153 39.84
154 39.45
155 39.06
156 38.67
157 38.28
158 37.89
159 37.50
160 37.11
161 36.72
162 36.33
163 35.94
164 35.55
165 35.16
166 34.77
167 34.38
168 33.98
169 33.59
170 33.20
171 32.81
172 32.42
173 32.03
174 31.64
175 31.25
176 30.86
177 30.47
178 30.08
179 29.69
180 29.30
181 28.91
182 28.52
183 28.13
184 27.73
185 27.34
186 26.95
187 26.56
188 26.17
189 25.78
190 25.39
191 25.00
192 24.61
193 24.22
194 23.83
195 23.44
196 23.05
197 22.66
198 22.27
199 21.88
200 21.48
201 21.09
202 20.70
203 20.31
204 19.92
205 19.53
206 19.14
207 18.75
208 18.36
209 17.97
210 17.58
211 17.19
212 16.80
213 16.41
214 16.02
215 15.63
216 15.23
217 14.84
218 14.45
219 14.06
220 13.67
221 13.28
222 12.89
223 12.50
224 12.11
225 11.72
226 11.33
227 10.94
228 10.55
229 10.16
230 9.77
231 9.38
232 8.98
233 8.59
234 8.20
235 7.81
236 7.42
237 7.03
238 6.64
239 6.25
240 5.86
241 5.47
242 5.08
243 4.69
244 4.30
245 3.91
246 3.52
247 3.13
248 2.73
249 2.34
250 1.95
251 1.56
252 1.17
253 0.78
254 0.39
255 0.00

Examples

  • transaction bytes: rlp(nonce, gasprice, gaslimit, to, value, data, chainId, 0, 0) # r # s # v # effectivePercentage
  • assumptions:
    • simplified calldata cost: 16 GAS each byte
    • L1GasPrice = 100 Gwei

Ethereum transfer

  • summary table
Bytes L1 DATA Cost ETH L1 Data gas used fair gasPrice priceSigned Redution to apply effectiveGasPrice
113 0.0001808 21000 8.6 GWei 15 Gwei 42.97 % 8.55 GWei
  • operations
    • transaction bytes: 113 bytes
    • transaction gas used: 21000 GAS
    • simplified breakeven gas price
      • data-availability costs: 16 GAS/byte * 113 bytes * L1GasPrice = 1808 GAS * 100 Gwei = 0.0001808 ether
      • fairGasPrice = 0.0001808 ether / 21000 = 8.6 Gwei
    • assumption: the user has signed a signedGasPrice = 15 GWei
    • Sequencer compute effectiveGasPercentage to reduce gasPrice applied from 15 Gwei to 8.6 Gwei
      • percentage = (8.6 GWei / 15 gWei) * 100 = 56.66 %
        • reduction applied = 100 - 56.66 = 43.34 %
      • sequencer select the closest percentage from the table --> select an effectivePercentage = 145 which correspond to a 42.97 % reduction
      • compute final gas price to apply to the transaction: effectiveGasPrice = Floor((15 gWei * (145 + 1)) / 256) = 8.55 GWei
@krlosMata krlosMata added the documentation Improvements or additions to documentation label Dec 20, 2023
@krlosMata krlosMata assigned krlosMata and unassigned krlosMata Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant