Skip to content

Conversation

@subwaycookiecrunch
Copy link
Contributor

Description

Fixes #12397

This PR addresses the issue of unbounded memory usage during long-running invariant tests. Previously, the InvariantExecutor retained the full calldata for every successful fuzz case. In testing sessions with millions of runs (e.g., overnight fuzzing), this caused memory usage to grow indefinitely, eventually leading to OOM crashes.

Changes

  • crates/evm/fuzz: Added prune_calldata() methods to FuzzCase and FuzzedCases to allow clearing the stored calldata while preserving metrics (gas, stipend).
  • crates/evm/evm: Updated InvariantExecutor to enforce a rolling window of stored calldata. It now keeps full traces only for the last 4,096 runs (for debugging purposes) and prunes the calldata from all older runs.

Verification

  • Verified manually with a reproduction case where memory usage remains stable.
  • Added extensive logic to ensure that while calldata is pruned, the total count of runs and other metrics remain accurate for reporting.

Copy link
Member

Choose a reason for hiding this comment

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

why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right , this file isn't required for the invariant memory fix.
Its presence here isn't intentional for this change, and I’ll remove it
from this PR so the scope stays minimal.

@subwaycookiecrunch subwaycookiecrunch force-pushed the fix/invariant-memory-usage branch from 278ae4d to 68b258a Compare December 21, 2025 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

bug(invariant): unbounded memory usage in long invariant testing runs

2 participants