Skip to content

feat(contracts): CapacityBond terms-hash acceptance at registration + governor-swappable currentTermsHash (ADR 019 §Terms Acceptance) #1076

Closed

Description

@alpergundogdu

Context

ADR 019 §Terms Acceptance and §Governance-canonical terms version (adr/019-node-onboarding.md:241-247) specify that node registration records the operator's acceptance of the current operator terms, carried in the EIP-712 registration signature, with a governance-canonical currentTermsHash on CapacityBond. The legal text (TERMS.md, #1044) and the ADR design (#1023) are merged, but the ADR explicitly calls the shown signatures "the pre-extension surface" — the contract change was never implemented.

Confirmed gaps in contracts/src/CapacityBond.sol:

  • BIND_NODE_TYPEHASH = keccak256("BindNodeId(bytes32 nodeId,uint64 nonce)") (:183) — no termsHash.
  • registerNode(...) (:691) takes no termsHash; no acceptance recorded.
  • No currentTermsHash state, no setCurrentTermsHash governor setter, no TermsAccepted event, no mismatch revert.
  • Zero terms references anywhere in contracts/src.

Scope (this issue — contract only)

CapacityBond.sol

  • Add bytes32 public currentTermsHash, initialized in the constructor (genesis launches with a real version — no permissive zero-default bootstrap).
  • Add REGISTER_NODE_TYPEHASH = keccak256("RegisterNode(bytes32 nodeId,uint64 nonce,bytes32 termsHash)"). Registration gets its own typehash; bindNodeId (rebind/key-rotation) keeps BIND_NODE_TYPEHASH unchanged, honoring ADR 019 §245 "enforcement at registration only" (rotating keys never re-accepts terms).
  • registerNode gains a bytes32 termsHash param: verify the binding signature over REGISTER_NODE_TYPEHASH; revert TermsHashMismatch(provided, expected) if termsHash != currentTermsHash; emit TermsAccepted(nodeId, termsHash, timestamp).
  • setCurrentTermsHash(bytes32 newHash) under GOVERNANCE_ROLE (governor-swappable, matching the other tunable-param setters). No [floor, ceiling] rail — a hash has no monotonic direction (ADR 019 §243). Emit CurrentTermsHashUpdated(old, new).

Wiring — touches deploy + all construction sites + interface freeze

  • Constructor arity change: update script/BaseProtocolDeploy.s.sol, script/DeployProtocol.s.sol (pass keccak256(TERMS.md) at genesis), and every test construction site.
  • registerNode selector + constructor change ⇒ update test/InterfaceFreeze.t.sol frozen set.

Test plan

  • register with termsHash == currentTermsHash succeeds, emits TermsAccepted.
  • register with stale/wrong termsHash reverts TermsHashMismatch.
  • signature must cover termsHash (a sig over a different hash reverts InvalidBindingSignature).
  • setCurrentTermsHash: role-gated, emits event; a bump binds new registrants; already-registered nodes unaffected.
  • bindNodeId (rebind) still works with the unchanged BindNodeId payload — no terms required (regression).
  • shared bindingNonce replay protection holds across registerNode/bindNodeId.

ADR reconciliation

  • ADR 003 §NodeId Binding: document the RegisterNode typed struct (termsHash field) as distinct from BindNodeId; drop the "pre-extension surface" caveat in ADR 019 §109.
  • ADR 019 §241-247: mark the contract surface as shipped.

Refs

CI reminders (Solidity)

  • FOUNDRY_PROFILE=ci forge build --sizes --deny warnings — watch CapacityBond --sizes (added storage/branch nudges bytecode toward EIP-170).
  • emit TermsAccepted before any revert path stays clear of W5740/mutability traps.
  • aderyn (fail-on high) / slither (fail-on medium) both run in CI.

Activity

  1. added
    kind:feature
    on Jul 7, 2026
  2. added a commit that references this issue on Jul 7, 2026
    0d73fe3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind:feature

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions