Skip to content

fix(tests): correct mip4 transition test for subsequent forks#30

Open
pdobacz wants to merge 1 commit into
forks/monad_ninefrom
fix-mip4-transition-test
Open

fix(tests): correct mip4 transition test for subsequent forks#30
pdobacz wants to merge 1 commit into
forks/monad_ninefrom
fix-mip4-transition-test

Conversation

@pdobacz

@pdobacz pdobacz commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Derive pre-transition precompile availability from transitions_from() so MONAD_NINEToMONAD_NEXT passes.

Greptile Summary

This PR fixes the test_fork_transition test so it also passes for subsequent-fork parametrisations (e.g. MONAD_NINEToMONAD_NEXT). The fix introduces a precompile_before flag derived from fork.transitions_from().precompiles() and uses it to set the correct pre-transition expected storage value instead of the previously hard-coded 0.

  • Adds precompile_before computation using fork.transitions_from().precompiles() — correct for both the initial MONAD_NINE transition (returns False) and subsequent-fork transitions where the precompile already exists (returns True).
  • Updates the expected callee_address storage at slot 14_999 from the hard-coded 0 to 1 if precompile_before else 0, and cleans up a now-stale inline comment at the same line.

Confidence Score: 5/5

Safe to merge — targeted fix to a single test file with no impact on production code.

The precompile_before derivation via fork.transitions_from().precompiles() is consistent with how the framework exposes transition fork metadata, and correctly handles both the initial MONAD_NINE transition and subsequent-fork runs. No logic errors were found.

No files require special attention; the docstring in the single changed file is mildly stale but does not affect correctness.

Important Files Changed

Filename Overview
tests/monad_nine/mip4_checkreservebalance/test_fork_transition.py Adds precompile_before flag derived from fork.transitions_from().precompiles() to correctly parameterise the pre-fork expected storage value; logic is correct for both MONAD_NINE and subsequent-fork transitions. Docstring still only describes the MONAD_NINE scenario.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[test_fork_transition runs] --> B{precompile in transitions_from precompiles?}
    B -- Yes - MONAD_NINEToMONAD_NEXT --> C[precompile_before = True]
    B -- No - First transition to MONAD_NINE --> D[precompile_before = False]
    C --> E[Block 14999 - callee slot = 1]
    D --> F[Block 14999 - callee slot = 0]
    E --> G[Block 15000 fork transition - callee slot = 1]
    F --> G
    G --> H[Block 15001 - callee slot = 1]
    H --> I[Assert post state]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[test_fork_transition runs] --> B{precompile in transitions_from precompiles?}
    B -- Yes - MONAD_NINEToMONAD_NEXT --> C[precompile_before = True]
    B -- No - First transition to MONAD_NINE --> D[precompile_before = False]
    C --> E[Block 14999 - callee slot = 1]
    D --> F[Block 14999 - callee slot = 0]
    E --> G[Block 15000 fork transition - callee slot = 1]
    F --> G
    G --> H[Block 15001 - callee slot = 1]
    H --> I[Assert post state]
Loading

Comments Outside Diff (2)

  1. tests/monad_nine/mip4_checkreservebalance/test_fork_transition.py, line 32-37 (link)

    P2 Docstring no longer accurate for subsequent_forks=True

    The docstring still reads "Before the fork, the precompile doesn't exist, so CALL returns empty output". When this test runs for a subsequent transition (e.g. MONAD_NINEToMONAD_NEXT), precompile_before is True and the precompile is already live before the tested fork, so the "before" block gets a 32-byte return, not empty output. The docstring should describe both variants (or at least note the conditional behaviour introduced by subsequent_forks=True).

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: tests/monad_nine/mip4_checkreservebalance/test_fork_transition.py
    Line: 32-37
    
    Comment:
    **Docstring no longer accurate for `subsequent_forks=True`**
    
    The docstring still reads "Before the fork, the precompile doesn't exist, so CALL returns empty output". When this test runs for a subsequent transition (e.g. `MONAD_NINEToMONAD_NEXT`), `precompile_before` is `True` and the precompile is already live before the tested fork, so the "before" block gets a 32-byte return, not empty output. The docstring should describe both variants (or at least note the conditional behaviour introduced by `subsequent_forks=True`).
    
    How can I resolve this? If you propose a fix, please make it concise.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

    Fix in Claude Code

  2. tests/monad_nine/mip4_checkreservebalance/test_fork_transition.py, line 110 (link)

    P2 Stale inline comment for the precompile_before=True case

    When precompile_before is True (e.g. MONAD_NINEToMONAD_NEXT), the outer CALL to callee_address still succeeds (result 1), but the precompile is not "returning empty" — it returns 32 bytes. The comment is misleading for the subsequent-fork scenario.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: tests/monad_nine/mip4_checkreservebalance/test_fork_transition.py
    Line: 110
    
    Comment:
    **Stale inline comment for the `precompile_before=True` case**
    
    When `precompile_before` is `True` (e.g. `MONAD_NINEToMONAD_NEXT`), the outer CALL to `callee_address` still succeeds (result `1`), but the precompile is not "returning empty" — it returns 32 bytes. The comment is misleading for the subsequent-fork scenario.
    
    
    
    How can I resolve this? If you propose a fix, please make it concise.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

    Fix in Claude Code

Reviews (2): Last reviewed commit: "fix(tests): correct mip4 transition test..." | Re-trigger Greptile

@pdobacz pdobacz requested review from QEDK and mijovic as code owners June 29, 2026 08:47
Derive pre-transition precompile availability from transitions_from()
so MONAD_NINEToMONAD_NEXT passes.

Co-Authored-By: Claude <claude-opus-4-8>
@pdobacz pdobacz force-pushed the fix-mip4-transition-test branch from 3bd80c2 to 4d6f537 Compare June 29, 2026 09:10
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.

1 participant