feat(evm): single-dimension gas repricing primitives (1/3)#213
Draft
davidtaikocha wants to merge 7 commits into
Draft
feat(evm): single-dimension gas repricing primitives (1/3)#213davidtaikocha wants to merge 7 commits into
davidtaikocha wants to merge 7 commits into
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Final-review hardening: opcode_surcharge is a [u64;256] but the builder reprices only the opcodes whose instruction fn it names, so a surcharge on any other index is dropped. Document this on the field and add a test pinning it (SSTORE 0x55) so extending coverage stays a conscious change.
`reprice` is a private build-time setup function called 5 times during instruction-table construction (fork init), not a hot runtime path. The `#[inline]` annotation implies performance-critical inner-loop semantics that don't apply here; the compiler's own inlining heuristics are appropriate for a tiny generic helper. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
What
Foundational, pure additive primitives for a future Taiko fork that folds proving cost into a single repriced gas dimension — the eventual replacement for the current Unzen
raw_gas × multiplierzk-gas meter. This is the first of three PRs:TaikoSpecId, wire these into the factory/handler, and gate thedifficulty/zk-gas path to end at the new fork (proving cost then commits via the standardgasUsed)Scope / safety
pub mod gas_reprice;line.zk_gastest — confirming zero behavior change).The primitives (
crates/evm/src/gas_reprice/)schedule.rs—RepriceSchedule { opcode_surcharge: [u64; 256], tx_intrinsic_surcharge }.opcodes.rs—repriced_instruction_table: an additivestatic_gassurcharge over revm's spec base table (the same mechanism revm itself uses for EIP-150/2929), charged before the opcode body so OOG, theGASopcode, and 63/64 call-forwarding stay self-consistent. No revm fork required.precompiles.rs—apply_precompile_surcharge: an input-scaled gas surcharge viaPrecompilesMap::map_precompile(mutates onlygas_used, forwards everything else).intrinsic.rs—add_tx_intrinsic_surcharge: a per-transaction intrinsic addition (covers ecrecover proving) with the same over-limit check revm raises.Notes for the wiring PR
opcodes.rsduplicate revm's internal table (becauseInstruction::static_gasis private) — re-audit them on every reth/revm pin bump (documented in-code).floor_gas(EIP-7623 calldata floor) is intentionally untouched by the intrinsic surcharge.PrecompileOutput.status, not always asErr— the wiring layer owns gas-limit re-validation.🤖 Generated with Claude Code