refactor!: replace per-fork enums with static OpCode(u8) table#4
Merged
Conversation
- 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
static [Option<OpCodeInfo>; 256]lookup table — O(1) opcode lookups, zero heap allocationOpcodeRegistryHashMap,traits.rs,unified.rs,generate_forks.pyForkenum to EVM-relevant forks only (drop consensus-only forks)gas_cost_for_fork()