Skip to content

test(rollback): fork-mode regression tests for precompile-storage checkpoint integration (BOP-214) - #100

Merged
amiecorso merged 1 commit into
mainfrom
amiecorso/bop-214-base-std-fork-mode-regression-tests-for-precompile-storage
May 29, 2026
Merged

amiecorso merged 1 commit into
mainfrom
amiecorso/bop-214-base-std-fork-mode-regression-tests-for-precompile-storage

Conversation

@amiecorso

Copy link
Copy Markdown
Collaborator

What

Adds three fork-mode regression tests verifying that mid-execution reverts in multi-write batch operations leave no orphan state.

File Operation Mid-batch revert trigger
test/unit/B20Security/batch/batchMint_rollback.t.sol batchMint Element 1 pushes totalSupply past supplyCap
test/unit/B20Security/batch/batchBurn_rollback.t.sol batchBurn Element 1's account has insufficient balance
test/unit/PolicyRegistry/createPolicyWithAccounts_rollback.t.sol createPolicyWithAccounts Batch length > MAX_BATCH_SIZE

Each test snapshots the relevant state (balances + totalSupply, or slot-level nextCounter + policy slot), triggers the revert, and asserts the post-revert state is byte-identical to pre-revert.

Why

Closes BOP-214. Companion to BOP-176 (Rust-side unit tests of the precompile-storage checkpoint mechanism in isolation).

Mock mode (revm-journaled storage) gives rollback for free — passing tests there mostly just confirms setup is correct and revm works. The signal is in fork mode, where the same tests exercise the real Rust precompile and verify that precompile-storage's JournaledState integration correctly rolls back partial writes on revert. A broken integration (writes that aren't journaled, checkpoints released early, future refactor that drops the hookup) would leave earlier writes persisted across the revert — this suite would catch it.

The createPolicyWithAccounts test is robust to either impl order:

  • Solidity mock advances nextCounter + writes the policy slot before the batch check (BOP-207 tracks the reorder), relying on revm's journal to roll back.
  • Rust precompile validates batch size first; no writes attempted.

Both reach the same end state (counter unchanged, predicted slot still zero); the test passes in both modes for different reasons today.

Verification

Mock mode:

forge test --match-contract 'Rollback' -vv
# 3 passed, 0 failed (256 fuzz runs each)

Fork mode (against live Rust precompile via patched anvil):

./script/run-fork-tests.sh --match-contract 'Rollback' -vv
# 3 passed, 0 failed (10 fuzz runs each)

Out of scope

Exhaustive coverage of every multi-write entrypoint — only enough to catch precompile-storage integration regressions. Comprehensive unit-level rollback coverage stays in BOP-176.

…ckpoint integration (BOP-214)

Add three fork-mode regression tests verifying that mid-execution
reverts in multi-write batch operations leave no orphan state.

Tests:
- batchMint with supply-cap-exceeded on element 1: element 0's
  balance + totalSupply writes are rolled back.
- batchBurn with insufficient-balance on element 1: element 0's
  debit is rolled back.
- createPolicyWithAccounts with oversized batch: nextCounter +
  predicted policy slot unchanged, predicted ID not reachable.

Mock mode (revm-journaled storage) provides the rollback for free
and confirms test setup. The actual signal is fork mode against
the real Rust precompile, where any break in precompile-storage's
JournaledState hookup would leave the earlier writes persisted.

Companion to BOP-176 (Rust-side unit tests of the same crate in
isolation).

All three pass in mock mode (256 fuzz runs) and fork mode (10 fuzz
runs against anvil + live Rust precompile).
@linear

linear Bot commented May 29, 2026

Copy link
Copy Markdown

BOP-214

@amiecorso
amiecorso merged commit 46324c6 into main May 29, 2026
7 of 8 checks passed
@amiecorso
amiecorso deleted the amiecorso/bop-214-base-std-fork-mode-regression-tests-for-precompile-storage branch May 29, 2026 18:42
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