Repository navigation
Description
Summary
Tracking issue for implementing the unified deCDN contract surface for audit. Scope is the canonical on-chain surface in ADR 016 § Contract Inventory. Per-function decomposition lives in the contracts themselves — auditors and implementers work against the canonical ADR specs.
This is a clean restart of the earlier scaffolding work (#237 is closed).
Scope reconciled 2026-05-30. The original 14-contract list predated the work-token rewrite (retired ADR 034 / 035) and the SafetyReserve removal (#708, retired ADR 033).
VotingEscrow,SafetyReserve, andDelegatorBuyerare gone;StakingRegistryis nowCapacityBond;SlashAppealis new;FeeRouteris three-bucket. Canonical surface is 12 contracts. Full reconciliation in this comment.
Scope
The 12 canonical contracts from ADR 016 § Contract Inventory, with current build status:
| Contract | ADR | Status |
|---|---|---|
Token (ERC20 + ERC20Burnable + ERC20Permit, fixed-supply; no ERC20Votes) |
026 | ✅ done |
CapacityBond (operator registry: capacity-bond curve, escrow-on-slash, NodeId binding, isActive, Genesis Bond Credit vesting) |
003, 026 | ✅ done |
PaymentChannel (USDC-only; settleChannel → FeeRouter.routeSettlement; EIP-712 vouchers; 48h dispute window; operator early-withdraw-while-open) |
003 | ⬜ not built |
FeeRouter (three-bucket: operator / buyback / treasury; canonical 60/30/10, launch 90/0/10; governance-tunable; no claim windows) |
026 | ✅ done |
SlashAppeal (ADR 028 appeal state machine; drives CapacityBond escrow-on-slash hooks) |
026, 028 | ✅ done |
BuybackBurner (Balancer V3 swap-and-burn; 30% steady-state leg) |
018, 026 | |
ContentBlacklist (hash / regional / operator + appeals) |
011 | ✅ done |
PublisherRegistry |
002 | ✅ done |
OriginAssignment (default-open allow-list) |
011 | ⬜ not built |
SlashJudge (evidence verification + challenge bonds; holds SLASH_ROLE) |
014 | ⬜ not built |
DecdnGovernor (OZ Governor wrapper; served-bytes vote source per ADR 036) |
009, 036 | ✅ done |
TimelockController (off-the-shelf OZ; 48h delay; treasury custodian) |
009 | ✅ wired in deploy |
Ed25519Verifier (production ed25519 behind IEd25519Verifier) |
003, 014 | ✅ done (#712) |
DeployProtocol (#700) wires the eight done contracts with grant-before-revoke Timelock handoff. The three unbuilt contracts plus the BuybackBurner binding (#686) are what remain.
Build toolchain: Foundry. Inheritance: OpenZeppelin v5. No proxy patterns. EIP-712 domain separators in signing contracts only (PaymentChannel, SlashJudge, CapacityBond.bindNodeId).
Remaining work
In dependency order:
PaymentChannel(ADR 003) — the USDC settlement gateway. Nothing feedsFeeRouteron-chain without it. The contract is this issue's scope; Rust integration stays in Implement on-chain CapacityBond and PaymentChannel contract integration #327.SlashJudge(ADR 014) — evidence verification + challenge bonds; theSLASH_ROLEholder that callsCapacityBond.slash(operator, challenger, offenseType). No on-chain slash trigger exists today (SLASH_ROLEis granted to nobody in the deploy).OriginAssignment(ADR 011) — default-open allow-list; one-shotsetContentBlacklistwiring.BuybackBurnerconcrete subclass — live Balancer V3 binding (feat(contracts): live Balancer V3 swap binding for BuybackBurner #686); launch routes 0% to buyback until it lands.- Extend
DeployProtocol— add the three contracts + role grants:ROUTER_CALLER_ROLE(PaymentChannel → FeeRouter),SLASH_ROLE(SlashJudge → CapacityBond), ContentBlacklist ↔ OriginAssignment wiring. - E2E integration test — register → bond → open channel → settle through
FeeRouter→ three buckets distribute → slash → escrow → ejection → appeal.
Acceptance
- 12 canonical contracts implemented per ADR 016 § Contract Inventory
-
forge fmt --checkclean -
FOUNDRY_PROFILE=ci forge build --deny warningsclean - Per-contract unit suites with fuzz coverage on math-bearing functions: three-bucket split sum-to-10000, capacity-bond curve, voucher math, escrow-on-slash, served-bytes window accounting
- End-to-end integration test: register → bond → open channel → settle through
FeeRouter→ three buckets distribute → slash → escrow → ejection → appeal -
DeployProtocoldeploys the full set in dependency order with launch shares[9000, 0, 1000], then applies post-deployment role grants + Timelock handoff atomically - Slither / aderyn clean at CI thresholds;
forge coveragethreshold met - Public-surface stability snapshot tests (interface ABIs frozen for audit)
Out of scope
- Per-function task decomposition. The canonical ADR specs are the work breakdown; this issue does not enumerate every function as a sub-task.
- Rust integration. Tracked separately under Implement on-chain CapacityBond and PaymentChannel contract integration #327. This issue ships Solidity + Foundry only.
- Audit kickoff. Separate issue once this is feature-complete and tagged.
- Multi-token
PaymentChannel. Dropped pre-launch in favor of a single immutable USDC token set at deployment (rationale archived inadr/_history/alternatives-pre-launch.md). - Production governance UI / proposal dashboard. Frontend work.
Dependencies
- ADR: unify contract surface; drop PoC/Production phasing in favor of tunable economics #449 merged (unified contract surface, tunability framing)
- ADR surface-gap audit: missing interface blocks and unspecified function signatures across the unified contract surface #450 closed (canonical interface blocks landed in their respective ADRs)
- ADR 026 / 027 / 028 surface lock-down: review formula shapes, state machines, and signatures before implementation #451 closed (ADR 026 / 028 surface locked)
Related
- Replaces: feat(contracts): scaffold PoC EVM contract set per ADR 016 #237 (closed)
- Builds on: ADR 002, 003, 009, 011, 014, 016, 018, 022, 026, 028, 031, 036. ADR 031 covers the
ContentBlacklistappeals surface; the slash-appeal surface isSlashAppeal(ADR 028). - Superseded specs: ADR 033 / 034 / 035 (retired under the work-token rewrite + SafetyReserve removal; archived in
adr/_history/). - Follows: Implement on-chain CapacityBond and PaymentChannel contract integration #327 (Rust integration; consumes the deployed contracts).
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
docs(adr): unify contract surface; drop PoC/Production phasing (#449)
docs(adr): unify contract surface; drop PoC/Production phasing (#449) (…
docs(adr): align ADR 030 enum/table comments with lien model; add UDV…
docs(adr): add ADR 032 — SafetyReserve appeal-surface contract surface (
docs(adr): surface-lock ADR 026/028/032 (resolve #451) (#575)
chore(contracts): foundry scaffold with OZ v5.1 and CI pipeline (#634)
chore(contracts,adr): drop ERC20Votes from TOKEN; ADR 016 now matches…
feat(contracts): add TOKEN — fixed-supply ERC20 with permit and burna…
alpergundogdu commentedon May 21, 2026
Implementation plan and design notes
Posting this so the work is self-contained for anyone picking it up. The four-partition layout below has been validated against the canonical dependency graph in ADR 016 § Deployment Order; partial work so far has shipped Partition A's first two contracts.
Design principles (locked in by ADR + this work)
AccessControl + ReentrancyGuard + Pausable + SafeERC20. Signing contracts (PaymentChannel,SlashJudge,StakingRegistry.bindNode) also inheritEIP712and useSignatureCheckerso ERC-4337 / ERC-1271 smart accounts work out of the box (ADR 024).ERC20Votes(governance reads fromVotingEscrow.balanceOfAt, not raw-TOKEN checkpoints) — that pattern should be applied to every contract: if an OZ base adds public surface we don't consume, drop it and document why.MintableTokentest variant. No production-divergent behavior. Test helpers (MockSafetyReserve,MockUSDC) live undertest/mocks/and are never deployable to mainnet.Partition A — Identity + governance shell (foundation)
Contracts:
Token,StakingRegistry,VotingEscrow,PublisherRegistry,TimelockController,DecdnGovernorNo USDC flow, no bucket math. Unblocks the rest of the surface because TOKEN is wired into ~half the contracts.
TokenERC20Votes.StakingRegistry(stake-and-slash core)SafetyReserveviaISafetyReserveinterface; mock ed25519 verifier interface not needed yet (deferred with the node-registry surface).StakingRegistry(node-registry surface)registerNode,deregisterNode,bindNodeId,reclaimNodeId, multiaddrs / regionHint,NodeId ↔ addressmappings, pagination views (getActiveNodes,getActiveNodeCount,getNode,nodeIdOf), full ADR 003 semantic forisActive. Wires theIEd25519Verifierabstraction.IEd25519Verifierimpled25519-sol). Its own audit boundary — separate from StakingRegistry so the verifier can be swapped if RIP-7212 ever ships on Arbitrum. Tests use a stub verifier that always returns true.VotingEscrowbalanceOfAt(user, ts)+totalSupplyAt(ts)for the Governor vote source. Nocreate_lock_for. See ADR 034.PublisherRegistryTimelockControllerDecdnGovernorGovernor + GovernorSettings + GovernorVotes + GovernorVotesQuorumFraction + GovernorTimelockControl. Vote source =VotingEscrow.balanceOfAt. 7-day vote, 0.1% proposal threshold, 4% quorum per ADR 026 § Governance.Partition B — Settlement spine (the centerpiece, ~50% of LoC)
Contracts:
SafetyReserve,BuybackBurner,FeeRouter,DelegatorBuyer,PaymentChannel— built in this internal orderBalancerV3SwapHelper(abstract)minOut, private-RPC,epochLiquidityCapFraction, Vault-scoped self-approval. Heavy fuzz; audit pass before specializing.SafetyReserveopenSlashAppeal/fastTrackAppeal/rejectAppeal/ratifyAppeal/reverseAppeal. ImplementsISafetyReserve.recordSlashInflowforStakingRegistry.slash. Replaces the mock currently intest/mocks/.BuybackBurnerFeeRouterDelegatorBuyermsg.sender == feeRouteras sole auth (ADR 035).PaymentChannelsettleChannelcallsFeeRouter.routeSettlementin same tx.SignatureCheckerfor ERC-1271 / ERC-4337 vouchers.Once
SafetyReservelands,StakingRegistry.setSafetyReservegets wired to the real address and the mock undertest/mocks/MockSafetyReserve.solstays for unit tests.Partition C — Content authorization (disjoint from money)
Contracts:
ContentBlacklist,OriginAssignment,SlashJudgeTouches
StakingRegistry(BLACKLIST_ROLE, SLASH_ROLE — both already wired in the current StakingRegistry) but never touchesFeeRouter. Can be built fully in parallel with Partition B once Partition A's node-registry surface is in.ContentBlacklistStakingRegistryforejectNode.OriginAssignmentsetContentBlacklistis one-shot post-deploy wiring.SlashJudgeStakingRegistry.slash(operator, challenger, offenseType). EIP-712 +SignatureChecker.nextSlashIdmonotonic counter. See ADR 014.Partition D — Deploy + post-deploy wiring + E2E
Artifacts:
script/Deploy.s.sol— deploys all 14 contracts in the 15-step order from ADR 016 § Deployment Order. Launch config80/0/0/10/10/0with zero-address dependencies forVotingEscrow/SafetyReserve/DelegatorBuyer(cross-validation invariant ensures any non-zero share has a non-zero destination).register → stake → open channel → settle through FeeRouter → buckets distribute → claim flows → slash → ejection → appeal.forge coveragethreshold gate.Cross-cutting infrastructure (build incrementally)
test/mocks/—MockSafetyReserveexists. AddMockUSDC(5-lineERC20 + mint()) whenPaymentChannel/FeeRouterwork begins. Both never leavetest/— auditor sees nothing insrc/they shouldn't.solidityjob is wired into the unifiedci.ymlaggregator. Addslitherandforge coveragejobs in Partition D, gated through the sameci-successalls-green pattern.default/ci(1024 fuzz, 256-depth invariants) /fuzz(10k runs, nightly) /coverage(optimizer off). Pinnedsolc 0.8.28,evm cancun,optimizer_runs 200.Open questions surfaced during work (need ADR clarification)
ADR 026 § Slashing and burn mentions "increasing reset periods" without defining them. Current implementation uses a pure lifetime counter with no reset. If a reset semantic is intended (e.g., counter decays after N days of clean operation), the ADR should specify the periods and a follow-up adds the logic.
ADR 014 line 237 had a 2-arg slash signature that didn't include the challenger. That row has been updated in-place to the canonical 3-arg form
slash(operator, challenger, offenseType) returns (uint256 slashAmount). No further action needed unless a different scheme is preferred (e.g., SlashJudge holding the full slashed amount and disbursing itself — see PR discussion for rejected alternatives).USDC
permitavailability is assumed across all target chains (Arbitrum One + Sepolia have it as of late 2024). If we ever target a chain where bridged USDC lacks EIP-2612,PaymentChannel.openChannelneeds a non-permit fallback path. Worth a quick check before the PaymentChannel PR.Picking this up
The repo is set up so the next PR is unblocked the moment the previous one merges:
contracts/src/contracts/src/interfaces/contracts/test/mocks/contracts/test/<Contract>.t.solforge fmtstyle (bracket spacing, line length 120, double quotes, snake_case test names)cd contracts && forge fmt --check && FOUNDRY_PROFILE=ci forge build --sizes && FOUNDRY_PROFILE=ci forge testConventional commits enforced by the
Semantic PR titlecheck — subject must start lowercase. Usefeat(contracts):for new contracts,chore(contracts):for tooling,docs(adr):for spec changes.The original 14-contract list and acceptance criteria above remain canonical; this comment is just the execution layout.
16 remaining items
alpergundogdu commentedon May 22, 2026
Progress update — Partition A complete
Partition A (identity + governance shell) is done; all custom contracts are merged to
main.TokenERC20+ERC20Burnable+ERC20Permit.ERC20Votesomitted — the Governor reads ve-balance, not raw-TOKEN checkpoints, so the per-transfer checkpoint cost isn't earned.StakingRegistryregisterNode/deregisterNode/updateMultiaddrs/bindNodeId/reclaimNodeId), NodeId↔address binding, pagination views. Slash isslash(operator, challenger, offenseType) → uint256. ed25519 ownership proof required on bothregisterNodeandbindNodeId(anti-squat);reclaimNodeIdis the backstop and zeroes the holder's staleNodeInfo.nodeIdfor read-view consistency. ed25519 verification sits behindIEd25519Verifier(mock for tests; production impl deferred — see below).VotingEscrowbalanceOfAt/totalSupplyAt. Vote delegation deferred (see below).PublisherRegistryAccessControl-only (noReentrancyGuard/Pausable); permissionless namespaces; 2-step timelocked ownership transfer with the per-publisher cap enforced on the recipient atfinalize; append-only multi-claim content.DecdnGovernorGovernor+GovernorCountingSimple+GovernorTimelockControlwith a custom ve vote source (_getVotes→VotingEscrow.balanceOfAt; quorum/threshold →totalSupplyAt).GovernorVotes/GovernorVotesQuorumFractionare not used becauseVotingEscrowis notIVotes(it exposes decaying ve-weight, not voting-unit checkpoints). Fixed params: timestamp clock, 1-day delay, 7-day vote, 0.1% threshold, 4% quorum (~10-day total latency).TimelockControllerDeferred (tracked)
IEd25519Verifier(feat(contracts): production IEd25519Verifier for on-chain NodeId ownership proof #669) — only the interface + test mock exist. On-chain ed25519 verification needs a vetted library + NodeId decompression withverify_strict-parity safety checks; library selection is part of that issue. It is a deploy blocker forStakingRegistrybut blocks nothing else (the mock covers unit tests).VotingEscrowvote delegation (feat(contracts): vote delegation for VotingEscrow (Governor Bravo over decaying ve-weight) #670) — for now each voter votes their own ve-balance. Delegating decaying ve-weight requires per-delegate bias/slope checkpointing inVotingEscrow(not ERC20Votes-style static checkpoints). ADRs 009/016/026 updated to mark delegation deferred.ADRs updated alongside the contracts
002 (PublisherRegistry surface, uint64 types), 003 (node registry / deregister /
bindNodeIded25519 / reclaim semantics), 009 (governance params, delegation deferral, ~10-day latency), 014 (slash signature), 016 (TOKEN + PublisherRegistry + DecdnGovernor inventory/composition), 026 (governance table).Remaining
BalancerV3SwapHelper→SafetyReserve→BuybackBurner→FeeRouter→DelegatorBuyer→PaymentChannel). Unblocked; needs Balancer V3 integration.ContentBlacklist→OriginAssignment→SlashJudge). Unblocked, disjoint from the money path;ContentBlacklist/SlashJudgepair directly with theslash/ejectNodesurface already shipped.alpergundogdu commentedon May 29, 2026
Status reconciliation against the canonical ADRs (2026-05-30)
This issue was last updated 2026-05-22 (Partition A complete). Two large changes landed afterward that the body above predates:
CapacityBond.ADR 016 § Contract Inventory was rewritten on 2026-05-27 to match, and ADR 036 (served-bytes voting weight) was added. Net effect: the 14-contract scope, the six-bucket
FeeRouter,VotingEscrow,SafetyReserve, andDelegatorBuyerin the body above are all stale. Reconciliation and a plan-to-close below.1. Canonical surface is now 12 contracts, not 14
src/?DeployProtocol?Token(noERC20Votes)CapacityBond(renamed + reshaped)PaymentChannelFeeRouter(3-bucket)BuybackBurner(abstract)ContentBlacklistPublisherRegistryOriginAssignmentSlashJudgeDecdnGovernor(served-bytes vote source)TimelockController(OZ)SlashAppeal(new; ADR 028)Ed25519Verifier, #712)Net: −3 removed (VotingEscrow, SafetyReserve, DelegatorBuyer), 1 renamed (StakingRegistry → CapacityBond), +1 added (SlashAppeal). 14 − 3 + 1 = 12.
2. Model changes driving the drift
CapacityBond. The operator registry now runs the capacity-bond curvebond = k·Mbps^α, escrow-on-slash, andPendingCreditvesting for the 50M Genesis Bond Credit allocation. There is no separate emissions contract. (rewritten ADR 026)FeeRouter: 6 buckets → 3. Now[operator, buyback, treasury], canonical steady-state 60/30/10, with no epoch buckets and no claim windows (all three legs transfer same-tx). Launch ships a simplified 90/0/10 (feeRouterShares = [9000, 0, 1000]); shares are governance-tunable within operator ∈ [40,90]%, buyback ∈ [5,50]%, treasury ∈ [0,30]%. The body's80/0/0/10/10/0launch config no longer exists.FeeRouter.bytesInWindowserved-bytes accounting +CapacityBond.firstBondedAttenure ramp +slashedAtEpochzero-out (ADR 036).#670(ve delegation) is mooted.CapacityBond; finality distribution is 50% challenger / 50% burn; theFeeRouterbuyback leg burns. (refactor(contracts): remove SafetyReserve; escrow-on-slash + 5% bucket to burn #708)SlashAppealis new — the ADR 028 appeal state machine (openSlashAppeal/fastTrackAppeal/rejectAppeal/grantAppeal/upholdAppeal/cleanupExpiredAppeal) that used to be bolted onto SafetyReserve, now standalone and wired toCapacityBond's escrow hooks.3. Already shipped (issue still lists these as TODO / deferred)
Ed25519Verifier— production impl merged (feat(contracts): production Ed25519Verifier (closes #669) #712, closes feat(contracts): production IEd25519Verifier for on-chain NodeId ownership proof #669). The body still defers this to feat(contracts): production IEd25519Verifier for on-chain NodeId ownership proof #669.DeployProtocol— merged (feat(contracts): production DeployProtocol script (closes #694) #700, closes Production DeployProtocol.s.sol with atomic deployer→Timelock role handoff #694), but only for the 8-contract live set (Token, CapacityBond, SlashAppeal, FeeRouter, ContentBlacklist, PublisherRegistry, DecdnGovernor, OZ Timelock) with grant-before-revoke handoff to the Timelock.4. Genuinely remaining to close this issue (the plan)
In dependency order:
PaymentChannel(ADR 003) — the USDC settlement gateway. EIP-712 vouchers, 48h dispute window, operator early-withdraw-while-open (ADR 003, docs(adr): operator early withdrawal (withdraw-while-open) in ADR 003 #710),settleChannel→FeeRouter.routeSettlementsame-tx. Biggest gap: nothing feedsFeeRouteron-chain without it. The contract is 452 scope; Rust integration stays in Implement on-chain CapacityBond and PaymentChannel contract integration #327.SlashJudge(ADR 014) — evidence verification + challenge bonds; holder ofSLASH_ROLE, the contract that actually callsCapacityBond.slash(operator, challenger, offenseType). TodaySLASH_ROLEis granted to nobody in the deploy, so slashing has no on-chain trigger.OriginAssignment(ADR 011) — default-open allow-list; one-shotsetContentBlacklistwiring. Spec-only today.BuybackBurnerconcrete subclass — the swap helper is abstract; the live Balancer V3 binding is feat(contracts): live Balancer V3 swap binding for BuybackBurner #686. Until it lands, launch routes 0% to buyback. [your call]: ship the binding under this issue, or leave it to feat(contracts): live Balancer V3 swap binding for BuybackBurner #686 and only dial the bucket up post-launch.DeployProtocol— add the three contracts + role grants:ROUTER_CALLER_ROLE(PaymentChannel → FeeRouter),SLASH_ROLE(SlashJudge → CapacityBond), and ContentBlacklist ↔ OriginAssignment wiring.register → bond → open channel → settle through FeeRouter → 3 buckets distribute → slash → escrow → ejection → appeal. Drop the "claim flows" leg (no claim windows) and the ve/gauge fuzz targets.5. Acceptance criteria — proposed rewrite
forge fmt --checkcleanFOUNDRY_PROFILE=ci forge build --deny warningscleanDeployProtocoldeploys the full set in dependency order with launch shares[9000, 0, 1000], then atomic role grants + Timelock handoffforge coveragegate; ABI snapshot freeze[your call] whether to fold this into the issue body or keep the body as historical and treat this comment as the live scope.
6. Related drift worth a sweep [your call]
These open issues still name the removed
SafetyReserveand should be re-scoped or closed:MAX_APPEAL_RESTITUTIONfor SafetyReserve" → the mechanic now lives inSlashAppeal.BuybackBurnerremains (item 4 above).SlashAppealand confirm the bug reproduces there.CapacityBond; it remains the Rust-integration follow-on.feat(contracts): add PaymentChannel USDC settlement gateway (#452) (#716
feat(contracts): add SlashJudge evidence verification + challenge bon…
feat(contracts): add SlashJudge evidence verification + challenge bon…
fix(contracts): suppress slither medium findings in OriginAssignment/…
feat(contracts): extend DeployProtocol with new contracts + E2E (#452)
fix(contracts): suppress aderyn reentrancy finding on second external…
feat(contracts): add OriginAssignment publisher-propose / DAO-ratify …
fix(contracts): grant PAUSER_ROLE to emergency multisig at deploy (#452)
test(contracts): close PR review gaps in deploy wiring + E2E (#452)
feat(contracts): extend DeployProtocol + full E2E integration (#452) (#…