You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Deposits from addresses that hold code on L2 after EIP-8298 (SETCODEFROM)
#980
EIP-8298 (SETCODEFROM, a Draft: https://eips.ethereum.org/EIPS/eip-8298) would let an EOA adopt account code at its own address, for example to retire its ECDSA key and move to post-quantum keys. On the OP Stack, deposits skip the L2 sender-code check, so the old L1 key could still act as an account that has already adopted code on L2.
As far as I can tell nothing is exploitable today: I found no SETCODEFROM in op-geth, op-revm or the specs, and this is not a report about released code. My question is whether the spec should say that, once 8298 is adopted, a deposit whose from holds regular code fails (mint kept, nothing executed). I'm not an author of EIP-8298 or an OP Stack developer, so corrections are welcome. I came to this while writing an ERC adoption profile for 8298 (thread: https://ethereum-magicians.org/t/30020).
Why deposits bypass the check
EIP-3607 stops an account with regular code from originating transactions, and a companion change such as EIP-8151 makes ecrecover stop returning such addresses. Deposits sidestep the transaction rule while the address is still an EOA on L1:
That's sound today: an address that is an EOA on L1 is controlled by the same key on L2, and EIP-7702 keeps it that way. EIP-8298 doesn't. If an account has adopted code on L2 but is still an EOA on L1, its L1 key can send a deposit with from set to the account and run any call as it on L2: move its tokens, move ETH it holds on L2 through value, or call its own code with msg.sender == address(this), which many wallets treat as authorized. So migrating on L2 does not stop an attacker who still holds the old key until the account also migrates on L1, which is a real cost for users who only use L2.
Ordering matters too. A deposit is derived from the receipts of its L1 origin and runs in the first L2 block of that epoch, ahead of the sequenced transactions ([derivation spec](
While EIP-8298 is active on L2, process a deposit whose from holds regular code (code that is neither empty nor an EIP-7702 delegation, the test regular transactions already get) as a failed deposit. The spec already says deposits are always included and "The mint persists even if execution fails" ([deposits.md L58](
- The `nonce` of `from` in the world state is incremented by 1, making the error equivalent to a native EVM failure.
)). So the old key could still credit the account with ETH and bump its L2 nonce, but could not call, create or transfer. This also removes the ordering dependence above for deposits whose from is the account: one that executes after the L2 migration fails. As far as I can tell, the change would go in op-revm, which both op-reth and the fault proof program (kona-client, through kona-executor) use, plus op-geth for chains still on it.
A regression test, from Revinand ([post 18](https://ethereum-magicians.org/t/30020/18)): queue a token-transfer deposit from the account, migrate it on L1, migrate it on L2 while its L1 origin is still behind the deposit's L1 block, then advance derivation. With the check, the deposit fails and keeps its mint. My PoC (https://github.com/nezu511/setcodefrom-adoption-poc) runs on the Python execution specs, which have no derivation, so it can't exercise this; it needs an OP Stack devnet.
Other rollups
Arbitrum and Scroll don't appear to have this gap: Arbitrum aliases the sender of every L1-originated message kind, and its one un-aliased path (*ToFork) keeps the sender-code check; Scroll keeps the check for L1 messages. Zealynx raised both ([post 17](https://ethereum-magicians.org/t/30020/17)); my reading of the sources, at the default-branch heads of 2026-10-25 and not the deployed versions, is in [post 19](https://ethereum-magicians.org/t/30020/19). I haven't checked forced inclusion on zk rollups, or what Scroll does with an L1 message that fails the check.
Not covered
Messages relayed through the CrossDomainMessenger arrive as deposits whose from is the aliased L1 messenger, so a check on from doesn't see them. They can't spend the account's own L2 balance (msg.sender at the target is the L2 messenger); the exposure is L2 contracts that grant authority to xDomainMessageSender() == account, which can include the account's own code. I'm listing that as a residual risk in the ERC draft.
Alternatives considered
Aliasing such senders: once the account also migrates on L1, its own deposits are aliased to that same address, so mapping old-key deposits there would let the old key pose as the migrated account.
Checking on L1: the portal can't see L2 state.
Wallet-side ordering only (migrate on L1 first, then wait until the L2 origin passes the L1 migration block): this closes the ordering window, but not the case of an account that is still an EOA on L1.
Leaving it to the account's code: a deposit-driven token transfer never runs that code.
Side effect: once the account has adopted code on L2, its L1 address can no longer act as it on L2 through deposits; the account acts on L2 with its own authorities. Deposits from L1 contracts aren't affected: their from is the alias address, which has no known key and no feasible deployer, so it holds no code on L2.
Questions
I think the check has to be in execution, since derivation avoids reading L2 state (e.g. [deposits.md L134-L135](
We do not use the sender's nonce to ensure uniqueness because this would require an extra L2 EVM state read from the
[execution engine][g-exec-engine] during block-derivation.
)). Is that right?
Does anything rely on deposits executing with a from that holds code? In the specs I looked at the L1 attributes depositor and the network-upgrade transaction senders, and none is meant to hold code; I haven't checked chain state.
Under [EIP-8141](https://eips.ethereum.org/EIPS/eip-8141) (a Draft) on L1, ORIGIN in a SENDER frame is the frame's caller, i.e. tx.sender. A code-holding account calling the portal directly would then have msg.sender == tx.origin, so EOA.isSenderEOA() would be true and its deposit wouldn't be aliased. Is that intended, and would the proposed check then fail that account's own deposits on L2?
Is it acceptable to leave messenger-relayed calls out of scope, with L2 contracts that authenticate an L1 address handling migration themselves?
If there's a better place to track this before any fork scoping, I'm happy to move it. Thanks for taking a look.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
EIP-8298 (
SETCODEFROM, a Draft: https://eips.ethereum.org/EIPS/eip-8298) would let an EOA adopt account code at its own address, for example to retire its ECDSA key and move to post-quantum keys. On the OP Stack, deposits skip the L2 sender-code check, so the old L1 key could still act as an account that has already adopted code on L2.As far as I can tell nothing is exploitable today: I found no
SETCODEFROMin op-geth, op-revm or the specs, and this is not a report about released code. My question is whether the spec should say that, once 8298 is adopted, a deposit whosefromholds regular code fails (mint kept, nothing executed). I'm not an author of EIP-8298 or an OP Stack developer, so corrections are welcome. I came to this while writing an ERC adoption profile for 8298 (thread: https://ethereum-magicians.org/t/30020).Why deposits bypass the check
EIP-3607 stops an account with regular code from originating transactions, and a companion change such as EIP-8151 makes
ecrecoverstop returning such addresses. Deposits sidestep the transaction rule while the address is still an EOA on L1:depositTransactiondoesn't alias the sender whenmsg.sender == tx.originor the sender is a 7702-delegated EOA ([OptimismPortal2.sol L835-L839](https://github.com/ethereum-optimism/optimism/blob/b84018de4fc5ea47f13b6ebdf7a2f793d8334ea8/packages/contracts-bedrock/src/L1/OptimismPortal2.sol#L835-L839), [EOA.sol](https://github.com/ethereum-optimism/optimism/blob/b84018de4fc5ea47f13b6ebdf7a2f793d8334ea8/packages/contracts-bedrock/src/libraries/EOA.sol#L9-L23); the 7702 case comes from [PR #14506](feat: do not alias 7702 addresses optimism#14506)). That is the source at those commits; I haven't checked deployed versions.specs/specs/protocol/deposits.md
Lines 174 to 175 in 21d1ff5
fromis an Externally Owner Account [sic] (EOA): the deposit is ensured not to be an EOA through L1 address masking, this may change in future L1 contract-deployments to e.g. enable an account-abstraction like mechanism". In op-revm, the deposit branch of[validate_against_state_and_deduct_caller](https://github.com/ethereum-optimism/optimism/blob/527e5c4bf40e5399d7f06027b7d99dd07166f7d5/rust/op-revm/src/handler.rs#L130-L160)returns before the account-code validation that regular transactions get at [L172](https://github.com/ethereum-optimism/optimism/blob/527e5c4bf40e5399d7f06027b7d99dd07166f7d5/rust/op-revm/src/handler.rs#L172). op-geth does the same ([deposit skip](https://github.com/ethereum-optimism/op-geth/blob/a5f1641275442adb466daef5f1be32bd28392daa/core/state_transition.go#L346-L348), [check for regular transactions](https://github.com/ethereum-optimism/op-geth/blob/a5f1641275442adb466daef5f1be32bd28392daa/core/state_transition.go#L384-L389)); its [support ended on 2026-05-31](https://docs.optimism.io/notices/op-geth-deprecation).That's sound today: an address that is an EOA on L1 is controlled by the same key on L2, and EIP-7702 keeps it that way. EIP-8298 doesn't. If an account has adopted code on L2 but is still an EOA on L1, its L1 key can send a deposit with
fromset to the account and run any call as it on L2: move its tokens, move ETH it holds on L2 throughvalue, or call its own code withmsg.sender == address(this), which many wallets treat as authorized. So migrating on L2 does not stop an attacker who still holds the old key until the account also migrates on L1, which is a real cost for users who only use L2.Ordering matters too. A deposit is derived from the receipts of its L1 origin and runs in the first L2 block of that epoch, ahead of the sequenced transactions ([derivation spec](
specs/specs/protocol/derivation.md
Lines 1012 to 1026 in 21d1ff5
--sequencer.l1-confs, [default 4](https://github.com/ethereum-optimism/optimism/blob/527e5c4bf40e5399d7f06027b7d99dd07166f7d5/op-node/flags/flags.go#L278-L284)), so a deposit queued before the account's L1 migration can still execute after its L2 migration, with its original unaliasedfrom. Revinand raised this ([post 18](https://ethereum-magicians.org/t/30020/18)).Proposal
While EIP-8298 is active on L2, process a deposit whose
fromholds regular code (code that is neither empty nor an EIP-7702 delegation, the test regular transactions already get) as a failed deposit. The spec already says deposits are always included and "The mint persists even if execution fails" ([deposits.md L58](specs/specs/protocol/deposits.md
Line 58 in 21d1ff5
What a failed deposit still does: the mint stays on the sender account (it is not forwarded to
to), and the sender's nonce is incremented ([L196](specs/specs/protocol/deposits.md
Line 196 in 21d1ff5
fromis the account: one that executes after the L2 migration fails. As far as I can tell, the change would go in op-revm, which both op-reth and the fault proof program (kona-client, through kona-executor) use, plus op-geth for chains still on it.A regression test, from Revinand ([post 18](https://ethereum-magicians.org/t/30020/18)): queue a token-transfer deposit from the account, migrate it on L1, migrate it on L2 while its L1 origin is still behind the deposit's L1 block, then advance derivation. With the check, the deposit fails and keeps its mint. My PoC (https://github.com/nezu511/setcodefrom-adoption-poc) runs on the Python execution specs, which have no derivation, so it can't exercise this; it needs an OP Stack devnet.
Other rollups
Arbitrum and Scroll don't appear to have this gap: Arbitrum aliases the sender of every L1-originated message kind, and its one un-aliased path (
*ToFork) keeps the sender-code check; Scroll keeps the check for L1 messages. Zealynx raised both ([post 17](https://ethereum-magicians.org/t/30020/17)); my reading of the sources, at the default-branch heads of 2026-10-25 and not the deployed versions, is in [post 19](https://ethereum-magicians.org/t/30020/19). I haven't checked forced inclusion on zk rollups, or what Scroll does with an L1 message that fails the check.Not covered
Messages relayed through the CrossDomainMessenger arrive as deposits whose
fromis the aliased L1 messenger, so a check onfromdoesn't see them. They can't spend the account's own L2 balance (msg.senderat the target is the L2 messenger); the exposure is L2 contracts that grant authority toxDomainMessageSender() == account, which can include the account's own code. I'm listing that as a residual risk in the ERC draft.Alternatives considered
Side effect: once the account has adopted code on L2, its L1 address can no longer act as it on L2 through deposits; the account acts on L2 with its own authorities. Deposits from L1 contracts aren't affected: their
fromis the alias address, which has no known key and no feasible deployer, so it holds no code on L2.Questions
specs/specs/protocol/deposits.md
Lines 134 to 135 in 21d1ff5
fromthat holds code? In the specs I looked at the L1 attributes depositor and the network-upgrade transaction senders, and none is meant to hold code; I haven't checked chain state.ORIGINin a SENDER frame is the frame's caller, i.e.tx.sender. A code-holding account calling the portal directly would then havemsg.sender == tx.origin, soEOA.isSenderEOA()would be true and its deposit wouldn't be aliased. Is that intended, and would the proposed check then fail that account's own deposits on L2?If there's a better place to track this before any fork scoping, I'm happy to move it. Thanks for taking a look.
All reactions