Parameterize gas() by an ExternalGas environment oracle - #41
Merged
Conversation
`gas()` was interpreted as an unconstrained nondeterministic read: in the open-world dialects `builtinWithExternal .gas []` admitted *every* word. That is the right may-semantics, but it makes `gas()` unrealizable by any concrete machine — a client proving forward simulation into a target EVM has to produce the word the source derivation already picked, and the target's `GAS` instruction produces its own. The result was that `gas()` could not enter a verified compiler's supported fragment at all. Make the oracle a parameter, on the same footing as `ExternalCalls` and `ExternalCreates` and for the same reason: what the surrounding environment reports is not determined by the state this semantics tracks. - new `ExternalGas` structure with `any` (the previous behavior), `none` (stuck, matching `ExternalCalls.none`), and `ofFun`; - `builtinWithExternal` and `evmWithExternal` take it explicitly; - `builtin` and `evmWithCalls` install `ExternalGas.any`, so every existing client keeps exactly its current meaning. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This was referenced Jul 30, 2026
Member
|
Looks good, should we merge this? Any reason not to? |
leonardoalt
marked this pull request as ready for review
August 6, 2026 10:05
Member
Author
Done :) |
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.
Why
gas()was interpreted as an unconstrained nondeterministic read: in the open-world dialects,builtinWithExternal .gas []admitted every word (∃ g, result = .ok [g] st).That is a sound may-semantics, but it makes
gas()unrealizable by any concrete machine. Aclient proving a forward simulation into a target EVM is handed a source derivation that has
already picked some
g, and must produce a target run yielding that sameg; the target'sGASinstruction produces its own remaining gas. So the two can never be made to agree, and
gas()cannot enter a verified compiler's supported fragment at all — which is exactly the blocker in
powdr-labs/yul-compiler(real Solidity output is full ofcall(gas(), …)).What
Make the oracle a parameter, on the same footing as
ExternalCallsandExternalCreates, andfor the same reason: what the surrounding environment reports is not determined by the state this
semantics tracks.
ExternalGasstructure (Gas : EvmState → U256 → Prop) withExternalGas.any— every word; the previous behavior,ExternalGas.none— stuck, matchingExternalCalls.none/ExternalCreates.none,ExternalGas.ofFun— the deterministic oracle reportingf st;builtinWithExternalandevmWithExternaltake it explicitly;builtinandevmWithCallsinstallExternalGas.any.Compatibility
Every existing client keeps exactly its current meaning: the two compatibility wrappers pin
ExternalGas.any, andevmWithExternal's new argument is the only source-level change callers see.stepOp .gas = noneis unchanged, so the closed-world executable dialectevmand its determinism /interpreter / adequacy results are untouched.
New guards in
Dialect/EVM.leanpin both directions: a general oracle only admits the words itpermits, and
ExternalGas.nonemakesgas()stuck.lake buildis clean.🤖 Generated with Claude Code