Repository navigation
Conversation
…nt state Adds `globalThis.DEBUG` assertions that the simulation runs and the production build strips: - revm holds a journal for each accepted mutation that is not finalized, and for nothing else. It caught a leak: `enqueueMutation` never pruned the journal of the `enqueue` it replays, so each ForceInclusionQueued log kept a journal for the life of the process. The enqueue is already onchain, so it is now pruned right away. - the settlement transaction, simulated from the state before its mutations, writes the values that accepting them left in speculative state. `simulate` now reports slot writes so the runtime can compare. `bunfig.toml` defines DEBUG for tests and the simulation, which refuses to run without it. The new `build` script bundles to dist/ with DEBUG=false. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kyscott18
force-pushed
the
debug-assertions
branch
from
October 26, 2026 22:16
0b88913 to
fc26388
Compare
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
Adds internal assertions behind
globalThis.DEBUG. The simulation runs with them on, and the production build strips them out. They check invariants that the simulation's end-of-run validation can't see.simulatesucceeds, every slot the settlement writes must equal the value in speculative state. In other words, whatexecutecallers andstatereaders were shown is what lands onchain.Bug fix found by the journal assertion
enqueueMutationreplays eachForceInclusionQueuedlog in revm. That creates a journal, and the journal was never pruned, so every enqueue leaked a journal (pre- and post-images) for the life of the process. The enqueue is already onchain and a settlement never rewinds it, so the journal is now pruned right away.With the fix removed, seed
0x4f4ff5f9…fails withAssertionError: revm holds journal 137, which belongs to no mutation.Supporting changes
typewriter-evm:simulatenow reportsslot_writes. They are collected inrun_two_passfor every successful pass, not only inexecute. A test covers the new field.packages/typewriter/bunfig.toml:[define] "globalThis.DEBUG" = "true"applies tobun testand the simulation. The simulation exits ifDEBUGisn't on.buildscript:bun buildtodist/with--define globalThis.DEBUG=false --minify-syntax --sourcemap=linked. Eachif (globalThis.DEBUG)block is removed along with its arguments. I checkeddist/index.jsand none of the assertion code is left; only two empty, unusedSet/Mapallocations remain.globalThis.DEBUGis used rather than a bareDEBUG, so code that importssrc/without the define (e.g. apps) readsundefinedand runs with the checks off, rather than throwing aReferenceError.Test plan
bun run typecheck, biome,bun run test(typewriter),bun test --timeout 30000(typewriter-evm)🤖 Generated with Claude Code