Repository navigation
feat(contracts): add ContentBlacklist core (hash + origin blacklist) - #675
alpergundogdu wants to merge 3 commits into
Conversation
Partition C / PR 1: the ADR 011 core surface, deferring the ADR 031 appeal flow to a follow-up PR. - Global + regional hash blacklist keyed by (blake3Hash, region); global entries use region bytes2(0). region is stored as bytes2 (ISO 3166-1 alpha-2, upper-cased), string at the external boundary. - effectiveAt = addedAt + grace = slashability threshold (grace = governable complianceWindow for governance entries, fixed 2h for emergency). isBlacklisted is immediate (eviction obligation), not gated on effectiveAt. - Origin blacklisting force-ejects via StakingRegistry.ejectNode (needs BLACKLIST_ROLE; granted post-deploy). removeOrigin does not un-eject. - Emergency multisig path with category auto-expiry (14d GENERAL / 90d CSAM,TERRORIST) and an immutable 365-day sunset. - Regional-body registry, governable complianceWindow (bounds [1h, 7d]), monotonic version counter, and the ADR 011 views. The BlacklistEntry struct carries suspended / suspendedAtUs so the views are forward-compatible with the deferred appeal flow; nothing sets them yet. 35 tests. ADR 011 clarified in-PR (implementation surfaced two unpinned spots, both confirmed with the maintainer): effectiveAt = addedAt + grace as the slashability threshold, and (hash, region) entry keying with a new getEntryInRegion view. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Gas snapshotGas changes vs baseRun: 26300354345 |
Contracts coverageLine coverage: 94.78% (744/785 lines) |
There was a problem hiding this comment.
Pull request overview
Adds the ADR 011 “ContentBlacklist” core contract to the Foundry contracts suite, providing governance/emergency-controlled hash blacklisting (global + regional) and origin blacklisting (with StakingRegistry.ejectNode integration), plus a polling-friendly version counter.
Changes:
- Introduces
ContentBlacklistcore contract: global/regional hash entries, origin entries w/ eject cross-call, emergency category expiry + sunset, regional-body registry, and compliance-window parameter. - Adds minimal
IStakingRegistryEjectinterface and a test mock, plus a comprehensive Foundry test suite for the new surface. - Updates ADR 011 compliance-window semantics and documents
(hash, region)keying +getEntryInRegion; regenerates gas snapshot.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| contracts/src/ContentBlacklist.sol | Implements the on-chain blacklist core (hash + origin, governance/emergency/regional paths, versioning, views/events). |
| contracts/src/interfaces/IStakingRegistryEject.sol | Minimal interface for StakingRegistry.ejectNode dependency. |
| contracts/test/ContentBlacklist.t.sol | Foundry tests covering constructor, role-gating, global/regional/emergency/origin flows, expiry/sunset, and compliance window/versioning. |
| contracts/test/mocks/MockStakingRegistryEject.sol | Test stand-in for StakingRegistry eject surface used by ContentBlacklist tests. |
| contracts/.gas-snapshot | Gas snapshot update to include new tests and refreshed baselines. |
| adr/011-content-takedown.md | ADR clarifications: (hash, region) keying + getEntryInRegion, and corrected compliance/grace semantics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request implements the ContentBlacklist contract and its associated interface, providing a governance-controlled mechanism for on-chain hash and origin blacklisting as specified in ADR 011. The system supports global and regional hash blacklists, origin-based node ejection from the StakingRegistry, and an emergency multisig path with category-specific auto-expiry. Review feedback recommends standardizing all timestamp and duration fields to uint256 for consistency with the broader protocol and ADR specifications. Additionally, it is suggested that the getEntryInRegion function be updated to handle empty region strings gracefully, ensuring consistent behavior across the contract's view functions.
The `addedAt == 0` revert guards in _removeHashEntry / removeOrigin are presence checks (0 = no entry), not value-bearing equalities. Annotate with slither-disable-next-line incorrect-equality (the same pattern StakingRegistry uses for its presence/amount sentinels). The remaining block.timestamp findings are LOW severity (below fail_on: medium), as in the already-merged StakingRegistry / PublisherRegistry. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…canonical region) - Use uint256 for all timestamp / duration fields (blacklistDeadline, complianceWindow, BlacklistEntry + OriginEntry fields, constants), matching StakingRegistry and the ADR 011 struct; drop the now-unneeded SafeCast. - removeHashRegional emits the canonical (upper-cased) region in HashRemoved, matching HashBlacklisted, instead of the raw caller input. - getEntryInRegion resolves an empty region to the global entry instead of reverting, consistent with isBlacklistedInRegion. - MockStakingRegistryEject.ejectNode marked override. - Add tests for getEntryInRegion (regional + empty/global) and the canonical-region HashRemoved emission. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Summary
Partition C / PR 1: the ADR 011 core
ContentBlacklistsurface. The ADR 031 appeal flow (openBlacklistAppeal+ the multisig/Governor lifecycle) is deferred to PR 2; theBlacklistEntry.suspended/suspendedAtUsfields exist here so theisBlacklistedviews are forward-compatible, but nothing sets them yet.Surface
addHash/removeHash,GOVERNANCE_ROLE) + regional (addHashRegionalby the registered body for its region;removeHashRegionalgovernance-only). Keyed by(blake3Hash, region), global =region bytes2(0), so a hash can be globally and/or regionally blacklisted independently.addOrigin/emergencyAddOriginforce-eject viaStakingRegistry.ejectNode(needsBLACKLIST_ROLE, granted post-deploy);removeOriginclears the entry but does not un-eject (re-entry needs fresh stake per ADR 011).emergencyAdd/emergencyAddOriginwith category auto-expiry (14dGENERAL/ 90dCSAM,TERRORIST) and an immutable 365-day sunset.complianceWindow(bounds[1h, 7d]), monotonicversioncounter, views (isBlacklisted,isBlacklistedInRegion,isOriginBlacklisted,getEntry,getEntryInRegion,getBlacklistVersion).regionstored asbytes2(ISO 3166-1 alpha-2, upper-cased/canonicalized),stringat the external boundary.AccessControl + ReentrancyGuard(no funds in the core;ReentrancyGuardcovers theejectNodecross-call).Design decisions (confirmed with maintainer; ADR 011 clarified in this PR)
ADR 011's core storage model was underspecified in two spots — both resolved and the ADR updated in-PR per the "update ADR in the same PR" convention:
effectiveAt = addedAt + grace= the slashability threshold (grace =complianceWindowfor governance entries, fixed 2h for emergency).isBlacklistedis immediate (eviction obligation begins ataddedAt) and does not gate oneffectiveAt. The struct comment / compliance table previously conflicted; fixed.(hash, region)entry keying (consistent with ADR 031), with a newgetEntryInRegionview added to the interface.Test plan
vm.expectCall), role gating, compliance-window bounds, version counterforge fmt --check,forge build --deny warnings, gas snapshot regenerated; ADRcheck-refs/check-book-list/markdownlint passFollow-ups
openBlacklistAppeal+ lifecycle, bond escrow, perjury denylist) on this same contract.OriginAssignment+SlashJudgecomplete Partition C.🤖 Generated with Claude Code