docs.rs failed to build mega-evm-1.6.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
mega-evm
A specialized Ethereum Virtual Machine (EVM) implementation tailored for MegaETH, built on top of revm and op-revm.
EVM Version
- Base EVM: revm v27.1.0 (v83)
- Optimism EVM: op-revm v8.1.0 (v83)
- Alloy EVM: alloy-evm v0.15.0
Terminology: Spec vs Hardfork
This codebase distinguishes between two related concepts:
- Spec (
MegaSpecId): Defines EVM behavior - what the EVM does. Values:EQUIVALENCE,MINI_REX,REX,REX1,REX2,REX3,REX4 - Hardfork (
MegaHardfork): Defines network upgrade events - when specs are activated. Values:MiniRex,MiniRex1,MiniRex2,Rex,Rex1,Rex2,Rex3,Rex4
Multiple hardforks can map to the same spec.
For example, both MiniRex and MiniRex2 hardforks use the MINI_REX spec.
Key Features
EQUIVALENCE Spec
- Optimism Compatibility: Maintains full compatibility with Optimism Isthmus EVM
- Parallel Execution Support: Block environment access tracking for conflict detection
MINI_REX Spec
- Multidimensional Gas Model: Independent tracking for compute gas (1B), data size (3.125 MB), and KV updates (125K)
- Compute Gas Tracking: Separate limit for computational work with gas detention for volatile data access
- Dynamic Gas Costs: SALT bucket-based scaling preventing state bloat
- Split LOG Costs: Compute gas (standard) + storage gas (10x multiplier) for independent resource pricing
- SELFDESTRUCT Prohibition: Complete disabling for contract integrity
- Large Contract Support: 512 KB contracts (21x increase from 24 KB)
- Gas Detention: Volatile data access (block env, beneficiary, oracle) triggers gas limiting with refunds
- Enhanced Security: Comprehensive limit enforcement preserving remaining gas on limit violations
For complete MiniRex specification, see the MiniRex upgrade page.
REX Spec
- Refined Storage Gas Economics: Optimized storage gas formulas with gradual scaling (20K-32K base costs vs. MiniRex's 2M)
- Transaction Intrinsic Storage Gas: 39,000 storage gas baseline for all transactions (total 60K with compute gas)
- Zero Cost Fresh Storage: Storage operations in minimum-sized SALT buckets charge 0 storage gas
- Separate Contract Creation Cost: Distinct storage gas for contract creation (32K base) vs. account creation (25K base)
- Critical Security Fixes: DELEGATECALL, STATICCALL, and CALLCODE now properly enforce 98/100 gas forwarding and oracle access detection
- MiniRex Foundation: Inherits all MiniRex features including multidimensional gas model, compute gas detention, and enhanced security
For complete Rex specification, see the Rex upgrade page.
REX1 Spec
- Limit Reset Fix: Resets compute gas limits at the start of each transaction
- No Other Behavioral Changes: Inherits Rex semantics fully
For complete Rex1 specification, see the Rex1 upgrade page.
REX2 Spec
- SELFDESTRUCT Restored: Re-enabled with EIP-6780 semantics
- KeylessDeploy System Contract: Enables keyless deployment (Nick's Method) with custom gas limits
- Rex1 Baseline: Inherits Rex1 behavior for all other features
For complete Rex2 specification, see the Rex2 upgrade page.
REX3 Spec
- Increased Oracle Access Gas Limit: Oracle access compute gas limit raised from 1M to 20M, allowing more post-oracle computation
- SLOAD-based Oracle Detention: Oracle gas detention triggers on SLOAD from oracle storage instead of CALL to oracle contract
- Keyless Deploy Compute Gas Tracking: Records the 100K keyless deploy overhead as compute gas
- Rex2 Baseline: Inherits all Rex2 behavior
For complete Rex3 specification, see the Rex3 upgrade page.
REX4 Spec
- Per-Call-Frame Resource Budgets: All four resource dimensions (compute gas, data size, KV updates, state growth) are bounded per call frame with 98/100 forwarding
- Relative Gas Detention: Effective detained limit is
current_usage + capinstead of an absolute cap - Storage Gas Stipend: Value-transferring CALL/CALLCODE receives an additional 23,000 gas for storage gas operations
- MegaAccessControl System Contract: Allows contracts to proactively disable volatile data access for a call subtree
- MegaLimitControl System Contract: Allows querying effective remaining compute gas under detention and call frame limits
- Rex3 Baseline: Inherits all Rex3 behavior
For complete Rex4 specification, see the Rex4 upgrade page.
Quick Start
use ;
use ;
// Create EVM instance with MINI_REX spec
let mut db = default;
let spec = MINI_REX;
let mut context = new;
let mut evm = new;
// Execute transaction
let tx = Transaction ;
let result = transact_raw?;