forked from scroll-tech/zkevm-circuits
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc for eip EIP2930&1559 (scroll-tech#1115)
* doc for eip EIP2930_1559 * add 1559 gadget * modify md format
- Loading branch information
1 parent
7d41598
commit 44fd11f
Showing
2 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
tags: scroll documentation | ||
--- | ||
|
||
# EIP 2930 & 1559 | ||
this doc describles how to support EIP2930 & 1559 in copy circuit and evm circuit. | ||
## links | ||
- EIP2930 https://eips.ethereum.org/EIPS/eip-2930 | ||
- EIP1559 https://eips.ethereum.org/EIPS/eip-1559 | ||
|
||
## copy circuit | ||
- EIP2030 generates copy event for variable length of access list items (two types: address, storage key), it is done by evm bussmaping side. so copy circuit need to handle such situation. | ||
- added two additinonal `CopyDataType`: | ||
- CopyDataType::AccessListAddresses: When copy event is access-list addresses (EIP-2930), source is tx-table and destination is rw-table. | ||
- CopyDataType::AccessListStorageKeys: When copy event is access-list storage keys (EIP-2930), source is tx-table and destination is rw-table. | ||
- constraints: | ||
- `constrain_tag` method include new `is_access_list_address`, `is_access_list_storage_key` constraint. | ||
- Tx access list address lookup(tx table with `TxContextFieldTag::AccessListAddress`) | ||
- Rw access list address lookup(rw table with `RwTableTag::TxAccessListAccount`) | ||
- Tx access list storage key lookup (tx table with `TxContextFieldTag::AccessListStorageKey`) | ||
- Rw access list storage key lookup (rw table with `RwTableTag::TxAccessListAccountStorage`) | ||
|
||
### EVM Circuit | ||
|
||
- **Bus Mapping** | ||
- New methods in `bus-mapping/src/evm/opcodes/begin_end_tx.rs` of `add_access_list_address_copy_event` and `add_access_list_storage_key_copy_event` to generate copy events which copy circuit handles. | ||
|
||
- **Circuit Gadgets** | ||
- **TxAccessListGadget**: Handles access-list for EIP-1559 and EIP-2930 | ||
- Fields: | ||
- `is_eip1559_tx`: Checks if it's a 1559 transaction type. | ||
- `is_eip2930_tx`: Checks if it's a 2930 transaction type. | ||
- `is_address_len_zero`: Checks if there are no access list addresses (AccessListAddressesLen == 0). | ||
- `address_len`: Length of access list addresses. | ||
- `storage_key_len`: Length of storage keys under one access list address item. | ||
- Constraints: | ||
- tx table lookups for [AccessListAddressesLen, AccessListStorageKeysLen] | ||
- Copy table lookups for tx-table's access list addresses (CopyDataType::AccessListAddresses) when `is_address_len_zero` is not true. | ||
- Copy table lookups for tx-table's access list storage keys (CopyDataType::AccessListStorageKeys) when `is_storage_key_len_zero` is not true. | ||
|
||
- **TxEip1559Gadget**: Gadget to check sender balance before transfer | ||
- Fields: | ||
- `is_eip1559_tx`: Checks if it's a 1559 transaction type. | ||
- `gas_fee_cap`: MaxFeePerGas in 1559. | ||
- `gas_tip_cap`: MaxPriorityFeePerGas in 1559. | ||
- `mul_gas_fee_cap_by_gas`: Calculates total gas amount. | ||
- `balance_check`: Calculates minimal caller's balance required = `mul_gas_fee_cap_by_gas` + `tx.value` + `tx_l1_fee`. | ||
- is_insufficient_balance: check balance is sufficient compared to | ||
minimal balance required. | ||
- gas_fee_cap_lt_gas_tip_cap: make sure gas_fee_cap not less than gas_tip_gap. | ||
- constraints: | ||
- tx table lookups for [MaxFeePerGas, MaxPriorityFeePerGas] | ||
- sender balance must be sufficient, means gas_fee_cap >= gas_tip_cap | ||
- `begin_tx` : take use of `TxAccessListGadget` and `TxEip1559Gadget` to implement corresponding constraints. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters