tags |
---|
scroll documentation |
this doc describles how to support EIP2930 & 1559 in copy circuit and evm 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 newis_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
)
-
Bus Mapping
- New methods in
bus-mapping/src/evm/opcodes/begin_end_tx.rs
ofadd_access_list_address_copy_event
andadd_access_list_storage_key_copy_event
to generate copy events which copy circuit handles.
- New methods in
-
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.
- Fields:
-
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.base_fee
: base fee from block context.gas_fee_cap_lt_base_fee
: make sure gas_fee_cap not less than base fee.
- constraints:
- tx table lookups for [MaxFeePerGas, MaxPriorityFeePerGas]
- sender balance must be sufficient, as well as gas_fee_cap >= gas_tip_cap, gas_fee_cap >= base_fee.
- Fields:
-
begin_tx
: take use ofTxAccessListGadget
andTxEip1559Gadget
to implement corresponding constraints.
-