Skip to content

refactor(contracts): remove SafetyReserve; escrow-on-slash + 5% bucket to burn - #708

Merged
thiras merged 3 commits into
mainfrom
refactor/remove-safety-reserve
May 29, 2026
Merged

thiras merged 3 commits into
mainfrom
refactor/remove-safety-reserve

Conversation

@thiras

@thiras thiras commented May 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Removes the SafetyReserve contract and its standing USDC insurance pool. Its only load-bearing job — slash restitution — is replaced by escrow-on-slash in CapacityBond (the slashed TOKEN is escrowed and refunded to the operator on a successful appeal, so no pool is needed), and the slash-appeal state machine moves to a new standalone SlashAppeal contract. The freed 5% FeeRouter bucket folds into buyback-and-burn (25%→30%).

This is the Option C + A decision: route the 5% safety bucket to burn, and adopt escrow-on-slash with delayed (finality-time) distribution.

Contract changes

  • Delete SafetyReserve.sol / ISafetyReserve.sol (+ test + mock) — 645 LOC of contract removed.
  • FeeRouter → three buckets [60/30/10] (operator / buyback / treasury). Dropped the safety bucket, safetyReserve/setSafetyReserve, ShareDestinations.safetyReserve; uint256[4]→uint256[3].
  • CapacityBond → escrow-on-slash:
    • slash() escrows the slashed TOKEN into a per-slashId record (escrowedTotal) — nothing is transferred or burned at slash time.
    • finalizeUnappealedSlash(slashId) — permissionless; after the 30-day filing window distributes 50% challenger / 50% burn.
    • SLASH_APPEAL_ROLE settle hooks markAppealOpen / settleAppealUpheld / settleAppealGranted (granted refunds the operator's escrowed TOKEN + internal _clearSlashedAtEpoch).
    • Removed the 30% safety redirect, the recordSlashInflow try/catch, and the SafetyReserveNotWired guard.
  • New SlashAppeal.sol (+ ISlashAppeal.sol, ICapacityBondSlashEscrow.sol): the slimmed appeal state machine (open/fastTrack/reject/grant/uphold/cleanup), TOKEN appeal bonds only — no USDC, pool, swap, or pending-claim queue. grant/uphold replace the confusing ratify/reverse naming.
  • Size: CapacityBond drops to 23,167 B (was 23,912) despite gaining escrow logic — the separate-contract choice keeps it comfortably under the 24 KB EIP-170 limit.

Verification

  • FOUNDRY_PROFILE=ci forge build --sizes --deny warnings — exit 0, all contracts < 24,576 B
  • forge fmt --check — clean
  • forge test — 257/257 pass (13 new SlashAppeal flow tests + new CapacityBond escrow-lifecycle tests)
  • aderyn — 0 high; slither — no medium+ (only the pre-existing low block-timestamp informational)
  • gas snapshot regenerated

ADR changes (single source of truth)

  • Retire ADR 032 + 033 to adr/_history/ with superseded-by headers.
  • Rewrite ADR 026 (split → 60/30/10, slashing → escrow-on-slash 50/50, recourse-gap note) and ADR 028 (escrow-refund-in-TOKEN, SlashAppeal contract surface).
  • Structural updates to ADR 016 (all 51 refs) and 009; cross-ref fixes in 003/008/014/018/031/036/architecture/glossary/appendices; updated decdn/CLAUDE.md ADR note.

Accepted scope reduction

Downtime / bad-data user recourse is no longer a protocol contract surface. It is handled, if ever needed, via the existing DAO Treasury through normal governance (no emergency-multisig fast-track); reputation (ADR 008) is the standing deterrent. ADR 026 documents this as an accepted, testnet-appropriate reduction that can be revisited before mainnet carries real customer SLAs.

Follow-up (separate repo, not in this PR)

finance/notebooks/_shared/params.py still carries fee_safety=0.05 / 25% burn and should be updated to the 60/30/10 split per the workspace single-source-of-truth rule, then affected notebooks re-run.

🤖 Generated with Claude Code

…t to burn

Removes the SafetyReserve contract and its standing USDC insurance pool.
Slash restitution is now handled by escrow-on-slash in CapacityBond, and the
slash-appeal state machine lives in a new standalone SlashAppeal contract.

Contracts:
- Delete SafetyReserve.sol / ISafetyReserve.sol (+ test + mock).
- FeeRouter: drop the 4th "safety" bucket; fold its 5% into buyback
  (25%->30%). Split is now 60/30/10, uint256[4]->uint256[3].
- CapacityBond: escrow-on-slash. slash() escrows the slashed TOKEN
  (escrowedTotal) instead of distributing it; add permissionless
  finalizeUnappealedSlash (50/50 challenger/burn after the 30-day window)
  and the SLASH_APPEAL_ROLE settle hooks markAppealOpen / settleAppealUpheld
  / settleAppealGranted (refund operator + internal _clearSlashedAtEpoch).
  Remove the 30% safety redirect, recordSlashInflow try/catch, and the
  SafetyReserveNotWired guard.
- New SlashAppeal.sol + ISlashAppeal.sol + ICapacityBondSlashEscrow.sol:
  open/fastTrack/reject/grant/uphold/cleanup; TOKEN appeal bonds only,
  no USDC/pool/swap/queue. grant/uphold replace the old ratify/reverse.
- CapacityBond drops to 23,167 B (was 23,912) despite gaining escrow logic.

Verification: forge build --sizes --deny warnings (all <24KB), forge fmt,
257/257 tests pass (new SlashAppeal + escrow-lifecycle coverage), aderyn 0
high, slither no medium+, gas snapshot regenerated.

ADRs (single source of truth):
- Retire 032 + 033 to _history/.
- Rewrite 026 (split 60/30/10, escrow-on-slash 50/50, recourse-gap note)
  and 028 (escrow-refund-in-TOKEN, SlashAppeal surface).
- Structural updates to 016 + 009; cross-ref fixes in 003/008/014/018/031/
  036/architecture/glossary/appendices; update decdn/CLAUDE.md ADR note.

Accepted scope reduction: downtime / bad-data user recourse is no longer a
protocol contract surface (DAO Treasury governance only); reputation
(ADR 008) is the standing deterrent.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings May 29, 2026 16:58
@github-actions

github-actions Bot commented May 29, 2026 •

Copy link
Copy Markdown

Contracts coverage

Line coverage: 83.62% (980/1172 lines)
▲ +1.95pp vs base (81.67% → 83.62%)
Run: 26651225936

@github-actions

github-actions Bot commented May 29, 2026 •

Copy link
Copy Markdown

Gas snapshot

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

Ran 18 tests for test/BuybackBurner.t.sol:BuybackBurnerTest
[PASS] test_constructor_grantsAdminAndGovernanceRoles() (gas: 14866)
[PASS] test_constructor_revertsOnZeroAdmin() (gas: 67810)
[PASS] test_constructor_revertsOnZeroToken() (gas: 67829)
[PASS] test_constructor_revertsOnZeroUsdc() (gas: 67793)
[PASS] test_executeBuyback_happyPath_burnsAndEmits() (gas: 105272)
[PASS] test_executeBuyback_revertsPoolNotWiredWhenPoolUnset() (gas: 840272)
[PASS] test_executeBuyback_revertsPoolNotWiredWhenVaultUnset() (gas: 840424)
[PASS] test_executeBuyback_revertsSwapNotImplementedWhenActualDeltaIsZero() (gas: 60069)
[PASS] test_executeBuyback_revertsSwapReportMismatch() (gas: 110981)
[PASS] test_executeBuyback_revertsWhenPaused() (gas: 73094)
[PASS] test_executeBuyback_revertsWithoutKeeperRole() (gas: 64298)
[PASS] test_executeBuyback_revertsZeroAmount() (gas: 20705)
[PASS] test_pause_revertsWithoutPauserRole() (gas: 11912)
[PASS] test_setPool_emitsUpdateEvent() (gas: 24953)
[PASS] test_setPool_revertsWithoutGovernanceRole() (gas: 12132)
[PASS] test_setVault_emitsUpdateEvent() (gas: 24896)
[PASS] test_setVault_revertsWithoutGovernanceRole() (gas: 12054)
[PASS] test_unpause_revertsWithoutPauserRole() (gas: 23849)
Suite result: ok. 18 passed; 0 failed; 0 skipped; finished in 4.37ms (3.52ms CPU time)

Ran 48 tests for test/CapacityBond.t.sol:CapacityBondTest
[PASS] test_appealGrant_unlocksClaimBeforeGateExpiry() (gas: 379365)
[PASS] test_claimVestedCredit_movesIntoActiveStake() (gas: 214266)
[PASS] test_claimVestedCredit_multiClaimFollowsLinearCurve() (gas: 218936)
[PASS] test_claimVestedCredit_revertsWhenNoActiveStake() (gas: 144400)
[PASS] test_claimVestedCredit_revertsWhenSlashedInWindow() (gas: 390764)
[PASS] test_claimVestedCredit_succeedsAfterSlashGateExpires() (gas: 393841)
[PASS] test_creditSlash_escrowsThenDistributes5050AtFinality() (gas: 406855)
[PASS] test_declaredMbps_storesValue() (gas: 37799)
[PASS] test_escrowHooks_requireSlashAppealRole() (gas: 14867)
[PASS] test_finalizeUnappealedSlash_distributes5050() (gas: 321851)
[PASS] test_firstBondedAt_immutableAcrossReBonds() (gas: 111402)
[PASS] test_firstBondedAt_setsOnFirstStake() (gas: 102556)
[PASS] test_forfeitUnvestedCredit_burnsWhenNoTreasury() (gas: 246115)
[PASS] test_forfeitUnvestedCredit_doesNotClawBackVestedUnclaimed() (gas: 281721)
[PASS] test_forfeitUnvestedCredit_onUnbond() (gas: 290488)
[PASS] test_genesisCredit_fullVestAfterDuration() (gas: 141232)
[PASS] test_genesisCredit_grantWithinWindow() (gas: 139077)
[PASS] test_genesisCredit_revertsAfterWindow() (gas: 82768)
[PASS] test_genesisCredit_vestsLinearly() (gas: 141534)
[PASS] test_markAppealOpen_blocksFinalize() (gas: 294979)
[PASS] test_pause_revertsWithoutRole() (gas: 14812)
[PASS] test_pendingCreditSlash_reducesOriginalGrant() (gas: 384877)
[PASS] test_reduceStakeAtTier_remainderClip() (gas: 4950010)
[PASS] test_reduceStakeAtTier_unbondingOnly() (gas: 4969820)
[PASS] test_registerNode_revertsOnInvalidEd25519Sig() (gas: 169259)
[PASS] test_registerNode_revertsWhenAlreadyActive() (gas: 376581)
[PASS] test_setClaimSlashGateEpochs_revertsWithoutRole() (gas: 14934)
[PASS] test_setMaxMultiaddrSize_revertsWithoutRole() (gas: 14823)
[PASS] test_setMinStake_revertsWithoutRole() (gas: 14792)
[PASS] test_setMultiaddrUpdateCooldown_revertsWithoutRole() (gas: 14844)
[PASS] test_setRegionStabilityWindow_revertsWithoutRole() (gas: 14822)
[PASS] test_setTreasury_revertsWithoutRole() (gas: 14925)
[PASS] test_setUnbondingPeriod_revertsWithoutRole() (gas: 14869)
[PASS] test_settleAppealGranted_clearsAndRefunds() (gas: 269662)
[PASS] test_settleAppealUpheld_distributes5050() (gas: 316308)
[PASS] test_slashHitsVestedAndUnvestedTogether() (gas: 428003)
[PASS] test_slashHitsVestedButUnclaimed() (gas: 395382)
[PASS] test_slashId_persistsRecord() (gas: 286634)
[PASS] test_slash_creditSlash_escalatesAcrossTiers() (gas: 527072)
[PASS] test_slash_escrowsWithoutDistribution() (gas: 297637)
[PASS] test_slash_stampsSlashedAtEpoch() (gas: 286483)
[PASS] test_slash_tier3_mixedStake_exhaustsActiveTapsUnbonding() (gas: 508263)
[PASS] test_slash_tierEscalation_15then50pct() (gas: 467444)
[PASS] test_slashedAtEpoch_zeroBeforeSlash() (gas: 10158)
[PASS] test_unpause_revertsWithoutRole() (gas: 72514)
[PASS] test_updateMultiaddrs_revertsWhenNodeNotActive() (gas: 15679)
[PASS] test_updateRegion_cooldownAndPrevSnapshot() (gas: 447956)
[PASS] test_updateRegion_revertsWhenNodeNotActive() (gas: 15675)
Suite result: ok. 48 passed; 0 failed; 0 skipped; finished in 21.11ms (17.50ms CPU time)

Ran 18 tests for test/ContentBlacklist.t.sol:ContentBlacklistTest
[PASS] test_addHashGlobal_andQuery() (gas: 38191)
[PASS] test_addHashGlobal_revertsWithoutGovernanceRole() (gas: 14608)
[PASS] test_addHashRegional_globalTakesPrecedence() (gas: 41980)
[PASS] test_addHashRegional_revertsWithoutRegionalBodyRole() (gas: 14684)
[PASS] test_addOperator_callsEjectOnCapacityBond() (gas: 91570)
[PASS] test_fullAppealFlow_ratifyRemovesHash() (gas: 275665)
[PASS] test_hasActiveAppeal_clearedOnLapseOpen() (gas: 242221)
[PASS] test_hasActiveAppeal_clearedOnReject() (gas: 433926)
[PASS] test_hasActiveAppeal_clearedOnReverse() (gas: 254985)
[PASS] test_openBlacklistAppeal_revertsDuplicatePerHash() (gas: 356697)
[PASS] test_openBlacklistAppeal_revertsOnEntryNotBlacklisted() (gas: 18635)
[PASS] test_openBlacklistAppeal_revertsOnZeroRegion() (gas: 16243)
[PASS] test_regionalCap_blocksMoreThanThreeActiveAppeals() (gas: 706667)
[PASS] test_registerRegionalBody_revertsWithoutGovernanceRole() (gas: 14830)
[PASS] test_rejectAppeal_burnsBond() (gas: 247882)
[PASS] test_removeHashRegional_blocksGlobalRegionEntries() (gas: 44419)
[PASS] test_reverseAppeal_clearsSuspendedAndBurnsBond() (gas: 261664)
[PASS] test_setAppealBond_revertsWithoutGovernanceRole() (gas: 14754)
Suite result: ok. 18 passed; 0 failed; 0 skipped; finished in 2.88ms (2.18ms CPU time)

Ran 13 tests for test/DecdnGovernor.t.sol:DecdnGovernorTest
[PASS] test_ageRampMonthsAt_preservesPriorReadAfterLaterPush() (gas: 4104760)
[PASS] test_getVotes_halfRamp() (gas: 173099)
[PASS] test_getVotes_historicalSnapshotIgnoresFutureSlash() (gas: 221405)
[PASS] test_getVotes_ramp() (gas: 173020)
[PASS] test_getVotes_recoversAfterWindowSlidesPastSlash() (gas: 196808)
[PASS] test_getVotes_uncappedWhenBelowCap() (gas: 173006)
[PASS] test_getVotes_zeroIfNeverBonded() (gas: 93593)
[PASS] test_getVotes_zeroWhenSlashedInWindow() (gas: 119032)
[PASS] test_proposalThreshold_isPointOnePercent() (gas: 71807)
[PASS] test_quorum_isFourPercentOfTotalBytesInWindow() (gas: 71639)
[PASS] test_setAgeRampMonths_revertsWithoutTimelockCaller() (gas: 11013)
[PASS] test_setVoteCapBps_revertsWithoutTimelockCaller() (gas: 11066)
[PASS] test_voteCapBpsAt_preservesPriorReadAfterLaterPush() (gas: 4104884)
Suite result: ok. 13 passed; 0 failed; 0 skipped; finished in 4.62ms (3.62ms CPU time)

Ran 16 tests for test/FeeRouter.t.sol:FeeRouterTest
[PASS] test_bytesInWindow_sumsTrailingWindow() (gas: 497291)
[PASS] test_bytesInWindow_zeroWindowReturnsZero() (gas: 9326)
[PASS] test_pause_revertsWithoutRole() (gas: 14609)
[PASS] test_routeSettlement_distributesThreeLegs() (gas: 232441)
[PASS] test_routeSettlement_dustRoutesToOperatorWhenBuybackUnset() (gas: 141838)
[PASS] test_routeSettlement_incrementsBytesPerEpoch() (gas: 221457)
[PASS] test_routeSettlement_revertsWithoutRouterRole() (gas: 89208)
[PASS] test_setBuybackBurner_revertsWithoutRole() (gas: 14720)
[PASS] test_setSharesAndDestinations_revertsWithoutRole() (gas: 19569)
[PASS] test_setShares_rejectsNonZeroShareWithoutDestination() (gas: 16239)
[PASS] test_setShares_rejectsSumNot10000() (gas: 14523)
[PASS] test_setShares_revertsWithoutRole() (gas: 15219)
[PASS] test_setTreasury_revertsWithoutRole() (gas: 14696)
[PASS] test_setWindowEpochs_enforcesBounds() (gas: 32780)
[PASS] test_setWindowEpochs_revertsWithoutRole() (gas: 14688)
[PASS] test_unpause_revertsWithoutRole() (gas: 72166)
Suite result: ok. 16 passed; 0 failed; 0 skipped; finished in 2.39ms (1.78ms CPU time)

Ran 13 tests for test/SlashAppeal.t.sol:SlashAppealTest
[PASS] test_cleanup_fastTrackedLapse_grantsOperatorFavorable() (gas: 426386)
[PASS] test_cleanup_openLapse_upholds() (gas: 445950)
[PASS] test_fastTrack_requiresMultisig() (gas: 459673)
[PASS] test_frequencyCap_blocksSecondAppealWithinWindow() (gas: 552253)
[PASS] test_grant_refundsOperatorAndBondAndClearsZeroOut() (gas: 435172)
[PASS] test_grant_requiresGovernance() (gas: 470085)
[PASS] test_grant_revertsIfNotFastTracked() (gas: 461993)
[PASS] test_open_locksEscrowAndPullsBond() (gas: 465836)
[PASS] test_open_revertsAfterFilingWindow() (gas: 456832)
[PASS] test_open_revertsOnDoubleAppeal() (gas: 461717)
[PASS] test_open_revertsUnknownSlash() (gas: 23726)
[PASS] test_reject_burnsBondAndDistributesEscrow() (gas: 452533)
[PASS] test_uphold_distributesEscrowAndSplitsBond() (gas: 488971)
Suite result: ok. 13 passed; 0 failed; 0 skipped; finished in 4.96ms (3.75ms CPU time)

Ran 50 tests for test/GovernanceLifecycle.t.sol:GovernanceLifecycleTest
[PASS] test_canary_executorIsTimelock() (gas: 9905)
[PASS] test_canary_governanceRoleHandoff() (gas: 99060)
[PASS] test_canary_governorVoteWeightWired() (gas: 129736)
[PASS] test_lifecycle_CapacityBond_setClaimSlashGateEpochs_happy() (gas: 588977)
[PASS] test_lifecycle_CapacityBond_setClaimSlashGateEpochs_outOfBounds() (gas: 594692)
[PASS] test_lifecycle_CapacityBond_setMaxMultiaddrSize_happy() (gas: 588653)
[PASS] test_lifecycle_CapacityBond_setMaxMultiaddrSize_outOfBounds() (gas: 594518)
[PASS] test_lifecycle_CapacityBond_setMinStake_happy() (gas: 588745)
[PASS] test_lifecycle_CapacityBond_setMinStake_outOfBounds() (gas: 594539)
[PASS] test_lifecycle_CapacityBond_setMultiaddrUpdateCooldown_happy() (gas: 605817)
[PASS] test_lifecycle_CapacityBond_setMultiaddrUpdateCooldown_outOfBounds() (gas: 594577)
[PASS] test_lifecycle_CapacityBond_setRegionStabilityWindow_happy() (gas: 588677)
[PASS] test_lifecycle_CapacityBond_setRegionStabilityWindow_outOfBounds() (gas: 594538)
[PASS] test_lifecycle_CapacityBond_setTreasury_happy() (gas: 606310)
[PASS] test_lifecycle_CapacityBond_setUnbondingPeriod_happy() (gas: 588736)
[PASS] test_lifecycle_CapacityBond_setUnbondingPeriod_outOfBounds() (gas: 594631)
[PASS] test_lifecycle_ContentBlacklist_addHashGlobal_happy() (gas: 609065)
[PASS] test_lifecycle_ContentBlacklist_addHashGlobal_outOfBounds() (gas: 596741)
[PASS] test_lifecycle_ContentBlacklist_addOperator_happy() (gas: 637740)
[PASS] test_lifecycle_ContentBlacklist_addOperator_outOfBounds() (gas: 596878)
[PASS] test_lifecycle_ContentBlacklist_registerRegionalBody_happy() (gas: 610683)
[PASS] test_lifecycle_ContentBlacklist_removeHashGlobal_happy() (gas: 993965)
[PASS] test_lifecycle_ContentBlacklist_removeHashGlobal_outOfBounds() (gas: 599289)
[PASS] test_lifecycle_ContentBlacklist_removeOperator_happy() (gas: 1022353)
[PASS] test_lifecycle_ContentBlacklist_setAppealBond_happy() (gas: 591164)
[PASS] test_lifecycle_ContentBlacklist_setAppealBond_outOfBounds() (gas: 597062)
[PASS] test_lifecycle_ContentBlacklist_setOriginBlacklist_happy() (gas: 609817)
[PASS] test_lifecycle_ContentBlacklist_setOriginBlacklist_outOfBounds() (gas: 597561)
[PASS] test_lifecycle_DecdnGovernor_setAgeRampMonths_happy() (gas: 630476)
[PASS] test_lifecycle_DecdnGovernor_setAgeRampMonths_outOfBounds() (gas: 636195)
[PASS] test_lifecycle_DecdnGovernor_setVoteCapBps_happy() (gas: 630594)
[PASS] test_lifecycle_DecdnGovernor_setVoteCapBps_outOfBounds() (gas: 636258)
[PASS] test_lifecycle_FeeRouter_setBuybackBurner_happy() (gas: 589124)
[PASS] test_lifecycle_FeeRouter_setBuybackBurner_outOfBounds() (gas: 596566)
[PASS] test_lifecycle_FeeRouter_setSharesAndDestinations_happy() (gas: 622058)
[PASS] test_lifecycle_FeeRouter_setSharesAndDestinations_outOfBounds() (gas: 597749)
[PASS] test_lifecycle_FeeRouter_setShares_happy() (gas: 608137)
[PASS] test_lifecycle_FeeRouter_setShares_outOfBounds() (gas: 596546)
[PASS] test_lifecycle_FeeRouter_setTreasury_happy() (gas: 589150)
[PASS] test_lifecycle_FeeRouter_setTreasury_outOfBounds() (gas: 594311)
[PASS] test_lifecycle_FeeRouter_setWindowEpochs_happy() (gas: 610850)
[PASS] test_lifecycle_FeeRouter_setWindowEpochs_outOfBounds() (gas: 596833)
[PASS] test_lifecycle_PublisherRegistry_setMaxNamespacesPerPublisher_happy() (gas: 591479)
[PASS] test_lifecycle_PublisherRegistry_setMaxNamespacesPerPublisher_outOfBounds() (gas: 597057)
[PASS] test_lifecycle_PublisherRegistry_setNamespaceTransferTimelock_happy() (gas: 591373)
[PASS] test_lifecycle_PublisherRegistry_setNamespaceTransferTimelock_outOfBounds() (gas: 597013)
[PASS] test_lifecycle_SlashAppeal_setAppealBond_happy() (gas: 591125)
[PASS] test_lifecycle_SlashAppeal_setAppealBond_outOfBounds() (gas: 597014)
[PASS] test_lifecycle_SlashAppeal_setChallengerIncentivePool_happy() (gas: 591586)
[PASS] test_lifecycle_SlashAppeal_setChallengerIncentivePool_outOfBounds() (gas: 596910)
Suite result: ok. 50 passed; 0 failed; 0 skipped; finished in 164.10ms (146.66ms CPU time)

Ran 44 tests for test/TestnetFaucet.t.sol:TestnetFaucetTest
[PASS] testFuzz_claim_atOrAboveCooldown(uint256) (runs: 1024, μ: 91490, ~: 91528)
[PASS] testFuzz_claim_belowCooldown(uint256) (runs: 1024, μ: 85155, ~: 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 261.45ms (259.90ms CPU time)

Ran 10 tests for test/Token.t.sol:TokenTest
[PASS] testFuzz_burn_reducesSupplyByExactAmount(uint256) (runs: 1024, μ: 27808, ~: 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 79.94ms (79.47ms CPU time)

Ran 27 tests for test/PublisherRegistry.t.sol:PublisherRegistryTest
[PASS] testFuzz_createNamespace_idsAreSequentialAndOwned(uint8) (runs: 1024, μ: 716302, ~: 427148)
[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: 135319)
[PASS] test_constructor_revertsZeroAdmin() (gas: 36674)
[PASS] test_constructor_setsDefaultsAndRoles() (gas: 19037)
[PASS] test_createNamespace_assignsIdsFromOne() (gas: 92728)
[PASS] test_createNamespace_revertsAtCap() (gas: 98581)
[PASS] test_createNamespace_zeroIsNeverAssigned() (gas: 65471)
[PASS] test_namespaceOf_emptyForUnclaimed() (gas: 8273)
[PASS] test_setMaxNamespaces_revertsOutOfBounds() (gas: 17605)
[PASS] test_setMaxNamespaces_revertsWithoutRole() (gas: 13384)
[PASS] test_setMaxNamespaces_withinBounds() (gas: 20687)
[PASS] test_setTransferTimelock_revertsOutOfBounds() (gas: 17706)
[PASS] test_setTransferTimelock_revertsWithoutRole() (gas: 14763)
[PASS] test_setTransferTimelock_withinBounds() (gas: 20560)
[PASS] test_transfer_cancelByOwner() (gas: 78668)
[PASS] test_transfer_cancelRevertsIfNotOwner() (gas: 93302)
[PASS] test_transfer_finalizeRevertsIfNotPendingOwner() (gas: 93817)
[PASS] test_transfer_finalizeRevertsNoPending() (gas: 68544)
[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. 27 passed; 0 failed; 0 skipped; finished in 570.26ms (571.11ms CPU time)

Ran 10 test suites in 740.11ms (1.12s CPU time): 257 tests passed, 0 failed, 0 skipped (257 total tests)
━ BuybackBurnerTest::test_constructor_grantsAdminAndGovernanceRoles() (gas: 14866 → 14866 | 0 0.000%)
━ BuybackBurnerTest::test_constructor_revertsOnZeroAdmin() (gas: 67810 → 67810 | 0 0.000%)
━ BuybackBurnerTest::test_constructor_revertsOnZeroToken() (gas: 67829 → 67829 | 0 0.000%)
━ BuybackBurnerTest::test_constructor_revertsOnZeroUsdc() (gas: 67793 → 67793 | 0 0.000%)
━ BuybackBurnerTest::test_executeBuyback_happyPath_burnsAndEmits() (gas: 105272 → 105272 | 0 0.000%)
━ BuybackBurnerTest::test_executeBuyback_revertsPoolNotWiredWhenPoolUnset() (gas: 840272 → 840272 | 0 0.000%)
━ BuybackBurnerTest::test_executeBuyback_revertsPoolNotWiredWhenVaultUnset() (gas: 840424 → 840424 | 0 0.000%)
━ BuybackBurnerTest::test_executeBuyback_revertsSwapNotImplementedWhenActualDeltaIsZero() (gas: 60069 → 60069 | 0 0.000%)
━ BuybackBurnerTest::test_executeBuyback_revertsSwapReportMismatch() (gas: 110981 → 110981 | 0 0.000%)
━ BuybackBurnerTest::test_executeBuyback_revertsWhenPaused() (gas: 73094 → 73094 | 0 0.000%)
━ BuybackBurnerTest::test_executeBuyback_revertsWithoutKeeperRole() (gas: 64298 → 64298 | 0 0.000%)
━ BuybackBurnerTest::test_executeBuyback_revertsZeroAmount() (gas: 20705 → 20705 | 0 0.000%)
━ BuybackBurnerTest::test_pause_revertsWithoutPauserRole() (gas: 11912 → 11912 | 0 0.000%)
━ BuybackBurnerTest::test_setPool_emitsUpdateEvent() (gas: 24953 → 24953 | 0 0.000%)
━ BuybackBurnerTest::test_setPool_revertsWithoutGovernanceRole() (gas: 12132 → 12132 | 0 0.000%)
━ BuybackBurnerTest::test_setVault_emitsUpdateEvent() (gas: 24896 → 24896 | 0 0.000%)
━ BuybackBurnerTest::test_setVault_revertsWithoutGovernanceRole() (gas: 12054 → 12054 | 0 0.000%)
━ BuybackBurnerTest::test_unpause_revertsWithoutPauserRole() (gas: 23849 → 23849 | 0 0.000%)
━ CapacityBondTest::test_appealGrant_unlocksClaimBeforeGateExpiry() (gas: 379365 → 379365 | 0 0.000%)
━ CapacityBondTest::test_claimVestedCredit_movesIntoActiveStake() (gas: 214266 → 214266 | 0 0.000%)
━ CapacityBondTest::test_claimVestedCredit_multiClaimFollowsLinearCurve() (gas: 218936 → 218936 | 0 0.000%)
━ CapacityBondTest::test_claimVestedCredit_revertsWhenNoActiveStake() (gas: 144400 → 144400 | 0 0.000%)
━ CapacityBondTest::test_claimVestedCredit_revertsWhenSlashedInWindow() (gas: 390764 → 390764 | 0 0.000%)
━ CapacityBondTest::test_claimVestedCredit_succeedsAfterSlashGateExpires() (gas: 393841 → 393841 | 0 0.000%)
━ CapacityBondTest::test_creditSlash_escrowsThenDistributes5050AtFinality() (gas: 406855 → 406855 | 0 0.000%)
━ CapacityBondTest::test_declaredMbps_storesValue() (gas: 37799 → 37799 | 0 0.000%)
━ CapacityBondTest::test_escrowHooks_requireSlashAppealRole() (gas: 14867 → 14867 | 0 0.000%)
━ CapacityBondTest::test_finalizeUnappealedSlash_distributes5050() (gas: 321851 → 321851 | 0 0.000%)
━ CapacityBondTest::test_firstBondedAt_immutableAcrossReBonds() (gas: 111402 → 111402 | 0 0.000%)
━ CapacityBondTest::test_firstBondedAt_setsOnFirstStake() (gas: 102556 → 102556 | 0 0.000%)
━ CapacityBondTest::test_forfeitUnvestedCredit_burnsWhenNoTreasury() (gas: 246115 → 246115 | 0 0.000%)
━ CapacityBondTest::test_forfeitUnvestedCredit_doesNotClawBackVestedUnclaimed() (gas: 281721 → 281721 | 0 0.000%)
━ CapacityBondTest::test_forfeitUnvestedCredit_onUnbond() (gas: 290488 → 290488 | 0 0.000%)
━ CapacityBondTest::test_genesisCredit_fullVestAfterDuration() (gas: 141232 → 141232 | 0 0.000%)
━ CapacityBondTest::test_genesisCredit_grantWithinWindow() (gas: 139077 → 139077 | 0 0.000%)
━ CapacityBondTest::test_genesisCredit_revertsAfterWindow() (gas: 82768 → 82768 | 0 0.000%)
━ CapacityBondTest::test_genesisCredit_vestsLinearly() (gas: 141534 → 141534 | 0 0.000%)
━ CapacityBondTest::test_markAppealOpen_blocksFinalize() (gas: 294979 → 294979 | 0 0.000%)
━ CapacityBondTest::test_pause_revertsWithoutRole() (gas: 14812 → 14812 | 0 0.000%)
━ CapacityBondTest::test_pendingCreditSlash_reducesOriginalGrant() (gas: 384877 → 384877 | 0 0.000%)
━ CapacityBondTest::test_reduceStakeAtTier_remainderClip() (gas: 4950010 → 4950010 | 0 0.000%)
━ CapacityBondTest::test_reduceStakeAtTier_unbondingOnly() (gas: 4969820 → 4969820 | 0 0.000%)
━ CapacityBondTest::test_registerNode_revertsOnInvalidEd25519Sig() (gas: 169259 → 169259 | 0 0.000%)
━ CapacityBondTest::test_registerNode_revertsWhenAlreadyActive() (gas: 376581 → 376581 | 0 0.000%)
━ CapacityBondTest::test_setClaimSlashGateEpochs_revertsWithoutRole() (gas: 14934 → 14934 | 0 0.000%)
━ CapacityBondTest::test_setMaxMultiaddrSize_revertsWithoutRole() (gas: 14823 → 14823 | 0 0.000%)
━ CapacityBondTest::test_setMinStake_revertsWithoutRole() (gas: 14792 → 14792 | 0 0.000%)
━ CapacityBondTest::test_setMultiaddrUpdateCooldown_revertsWithoutRole() (gas: 14844 → 14844 | 0 0.000%)
━ CapacityBondTest::test_setRegionStabilityWindow_revertsWithoutRole() (gas: 14822 → 14822 | 0 0.000%)
━ CapacityBondTest::test_setTreasury_revertsWithoutRole() (gas: 14925 → 14925 | 0 0.000%)
━ CapacityBondTest::test_setUnbondingPeriod_revertsWithoutRole() (gas: 14869 → 14869 | 0 0.000%)
━ CapacityBondTest::test_settleAppealGranted_clearsAndRefunds() (gas: 269662 → 269662 | 0 0.000%)
━ CapacityBondTest::test_settleAppealUpheld_distributes5050() (gas: 316308 → 316308 | 0 0.000%)
━ CapacityBondTest::test_slashHitsVestedAndUnvestedTogether() (gas: 428003 → 428003 | 0 0.000%)
━ CapacityBondTest::test_slashHitsVestedButUnclaimed() (gas: 395382 → 395382 | 0 0.000%)
━ CapacityBondTest::test_slashId_persistsRecord() (gas: 286634 → 286634 | 0 0.000%)
━ CapacityBondTest::test_slash_creditSlash_escalatesAcrossTiers() (gas: 527072 → 527072 | 0 0.000%)
━ CapacityBondTest::test_slash_escrowsWithoutDistribution() (gas: 297637 → 297637 | 0 0.000%)
━ CapacityBondTest::test_slash_stampsSlashedAtEpoch() (gas: 286483 → 286483 | 0 0.000%)
━ CapacityBondTest::test_slash_tier3_mixedStake_exhaustsActiveTapsUnbonding() (gas: 508263 → 508263 | 0 0.000%)
━ CapacityBondTest::test_slash_tierEscalation_15then50pct() (gas: 467444 → 467444 | 0 0.000%)
━ CapacityBondTest::test_slashedAtEpoch_zeroBeforeSlash() (gas: 10158 → 10158 | 0 0.000%)
━ CapacityBondTest::test_unpause_revertsWithoutRole() (gas: 72514 → 72514 | 0 0.000%)
━ CapacityBondTest::test_updateMultiaddrs_revertsWhenNodeNotActive() (gas: 15679 → 15679 | 0 0.000%)
━ CapacityBondTest::test_updateRegion_cooldownAndPrevSnapshot() (gas: 447956 → 447956 | 0 0.000%)
━ CapacityBondTest::test_updateRegion_revertsWhenNodeNotActive() (gas: 15675 → 15675 | 0 0.000%)
━ ContentBlacklistTest::test_addHashGlobal_andQuery() (gas: 38191 → 38191 | 0 0.000%)
━ ContentBlacklistTest::test_addHashGlobal_revertsWithoutGovernanceRole() (gas: 14608 → 14608 | 0 0.000%)
━ ContentBlacklistTest::test_addHashRegional_globalTakesPrecedence() (gas: 41980 → 41980 | 0 0.000%)
━ ContentBlacklistTest::test_addHashRegional_revertsWithoutRegionalBodyRole() (gas: 14684 → 14684 | 0 0.000%)
━ ContentBlacklistTest::test_addOperator_callsEjectOnCapacityBond() (gas: 91570 → 91570 | 0 0.000%)
━ ContentBlacklistTest::test_fullAppealFlow_ratifyRemovesHash() (gas: 275665 → 275665 | 0 0.000%)
━ ContentBlacklistTest::test_hasActiveAppeal_clearedOnLapseOpen() (gas: 242221 → 242221 | 0 0.000%)
━ ContentBlacklistTest::test_hasActiveAppeal_clearedOnReject() (gas: 433926 → 433926 | 0 0.000%)
━ ContentBlacklistTest::test_hasActiveAppeal_clearedOnReverse() (gas: 254985 → 254985 | 0 0.000%)
━ ContentBlacklistTest::test_openBlacklistAppeal_revertsDuplicatePerHash() (gas: 356697 → 356697 | 0 0.000%)
━ ContentBlacklistTest::test_openBlacklistAppeal_revertsOnEntryNotBlacklisted() (gas: 18635 → 18635 | 0 0.000%)
━ ContentBlacklistTest::test_openBlacklistAppeal_revertsOnZeroRegion() (gas: 16243 → 16243 | 0 0.000%)
━ ContentBlacklistTest::test_regionalCap_blocksMoreThanThreeActiveAppeals() (gas: 706667 → 706667 | 0 0.000%)
━ ContentBlacklistTest::test_registerRegionalBody_revertsWithoutGovernanceRole() (gas: 14830 → 14830 | 0 0.000%)
━ ContentBlacklistTest::test_rejectAppeal_burnsBond() (gas: 247882 → 247882 | 0 0.000%)
━ ContentBlacklistTest::test_removeHashRegional_blocksGlobalRegionEntries() (gas: 44419 → 44419 | 0 0.000%)
━ ContentBlacklistTest::test_reverseAppeal_clearsSuspendedAndBurnsBond() (gas: 261664 → 261664 | 0 0.000%)
━ ContentBlacklistTest::test_setAppealBond_revertsWithoutGovernanceRole() (gas: 14754 → 14754 | 0 0.000%)
━ DecdnGovernorTest::test_ageRampMonthsAt_preservesPriorReadAfterLaterPush() (gas: 4104760 → 4104760 | 0 0.000%)
━ DecdnGovernorTest::test_getVotes_halfRamp() (gas: 173099 → 173099 | 0 0.000%)
━ DecdnGovernorTest::test_getVotes_historicalSnapshotIgnoresFutureSlash() (gas: 221405 → 221405 | 0 0.000%)
━ DecdnGovernorTest::test_getVotes_ramp() (gas: 173020 → 173020 | 0 0.000%)
━ DecdnGovernorTest::test_getVotes_recoversAfterWindowSlidesPastSlash() (gas: 196808 → 196808 | 0 0.000%)
━ DecdnGovernorTest::test_getVotes_uncappedWhenBelowCap() (gas: 173006 → 173006 | 0 0.000%)
━ DecdnGovernorTest::test_getVotes_zeroIfNeverBonded() (gas: 93593 → 93593 | 0 0.000%)
━ DecdnGovernorTest::test_getVotes_zeroWhenSlashedInWindow() (gas: 119032 → 119032 | 0 0.000%)
━ DecdnGovernorTest::test_proposalThreshold_isPointOnePercent() (gas: 71807 → 71807 | 0 0.000%)
━ DecdnGovernorTest::test_quorum_isFourPercentOfTotalBytesInWindow() (gas: 71639 → 71639 | 0 0.000%)
━ DecdnGovernorTest::test_setAgeRampMonths_revertsWithoutTimelockCaller() (gas: 11013 → 11013 | 0 0.000%)
━ DecdnGovernorTest::test_setVoteCapBps_revertsWithoutTimelockCaller() (gas: 11066 → 11066 | 0 0.000%)
━ DecdnGovernorTest::test_voteCapBpsAt_preservesPriorReadAfterLaterPush() (gas: 4104884 → 4104884 | 0 0.000%)
━ FeeRouterTest::test_bytesInWindow_sumsTrailingWindow() (gas: 497291 → 497291 | 0 0.000%)
━ FeeRouterTest::test_bytesInWindow_zeroWindowReturnsZero() (gas: 9326 → 9326 | 0 0.000%)
━ FeeRouterTest::test_pause_revertsWithoutRole() (gas: 14609 → 14609 | 0 0.000%)
━ FeeRouterTest::test_routeSettlement_distributesThreeLegs() (gas: 232441 → 232441 | 0 0.000%)
━ FeeRouterTest::test_routeSettlement_dustRoutesToOperatorWhenBuybackUnset() (gas: 141838 → 141838 | 0 0.000%)
━ FeeRouterTest::test_routeSettlement_incrementsBytesPerEpoch() (gas: 221457 → 221457 | 0 0.000%)
━ FeeRouterTest::test_routeSettlement_revertsWithoutRouterRole() (gas: 89208 → 89208 | 0 0.000%)
━ FeeRouterTest::test_setBuybackBurner_revertsWithoutRole() (gas: 14720 → 14720 | 0 0.000%)
━ FeeRouterTest::test_setSharesAndDestinations_revertsWithoutRole() (gas: 19569 → 19569 | 0 0.000%)
━ FeeRouterTest::test_setShares_rejectsNonZeroShareWithoutDestination() (gas: 16239 → 16239 | 0 0.000%)
━ FeeRouterTest::test_setShares_rejectsSumNot10000() (gas: 14523 → 14523 | 0 0.000%)
━ FeeRouterTest::test_setShares_revertsWithoutRole() (gas: 15219 → 15219 | 0 0.000%)
━ FeeRouterTest::test_setTreasury_revertsWithoutRole() (gas: 14696 → 14696 | 0 0.000%)
━ FeeRouterTest::test_setWindowEpochs_enforcesBounds() (gas: 32780 → 32780 | 0 0.000%)
━ FeeRouterTest::test_setWindowEpochs_revertsWithoutRole() (gas: 14688 → 14688 | 0 0.000%)
━ FeeRouterTest::test_unpause_revertsWithoutRole() (gas: 72166 → 72166 | 0 0.000%)
━ GovernanceLifecycleTest::test_canary_executorIsTimelock() (gas: 9905 → 9905 | 0 0.000%)
━ GovernanceLifecycleTest::test_canary_governanceRoleHandoff() (gas: 99060 → 99060 | 0 0.000%)
━ GovernanceLifecycleTest::test_canary_governorVoteWeightWired() (gas: 129736 → 129736 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_CapacityBond_setClaimSlashGateEpochs_happy() (gas: 588977 → 588977 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_CapacityBond_setClaimSlashGateEpochs_outOfBounds() (gas: 594692 → 594692 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_CapacityBond_setMaxMultiaddrSize_happy() (gas: 588653 → 588653 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_CapacityBond_setMaxMultiaddrSize_outOfBounds() (gas: 594518 → 594518 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_CapacityBond_setMinStake_happy() (gas: 588745 → 588745 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_CapacityBond_setMinStake_outOfBounds() (gas: 594539 → 594539 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_CapacityBond_setMultiaddrUpdateCooldown_happy() (gas: 605817 → 605817 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_CapacityBond_setMultiaddrUpdateCooldown_outOfBounds() (gas: 594577 → 594577 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_CapacityBond_setRegionStabilityWindow_happy() (gas: 588677 → 588677 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_CapacityBond_setRegionStabilityWindow_outOfBounds() (gas: 594538 → 594538 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_CapacityBond_setTreasury_happy() (gas: 606310 → 606310 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_CapacityBond_setUnbondingPeriod_happy() (gas: 588736 → 588736 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_CapacityBond_setUnbondingPeriod_outOfBounds() (gas: 594631 → 594631 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_ContentBlacklist_addHashGlobal_happy() (gas: 609065 → 609065 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_ContentBlacklist_addHashGlobal_outOfBounds() (gas: 596741 → 596741 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_ContentBlacklist_addOperator_happy() (gas: 637740 → 637740 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_ContentBlacklist_addOperator_outOfBounds() (gas: 596878 → 596878 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_ContentBlacklist_registerRegionalBody_happy() (gas: 610683 → 610683 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_ContentBlacklist_removeHashGlobal_happy() (gas: 993965 → 993965 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_ContentBlacklist_removeHashGlobal_outOfBounds() (gas: 599289 → 599289 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_ContentBlacklist_removeOperator_happy() (gas: 1022353 → 1022353 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_ContentBlacklist_setAppealBond_happy() (gas: 591164 → 591164 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_ContentBlacklist_setAppealBond_outOfBounds() (gas: 597062 → 597062 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_ContentBlacklist_setOriginBlacklist_happy() (gas: 609817 → 609817 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_ContentBlacklist_setOriginBlacklist_outOfBounds() (gas: 597561 → 597561 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_DecdnGovernor_setAgeRampMonths_happy() (gas: 630476 → 630476 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_DecdnGovernor_setAgeRampMonths_outOfBounds() (gas: 636195 → 636195 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_DecdnGovernor_setVoteCapBps_happy() (gas: 630594 → 630594 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_DecdnGovernor_setVoteCapBps_outOfBounds() (gas: 636258 → 636258 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_FeeRouter_setBuybackBurner_happy() (gas: 589124 → 589124 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_FeeRouter_setBuybackBurner_outOfBounds() (gas: 596566 → 596566 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_FeeRouter_setSharesAndDestinations_happy() (gas: 622058 → 622058 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_FeeRouter_setSharesAndDestinations_outOfBounds() (gas: 597749 → 597749 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_FeeRouter_setShares_happy() (gas: 608137 → 608137 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_FeeRouter_setShares_outOfBounds() (gas: 596546 → 596546 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_FeeRouter_setTreasury_happy() (gas: 589150 → 589150 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_FeeRouter_setTreasury_outOfBounds() (gas: 594311 → 594311 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_FeeRouter_setWindowEpochs_happy() (gas: 610850 → 610850 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_FeeRouter_setWindowEpochs_outOfBounds() (gas: 596833 → 596833 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_PublisherRegistry_setMaxNamespacesPerPublisher_happy() (gas: 591479 → 591479 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_PublisherRegistry_setMaxNamespacesPerPublisher_outOfBounds() (gas: 597057 → 597057 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_PublisherRegistry_setNamespaceTransferTimelock_happy() (gas: 591373 → 591373 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_PublisherRegistry_setNamespaceTransferTimelock_outOfBounds() (gas: 597013 → 597013 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_SlashAppeal_setAppealBond_happy() (gas: 591125 → 591125 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_SlashAppeal_setAppealBond_outOfBounds() (gas: 597014 → 597014 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_SlashAppeal_setChallengerIncentivePool_happy() (gas: 591586 → 591586 | 0 0.000%)
━ GovernanceLifecycleTest::test_lifecycle_SlashAppeal_setChallengerIncentivePool_outOfBounds() (gas: 596910 → 596910 | 0 0.000%)
━ PublisherRegistryTest::testFuzz_createNamespace_idsAreSequentialAndOwned(uint8) (gas: 427148 → 427148 | 0 0.000%)
━ 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: 135319 → 135319 | 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: 92728 → 92728 | 0 0.000%)
━ PublisherRegistryTest::test_createNamespace_revertsAtCap() (gas: 98581 → 98581 | 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: 17605 → 17605 | 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_revertsWithoutRole() (gas: 14763 → 14763 | 0 0.000%)
━ PublisherRegistryTest::test_setTransferTimelock_withinBounds() (gas: 20560 → 20560 | 0 0.000%)
━ PublisherRegistryTest::test_transfer_cancelByOwner() (gas: 78668 → 78668 | 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: 68544 → 68544 | 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%)
━ SlashAppealTest::test_cleanup_fastTrackedLapse_grantsOperatorFavorable() (gas: 426386 → 426386 | 0 0.000%)
━ SlashAppealTest::test_cleanup_openLapse_upholds() (gas: 445950 → 445950 | 0 0.000%)
━ SlashAppealTest::test_fastTrack_requiresMultisig() (gas: 459673 → 459673 | 0 0.000%)
━ SlashAppealTest::test_frequencyCap_blocksSecondAppealWithinWindow() (gas: 552253 → 552253 | 0 0.000%)
━ SlashAppealTest::test_grant_refundsOperatorAndBondAndClearsZeroOut() (gas: 435172 → 435172 | 0 0.000%)
━ SlashAppealTest::test_grant_requiresGovernance() (gas: 470085 → 470085 | 0 0.000%)
━ SlashAppealTest::test_grant_revertsIfNotFastTracked() (gas: 461993 → 461993 | 0 0.000%)
━ SlashAppealTest::test_open_locksEscrowAndPullsBond() (gas: 465836 → 465836 | 0 0.000%)
━ SlashAppealTest::test_open_revertsAfterFilingWindow() (gas: 456832 → 456832 | 0 0.000%)
━ SlashAppealTest::test_open_revertsOnDoubleAppeal() (gas: 461717 → 461717 | 0 0.000%)
━ SlashAppealTest::test_open_revertsUnknownSlash() (gas: 23726 → 23726 | 0 0.000%)
━ SlashAppealTest::test_reject_burnsBondAndDistributesEscrow() (gas: 452533 → 452533 | 0 0.000%)
━ SlashAppealTest::test_uphold_distributesEscrowAndSplitsBond() (gas: 488971 → 488971 | 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%)

--------------------------------------------------------------------------------
Total tests: 257, ↑ 0, ↓ 0, ━ 257
Overall gas change: 0 (0.000%)

Run: 26651225936

@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 retires the SafetyReserve contract and introduces a standalone SlashAppeal contract alongside an escrow-on-slash model in CapacityBond. It also updates the tokenomics to a three-bucket split (60% operator, 30% buyback, 10% treasury). The review feedback highlights several improvement opportunities: restricting rejectAppeal in SlashAppeal to open appeals to preserve the two-stage governance process, adding explicit validation checks for invalid slash IDs in CapacityBond's escrow hooks, and specifying exact error selectors in Foundry tests instead of using empty vm.expectRevert() calls.

Comment thread contracts/src/SlashAppeal.sol Resolved
Comment thread contracts/src/CapacityBond.sol Resolved
Comment thread contracts/src/CapacityBond.sol Resolved
Comment thread contracts/src/CapacityBond.sol Resolved
Comment thread contracts/src/CapacityBond.sol Resolved
Comment thread contracts/test/SlashAppeal.t.sol Resolved
Comment thread contracts/test/FeeRouter.t.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

This PR removes the SafetyReserve contract surface and replaces slash restitution with CapacityBond escrow-on-slash plus a standalone SlashAppeal state machine. It also updates fee routing from 60/25/10/5 to 60/30/10 and refreshes tests, gas snapshots, and ADR documentation around the new contract model.

Changes:

  • Removed SafetyReserve contracts/tests/mocks/interfaces and introduced SlashAppeal + ICapacityBondSlashEscrow.
  • Refactored CapacityBond slashing to escrow slashed TOKEN until finality or appeal resolution.
  • Updated FeeRouter bucket accounting, governance lifecycle tests, and ADR references for the 60/30/10 split.

Reviewed changes

Copilot reviewed 36 out of 36 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
contracts/src/CapacityBond.sol Adds slash escrow records, finality distribution, and appeal settle hooks.
contracts/src/SlashAppeal.sol New slash appeal state machine and appeal bond handling.
contracts/src/FeeRouter.sol Converts routing from four buckets to three buckets.
contracts/src/ContentBlacklist.sol Updates comments to reference SlashAppeal.
contracts/src/interfaces/ICapacityBond.sol Removes external slash-clearer from the read interface.
contracts/src/interfaces/ICapacityBondSlashEscrow.sol Adds escrow hook interface for SlashAppeal.
contracts/src/interfaces/ISlashAppeal.sol Adds SlashAppeal public interface.
contracts/src/interfaces/ISafetyReserve.sol Removes retired SafetyReserve interface.
contracts/src/SafetyReserve.sol Removes retired SafetyReserve contract.
contracts/test/CapacityBond.t.sol Updates slashing tests for escrow lifecycle.
contracts/test/SlashAppeal.t.sol Adds end-to-end SlashAppeal flow tests.
contracts/test/FeeRouter.t.sol Updates FeeRouter tests for three-bucket routing.
contracts/test/GovernanceLifecycle.t.sol Replaces SafetyReserve lifecycle coverage with SlashAppeal coverage.
contracts/test/SafetyReserve.t.sol Removes retired SafetyReserve tests.
contracts/test/mocks/MockSafetyReserve.sol Removes retired SafetyReserve mock.
contracts/test/mocks/MockCapacityBond.sol Updates mock comments/interface compatibility.
contracts/.gas-snapshot Refreshes Foundry gas snapshots.
CLAUDE.md Updates repository/ADR notes for SafetyReserve retirement.
adr/003-payments.md Updates payment-routing docs to 60/30/10.
adr/008-reputation.md Updates non-base skim description.
adr/009-governance.md Updates governance model for SlashAppeal and three FeeRouter shares.
adr/014-on-chain-verification.md Updates slashing verification docs for escrow-on-slash.
adr/018-liquidity-strategy.md Updates buyback inflow references to 30%.
adr/026-tokenomics.md Rewrites tokenomics around escrow-on-slash and no SafetyReserve.
adr/031-content-blacklist-appeals-contract.md Updates analogy/reference from SafetyReserve to SlashAppeal.
adr/036-served-bytes-voting-weight.md Updates slash-zero-out appeal recovery path.
adr/appendix-l2-deployment.md Updates settlement overhead and buyback share docs.
adr/appendix-observability.md Replaces SafetyReserve metrics with slash escrow/appeal metrics.
adr/appendix-operator-key-rotation.md Updates compromised-key recourse guidance.
adr/appendix-poc-production-seams.md Updates contract-client seam list.
adr/architecture.md Updates architecture index for SafetyReserve retirement.
adr/glossary.md Updates FeeRouter and SlashAppeal glossary entries.
adr/_history/032-safety-reserve-appeals-contract.md Marks ADR 032 retired.
adr/_history/033-safety-insurance-reserve.md Marks ADR 033 retired.

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

Comment thread contracts/src/CapacityBond.sol Resolved
Comment thread contracts/src/SlashAppeal.sol Resolved
Comment thread adr/018-liquidity-strategy.md Resolved
Comment thread adr/glossary.md Resolved
Comment thread adr/026-tokenomics.md Resolved
Comment thread adr/009-governance.md Resolved
…nSlash guards

Code-review feedback from gemini-code-assist + Copilot on #708:

- SlashAppeal.rejectAppeal: restrict to AppealStatus.Open only. A FastTracked
  appeal must be resolved by the Governor (grantAppeal/upholdAppeal), so the
  multisig can no longer overturn its own interim relief and burn the full
  bond — preserves the two-stage governance process and the 50/50 bond split
  on the fast-tracked-failure path. (matches ADR 028 "rejects at intake")
- CapacityBond: add explicit `slashId >= slashCounter -> UnknownSlash` guards
  to finalizeUnappealedSlash / markAppealOpen / settleAppealUpheld /
  settleAppealGranted, matching getSlashRecord's clearer error reporting.
- Tests: replace bare vm.expectRevert() with specific selectors in
  SlashAppeal.t.sol (access-control) and FeeRouter.t.sol (SharesDoNotSum /
  NonZeroShareNeedsDestination).

ADR consistency (stale-reference cleanups the reviewers flagged):
- 018: remaining 25% buyback/inflow refs -> 30% (liquidity-cap + risk sections).
- glossary: BuybackBurner 25%->30%; Slashing entry -> escrow-on-slash 50/50;
  slashedAtEpoch cleared via settleAppealGranted (not clearSlashedAtEpoch).
- 009: "four FeeRouter shares" -> three; drop "safety" from the 0%-floor prose.
- 026 + 028: correct the credit-slash scope to match the contract — the full
  at-risk pool (originalGrant - claimed, incl. vested-but-unclaimed) is
  slashable (closes the delay-to-shield loophole); claimed credit is slashed
  via the stake path. (Pre-existing ADR/contract mismatch.)

Verification: build --deny warnings (all <24KB), fmt, 257/257 tests, aderyn 0
high, slither no medium+, gas snapshot regenerated.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

@alpergundogdu alpergundogdu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Max-effort review of the escrow-on-slash rewrite. Core mechanism is sound — escrow token-backing stays balanced, no double-settle (status guards are one-shot), CEI + nonReentrant throughout, splits round safely, and cleanupExpiredAppeal is a permissionless backstop so escrow can't lock forever. 7 findings inline.

Decisions folded into the comments below:

  • Pause (#4/#5): pause should apply to the whole settlement path, and the appeal windows should be extended by the paused duration so a pause never silently consumes a deadline.
  • #6 and #7 are must-fix in this PR, not deferred.

#1 is a blocker — it's a cheap, profitable griefing attack that nullifies the appeal protection this PR's ADR exists to provide.

Comment thread contracts/src/SlashAppeal.sol Resolved
Comment thread contracts/src/CapacityBond.sol Resolved
Comment thread contracts/src/SlashAppeal.sol Resolved
Comment thread contracts/src/CapacityBond.sol Resolved
Comment thread contracts/src/SlashAppeal.sol Resolved
Comment thread contracts/src/CapacityBond.sol Resolved
Comment thread contracts/src/CapacityBond.sol Resolved
…+ 6 more

7 findings from the max-effort escrow-on-slash review on #708.

#1 (blocker) — appeal-slot griefing. `openSlashAppeal` was permissionless;
the one-shot-per-slashId guard let anyone (notably the recorded challenger,
who earns 50% of an upheld slash) front-run a junk appeal and permanently
burn the operator's only recourse. Now operator-only: `msg.sender` must equal
the operator recorded in the slash. New `CallerNotOperator` error + tests.

#6 (must-fix) — clip the credit-slash leg. `_slashPendingCreditAtTier` now
caps `slashed` at `atRisk` (symmetric with `_reduceStakeAtTier`'s C2 clip), so
`escrowedTotal` can never book more than the tokens removed if a tier constant
is ever set >100%. Invariant comment added.

#7 (must-fix) — granted appeal restores credit vesting, not liquid TOKEN.
`SlashRecord` gains `creditPortion` (set in `_mintSlashRecord`). On
`settleAppealGranted` the credit portion is added back to
`_pendingCredit.originalGrant` (grantedAt untouched → vest resumes) and only
the stake portion is refunded liquid — exactly whole, no accelerated-credit
windfall. New credit-restore test.

#2 — conditional `slashedAtEpoch` clear. `settleAppealGranted` clears the
per-operator stamp only when it belongs to the reversed slash; a later
still-standing slash keeps its zero-out. Two-slash regression test. (Closes
the deferral in #709.)

#3 — `upholdAppeal` graceful degrade. Drops the `ChallengerPoolNotWired`
revert; burns 100% of the bond when the pool is unset (matching
`rejectAppeal`) so a misconfig can't block an uphold and let cleanup flip it
to an operator-favorable grant. Pool-unset test.

#4 — pause covers the whole settlement path. `whenNotPaused` added to the
CapacityBond settle hooks and all SlashAppeal resolution functions.

#5 — appeal windows extended by paused duration. Each contract tracks
`pausedTotal` (override `_pause`/`_unpause`); filing/review/ratification
deadline checks add the offset so a pause never silently consumes a window.
Pause-spans-window test.

ADR 028 updated for operator-only filing. Verification: build --deny warnings
(both contracts <24,576), fmt, 262/262 tests, aderyn 0 high, slither no
medium+, gas snapshot regenerated.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@thiras
thiras merged commit b613325 into main May 29, 2026
@thiras
thiras deleted the refactor/remove-safety-reserve branch May 29, 2026 18:01
thiras added a commit that referenced this pull request May 29, 2026
Two comment-only corrections surfaced by PR review after the #708 rebase:
- GovernanceLifecycle.t.sol: buyback share in the fixture is 3000 bps, not
  the 2500 left over from the old 4-bucket split.
- DeployProtocolScript.t.sol: the base-deploy pipeline is 6 phases (the
  _assertNoBackDoors guard at phase 6 is covered in DeployProtocol.t.sol),
  not "phases 1-5".

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
thiras added a commit that referenced this pull request May 29, 2026
* feat(contracts): production DeployProtocol script (closes #694)

Add `script/DeployProtocol.s.sol` + abstract `BaseProtocolDeploy.s.sol`
that deploys the v3 contract surface in ADR 016 § Deployment Order, wires
cross-contract roles, and atomically hands off GOVERNANCE_ROLE +
DEFAULT_ADMIN_ROLE from the deployer EOA to a fresh TimelockController.
Post-deploy `_assertNoBackDoors` reverts the run if any step left the
deployer holding a privileged role.

The shared base is also consumed by `GovernanceLifecycleTest`, removing
~150 lines of duplicated deploy helpers; all 57 lifecycle tests pass
unchanged.

Design choices (confirmed up-front):
- BuybackBurner is abstract; ship with bucket dormant
  (buybackBurner_=address(0), shares[1]=0). Governance activates later
  via setSharesAndDestinations once a concrete subclass lands.
- ED25519_VERIFIER_ADDRESS is operator-supplied via env var (no
  production verifier in repo yet).

13 new tests across DeployProtocol.t.sol + DeployProtocolScript.t.sol:
role-matrix invariants, 7 ZeroAddress fail-fast cases, manifest
write/overwrite/contents, env-var defaults, run-guard against forge's
default sender.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(contracts): mark defaults test view to satisfy --deny warnings

solc W2018 (state mutability can be restricted to view) is fatal under
FOUNDRY_PROFILE=ci --deny warnings. test_readConfig_appliesDefaultsForOptionalVars
only calls the external-view wrapper and pure assertions, so solc flags it.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(contracts): Timelock-custody FeeRouter treasury per ADR 016

Address PR #700 review:

- Deploy TimelockController before FeeRouter (new phase 1) and wire it as the
  treasury bucket destination, matching ADR 016 § Deployment Order step 7
  (treasury is Timelock-custodied, disbursed only by governance proposal).
  Previously FeeRouter took an operator-supplied TREASURY_ADDRESS deployed
  before the timelock existed — so "treasury == the Timelock" was unreachable
  in a single run. Drop the TREASURY_ADDRESS env var and the treasury config
  field; the bucket is now always address(timelock). _deployGovernance splits
  into _deployTimelock (phase 1) + _deployGovernor (phase 3).

  Note: FeeRouter.treasury is a mutable GOVERNANCE_ROLE-gated setter, not
  immutable as the review stated, so a misconfig was always correctable via a
  48h proposal — but Timelock-custody is the canonical ADR 016 model regardless.

- gitignore deployments/3133769*.json so a failed/interrupted DeployProtocolScript
  test run can't leave a stray test manifest that gets accidentally committed.
  Real-chain manifests use other ids and remain committable with `git add -f`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(contracts): address DeployProtocol review findings

Multi-agent review of PR #700 surfaced several gaps; all verified findings fixed:

- Manifest writability is now checked in run() BEFORE vm.startBroadcast, not
  after. Previously a stale manifest with no FORCE_OVERWRITE_MANIFEST let the
  whole deploy + governance handoff broadcast on-chain, then reverted at the
  write — leaving deployed contracts with no recorded addresses. New
  _assertManifestWritable/_manifestPath helpers; _writeManifest keeps the guard
  so direct callers/tests still get it.

- Grant GENESIS_GRANTOR_ROLE to the Timelock in phase 4 (ADR 016 § Post-Deploy
  Init step 7). The 30-day genesis window starts ticking at CapacityBond
  construction; without this, enabling credits needed a ~10-day proposal,
  burning a third of the window.

- Drop FEE_ROUTER_EPOCH_LENGTH env var — it can only ever be 7 days
  (FeeRouter reverts EpochLengthMismatch otherwise), so it advertised false
  tunability and carried a silent uint256->uint64 truncation. Now a fixed
  uint64 constant; FEE_ROUTER_WINDOW_EPOCHS gets an explicit overflow guard.

- Enforce a MIN_TIMELOCK_DELAY floor — TIMELOCK_DELAY=0 was silently accepted,
  constructing a zero-delay Timelock that defeats the governance-delay model.

- Make _assertNoBackDoors symmetric: assert the Timelock HOLDS both roles on
  every target and self-administers, not just that the deployer is out. A
  handoff that revoked the deployer but skipped a Timelock grant would
  otherwise pass while leaving a contract ungoverned. New GovernanceNotHandedOff
  error; extract _governedTargets(d) as the single source of truth for the
  handoff loop and the guard.

- Fix stale comments: "five-phase"->"six-phase", "§ Role Matrix"->"§ Access
  Control Matrix", "phases 1-5"->"phases 1-6", imprecise ADR step-7 custody
  citations, and the overstated "sorted alphabetically" manifest claim.

Tests: add run() pre-broadcast manifest-guard test, GovernanceNotHandedOff
negative test, genesis-grantor wiring test, and manifest deployer/deployBlock
assertions. 297 pass; forge fmt, aderyn (0 high), slither (clean).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* docs(contracts): fix stale review comments in deploy tests

Two comment-only corrections surfaced by PR review after the #708 rebase:
- GovernanceLifecycle.t.sol: buyback share in the fixture is 3000 bps, not
  the 2500 left over from the old 4-bucket split.
- DeployProtocolScript.t.sol: the base-deploy pipeline is 6 phases (the
  _assertNoBackDoors guard at phase 6 is covered in DeployProtocol.t.sol),
  not "phases 1-5".

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[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.

3 participants