MIP-19: Reserve Balance-Compatible SETCODEFROM Opcode

This MIP makes the SETCODEFROM opcode from EIP-8298 work under Monad’s reserve balance rules.

SETCODEFROM follows the EIP-8298 spec, except that a delegated account can adopt regular code only in a transaction it sent or with an active reserve of 0. An account that adopts regular code in a transaction it sent stays under the reserve balance check for the adopting transaction and the rest of a k-block window; in-flight transactions of such an account that execute after the adoption are included, fail, and pay full gas.

Two data points from Monad mainnet that bear on this, from the EIP-7702 measurement we posted in EIP-7702 on Monad mainnet: wallets, not sweepers (every type-4 transaction up to block 117,375,623).

Who can take the self-sent path

The self-sent adoption needs the delegated account to originate a transaction and pay for it. Most delegated accounts on Monad do neither today. Of 362,892 authorisations whose signer we recovered, 5.0 % were sent by the account itself; the rest came through sponsors and relayers. In a sample of 1,000 of the 279,520 accounts delegated now, 9.7 % have sent a transaction of their own since delegating, and 80.6 % hold no MON at all.

So in practice the relayed path through a zero reserve looks like the main one, not the fallback: set the reserve to 0, wait k blocks, then a relayer or bundler migrates. That makes the “Account-configurable reserve balance” MIP a hard dependency for most of the accounts this is meant for, and the two-step flow with a wait is what wallets would have to build. Would it be worth specifying the two together, or describing how a wallet is expected to batch the reserve update with the rest of its setup?

The compromised-key case

The actor in “In-Flight Transactions From a Compromised Key” exists on Monad. On wallets whose private keys are public and which were delegated, 60 of the 126 arrivals from third parties left again within two blocks, inside the k = 3 window. Bots holding such keys already act faster than the window closes. That seems to us an argument for charging only the base fee on the in-flight path, so that no leader is paid for including those transactions.

Limits: the 1,000 accounts are a deterministic sample, and a balance of zero now says nothing about the balance an account will hold when it migrates; a wallet can fund it first. Happy to share the data or rerun it for a specific delegate contract.

1 Like

Thank you for the comments! Re:

and

Noted, this is a useful data point. The migration is also useful to accounts that are not delegated now: a single type-4 transaction they send delegates and adopts the code, which takes the self-sent path. Such accounts don’t show up among the delegated accounts today. I don’t have numbers on this yet.

My working assumption is that wallets build the migration itself the same way as on other EVM chains with EIP-8298. Setting the reserve to 0 is Monad-specific, but wallets will already support it for the configurable reserve balance MIP. Ideally, MIP-19 on its own requires no bespoke wallet handling. I’m not sure batching is necessary. A wallet warning on the migration path on Monad may be enough, saying that the reserve must be 0 if the wallet sees it isn’t.

It seems the data speaks to keys leaked long before migration, which bots sweep before the account can migrate. The section covers a key exposed at the moment of migration, e.g. by a quantum attack on the public key the migration transaction reveals. Once the adoption executes, transactions signed with that key can’t move funds, but for k blocks the key can still burn the account’s balance on fees, and the priority fees go to the leader. That window is small enough that the extra carve-out to charge only the base fee may not be necessary. If there’s a practical exploit I’m missing, the carve-out can be reconsidered.

Thanks, both points taken. On the compromised key you are right: our data is about keys leaked long before migration, which is not the case the section covers.

On accounts that are not delegated today, here is a first number. Over the last 3,000 mainnet blocks (to 117,639,095, about 20 minutes) there were 822 distinct senders: 94.2 % plain EOAs with no code, 5.8 % delegated, none with contract code. Of the plain EOAs, 500 of 774 hold at least 0.1 MON, enough to send the single type-4 transaction that delegates and adopts. So the active accounts mostly can take the self-sent path; the 80 % of delegated accounts without MON are the sponsored ones that never send their own transactions.

A 20-minute window leans towards bots; I can run it over a day or a week if that helps.

This looks exciting!

One question: the Open Questions section notes that this design is incompatible with MCP and Cadence. Is MIP-19 intended to activate before Cadence, or should it be read mainly as a reference for the revised design?

The MIP tries to abstract activations out of its text, there have been no consideration on timelines yet. For simplicity it assumes EIP-8928 is active on other EVMs, configurable reserve balance is active on Monad, while Cadence isn’t yet.

In terms of reading: best to keep both in mind. Treat the MIP as a general feasibility study, a reference for a post-Cadence revised design, but also as a contingency plan in case the timelines end up making SETCODEFROM support favorable to activate pre-Cadence.

1 Like