Repository navigation
feat(contracts): add PublisherRegistry — namespaces and content claims - #667
Conversation
…(ADR 002) Fourth Partition-A contract from #452. Permissionless namespace creation (publisher identity implicit on first createNamespace), append-only content claims binding (namespaceId, blake3Hash), and a timelocked 2-step namespace ownership transfer. Spec: ADR 002. OZ: AccessControl only. Governable params (maxNamespacesPerPublisher, namespaceTransferTimelock) carry GOVERNANCE_ROLE, held by the Timelock. Omits ReentrancyGuard despite ADR 016's inventory listing it: no external calls, no fund custody, so the guard is dead weight (same narrow-surface judgment as dropping ERC20Votes from TOKEN). ADR 016 row updated. No Pausable - creation is permissionless by design. Design: - namespaceId 0 reserved as default-open, never assigned; counter starts at 1. Claiming under 0 reverts (no owner). - Claims content-immutable + append-only; multi-claim across namespaces allowed; same-namespace re-claim reverts (idempotency). - 2-step transfer: owner initiates (days-scale timelock), pending recipient finalizes after delay, owner can cancel during window. - Bounds: maxNamespacesPerPublisher default 100 [1,1000]; namespaceTransferTimelock default 7d [1d,30d]. - Added NamespaceTransferCancelled event (not in ADR interface) for observability. Tests: 23 unit + 1 fuzz (168/168 suite-wide). Ids/cap; multi-claim + idempotency + owner-only + default-open revert; full transfer flow + all revert paths; setter bounds + role gating; sequential-id fuzz. Refs: #452 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Gas snapshotGas changes vs baseRun: 26289541293 |
Contracts coverageLine coverage: 92.67% (518/559 lines) |
There was a problem hiding this comment.
Code Review
This pull request introduces the PublisherRegistry contract, which manages namespaces and content claims as defined in ADR 002. The implementation includes permissionless namespace creation, a two-step timelocked ownership transfer process, and governance-controlled parameters for namespace caps and transfer delays. Feedback identifies a logic flaw where the per-publisher namespace cap could be bypassed through transfers. Additionally, several gas optimization opportunities were suggested, specifically regarding storage packing for the PendingTransfer struct and governable state variables by utilizing smaller integer types.
There was a problem hiding this comment.
Pull request overview
Adds the PublisherRegistry Solidity contract (per ADR 002) to support permissionless namespace creation, append-only content claims, and a timelocked 2-step namespace ownership transfer, along with a dedicated Foundry test suite and supporting documentation/snapshot updates.
Changes:
- Introduces
PublisherRegistrycontract implementing namespace creation, content claiming, and timelocked transfers withAccessControl-gated governance setters. - Adds
PublisherRegistry.t.solunit + fuzz coverage for the full surface (creation, claims, transfers, setter bounds/roles). - Updates contract inventory documentation and regenerates the Foundry gas snapshot to include the new tests.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| contracts/src/PublisherRegistry.sol | New PublisherRegistry contract implementing ADR 002 interface (namespaces, claims, timelocked transfers, governance-bound params). |
| contracts/test/PublisherRegistry.t.sol | New Foundry tests covering constructor defaults/roles, namespace creation/caps, claim semantics, transfer flows, and governance setters. |
| contracts/.gas-snapshot | Gas snapshot updated to include the new PublisherRegistry tests. |
| adr/016-contract-interactions.md | Contract inventory row updated to reflect PublisherRegistry’s OZ composition (omitting ReentrancyGuard). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
gemini (HIGH): finalizeNamespaceTransfer now enforces the recipient's
namespace cap. Without it the anti-squatting cap was bypassable by
minting namespaces under throwaway addresses and transferring them to
one publisher. Self-transfers (from == newOwner) are exempt (count
unchanged). +2 tests.
gemini (MEDIUM, storage packing):
- PendingTransfer.readyAt uint256 -> uint64 (packs with newOwner).
- maxNamespacesPerPublisher (uint64) + namespaceTransferTimelock (uint64)
+ _nextNamespaceId (uint64) declared consecutively -> one slot.
- Narrowing casts via OZ SafeCast (reverts on unreachable overflow).
Copilot: ADR 016 PublisherRegistry section claimed nonReentrant is
included for defense-in-depth, contradicting the no-guard implementation
and the inventory-row update. Corrected.
ADR consistency: ADR 002 interface (pendingTransfer readyAt +
maxNamespacesPerPublisher return uint64; cap-on-transfer note); ADR 016
finalize guard row + nonReentrant statement.
170/170 suite-wide. Gas snapshot regenerated.
Refs: #452
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Summary
Fourth Partition-A contract from #452. PublisherRegistry handles permissionless namespace creation (publisher identity is implicit on the first
createNamespace), append-only content claims binding(namespaceId, blake3Hash), and a timelocked 2-step namespace ownership transfer. Spec: ADR 002 § Contract: PublisherRegistry.OZ composition + a deliberate omission
AccessControlonly — the two governable parameters carryGOVERNANCE_ROLE, held by the Timelock post-deploy.Omits
ReentrancyGuarddespite ADR 016's inventory listing it: the contract makes no external calls and holds no funds, so a reentrancy guard is dead weight (every function is pure storage bookkeeping). Same narrow-surface judgment as droppingERC20Votesfrom TOKEN — I updated the ADR 016 inventory row to match. NoPausableeither; creation is permissionless by design (ADR 002 § Default-open namespace).Design
namespaceId == 0initiates (queues with a days-scale timelock), the pending recipientfinalizes after the delay (explicit acceptance), owner cancancelduring the window (key-compromise mitigation)maxNamespacesPerPublisherdefault 100,[1, 1000];namespaceTransferTimelockdefault 7d,[1d, 30d]Added a
NamespaceTransferCancelledevent (not in the ADR's interface block) so cancellation is observable alongside initiate/complete.Tests (23 unit + 1 fuzz, 168/168 suite-wide under
FOUNDRY_PROFILE=ci)createNamespace: ids from 1, count tracking, cap revertnamespaceOffor unclaimedGOVERNANCE_ROLEgatingTest plan
forge fmt --checkcleanforge build --deny warningsclean (forge v1.7.1, CI pin)FOUNDRY_PROFILE=ci forge test— 168/168Refs: #452