Skip to content

feat(contracts): add per-(filer,region) concurrent fast-track cap alongside region ceiling (#1015) - #1045

Merged
alpergundogdu merged 2 commits into
mainfrom
feat/1015-per-filer-relief-cap
Jun 30, 2026
Merged

alpergundogdu merged 2 commits into
mainfrom
feat/1015-per-filer-relief-cap

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1015. Sub-issue of #688 — Mechanism D. Independent of B/C; coordinated with #1016 (now merged) since they share fast-track exit-path accounting.

What

The interim-relief concurrent cap was keyed on region alone (BODY_CONCURRENT_APPEAL_CAP = 3), so a single adversarial filer could saturate a region's fast-track relief slots. This adds a per-(filer, region) sub-cap alongside the existing per-region ceiling — both coexist (the region ceiling stays as a second backstop, per the resolved decision).

Changes (ContentBlacklist.sol)

  • Renamed BODY_CONCURRENT_APPEAL_CAP → REGION_CONCURRENT_RELIEF_CAP (the "body" name was misleading — enforcement is per region, not per requesting body). Updated the header docstring + RegionalCapHit doc.
  • Added FILER_CONCURRENT_RELIEF_CAP = 2 (see note below), the filerRegionActiveRelief[region][filer] mapping (public getter), and the FilerReliefCapHit(filer, cap) error.
  • Accounting symmetry — mirrors regionActiveReliefCount exactly: fastTrackBlacklistAppeal checks + increments both counters; all five fast-track exit paths decrement both with the same != 0 guard. The fifth path is rejectAppealAsPerjury (added by feat(contracts): add multisig perjury denylist via rejectAppealAsPerjury (#688) #1016) — this is the shared-accounting overlap the issues warned about, now handled since feat(contracts): add multisig perjury denylist via rejectAppealAsPerjury (#688) #1016 landed first.

Cap value — flagged for your review

FILER_CONCURRENT_RELIEF_CAP = 2 with REGION_CONCURRENT_RELIEF_CAP = 3. Rationale: it must be strictly below the region ceiling so one filer can't fully monopolize a region (2 of 3 → one slot always reachable by others), and it's the value that makes the issue's "two different filers each fast-track up to the region ceiling" test coherent (2 + 1 = 3). If you'd prefer the stricter 1 (one concurrent relief per filer per region), it's a one-line change — say the word.

Tests (ContentBlacklist.t.sol)

  • Rewrote test_regionalCap_countsFastTrackedNotOpen to use two filers to fill the region ceiling (one filer alone now tops out at the sub-cap; the 4th fast-track hits RegionalCapHit while the filer is still under its sub-cap).
  • New: per-filer cap blocks while the region has headroom (FilerReliefCapHit, region count unchanged).
  • New: every exit path — reject / perjury / ratify / reverse / cleanup — decrements the per-filer counter; cleanup test also re-fast-tracks to prove the freed slot.
  • 52/52 ContentBlacklist, 681 full suite (incl. InterfaceFreeze).

ADR-031 reconciliation

Two-tier model documented in §90 (mapping, revert table, fast-track state transition, decrement points); per-filer-cap removed from the deferred-machinery note. Also dropped the now-stale "perjury denylist is deferred" line from the contract header (implemented in #1016 — that comment was missed there).

Out of scope / flagged

  • ADR-011 still references the old BODY_CONCURRENT_APPEAL_CAP name (lines 260/271/303) — it's the upstream semantic spec and the issue scopes the doc work to ADR-031 §90, so I left it. Happy to reconcile ADR-011 separately if you want.

Checks

CI-profile forge build --deny warnings (clean), full forge test (681), gas snapshot regenerated + verified against the CI deterministic check, forge fmt/solhint/markdownlint/ADR hygiene all green. (slither/aderyn run in CI — accounting mirrors existing passing patterns.)

Refs #688.

Summary by CodeRabbit

  • New Features

    • Added a new two-level limit for fast-tracked content appeals: one limit applies per region, and a stricter limit applies per filer within each region.
    • Appeals now show clearer limit-related errors when either the regional or filer-specific cap is reached.
  • Bug Fixes

    • Improved consistency so fast-track appeal counts are updated correctly when appeals are resolved, reversed, or expire.

ADR 031 Mechanism D. The interim-relief concurrent cap was keyed on region
alone, so a single adversarial filer could saturate a region's fast-track
relief slots. Add a per-(filer, region) sub-cap alongside the existing
per-region ceiling — both coexist (region ceiling kept as a second backstop).

- Rename `BODY_CONCURRENT_APPEAL_CAP` -> `REGION_CONCURRENT_RELIEF_CAP` (the
  "body" name was misleading; enforcement is per region). Add
  `FILER_CONCURRENT_RELIEF_CAP = 2`, strictly below the region ceiling (3) so
  one filer can never monopolize a region. Both fixed constants, no setter.
- New `filerRegionActiveRelief[region][filer]` mapping (public getter) +
  `FilerReliefCapHit(filer, cap)` error.
- `fastTrackBlacklistAppeal` checks + increments both counters; all FIVE
  fast-track exit paths decrement both with the same `!= 0` guard — including
  `rejectAppealAsPerjury` (the exit path added by #1016).

Tests: per-filer cap blocks while the region has headroom; two filers fill the
region ceiling (per-filer doesn't block, region does); every exit path
(reject / perjury / ratify / reverse / cleanup) decrements the per-filer
counter and frees the filer to fast-track again. 52/52 ContentBlacklist, 681
full suite. Gas snapshot regenerated.

ADR-031 reconciled: two-tier cap documented, revert table + decrement points
updated, per-filer-cap removed from the deferred-machinery note. Also dropped
the now-stale "perjury denylist is deferred" line from the contract header
(implemented in #1016).

Closes #1015. Refs #688.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Copilot AI review requested due to automatic review settings June 30, 2026 14:26
@coderabbitai

coderabbitai Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@alpergundogdu, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 6 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 65515214-4bfc-4ae7-9f9d-0adc3263f606

📥 Commits

Reviewing files that changed from the base of the PR and between 13d938d and 615e7eb.

📒 Files selected for processing (2)
  • contracts/.gas-snapshot
  • contracts/src/ContentBlacklist.sol

Walkthrough

The PR upgrades the interim-relief fast-track concurrency model in ContentBlacklist from a single per-region cap to a two-tier model: a per-region ceiling (REGION_CONCURRENT_RELIEF_CAP) plus a per-(filer, region) sub-cap (FILER_CONCURRENT_RELIEF_CAP). A new filerRegionActiveRelief storage mapping and FilerReliefCapHit error are introduced. All five FastTracked exit paths decrement both counters. The ADR, tests, and gas snapshots are updated accordingly.

Changes

Two-tier interim-relief concurrency cap

Layer / File(s) Summary
ADR and contract data/error contracts
adr/031-content-blacklist-appeals-contract.md, contracts/src/ContentBlacklist.sol
ADR revised to describe the two-tier cap with filerRegionActiveRelief and FilerReliefCapHit; contract adds REGION_CONCURRENT_RELIEF_CAP, FILER_CONCURRENT_RELIEF_CAP constants, filerRegionActiveRelief public mapping, and FilerReliefCapHit error.
fastTrackBlacklistAppeal and exit-path decrements
contracts/src/ContentBlacklist.sol
fastTrackBlacklistAppeal checks and increments both caps; all five FastTracked exit paths (rejectBlacklistAppeal, rejectAppealAsPerjury, ratifyBlacklistAppealRemoval, reverseBlacklistAppeal, cleanupExpiredBlacklistAppeal) decrement both counters.
Test helpers and per-filer cap test suite
contracts/test/ContentBlacklist.t.sol
_fundedFiler helper added; test_regionalCap_countsFastTrackedNotOpen refactored across two filers; _filerAtReliefCap helper and six new tests (test_filerReliefCap_*) verify FilerReliefCapHit blocking and counter decrements on all exit paths.
Gas snapshot updates
contracts/.gas-snapshot
Baseline updated for new and modified ContentBlacklistTest entries plus collateral gas changes across CapacityBond, DeployProtocol, GovernanceLifecycle, PaymentChannel, PublisherRegistry, TestnetFaucet, and Token test suites.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding a per-filer, per-region fast-track cap alongside the existing region ceiling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/1015-per-filer-relief-cap

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

Contracts coverage

Line coverage: 90.87% (2289/2519 lines)
▲ +0.59pp vs base (90.28% → 90.87%)
Run: 28452274318

@github-actions

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR strengthens ContentBlacklist’s fast-track (interim-relief) anti-spam controls by adding a per-(filer, region) concurrent fast-track cap that complements (and does not replace) the existing per-region ceiling, preventing a single filer from monopolizing a region’s relief slots.

Changes:

  • Rename the region-scoped ceiling constant to REGION_CONCURRENT_RELIEF_CAP and document the two-tier model in the contract header.
  • Add FILER_CONCURRENT_RELIEF_CAP, a filerRegionActiveRelief[region][filer] counter, and enforce it in fastTrackBlacklistAppeal with symmetric decrementing across all fast-track exit paths.
  • Update/extend Foundry tests to cover: (1) region-cap filling now requiring two filers, (2) per-filer cap reverts while region has headroom, and (3) all exit paths correctly decrement the per-filer counter; regenerate gas snapshot and reconcile ADR-031 §90.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
contracts/src/ContentBlacklist.sol Implements the two-tier concurrent fast-track cap (per-region + per-filer-per-region) and updates accounting on all fast-track exit paths.
contracts/test/ContentBlacklist.t.sol Updates the regional-cap test to use two filers and adds targeted tests ensuring the per-filer cap and all decrement paths behave correctly.
contracts/.gas-snapshot Updates gas baselines reflecting the additional storage checks/writes and new tests.
adr/031-content-blacklist-appeals-contract.md Updates ADR-031 §90 to describe the two-tier cap and its increment/decrement points.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request implements a two-tier concurrent fast-track cap for interim relief in the ContentBlacklist contract, as specified in ADR 031. It introduces a global per-region ceiling of 3 active slots and a per-filer, per-region sub-cap of 2 active slots to prevent a single filer from monopolizing a region's relief slots. The implementation updates ContentBlacklist.sol to track, enforce, and release both caps across all fast-track entry and exit paths, supported by comprehensive unit tests. The review feedback identifies a valuable gas optimization opportunity in fastTrackBlacklistAppeal and related exit functions to cache frequently accessed storage variables like a.region, a.filer, and a.hash into local memory to avoid redundant SLOAD operations.

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.

Comment thread contracts/src/ContentBlacklist.sol Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@contracts/src/ContentBlacklist.sol`:
- Around line 507-524: The appeal lifecycle transitions are missing deadline
checks, allowing stale appeals to be fast-tracked or resolved after their
allowed windows. Update fastTrackBlacklistAppeal, ratifyBlacklistAppealRemoval,
and reverseBlacklistAppeal to enforce APPEAL_REVIEW_WINDOW from openedAt and
APPEAL_RATIFICATION_WINDOW from fastTrackedAt before changing status or
blacklist/bond outcomes, and route expired cases into the existing timeout/lapse
handling instead of permitting the transition. Make sure the checks are applied
consistently at the start of these functions using the existing appeal state
fields and error paths.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: dcd99b5e-f6c0-449f-812d-c44dc75d75be

📥 Commits

Reviewing files that changed from the base of the PR and between 9e8726b and 13d938d.

📒 Files selected for processing (4)
  • adr/031-content-blacklist-appeals-contract.md
  • contracts/.gas-snapshot
  • contracts/src/ContentBlacklist.sol
  • contracts/test/ContentBlacklist.t.sol

Comment thread contracts/src/ContentBlacklist.sol Resolved
…review)

Cache a.region and a.filer in locals to avoid redundant warm SLOADs in
fastTrackBlacklistAppeal, which this PR reworked to read both fields ~6x
across the two cap checks and increments (gemini). Scoped to this function;
a.hash is read once so it stays inline. Gas snapshot refreshed.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(contracts): add per-(filer,region) concurrent fast-track cap alongside region ceiling (#688)

2 participants