EIP-8298: SETCODEFROM Code Reuse Instruction

Thanks — that distinction is helpful. EIP-8058 appears more directly aimed at reducing duplicate code storage and deployment costs, and compatible factories could potentially benefit for future deployments. That benefit should be distinguished from retrofitting existing deployed instances; whether that is possible depends on the proposal’s specified mechanism.

I would not frame EIP-8298 as a replacement for EIP-8058. Its code-adoption primitive also targets code reuse, while its separate migration use case is to let an account adopt wallet code so EIP-3607 prevents transactions originating directly from that account. That is a migration path, not general-purpose upgradeability.

The useful comparison, then, is about scope and compatibility: which deployment patterns each proposal supports, what changes are needed in factories or account initialization, and whether existing instances can benefit. If their mechanisms are compatible, they may be complementary rather than mutually exclusive.

1 Like

I’ve posted a pre-ERC on the code an EOA adopts via SETCODEFROM: an adoption profile, a migration guard, and a reference kernel. Pre-ERC: Adoption Profile and Reference Kernel for EOAs Adopting Code via SETCODEFROM

Several of its failure modes read as general guidance for this EIP, so the thread includes draft text for its Security Considerations (first reply); I’m happy to open a PR. One small related fix: the Security Considerations still says an EIP-8151 rejection returns 32 zero bytes, but since ethereum/EIPs#12540 it returns empty output. One question affects the design: does the public-mempool scan apply to the sender’s own code when it runs as the frame target? (Q2 in the post.)

The fact that EXTCODEHASH(adopting account) can return a code hash different from that of the code currently executing seems problematic.

Deployed contracts that check EXTCODEHASH(CALLER) to authorize an operation can be fooled if a malicious CALLER executes SETCODEFROM(<authorized source>) just before calling into the victim.

More broadly, the current EIP-8298 draft breaks an EVM invariant: whenever EXTCODEHASH(X) returns H, every frame running code loaded from X is running H.

An alternative that fixes this is to make a SETCODEFROM adoption take effect only when the outermost frame executing in the adopting account exits. This preserves the invariant and is in line with CREATE/CREATE2, creation transactions and pre-6780 SELFDESTRUCT behavior.