Repository navigation
feat(contracts): rejection cooldown for blacklist appeals (#688 item 1, H-4) - #913
Conversation
…appeals (H-4) ContentBlacklist shipped the ADR 031 appeal lifecycle but deferred the rejection cooldown, so the only brake on abusive/rejected filers was the bond — an attacker could spam openBlacklistAppeal across distinct live entries, bounded only by bond cost (audit finding H-4). The success-path frequency cap (lastRatifiedSuccessAt) only throttles ratified filers. Implement the ADR 031 § APPEAL_FILER_REJECTION_COOLDOWN semantics: a per-filer RejectionWindow ring records the three most recent rejection timestamps; rejectBlacklistAppeal appends to it, and three rejections inside a rolling window lock the filer out of openBlacklistAppeal for a fresh full window. The window length is governance-tunable (setRejectionCooldownWindow, bounds-checked like appealBond); the threshold is fixed at three by the single-slot fixed-size ring. Scoped to issue #688 item 1 only — the perjury denylist, standing-enforcement clawback, and per-body concurrent-appeal cap remain deferred. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Gas snapshotGas changes vs baseRun: 27548644982 |
Contracts coverageLine coverage: 89.73% (2098/2338 lines) |
There was a problem hiding this comment.
Code Review
This pull request implements the ADR 031 rejection cooldown mechanism to throttle abusive filers who repeatedly submit rejected appeals. It introduces a rolling window tracking the three most recent rejections per filer, locking them out for a governance-tunable duration if all three occur within the window. Comprehensive tests have been added to verify this behavior. The reviewer pointed out a potential edge case where a newly calculated cooldown could prematurely shorten an active lockout if governance reduces the window, and suggested only updating the cooldown timestamp if it is strictly greater than the existing one.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if (oldest != 0 && nowTs - oldest <= window) { | ||
| w.cooldownUntilAt = nowTs + window; | ||
| w.rejections[0] = 0; | ||
| w.rejections[1] = 0; | ||
| w.rejections[2] = 0; | ||
| } |
There was a problem hiding this comment.
If a filer is already in an active cooldown and governance subsequently reduces the rejectionCooldownWindow, a new set of rejections during the active cooldown could calculate a newCooldown (nowTs + window) that is earlier than the existing cooldownUntilAt. This would prematurely shorten the filer's active lockout period.
To prevent this, only update cooldownUntilAt if the newly calculated cooldown timestamp is strictly greater than the existing one.
if (oldest != 0 && nowTs - oldest <= window) {
uint64 newCooldown = nowTs + window;
if (newCooldown > w.cooldownUntilAt) {
w.cooldownUntilAt = newCooldown;
}
w.rejections[0] = 0;
w.rejections[1] = 0;
w.rejections[2] = 0;
}
There was a problem hiding this comment.
Pull request overview
Implements ADR-031’s (audit finding H-4) rejection cooldown for ContentBlacklist appeals to rate-limit abusive filers whose appeals are repeatedly rejected, and adds Foundry coverage for the new behavior.
Changes:
- Added per-filer rolling rejection tracking (
filerRejections) and an intake-time lockout (FilerInRejectionCooldown) enforced inopenBlacklistAppeal. - Recorded rejections on
rejectBlacklistAppealand applied a full-window cooldown after 3 in-window rejections. - Added governance setter + tests for configuring the cooldown window, plus behavioral tests for cooldown triggering/expiry/rolling-window behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
contracts/src/ContentBlacklist.sol |
Adds rejection cooldown storage, enforcement, governance setter, and rejection recording logic. |
contracts/test/ContentBlacklist.t.sol |
Adds Foundry tests covering cooldown behavior and the governance setter bounds/access-control. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// @notice Governance-tunable ADR 031 rejection cooldown window (rolling | ||
| /// lookback == lockout duration). Bounded for the same reason as | ||
| /// `appealBond` — keeps the abuse throttle inside sane limits. |
Summary
Implements item 1 of #688 — the ADR 031 rejection cooldown (audit finding H-4). The other three items in #688 (perjury denylist, standing-enforcement / synthetic-standing clawback, per-body concurrent-appeal cap) are out of scope and left for follow-up.
ContentBlacklistshipped the ADR 031 appeal lifecycle but deferred the rejection cooldown. Until now the only brake on abusive/rejected filers was the bond: an attacker could spamopenBlacklistAppealacross distinct live entries, bounded only by bond cost. The existing success-path frequency cap (lastRatifiedSuccessAt) only throttles ratified filers, never rejected ones.What changed
Matches ADR 031 § APPEAL_FILER_REJECTION_COOLDOWN — three rejections in a rolling window → a full-window lockout:
RejectionWindowstruct +filerRejectionsmapping — a single-slot, fixeduint64[3]ring of the three most recent rejection timestamps pluscooldownUntilAt.rejectBlacklistAppealnow records the rejection via_recordRejection; when three rejections fall inside the window it sets the cooldown and clears the ring (so the filer starts fresh once it elapses).openBlacklistAppealrejects filers whosecooldownUntilAtis in the future with a newFilerInRejectionCooldownerror — a cheap single SLOAD placed before the standing / external-call checks.rejectionCooldownWindow(default 90d, bounds[1d, 365d]) with asetRejectionCooldownWindowsetter mirroring the existingsetAppealBondpattern (GOVERNANCE_ROLE, bounds-checked, event). The threshold stays fixed at three (the ring length).uint64like every other appeal-machinery time field, so there are no widen/narrow casts.The contract header note is updated to reflect that the rejection cooldown now ships (perjury denylist remains deferred).
Tests
8 new Foundry cases in
ContentBlacklist.t.sol:Verification
Mirrors CI locally:
forge fmt --check✅FOUNDRY_PROFILE=ci forge build --deny warnings✅forge test— 613 passed, 0 failedslither . --config-file slither.config.json— no medium/high findings from this changeaderyn(fail-on: high) — no high findings inContentBlacklist.sol🤖 Generated with Claude Code