Skip to content

refactor!: replace per-fork enums with static OpCode(u8) table#4

Merged
g4titanx merged 4 commits into
masterfrom
refactor/opcode-overhaul
Mar 17, 2026
Merged

refactor!: replace per-fork enums with static OpCode(u8) table#4
g4titanx merged 4 commits into
masterfrom
refactor/opcode-overhaul

Conversation

@g4titanx
Copy link
Copy Markdown
Owner

@g4titanx g4titanx commented Mar 17, 2026

Summary

  • Replace 9 fork files (~12K LOC) with a single static [Option<OpCodeInfo>; 256] lookup table — O(1) opcode lookups, zero heap allocation
  • Remove OpcodeRegistry HashMap, traits.rs, unified.rs, generate_forks.py
  • Simplify Fork enum to EVM-relevant forks only (drop consensus-only forks)
  • Centralize gas repricing (EIP-150, EIP-1884, EIP-2929) in gas_cost_for_fork()
  • Add Fusaka fork with EOF opcodes (EIP-7692) and CLZ (EIP-7939)
  • Add Prague fork
  • Consolidate duplicate type definitions, simplify gas analysis/validation/tests/examples

- Replace 9 fork files (~12K LOC) with a single static [Option<OpCodeInfo>; 256]
  lookup table for O(1) opcode lookups with zero heap allocation
- Remove OpcodeRegistry HashMap, traits.rs, unified.rs, generate_forks.py
- Simplify Fork enum to EVM-relevant forks only (drop consensus-only forks)
- Centralize gas repricing (EIP-150, EIP-1884, EIP-2929) in gas_cost_for_fork()
- Add Fusaka fork with EOF opcodes (EIP-7692) and CLZ (EIP-7939)
- Add Prague fork
- Consolidate duplicate ChangeType definitions
- Simplify gas analysis, validation, tests, and examples

BREAKING CHANGE: public API replaced — OpCode is now a struct, not a trait
thin pattern-matchable wrapper over OpCode(u8) with PUSH(n), DUP(n),
SWAP(n), and UNKNOWN(u8) variants for downstream crates that need
match ergonomics (bytecode transforms, disassemblers).

zero-cost conversion to/from OpCode via From impls.
@g4titanx g4titanx merged commit be04da1 into master Mar 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant