Repository navigation
feat(contracts): enforce Publisher and TokenHolder standing at appeal filing (audit I-3) (#1017) - #1050
Conversation
… filing (#688) ADR 031 § 216 Mechanism C1 (audit I-3). `openBlacklistAppeal` previously only verified Operator standing; Publisher and TokenHolder were enum-range-checked only, so any address could forge them. Enforce all three at filing. - New `namespaceId` filing arg on `openBlacklistAppeal`. Publisher path now requires `publisherRegistry.ownerOf(namespaceId) == msg.sender` AND `publisherRegistry.hasClaimed(namespaceId, hash)` (a hash->namespace reverse lookup is ambiguous, so the namespace is passed explicitly). `namespaceId` is ignored on the other paths. - TokenHolder path now requires `token.balanceOf(filer) >= appealFilerTokenThreshold`, a governable bounded param: default 1,000e18, bounds [1,000e18, 1,000,000e18], tightening-only (floor == launch default). Low at launch per the operator- barrier preference; the bond + the deferred §216(c) clawback are the primary Sybil deterrents. - `PublisherRegistry` bound as a constructor immutable (security-critical, can't be left unset/re-pointed). New minimal `IPublisherRegistryStanding` interface (ownerOf + hasClaimed); `PublisherRegistry` gains a public `hasClaimed` getter. Deploy reordered so the registry (needs only `admin`) builds first. Wiring updated: BaseProtocolDeploy + the ContentBlacklist / CapacityBondRegionE2E construction sites. InterfaceFreeze is NOT touched — it does not pin ContentBlacklist (only PaymentChannel/SlashJudge/OriginAssignment). Tests: Publisher owner+claimed succeeds; non-owner / owner-but-unclaimed / wrong-namespaceId revert; TokenHolder at/below threshold; threshold setter bounds (tightening-only floor), role-gating; Operator path regression. 62/62 ContentBlacklist, 685 full suite. ADR-031 standing section reconciled. Prerequisite for #1018 (synthetic-standing clawback). Closes #1017. Refs #688. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughEnforces Publisher and TokenHolder standing at ChangesPublisher & TokenHolder Standing Enforcement
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Contracts coverageLine coverage: 91.48% (2331/2548 lines) |
Gas snapshotNo gas changes vs base. |
There was a problem hiding this comment.
Code Review
This pull request implements standing enforcement at filing for all three paths (Operator, Publisher, and TokenHolder) in ContentBlacklist as specified in ADR 031 and addressing audit finding I-3. It introduces the IPublisherRegistryStanding interface, integrates PublisherRegistry into ContentBlacklist as an immutable constructor dependency, and updates the openBlacklistAppeal function to accept a namespaceId for the Publisher standing check. Additionally, it adds a governable appealFilerTokenThreshold for TokenHolder standing checks, along with corresponding setters, events, and comprehensive unit tests. There are no review comments, so I have no feedback to provide.
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.
There was a problem hiding this comment.
Pull request overview
This PR tightens ContentBlacklist.openBlacklistAppeal standing enforcement to address audit finding I-3 by requiring real Publisher and TokenHolder standing at appeal filing (not just enum-range validation), and updates deploy wiring/tests/documentation accordingly.
Changes:
- Extended
openBlacklistAppealwith anamespaceIdargument and enforced Publisher standing viapublisherRegistry.ownerOf(namespaceId)+publisherRegistry.hasClaimed(namespaceId, hash). - Enforced TokenHolder standing via a governable
appealFilerTokenThreshold(default 1000e18; bounded). - Added
PublisherRegistry.hasClaimedview getter and introduced a minimalIPublisherRegistryStandinginterface; updated deploy script + tests + ADR and regenerated gas snapshots.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| contracts/src/ContentBlacklist.sol | Adds publisher-registry immutable binding, token-holder threshold gating, new namespaceId arg, and standing checks at filing. |
| contracts/src/interfaces/IPublisherRegistryStanding.sol | Defines minimal read-only interface needed for Publisher standing checks. |
| contracts/src/PublisherRegistry.sol | Exposes hasClaimed(namespaceId, hash) for standing verification. |
| contracts/script/BaseProtocolDeploy.s.sol | Reorders deployment so PublisherRegistry is deployed before ContentBlacklist and wired immutably. |
| contracts/test/ContentBlacklist.t.sol | Updates constructor usage + appeal calls with namespaceId, and adds new standing enforcement tests. |
| contracts/test/CapacityBondRegionE2E.t.sol | Updates ContentBlacklist construction to include publisher registry binding. |
| adr/031-content-blacklist-appeals-contract.md | Updates ADR narrative + signature/revert-table notes to reflect standing enforcement and new arg. |
| contracts/.gas-snapshot | Updates gas baselines after contract/test changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
contracts/script/BaseProtocolDeploy.s.sol (1)
277-289: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winAssert the new registry binding in the deploy invariants.
publisherRegistry_is now a security-critical standing gate, but phase 7 never re-reads it. A future constructor-arg mix-up would still let the script finish withContentBlacklistpointing at the wrong registry.Suggested follow-up
address boundBlacklist = d.originAssignment.contentBlacklist(); if (boundBlacklist != address(d.blacklist)) { revert BindingNotWired(address(d.originAssignment), address(d.blacklist), boundBlacklist); } + address boundPublisherRegistry = address(d.blacklist.publisherRegistry()); + if (boundPublisherRegistry != address(d.registry)) { + revert BindingNotWired(address(d.blacklist), address(d.registry), boundPublisherRegistry); + } address boundPool = d.slashAppeal.challengerIncentivePool(); if (boundPool != cfg.challengerIncentivePool) { revert BindingNotWired(address(d.slashAppeal), cfg.challengerIncentivePool, boundPool); }🤖 Prompt for 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. In `@contracts/script/BaseProtocolDeploy.s.sol` around lines 277 - 289, The deploy script currently creates PublisherRegistry and passes it into ContentBlacklist, but the phase 7 deploy invariants do not verify that binding. Add an assertion in the deploy invariant checks around the ContentBlacklist deployment to confirm the blacklist’s publisherRegistry_ is the freshly deployed registry (using the existing d.registry and d.blacklist symbols), so a constructor-argument mix-up is caught immediately after deployment.contracts/test/ContentBlacklist.t.sol (1)
1108-1142: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd the missing decrease-after-increase regression.
These cases cover floor/ceiling bounds, but not the required tightening-only behavior. As written, the current setter can raise to
5000e18and then drop back to1000e18while still satisfying every new test here.Suggested test
+ function test_setAppealFilerTokenThreshold_cannotDecreaseAfterIncrease() public { + vm.startPrank(admin); + blacklist.setAppealFilerTokenThreshold(5000e18); + vm.expectRevert(); + blacklist.setAppealFilerTokenThreshold(1000e18); + vm.stopPrank(); + }🤖 Prompt for 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. In `@contracts/test/ContentBlacklist.t.sol` around lines 1108 - 1142, The new tests for setAppealFilerTokenThreshold only cover bounds and access control, but miss the tightening-only regression where the value can be increased and then lowered back to the default. Add a test in ContentBlacklist.t.sol alongside test_setAppealFilerTokenThreshold_updatesValue that first calls ContentBlacklist.setAppealFilerTokenThreshold to raise the threshold and then asserts a subsequent attempt to set it back to 1000e18 reverts with ContentBlacklist.ParamOutOfBounds, using vm.prank(admin) for both calls.
🤖 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 741-750: The `setAppealFilerTokenThreshold` setter in
`ContentBlacklist` is only enforcing floor/ceiling bounds, so governance can
still lower `appealFilerTokenThreshold` after raising it. Update this method to
make the change tightening-only by rejecting any `newThreshold` that is below
the current `appealFilerTokenThreshold`, while still keeping the existing
`_enforceAppealFilerTokenThresholdBounds` check. Preserve the existing
`AppealFilerTokenThresholdUpdated` event flow and use the current storage
variable in the comparison so the gate can only stay the same or increase.
---
Nitpick comments:
In `@contracts/script/BaseProtocolDeploy.s.sol`:
- Around line 277-289: The deploy script currently creates PublisherRegistry and
passes it into ContentBlacklist, but the phase 7 deploy invariants do not verify
that binding. Add an assertion in the deploy invariant checks around the
ContentBlacklist deployment to confirm the blacklist’s publisherRegistry_ is the
freshly deployed registry (using the existing d.registry and d.blacklist
symbols), so a constructor-argument mix-up is caught immediately after
deployment.
In `@contracts/test/ContentBlacklist.t.sol`:
- Around line 1108-1142: The new tests for setAppealFilerTokenThreshold only
cover bounds and access control, but miss the tightening-only regression where
the value can be increased and then lowered back to the default. Add a test in
ContentBlacklist.t.sol alongside test_setAppealFilerTokenThreshold_updatesValue
that first calls ContentBlacklist.setAppealFilerTokenThreshold to raise the
threshold and then asserts a subsequent attempt to set it back to 1000e18
reverts with ContentBlacklist.ParamOutOfBounds, using vm.prank(admin) for both
calls.
🪄 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: cb2520a2-e3b1-4f69-a231-67758b986186
📒 Files selected for processing (8)
adr/031-content-blacklist-appeals-contract.mdcontracts/.gas-snapshotcontracts/script/BaseProtocolDeploy.s.solcontracts/src/ContentBlacklist.solcontracts/src/PublisherRegistry.solcontracts/src/interfaces/IPublisherRegistryStanding.solcontracts/test/CapacityBondRegionE2E.t.solcontracts/test/ContentBlacklist.t.sol
… FP (#1017) The new TokenHolder standing check `token.balanceOf(filer)` is an external call whose result gates a state-affecting revert, which aderyn flags as reentrancy-state-change (1 high) like the existing region-scope read. The function is nonReentrant, so it's a false positive. Cache the balance on its own line preceded by `// aderyn-ignore-next-line(reentrancy-state-change)`, mirroring the ownerOf/hasClaimed/regionScopeData guards. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…1017 review) Address PR #1050 review: - setAppealFilerTokenThreshold is now monotonic non-decreasing — reverts AppealFilerTokenThresholdNotIncreasing on any value below the current threshold, not just below the static floor. The bounds check stays, so a below-floor value still reverts ParamOutOfBounds first (gemini, coderabbit Major: governance could previously raise to 5000 then drop back to 1000). - Add the decrease-after-increase regression test (coderabbit). - Assert the ContentBlacklist->PublisherRegistry immutable binding in the phase-7 deploy invariants, so a constructor-arg mix-up on a security-critical standing gate is caught at deploy (coderabbit). - Fix a stale test comment that referenced `filer` instead of `poorHolder` (copilot). 686 tests pass; gas snapshot refreshed. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Review + CI fixes (c55fa1d, and aderyn in 5aa14b4)CI aderyn (1 high) — fixed in 5aa14b4: the new Major (gemini + @coderabbitai) — tightening-only: @coderabbitai nitpicks (both addressed):
@copilot nit: fixed the stale 686 tests pass; gas snapshot refreshed; fmt/solhint/markdownlint/ADR hygiene green. 🤖 Addressed by Claude Code |
|
Tip For best results, initiate chat on the files or code changes.
The monotonic “governance can only raise” change for 🐇✅ ✏️ Learnings added
|
…forcement # Conflicts: # adr/031-content-blacklist-appeals-contract.md
…forcement # Conflicts: # contracts/.gas-snapshot
…threshold + clawback Replace the governable TOKEN balance threshold for StandingPath.TokenHolder with a no-special-case design: the escrowed appeal bond IS the standing. Standing only grants the right to file; an Open appeal has zero interim relief and every consequential transition is EMERGENCY_MULTISIG_ROLE-gated, so spam is already bounded by the bond + hasActiveAppeal + filerRejections cooldown + perjury denylist. A balance gate protects nothing not already protected, and because the bond is escrowed it can't be flash-loaned — so the synthetic-standing clawback (issue #1018) is dropped, not deferred: there is nothing to fake. ContentBlacklist.sol: remove appealFilerTokenThreshold state var, the DEFAULT/FLOOR/CEILING constants, setAppealFilerTokenThreshold, _enforceAppealFilerTokenThresholdBounds, the AppealFilerTokenThresholdUpdated event, the AppealFilerTokenThresholdNotIncreasing error, and the constructor init. The TokenHolder branch is now a documented no-op (bond-is-standing). Tests: drop the 5 threshold-setter tests and the 2 at/below-threshold tests; add test_tokenHolderStanding_bondIsStanding_succeedsAndEscrows proving a bond-only filer gets standing and the bond is escrowed. ADR 031: TokenHolder standing = the escrowed bond, no appealFilerTokenThreshold, clawback dropped-not-deferred; excise the clawback from the target spec (cleanup condition (c), LapseReason enum, state diagram, STANDING_LOOKBACK checkpoint) and renumber global-override (d)->(c). Publisher path unchanged. Regenerate .gas-snapshot. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Review — standing enforcement at appeal filing (#1017)Reviewed the full diff (contracts + ADR 031 + deploy wiring + tests) at high effort. The core change is correct and well-tested: the enum-branch refactor maps cleanly ( What's left is doc drift the PR introduced or should have swept, plus one design point worth confirming. 1.
|
… stale comments (#1017) Follow-up to review feedback on the standing-enforcement change. - ADR 011 (canonical takedown ADR): drop the removed synthetic-standing clawback + TOKEN-balance standing threshold. Rewrite path 3 (TokenHolder) to bond-is-standing, correct path 1 (Publisher) to pass namespaceId explicitly (the contract does not derive it from the hash), remove the clawback lapse condition and renumber (d)->(c), fix the Sybil paragraph, and add namespaceId to the interface + sequence-diagram signatures. - docs/runbook.md: update openBlacklistAppeal to the 5-arg signature and replace the now-false "recorded but not verified" caveat with the as-shipped per-path standing behavior. - ContentBlacklist.sol: drop the stale "s 216(c), formerly #1018" comment pointers (after this PR's own (d)->(c) renumbering, 216(c) is the global- override case), and clarify that the Publisher gate proves namespace control, not authorship. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Re-resolves the regenerated .gas-snapshot after main advanced. Full suite green: 701 passed, 0 failed, 6 skipped. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Closes #1017. Sub-issue of #688 — Mechanism C1 (audit I-3).
What
openBlacklistAppealpreviously only verified Operator standing;PublisherandTokenHolderwere enum-range-checked only — any address could forge them (audit I-3). This enforces standing at filing for all three paths.Design
publisherRegistry.ownerOf(namespaceId) == msg.senderANDpublisherRegistry.hasClaimed(namespaceId, hash). A newnamespaceIdfiling arg carries the claiming namespace (a hash→namespace reverse lookup is ambiguous — many namespaces can claim one hash — so it's passed explicitly). Ignored on non-Publisher paths.Openappeal has zero interim relief and every consequential transition (fastTrackBlacklistAppeal) isEMERGENCY_MULTISIG_ROLE-gated. Spam is already bounded by the bond +hasActiveAppeal+ thefilerRejectionscooldown + the perjury denylist, so a balance gate protects nothing that isn't already protected.Change from the earlier revision of this PR
The earlier version gated TokenHolder on a governable TOKEN balance threshold (
appealFilerTokenThreshold, default 1,000e18, tightening-only). That's been removed in favor of bond-is-standing. Because the bond is escrowed by the appeal it can't be flash-loaned, so the synthetic-standing clawback (#1018) that was meant to defend the threshold is dropped, not deferred — there is nothing to fake by construction.The safety argument holds only while standing-alone grants no automatic outcome. A code comment on the TokenHolder branch (and the contract header) flags: if any future change lets standing auto-fast-track or gain relief without a trusted role, a credential gate must be reinstated.
Changes
ContentBlacklist.solnamespaceIdfiling arg; Publisher owner+claim check; TokenHolder path posts the bond with no extra credential.appealFilerTokenThresholdmachinery (state var, DEFAULT/FLOOR/CEILING constants,setAppealFilerTokenThreshold, bounds helper,AppealFilerTokenThresholdUpdatedevent,AppealFilerTokenThresholdNotIncreasingerror, constructor init).PublisherRegistrybound as a constructor immutable (security-critical standing gate, can't be left unset/re-pointed).Wiring
IPublisherRegistryStandinginterface (ownerOf+hasClaimed);PublisherRegistrygains a publichasClaimedgetter.BaseProtocolDeployreordered soPublisherRegistry(needs onlyadmin) builds beforeContentBlacklist; constructor arg + post-deploy binding check added.ContentBlacklist.t.sol,CapacityBondRegionE2E.t.sol.ADR 031 — TokenHolder standing = the escrowed bond; clawback dropped-not-deferred. Excised the clawback from the target spec (cleanup admissibility condition (c), the
LapseReason/StandingClawbackenum value, the state diagram, theSTANDING_LOOKBACKcheckpoint) and renumbered global-override (d)→(c). Publisher path prose kept.Notes on the issue's assumptions
InterfaceFreezeis NOT touched — it explicitly does not pinContentBlacklist(only PaymentChannel/SlashJudge/OriginAssignment), so the new signature doesn't break it.namespaceIdis ignored (not required-zero) on non-Publisher paths — simpler, no special-case revert.Tests (57/57 ContentBlacklist, 689 full suite)
Publisher: owner-of-claiming-namespace succeeds; non-owner / owner-but-hash-not-claimed / wrong-namespaceId revert. TokenHolder: a bond-only filer gets standing and the bond is escrowed (
test_tokenHolderStanding_bondIsStanding_succeedsAndEscrows). Operator path regression retained. The prior threshold-setter and at/below-threshold tests were deleted.Checks
CI-profile
forge build --sizes --deny warningsclean (ContentBlacklist13,716 < EIP-170, down from 14,170); fullforge test(689 pass);forge fmt/solhint/markdownlint/ADR hygiene green; aderyn 0 High; slither exit 0 (no medium+); gas snapshot regenerated.Refs #688.