Skip to content

MIP-7 EXTENSION decode - #2662

Draft
khordadi wants to merge 1 commit into
mainfrom
khordadi/mip-7-extension
Draft

khordadi wants to merge 1 commit into
mainfrom
khordadi/mip-7-extension

Conversation

@khordadi

@khordadi khordadi commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Implements the MIP-7 EXTENSION (0xAE) decode at MONAD_NEXT. No selector is assigned yet, so every extended opcode still behaves as INVALID. EXE-232

  • 0xAE dispatches on its selector through a second opcode table in the interpreter and the compiler. An unassigned or excluded selector is INVALID and is not consumed, so 0xAE 0x5B keeps its JUMPDEST. A compile-time check keeps 0x5B and PUSHn unassigned.
  • A trailing 0xAE has no selector and halts exceptionally, as MIP-7 now requires (Update MIP-7, MIP-18: trailing 0xae monad-crypto/MIPs#95). That only changes behaviour once a selector is assigned; MIP-18 in MIP-18 (CALLSTACKDEPTH, CALLERN) #2621, stacked on this, covers it.

🤖 Generated with Claude Code

This comment was marked as outdated.

@khordadi
khordadi added this pull request to stack #2663 October 8, 2026 15:50
Comment thread category/vm/interpreter/instruction_table.hpp
Comment thread category/vm/evm/opcodes.hpp

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the MIP-7 EXTENSION (0xAE) decode against the traits system, the compiler/interpreter decode paths, and the stated MIP-7 semantics.

What was checked:

  • Traits: mip_7_active() is correctly added to the Traits concept and to both EvmTraits (always false) and MonadTraits (Rev >= MONAD_NEXT); the opcode table entry is gated with when(...) and the interpreter entry with avail(...), so 0xAE stays invalid everywhere before MONAD_NEXT. No explicit-instantiation macros are involved (header templates only), and the trait instantiation CI check passes.
  • Decode consistency: compiler and interpreter agree for every reachable case — trailing 0xAE halts exceptionally in both (scan_extension bounds check; instr_ptr + 1 < code() + size() in the interpreter, which is correct against the unpadded size), and an unassigned selector is invalid without being consumed, so 0xAE 0x5B keeps its JUMPDEST in both the compiler's block scan and the interpreter's unchanged find_jumpdests. The compile-time guard keeping JUMPDEST/PUSHn selectors unassigned is exactly what keeps the two jumpdest analyses equivalent once selectors are assigned.
  • C++ correctness: the Instruction constructor argument order matches, index()'s assert and the formatter are updated, MONAD_ABORT() in the x86 emitter's Extension case is [[noreturn]] and unreachable while the selector table is empty, and the interpreter dispatch preserves must-tail discipline (MONAD_VM_MUST_TAIL with the table lookup done before the call).
  • Tests: the typed test matrix includes MONAD_NEXT (MIP-7 active) as well as all pre-NEXT revisions, and the three tests cover invalid selectors, jumpdest preservation/consumption, and trailing 0xAE, on both interpreter and compiler.
  • PR hygiene: single commit, no merge commits; CI green on everything completed so far, including the compiler test suite.

Two non-blocking [P3] suggestions posted inline, both about hardening the future selector-assignment path: a consteval cross-check that the compiler and interpreter selector tables agree, and making the JUMPDEST/PUSHn guard asserts robust to assignments inserted after them.

Verdict: CORRECT

🤖 Generated with Claude Code

@Baltoli Baltoli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MIP-7 is pending spec tests, confirmation etc. - will review properly when we have that but let's not merge this just yet

@khordadi
khordadi marked this pull request as draft October 8, 2026 15:58
@khordadi
khordadi requested a balanced review from Copilot October 8, 2026 16:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Static review found no blocking issues in revision gating, selector handling, or jump-destination preservation, with focused tests covering both engines.

0 open findings

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

Decode MIP-7's EXTENSION (0xAE) and its selector byte in the interpreter
and the compiler, active at MONAD_NEXT. No selector is assigned yet, so
every extended opcode still behaves as INVALID.

Unassigned and excluded selectors are not consumed, so JUMPDEST analysis
is unchanged. A trailing 0xAE has no selector and halts exceptionally,
as MIP-7 now requires (monad-crypto/MIPs#95).

https://linear.app/category-labs/issue/EXE-232

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@khordadi
khordadi force-pushed the khordadi/mip-7-extension branch from 6c67846 to e2adc5a Compare October 20, 2026 15:11
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.

3 participants