Pre-ERC: Adoption Profile and Reference Kernel for EOAs Adopting Code via SETCODEFROM

Draft v2.8. Sections S1–S16 are in the first reply.

TL;DR

EIP-8298 (SETCODEFROM) lets an EOA adopt account code at its own address. EIP-8151 makes ecrecover stop returning addresses that hold regular code. Together, they stop a secp256k1 key from sending transactions or passing ecrecover for that account, without moving assets. On a chain where some inclusion path skips the sender-code check (OP Stack deposits from an unmigrated L1), that holds only once the account has migrated where the path originates (W12).

Adoption is one-way: there is no return to empty code, and that is what retires the key. So the adopted code, and the transaction that adopts it, must be right the first time. Neither EIP specifies that code.

I found seven failure modes. Most are irreversible, and one is a check that looks sound but proves nothing. For example, code that falls back to ecrecover(...) == address(this) locks the account out the moment it is adopted.

This pre-ERC proposes:

  1. An adoption profile. Requirements R1–R9, most tied to a failure mode. Conformance belongs to a code hash, not to a product; existing designs can be reworked to conform.
  2. A migration guard. MigrationCheck reverts the migration unless four things hold in one transaction: the old key signed this migration, the signed code was adopted, the signed initialization ran and recorded itself, and ecrecover now rejects the old key.
  3. A reference kernel (non-normative). A minimal conforming account with ERC-7913 verifiers for post-quantum (PQ) keys.

Where I most need input:

  • The general guidance is now in EIP-8298 (ethereum/EIPs#12564). Is the rest the right scope for an ERC?
  • How would ERC-8286 and existing 4337/7579 accounts best conform?

Context: I wrote the EELS implementation of EIP-8151 (ethereum/execution-specs#3860, merged into the EIP-8151 branch with further tests from spencer-tb). PoC-1 (Route A, Migrator, MigrationCheck and a single-key kernel on EELS) is at nezu511/setcodefrom-adoption-poc.

Background

  • Status. For Hegotá, EIP-8141 (frame transactions) is Scheduled for Inclusion. EIP-8151 and EIP-8298 have been Considered for Inclusion since ACDE #247 (2026-10-08). The reference kernel depends on all three; the profile and Route A need only EIP-8298 and EIP-8151.
  • Key authority. A 7702 delegation keeps the EOA key’s authority; adopting regular code via EIP-8298 retires it. Wallet code alone can’t stop ecrecover-based authorization in existing contracts, so EIP-8151 closes that path in the protocol. The guard below tests exactly this choice. (This framing is due to @colinlyguo.)
  • The gap. EIP-8298 sketches SETCODEFROM(PQ_WALLET_TEMPLATE) but leaves the template undefined. ethereum/EIPs#12506 (open) adds a set-code operation to EIP-8141’s default code, and it also leaves the adopted code open.
  • Prior art. I found no standard or implementation that targets adoption via SETCODEFROM (S1). Pointers are welcome.

Failure modes (FM1–FM7)

Arrows point to the requirement (R) or guard check (P) that prevents each one.

  • FM1. Self-recovery locks the account out. Code that authorizes with ecrecover(...) == address(this) stops working once adopted, because EIP-8151 rejects addresses with code. A “fall back to the EOA key when no other key is set” design falls into this trap: it is code trying to keep a key the owner has just retired. (→ R1)
  • FM2. ERC-1271 passes, but VERIFY fails. Without a relay path (such as ERC-4337 validateUserOp), the account can initiate actions only as a frame-transaction sender, and that requires its code to APPROVE in VERIFY. A post-migration ERC-1271 check goes through a different entry point. It can pass while VERIFY is broken, and then the account can never act again, not even to replace its code. (→ R2, R3, W7)
  • FM3. Adopted but not initialized. If initialization isn’t in the adopting transaction, the code has no key and can never approve anything, including its own initialization. If initialization is left open to anyone instead, it can be front-run. (→ R4, P3)
  • FM4. Receiving breaks. ETH transfers and ERC-721/1155 safe transfers now run the code, and they revert without a payable path and receiver hooks. This is repairable only if the code is replaceable. Senders that hard-code 21,000 gas can fail against almost any code, a 7702 delegation included. (→ R7)
  • FM5. The source can change. SETCODEFROM copies whatever code is at the source address when it runs, and a source can replace its own code. So the user signs a code hash, not an address. (→ R6, P2)
  • FM6. An empty ecrecover result proves nothing. An invalid signature and an EIP-8151 rejection give the same empty output. So the guard makes the same call twice: before adoption it must return the account, and after adoption it must return empty output. (→ P1, P4)
  • FM7. No EIP-8141, no way out. EIP-3607 rejects transactions from accounts with code. EIP-8298 does not require EIP-8141. On a chain with EIP-8298 but without EIP-8141, code without a relay path can never initiate anything again, and no on-chain check can detect the missing EIP. (→ W4)

Why an ERC, and what went upstream

FM1, FM3, FM4, FM5 and FM7 are general guidance on using SETCODEFROM. They are now in EIP-8298’s Security Considerations (ethereum/EIPs#12564). FM7 also stays here as a wallet requirement.

Three things need agreement between parties that don’t share code:

  • Signers need one Migration typed-data format they can recognize and display. It is the one signature that hands an address over irreversibly.
  • Wallets need one audited Migrator they can allowlist as a 7702 target, ideally at the same address on every chain.
  • Wallets and auditors need one conformance target to check a code hash against before the irreversible step: the profile plus a test suite.

Components

Part Role Status
Adoption profile (R1–R9, V1–V4) Requirements for adopted code and its verifiers Normative
Migrator 7702 delegate that adopts and initializes in one call Normative behavior (M4–M7); canonical deployment recommended
MigrationCheck Guard for both routes (P1–P4), plus revocation Normative behavior (M1–M3, M7); canonical deployment recommended
Wallet requirements W1–W16 Normative
Reference kernel A minimal conforming account Non-normative

Terms

  • Old key: the EOA’s secp256k1 key.
  • Authority: anything the account registers that can approve, with a scope. In the reference kernel it is (ERC-7913 verifier, key, scope). v1 deliberately covers single keys only; composite authorities need their own proof format and will come as an extension.
  • Execution-capable: the authority’s scope lets it authorize the account’s own actions, through EIP-8141 execution approval or the equivalent on a relay path.
  • Registration proof: the key’s signature over an EIP-712 Registration digest. The digest binds the authority’s parameters, the chain and the account, but not the code version, so proofs survive replacement. It is the key holder’s consent, not an authorization: installing an authority always takes the chain-bound Migration or the account’s own execution-capable authority on that chain. The opt-in chain-free form (RegistrationAnyChain) replaces the chain with a deadline, for cold or few-time recovery keys (Q10, settled).
  • Relay path: an entry point through which a third party submits actions the account signed, such as ERC-4337 validateUserOp, so the account acts without sending transactions.

Adoption profile (draft requirements)

RFC 2119 keywords are used for precision, and everything is open for discussion. Tags: safety prevents an irreversible failure, mempool is for public-mempool use, interop lets others rely on the account. The only interface the profile defines is initialize(bytes); Route B also reads one view (M7).

Adopted code MUST:

  • R1. No self-recovery (safety, FM1). Never authorize via secp256k1 recovery against the account’s own address, through either ecrecover or an EIP-8141 SECP256K1 entry naming the account. Which authorities the old key could satisfy is for the wallet to check (W2).

  • R2. VERIFY approval (safety, FM2). Code that supports EIP-8141 MUST do the following before it calls APPROVE:

    • check that the frame mode is VERIFY, as ERC-8286 also requires, because APPROVE itself does not check the frame mode;
    • approve exactly the frame’s allowed scope, and only when one registered authority holds that whole scope and verifies a signature over the canonical signature hash.

    Code without VERIFY support MUST have a relay path instead. Whether the account can act on a given chain is a wallet check, not part of conformance (FM7).

  • R3. One verification (safety, FM2).

    • Every entry point that checks signatures (VERIFY, ERC-1271, registration proofs and any relay path) first builds its own digest and applies its own conditions: scope, domain, registration state and frame mode.
    • It then calls one shared verification of (authority, digest, signature), which gives the same result on every path for the same inputs.
    • Verifiers are called via STATICCALL on every path, including proof checks during initialization.
  • R4. Initialization (safety, FM3). initialize(bytes):

    • first locks the account: for the rest of the current EIP-8141 frame (transient storage is discarded between frames) or, outside a frame transaction, of the transaction, the new code rejects every incoming call to an entry that acts on the account’s authority: execution entries, authority changes (R5) and replacement (R6). Receiving assets (R7) and view calls still work. The lock holds even if the replaced code did not conform, unless that code clears it from its own frame, which keeps running after initialize returns. Under ERC-4337 it also stops a second UserOp of the same account in the bundle, validated by the old authority set, from running against the new code;
    • can be called only by the account itself;
    • reverts if the code hash recorded at the last initialization equals EXTCODEHASH(this), and otherwise runs and records the current hash. The record lives at a storage slot fixed by this ERC (R4_SLOT), so every conforming code reads the same one;
    • installs the authority set, and the code treats only what this initialization or a later R5 change wrote as authorities, modules, hooks, handlers or implementation targets. Data already in storage (for example, from an earlier 7702 delegate) has no effect; the code need not clear it;
    • checks EXTCODEHASH(verifier) == verifierCodeHash before verifying each proof, then verifies the registration proof of every execution-capable authority it installs (R3) and reverts if any fails or none exists; a chain-free proof is valid only while block.timestamp <= deadline. For the same initData it either reverts or installs the same authorities, whatever the gas, value, ORIGIN, balance, block or transient storage it did not write.
  • R5. Authority changes (safety). Only by the account itself. Every execution-capable authority needs a verified proof (verifier code hash and deadline checked as in R4), and at least one must always remain.

  • R6. Replacement (safety, FM5). Thanks to @Revinand for raising nested replacement, which led to the first two points, the end of the fifth, and R4’s lock.

    • Only on the account’s own authority: an EIP-8141 SENDER frame, or a relay path dispatching the replacement directly as the operation it validated. For a 4337/7579 account, this means a dedicated replacement function called directly as the UserOp’s callData and gated on the EntryPoint, not through execute/executeBatch, executeUserOp or an executor module; hooks may run before it, none after.
    • Replacement runs only as the outermost call into the account’s code: it reverts if any other call frame executing with the account as ADDRESS is active, including one entered through DELEGATECALL. (Informative: every entry that can write storage or make calls can count itself in transient storage at a slot this ERC would fix, so that the new code’s check also sees frames of conforming code it replaced; replacement then requires a count of one.)
    • The replacement call carries the expected code hash, and the signature that authorized it covers that hash.
    • The code compares the hash with EXTCODEHASH(source) immediately before SETCODEFROM, and with its own hash afterwards.
    • It then runs the new code’s initialize in the same call (R4), so replacement reverts unless the new code verifies the proof of an execution-capable authority. Because R4 reverts when the recorded hash equals the current one, replacing with the same code hash always reverts. After initialize returns, the replacement path returns without further SSTOREs or calls.
    • SETCODEFROM is reachable only on this path, including through DELEGATECALL, and never executes during validation (mempool): not in the EIP-8141 validation prefix, where EIP-8298 bans it, nor in a relay path’s validation phase (ERC-7562). In a VERIFY frame it would halt anyway, since VERIFY runs as a STATICCALL.
  • R7. Receiving (safety, FM4). Accept ETH with empty calldata, and ERC-721/1155 safe transfers.

  • R8. ERC-1271 (interop). Bind the hash to the account and chain before verifying, and accept only execution-capable authorities. Other accounts’ validation can’t call it in the public mempool (S14).

  • R9. Origin (safety). Outside an EIP-8141 frame transaction, a call with ORIGIN == ADDRESS to any entry other than initialize is not the account’s own call and carries no authority. Such calls arise without the code’s approval: OP Stack deposits, for example, skip the EIP-3607 check. (Informative: TXPARAM halts outside a frame transaction, so a low-gas STATICCALL to code that executes it tells whether one is running.)

Adopted code SHOULD also receive ETH within the 2,300-gas stipend, offer at least one configuration within EIP-8141’s MAX_VERIFY_GAS of 100,000, and follow S8.

Verifier rules. Verifiers called during validation, and any code they call or read, MUST:

  • V1. Stateless. Under EIP-8151, ecrecover reads the recovered account’s code, so an ecrecover-based secp256k1 verifier does not conform. Nor do inline ecrecover checks of an owner address, common in ERC-4337 accounts: if that address later adopts code, the authority stops verifying.
  • V2. Immutable. No SETCODEFROM, SELFDESTRUCT, DELEGATECALL or CALLCODE, and not 7702-delegated; helpers and key blobs included.
  • V3. Canonical. Reject trailing bytes and empty keys.
  • V4. Fixed scheme. The scheme and parameter set are fixed by the code or the key, never by the signature, and empty or short return data from any call, a precompile included, is a failure.

SHOULDs for verifiers (bytes at opcode positions, published gas) are in S7.

Migration: guard and routes

Typed data. D is the EIP-712 digest of the signed Migration; ownerSig is the old key’s signature over D; check names the MigrationCheck instance. The types are exactly these encodeType strings, hashed as written. verifyingContract is the account; name and version are fixed by this ERC (TBD). Registration is for ERC-7913 authorities; the last two are the opt-in chain-free proof and its domain.

EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)

Migration(address source,bytes32 codeHash,bytes32 initDataHash,uint256 deadline,address executor,address check)

Registration(address verifier,bytes32 verifierCodeHash,bytes32 keyHash,uint8 scope)

RegistrationAnyChain(address verifier,bytes32 verifierCodeHash,bytes32 keyHash,uint8 scope,uint256 deadline)

EIP712Domain(string name,string version,address verifyingContract)

keyHash is keccak256(key), where key is the bytes passed to the verifier’s verify. scope uses EIP-8141’s approval bits (0x1 payment, 0x2 execution); initialize reverts if any other bit is set. initData’s layout is implementation-defined (Q13). Typehashes and notes: S2.

MigrationCheck reverts the migration unless all four checks hold in the same transaction:

Check What it shows
P1 ecrecover(D, ownerSig) succeeds and returns the account the old key signed this and still controlled the account
P2 EXTCODEHASH(account) == codeHash after adoption exactly the signed code was adopted
P3 initialize(initData) ran on the adopted code and recorded its hash (R4), and keccak256(initData) == initDataHash for conforming code, exactly the signed authorities were installed
P4 the same ecrecover call, with the ownerSig P1 accepted, succeeds with empty output EIP-8151 rejects the old key on this chain

Guard and Migrator rules (M1–M7).

  • M1. begin tells the routes apart by its caller’s code: the delegation indicator for this instance’s Migrator means Route A, empty code means Route B, anything else reverts. In both routes it checks p.check == address(this), the deadline (valid while block.timestamp <= deadline, as in EIP-2612), revocation and P1; in Route B it also requires p.executor == account and p.source to be where its factory places p.codeHash (W10).
  • M2. finish checks P2 and P4, reverts unless P4 uses the ownerSig that P1 accepted, and emits Migrated(account, codeHash, D, route) at most once per begin. The guard enforces the last two itself, whatever arguments finish receives.
  • M3. P1 and P4 forward gas() and check returndatasize before reading the output; P4 accepts only success = 1 with empty output (S3).
  • M4. Migrator runs only for msg.sender == p.executor, and reverts if p.executor is EIP-8141’s ENTRY_POINT (0xaa).
  • M5. migrate reverts unless the address Migrator recorded for its MigrationCheck, not p.check, holds code with the hash Migrator recorded. Migrator creates MigrationCheck in its constructor (CREATE, nonce 1), reverts if that yields no code, and records its hash. Without this, a missing guard would pass silently (S6).
  • M6. Migrator keeps no storage, calls nothing but MigrationCheck and the account’s own initialize, and exposes only migrate and receive hooks that make no outbound calls. Neither it, MigrationCheck nor the factory can reach SELFDESTRUCT, SETCODEFROM, DELEGATECALL or CALLCODE at its own address.
  • M7. P3. In Route A, Migrator requires SLOAD(R4_SLOT) != p.codeHash before SETCODEFROM and SLOAD(R4_SLOT) == EXTCODEHASH(this) after initialize. In Route B, begin checks by frame introspection that initialize(initData), with keccak256(initData) == p.initDataHash, follows the set-code frame in the same atomic batch, and finish STATICCALLs the account’s initializedCodeHash() view and reverts unless its 32-byte output equals EXTCODEHASH(account).

Preinstalls. A chain that places these contracts without running constructors MUST place at each address the code its constructor would have returned there (MigrationCheck at CREATE(Migrator, 1)), not a compiler’s deployedBytecode (immutables zero). A canonical deployment at a deterministic address will be published.

Limits of the guard.

  • The old key as an authority. Neither the profile nor the guard checks the installed authorities against the old key. A secp256k1 verifier written in Solidity, registered with the old key, passes P1–P4 and leaves the key in control. Only the wallet can check this (W2).
  • Inputs, not quality. The guard checks the user’s signed inputs, not the quality of the code. Code that merely writes R4’s record passes P3. Conformance comes from choosing a code hash that has been checked against the profile and test suite (W6).
  • What P3 shows. For conforming code, a successful P3 means every execution-capable key passed the same verification that ERC-1271 and VERIFY (or the relay path) use (R3, R4). Nothing on-chain runs the VERIFY wrapper itself; only fork simulation does (W7).
  • Completion. Migrated is emitted only when all four checks pass. If the 7702 authorization was skipped, migrate hits empty code and still “succeeds”, and adopted code could emit the same topic, so completion is confirmed by the event and its emitter (W9).

Route A: EIP-7702 + Migrator (normative)

A single type-4 transaction authorizes the EOA → Migrator and calls migrate(p, initData, ownerSig), where p is the signed Migration struct. Migrator adopts and initializes the new code between MigrationCheck.begin and .finish. The account can revoke a signed intent with MigrationCheck.revoke(D). Using the reference kernel afterwards requires EIP-8141 (FM7). The pseudo-code illustrates M1–M7. Executor, revocation, failure and already-delegated EOAs: S4.

// SELF = Migrator's address; CHECK = its MigrationCheck
// CHECK_HASH = CHECK's code hash, recorded at construction
// EMPTY = keccak256("")
require address(this) != SELF
require msg.sender == p.executor
require p.executor != ENTRY_POINT
require CHECK_HASH != 0 && CHECK_HASH != EMPTY
require EXTCODEHASH(CHECK) == CHECK_HASH
require keccak256(initData) == p.initDataHash
// route A; p.check == CHECK; deadline; not revoked; P1
CHECK.begin(p, ownerSig)
require EXTCODEHASH(p.source) == p.codeHash
// no stale record
require SLOAD(R4_SLOT) != p.codeHash
require SETCODEFROM(p.source) == 1
// the new code runs with msg.sender == account
require address(this).call(initialize(initData))
// P3: R4's record
require SLOAD(R4_SLOT) == EXTCODEHASH(this)
// P2, P4; emits Migrated
CHECK.finish(p, ownerSig)

Route B: EIP-8141 default code (provisional; needs ethereum/EIPs#12506)

Route B is a VERIFY frame followed by one atomic batch of four SENDER frames: begin, the set-code frame, initialize, and finish. begin checks the frames after it by introspection, so that a revert in begin still skips the adoption; finish ties itself to the same batch, then checks P2, P3 and P4 (M7). p.source is the address at which MigrationCheck’s factory places code of the signed hash, so on a chain without MigrationCheck the set-code frame reverts and the batch with it (W10). Details, the frame table and a private-submission variant: S5.

Wallet requirements (proposed)

  • W1. Initiation. Wallets MUST NOT sign Migration for an external origin, such as eth_signTypedData* from a dApp. Migration starts only from the wallet’s own UI.
  • W2. Old key. Wallets MUST register authorities only under verifiers they recognize by code hash on each chain, and MUST check that the old key can satisfy none of them, at migration and at every R5 or R6 change they authorize.
  • W3. Executor. Wallets MUST NOT name as executor a contract that forwards arbitrary calls; Migrator can’t detect one.
  • W4. Chains. Wallets MUST NOT adopt code on a chain where the code has no working way to act (FM7). VERIFY needs EIP-8141 on that chain, and a relay path needs its entry contract (for example, the ERC-4337 EntryPoint the code trusts) to be deployed there.
  • W5. Control. Wallets MUST NOT show a chain as migrated, or the old key as retired there, before reading on that chain the account’s code hash, its full authority set and each verifier’s code hash, and MUST treat the account as not controlled if any differs from what they installed.
  • W6. Code. Wallets MUST offer only code hashes they have checked against R1–R9.
  • W7. Simulation. Wallets MUST NOT sign any part of a migration with the old key until a simulation passes on a fork that applies the target chain’s rules: a state-changing test authorized by an execution-capable authority through VERIFY or a relay path usable on that chain, on the account as the planned migration would leave it. The test MUST be bound to the chain’s ID and never be includable there (S9).
  • W8. Deployments. Before signing, wallets MUST compare the code hashes of Migrator and MigrationCheck, at a finalized block of the target chain, with values they have checked against M1–M7 (keccak256 of the full runtime code, immutables included), and MUST NOT sign a 7702 authorization with chain ID 0.
  • W9. Completion. Wallets MUST treat a migration as complete only when Migrated was emitted by p.check, not on transaction success.
  • W10. Route B. p.source MUST be the address where the factory places the signed code, and the begin and finish frames MUST target the MigrationCheck that created that factory.
  • W11. Chain-free proofs. Wallets MUST NOT sign a RegistrationAnyChain proof without a deadline the user has seen and accepted, and MUST NOT submit one for a key they have retired on any chain.
  • W12. Inclusion paths. On a chain where another chain can originate transactions as the account’s unaliased address without a sender-code check (OP Stack deposits from L1), wallets MUST warn that the old key can still move the account’s assets there, and MUST NOT show the old key as retired there until the account’s migration block M on the originating chain is finalized and a finalized block of this chain, after its migration, has an origin at or past M (S11). They SHOULD migrate the originating chain first.
  • W13. EIP-8141 entries. On a chain where EIP-8141 is active, wallets MUST NOT show the old key as retired until ethereum/EIPs#12505, or an equivalent rule, is active there, and SHOULD then confirm by simulation that such an entry fails.
  • W14. Key independence. An authority’s secret MUST NOT be computable from the old private key and public or shared data. Wallets MUST NOT derive an authority’s key from the BIP-32 tree that holds the old key.
  • W15. PQ display. Wallets MUST NOT present an account as quantum-safe unless every authority, of any scope, requires a valid signature under a quantum-resistant scheme; a hybrid that accepts either component alone does not count.
  • W16. Signature budget. Every signature by an authority’s key, proofs and simulations included, counts against its budget; for a stateful scheme it MUST advance the key’s single cross-chain state. One-time keys MUST NOT be registered as authorities that need a registration proof.

Wallet SHOULDs (display, backup, submission, simulation after signing, failure handling, other chains) are in S9 and S10.

Reference kernel

The kernel has no execute(): SENDER frames call their targets directly, which ERC-8286 calls the protocol-dispatched route. It also has no DELEGATECALL. Plugins are ERC-7913 verifiers called via STATICCALL, and larger changes adopt a new kernel. These are choices of the kernel, not requirements of the profile. Sketch, storage layout and PQ budget: S12.

Relation to existing work

  • ERC-8286 standardizes modules for frame-transaction accounts. SETCODEFROM adoption and migration checks are outside its scope. I think a protocol-dispatched 8286 account could conform under R3; see Q3.
  • ethereum/ERCs#1695 (closed) is the closest prior work on standard 8141 verification code. It targets 7702/7819 delegation, where its fallback to the account’s own address (in its reference code) is correct. Adopted as regular code with no key set, that fallback would cause FM1.
  • ethereum/EIPs#12506 is Route B. This proposal is one candidate for what that route adopts.

More related work (ERC-8403, JARDIN, EIP-8425, ERC-8421): S13.

Residual risks

  • Other chains. The old key stays valid wherever the account hasn’t migrated. A 7702 authorization with chain ID 0 is valid on every chain (W8).
  • Off-chain and Solidity checks. EIP-8151 doesn’t reach off-chain verification (SIWE, order books) or secp256k1 code written in Solidity, and this draft claims nothing about them. Integrators: if an address holds code that is neither empty nor a 7702 delegation on any chain you serve, do not accept a raw secp256k1 signature from it, not even as a fallback after ERC-1271 fails; a message’s chain ID is chosen by the signer.
  • Bridges and other code checks. Contracts that branch on whether the caller has code treat a migrated account as a contract; bridges that alias such senders credit deposits to the alias afterwards (S14; thanks to @Zealynx). OP Stack deposits run the other way too (W12), and messages relayed through a cross-domain messenger stay out of W12’s reach. For chains on chains, apply W12 to each parent–child pair from the root outward. In every case, funds at the account’s own address on a chain where it hasn’t migrated belong to the old key.
  • EIP-8141 SECP256K1 entries. EIP-8151 doesn’t cover them. An entry naming a migrated account still validates with the old key, so any contract that trusts an entry’s resolved signer accepts it, until ethereum/EIPs#12505 (which rejects SECP256K1 and P256 entries whose signer has regular code) or an equivalent rule is active on that chain (W13). The kernel itself never accepts such entries (R1).

More residual risks (Q-day timing, admin rights, validation calling into the kernel, sponsoring, bridge details): S14.

Open questions

Corrections are especially welcome wherever I’ve misread EIP-8141, 8298 or 8151.

  • Q1. ERC or upstream? Settled with @colinlyguo: FM1, FM3, FM4, FM5 and FM7 are now in EIP-8298 (ethereum/EIPs#12564). The Migration type, Migrator and the conformance target stay in an ERC.
  • Q2. EIP-8298’s scan and the sender’s own code. Settled with @colinlyguo: the sender’s own code running as the frame target is not treated as mutable merely because it contains SETCODEFROM, and executing the instruction during validation stays banned in the public mempool. EIP-8298’s Public Mempool section now says so (ethereum/EIPs#12564).
  • Q3. ERC-8286 and existing accounts. Is R3 (one shared verification for every entry point) easy to meet for 8286 validators and for 4337/7579 relay paths? Would a view hook previewApprove(bytes32 hash, bytes sig) help show it from outside, or invite misuse as a check that isn’t bound to the account?

Q4–Q14, grouped by audience, are in S16 (Q10 is settled; Q14 is the seal for chains the account doesn’t use).

Next steps

  • PoC-1 on EELS (nezu511/setcodefrom-adoption-poc): EIP-8298 + EIP-8151, a single-key kernel, Route A, Migrator and MigrationCheck; tests reproduce FM1 and FM3–FM6 and run the same migration with and without EIP-8151. Commits 1ad1351 and 43a0579 add M7’s Route A checks, and 3a979bc adds M5 and the scope check.
  • PoC-2. verifierCodeHash and R4’s lock; EIP-8141 integration: FM2 tests on a fresh transaction, Route B with the factory source and initializedCodeHash(), gas of the PQ paths and of the seal (Q14).
  • Conformance suite and fork-simulation tool. A black-box suite that runs against any code hash, with fault injection for R4 (one broken proof must revert; varying gas, value, ORIGIN, balance, block and transient storage must give the same authorities or a revert) and @Revinand’s nested-replacement test (S15).
  • Afterwards. A draft PR to ethereum/ERCs.
4 Likes

Continuation of the post above. Every MUST and definition is there; this reply explains and holds only the SHOULDs it points to by number. Where the two differ, the post above is correct. Sections keep their numbers across revisions. The EIP-8298 Security Considerations draft that was here is merged in ethereum/EIPs#12564.

S1. Where I looked

Informative.

ethereum/ERCs and ethereum/EIPs (open PRs included), the EIP-8298 Magicians thread, and Solady, OpenZeppelin, ZeroDev Kernel, Safe, Coinbase Smart Wallet, eth-infinitism, erc7579-implementation, Alchemy Modular Account, JARDIN and SPHINCs-.

S2. Typed data

Informative; ERC: Rationale and Test Cases. Explains Typed data in the post above.

  • Exact strings. Each line is an EIP-712 encodeType string with no space after a comma, so it hashes as written; v2.7 printed them with spaces, which hash to other values.
  • typeHash values (keccak256 of each string; digest vectors follow once name and version are fixed):
    • EIP712Domain with chainId: 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f
    • Migration: 0x88bf991dc9a5e9f1845328b77bf9cf83b6c7df88ae1e07cc1bb36be610c9801a
    • Registration: 0x0189d872514f3ce92752e739b26c2c44c75e340b91cb0afab5c6364434961bd1
    • RegistrationAnyChain: 0xfb6770718b65ed2ee21dcafcd8e962d8ce1c3cf471cb1675cb06f469d202f241
    • EIP712Domain without chainId: 0x91ab3d17e3a50a9d89e63fd30b92be7f5336b03b287bb946787a83a9d62a2766
  • Chain ID. Registration binds the chain by default, so a saved bundle reused after a key was retired on one chain fails safely. A “twin” account elsewhere is not the reason: an attacker who adopts other code there can list the user’s keys without any proof, and W5 is what catches that.
  • Chain-free form. RegistrationAnyChain is a separate type under a domain without chainId, so a chain-free proof can’t pass as a chain-bound one. The contract can’t tell how far ahead a deadline was set, so its length is a wallet matter (W11); since initialize re-verifies every proof on replacement (R4, R6), a replacement after the deadline needs a fresh cold-key signature. An authoritySetHash was considered and dropped: it binds neither the code nor the chain, and W5 does the work.
  • keyHash and scope. key is the second half of an ERC-7913 signer (verifier ‖ key). The scope bits are EIP-8141’s APPROVE_PAYMENT and APPROVE_EXECUTION; APPROVE reverts on bits outside the mask, and initialize does the same.
  • initData. Its layout is implementation-defined, so a signer cannot display what it installs (Q13). If Q13 adds an authoritiesHash to Migration, that type string and its hash change.

S3. P1/P4 details

Informative; ERC: Rationale. Explains M3.

  • Why two identical calls. An invalid signature already returns empty output, which Solidity reads as address(0), and since ethereum/EIPs#12540 an EIP-8151 rejection returns the same empty output with success = 1. Before adoption the call must return the account, which shows the signature is genuine; recovery is deterministic, so if the identical call afterwards returns empty output, the only thing that changed is the account’s code.
  • Delegated account during P1. In Route A, P1 runs while the account holds the 7702 delegation indicator, which EIP-8151 exempts on purpose: a delegation keeps the key’s authority.
  • Only empty output. Earlier drafts of EIP-8151 returned 32 zero bytes instead. Accepting those would also be sound, since P1 already showed that the same input recovers, but no chain targeted here returns them, and conformance tests need one expected result.
  • Reading the output. A call with empty output writes nothing to the output buffer, which keeps whatever it held before. In P1 that can be the account’s own address, left over from building the EIP-712 domain, exactly the value P1 compares against; so a malformed signature could pass P1 without the returndatasize check.
  • Gas. Under EIP-8151 a successful recovery costs 6,100 gas cold and 3,200 warm (EIP-8038 access costs), so a fixed 3,000 runs out of gas, which gives success = 0 and never passes as a rejection.

S4. Route A details

Informative; ERC: Specification notes and Security Considerations. Explains M4–M7 and the pseudo-code.

Executor (M4). ENTRY_POINT (0xaa) is the caller of every DEFAULT frame, hence excluded. Self-sent (executor = account): an intent runs only in a transaction the old key signs. Sponsored: the sponsor can run any unexpired intent that names it whenever the account is delegated to Migrator; Migrator can’t tell a call-forwarding executor from a real one (W3). The delegation is not bound to any D: while it stands, every unexpired, unrevoked intent of the account is executable by its executor, and re-delegating away only suspends them; any later delegation to Migrator, including one left by a failed attempt, revives them.

Revocation. The account can still send ordinary transactions with the old key, so it can call MigrationCheck.revoke(D); that records (msg.sender, D), and begin rejects D once (account, D) is recorded. Nobody else can revoke an account’s intent. MigrationCheck is never on a validation path, so the revocation set has no mempool impact. A revocation can still lose a race with a sponsor who executes first, so deadlines SHOULD be short.

The guard’s self-check (M5). Migrator creates MigrationCheck with CREATE in its constructor and reverts if no code results, so it never records 0 or keccak(""); MigrationCheck learns its Migrator from msg.sender, so nothing is circular. Re-checking on every call, rather than trusting the creation, covers deployments that copy runtime code without running constructors (OP Stack’s genesis preinstalls the ERC-4337 EntryPoint and its SenderCreator separately): a Migrator copied alone has the correct code hash and an empty guard. Requiring code (a recorded hash that is neither 0 nor keccak("")) also refuses a template whose immutables were never filled, which would compare 0 with 0. A Migrator whose immutables name other code with that code’s hash still passes M5; only W8 catches it. Cost: about 150 gas per migration.

Linking begin and finish (M2). begin writes a link to transient storage, keyed by (account, D) and holding keccak256(ownerSig), so finish runs P4 with the signature P1 accepted. finish consumes the link, so a second finish reverts: if the adopted code’s initialize calls finish early, before P3 holds, Migrator’s own finish reverts and takes the migration with it. After initialize, Migrator calls only finish, which writes nothing in the account.

P3’s record checks (M7). The check before SETCODEFROM rejects a stale record; the slot need not be empty (an earlier initialization may legitimately have left another hash), only not hold the hash about to be adopted. The check after initialize is what P3 verifies: code that answers every call with success without initializing (a permissive fallback, a proxy with an empty implementation slot) never writes it. Both read a record R4 already requires, so they add nothing to the profile and judge inputs, not quality.

Failure. On failure the call reverts but the 7702 delegation stays, and senders that hard-code 21,000 gas fail against it as against code; hence M6’s receive hooks. What a wallet does next is in S9.

Already-delegated EOAs. The type-4 transaction replaces an existing delegation. The old delegate’s storage stays behind and has no effect under R4; if it happens to hold the new code’s hash in R4’s slot, Migrator reverts before the adoption (M7).

S5. Route B details

Informative. Route B needs ethereum/EIPs#12506; explains M1, M7 and W10.

begin. It requires EXTCODEHASH(sender) == keccak256("") (never 0: frame 0’s APPROVE bumped the nonce; an active 7702 delegation must be cleared first), then reads the next three frames with FRAMEPARAM and FRAMEDATACOPY. With begin itself they must match rows 1–4 of the table below in mode, target, data and flags (‖ is byte concatenation), so the four frames form exactly one atomic batch, and finish must be the last frame, so frame 0’s approval cannot act on the adopted code after Migrated.

Why forward. A revert unrolls only its own batch, so a check outside the set-code frame’s batch could not undo the adoption; begin shares that batch and checks ahead, so a wrong structure reverts before the adoption (pointed out by Daniil Ankushin). Order matters too: initialize before the set-code frame would hit the default code and still succeed.

finish. Transient storage doesn’t survive across frames, so finish checks that the frame three back is begin(p, ownerSig) on this instance, that it and the next two carry the flag, and that all three have status 1; reading ownerSig from that frame makes P4 use the signature P1 accepted. Locating begin by position means only frame 4 can pass, so Migrated is emitted at most once and initialize (frame 3) cannot call it.

R4’s record (M7). finish is another contract and frames pass no return data, so it can’t read the account’s storage; it STATICCALLs initializedCodeHash() and requires 32 bytes equal to EXTCODEHASH(account), else it reverts and the batch undoes the adoption. So code that accepts any call is refused here as in Route A (a stale record only by R4), and code without this view can’t migrate through Route B. Only Route B needs the view for now; whether the profile requires it of all adopted code will be settled before a conformance suite is published.

The source (W10). A frame targeting an address without code succeeds under the default code, so with an empty MigrationCheck frames 1 and 4 would do nothing and the adoption would go through without P4, the structure checks, the deadline or Migrated (only the signer is exposed). The one thing the protocol does check inside the batch is that source exists and holds the signed code hash. So MigrationCheck’s constructor creates a factory that places code of hash h only at CREATE2(factory, salt = h, LOADER), and begin requires p.source to be that address. Without MigrationCheck there is no factory and no source, so the set-code frame reverts and the batch with it: fail-closed, by consensus, in the public mempool. A wallet derives MigrationCheck, the factory and the source from Migrator’s address alone (CREATE at nonce 1 twice, then CREATE2), so even a hardware signer can check the frames. Every route needs a source per chain and code hash, placed in an earlier transaction (EIP-8298); this only fixes where it lives. Not implemented yet.

Private submission. Alternatively, begin can be a VERIFY frame with scope 0, so an empty MigrationCheck makes the transaction invalid. A VERIFY frame after the validation prefix breaks EIP-8141’s public-mempool structure rule, so this form is for private submission only, M1 and finish need variants, and whether builders and L2 sequencers accept it is unchecked.

What remains. A set-code frame outside this batch, or a batch without the flags, shares no batch with a guard frame; begin rejects a sender that already has code, but cannot unroll a frame it shares no batch with. Wallets build the frames as in the table; the simulation after signing (S9) catches a mistake.

ownerSig. It is still needed, because the ECDSA bytes verified by the default code are not readable from the EVM.

# mode target data flags
0 VERIFY sender – 0x3 (APPROVE_EXECUTION_AND_PAYMENT)
1 SENDER MigrationCheck begin(p, ownerSig) atomic
2 SENDER sender 0x01 ‖ p.source ‖ p.codeHash atomic
3 SENDER sender initialize(initData) atomic
4 SENDER MigrationCheck finish(p, ownerSig) – (closes the batch)

S6. More on the guard

Informative; ERC: Security Considerations.

  • Missing EIP-8151 is caught. On a chain without EIP-8151, P4 fails, so the migration is refused. A missing EIP-8141 (FM7), by contrast, cannot be detected.
  • A missing guard is caught (M5, W8, W10). A call to an address without code succeeds, so a missing MigrationCheck would pass silently: in Route A anyone could then migrate an account left delegated to Migrator with an intent of their own, and in Route B the signer would lose P4 and Migrated. M5 and the factory source close both (S4, S5); W8 catches a Migrator copied without its guard, whose own code hash is still correct. An address list, or source verification that masks immutables, does not replace W8’s comparison. Nothing is exploitable today: EIP-8298 is live on no chain.
  • The reference template is inert. The canonical reference kernel is deployed uninitialized. It has no authority and accepts initialization only from itself, so nobody can initialize or replace it, and its hash is stable in practice. FM5 matters mainly when the source is someone else’s live account.
  • Completion (W9). A frame transaction’s receipt has no single status, and adopted code can emit a log with Migrated’s topic, so the wallet checks the emitter.

S7. Verifier rules: notes and SHOULDs

Informative except the SHOULDs; ERC: Specification. Explains V1–V4.

  • Stateless (V1). ERC-7913 only says SHOULD.
  • Canonical encodings (V3). Trailing bytes must be rejected because ARBITRARY signature bytes are outside the signature hash.
  • Fixed scheme (V4). A signature that selects its own scheme or parameters invites downgrade; and verifierCodeHash does not capture whether a precompile the verifier calls exists on this chain, so an empty return from it must be a failure, not a pass.
  • Bytes at opcode positions (SHOULD). No 0xA7, 0xF4 or 0xF2 at an opcode position, including in compiler metadata.
    • A contract containing 0xA7 is treated by EIP-8298 like a 7702-delegated account, which EIP-8141’s trace rules reject.
    • Contracts containing 0xF4/0xF2 are tracked by code hash, with a cap on the pending transactions that depend on them.
    • The reference kernel’s verifiers avoid all three.
  • Gas (SHOULD). Publish worst-case gas.

S8. Other code SHOULDs and notes

SHOULDs for adopted code, and informative notes; ERC: Specification and Security Considerations.

  • Replaceability (SHOULD). Declare via ERC-165 (interface ID TBD) whether the code is replaceable, and require an explicit freeze flag before replacing itself with code that isn’t.
  • Own address in VERIFY (SHOULD, mempool). Never CALL*/EXTCODE* its own address while in VERIFY. Replaceable code contains SETCODEFROM. EIP-8298 treats a contract containing it like a 7702-delegated account, and EIP-8141’s trace rules reject validation that reaches such an account.
  • Constructors don’t run. SETCODEFROM copies runtime code only. State a constructor writes (an initialized flag, a locked threshold, an owner) is absent at the adopting account, and an immutable that captured msg.sender or address(this) is the source’s, shared by every adopter. Code whose initialization guard lives in a constructor fails FM3; the conformance suite will carry such a negative fixture.
  • Code that answers unknown selectors. A fallback that returns success for any selector, or a proxy with an empty implementation slot, “initializes” without doing anything; M7 refuses it (suite fixtures: permissive fallback, stale storage). A multisig with setup open at threshold zero, or a fixed layout that reads old owners, does not conform as is; its EOA owners stop recovering once they adopt code.
  • Code that depends on mutable external code. A proxy with an immutable admin elsewhere, or a beacon proxy, passes P3 and any simulation while a third party can still change it. Only W6 catches that.

S9. Simulation (wallets)

Explains W7 and W16; SHOULDs for wallets; ERC: Security Considerations.

  • What passes. The test transaction is valid, every SENDER frame has status 1 (on a relay path, UserOperationEvent.success), and the expected state change happened. ERC-1271 does not count (FM2).
  • The state. Start from the target chain’s state at a recent block, override the account’s code with the code of the planned codeHash (not its storage) and its nonce as the test needs, call initialize(initData) from the account itself, then run the test. For conforming code this leaves the authorities the real migration would, whatever the context R4 lists; external state is not covered (below), and for other code nothing is (W6).
  • The chain’s rules. A simulator with the wrong fork rules passes code that fails on the chain: a VERIFY test with EIP-8141 enabled where the chain lacks it (FM7), or fixed gas forwarded to ecrecover where EIP-8151 raised its cost. The pre-signing test no longer catches a missing EIP-8151 through P4, hence the explicit rule. A key-free probe: take the address some arbitrary (hash, v, r, s) recovers to, give it regular code (not a 7702 indicator, which EIP-8151 exempts) in the fork, and call ecrecover with that input; under EIP-8151 the output is empty.
  • Never includable. Use a nonce of 2^63 in the frame transaction, or the EntryPoint’s sequential nonce far ahead for a relay path. A harmless target, an entry without the chain ID, or EIP-8250’s single-use nonce (nonce_seq = MAX is reserved) is not enough. The test is signed once and reused.
  • Scope. W7 asks for one execution-capable authority on one usable path because that is what prevents lockout: one working execution path can replace the code (R6) and repair the rest. Wallets SHOULD also test every other path, verifier and scope the account will use, including payment by an authority that will pay.
  • After signing (SHOULD). Simulate the signed migration itself, then the same test, on the user’s device before submitting it or giving ownerSig and the authorization to an executor.
  • Failure (SHOULD). If a migration fails and will not be resubmitted, wallets SHOULD revoke D with an old-key transaction, which also voids unused authorizations and frame transactions by advancing the nonce, and offer to clear a leftover delegation. The delegation keeps every unexpired intent executable (S4) and makes 21,000-gas senders fail; clearing it fixes only the second, and re-delegating later revives the intents, so revoke.
  • State source (SHOULD). Use state the wallet validated itself (its own node, or eth_getProof against a light-client header), or at least two independent RPC providers; W8 reads the same RPC, so one lying provider defeats both. Nothing signed with the old key exists before the test passes, so the test may run off-device; keeping the signed test on-device is a SHOULD (few-time keys, W16).
  • Tooling and limits. A relay-path test needs only a current EVM and a code override in eth_call; a VERIFY test needs an EVM with EIP-8141, which clients’ devnet branches have and standard simulation APIs don’t yet, and is needed only where EIP-8141 is live. No simulation shows state changes before inclusion (a module’s onInstall target), mempool rules or future forks.
  • Signature budget (W16). A stateful scheme’s signer state is one across chains and is never rolled back with a fork; few-time schemes (FORS, HORS, reduced-parameter SPHINCS+) lose security with every signature seen, so their test stays on the device; one-time schemes (WOTS) cannot carry a registration proof at all.

S10. Wallet recommendations

SHOULDs for wallets; ERC: Security Considerations.

  • Display. When signing, show the code hash and its implementation, every authority with its scope, the executor and the deadline; W2’s check and the display SHOULD cover every module, hook, executor and handler that can act or answer for the account.
  • Backup. Offer a second, separately held execution-capable authority. After migration, the old key is no longer a fallback.
  • Key derivation (W14). Derive authority keys from the seed with a separate, domain-separated KDF. In BIP-32 a non-hardened child key plus the parent xpub yields the parent key, and a quantum attacker breaks the public keys in an xpub directly.
  • PQ migrations (W15). When the purpose is quantum resistance, install only quantum-resistant authorities; a P256 passkey is a legitimate authority for other purposes.
  • Other chains. Before migrating, show the balances held at the same address on other chains, and warn that bridges which alias senders with code will credit deposits to the alias afterwards (S14), and about powers this ERC does not reach: balances released by off-chain or other-chain ECDSA, accounts the address controls elsewhere, keys derived from the old key’s signatures.
  • Unexposed public key. If the old key’s public key has not appeared on chain yet, sign every chain’s migration in advance and submit them privately within a short window, originating chains first (W12).
  • Submission. Submit privately, because the transaction is signed with the old key (Q-day timing, S14).

S11. Inclusion paths without a sender-code check

Explains W12; ERC: Security Considerations.

  • The gap. An OP Stack deposit carries no signature: the portal does not alias an L1 sender that is an EOA or a 7702-delegated EOA, and L2 skips the EIP-3607 check for deposits. So an account migrated on L2 but still an EOA on L1 can be driven from L1 by the old key: token transfers, L2 ETH through value, calls into its own code (R9 denies those authority, but a deposit with to set to a token never touches the code).
  • Ordering. A deposit is derived from the receipts of its L1 origin and runs in the first L2 block of that epoch, ahead of sequenced transactions, and the sequencer keeps its origin behind the L1 head. So a deposit queued before the L1 migration can execute after the L2 migration (raised by Revinand).
  • What “retired” means. Once shown, every deposit from an L1 block at or before M has executed on L2, and new old-key transactions here are rejected; later deposits from the same L1 address can only come from the account’s new code.
  • The display condition. M must be finalized, because a reorg could undo it; and some finalized L2 block after the L2 migration must have an L1 origin at or past M. Reply #20 required the migration’s own block to have that origin; a wallet that submitted before the origin reached M would then show “pending” forever, so any later finalized block now counts. The origin never moves backward on the canonical chain.
  • Submission (SHOULD). Submit the L2 migration only after M is final and a safe L2 head reports L1Block.number() >= M: an unsafe block can be rebuilt, and once a safe head shows M every later canonical block does too.
  • Not covered. Assets a queued deposit moves before the migration lands (a loss before migration); earlier approvals and roles; unfinalized withdrawals; failed cross-domain messages that can be replayed; messages through the CrossDomainMessenger, whose from is the aliased L1 messenger and whose L2 targets read xDomainMessageSender(). Wallets SHOULD say so.
  • Other rollups. Arbitrum aliases every L1 message sender through Inbox._deliverToBridge (retryables included) and keeps the sender-code check on the un-aliased *ToFork path; Scroll keeps the check for L1 messages (both read at branch heads, not deployed versions; raised by Zealynx). Forced inclusion on zk rollups, and a Scroll L1 message that fails the check, are unchecked.
  • Rollup-side fix. Process a deposit whose from holds regular code on L2 as a failed deposit (mint kept, nothing executed): proposed in ethereum-optimism/specs#980, with Revinand’s regression test (queue a token-transfer deposit, migrate on L1, migrate on L2 while the origin is behind, advance derivation). Without the check, the same sequence tests W12.

S12. Reference kernel: sketch, storage, PQ budget

Informative.

// frame data, covered by the signature hash:
// verify(uint8 authorityId, uint8 sigIndex)
assert FRAMEPARAM(cur, MODE) == VERIFY
assert SIGPARAM(sigIndex, SCHEME) == ARBITRARY
// canonical tx signature hash
assert SIGPARAM(sigIndex, MSG) == 0
sig     = SIGDATACOPY(sigIndex)
allowed = FRAMEPARAM(cur, ALLOWED_SCOPE)
// shared verification (R3)
scope = _authorize(authorityId, TXPARAM(SIG_HASH), sig)
assert allowed != 0 && (scope & allowed) == allowed
APPROVE(0, 0, allowed)
  • Storage. ERC-7201 namespaced. An active-id bitmap and the code hash recorded at initialization implement R4; initializedCodeHash() returns that record (M7).
  • PQ budget. The 100k budget covers the whole validation prefix, not just the verifier. Candidates: JARDIN’s compact path at about 48K (its note) or 60K (its README’s estimate); SLH-DSA-Keccak-128-24 at about 94K for verification alone (the SPHINCs- README), which leaves little room.
  • Large PQ keys. A key-blob contract encoded as 0x00 ‖ (PUSH32 ‖ 32 bytes)* keeps every byte as PUSH data; a raw 1,312-byte ML-DSA-44 key contains 0xA7 at an opcode position in about 80% of cases.

S13. More related work

Informative.

  • ERC-8403 (ethereum/ERCs#1979) defines an account-authority lifecycle and notes that no revoke removes a 7702-delegated EOA’s native key; of its two remedies (a new account, or regular code at the same address via EIP-8298 and EIP-8151), this proposal covers the second.
  • JARDIN is a hash-based PQ account (a research prototype per its README); its verifiers could be wrapped as ERC-7913 verifiers.
  • EIP-8425 (ethereum/EIPs#12383) installs a PQ wallet at the same address during recovery. The kernel could serve as that wallet. That path removes ecrecover, though, so P1 and P4 don’t apply.
  • ERC-8421 (ethereum/ERCs#2028) defines alternative mempools, the natural home for configurations over MAX_VERIFY_GAS.

S14. More residual risks

Informative; ERC: Security Considerations.

  • Q-day timing. The migration is signed with the old key, so this is a pre-Q-day procedure. Submit privately.
  • Admin rights. Any execution-capable authority can replace the code; v1 has no separate admin role.
  • Non-conforming old code. Replacing it is outside what the profile can guarantee: its frame keeps running after initialize and can do anything the account can, the lock and R6’s count included.
  • Validation calling into the kernel. Another account’s validation may call into the kernel, for example to check its ERC-1271 signature. EIP-8141’s trace rules already reject that, because it reads storage outside tx.sender. EIP-8298’s rule would reject even a storage-free call, because the kernel’s code contains SETCODEFROM.
  • Sponsoring. When the kernel approves payment for another sender, it acts as a non-canonical paymaster, limited to one pending transaction in the public mempool. Its pay frame reads the kernel’s own storage. I read EIP-8141’s “gas account” rationale as allowing that, but the trace rules don’t say so explicitly.
  • Bridges that alias senders with code (raised by Zealynx).
    • Arbitrum’s Inbox credits depositEth() from a sender with code to its L2 alias, and createRetryableTicket aliases refund addresses that have code; both already apply to 7702-delegated EOAs, and adoption makes them permanent. to is not rewritten, so a retryable with to set to the account still delivers l2CallValue to the account’s own L2 address.
    • OP Stack’s OptimismPortal2 treats the caller as an EOA when it is tx.origin or holds exactly a 7702 delegation indicator. A SENDER frame passes (ORIGIN is tx.sender there); a call through a relay path does not, so its deposit is aliased where a 7702-delegated account would still pass, and without EIP-8141 a relay path is the account’s only way to act. Whether the un-aliased frame case is intended is asked in ethereum-optimism/specs#980.
    • The opposite direction, deposits from an unmigrated L1 into a migrated L2, is W12 and S11.

S15. Nested-replacement test (from Revinand)

Informative; part of the planned conformance suite.

Expected results:

  • Replacement from inside execute, executeBatch, an executor, or executor → handleOps reverts.
  • Direct dispatch succeeds, with no SSTORE, CALL* or SETCODEFROM by the account after initialize returns.
  • With old code that ignores R6 but calls back into the account, both replace(oldSource) and a second op of the same bundle revert on R4’s lock.

S16. More questions (Q4–Q14)

Open questions, continued from the post above.

For EIP-8141 authors

  • Q4. MAX_VERIFY_GAS. EIP-8141’s mempool rule 6 counts “the intrinsic cost of validating tx.signatures”. I assume this means only signature_verification_cost (100 per ARBITRARY entry), not signature calldata. Can you confirm?
  • Q5. P256 entries. Should protocol-validated P256 signature entries be an authority kind? They cost 6,700 gas and need no verifier call, but a contract sees only their resolved signer, and only inside the frame transaction that carries them, so ERC-1271 would need a separate path.
  • Q6. Stateless verifiers. Under EIP-8151, ecrecover-based verifiers are no longer stateless, and EIP-8141’s trace and revalidation rules don’t track that read (the canonical paymaster’s signer check is one case). Should EIP-8141’s mempool section say so? Also raised in the EIP-8141 thread.
  • Q7. Large PQ keys. PUSH32 key blobs now, or wait for Public Key Aliases?

For wallet and account authors

  • Q8. ERC-1271 wrapping. A minimal AccountMessage(bytes32 hash) under the account’s domain, as Coinbase Smart Wallet does, or ERC-7739, readable but heavier and still Draft?
  • Q9. Revocation. Are executor, per-account revoke(D) and a short deadline enough?
  • Q10. Registration digests. Settled with Zealynx: chain-bound by default, with the opt-in RegistrationAnyChain form carrying a deadline (S2).
  • Q11. The event. Is an on-chain completion event useful to anyone besides the migrating wallet?
  • Q12. Canonical addresses. Migrator and MigrationCheck are specified by behavior, and a canonical deployment will be published at a deterministic address. Should conformance be limited to it?
  • Q13. What signers can see. initData is opaque to signers. Should the ERC fix an authority-list prefix for initData, or add an authoritiesHash to Migration, so that wallets can display what they install?
  • Q14. A seal for chains the account doesn’t use. Migrating L1 first is a lot to ask of someone who only uses L2, mostly because of registering PQ authorities (SETCODEFROM itself costs 12,200 gas with a cold source). Should the ERC define a seal: minimal code that authorizes nothing, or holds only a commitment to a recovery key whose proof is checked on first use? It would close the deposit path (W12) cheaply, but meets neither R4 nor P3 as written, so it needs a guard variant without P3, and the address is unusable there until recovery (forever, without a commitment). To be measured in PoC-2.
2 Likes

Really thorough write-up, the double ecrecover call for FM6 is a neat trick.

One thing I didn’t see under residual risks: canonical bridges that decide whether to alias the L1 sender by looking at its code. After adoption the account holds regular code, so:

  1. Arbitrum’s Inbox.depositEth() aliases whenever isContract(msg.sender) is true, so ETH deposited from a migrated account lands on applyL1ToL2Alias(account) on L2, not on the account itself. createRetryableTicket also rewrites excessFeeRefundAddress and callValueRefundAddress to their alias when they have code, and callValueRefundAddress is the address that can cancel the ticket on L2.
  2. OP Stack’s OptimismPortal2 uses EOA.isSenderEOA(): msg.sender == tx.origin, or exactly 23 bytes of code starting with 0xEF0100. Adopted code fails the second check, so the outcome depends on what ORIGIN returns inside a SENDER frame. If it isn’t the sender, deposits get aliased there too.

This shouldn’t lose funds by itself, since the alias stays reachable through L1 to L2 messages sent by the account. But it pairs badly with “Other chains”: on the L2 the real address is still controlled by the old key, and new deposits land on an address the wallet probably isn’t watching. Might be worth a wallet SHOULD: before migrating on L1, show the balances held at the same address on L2s, and warn that canonical bridge deposits will be credited to the alias afterwards.

2 Likes

Thanks for the detailed proposal.

For Q1, I agree with the split: the general migration risks belong in EIP-8298’s Security Considerations, while the adoption profile, migration format and guard contracts fit better in an ERC.

For Q2, your reading matches the intent. Loading the sender’s own code as the validation frame’s target should not trigger the mutable-code rule merely because it contains SETCODEFROM. Executing SETCODEFROM during the validation prefix remains disallowed.

For Q6, I agree that EIP-8151 introduces this state dependency. In my view, EIP-8141’s mempool rules need to explicitly track this dependency and bound the validation work that a single code change can invalidate. I would welcome input from the EIP-8141 authors on the precise handling, including the canonical paymaster case.

I also noticed that EIP-8298 still mentions “32 zero bytes” and has not been updated to reflect EIP-8151’s recent change to empty output.

The source front-running risk described in FM5 also belongs in EIP-8298’s Security Considerations as a general risk. I think it would be helpful to highlight the source front-running risk described in FM5 as a general security consideration in EIP-8298.

We can discuss and address these points together in a single PR, and please feel free to open one.

2 Likes

Thanks @Zealynx, this is a real gap, and I agree it doesn’t lose funds by itself. I checked both against the current sources (nitro-contracts develop faad883, optimism develop ca63e7e).

Arbitrum. Confirmed. Inbox.depositEth() aliases when isContract(msg.sender) || tx.origin != msg.sender, and createRetryableTicket aliases both refund addresses when they have code. Two additions. isContract is already true for a 7702-delegated EOA (23 bytes of code), so a delegated EOA is aliased there today; adoption makes it permanent. And unsafeCreateRetryableTicket skips the refund rewrite, so a migrated account can still name its own address as callValueRefundAddress. There is no such variant for depositEth. to is not rewritten either, so a retryable with to set to the account delivers l2CallValue to the account’s own L2 address on redeem.

OP Stack. For a SENDER frame, no alias. EIP-8141 sets the frame’s caller to tx.sender in SENDER mode, and ORIGIN returns the frame’s caller at every call depth, so a call to OptimismPortal2 from the account has msg.sender == tx.origin and passes isSenderEOA(). The case that does alias is a relay path such as ERC-4337, where ORIGIN is the bundler: the account has regular code, not 23 bytes, so it fails both checks. A 7702-delegated account on the same relay path still passes, so this is one more thing adoption changes. On a chain without EIP-8141 (FM7), a relay path is the only way the account can act, so deposits from there are always aliased. Even then, the alias is only the L2 from: the mint is credited to from unconditionally, and value is then sent to _to, which is msg.sender for receive(), so ETH sent to the account’s own address arrives there unless the L2 execution fails.

Either way, what lands at the account’s own address on a chain where it hasn’t migrated belongs to the old key, which is your “Other chains” point again.

I’ll add this under Residual risks with credit, and take your wallet SHOULD: before migrating, show the balances held at the same address on other chains, and warn that deposits through bridges that alias senders with code will be credited to the alias afterwards. On Arbitrum that is depositEth() itself; on OP Stack via a relay path, the mint lands on the alias and reaches the account only if the L2 call succeeds.

1 Like

Thanks @colinlyguo. That settles the split, and I’ll open the PR.

Scope. One PR against EIP-8298, with you and @nconsigny as reviewers:

  1. Security Considerations: the draft text from the first reply (FM1, FM3, FM4, FM7), plus FM5 as a general risk rather than a note for migration code. The Rationale already says a valid source can replace its own code hash in the same block; the caller-side consequence is that anyone committing to an adoption should commit to a code hash, and the adopting code should compare it with EXTCODEHASH(source) immediately before SETCODEFROM.
  2. The “return 32 zero bytes” sentence, updated to empty output with success = 1, as EIP-8151 specifies after ethereum/EIPs#12540.
  3. Optionally, one sentence after the second mempool bullet stating what you confirmed for Q2: the sender’s own code running as the frame target is not a contract “reached through CALL* or EXTCODE*”. I’ll keep it in a separate commit so it’s easy to drop.

I’ll post the link here within the week.

On Q2, thanks. The reference kernel is consistent with the second half: its VERIFY path never calls its own address, and R6 accepts only the account itself as caller, so SETCODEFROM cannot execute during validation.

On Q6, agreed. Two points for the EIP-8141 authors, in case they help. The address whose code ecrecover reads is known only when the precompile returns, so this dependency can’t be derived from the frame structure; it would have to be recorded from the trace, as sender storage slots are today. And the canonical paymaster is admitted by code match and exempt from the trace rules, so its signer’s code would need to be added to the paymaster-specific revalidation list explicitly. I’d be glad to raise this in the EIP-8141 thread with a link to your reply, unless you’d rather.

1 Like

Thanks, the PR scope looks good, and about EIP-8141 discussion, feel free to go ahead!

2 Likes

EIP-8298 keeps an existing call frame running its original code after SETCODEFROM. In a 4337/7579 adapter, an executeBatch could self-call the replacement path, initialize the new implementation, then return to an old hook or cleanup routine that writes to storage. Those writes could overwrite newly initialized state even though adoption and initialization were atomic. Could R6 explicitly cover replacement while older account call frames are still active?

Stopping the replacement function after initialization would still leave any older account frames on the stack. A conformance test could trigger replacement inside nested execution and check that subsequent writes from old code cannot invalidate the new authorization state. The reference kernel’s lack of execute() simplifies this, but an explicit rule would help existing accounts adapt to the profile. What invariant should conforming accounts enforce here?

3 Likes

Thanks @Revinand, this is a real gap. R6’s “only by the account itself” is satisfied by a self-call from inside executeBatch, and EIP-8298 keeps that outer frame on the old code after the replacement returns, so whatever it does next runs with the account’s authority against the new code’s storage. The reference kernel avoids this only by construction; the profile should say it.

Two rules, one on each side of the replacement.

R6: replacement is the outermost frame of the account’s code, and the last thing the old code does.

  • The replacement path MUST revert if any other frame whose ADDRESS is the account is active, including frames reached through DELEGATECALL. One way to enforce it: every entry that can write storage or make calls counts itself in transient storage at a slot fixed by this ERC, and the replacement path requires a count of one. The slot is fixed so that the new code’s check also sees frames of the code it replaced.
  • After initialize returns, the replacement path MUST return without further storage writes or calls.

“Only by the account itself” becomes “only on the account’s own authority”: a self-call, an EIP-8141 SENDER frame (its caller is tx.sender, and transient storage is discarded between frames, so the count is per frame), or the relay path dispatching the replacement directly as the operation it validated. For a 4337/7579 account that means a dedicated replacement entry taken as the UserOp’s calldata, gated on the EntryPoint, never routed through execute/executeBatch, executeUserOp or an executor; hooks before it, none after. The rest of the account is untouched.

R4: after initialize, the new code locks itself. For the rest of the frame under EIP-8141, or of the transaction elsewhere, the new code MUST reject every call that acts on the account’s authority: execution entries, R5 and R6. Receiving assets and answering queries stay open. This is the rule that holds even if the old code is not conforming, and it closes two things the first rule can’t reach:

  • a same-transaction undo: an old frame that calls replace(oldSource, oldHash) on the new code passes, because the new R6 sees msg.sender == address(this) and R4’s record now holds the new hash, so the old initialize runs again;
  • under 4337, a second UserOp of the same account in the bundle, validated by the old authority set before execution and then executed against the new code. Under 8141 one signature covers all frames, so the lock costs nothing there.

I’d rather require these than make the new state clobber-proof: the new code cannot know the old code’s layout, and isolation would not stop the old frame from acting with the account’s authority.

The conformance test is yours with the expected results changed: replacement attempted from inside execute, executeBatch, an executor, or executor → handleOps must revert; direct dispatch must succeed with no SSTORE, CALL* or SETCODEFROM by the account after initialize returns; and with a harness old code that ignores the first rule, its replace(oldSource) and a same-bundle second op must both revert on the lock. I’ll add both rules and the test to the next revision, with credit. If you had the isolation form in mind (nested replacement succeeds and the state survives), I’d like to hear why.

Route A is separate: Migrator is the 7702 delegate, not adopted code, and after initialize it calls only MigrationCheck.finish, which reads the account’s code hash and ecrecover and writes nothing in the account.

1 Like

Thanks, PR is open: Update EIP-8298: Add adoption guidance to Security Considerations by nezu511 · Pull Request #12564 · ethereum/EIPs · GitHub

It keeps to the agreed scope: the Security Considerations paragraphs, the success = 1 wording, and one sentence in Public Mempool (kept separable, so it is easy to drop if you prefer the current wording). No change to the specification or requires.

I also raised the EIP-8151 mempool dependency in the EIP-8141 thread as discussed: EIP-8141: Frame Transaction - #179 by nezu511

2 Likes

I’ve revised the first two posts (v2.7 in the edit history). Here is what changed and where it came from.

Layout

  • To stay under Discourse’s 32,000-character limit, these moved from the first post to the first reply: Route B details, more on the guard, verifier rules in full, the kernel sketch, more related work and more residual risks. Their text is unchanged except for a few sentences in Route B begin and finish, below.

Upstream

  • The general guidance (FM1, FM3, FM4, FM5, FM7) is now in EIP-8298’s Security Considerations, merged in ethereum/EIPs#12564 with review from @colinlyguo. The draft text in the first reply now points there, and Q1 and Q2 are marked settled.
  • ethereum/execution-specs#3860 (EIP-8151) is merged into the EIP-8151 branch.
  • R6 and validation. Following Colin’s answer to Q2, R6 now says SETCODEFROM never executes during validation (the 8141 validation prefix, or a relay path’s validation phase) (mempool), instead of leaving it implicit.

From this thread

  • R6 and R4 (@Revinand). Replacement runs only as the outermost call into the account’s code and is the last thing the old code does. “Only by the account itself” becomes “only on the account’s own authority”, including direct dispatch from a relay path. After initialize, the new code locks itself for the rest of the 8141 frame or the transaction, which blocks a same-transaction undo by non-conforming old code. Your nested-replacement test is in the first reply as part of the planned conformance suite.
  • Residual risks and wallet SHOULDs (@Zealynx). Bridges that alias senders with code, and a pre-migration check of balances at the same address on other chains.

From building PoC-1 on EELS (repository to follow)

  • P4. It uses the ownerSig that P1 accepted, enforced by the guard itself, and accepts only empty output.
  • returndatasize. It must be checked in P1 as well as P4. A stale word in the output buffer can equal the account’s address and let a malformed signature pass P1.
  • finish. It consumes the link from begin, so Migrated is emitted at most once. Without that, adopted code could call finish from its own initialize, before P3 holds. In Route B, finish now finds begin by position, and begin requires finish to be the last frame, so frame 0’s approval can’t act on the adopted code after Migrated.
  • Executor. Migrator itself rejects ENTRY_POINT as executor. The “no call-forwarding executor” rule is now a wallet MUST, since code can’t check it.
  • Deadline. Valid while block.timestamp <= deadline.
  • R4. Old authority data is ignored, not cleared.
  • 21,000-gas senders. They fail against a 7702 delegation too, including one left behind by a failed migration.

Removed, and one limit made explicit

  • R1’s last two sentences (“Reject any authority it can recognize as satisfiable by the old key…”). Code can’t judge an arbitrary verifier, so the requirement was untestable. The check stays where it can be done, as the wallet MUST under Old key.
  • Limits of the guard now says so plainly: a Solidity secp256k1 verifier registered with the old key passes P1–P4, and only the wallet can catch it.
3 Likes

Thanks for the credit.

On Q10: dropping the chain looks safe for the registration proof itself, since it’s the new key’s consent and installing it still needs the chain-bound Migration signature. What it changes is what verifier means. The same address can be empty, or hold different code, on another chain, and the proof is checked through whatever is deployed there. If chainId goes, I’d add the verifier’s code hash to Registration and have initialize check EXTCODEHASH(verifier) against it.

Same for the Deployments SHOULD: it covers Migrator and MigrationCheck, but a wallet that recognizes verifiers by address should check their code hash on each chain too. A verifier that accepts any signature at a familiar address would hand the account to anyone once installed.

1 Like

Thanks @Zealynx, both points are right, and I’d take the code-hash binding whether or not the chain ID stays.

Q10. The proof binds the verifier’s address, not its code, so it is only as good as whatever sits at that address on each chain: nothing yet, or a different contract if the deployer’s nonce or a CREATE2 factory was used differently there. I’ll add verifierCodeHash to Registration and have initialize require EXTCODEHASH(verifier) == verifierCodeHash before checking the proof. Verifiers are immutable under the profile, so one check at registration is enough on that chain, and it rejects an empty address outright instead of relying on how the kernel reads an empty return. The key is already covered by keyHash, so the verifier was the only unbound part.

On the chain ID itself, I now lean toward keeping it as the default. You’re right that a proof alone installs nothing, but once used on one chain it is public. Someone who later breaks the old key on a chain I haven’t migrated yet could migrate it with my key plus theirs: my signatures keep working there, and the account looks like mine. A chain-bound proof can’t be reused that way, and it also fails safe if I retire a key and a wallet later reuses a stored migration bundle. The cost of re-signing falls mostly on few-time and cold keys, so I’ll rewrite Q10 as whether those deserve an explicit opt-in form, rather than dropping the chain for everyone. Either way, wallets should judge control by the whole authority set on each chain, not by finding their own key in it.

Deployments. Agreed, and it’s what makes the code-hash fix work: the check is only as good as the hash the wallet puts in Registration. A wallet that reads the hash from the chain it’s migrating on would bind whatever is there. So wallets should recognize verifiers by known code hash, checked on each chain, and the Old key MUST should say so: a verifier that accepts any signature at a familiar address hands the account to whoever signs next. I’ll extend the Deployments SHOULD to cover verifiers alongside Migrator and MigrationCheck.

Both go into the next revision, with credit.

Fair, I missed that a proof is public once it’s used and outlives the old key on chains you haven’t migrated yet. Keeping the chain ID as the default makes sense.

For the opt-in form, one way to close that case: have a chain-free proof also sign the hash of the whole authority set being installed, not only its own verifier, keyHash and scope. Then a public proof can only install exactly the set you chose, which locks out whoever broke the old key, and nobody can put your key in a set of theirs as an execution authority without a new signature from it. The cost moves to set changes: adding or rotating any key means signing again with the slow key, but only then, not once per chain.

1 Like

Thanks @Zealynx. It’s a clean construction, and it answers the twin I raised for keeping the chain ID.

Before adding it, I checked the twin against the threat model I care about most: the old key will eventually be broken. Losing a chain I haven’t migrated is accepted; the old key must not be usable on a chain I have migrated. Under that model I overstated the twin, and that’s on me. Your binding, like the chain ID, covers the proofs, not the account’s code. On a chain where the old key is broken, the attacker can adopt different code that lists my keys without checking any proof, so the twin can look like mine either way. Your framing in #12, that the proof is the new key’s consent and installing still needs a chain-bound Migration, was the right one.

So the defense against the twin has to be the wallet: before treating an account as mine on a chain, read its code hash, its full authority set and each verifier’s code hash, and treat it as not mine if anything differs from what I installed. With that as a MUST, the set binding adds no protection there, and it costs a cold or few-time key a new signature on every set change. Where I can see it helping is a compromised host at signing time, if the cold device shows the set before signing. That’s the problem Q13 already raises for Migration, and I’d rather solve both there.

The stored bundle still stands, but the set hash doesn’t change it: a stale bundle carries the set I chose back then, with a matching hash, so a wallet that reuses it after I retire a key installs that key again. A chain-bound proof fails safe there, and that’s why I’d keep it as the default. The opt-in form needs a wallet rule instead: never submit a chain-free proof for a key retired on any chain.

For the next revision: chain-bound by default, the opt-in chain-free proof over (verifier, verifierCodeHash, keyHash, scope), and both wallet rules as MUSTs. This exchange is what turned them into concrete rules, and I’ll credit it. Do you see a case the set binding covers that these rules don’t?

Separately, going through every path the old key keeps after migration turned up a gap next to your bridge point in #3, in OP Stack deposits. I’ll post it on its own below.

While checking every path the old key keeps after migration (assuming it eventually gets broken), I found one the draft doesn’t cover: OP Stack deposits. It sits next to the bridge aliasing raised in #3, in the other direction.

The gap. An L1→L2 deposit carries no signature; the L2 trusts the from the portal records.

  • On L1, depositTransaction doesn’t alias the sender when msg.sender == tx.origin or the sender is a 7702-delegated EOA (OptimismPortal2, EOA.sol).
  • On L2, deposits skip the sender-code check. The spec says “No check if from is an Externally Owner Account”, and op-geth’s preCheck says “no need to check if EOA (L1 already verified it for us)” (state_transition.go).

Before 8298 that’s sound: an address that is an EOA on L1 is controlled by the same key on L2. With 8298 it isn’t. If the account migrated on L2 but not on L1, whoever holds the old key can send a deposit from L1 with from set to the account and run any call as it on L2: move its tokens, send its L2 ETH through value, and, with to set to the account, look like a self-call to its own code. EIP-3607 and EIP-8151 never come into it.

Nothing is exploitable today: no OP Stack chain runs 8298, and a 7702 delegation keeps the key in control anyway. It matters for how rollups adopt 8298.

In the draft (v2.8):

  • A scope note on the opening claim: it holds only where every path that originates transactions as the account enforces EIP-3607.
  • Wallets MUST NOT present the old key as retired on such a chain until the account has migrated on the chain the deposits come from, and MUST warn. They SHOULD migrate that chain first.
  • Code MUST NOT treat a call as the account’s own when ORIGIN == ADDRESS outside an EIP-8141 frame transaction, except initialize. This narrows the “self-call” in R6: a deposit with to set to the account and data calling the replacement path is the outermost frame, so it would pass R6 as written. The rule stops a deposit from changing authorities, though not from moving assets.

For rollups. When adopting 8298, treat a deposit whose from holds regular code on L2 (neither empty nor a 7702 delegation) as a failed deposit: the mint still lands, the call doesn’t run. Deposits must always be included, and the spec already says “The mint persists even if execution fails”, so this adds a condition, not a mechanism. Aliasing instead would be worse, since on L2 only the old key’s deposits control the alias. I’ll open a discussion on ethereum-optimism/specs.

Q14. A seal for chains the account doesn’t use. Migrating L1 first is a lot to ask of someone who only uses L2, mostly because of registering PQ authorities (their storage and proof checks), not adoption itself: SETCODEFROM costs 12,200 gas with a cold source, regardless of code size (EIP-8298, Gas Costs). Should the ERC define a seal, adopting minimal code that authorizes nothing, or that holds only a commitment to a recovery key whose registration proof is checked when it’s first used? It would close the deposit path for much less than a full migration, though I haven’t measured it yet. The price is that the address is unusable on that chain until recovery, or forever without a commitment. I’d measure it in PoC-2.

Not yet checked: Arbitrum’s signed delayed-inbox messages (unsigned ones are aliased, except the *ToFork functions, which only work after a chain-ID change), Scroll’s enforced transactions, and forced inclusion on zk rollups. If you know how they treat a sender with code, I’d like to hear it.

No, I don’t see one. Where the attacker controls the code, nothing inside the proof helps, and on the honest path the old key’s chain-bound Migration already signs the initialization, and with it the set. Your rules cover it.

The one thing I’d add is for the stale bundle. “Never submit a chain-free proof for a key retired on any chain” only works if the wallet knows about retirements made from another wallet or device. A deadline in the opt-in proof, like the one Migration already has, bounds that window without needing a global view. The cost is re-signing with the slow key for chains you haven’t migrated by then.

On #16, I checked two of the paths you listed.

Arbitrum signed delayed-inbox messages: ArbOS parses them as ordinary signed transactions (L2MessageKind_SignedTx in arbos/parse_l2.go), so from comes from the signature, and Nitro’s geth keeps the sender-code check for those types (skipTransactionChecks() is false for them in core/types/arb_types.go, so preCheck returns ErrSenderNoEOA). A migrated account can’t be used through that path.

Scroll enforced transactions: EnforcedTxGateway only aliases when msg.sender != tx.origin, and the signed variant only checks a plain ECDSA recover against _sender on L1, so as on OP the L2 from is the account. The difference is in l2geth: preCheck runs the sender-code check for L1 messages too, before the L1 message branch, so a call from an account with regular code on L2 fails there. That’s close to the rollup rule you propose, though I haven’t traced what happens to the message and its value after that.

I haven’t looked at forced inclusion on zk rollups.

1 Like

On #16, could the wallet rule also cover deposits already in flight? An L1 migration receipt doesn’t establish that L2 has processed earlier deposits: OP derivation ties them to the L2 block’s L1 origin. My reading is that a deposit submitted before L1 adoption could execute after L2 adoption while the origin catches up, keeping its original unaliased from. Under the existing deposit rules, neither the sender’s nonce nor its code is checked, so adoption wouldn’t invalidate that queued call.

A regression test could queue a token-transfer deposit, migrate L1, migrate L2 while its origin is behind, then advance derivation. The proposed rollup-side check should fail the call while preserving the mint. For chains relying on the wallet mitigation, the test would check whether migration ordering also handles pending deposits. Should wallets wait for L1 migration finality and an L2 safe head whose L1 origin reaches that block before submitting the L2 migration?

1 Like

Thanks @Zealynx, and for checking those two paths.

Deadline: agreed, and I’d make it mandatory. The chain-free proof becomes (verifier, verifierCodeHash, keyHash, scope, deadline), the deadline is checked like Migration’s (block.timestamp <= deadline), and wallets MUST NOT sign one without a finite deadline. The contract can’t tell how far ahead a deadline was set, so a cap on its length can only be a wallet rule. Always having the field also means one proof form, with no with-or-without-deadline variants. The wallet rule stays for retirements the wallet does know about. Choosing the deadline is the trade-off you describe: a shorter one means re-signing with the slow key more often. One more cost: initialize re-verifies every proof when code is replaced, so after the deadline a replacement needs a fresh slow-key signature too.

Arbitrum and Scroll: I read both (branch heads, not deployed versions), and they match your description. Two additions on Arbitrum. The *ToFork exception I noted in #16 (usable only after a chain-ID change) is covered: its unsigned EOA message becomes an ArbitrumUnsignedTx with the unaliased sender, and skipTransactionChecks() is false for that type, so preCheck rejects an account with regular code. I also checked retryable tickets: Inbox._deliverToBridge aliases the sender recorded for every message kind (separate from the isContract conditions on depositEth and refund addresses from #3), and ArbOS takes the ticket’s from from the message’s poster, so a ticket created by an EOA runs as its alias. Among the paths checked so far, then, Arbitrum either aliases the L1 sender or keeps the sender-code check, Scroll keeps the check for L1 messages, and the OP Stack skips it. Forced inclusion on zk rollups is still unchecked, and so is what happens to a Scroll L1 message after it fails preCheck. I’ll cite Arbitrum and Scroll in the OP Stack discussion as precedent for keeping the sender-code check.

The Arbitrum and Scroll results go into the bridges item under Residual risks in the next revision, with credit.

Thanks @Revinand, good catch.

Yes, in this form, with two conditions kept apart. When to show “retired”: a wallet MUST NOT show the old key as retired on L2 until the L1 migration block M is finalized and the L2 migration is itself in a finalized L2 block whose L1 origin is at least M; until then it shows the migration as pending. The MUST warn and SHOULD-migrate-L1-first from #16 stay. When to submit: a wallet SHOULD submit the L2 migration only after M is final and a safe L2 head reports L1Block.number() >= M (that value is the number of the L1 origin of the L2 block being executed). Finality of M is needed because a reorg could undo the L1 migration. Safe is needed because an unsafe block can be rebuilt; origin never moves backward, so once a safe head shows at least M, every later block on the canonical chain does too, including the one that will hold the migration. The display condition asks for finalized rather than safe because a safe block is derived from L1 data that could still be reorged. An early L2 migration can’t be undone, so wallets should wait before submitting.

Your reading matches the spec: a deposit is derived from the receipts of its L1 origin and appears only in the first L2 block of that epoch, ahead of the sequenced transactions, so a deposit from L1 block N can’t run in an L2 block whose origin is below N. An L1 receipt says nothing about where L2 is, and deposits check neither the sender’s nonce nor its code, so one queued before the L1 migration can run after the L2 migration.

What the rule does and doesn’t do. It can’t rescue what a queued deposit moves before the migration lands; that is a loss before migration, which I accept. It pins down what “retired” means: once shown, every deposit from an L1 block at or before M has already executed on L2, and new old-key transactions on this chain are rejected. Deposits from the same L1 address after M can only come from the account’s new code, since the old key can no longer send L1 transactions. Not covered: earlier approvals and roles, unfinalized withdrawals, and failed messenger messages that can be replayed; wallets should say so. A deposit that runs after adoption can also reach the new code: with to set to the account it looks like a self-call, which is what the ORIGIN == ADDRESS rule in the next revision is for, so the ordering is a second layer.

The rollup-side check would remove the ordering dependence for deposits whose from is the account: one that runs after adoption sees a sender with code, fails, and keeps its mint. It doesn’t see messages relayed through the CrossDomainMessenger, whose from is the aliased L1 messenger and whose L2 targets read the L1 caller from xDomainMessageSender(); I’ll list those under Residual risks.

I haven’t measured the window in practice. op-node’s default sequencer.l1-confs is 4; beyond that the lag behind the L1 head is the sequencer’s choice, though a block with transactions can’t run more than max_sequencer_drift ahead of its origin’s timestamp.

I’ll add your sequence to the OP discussion as a regression test (queue a token-transfer deposit, migrate L1, migrate L2 while the origin is behind, advance derivation) and credit you. On a chain without the rollup-side check, the same sequence tests the wallet rule: “retired” must not appear until the queued deposit has run. My PoC (GitHub - nezu511/setcodefrom-adoption-poc · GitHub) runs on EELS, which has no derivation, so running it needs an OP Stack devnet.

1 Like