Rex2

Rex2 network upgrade — SELFDESTRUCT restored with EIP-6780, KeylessDeploy system contract added.

This page is an informative summary of the Rex2 specification. For the full normative definition, see the Rex2 spec in the mega-evm repository.

Summary

Rex2 makes two changes. First, it restores the SELFDESTRUCT opcode with post-Cancun (EIP-6780arrow-up-right) semantics — MiniRex had completely disabled it. Second, it introduces the KeylessDeploy system contract, which enables deterministic cross-chain contract deployment via Nick's Method with a gas limit override to account for MegaETH's different gas pricing.

What Changed

SELFDESTRUCT Re-Enabled (EIP-6780)

Previous behavior

  • SELFDESTRUCT halts execution with InvalidFEOpcode.

New behavior

  • SELFDESTRUCT is a valid opcode.

  • If the contract was created in the same transaction, SELFDESTRUCT removes the contract's code and storage and transfers the remaining balance to the target address.

  • If the contract was not created in the same transaction, SELFDESTRUCT only transfers the remaining balance to the target address — code and storage are preserved.

This is the standard EIP-6780 behavior already used across Ethereum post-Cancun.

Oracle Bytecode Update

Previous behavior

  • Oracle bytecode version 1.0.0 (code hash 0xe9b044afb735a0f569faeb248088b4f267578f60722f87d06ec3867b250a2c34).

  • No sendHint function.

New behavior

  • Oracle bytecode version 1.1.0 (code hash 0x06df675a69e53ea2a3c948521e330b3801740fede324a1cef2044418f8e09242).

  • Adds the sendHint(bytes32,bytes) function to the deployed bytecode.

  • Introduces call interception for sendHint hint forwarding.

KeylessDeploy System Contract

Previous behavior

  • No system-level support for keyless deployment with gas limit overrides.

  • Contracts that deploy via keyless transactions on Ethereum may run out of gas on MegaETH due to different gas pricing.

New behavior

  • A system contract at 0x6342000000000000000000000000000000000003 provides keyless deployment.

  • The contract intercepts calls at depth 0 only (direct transaction calls).

  • keylessDeploymentTransaction is the RLP-encoded pre-EIP-155 transaction.

  • gasLimitOverride replaces the gas limit in the original transaction.

  • The sandbox charges a fixed overhead of 100,000 gas (deducted from the caller's total gas, tracked as compute gas from Rex3 onward) for RLP decoding, signature recovery, and state filtering.

  • Calls from other contracts (depth > 0) are not intercepted and fall through to on-chain bytecode, reverting with NotIntercepted().

  • Value-bearing calls are rejected.

  • Unknown selectors are not intercepted and fall through to on-chain bytecode.

Developer Impact

SELFDESTRUCT is available again. If your contracts previously needed workarounds for the disabled opcode, you can now use SELFDESTRUCT with EIP-6780 semantics. Note that only contracts created in the same transaction can be fully destroyed — pre-existing contracts will only have their balance transferred.

You can deploy contracts via Nick's Method on MegaETH. Use the KeylessDeploy system contract to execute pre-signed keyless deployment transactions with an adjusted gas limit. The gasLimitOverride parameter lets you account for MegaETH's different gas costs without changing the signed transaction (which would change the deployment address).

KeylessDeploy only works at depth 0. You cannot call KeylessDeploy from within another contract — it must be the direct transaction target. This prevents wrap-and-revert attacks.

Safety and Compatibility

All pre-Rex2 behavior is unchanged.

The SELFDESTRUCT restoration uses the same EIP-6780arrow-up-right semantics already implemented in the underlying revm. The "same transaction" check means only contracts created via CREATE or CREATE2 within the currently executing transaction are eligible for full destruction.

KeylessDeploy sandbox state is merged into main execution on both success and execution failure. On execution failure the sandbox itself has already reverted most state changes, so the merged state contains only the signer's nonce increment and balance deduction — not the failed deployment artifacts. Validation failures do not reach sandbox execution and therefore do not merge any state.

References

Last updated