fix(tests,evm): Reserve bal. & MIP-4 vs initcode execution#19
fix(tests,evm): Reserve bal. & MIP-4 vs initcode execution#19pdobacz merged 1 commit intoforks/monad_ninefrom
Conversation
Greptile SummaryThis PR fixes two related issues in the Monad EVM reserve-balance enforcement: (1) contracts that self-destruct during initcode should be exempted from the end-of-tx reserve-balance check because their balance legitimately drops to zero, and (2) for creation transactions the correct code to test against is Key changes:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant TX as Transaction
participant PM as process_message (depth=0)
participant PM2 as process_message (depth>0 / initcode)
participant Precompile as reserve_balance precompile
participant IRV as is_reserve_balance_violated(evm)
Note over TX,IRV: End-of-tx check (MONAD_EIGHT / MONAD_NINE)
TX->>PM: execute top-level call
PM->>PM2: nested CALL / CREATE (accounts_to_delete propagated up on success)
PM2-->>PM: return (accounts_to_delete merged via incorporate_child_on_success)
PM->>IRV: is_reserve_balance_violated(root_evm)
Note right of IRV: Walk root_evm.accounts_to_delete<br>(single frame, no ancestor traversal needed)
IRV->>IRV: skip addr if in accounts_to_delete
IRV->>IRV: for creation tx: code = evm.output<br>(not yet set via set_code)
IRV->>IRV: is_exception = (origin==addr AND<br>not is_sender_authority AND<br>not is_valid_delegation)
IRV-->>PM: True → rollback / False → commit
Note over TX,IRV: Mid-execution check via dippedIntoReserve() precompile (MONAD_NINE)
PM2->>Precompile: CALL dippedIntoReserve()
Precompile->>IRV: is_reserve_balance_violated(precompile_evm)
Note right of IRV: Traverse ancestors collecting<br>accounts_to_delete from all frames
IRV->>IRV: skip addr if in any ancestor's accounts_to_delete
IRV->>IRV: code = acc.code (not Bytes0 target in mid-exec)
IRV-->>Precompile: 0 or 1 (no revert, just detection)
Precompile-->>PM2: return uint256(0 or 1)
Last reviewed commit: "fix(tests,evm): Rese..." |
dd68caf to
f3092ea
Compare
Co-Authored-By: Claude opus-4-6
f3092ea to
8885d5d
Compare
|
@greptileai re review |
Adjusts tests to category-labs/monad#2037 + other aspects of MIP-4 and reserve balance rules (referenced below).
Expands tests to cover edge cases