Skip to content

Production DeployProtocol.s.sol with atomic deployer→Timelock role handoff #694

Closed

Description

@thiras

Summary

Only contracts/script/TestnetFaucet.s.sol exists. The faucet's own header (L12) notes: "production deploy script MUST be named differently". There is no script that deploys the full v3 protocol surface in ADR 016 §2 dependency order and atomically transfers GOVERNANCE_ROLE (and related setter roles) from the deployer to TimelockController.

Without this, every deploy is a manual sequence of forge create calls plus separate grantRole / renounceRole transactions — which is both error-prone and leaves a window where the deployer EOA holds god-mode on production contracts.

Why prod-blocking

  • Any Sepolia or mainnet deploy needs a reproducible, scripted, audit-reviewable deployment artifact.
  • The role-handoff atomicity is a security property: if a deploy script revert leaves DEFAULT_ADMIN_ROLE on the deployer EOA, post-mortem custody becomes a per-deploy ad-hoc operation rather than a known-good pattern.
  • Issue Governance lifecycle test suite: propose → vote → queue → execute for every governable parameter #693 (governance lifecycle tests) assumes Timelock holds GOVERNANCE_ROLE on every target; this script is the production realization of that assumption.

Scope

New contracts/script/DeployProtocol.s.sol that:

  1. Deploys in ADR 016 §2 order:
    Token → CapacityBond → FeeRouter (with safetyReserve/buybackBurner initially address(0), set in step 2 per ADR 016's §Tunable Economics note) → SafetyReserve → BuybackBurner → ContentBlacklist → PublisherRegistry → TimelockController (48h delay, proposers/executors set in step 3) → DecdnGovernor.
  2. Wires post-deploy dependencies: FeeRouter.setSafetyReserve, FeeRouter.setBuybackBurner, SafetyReserve grants to CapacityBond's APPEAL_REVERSAL_ROLE, etc.
  3. Configures Timelock: grants PROPOSER_ROLE and CANCELLER_ROLE to DecdnGovernor, grants EXECUTOR_ROLE to address(0) (open execution), revokes Timelock's own admin role from the deployer.
  4. Atomic role handoff on every target contract:
    • grantRole(GOVERNANCE_ROLE, address(timelock)) on FeeRouter, CapacityBond, ContentBlacklist, SafetyReserve, PublisherRegistry.
    • grantRole(EMERGENCY_MULTISIG_ROLE, <multisig from env>) on SafetyReserve and other emergency surfaces.
    • renounceRole(DEFAULT_ADMIN_ROLE, deployer) on every contract — last step, after all other grants confirmed.

Env-var contract:

  • USDC_ADDRESS — settlement token (Arbitrum Sepolia USDC for testnet)
  • EMERGENCY_MULTISIG — 3-of-5 multisig for EMERGENCY_MULTISIG_ROLE
  • TREASURY_ADDRESS — initial treasury destination (often the Timelock itself per ADR 016)
  • TIMELOCK_DELAY — defaults to 48h per ADR 009

Acceptance

  • forge script script/DeployProtocol.s.sol --rpc-url <fork> runs against an Arbitrum Sepolia fork and succeeds end-to-end.
  • Post-deploy assertions in the script verify, for every contract: hasRole(DEFAULT_ADMIN_ROLE, deployer) == false and hasRole(GOVERNANCE_ROLE, timelock) == true.
  • A companion DeployProtocol.t.sol runs the script in-process via vm.startStateDiffRecording (or equivalent) and asserts the final role topology matches ADR 016 §Role Matrix.
  • Deployed addresses are written to a deterministic JSON manifest (deployments/<chainid>.json) for downstream tooling.

Out of scope

  • Mainnet deployment of TOKEN's initial supply distribution (Genesis Bond Credits etc. per ADR 026) — that's a separate one-shot script.
  • Verification on Arbiscan — should be a separate CI step driven from the manifest.
  • Frontend address-injection — separate website-repo work.

Related

Activity

  1. added
    kind:feature
    on May 28, 2026
  2. added
    kind:security
    on May 28, 2026
  3. github-actions commented on May 28, 2026

    @github-actions

    🎯 Triage report

    This issue requests a new contracts/script/DeployProtocol.s.sol that orchestrates the full v3 contract surface deployment in ADR 016 §2 dependency order, then atomically hands off all privileged roles from the deployer EOA to TimelockController. The security motivation is clear: without this, any partial-revert during a manual deploy leaves DEFAULT_ADMIN_ROLE on the deployer indefinitely. It directly unblocks #693 (governance lifecycle tests) and is explicitly marked prod-blocking.

    📊 Assessment

    Dimension Value Reasoning
    Type Task Concrete implementation deliverable with well-specified acceptance criteria; no design ambiguity
    Labels security added (existing: enhancement, technical, architecture, prod-blocking) The deployer-EOA god-mode window is a live security property, not just a missing feature
    Coding agent Suitable Scope is fully specified: deploy order, post-deploy wiring calls, Timelock config, role-handoff sequence, env-var contract, acceptance assertions, manifest output, and companion test file are all enumerated in the issue

    🔗 Similar issues

    💡 Notes and suggestions

    Implementation checklist

    • contracts/script/DeployProtocol.s.sol — Script subcontract, uses vm.startBroadcast(deployer)
    • Deploy order (ADR 016 §2): Token → CapacityBond → FeeRouter (with zero addresses for SR/BB) → SafetyReserve → BuybackBurner → ContentBlacklist → PublisherRegistry → TimelockController → DecdnGovernor
    • Post-deploy wiring: FeeRouter.setSafetyReserve, FeeRouter.setBuybackBurner, SafetyReserve → CapacityBond APPEAL_REVERSAL_ROLE grant
    • Timelock config: PROPOSER_ROLE+CANCELLER_ROLE → Governor; EXECUTOR_ROLE → address(0); revoke deployer's Timelock admin
    • Role handoff on all targets: grantRole(GOVERNANCE_ROLE, timelock), grantRole(EMERGENCY_MULTISIG_ROLE, multisig), renounceRole(DEFAULT_ADMIN_ROLE, deployer) — renounce last
    • Post-deploy assertions in-script (not just in the test): loop all targets, assert !hasRole(DEFAULT_ADMIN_ROLE, deployer) and hasRole(GOVERNANCE_ROLE, timelock)
    • Manifest write: deployments/<chainid>.json with all contract addresses + deploy block
    • contracts/test/DeployProtocol.t.sol: runs script in-process via vm.startStateDiffRecording, asserts ADR 016 §Role Matrix topology

    Solidity CI gotchas to watch:

    • renounceRole on DEFAULT_ADMIN_ROLE is the last call — if any earlier grant reverts, the admin role stays with the deployer; consider a require-after-renounce guard
    • FOUNDRY_PROFILE=ci forge build --sizes --deny warnings will catch any unreachable-code warnings introduced by always-reverting stubs; avoid adding nonReentrant on any always-reverting function (W5740 trap per CLAUDE.md)
    • forge fmt must pass before CI; run pre-commit run --all-files before push

    Env-var validation: add explicit require(usdcAddress != address(0), "USDC_ADDRESS not set") guards at script top; a silent zero-address for USDC would deploy a broken-but-non-reverting protocol

    Generated by Agentic Triage for issue #694 · ● 1.7M · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
    
  4. self-assigned this
    on May 28, 2026
  5. added a commit that references this issue on May 29, 2026
    f54e98c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind:featurekind:security

Type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions