Skip to content

feat(contracts): add PublisherRegistry — namespaces and content claims - #667

Merged
alpergundogdu merged 2 commits into
mainfrom
feat/contracts-publisher-registry
May 22, 2026
Merged

alpergundogdu merged 2 commits into
mainfrom
feat/contracts-publisher-registry

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

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

AccessControl only — the two governable parameters carry GOVERNANCE_ROLE, held by the Timelock post-deploy.

Omits ReentrancyGuard despite 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 dropping ERC20Votes from TOKEN — I updated the ADR 016 inventory row to match. No Pausable either; creation is permissionless by design (ADR 002 § Default-open namespace).

Design

Aspect Behavior
namespaceId == 0 Reserved as default-open, never assigned; id counter starts at 1. Claiming under 0 reverts (no owner)
Claims Content-immutable + append-only. Multiple non-zero namespaces may claim the same hash independently (multi-claim); a namespace re-claiming its own hash reverts (idempotency)
Transfer 2-step: owner initiates (queues with a days-scale timelock), the pending recipient finalizes after the delay (explicit acceptance), owner can cancel during the window (key-compromise mitigation)
Bounds (ADR 002/009) maxNamespacesPerPublisher default 100, [1, 1000]; namespaceTransferTimelock default 7d, [1d, 30d]

Added a NamespaceTransferCancelled event (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 revert
  • Claims: multi-claim across namespaces, idempotency revert, owner-only, default-open (id 0) revert, empty namespaceOf for unclaimed
  • Transfer: full flow (initiate → not-ready revert → finalize), and all revert paths (not-owner, zero recipient, not-pending-owner, cancel-then-finalize-fails, no-pending)
  • Setters: bounds + GOVERNANCE_ROLE gating
  • Fuzz: sequential id assignment + ownership

Test plan

  • forge fmt --check clean
  • forge build --deny warnings clean (forge v1.7.1, CI pin)
  • FOUNDRY_PROFILE=ci forge test — 168/168
  • gas snapshot regenerated
  • CI solidity suite (incl. slither / aderyn) green

Refs: #452

…(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]>
@github-actions

github-actions Bot commented May 22, 2026 •

Copy link
Copy Markdown

Gas snapshot

Gas changes vs base
Compiling 67 files with Solc 0.8.28
Solc 0.8.28 finished in 3.73s
Compiler run successful!

Ran 44 tests for test/TestnetFaucet.t.sol:TestnetFaucetTest
[PASS] testFuzz_claim_atOrAboveCooldown(uint256) (runs: 1024, μ: 91479, ~: 91528)
[PASS] testFuzz_claim_belowCooldown(uint256) (runs: 1024, μ: 85167, ~: 85389)
[PASS] test_admin_canGrantAndRevokeRoles() (gas: 56401)
[PASS] test_claim_blocksReentrancy() (gas: 1550228)
[PASS] test_claim_happyPath() (gas: 82821)
[PASS] test_claim_perCallerCooldownIndependence() (gas: 133478)
[PASS] test_claim_revertsBeforeCooldown() (gas: 83092)
[PASS] test_claim_revertsOnInsufficientBalance() (gas: 50715)
[PASS] test_claim_revertsOneSecondBeforeCooldownBoundary() (gas: 82996)
[PASS] test_claim_revertsWhenPaused() (gas: 39998)
[PASS] test_claim_succeedsAfterCooldown() (gas: 90430)
[PASS] test_claim_succeedsAtExactCooldownBoundary() (gas: 87103)
[PASS] test_constructor_allowsZeroCooldown() (gas: 1810378)
[PASS] test_constructor_revertsOnCooldownExceedingMax() (gas: 1015061)
[PASS] test_constructor_revertsOnMainnetChainId() (gas: 988198)
[PASS] test_constructor_revertsOnZeroAdmin() (gas: 985898)
[PASS] test_constructor_revertsOnZeroClaimAmount() (gas: 988045)
[PASS] test_constructor_revertsOnZeroFunding() (gas: 988061)
[PASS] test_constructor_revertsOnZeroGovernance() (gas: 985864)
[PASS] test_constructor_revertsOnZeroPauser() (gas: 985954)
[PASS] test_constructor_revertsOnZeroTokenAddress() (gas: 70468)
[PASS] test_constructor_revertsOnZeroTreasury() (gas: 987830)
[PASS] test_constructor_revertsWhenTreasuryNotApproved() (gas: 1110690)
[PASS] test_constructor_setsStateAndRoles() (gas: 43070)
[PASS] test_nonAdmin_cannotGrantRoles() (gas: 17889)
[PASS] test_pause_blocksClaimUnpauseRestores() (gas: 91691)
[PASS] test_pause_revertsOnNonPauser() (gas: 14607)
[PASS] test_setClaimAmount_revertsOnNonGovernance() (gas: 14702)
[PASS] test_setClaimAmount_revertsOnZero() (gas: 13338)
[PASS] test_setClaimAmount_updatesAndEmits() (gas: 22083)
[PASS] test_setCooldown_acceptsMaxCooldown() (gas: 20228)
[PASS] test_setCooldown_allowsZero() (gas: 94920)
[PASS] test_setCooldown_revertsOnExceedingMax() (gas: 13790)
[PASS] test_setCooldown_revertsOnNonGovernance() (gas: 14705)
[PASS] test_setCooldown_updatesAndEmits() (gas: 22231)
[PASS] test_timeUntilNext_tracksCooldownWindow() (gas: 82615)
[PASS] test_timeUntilNext_zeroBeforeFirstClaim() (gas: 10099)
[PASS] test_unpause_revertsOnNonPauser() (gas: 43483)
[PASS] test_withdraw_revertsOnInsufficientBalance() (gas: 26877)
[PASS] test_withdraw_revertsOnNonGovernance() (gas: 17089)
[PASS] test_withdraw_revertsOnZeroAmount() (gas: 20838)
[PASS] test_withdraw_revertsOnZeroTo() (gas: 18662)
[PASS] test_withdraw_transfersAndEmits() (gas: 44129)
[PASS] test_withdraw_worksWhilePaused() (gas: 68286)
Suite result: ok. 44 passed; 0 failed; 0 skipped; finished in 253.68ms (252.01ms CPU time)

Ran 10 tests for test/Token.t.sol:TokenTest
[PASS] testFuzz_burn_reducesSupplyByExactAmount(uint256) (runs: 1024, μ: 27781, ~: 27700)
[PASS] test_burnFrom_consumesAllowance() (gas: 38534)
[PASS] test_burn_reducesTotalSupplyAndBalance() (gas: 26044)
[PASS] test_constructor_metadata() (gas: 17896)
[PASS] test_constructor_mintsFullSupplyToHolder() (gas: 12954)
[PASS] test_constructor_revertsOnZeroInitialHolder() (gas: 83264)
[PASS] test_constructor_totalSupplyConstantMatches() (gas: 9364)
[PASS] test_noMintFunctionExposed() (gas: 10765)
[PASS] test_noVotesSurfaceExposed() (gas: 11991)
[PASS] test_permit_setsAllowance() (gas: 67380)
Suite result: ok. 10 passed; 0 failed; 0 skipped; finished in 91.64ms (89.11ms CPU time)

Ran 26 tests for test/PublisherRegistry.t.sol:PublisherRegistryTest
[PASS] testFuzz_createNamespace_idsAreSequentialAndOwned(uint8) (runs: 1024, μ: 692676, ~: 315839)
[PASS] test_claimContent_multiClaimAcrossNamespaces() (gas: 233820)
[PASS] test_claimContent_recordsClaim() (gas: 134733)
[PASS] test_claimContent_revertsForDefaultOpenNamespace() (gas: 13756)
[PASS] test_claimContent_revertsIfNotOwner() (gas: 66829)
[PASS] test_claimContent_revertsOnDuplicateSameNamespace() (gas: 135341)
[PASS] test_constructor_revertsZeroAdmin() (gas: 36674)
[PASS] test_constructor_setsDefaultsAndRoles() (gas: 19037)
[PASS] test_createNamespace_assignsIdsFromOne() (gas: 92750)
[PASS] test_createNamespace_revertsAtCap() (gas: 98492)
[PASS] test_createNamespace_zeroIsNeverAssigned() (gas: 65471)
[PASS] test_namespaceOf_emptyForUnclaimed() (gas: 8273)
[PASS] test_setMaxNamespaces_revertsOutOfBounds() (gas: 17627)
[PASS] test_setMaxNamespaces_revertsWithoutRole() (gas: 13384)
[PASS] test_setMaxNamespaces_withinBounds() (gas: 20687)
[PASS] test_setTransferTimelock_revertsOutOfBounds() (gas: 17706)
[PASS] test_setTransferTimelock_withinBounds() (gas: 20560)
[PASS] test_transfer_cancelByOwner() (gas: 78690)
[PASS] test_transfer_cancelRevertsIfNotOwner() (gas: 93302)
[PASS] test_transfer_finalizeRevertsIfNotPendingOwner() (gas: 93817)
[PASS] test_transfer_finalizeRevertsNoPending() (gas: 68566)
[PASS] test_transfer_fullFlow() (gas: 98658)
[PASS] test_transfer_initiateRevertsIfNotOwner() (gas: 66923)
[PASS] test_transfer_initiateRevertsZeroNewOwner() (gas: 64330)
[PASS] test_transfer_revertsWhenRecipientAtCap() (gas: 150145)
[PASS] test_transfer_selfTransferExemptFromCap() (gas: 95404)
Suite result: ok. 26 passed; 0 failed; 0 skipped; finished in 754.10ms (753.05ms CPU time)

Ran 60 tests for test/StakingRegistry.t.sol:StakingRegistryTest
[PASS] testFuzz_slash_threeLegsSumToSlashAmount(uint256) (runs: 1024, μ: 267872, ~: 267920)
[PASS] test_constructor_revertsOnOutOfBoundsMaxMultiaddrSize() (gas: 135651)
[PASS] test_constructor_revertsOnOutOfBoundsMinStake() (gas: 135082)
[PASS] test_constructor_revertsOnOutOfBoundsMultiaddrCooldown() (gas: 73167)
[PASS] test_constructor_revertsOnOutOfBoundsUnbondingPeriod() (gas: 135314)
[PASS] test_constructor_revertsOnZeroAdmin() (gas: 70797)
[PASS] test_constructor_revertsOnZeroToken() (gas: 70713)
[PASS] test_constructor_revertsOnZeroVerifier() (gas: 70770)
[PASS] test_constructor_setsImmutableAndState() (gas: 32980)
[PASS] test_deregisterNode_flipsFlagAndRemovesFromActiveSet() (gas: 358561)
[PASS] test_deregisterNode_revertsWhenNotActive() (gas: 20335)
[PASS] test_ejectNode_flipsBothFlagsWhenRegistered() (gas: 378376)
[PASS] test_ejectNode_revertsWithoutBlacklistRole() (gas: 13021)
[PASS] test_ejectNode_unregisteredOperator_onlySetsFlag() (gas: 117207)
[PASS] test_getActiveNodes_paginationBounds() (gas: 985168)
[PASS] test_isActive_falseWhenAnyStakeInUnbonding() (gas: 425144)
[PASS] test_isActive_requiresStakeAndRegistration() (gas: 426286)
[PASS] test_reRegisterSameNodeId_afterDeregister_works() (gas: 425528)
[PASS] test_recordSettlement_revertsWithoutReporterRole() (gas: 13113)
[PASS] test_recordSettlement_updatesTimestamp() (gas: 39691)
[PASS] test_registerNode_happyPath() (gas: 426051)
[PASS] test_registerNode_revertsBelowMinStake() (gas: 114051)
[PASS] test_registerNode_revertsOnAlreadyRegistered() (gas: 380238)
[PASS] test_registerNode_revertsOnBadBindingSignature() (gas: 124858)
[PASS] test_registerNode_revertsOnNodeIdBoundToOther() (gas: 428422)
[PASS] test_registerNode_revertsOnRejectedEd25519Signature() (gas: 135964)
[PASS] test_registerNode_revertsOnZeroNodeId() (gas: 110265)
[PASS] test_registerNode_revertsWhenEjected() (gas: 138598)
[PASS] test_registerNode_revertsWhenMultiaddrsTooLarge() (gas: 112644)
[PASS] test_registerNode_revertsWhenRegionHintTooLong() (gas: 112471)
[PASS] test_requestUnstake_movesAmountToUnbonding() (gas: 137388)
[PASS] test_requestUnstake_revertsOnInflightRequest() (gas: 140031)
[PASS] test_requestUnstake_revertsOnInsufficientStake() (gas: 89163)
[PASS] test_setMaxMultiaddrSize_withinBounds() (gas: 20363)
[PASS] test_setMinStake_revertsOutOfBounds() (gas: 17669)
[PASS] test_setMinStake_withinBoundsSucceeds() (gas: 20300)
[PASS] test_setUnbondingPeriod_revertsOutOfBounds() (gas: 17636)
[PASS] test_slashAutoEject_bumpsRegistrationNonce() (gas: 541093)
[PASS] test_slash_appliesToActivePlusUnbonding() (gas: 307811)
[PASS] test_slash_autoEjectAlsoFlipsNodeActive() (gas: 585356)
[PASS] test_slash_distributes50_30_20() (gas: 266908)
[PASS] test_slash_drawsFromUnbondingWhenActiveInsufficient() (gas: 312619)
[PASS] test_slash_notifiesSafetyReserve() (gas: 262234)
[PASS] test_slash_revertsOnZeroChallenger() (gas: 93086)
[PASS] test_slash_revertsWhenSafetyReserveNotWired() (gas: 102931)
[PASS] test_slash_revertsWithoutSlashRole() (gas: 92662)
[PASS] test_slash_tier1_is5Percent() (gas: 259268)
[PASS] test_slash_tier2_is15Percent() (gas: 323795)
[PASS] test_slash_tier3Stays50PercentBeyondThird() (gas: 522430)
[PASS] test_slash_tier3_is50Percent() (gas: 389479)
[PASS] test_stake_addsToActiveStake() (gas: 87111)
[PASS] test_stake_clearsEjectedFlagWhenRestakedToMinimum() (gas: 137631)
[PASS] test_stake_revertsOnZeroAmount() (gas: 18288)
[PASS] test_stake_revertsWhenPaused() (gas: 45244)
[PASS] test_unstake_returnsTokensAfterUnbonding() (gas: 135725)
[PASS] test_unstake_revertsBeforeUnbondingComplete() (gas: 128481)
[PASS] test_unstake_revertsWithNoRequest() (gas: 22517)
[PASS] test_updateMultiaddrs_replacesAndStampsTimestamp() (gas: 404234)
[PASS] test_updateMultiaddrs_respectsCooldown() (gas: 426564)
[PASS] test_updateMultiaddrs_revertsWhenNotActive() (gas: 15622)
Suite result: ok. 60 passed; 0 failed; 0 skipped; finished in 274.49ms (272.15ms CPU time)

Ran 30 tests for test/VotingEscrow.t.sol:VotingEscrowTest
[PASS] testFuzz_balanceOf_neverExceedsAmount_decaysMonotonically(uint256,uint256,uint256) (runs: 1024, μ: 2999738, ~: 2999794)
[PASS] testFuzz_totalSupplyMatchesSum(uint256,uint256,uint256,uint256,uint256) (runs: 1024, μ: 3389820, ~: 3312925)
[PASS] test_balanceOfAt_historical() (gas: 2997904)
[PASS] test_balanceOfAt_revertsFutureLookup() (gas: 2992234)
[PASS] test_balanceOf_decaysLinearlyToZero() (gas: 3008821)
[PASS] test_balanceOf_zeroForNeverLocked() (gas: 10164)
[PASS] test_constructor_revertsBadDurations() (gas: 126152)
[PASS] test_constructor_revertsMaxLockExceedsWalkCap() (gas: 1713697)
[PASS] test_constructor_revertsZeroToken() (gas: 64692)
[PASS] test_constructor_setsState() (gas: 15440)
[PASS] test_createLock_locksAndSetsWeight() (gas: 2996643)
[PASS] test_createLock_revertsAboveMaxDuration() (gas: 51400)
[PASS] test_createLock_revertsBelowMinDuration() (gas: 51231)
[PASS] test_createLock_revertsExistingLock() (gas: 3019383)
[PASS] test_createLock_revertsZeroAmount() (gas: 18380)
[PASS] test_createLock_weekAligned() (gas: 2990616)
[PASS] test_increaseAmount_raisesWeight() (gas: 3110971)
[PASS] test_increaseAmount_revertsNoLock() (gas: 20476)
[PASS] test_increaseUnlockTime_extendsAndRaisesWeight() (gas: 3101851)
[PASS] test_increaseUnlockTime_revertsAboveMax() (gas: 2996215)
[PASS] test_increaseUnlockTime_revertsNotInFuture() (gas: 2996294)
[PASS] test_noTransferSurface() (gas: 2995268)
[PASS] test_pause_blocksCreateLock() (gas: 75658)
[PASS] test_totalSupplyAt_revertsFutureLookup() (gas: 9014)
[PASS] test_totalSupplyAt_zeroBeforeGenesis() (gas: 2993507)
[PASS] test_totalSupply_currentMatchesSum() (gas: 3279374)
[PASS] test_totalSupply_equalsSumOfBalances_multipleLocks() (gas: 4790797)
[PASS] test_withdraw_afterExpiry() (gas: 5477775)
[PASS] test_withdraw_revertsBeforeExpiry() (gas: 2995832)
[PASS] test_withdraw_revertsNoLock() (gas: 20423)
Suite result: ok. 30 passed; 0 failed; 0 skipped; finished in 2.32s (2.35s CPU time)

Ran 5 test suites in 2.68s (3.70s CPU time): 170 tests passed, 0 failed, 0 skipped (170 total tests)
━ PublisherRegistryTest::test_claimContent_multiClaimAcrossNamespaces() (gas: 233820 → 233820 | 0 0.000%)
━ PublisherRegistryTest::test_claimContent_recordsClaim() (gas: 134733 → 134733 | 0 0.000%)
━ PublisherRegistryTest::test_claimContent_revertsForDefaultOpenNamespace() (gas: 13756 → 13756 | 0 0.000%)
━ PublisherRegistryTest::test_claimContent_revertsIfNotOwner() (gas: 66829 → 66829 | 0 0.000%)
━ PublisherRegistryTest::test_claimContent_revertsOnDuplicateSameNamespace() (gas: 135341 → 135341 | 0 0.000%)
━ PublisherRegistryTest::test_constructor_revertsZeroAdmin() (gas: 36674 → 36674 | 0 0.000%)
━ PublisherRegistryTest::test_constructor_setsDefaultsAndRoles() (gas: 19037 → 19037 | 0 0.000%)
━ PublisherRegistryTest::test_createNamespace_assignsIdsFromOne() (gas: 92750 → 92750 | 0 0.000%)
━ PublisherRegistryTest::test_createNamespace_revertsAtCap() (gas: 98492 → 98492 | 0 0.000%)
━ PublisherRegistryTest::test_createNamespace_zeroIsNeverAssigned() (gas: 65471 → 65471 | 0 0.000%)
━ PublisherRegistryTest::test_namespaceOf_emptyForUnclaimed() (gas: 8273 → 8273 | 0 0.000%)
━ PublisherRegistryTest::test_setMaxNamespaces_revertsOutOfBounds() (gas: 17627 → 17627 | 0 0.000%)
━ PublisherRegistryTest::test_setMaxNamespaces_revertsWithoutRole() (gas: 13384 → 13384 | 0 0.000%)
━ PublisherRegistryTest::test_setMaxNamespaces_withinBounds() (gas: 20687 → 20687 | 0 0.000%)
━ PublisherRegistryTest::test_setTransferTimelock_revertsOutOfBounds() (gas: 17706 → 17706 | 0 0.000%)
━ PublisherRegistryTest::test_setTransferTimelock_withinBounds() (gas: 20560 → 20560 | 0 0.000%)
━ PublisherRegistryTest::test_transfer_cancelByOwner() (gas: 78690 → 78690 | 0 0.000%)
━ PublisherRegistryTest::test_transfer_cancelRevertsIfNotOwner() (gas: 93302 → 93302 | 0 0.000%)
━ PublisherRegistryTest::test_transfer_finalizeRevertsIfNotPendingOwner() (gas: 93817 → 93817 | 0 0.000%)
━ PublisherRegistryTest::test_transfer_finalizeRevertsNoPending() (gas: 68566 → 68566 | 0 0.000%)
━ PublisherRegistryTest::test_transfer_fullFlow() (gas: 98658 → 98658 | 0 0.000%)
━ PublisherRegistryTest::test_transfer_initiateRevertsIfNotOwner() (gas: 66923 → 66923 | 0 0.000%)
━ PublisherRegistryTest::test_transfer_initiateRevertsZeroNewOwner() (gas: 64330 → 64330 | 0 0.000%)
━ PublisherRegistryTest::test_transfer_revertsWhenRecipientAtCap() (gas: 150145 → 150145 | 0 0.000%)
━ PublisherRegistryTest::test_transfer_selfTransferExemptFromCap() (gas: 95404 → 95404 | 0 0.000%)
━ StakingRegistryTest::testFuzz_slash_threeLegsSumToSlashAmount(uint256) (gas: 267920 → 267920 | 0 0.000%)
━ StakingRegistryTest::test_constructor_revertsOnOutOfBoundsMaxMultiaddrSize() (gas: 135651 → 135651 | 0 0.000%)
━ StakingRegistryTest::test_constructor_revertsOnOutOfBoundsMinStake() (gas: 135082 → 135082 | 0 0.000%)
━ StakingRegistryTest::test_constructor_revertsOnOutOfBoundsMultiaddrCooldown() (gas: 73167 → 73167 | 0 0.000%)
━ StakingRegistryTest::test_constructor_revertsOnOutOfBoundsUnbondingPeriod() (gas: 135314 → 135314 | 0 0.000%)
━ StakingRegistryTest::test_constructor_revertsOnZeroAdmin() (gas: 70797 → 70797 | 0 0.000%)
━ StakingRegistryTest::test_constructor_revertsOnZeroToken() (gas: 70713 → 70713 | 0 0.000%)
━ StakingRegistryTest::test_constructor_revertsOnZeroVerifier() (gas: 70770 → 70770 | 0 0.000%)
━ StakingRegistryTest::test_constructor_setsImmutableAndState() (gas: 32980 → 32980 | 0 0.000%)
━ StakingRegistryTest::test_deregisterNode_flipsFlagAndRemovesFromActiveSet() (gas: 358561 → 358561 | 0 0.000%)
━ StakingRegistryTest::test_deregisterNode_revertsWhenNotActive() (gas: 20335 → 20335 | 0 0.000%)
━ StakingRegistryTest::test_ejectNode_flipsBothFlagsWhenRegistered() (gas: 378376 → 378376 | 0 0.000%)
━ StakingRegistryTest::test_ejectNode_revertsWithoutBlacklistRole() (gas: 13021 → 13021 | 0 0.000%)
━ StakingRegistryTest::test_ejectNode_unregisteredOperator_onlySetsFlag() (gas: 117207 → 117207 | 0 0.000%)
━ StakingRegistryTest::test_getActiveNodes_paginationBounds() (gas: 985168 → 985168 | 0 0.000%)
━ StakingRegistryTest::test_isActive_falseWhenAnyStakeInUnbonding() (gas: 425144 → 425144 | 0 0.000%)
━ StakingRegistryTest::test_isActive_requiresStakeAndRegistration() (gas: 426286 → 426286 | 0 0.000%)
━ StakingRegistryTest::test_reRegisterSameNodeId_afterDeregister_works() (gas: 425528 → 425528 | 0 0.000%)
━ StakingRegistryTest::test_recordSettlement_revertsWithoutReporterRole() (gas: 13113 → 13113 | 0 0.000%)
━ StakingRegistryTest::test_recordSettlement_updatesTimestamp() (gas: 39691 → 39691 | 0 0.000%)
━ StakingRegistryTest::test_registerNode_happyPath() (gas: 426051 → 426051 | 0 0.000%)
━ StakingRegistryTest::test_registerNode_revertsBelowMinStake() (gas: 114051 → 114051 | 0 0.000%)
━ StakingRegistryTest::test_registerNode_revertsOnAlreadyRegistered() (gas: 380238 → 380238 | 0 0.000%)
━ StakingRegistryTest::test_registerNode_revertsOnBadBindingSignature() (gas: 124858 → 124858 | 0 0.000%)
━ StakingRegistryTest::test_registerNode_revertsOnNodeIdBoundToOther() (gas: 428422 → 428422 | 0 0.000%)
━ StakingRegistryTest::test_registerNode_revertsOnRejectedEd25519Signature() (gas: 135964 → 135964 | 0 0.000%)
━ StakingRegistryTest::test_registerNode_revertsOnZeroNodeId() (gas: 110265 → 110265 | 0 0.000%)
━ StakingRegistryTest::test_registerNode_revertsWhenEjected() (gas: 138598 → 138598 | 0 0.000%)
━ StakingRegistryTest::test_registerNode_revertsWhenMultiaddrsTooLarge() (gas: 112644 → 112644 | 0 0.000%)
━ StakingRegistryTest::test_registerNode_revertsWhenRegionHintTooLong() (gas: 112471 → 112471 | 0 0.000%)
━ StakingRegistryTest::test_requestUnstake_movesAmountToUnbonding() (gas: 137388 → 137388 | 0 0.000%)
━ StakingRegistryTest::test_requestUnstake_revertsOnInflightRequest() (gas: 140031 → 140031 | 0 0.000%)
━ StakingRegistryTest::test_requestUnstake_revertsOnInsufficientStake() (gas: 89163 → 89163 | 0 0.000%)
━ StakingRegistryTest::test_setMaxMultiaddrSize_withinBounds() (gas: 20363 → 20363 | 0 0.000%)
━ StakingRegistryTest::test_setMinStake_revertsOutOfBounds() (gas: 17669 → 17669 | 0 0.000%)
━ StakingRegistryTest::test_setMinStake_withinBoundsSucceeds() (gas: 20300 → 20300 | 0 0.000%)
━ StakingRegistryTest::test_setUnbondingPeriod_revertsOutOfBounds() (gas: 17636 → 17636 | 0 0.000%)
━ StakingRegistryTest::test_slashAutoEject_bumpsRegistrationNonce() (gas: 541093 → 541093 | 0 0.000%)
━ StakingRegistryTest::test_slash_appliesToActivePlusUnbonding() (gas: 307811 → 307811 | 0 0.000%)
━ StakingRegistryTest::test_slash_autoEjectAlsoFlipsNodeActive() (gas: 585356 → 585356 | 0 0.000%)
━ StakingRegistryTest::test_slash_distributes50_30_20() (gas: 266908 → 266908 | 0 0.000%)
━ StakingRegistryTest::test_slash_drawsFromUnbondingWhenActiveInsufficient() (gas: 312619 → 312619 | 0 0.000%)
━ StakingRegistryTest::test_slash_notifiesSafetyReserve() (gas: 262234 → 262234 | 0 0.000%)
━ StakingRegistryTest::test_slash_revertsOnZeroChallenger() (gas: 93086 → 93086 | 0 0.000%)
━ StakingRegistryTest::test_slash_revertsWhenSafetyReserveNotWired() (gas: 102931 → 102931 | 0 0.000%)
━ StakingRegistryTest::test_slash_revertsWithoutSlashRole() (gas: 92662 → 92662 | 0 0.000%)
━ StakingRegistryTest::test_slash_tier1_is5Percent() (gas: 259268 → 259268 | 0 0.000%)
━ StakingRegistryTest::test_slash_tier2_is15Percent() (gas: 323795 → 323795 | 0 0.000%)
━ StakingRegistryTest::test_slash_tier3Stays50PercentBeyondThird() (gas: 522430 → 522430 | 0 0.000%)
━ StakingRegistryTest::test_slash_tier3_is50Percent() (gas: 389479 → 389479 | 0 0.000%)
━ StakingRegistryTest::test_stake_addsToActiveStake() (gas: 87111 → 87111 | 0 0.000%)
━ StakingRegistryTest::test_stake_clearsEjectedFlagWhenRestakedToMinimum() (gas: 137631 → 137631 | 0 0.000%)
━ StakingRegistryTest::test_stake_revertsOnZeroAmount() (gas: 18288 → 18288 | 0 0.000%)
━ StakingRegistryTest::test_stake_revertsWhenPaused() (gas: 45244 → 45244 | 0 0.000%)
━ StakingRegistryTest::test_unstake_returnsTokensAfterUnbonding() (gas: 135725 → 135725 | 0 0.000%)
━ StakingRegistryTest::test_unstake_revertsBeforeUnbondingComplete() (gas: 128481 → 128481 | 0 0.000%)
━ StakingRegistryTest::test_unstake_revertsWithNoRequest() (gas: 22517 → 22517 | 0 0.000%)
━ StakingRegistryTest::test_updateMultiaddrs_replacesAndStampsTimestamp() (gas: 404234 → 404234 | 0 0.000%)
━ StakingRegistryTest::test_updateMultiaddrs_respectsCooldown() (gas: 426564 → 426564 | 0 0.000%)
━ StakingRegistryTest::test_updateMultiaddrs_revertsWhenNotActive() (gas: 15622 → 15622 | 0 0.000%)
━ TestnetFaucetTest::testFuzz_claim_atOrAboveCooldown(uint256) (gas: 91528 → 91528 | 0 0.000%)
━ TestnetFaucetTest::testFuzz_claim_belowCooldown(uint256) (gas: 85389 → 85389 | 0 0.000%)
━ TestnetFaucetTest::test_admin_canGrantAndRevokeRoles() (gas: 56401 → 56401 | 0 0.000%)
━ TestnetFaucetTest::test_claim_blocksReentrancy() (gas: 1550228 → 1550228 | 0 0.000%)
━ TestnetFaucetTest::test_claim_happyPath() (gas: 82821 → 82821 | 0 0.000%)
━ TestnetFaucetTest::test_claim_perCallerCooldownIndependence() (gas: 133478 → 133478 | 0 0.000%)
━ TestnetFaucetTest::test_claim_revertsBeforeCooldown() (gas: 83092 → 83092 | 0 0.000%)
━ TestnetFaucetTest::test_claim_revertsOnInsufficientBalance() (gas: 50715 → 50715 | 0 0.000%)
━ TestnetFaucetTest::test_claim_revertsOneSecondBeforeCooldownBoundary() (gas: 82996 → 82996 | 0 0.000%)
━ TestnetFaucetTest::test_claim_revertsWhenPaused() (gas: 39998 → 39998 | 0 0.000%)
━ TestnetFaucetTest::test_claim_succeedsAfterCooldown() (gas: 90430 → 90430 | 0 0.000%)
━ TestnetFaucetTest::test_claim_succeedsAtExactCooldownBoundary() (gas: 87103 → 87103 | 0 0.000%)
━ TestnetFaucetTest::test_constructor_allowsZeroCooldown() (gas: 1810378 → 1810378 | 0 0.000%)
━ TestnetFaucetTest::test_constructor_revertsOnCooldownExceedingMax() (gas: 1015061 → 1015061 | 0 0.000%)
━ TestnetFaucetTest::test_constructor_revertsOnMainnetChainId() (gas: 988198 → 988198 | 0 0.000%)
━ TestnetFaucetTest::test_constructor_revertsOnZeroAdmin() (gas: 985898 → 985898 | 0 0.000%)
━ TestnetFaucetTest::test_constructor_revertsOnZeroClaimAmount() (gas: 988045 → 988045 | 0 0.000%)
━ TestnetFaucetTest::test_constructor_revertsOnZeroFunding() (gas: 988061 → 988061 | 0 0.000%)
━ TestnetFaucetTest::test_constructor_revertsOnZeroGovernance() (gas: 985864 → 985864 | 0 0.000%)
━ TestnetFaucetTest::test_constructor_revertsOnZeroPauser() (gas: 985954 → 985954 | 0 0.000%)
━ TestnetFaucetTest::test_constructor_revertsOnZeroTokenAddress() (gas: 70468 → 70468 | 0 0.000%)
━ TestnetFaucetTest::test_constructor_revertsOnZeroTreasury() (gas: 987830 → 987830 | 0 0.000%)
━ TestnetFaucetTest::test_constructor_revertsWhenTreasuryNotApproved() (gas: 1110690 → 1110690 | 0 0.000%)
━ TestnetFaucetTest::test_constructor_setsStateAndRoles() (gas: 43070 → 43070 | 0 0.000%)
━ TestnetFaucetTest::test_nonAdmin_cannotGrantRoles() (gas: 17889 → 17889 | 0 0.000%)
━ TestnetFaucetTest::test_pause_blocksClaimUnpauseRestores() (gas: 91691 → 91691 | 0 0.000%)
━ TestnetFaucetTest::test_pause_revertsOnNonPauser() (gas: 14607 → 14607 | 0 0.000%)
━ TestnetFaucetTest::test_setClaimAmount_revertsOnNonGovernance() (gas: 14702 → 14702 | 0 0.000%)
━ TestnetFaucetTest::test_setClaimAmount_revertsOnZero() (gas: 13338 → 13338 | 0 0.000%)
━ TestnetFaucetTest::test_setClaimAmount_updatesAndEmits() (gas: 22083 → 22083 | 0 0.000%)
━ TestnetFaucetTest::test_setCooldown_acceptsMaxCooldown() (gas: 20228 → 20228 | 0 0.000%)
━ TestnetFaucetTest::test_setCooldown_allowsZero() (gas: 94920 → 94920 | 0 0.000%)
━ TestnetFaucetTest::test_setCooldown_revertsOnExceedingMax() (gas: 13790 → 13790 | 0 0.000%)
━ TestnetFaucetTest::test_setCooldown_revertsOnNonGovernance() (gas: 14705 → 14705 | 0 0.000%)
━ TestnetFaucetTest::test_setCooldown_updatesAndEmits() (gas: 22231 → 22231 | 0 0.000%)
━ TestnetFaucetTest::test_timeUntilNext_tracksCooldownWindow() (gas: 82615 → 82615 | 0 0.000%)
━ TestnetFaucetTest::test_timeUntilNext_zeroBeforeFirstClaim() (gas: 10099 → 10099 | 0 0.000%)
━ TestnetFaucetTest::test_unpause_revertsOnNonPauser() (gas: 43483 → 43483 | 0 0.000%)
━ TestnetFaucetTest::test_withdraw_revertsOnInsufficientBalance() (gas: 26877 → 26877 | 0 0.000%)
━ TestnetFaucetTest::test_withdraw_revertsOnNonGovernance() (gas: 17089 → 17089 | 0 0.000%)
━ TestnetFaucetTest::test_withdraw_revertsOnZeroAmount() (gas: 20838 → 20838 | 0 0.000%)
━ TestnetFaucetTest::test_withdraw_revertsOnZeroTo() (gas: 18662 → 18662 | 0 0.000%)
━ TestnetFaucetTest::test_withdraw_transfersAndEmits() (gas: 44129 → 44129 | 0 0.000%)
━ TestnetFaucetTest::test_withdraw_worksWhilePaused() (gas: 68286 → 68286 | 0 0.000%)
━ TokenTest::testFuzz_burn_reducesSupplyByExactAmount(uint256) (gas: 27700 → 27700 | 0 0.000%)
━ TokenTest::test_burnFrom_consumesAllowance() (gas: 38534 → 38534 | 0 0.000%)
━ TokenTest::test_burn_reducesTotalSupplyAndBalance() (gas: 26044 → 26044 | 0 0.000%)
━ TokenTest::test_constructor_metadata() (gas: 17896 → 17896 | 0 0.000%)
━ TokenTest::test_constructor_mintsFullSupplyToHolder() (gas: 12954 → 12954 | 0 0.000%)
━ TokenTest::test_constructor_revertsOnZeroInitialHolder() (gas: 83264 → 83264 | 0 0.000%)
━ TokenTest::test_constructor_totalSupplyConstantMatches() (gas: 9364 → 9364 | 0 0.000%)
━ TokenTest::test_noMintFunctionExposed() (gas: 10765 → 10765 | 0 0.000%)
━ TokenTest::test_noVotesSurfaceExposed() (gas: 11991 → 11991 | 0 0.000%)
━ TokenTest::test_permit_setsAllowance() (gas: 67380 → 67380 | 0 0.000%)
━ VotingEscrowTest::testFuzz_balanceOf_neverExceedsAmount_decaysMonotonically(uint256,uint256,uint256) (gas: 2999794 → 2999794 | 0 0.000%)
━ VotingEscrowTest::test_balanceOfAt_historical() (gas: 2997904 → 2997904 | 0 0.000%)
━ VotingEscrowTest::test_balanceOfAt_revertsFutureLookup() (gas: 2992234 → 2992234 | 0 0.000%)
━ VotingEscrowTest::test_balanceOf_decaysLinearlyToZero() (gas: 3008821 → 3008821 | 0 0.000%)
━ VotingEscrowTest::test_balanceOf_zeroForNeverLocked() (gas: 10164 → 10164 | 0 0.000%)
━ VotingEscrowTest::test_constructor_revertsBadDurations() (gas: 126152 → 126152 | 0 0.000%)
━ VotingEscrowTest::test_constructor_revertsMaxLockExceedsWalkCap() (gas: 1713697 → 1713697 | 0 0.000%)
━ VotingEscrowTest::test_constructor_revertsZeroToken() (gas: 64692 → 64692 | 0 0.000%)
━ VotingEscrowTest::test_constructor_setsState() (gas: 15440 → 15440 | 0 0.000%)
━ VotingEscrowTest::test_createLock_locksAndSetsWeight() (gas: 2996643 → 2996643 | 0 0.000%)
━ VotingEscrowTest::test_createLock_revertsAboveMaxDuration() (gas: 51400 → 51400 | 0 0.000%)
━ VotingEscrowTest::test_createLock_revertsBelowMinDuration() (gas: 51231 → 51231 | 0 0.000%)
━ VotingEscrowTest::test_createLock_revertsExistingLock() (gas: 3019383 → 3019383 | 0 0.000%)
━ VotingEscrowTest::test_createLock_revertsZeroAmount() (gas: 18380 → 18380 | 0 0.000%)
━ VotingEscrowTest::test_createLock_weekAligned() (gas: 2990616 → 2990616 | 0 0.000%)
━ VotingEscrowTest::test_increaseAmount_raisesWeight() (gas: 3110971 → 3110971 | 0 0.000%)
━ VotingEscrowTest::test_increaseAmount_revertsNoLock() (gas: 20476 → 20476 | 0 0.000%)
━ VotingEscrowTest::test_increaseUnlockTime_extendsAndRaisesWeight() (gas: 3101851 → 3101851 | 0 0.000%)
━ VotingEscrowTest::test_increaseUnlockTime_revertsAboveMax() (gas: 2996215 → 2996215 | 0 0.000%)
━ VotingEscrowTest::test_increaseUnlockTime_revertsNotInFuture() (gas: 2996294 → 2996294 | 0 0.000%)
━ VotingEscrowTest::test_noTransferSurface() (gas: 2995268 → 2995268 | 0 0.000%)
━ VotingEscrowTest::test_pause_blocksCreateLock() (gas: 75658 → 75658 | 0 0.000%)
━ VotingEscrowTest::test_totalSupplyAt_revertsFutureLookup() (gas: 9014 → 9014 | 0 0.000%)
━ VotingEscrowTest::test_totalSupplyAt_zeroBeforeGenesis() (gas: 2993507 → 2993507 | 0 0.000%)
━ VotingEscrowTest::test_totalSupply_currentMatchesSum() (gas: 3279374 → 3279374 | 0 0.000%)
━ VotingEscrowTest::test_totalSupply_equalsSumOfBalances_multipleLocks() (gas: 4790797 → 4790797 | 0 0.000%)
━ VotingEscrowTest::test_withdraw_afterExpiry() (gas: 5477775 → 5477775 | 0 0.000%)
━ VotingEscrowTest::test_withdraw_revertsBeforeExpiry() (gas: 2995832 → 2995832 | 0 0.000%)
━ VotingEscrowTest::test_withdraw_revertsNoLock() (gas: 20423 → 20423 | 0 0.000%)
↑ VotingEscrowTest::testFuzz_totalSupplyMatchesSum(uint256,uint256,uint256,uint256,uint256) (gas: 3303561 → 3312925 | 9364 0.283%)
↓ PublisherRegistryTest::testFuzz_createNamespace_idsAreSequentialAndOwned(uint8) (gas: 343666 → 315839 | -27827 -8.097%)

--------------------------------------------------------------------------------
Total tests: 170, ↑ 1, ↓ 1, ━ 168
Overall gas change: -18463 (-0.021%)

Run: 26289541293

@github-actions

github-actions Bot commented May 22, 2026 •

Copy link
Copy Markdown

Contracts coverage

Line coverage: 92.67% (518/559 lines)
▲ +0.83pp vs base (91.83% → 92.67%)
Run: 26289541293

@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 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.

Comment thread contracts/src/PublisherRegistry.sol Resolved
Comment thread contracts/src/PublisherRegistry.sol Resolved
Comment thread contracts/src/PublisherRegistry.sol Resolved
Comment thread contracts/src/PublisherRegistry.sol Resolved

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

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 PublisherRegistry contract implementing namespace creation, content claiming, and timelocked transfers with AccessControl-gated governance setters.
  • Adds PublisherRegistry.t.sol unit + 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.

Comment thread adr/016-contract-interactions.md Resolved
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]>
@alpergundogdu
alpergundogdu merged commit bae7104 into main May 22, 2026
19 checks passed
@alpergundogdu
alpergundogdu deleted the feat/contracts-publisher-registry branch May 22, 2026 13:11
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.

2 participants