Repository navigation
chore(contracts): foundry scaffold with OZ v5.1 and CI pipeline - #634
Conversation
Lays the Foundry project structure under contracts/ for the unified 14-contract surface from #452. No deCDN contract logic ships yet — this is the audit-ready toolchain only. - Foundry project at contracts/, solc 0.8.28, evm cancun - 4 profiles: default (fast local), ci (1024 fuzz / 256-depth invariants), fuzz (10k runs nightly), coverage (optimizer off) - forge-std v1.16.1 + openzeppelin-contracts v5.1.0 as submodules, SHAs pinned in foundry.lock - @openzeppelin/contracts/ and forge-std/ remappings - SanityTest verifies the toolchain wires through correctly; will be deleted once the first real contract from #452 lands - ci.yml extended with a `solidity` paths-filter and a solidity job running fmt --check / build --sizes / test under FOUNDRY_PROFILE=ci, gated by ci-success alls-green like the existing rust/adr jobs Deferred to follow-up PRs (acceptance criteria from #452 that belong with the contracts they apply to): Slither config, forge coverage gate, ABI snapshot tests, forge script deploy template. Refs: #452 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request initializes the Foundry development environment by adding submodules for forge-std and OpenZeppelin contracts, configuring the foundry.toml file, and establishing import remappings. A sanity test is also included to verify the setup. Feedback focuses on improving the .gitignore by excluding the entire broadcast directory to prevent repository bloat and reducing the max_test_rejects value in the fuzzing profile to ensure more efficient test execution.
| /contracts/broadcast/*/[0-9]*/ | ||
| /contracts/broadcast/**/dry-run/ |
There was a problem hiding this comment.
The current patterns for ignoring broadcast artifacts are unnecessarily complex and may still allow some metadata or summary files to be accidentally tracked. It is safer and more standard to ignore the entire broadcast/ directory to prevent repository bloat and accidental tracking of sensitive deployment metadata.
/contracts/broadcast/
| verbosity = 3 | ||
|
|
||
| [profile.fuzz] | ||
| fuzz = { runs = 10_000, max_test_rejects = 1_000_000 } |
There was a problem hiding this comment.
A max_test_rejects value of 1,000,000 is excessively high. If a fuzz test is rejecting that many inputs, it indicates a significant efficiency issue in the test's constraints (e.g., over-reliance on vm.assume). This can lead to extremely long CI runtimes. It is better to use vm.bound or more specific input types to ensure the fuzzer generates valid inputs efficiently.
| fuzz = { runs = 10_000, max_test_rejects = 1_000_000 } | |
| fuzz = { runs = 10_000, max_test_rejects = 65536 } |
Coverage reportTotal: 89.95% (was 89.96%, ▼ 0.01%) — 16723/18591 lines No Rust files changed in this PR. History
|
…e + cap max_test_rejects - .gitignore: replace per-pattern broadcast/ rules with the whole dir. Foundry's default `broadcast/*/[0-9]*/` + `broadcast/**/dry-run/` pattern leaves run-latest.json + tx metadata tracked, which can leak RPC URLs and gas estimates. We don't need the deployment-history trail in-repo (tagged releases + deployment docs cover that). - foundry.toml [profile.fuzz]: cap max_test_rejects at foundry's default (65_536) instead of 1_000_000. A test hitting the ceiling signals over-constrained inputs (typically vm.assume overuse); the right fix is vm.bound / tighter input types, not raising the limit. Comment added to flag this for the next contributor. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Summary
First step of #452 — lays the Foundry toolchain under
contracts/so the 14-contract surface can land one PR at a time against a working build + fmt + test pipeline. No deCDN contract logic ships in this PR.contracts/, solc0.8.28, evmcancunfoundry.toml:default(fast local),ci(1024 fuzz / 256-depth invariants),fuzz(10k runs for nightly),coverage(optimizer off for accurate source mapping)[email protected]+[email protected]as git submodules; SHAs pinned infoundry.lock@openzeppelin/contracts/+forge-std/remappings inremappings.txttest/Sanity.t.solconfirms the toolchain wires through (forge-std loads, OZ remap resolves to the canonicalIERC20.transferselector); it will be deleted once the first real contract from Implement unified deCDN contract surface for audit (full 14-contract scope) #452 landsCI integration
Extended the existing
.github/workflows/ci.ymlrather than forking a new workflow — keeps the singleci-successalls-green gate authoritative across rust + adr + solidity.solidityfilter on thechangesjob (triggers oncontracts/**,.gitmodules, the workflow file itself)solidityjob: checkout withsubmodules: recursive, installsfoundry-rs/foundry-toolchain@v1stable, runsforge fmt --check→forge build --sizes→forge test, all underFOUNDRY_PROFILE=cici-success.needsandallowed-skipsso doc-only PRs (nocontracts/**changes) skip cleanlyPinning rationale
solc 0.8.28^0.8.20; pinning to one stable so audit diffs don't move across machinesevm_version = "cancun"tstore/mcopyif a contract wants themoptimizer_runs = 200forge initpulled — safe defaultOut of scope (acceptance criteria from #452 deferred to follow-up PRs)
These belong with the contracts they apply to, not the scaffold:
forge coveragethreshold gate — nothing to measure yetforge scriptdeploy template — no contracts to deploy yetTest plan
forge fmt --checkclean locallyFOUNDRY_PROFILE=ci forge build --sizesclean from aforge cleanstateFOUNDRY_PROFILE=ci forge test— 2/2 sanity tests passsolidityjob greenci-successaggregator green (existing rust/adr/markdown jobs untouched)Refs: #452