Skip to content

Reserve balance tests: authorization lists & SELFDESTRUCT#12

Merged
pdobacz merged 3 commits intoforks/monad_ninefrom
new-resbal-test2
Mar 4, 2026
Merged

Reserve balance tests: authorization lists & SELFDESTRUCT#12
pdobacz merged 3 commits intoforks/monad_ninefrom
new-resbal-test2

Conversation

@pdobacz
Copy link
Collaborator

@pdobacz pdobacz commented Mar 3, 2026

Adding two additional tests for the reserve balance I've gathered over the past days.

The first one is simple.

The other one is a bit convoluted, but essential to cover the init-selfdestruct scenarios. In a nutshell, an account is receiving its balance if various combinations of crediting calls and in the end SELFDESTRUCTs. Reserve balance should only be considered when the SELFDESTRUCT is done on behalf of a 7702 delegation.

@pdobacz pdobacz changed the title New resbal test2 Reserve balance tests: authorization lists & SELFDESTRUCT Mar 3, 2026
@greptile-apps
Copy link

greptile-apps bot commented Mar 3, 2026

Greptile Summary

This PR adds two new test cases for Monad's reserve balance feature: test_delegated_eoa_auth_list (reserve balance across various EIP-7702 delegation sequences) and test_contract_unrestricted_with_selfdestruct (reserve balance for SELFDESTRUCT via 7702 delegation).

Key findings:

  • any_delegation logic error (line 414): The condition pre_delegated or len(delegation_targets) > 0 incorrectly marks accounts as delegated when the auth list contains only undelegations or ends with an undelegation. The final delegation state should be determined by the last entry in the auth list, not by the mere presence of entries. This causes incorrect test expectations for cases like undelegate_twice and delegate_undelegate.

  • Incomplete reverted post-state assertions (line 1636): When reverted=True, the post-state only verifies factory_address, leaving selfdestruct_target, delegated_address, and new_contract_address completely unchecked. This reduces the test's ability to detect bugs where balance is incorrectly transferred or accounts are incorrectly modified during a reverting transaction.

Confidence Score: 3/5

  • Tests have logic errors in delegation detection and incomplete reverted-state assertions, reducing spec compliance assurance.
  • The new tests cover important edge cases but contain two verified issues: (1) the any_delegation logic incorrectly marks accounts as delegated when the auth list contains only undelegations or ends with undelegation, causing incorrect test expectations for multiple parameter combinations; (2) the reverted branch of test_contract_unrestricted_with_selfdestruct does not assert several key accounts (selfdestruct_target, delegated_address, new_contract_address), which reduces the test's ability to detect bugs in the revert path. These are not test failures but logic/coverage gaps that weaken confidence in whether the tests fully validate the spec.
  • tests/monad_eight/reserve_balance/test_transfers.py — specifically any_delegation logic around line 414 and reverted post-state assertions starting at line 1636.

Last reviewed commit: 9aac490

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@pdobacz pdobacz requested review from QEDK and mijovic March 3, 2026 12:29
@pdobacz pdobacz force-pushed the new-resbal-test2 branch from f37e985 to e8a02f7 Compare March 4, 2026 07:54
@pdobacz pdobacz merged commit ba3ad7d into forks/monad_nine Mar 4, 2026
4 checks passed
@pdobacz pdobacz deleted the new-resbal-test2 branch March 4, 2026 14:09
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