Skip to content

Commit

Permalink
Update EIP-4762: Cleanup/refactor the text as per clarifications
Browse files Browse the repository at this point in the history
Merged by EIP-Bot.
  • Loading branch information
g11tech authored Jun 29, 2024
1 parent 9590d79 commit c7de6af
Showing 1 changed file with 12 additions and 31 deletions.
43 changes: 12 additions & 31 deletions EIPS/eip-4762.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_storage_slot_tree_keys(storage_key: int) -> [int, int]:

### Access events

We define access events as follows. When an access event takes place, the accessed data is saved to the Verkle tree (even if it was not modified). An access event is of the form`(address, sub_key, leaf_key)`, determining what data is being accessed.
Whenever the state is read, one or more of the access events of the form`(address, sub_key, leaf_key)` take place, determining what data is being accessed. We define access events as follows:

#### Access events for account headers

Expand All @@ -46,21 +46,21 @@ When:
3. any address is the target of the `BALANCE` opcode
4. a _deployed_ contract calls `CODECOPY`

process this access events:
process this access event:

```
(address, 0, BASIC_DATA_LEAF_KEY)
```

Note: a non-value-bearing `SELFDESTRUCT` or `*CALL`, targetting a precompile, will not cause the `BASIC_DATA_LEAF_KEY` to be added to the witness.

If a `*CALL` or `SELFDESTRUCT` is value-bearing (ie. it transfers nonzero wei), whether or not the callee is a precompile, process this additional access event:
If a `*CALL` or `SELFDESTRUCT` is value-bearing (ie. it transfers nonzero wei), whether or not the `callee` is a precompile, process this additional access event:

```
(origin, 0, BASIC_DATA_LEAF_KEY)
(caller, 0, BASIC_DATA_LEAF_KEY)
```

Note: when checking for the existence of the callee, the existence check is done by validating that there is an extension-and-suffix tree at the corresponding stem, and does not rely on `CODEHASH_LEAF_KEY`.
Note: when checking for the existence of the `callee`, the existence check is done by validating that there is an extension-and-suffix tree at the corresponding stem, and does not rely on `CODEHASH_LEAF_KEY`.

When calling `EXTCODEHASH` on a non-precompile target, process the access event:

Expand Down Expand Up @@ -111,21 +111,21 @@ In the conditions below, “chunk chunk_id is accessed” is understood to mean

### Write Events

We define **write events** as follows. Note that when a write takes place, an access event also takes place (so the definition below should be a subset of the definition of access lists) A write event is of the form `(address, sub_key, leaf_key)`, determining what data is being written to.
We define **write events** as follows. Note that when a write takes place, an access event also takes place (so the definition below should be a subset of the definition of access events). A write event is of the form `(address, sub_key, leaf_key)`, determining what data is being written to.

#### Write events for account headers

When a nonzero-balance-sending `*CALL` or `SELFDESTRUCT` with a given sender and recipient takes place, process these write events:

```
(origin, 0, BASIC_DATA_LEAF_KEY)
(target, 0, BASIC_DATA_LEAF_KEY)
(caller, 0, BASIC_DATA_LEAF_KEY)
(callee, 0, BASIC_DATA_LEAF_KEY)
```

if no account exists at `callee_address`, also process:

```
(target, 0, CODEHASH_LEAF_KEY)
(callee, 0, CODEHASH_LEAF_KEY)
```

When a contract creation is initialized, process these write events:
Expand Down Expand Up @@ -166,7 +166,7 @@ For `i` in `0 ... (len(code)+30)//31`.

Note: since no access list existed for code up until this EIP, note that no warm costs are charged for code accesses.

### Transactions
### Transaction

#### Access events

Expand Down Expand Up @@ -221,15 +221,13 @@ When executing a transaction, maintain four sets:

When an **access** event of `(address, sub_key, leaf_key)` occurs, perform the following checks:

* Perform the following steps unless `address` is either:
* the transaction's originator;
* the transactions's target;
* Perform the following steps unless event is a _Transaction access event_;
* If `(address, sub_key)` is not in `accessed_subtrees`, charge `WITNESS_BRANCH_COST` gas and add that tuple to `accessed_subtrees`.
* If `leaf_key` is not `None` and `(address, sub_key, leaf_key)` is not in `accessed_leaves`, charge `WITNESS_CHUNK_COST` gas and add it to `accessed_leaves`

When a **write** event of `(address, sub_key, leaf_key)` occurs, perform the following checks:

* If `address` is either the transaction's originator or target, skip the following steps.
* If event is _Transaction write event_, skip the following steps.
* If `(address, sub_key)` is not in `edited_subtrees`, charge `SUBTREE_EDIT_COST` gas and add that tuple to `edited_subtrees`.
* If `leaf_key` is not `None` and `(address, sub_key, leaf_key)` is not in `edited_leaves`, charge `CHUNK_EDIT_COST` gas and add it to `edited_leaves`
* Additionally, if there was no value stored at `(address, sub_key, leaf_key)` (ie. the state held `None` at that position), charge `CHUNK_FILL_COST`
Expand All @@ -243,23 +241,6 @@ Note that values should only be added to the witness if there is sufficient gas
* this minimum 1/64th gas reservation is checked **AFTER** charging the witness costs when performing a `CALL`, `CODECALL`, `DELEGATECALL` or`STATICCALL`
* this 1/64th of the gas is subtracted **BEFORE** charging the witness costs when performing a `CREATE` or `CREATE2`

### Replacement for access lists

We replace [EIP-2930](./eip-2930.md) access lists with an SSZ structure of the form:

```python
class AccessList(Container):
addresses: List[AccountAccessList, ACCESS_LIST_MAX_ELEMENTS]

class AccountAccessList(Container):
address: Address32
subtrees: List[AccessSubtree, ACCESS_LIST_MAX_ELEMENTS]

class AccessSubtree(Container):
subtree_key: uint256
elements: BitVector[256]
```

### Block-level operations

None of:
Expand Down

0 comments on commit c7de6af

Please sign in to comment.