Repository navigation
chore(contracts): triage slither + aderyn findings (closes #690) - #692
Conversation
PR #684's test plan deferred the slither + aderyn static-analysis pass to a follow-up. Both CI gates were already green on main (slither 31 findings, all sub-medium; aderyn 0 High, 80 Low), so this commit handles the explicit triage: fix root causes where cheap, suppress with inline directives where intent is documented, leave sub-threshold noise alone. Slither (31 → 21): - Hoist `ICapacityBondEjector` (was inline in ContentBlacklist) and `ICapacityBondReporter` (was inline in FeeRouter) into dedicated files under `src/interfaces/`. Declare them on `CapacityBond`, mark `ejectNode`, `recordSettlement`, `epochLength` `override`. Clears 2x `missing-inheritance`. - Suppress `missing-zero-check` at the 5 sites where zero address is documented-intentional: `BuybackBurner.setPool`/`setVault` ("not wired" state — `executeBuyback` reverts with `PoolNotWired`), `CapacityBond. setTreasury` (forfeit burns as fallback), and the two `FeeRouter` constructor params for `safetyReserve_` / `buybackBurner_` (allowed iff matching share is zero; cross-validated in `_setShares`). - Suppress `unimplemented-functions` on the `abstract BuybackBurner` — the `_performSwap` virtual-without-body is the documented seam for the Balancer V3 deployment-PR subclass. Aderyn (L-3: 6 → 3, L-5: 1 → 0): - Real zero-checks added to `SafetyReserve.setBalancerPool`, `SafetyReserve.setChallengerIncentivePool`, and `CapacityBond.setSafetyReserve` — none had a documented intent for zero, and writing zero would brick the slash-routing flow. - Remove the unused `error NoPendingCredit()` from CapacityBond. Remaining sub-threshold findings (~21 slither timestamp lows on time-gated state machines + aderyn centralization-risk / unchecked-return / large-numeric lows) are accepted by design — suppressing each would add ~30 directives of noise without clearing any gate. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Gas snapshotGas changes vs baseRun: 26586508188 |
Contracts coverageLine coverage: 67.88% (856/1261 lines) |
There was a problem hiding this comment.
Code Review
This pull request refactors the codebase by extracting the ICapacityBondEjector and ICapacityBondReporter interfaces into standalone files and having CapacityBond explicitly inherit and override their functions. It also introduces zero-address validation checks in CapacityBond.setSafetyReserve and SafetyReserve setter functions, alongside adding several Slither static analysis disable annotations. The feedback recommends correcting an outdated line number reference in a comment within FeeRouter.sol to ensure accuracy.
There was a problem hiding this comment.
Pull request overview
This PR triages Solidity static-analysis findings (Slither + Aderyn) from the post-#684 contract suite by addressing low-effort root causes (e.g., missing inheritance declarations, missing zero checks, unused error) and adding narrowly-scoped inline suppressions where address(0) is intentionally supported.
Changes:
- Hoists
ICapacityBondEjector/ICapacityBondReporterinto standalonesrc/interfaces/files and updates contracts/tests to import them. - Adds explicit zero-address guards to governance setters where zero would break critical wiring (
SafetyReservepools,CapacityBond.setSafetyReserve). - Documents intentional
address(0)allowances with Slither suppressions and removes an unused custom error.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| contracts/test/FeeRouter.t.sol | Updates interface import path after interface hoist. |
| contracts/test/ContentBlacklist.t.sol | Updates interface import path after interface hoist. |
| contracts/src/SafetyReserve.sol | Adds zero-address checks for pool wiring setters. |
| contracts/src/interfaces/ICapacityBondReporter.sol | New standalone reporter interface used by FeeRouter and implemented by CapacityBond. |
| contracts/src/interfaces/ICapacityBondEjector.sol | New standalone ejector interface used by ContentBlacklist and implemented by CapacityBond. |
| contracts/src/FeeRouter.sol | Replaces inline interface with import; adds documented Slither suppressions for intentional zero-address cases. |
| contracts/src/ContentBlacklist.sol | Replaces inline interface with import. |
| contracts/src/CapacityBond.sol | Declares interface inheritance + overrides, removes unused error, adds zero-check for setSafetyReserve, and documents intentional zero in setTreasury. |
| contracts/src/BuybackBurner.sol | Adds Slither suppression for abstract hook and documents intentional zero-address “not wired” mode in setters. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Bot reviewers flagged the `// See NatSpec on lines 161-164` reference as both wrong (the @PARAM NatSpec is above the constructor signature) and brittle (hard-coded line numbers drift). The @PARAM NatSpec already documents the zero-allowed semantics — the inline comment was redundant. Keep the two `slither-disable-next-line missing-zero-check` directives. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…rface NatSpec - Add `override` to the four pre-existing `ICapacityBond` implementations on `CapacityBond` (`clearSlashedAtEpoch`, `firstBondedAt`, `slashedAtEpoch`, `slashRecords`) so the file no longer mixes styles with the three new `override` markers added for the hoisted `ICapacityBondEjector` / `ICapacityBondReporter` interfaces. - Document on `ICapacityBondReporter.epochLength` why the interface is declared `view` rather than `pure` despite the production implementor being `pure` — test mocks need to return a constructor-stored value per instance, which `pure` (which can't read state or immutables) would block. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Summary
main(slither 31 findings, all sub-medium; aderyn 0 High, 80 Low). This PR is the explicit triage: fix root causes where cheap, suppress where intent is documented, leave sub-threshold noise alone.missing-zero-check,missing-inheritance,unimplemented-functions) all clear; only the ~21timestamplows on intentional time-gated state machines remain. Exit code 0 preserved againstfail-on: medium.address-set-without-checks6 → 3 (real fixes for 3 sites; the remaining 3 are documented-intentional); L-5 unused-error 1 → 0. 0 High preserved againstfail-on: high.Triage decisions
Root-cause fixes
ICapacityBondEjectorandICapacityBondReporterwere inline inContentBlacklist.solandFeeRouter.solrespectively. Moved to new files undersrc/interfaces/.CapacityBondnow declaresis ICapacityBondEjector, ICapacityBondReporter, andejectNode/recordSettlement/epochLengthare markedoverride. Clears 2×missing-inheritance.SafetyReserve.setBalancerPool,SafetyReserve.setChallengerIncentivePool, andCapacityBond.setSafetyReserve— none had a documented intent for zero, and writing zero would brick the slash-routing flow.error NoPendingCredit()from CapacityBond (confirmed unused via grep). Clears aderyn L-5.Inline suppressions (intent already documented in NatSpec)
BuybackBurner.setPool/setVault:address(0)is the "not wired" mode;executeBuybackreverts withPoolNotWired.CapacityBond.setTreasury:address(0)documented as the burn-as-fallback path.FeeRouterconstructorsafetyReserve_/buybackBurner_: allowed iff matching share is zero; cross-validated in_setShares.abstract BuybackBurner:_performSwapvirtual-without-body is the documented seam for the Balancer V3 deployment-PR subclass.Left alone (sub-threshold, by design)
timestamp(~21 sites): intentional time-gated guards on unlock / appeal / vest windows. Low severity; suppressing each would add ~15 directives of noise.centralization-risk(53): intentionalonlyRole(GOVERNANCE_ROLE)/EMERGENCY_MULTISIG_ROLEadministration.unchecked-return(18): all on OZCheckpoints.Trace208.push/_grantRole/SafeERC20calls where the return value is correctly ignored by the library contract.large-numeric-literal(2):10_000BPS denominators where readability beats scientific notation.Test plan
forge fmt --checkcleanFOUNDRY_PROFILE=ci forge build --sizes --deny warningsclean (no solc / forge-lint warnings)forge test— 153/153 passingaderyn -o /tmp/aderyn.md --no-snippets --skip-update-check— 0 High preserved; L-3 6→3, L-5 1→0slither . --config-file slither.config.json— exit 0; 31→21 findings (onlytimestampremains)solidity-fmt,solidity-build-test,solidity-slither,solidity-aderynCloses #690.
🤖 Generated with Claude Code