Skip to content

Commit f93b530

Browse files
authored
Update EIP-7702: add delegation designation
Merged by EIP-Bot.
1 parent 9b7d6a5 commit f93b530

File tree

1 file changed

+29
-20
lines changed

1 file changed

+29
-20
lines changed

EIPS/eip-7702.md

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
---
22
eip: 7702
3-
title: Set EOA account code for one transaction
4-
description: Add a new tx type that sets the code for an EOA during one transaction execution
3+
title: Set EOA account code
4+
description: Add a new tx type that sets the code for an EOA during execution
55
author: Vitalik Buterin (@vbuterin), Sam Wilson (@SamWilsn), Ansgar Dietrichs (@adietrichs), Matt Garnett (@lightclient)
66
discussions-to: https://ethereum-magicians.org/t/eip-set-eoa-account-code-for-one-transaction/19923
77
status: Review
88
type: Standards Track
99
category: Core
1010
created: 2024-05-07
11-
requires: 2718, 2929, 2930
11+
requires: 2718, 2929, 2930, 3541, 3607
1212
---
1313

1414
## Abstract
1515

16-
Add a new transaction type that adds a list of `[address, y_parity, r, s]` authorization tuples, and converts the signing accounts (not necessarily the same as the `tx.origin`) into smart contract wallets for the duration of that transaction.
16+
Add a new transaction type that adds a list of `[chain_id, address, nonce, y_parity, r, s]` authorization tuples. For each tuple, write a delegation designator `(0xef0000 ++ address)` to the signing account's code. All code reading operations must load the code pointed to by the designator.
1717

1818
## Motivation
1919

@@ -40,38 +40,49 @@ We introduce a new [EIP-2718](./eip-2718.md) transaction, "set code transaction"
4040
```
4141
rlp([chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas_limit, destination, value, data, access_list, authorization_list, signature_y_parity, signature_r, signature_s])
4242
43-
authorization_list = [[chain_id, address, [nonce], y_parity, r, s], ...]
43+
authorization_list = [[chain_id, address, nonce, y_parity, r, s], ...]
4444
```
4545

4646
The fields `chain_id`, `nonce`, `max_priority_fee_per_gas`, `max_fee_per_gas`, `gas_limit`, `destination`, `value`, `data`, and `access_list` of the outer transaction follow the same semantics as [EIP-1559](./eip-1559.md).
4747

48-
The `authorization_list` is a list of tuples that store the address to code which the signer desires to set in their EOA temporarily. The third element is a list item mimicking an optional value. When the list length is zero, consider the authorization nonce to be null. When the list length is one, consider the single integer value to be the provided nonce authorization. Other lengths and value types in this optional are invalid and the transaction as a whole should be considered malformed.
48+
The `authorization_list` is a list of tuples that store the address to code which the signer desires to execute in the context of their EOA.
4949

5050
The [EIP-2718](./eip-2718.md) `ReceiptPayload` for this transaction is `rlp([status, cumulative_transaction_gas_used, logs_bloom, logs])`.
5151

5252
#### Behavior
5353

54-
At the start of executing the transaction, for each `[chain_id, address, [nonce], y_parity, r, s]` tuple:
54+
At the start of executing the transaction, for each `[chain_id, address, nonce, y_parity, r, s]` tuple:
5555

56-
1. `authority = ecrecover(keccak(MAGIC || rlp([chain_id, address, [nonce]])), y_parity, r, s]`
56+
1. `authority = ecrecover(keccak(MAGIC || rlp([chain_id, address, nonce])), y_parity, r, s]`
5757
2. Verify the chain id is either 0 or the chain's current ID.
58-
3. Verify that the code of `authority` is empty.
59-
4. If nonce list item is length one, verify the nonce of `authority` is equal to `nonce`.
60-
5. Set the code of `authority` to code associated with `address`.
61-
6. Add the `authority` account to `accessed_addresses` (as defined in [EIP-2929](./eip-2929.md).)
58+
3. Verify that the code of `authority` is either empty or already delegated.
59+
4. Verify the nonce of `authority` is equal to `nonce`.
60+
5. Set the code of `authority` to be `0xef0100 || address`. This is a delegation designation.
61+
6. Increase the nonce of `authority` by one.
62+
7. Add the `authority` account to `accessed_addresses` (as defined in [EIP-2929](./eip-2929.md).)
6263

63-
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 specified by the address in the first occurrence.
64-
65-
At the end of the transaction, set the code of each `authority` back to empty.
64+
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 specified by the address in the last occurrence.
6665

6766
Note that the signer of an authorization tuple may be different than `tx.origin` of the transaction.
6867

68+
##### Delegation Designation
69+
70+
The delegation designation uses the banned opcode `0xef` from [EIP-3541](./eip-3541) to designate the code has a special purpose. This designator requires all code retrieving operations follow the address pointer to fill the accounts observable code. The following instructions are impacted: `EXTCODESIZE`, `EXTCODECOPY`, `EXTCODEHASH`, `CALL`, `CALLCODE`, `STATICCALL`, `DELEGATECALL`.
71+
72+
For example, `EXTCODESIZE` would return the size of the code pointed to by `address` instead of `24` which would represent the delegation designation. `CALL` would similarly load the code from `address` and execute it in the context of `authority`.
73+
74+
In case a delegation designator points to another designator, creating a potential chain or loop of designators, clients must retrieve only the first code and then stop following the designator chain.
75+
6976
#### Gas Costs
7077

71-
The intrinsic cost of the new transaction is inherited from [EIP-2930](./eip-2930.md), specifically `21000 + 16 * non-zero calldata bytes + 4 * zero calldata bytes + 1900 * access list storage key count + 2400 * access list address count`. Additionally, we add a cost of `PER_CONTRACT_CODE_BASE_COST * authorization list length`.
78+
The intrinsic cost of the new transaction is inherited from [EIP-2930](./eip-2930.md), specifically `21000 + 16 * non-zero calldata bytes + 4 * zero calldata bytes + 1900 * access list storage key count + 2400 * access list address count`. Additionally, we add a cost of `PER_AUTH_BASE_COST * authorization list length`.
7279

7380
The transaction sender will pay for all authorization tuples, regardless of validity or duplication.
7481

82+
#### Transaction Origination
83+
84+
Modify the restriction put in place by [EIP-3607](./eip-3607.md) to allow EOAs whose code is a valid delegation designation, i.e. `0xef0100 || address`, to continue to originate transactions. Accounts with any other code values may not originate transactions.
85+
7586
## Rationale
7687

7788
### No initcode
@@ -108,9 +119,7 @@ An alternative to adding chain ID could be to sign over the code the address poi
108119

109120
#### In-protocol revocation
110121

111-
A hotly debated element of this EIP is the need for in-protocol revocation. Although it is possible to implement revocation logic within delegated code, for some this isn't sufficient and it is the duty of the protocol to provide a revocation option of last resort.
112-
113-
For this reason, the proposal provides two separate schemes. The first is an eternal delegation to a smart contract. At the protocol level, it is not possible to revoke. However, the contract you delegate to is one which can expect to use in your account for perpetuity; similar to how smart contract wallet users deploy proxy contracts to their account and point the target at a wallet implementation. The second is a scoped delegation with a revocation mechanism based on the EOA's nonce. This is a safer to begin using smart contract code in the context of your EOA without potentially committing to a specific piece of code forever.
122+
Unlike previous versions of this EIP and EIPs similar, the delegation designation can be revoked at anytime signing and sending a EIP-7702 authorization to a new target with the account's current nonce. Without such action, a delegation will remain valid in perpetuity.
114123

115124
### Self-sponsoring: allowing `tx.origin` to set code
116125

@@ -146,7 +155,7 @@ Specifically:
146155
* The "code pathways" that are used are code pathways that would, in many cases (though perhaps not all), continue to "make sense" in a pure-smart-contract-wallet world.
147156
* Hence, it avoids the problem of "creating two separate code ecosystems", because to a large extent they would be the same ecosystem. There would be some workflows that require kludges under this solution that would be better done in some different "more native" under "endgame AA", but this is relatively a small subset.
148157
* It does not require adding any opcodes, that would become dangling and useless in a post-EOA world.
149-
* It allows EOAs to temporarily convert themselves into contracts to be included in ERC-4337 bundles, in a way that's compatible with the existing `EntryPoint`.
158+
* It allows EOAs to masquerade as contracts to be included in ERC-4337 bundles, in a way that's compatible with the existing `EntryPoint`.
150159
* Once this is implemented, allowing EOAs to migrate permanently is "only one line of code": just add a flag to not set the code back to empty at the end.
151160

152161
## Backwards Compatibility

0 commit comments

Comments
 (0)