Commit cea9f0c
feat(l2): allow paying fees with custom token (#5024)
**Motivation**
This pull request introduces support for a new transaction type,
`CustomFeeTransaction`, we want to be able to pay fees with an ERC20
token instead of ETH.
**Description**
* Added `FeeTokenTransaction` as a new variant to the `Transaction`
enum, and updated the `TxType` enum and its associated methods to
recognize the new type.
* Modified `l2_hook` to deduct and refund fees according to the ERC20
tokens desired as the user
* Added new flag for deployer `initial_fee_token` that will register one
address in advance.
**How to test**
You can see the `test_fee_token` in `tests.rs` to see how to build a tx.
Some useful commands may be:
Register a new fee token:
```bash
rex send <BRIDGE_L1> "registerNewFeeToken(address)" <FEE_TOKEN> --rpc-url http://localhost:8545 --private-key 0x941e103320615d394a55708be13e45994c7d93b932b064dbcb2b511fe3254e2e
```
Check if fee token is allowed
```bash
rex call 0x000000000000000000000000000000000000fffc "isFeeToken(address)" <FEE_TOKEN> --rpc-url http://localhost:1729
```
---------
Co-authored-by: Avila Gastón <[email protected]>
Co-authored-by: Manuel Iñaki Bilbao <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Ivan Litteri <[email protected]>1 parent e7f1385 commit cea9f0c
File tree
45 files changed
+2643
-1091
lines changed- cmd/ethrex
- l2
- crates
- blockchain
- metrics
- common/types
- l2
- contracts/src
- example
- l1
- interfaces
- l2
- interfaces
- networking/rpc
- prover/src/guest_program/src/risc0
- sdk/src
- tests
- networking/rpc
- clients/eth
- eth
- types
- vm
- backends/levm
- levm/src
- db
- hooks
- docs
- l2
- architecture
- fundamentals
- fixtures
- blobs
- contracts/ERC20
- genesis
- keys
- tooling/ef_tests
- state_v2/src/modules
- state/runner
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
45 files changed
+2643
-1091
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
128 | 132 | | |
129 | 133 | | |
130 | 134 | | |
| |||
273 | 277 | | |
274 | 278 | | |
275 | 279 | | |
276 | | - | |
| 280 | + | |
| 281 | + | |
277 | 282 | | |
278 | 283 | | |
279 | 284 | | |
| |||
330 | 335 | | |
331 | 336 | | |
332 | 337 | | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
333 | 344 | | |
334 | 345 | | |
335 | 346 | | |
| |||
433 | 444 | | |
434 | 445 | | |
435 | 446 | | |
436 | | - | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
437 | 455 | | |
438 | 456 | | |
439 | 457 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
275 | 276 | | |
276 | 277 | | |
277 | 278 | | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
278 | 289 | | |
279 | 290 | | |
280 | 291 | | |
| |||
336 | 347 | | |
337 | 348 | | |
338 | 349 | | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
339 | 358 | | |
340 | 359 | | |
341 | 360 | | |
| |||
396 | 415 | | |
397 | 416 | | |
398 | 417 | | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
399 | 429 | | |
400 | 430 | | |
401 | 431 | | |
402 | 432 | | |
403 | 433 | | |
404 | 434 | | |
405 | 435 | | |
| 436 | + | |
406 | 437 | | |
407 | 438 | | |
408 | 439 | | |
| |||
977 | 1008 | | |
978 | 1009 | | |
979 | 1010 | | |
980 | | - | |
| 1011 | + | |
981 | 1012 | | |
982 | 1013 | | |
983 | 1014 | | |
| |||
994 | 1025 | | |
995 | 1026 | | |
996 | 1027 | | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
997 | 1078 | | |
998 | 1079 | | |
999 | 1080 | | |
| |||
1031 | 1112 | | |
1032 | 1113 | | |
1033 | 1114 | | |
| 1115 | + | |
| 1116 | + | |
1034 | 1117 | | |
1035 | 1118 | | |
1036 | 1119 | | |
| |||
1070 | 1153 | | |
1071 | 1154 | | |
1072 | 1155 | | |
| 1156 | + | |
1073 | 1157 | | |
1074 | 1158 | | |
1075 | 1159 | | |
| |||
1084 | 1168 | | |
1085 | 1169 | | |
1086 | 1170 | | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
1087 | 1174 | | |
1088 | 1175 | | |
1089 | 1176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1382 | 1382 | | |
1383 | 1383 | | |
1384 | 1384 | | |
| 1385 | + | |
1385 | 1386 | | |
1386 | 1387 | | |
1387 | 1388 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| 165 | + | |
165 | 166 | | |
166 | 167 | | |
167 | 168 | | |
| |||
172 | 173 | | |
173 | 174 | | |
174 | 175 | | |
| 176 | + | |
175 | 177 | | |
176 | 178 | | |
177 | 179 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| 178 | + | |
178 | 179 | | |
179 | 180 | | |
180 | 181 | | |
| |||
237 | 238 | | |
238 | 239 | | |
239 | 240 | | |
| 241 | + | |
240 | 242 | | |
241 | 243 | | |
242 | 244 | | |
| |||
0 commit comments