Skip to content

Commit

Permalink
Update EIP-7702: fixup gas costs and empty code hash
Browse files Browse the repository at this point in the history
Merged by EIP-Bot.
  • Loading branch information
lightclient authored Oct 9, 2024
1 parent 71e6866 commit 0b5d3a6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions EIPS/eip-7702.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ There is a lot of interest in adding short-term functionality improvements to EO
| ------------------------ | ------- |
| `SET_CODE_TX_TYPE` | `0x04` |
| `MAGIC` | `0x05` |
| `PER_AUTH_BASE_COST` | `15000` |
| `PER_AUTH_BASE_COST` | `12500` |
| `PER_EMPTY_ACCOUNT_COST` | `25000` |

### Set Code Transaction
Expand Down Expand Up @@ -74,7 +74,7 @@ At the start of executing the transaction, after incrementing the sender's nonce
6. Verify the nonce of `authority` is equal to `nonce`. In case `authority` does not exist in the trie, verify that `nonce` is equal to `0`.
7. Add `PER_EMPTY_ACCOUNT_COST - PER_AUTH_BASE_COST` gas to the global refund counter if `authority` exists in the trie.
8. Set the code of `authority` to be `0xef0100 || address`. This is a delegation designation.
* As a special case, if `address` is `0x0000000000000000000000000000000000000000` do not write the designation. Clear the accounts code and reset the account's code hash to `0x0000000000000000000000000000000000000000000000000000000000000000`.
* As a special case, if `address` is `0x0000000000000000000000000000000000000000` do not write the designation. Clear the accounts code and reset the account's code hash to the empty hash `0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470`.
9. Increase the nonce of `authority` by one.

If any of the above steps fail, immediately stop processing that tuple and continue to the next tuple in the list. It will in the case of multiple tuples for the same authority, set the code using the address in the last valid occurrence.
Expand Down Expand Up @@ -115,13 +115,13 @@ Additionally, if a transaction's `destination` has a delegation designation, add

The `PER_AUTH_BASE_COST` is the cost to process the authorization tuple and set the delegation destination. We are able to compute a fair cost for this operation by reviewing its impact on the system:

* ferry 101 bytes of calldata = `101 * 16 = 1616`
* ferry 101 bytes of calldata = `101 * non-zero cost (16) = 1616`
* recovering the `authority` address = `3000`
* reading the nonce and code of `authority` = `5000`
* reading the nonce and code of `authority` = `2600`
* storing values in already warm account = `200`
* cost to deploy code = `200 * 23 = 4600`

The impact-based assessment leaves us with `14416` gas for the operation. We round up to `15000` to account for miscellaneous costs associated with shuttling data around the state transition.
The impact-based assessment leaves us with `12016` gas for the operation. We round up to `12500` to account for miscellaneous costs associated with shuttling data around the state transition.

### No initcode

Expand Down

0 comments on commit 0b5d3a6

Please sign in to comment.