Skip to content

Fix Foundry blockhash handling and clear compiler cache in CI#3862

Open
MontrealAI wants to merge 1 commit into
mainfrom
codex/fix-foundry-fuzz-test-failures
Open

Fix Foundry blockhash handling and clear compiler cache in CI#3862
MontrealAI wants to merge 1 commit into
mainfrom
codex/fix-foundry-fuzz-test-failures

Conversation

@MontrealAI
Copy link
Copy Markdown
Owner

Motivation

  • Foundry fuzz tests were failing because vm.setBlockhash was being called for blocks in the future, producing "block number must be less than or equal to the current block number" errors.
  • CI surfaced warnings from unsupported forge_version keys in foundry.toml that should not be declared in profiles.
  • A foundry_compilers::cache deserialization error suggested a stale/corrupted incremental compiler cache file was being restored in CI.
  • Test invocation snippets referenced non-portable paths (e.g., /root/.foundry/bin) that break in different runner/home environments.

Description

  • Added _rollPastAndSetBlockhash(uint256, bytes32) helper to test/v2/ValidatorStakeLock.t.sol and replaced the direct vm.setBlockhash call so the test always rolls past the target block before setting the blockhash.
  • Removed forge_version entries from foundry.toml to eliminate the Foundry profile warnings.
  • Added rm -f cache/solidity-files-cache.json || true steps to the Foundry CI jobs (.github/workflows/ci.yml, contracts.yml, and fuzz.yml) so stale compiler cache files are removed before running forge test.
  • Kept the prior CI refactor intact and avoided changing unrelated test runners or Python/torch defaults.

Testing

  • No automated tests were executed within this workspace as part of the change; CI will run the existing Foundry jobs to verify behavior.
  • Recommended local verification commands are forge test --match-path test/v2/ValidatorStakeLock.t.sol -vvvv and forge test -vvvv --ffi --fuzz-runs 256 --match-contract 'CommitReveal|Stake|Fee|Slashing'.
  • The three previously failing tests (testSlashingSucceedsWithShortUnbondingPeriod, testValidatorCannotFinalizeWithdrawalWhileAssigned, and testValidatorWithdrawStakeRevertsDuringActiveJob) are expected to pass when running the above Foundry commands.
  • After these changes CI Foundry jobs should be quieter and avoid the foundry_compilers::cache deserialization noise once workflows run on the branch.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant