Skip to content

fix(tests): clamp reserve balance threshold at zero - #43

Merged
QEDK merged 1 commit into
forks/monad_ninefrom
fix/reserve-balance-threshold-clamp
Aug 19, 2026
Merged

fix(tests): clamp reserve balance threshold at zero#43
QEDK merged 1 commit into
forks/monad_ninefrom
fix/reserve-balance-threshold-clamp

Conversation

@pdobacz

@pdobacz pdobacz commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

MERGE after #42.

Add a spec test that a sender whose gas fees exceed the reserve can empty.

Also throw a meaningful assertion error on txs impossible to come from consensus, when gas fees exceed reserve but sender cannot empty.

Both were missed in the original reserve balance implementation (in execution-specs that is), and the implementation would just throw an OverflowError in both cases (U256 underflow to be precise)

Greptile Summary

The PR clamps the sender reserve threshold at zero when gas fees equal or exceed the reserve and adds an assertion for transactions that consensus should not sequence.

  • Applies the reserve-threshold correction consistently across Monad Eight, Nine, Ten, and Next.
  • Adds boundary coverage for gas fees below, above, and around the reserve.

Confidence Score: 5/5

The PR appears safe to merge with no actionable correctness or security issues identified.

The clamp prevents unsigned subtraction underflow for senders allowed to empty their balance, while the assertion preserves the stated consensus restriction for other senders and the new tests cover the relevant fee boundaries.

Important Files Changed

Filename Overview
src/ethereum/forks/monad_eight/vm/interpreter.py Clamps the sender threshold before reserve validation and explicitly rejects consensus-impossible non-exception transactions.
src/ethereum/forks/monad_nine/vm/interpreter.py Carries the corrected reserve-threshold calculation and assertion into Monad Nine.
src/ethereum/forks/monad_ten/vm/interpreter.py Carries the corrected reserve-threshold calculation and assertion into Monad Ten.
src/ethereum/forks/monad_next/vm/interpreter.py Carries the corrected reserve-threshold calculation and assertion into Monad Next.
tests/monad_eight/reserve_balance/test_gas_fees_vs_reserve.py Adds regression coverage spanning gas fees below and above the reserve, including the former unsigned-underflow boundary.

Reviews (1): Last reviewed commit: "fix(spec-specs, tests): clamp reserve ba..." | Re-trigger Greptile

Assert that a sender whose gas fees exceed the reserve can empty.

Co-Authored-By: Claude <claude-opus-5[1m]>
@pdobacz
pdobacz requested review from QEDK and mijovic as code owners August 18, 2026 12:57
Base automatically changed from from-upstream to forks/monad_nine August 19, 2026 11:35

@QEDK QEDK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

@QEDK
QEDK merged commit bc13662 into forks/monad_nine Aug 19, 2026
5 checks passed
@QEDK
QEDK deleted the fix/reserve-balance-threshold-clamp branch August 19, 2026 11:35
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.

2 participants