Skip to content

feat(contracts): terms-hash acceptance at registration + governor-swappable currentTermsHash (#1076) - #1078

Merged
alpergundogdu merged 3 commits into
mainfrom
claude/elegant-goldstine-c7e4d8
Jul 7, 2026
Merged

alpergundogdu merged 3 commits into
mainfrom
claude/elegant-goldstine-c7e4d8

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1076. Ships the on-chain half of ADR 019 § Terms Acceptance, which until now existed only as spec — ADR 019 §109 called the shown signatures the "pre-extension surface" and no contract carried termsHash. The legal text (#1044) and ADR (#1023) had already merged; this is the missing contract.

What changed

CapacityBond

  • registerNode gains a termsHash param. It must equal the governance-canonical currentTermsHash (TermsHashMismatch otherwise) and is covered by the binding signature over a new RegisterNode(nodeId,nonce,termsHash) typehash. Emits TermsAccepted(nodeId, termsHash, timestamp).
  • currentTermsHash is set at genesis (constructor) and governor-swappable post-deploy via setCurrentTermsHash under GOVERNANCE_ROLE. No [floor, ceiling] rail — a hash has no monotonic direction (ADR 019 §243).
  • Registration-only enforcement: bindNodeId (key rotation) keeps the unchanged BindNodeId payload and never re-accepts terms. The distinct typehash prevents replaying a registration signature as a bare rebind; the shared bindingNonce preserves cross-path replay protection.

Deploy: DeployConfig.currentTermsHash threaded through BaseProtocolDeploy / DeployProtocol (env CURRENT_TERMS_HASH, default 0).

ADRs: ADR 003 § NodeId Binding documents the RegisterNode typed struct alongside BindNodeId; ADR 019 drops the pre-extension caveat and names setCurrentTermsHash.

Design note

Registration uses its own RegisterNode typehash rather than extending BindNodeId, so key rotation stays a pure rebind with no meaningless terms re-acceptance. Genesis initializes currentTermsHash in the constructor (no permissive zero-default bootstrap).

Tests (7 new, all TDD + negative-controlled)

recordsTermsAcceptance, revertsOnTermsHashMismatch, signatureMustCoverTermsHash, setCurrentTermsHash_onlyGovernance, _emitsAndSwaps, _bindsNewRegistrantsOnly, bindNodeId_rebindRequiresNoTermsAcceptance. Negative control confirmed the behavior tests fail when the check/event is removed.

CI-mirror (local)

  • forge fmt --check clean; FOUNDRY_PROFILE=ci forge build --deny warnings exit 0 (CapacityBond 23,019 B, 1,557 under EIP-170).
  • forge test: 682 passed, 0 failed.
  • aderyn: 4 highs — identical to pre-change baseline (known local over-report; no new finding).
  • slither (fail_on: medium): exit 0; no finding references the new symbols.

Follow-up

CLI display + acceptance flow: #1077 (depends on this).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Node registration now requires acceptance of the currently active operator terms, tied to a terms hash in the onboarding signature flow.
    • Governance can update the active terms hash, affecting subsequent registrations.
  • Bug Fixes

    • Registration signature verification now aligns with the on-chain terms state, preventing failures from stale or incomplete signatures.
    • Rebinding continues to work without requiring terms re-acceptance.
  • Tests

    • Expanded unit and end-to-end test coverage for terms acceptance, signature validation rules, governance updates, and rebinding behavior.

…ppable currentTermsHash (#1076)

Ships the on-chain half of ADR 019 § Terms Acceptance, previously only
specified ("pre-extension surface"). `CapacityBond.registerNode` now carries a
`termsHash` the operator accepts; it must equal the governance-canonical
`currentTermsHash`, is covered by the binding signature over a distinct
`RegisterNode(nodeId,nonce,termsHash)` typehash, and emits
`TermsAccepted(nodeId, termsHash, timestamp)`.

- `currentTermsHash` is set at genesis (constructor) and swapped post-deploy via
  `setCurrentTermsHash` under GOVERNANCE_ROLE — no `[floor, ceiling]` rail since
  a hash has no monotonic direction (ADR 019 §243).
- Enforcement is registration-only: `bindNodeId` (key rotation) keeps the
  unchanged `BindNodeId` payload and never re-accepts terms. The distinct
  typehash blocks replaying a registration signature as a bare rebind; the
  shared `bindingNonce` preserves cross-path replay protection.
- Deploy config threads `currentTermsHash` (env `CURRENT_TERMS_HASH`, default 0).
- ADR 003 § NodeId Binding documents the `RegisterNode` struct; ADR 019 drops
  the pre-extension caveat and names the setter.

CLI display + acceptance flow is the tracked follow-up (#1077).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Copilot AI review requested due to automatic review settings July 7, 2026 15:03
@github-actions

github-actions Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Contracts coverage

Line coverage: 91.52% (2320/2535 lines)
▲ +0.65pp vs base (90.87% → 91.52%)
Run: 28879010890

@github-actions

github-actions Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@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 implements operator terms acceptance during node registration as specified in ADR 019. It introduces a new RegisterNode EIP-712 typed structured data format that includes a termsHash parameter, which must match the governance-canonical currentTermsHash stored in the CapacityBond contract. The registerNode function has been updated to validate this hash and signature, emitting a TermsAccepted event upon success. Additionally, a governance-restricted setCurrentTermsHash function has been added to allow updating the canonical terms hash. Deployment scripts and test suites have been updated accordingly to support and verify this new workflow. I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

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 implements ADR 019’s on-chain “operator terms acceptance” mechanism by extending CapacityBond.registerNode to require/verify a termsHash that matches a governance-canonical currentTermsHash, recording acceptance on-chain and allowing governance to update the canonical hash over time.

Changes:

  • Added currentTermsHash, REGISTER_NODE_TYPEHASH, TermsAccepted, and a governance-gated setCurrentTermsHash to CapacityBond, and updated registerNode to enforce and signature-bind termsHash.
  • Threaded currentTermsHash through protocol deployment configuration/wiring.
  • Updated ADR 019 and ADR 003 to reflect the shipped RegisterNode typed struct and registration-only enforcement; updated tests accordingly.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
contracts/src/CapacityBond.sol Enforces terms-hash at registration via new EIP-712 payload; adds governance-swappable currentTermsHash and acceptance/event surface.
contracts/script/BaseProtocolDeploy.s.sol Extends deploy config and constructor wiring to pass currentTermsHash into CapacityBond.
contracts/script/DeployProtocol.s.sol Reads CURRENT_TERMS_HASH into deployment config for genesis initialization.
contracts/test/CapacityBond.t.sol Adds and updates tests covering terms-hash enforcement, signature binding, and governance updates.
contracts/test/CapacityBondRegionE2E.t.sol Updates E2E region registration helpers/calls to use RegisterNode(..., termsHash).
contracts/test/E2EProtocol.t.sol Updates registration signing helper and registerNode call site for new typehash + termsHash.
contracts/test/DeployProtocol.t.sol Updates deploy fixture config to include currentTermsHash.
contracts/test/GovernanceLifecycle.t.sol Threads currentTermsHash through governance lifecycle fixture config.
contracts/test/SlashAppeal.t.sol Updates deploy config construction to include currentTermsHash.
contracts/test/CapacityBondSlashJudgeInvariant.t.sol Updates deploy config construction to include currentTermsHash.
adr/019-node-onboarding.md Removes “pre-extension” caveat and documents the shipped RegisterNode/currentTermsHash behavior.
adr/003-payments.md Documents the two typed structs (RegisterNode vs BindNodeId) and registration-time-only terms enforcement.

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

Comment thread contracts/script/DeployProtocol.s.sol Resolved
Comment thread contracts/src/CapacityBond.sol Resolved
Comment thread contracts/test/CapacityBond.t.sol Resolved
…rough Rust ABI, refresh gas snapshot

Addresses CI + review on #1078.

Contract:
- CapacityBond rejects the zero `currentTermsHash` sentinel in the constructor
  and `setCurrentTermsHash` (`ZeroTermsHash`), so genesis must commit to a real
  (possibly draft) terms version and governance can only swap to another
  non-zero one — no permissive terms-disabled bootstrap. Addresses Copilot
  review on the constructor/deploy zero-default.
- DeployProtocol.s.sol now REQUIRES `CURRENT_TERMS_HASH` (no zero default);
  dev-deploy.sh + the anvil/e2e harnesses pass a non-zero placeholder.

Rust ABI (the contract signature change reached the registration path):
- bind_sig: add `RegisterNode(nodeId,nonce,termsHash)` typed struct +
  `register_node_signing_hash`, with a type-hash parity test vs the contract.
  `BindNodeId` / `binding_signing_hash` stay for ephemeral client bindings and
  key-rotation rebinds.
- capacity_bond + e2e bindings: `registerNode` gains `termsHash`; add
  `currentTermsHash()` view.
- register.rs + e2e chain fixtures read `currentTermsHash` on-chain, sign
  `RegisterNode`, and pass `termsHash`. Operator-facing terms display +
  explicit acknowledgement remains #1077.

Also: regenerated the stale `.gas-snapshot`, and fixed a `BindNode` → `BindNodeId`
doc typo in the test helper (Copilot review). Full anvil settlement e2e passes.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a523ef61-6e58-407e-a0d9-3397f1f40367

📥 Commits

Reviewing files that changed from the base of the PR and between fc8f410 and dc65040.

📒 Files selected for processing (3)
  • adr/019-node-onboarding.md
  • contracts/.gas-snapshot
  • contracts/test/DeployProtocolScript.t.sol
✅ Files skipped from review due to trivial changes (1)
  • contracts/.gas-snapshot
🚧 Files skipped from review as they are similar to previous changes (2)
  • contracts/test/DeployProtocolScript.t.sol
  • adr/019-node-onboarding.md

Walkthrough

This PR adds registration-time termsHash acceptance to CapacityBond, introduces a governance-managed currentTermsHash, and updates deploy wiring, tests, Rust bindings, and CLI/e2e registration flows to use the new RegisterNode signature.

Changes

Terms Acceptance Feature

Layer / File(s) Summary
ADR updates
adr/003-payments.md, adr/019-node-onboarding.md
ADRs add RegisterNode with termsHash, require registration against currentTermsHash, distinguish registration from rebinding, and describe governance updates to currentTermsHash.
CapacityBond registration and governance
contracts/src/CapacityBond.sol
Adds REGISTER_NODE_TYPEHASH, currentTermsHash, terms acceptance errors and events, constructor validation, registration-time termsHash enforcement and signature verification, and setCurrentTermsHash.
Deploy config and script wiring
contracts/script/BaseProtocolDeploy.s.sol, contracts/script/DeployProtocol.s.sol, contracts/dev-deploy.sh
Deploy config and scripts now carry currentTermsHash from CURRENT_TERMS_HASH into CapacityBond deployment.
Solidity test updates
contracts/test/CapacityBond*.t.sol, contracts/test/DeployProtocol*.t.sol, contracts/test/E2EProtocol.t.sol, contracts/test/GovernanceLifecycle.t.sol, contracts/test/SlashAppeal.t.sol
Tests now construct CapacityBond with currentTermsHash, sign RegisterNode payloads with termsHash, and cover terms acceptance and governance behavior.
Rust bindings and registration flows
crates/incentive/src/*, crates/e2e/src/*, crates/cli/src/commands/register.rs, crates/node/tests/anvil_settlement_e2e.rs
Rust bindings add currentTermsHash/registerNode termsHash support, and CLI/e2e/node flows fetch the on-chain hash and pass it through signing and registration calls.
Gas snapshot regeneration
contracts/.gas-snapshot
Recorded gas values are updated across affected Solidity test suites.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related issues

Possibly related PRs

  • decdn/decdn#1053: The crates/e2e/src/chain.rs onboarding flow here is directly related to the e2e harness introduced in this PR.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning Most ADR 019 contract and wiring requirements are covered, but the required InterfaceFreeze.t.sol update isn't shown in the changed files. Add the interface freeze test update for CapacityBond's constructor and registerNode signature, then rerun the suite.
Out of Scope Changes check ⚠️ Warning The CLI registration flow change appears outside the issue scope, which called the CLI follow-up separately. Move the CLI registration changes to the separate follow-up or document why they belong in this PR.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main contract change around terms-hash registration and swappable currentTermsHash.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/elegant-goldstine-c7e4d8

Comment @coderabbitai help to get the list of available commands.

@alpergundogdu

Copy link
Copy Markdown
Contributor Author

Update — CI fixes + review feedback (fc8f410)

The initial commit changed the registerNode ABI, which rippled further than the Solidity surface. Addressed:

CI failures

  • solidity build+test was the stale .gas-snapshot (renamed/shifted gas entries) — regenerated with FOUNDRY_PROFILE=ci forge snapshot --snap.
  • anvil e2e reverted with empty data because the Rust registration path called the old registerNode selector. Threaded termsHash through the Rust ABI: new RegisterNode EIP-712 signing helper (with a type-hash parity test), registerNode(...,termsHash,...) + currentTermsHash() on the alloy bindings, and register.rs + the e2e fixtures read currentTermsHash on-chain and sign RegisterNode. The full anvil settlement e2e passes locally (4/4).

Review (Copilot) — zero-default hardening

  • CapacityBond now rejects the zero currentTermsHash sentinel in the constructor and setCurrentTermsHash (ZeroTermsHash). DeployProtocol.s.sol requires CURRENT_TERMS_HASH (no default). Genesis must commit to a real (possibly draft) terms version; no permissive terms-disabled bootstrap.
  • Fixed the BindNode → BindNodeId doc typo.

Operator-facing terms display + explicit acknowledgement remains scoped to #1077; this PR delivers the on-chain enforcement + ABI compatibility.

Local CI-mirror: forge fmt/build --deny warnings, 684 solidity tests, gas snapshot stable, aderyn (== baseline) + slither clean; cargo fmt/clippy/nextest (incentive+cli) + anvil e2e all green.

@github-actions

github-actions Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 82.06% (was 82.11%, ▼ 0.05%) — 42388/51654 lines

File Coverage Lines Δ
crates/cli/src/commands/register.rs 28.73% 52/181 ▼ 1.16%
crates/e2e/src/chain.rs 2.96% 11/372 ▼ 0.11%
crates/incentive/src/bind_sig.rs 87.60% 113/129 ▼ 9.68%
History
Commit Total Δ vs base
fc8f410 82.06% ▼ 0.05%
dc65040 (HEAD) 82.06% ▼ 0.05%

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
adr/019-node-onboarding.md (1)

83-113: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Step 2.3 call signature and atomic-actions list are now internally inconsistent.

Line 85 still shows registerNode(nodeId, multiaddrs, regionHint, bindingSignature, ed25519Signature) (no termsHash), and the bullet at line 89 still describes verifying BindNodeId(nodeId, bindingNonce[ethAddress]). Both contradict the newly added text at lines 104-109 (and the shipped call site in E2EProtocol.t.sol, which passes termsHash as a positional argument and signs RegisterNode).

📝 Proposed fix to reconcile Step 2.3
-Call `CapacityBond.registerNode(nodeId, multiaddrs, regionHint, bindingSignature, ed25519Signature)`.
+Call `CapacityBond.registerNode(nodeId, multiaddrs, regionHint, termsHash, bindingSignature, ed25519Signature)`.

 This single transaction atomically:

-- Verifies the EIP-712 `bindingSignature` over `BindNodeId(nodeId, bindingNonce[ethAddress])`, establishing the `nodeId → ethAddress` mapping for slash evidence and payment attribution.
+- Requires `termsHash == currentTermsHash` and verifies the EIP-712 `bindingSignature` over `RegisterNode(nodeId, bindingNonce[ethAddress], termsHash)`, establishing the `nodeId → ethAddress` mapping for slash evidence and payment attribution.
 - Verifies the `ed25519Signature` over `keccak256(abi.encodePacked(nodeId, ethAddress, chainId, registrationNonce[nodeId]))`, proving the operator controls the iroh private key (prevents NodeId squatting). (`ethAddress` is `msg.sender` and `chainId` is `block.chainid` on-chain; this ADR uses operator-perspective names for consistency with the signing pseudo-code below.)
 - Records `NodeInfo` (including `firstBondedAt` if this is the node's first-ever registration — used for cold-start bootstrap eligibility in [ADR 008](008-reputation.md#cold-start-bootstrap)).
 - Sets `active = true` in the registry.
+- Emits `TermsAccepted(nodeId, termsHash, timestamp)`.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@adr/019-node-onboarding.md` around lines 83 - 113, Update Step 2.3 so the
documented `CapacityBond.registerNode` call matches the actual `RegisterNode`
flow used by `E2EProtocol.t.sol`: include `termsHash` in the signature and
describe the binding step as signing `RegisterNode { nodeId, nonce, termsHash }`
rather than `BindNodeId(...)`. Keep the atomic-actions list aligned with the
real on-chain behavior in `registerNode` by noting that it verifies both
`termsHash == currentTermsHash` and the EIP-712 binding signature, while
preserving the `ed25519Signature` verification and `NodeInfo`/`active` updates.
🧹 Nitpick comments (1)
contracts/test/DeployProtocolScript.t.sol (1)

51-60: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add a currentTermsHash assertion to the config round-trip test.

test_readConfig_appliesDefaultsForOptionalVars asserts every other DeployConfig field but not cfg.currentTermsHash, even though this PR adds the CURRENT_TERMS_HASH env var this test's setUp() now depends on. A wiring regression on this field would go unnoticed here.

✅ Proposed addition
         assertEq(cfg.regionStabilityWindow, DEFAULT_REGION_STABILITY_WINDOW, "regionStability");
+        assertEq(cfg.currentTermsHash, TEST_TERMS_HASH, "currentTermsHash");
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@contracts/test/DeployProtocolScript.t.sol` around lines 51 - 60, The config
round-trip test is missing coverage for the new CURRENT_TERMS_HASH wiring, so a
regression in DeployConfig.currentTermsHash could slip through. Update
test_readConfig_appliesDefaultsForOptionalVars in DeployProtocolScript.t.sol to
assert that cfg.currentTermsHash matches the expected TEST_TERMS_HASH alongside
the other DeployConfig fields, using the existing readConfig/deploy config
assertions as the place to add it.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@adr/019-node-onboarding.md`:
- Around line 83-113: Update Step 2.3 so the documented
`CapacityBond.registerNode` call matches the actual `RegisterNode` flow used by
`E2EProtocol.t.sol`: include `termsHash` in the signature and describe the
binding step as signing `RegisterNode { nodeId, nonce, termsHash }` rather than
`BindNodeId(...)`. Keep the atomic-actions list aligned with the real on-chain
behavior in `registerNode` by noting that it verifies both `termsHash ==
currentTermsHash` and the EIP-712 binding signature, while preserving the
`ed25519Signature` verification and `NodeInfo`/`active` updates.

---

Nitpick comments:
In `@contracts/test/DeployProtocolScript.t.sol`:
- Around line 51-60: The config round-trip test is missing coverage for the new
CURRENT_TERMS_HASH wiring, so a regression in DeployConfig.currentTermsHash
could slip through. Update test_readConfig_appliesDefaultsForOptionalVars in
DeployProtocolScript.t.sol to assert that cfg.currentTermsHash matches the
expected TEST_TERMS_HASH alongside the other DeployConfig fields, using the
existing readConfig/deploy config assertions as the place to add it.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1f67bd62-1d67-463b-875e-885eacc54efe

📥 Commits

Reviewing files that changed from the base of the PR and between 36aafe6 and fc8f410.

📒 Files selected for processing (22)
  • adr/003-payments.md
  • adr/019-node-onboarding.md
  • contracts/.gas-snapshot
  • contracts/dev-deploy.sh
  • contracts/script/BaseProtocolDeploy.s.sol
  • contracts/script/DeployProtocol.s.sol
  • contracts/src/CapacityBond.sol
  • contracts/test/CapacityBond.t.sol
  • contracts/test/CapacityBondRegionE2E.t.sol
  • contracts/test/CapacityBondSlashJudgeInvariant.t.sol
  • contracts/test/DeployProtocol.t.sol
  • contracts/test/DeployProtocolScript.t.sol
  • contracts/test/E2EProtocol.t.sol
  • contracts/test/GovernanceLifecycle.t.sol
  • contracts/test/SlashAppeal.t.sol
  • crates/cli/src/commands/register.rs
  • crates/e2e/src/bindings.rs
  • crates/e2e/src/chain.rs
  • crates/incentive/src/bind_sig.rs
  • crates/incentive/src/capacity_bond.rs
  • crates/incentive/src/lib.rs
  • crates/node/tests/anvil_settlement_e2e.rs

…t currentTermsHash wiring

CodeRabbit review on #1078:
- ADR 019 Step 2.3 still showed the pre-extension `registerNode(...)` call and a
  `BindNodeId` binding bullet; update to the shipped `RegisterNode` signature
  (termsHash arg + termsHash==currentTermsHash requirement + TermsAccepted emit).
- DeployProtocolScriptTest: assert `cfg.currentTermsHash == TEST_TERMS_HASH` in
  the config round-trip so a wiring regression on the new field is caught.

Regenerated .gas-snapshot for the added assertion.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@alpergundogdu

Copy link
Copy Markdown
Contributor Author

Thanks @coderabbitai — both addressed in dc65040:

  • ADR 019 Step 2.3 (Major): updated the registerNode(...) call to the termsHash signature and the atomic-actions list to sign RegisterNode(nodeId, nonce, termsHash), require termsHash == currentTermsHash, and emit TermsAccepted. This was a real inconsistency — I'd updated the "Constructing signatures" block but missed the call line + bullet above it.
  • DeployProtocolScriptTest (nitpick): added assertEq(cfg.currentTermsHash, TEST_TERMS_HASH) to the config round-trip so a wiring regression on the new field is caught. Regenerated .gas-snapshot for the added assertion.

🤖 Addressed by Claude Code

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

@alpergundogdu Thanks for the update — both fixes look good:

  • The ADR 019 Step 2.3 correction closes the gap between the "Constructing signatures" block and the actual registerNode(...) call/bullet, so the doc now consistently reflects RegisterNode(nodeId, nonce, termsHash), the termsHash == currentTermsHash check, and the TermsAccepted emission.
  • The added assertEq(cfg.currentTermsHash, TEST_TERMS_HASH) in DeployProtocolScriptTest is exactly the kind of regression guard needed for the new config field, and regenerating the gas snapshot for it makes sense.

Nice work tightening this up.

(=^・ω・^=)

@alpergundogdu
alpergundogdu merged commit 0d73fe3 into main Jul 7, 2026
22 checks passed
@alpergundogdu
alpergundogdu deleted the claude/elegant-goldstine-c7e4d8 branch July 7, 2026 16:00
alpergundogdu added a commit that referenced this pull request Jul 7, 2026
#1079)

* feat(cli): operator terms display + acceptance at registration (#1077)

Implements the operator-facing half of ADR 019 § Terms Acceptance (the on-chain
enforcement shipped in #1078).

- New `commands::terms`: embeds the canonical TERMS.md (`include_str!`), so the
  displayed text is the exact preimage of the recorded hash. `decide` is the
  pure acceptance policy; `ensure_accepted` is the IO wrapper.
- `decdn node register` / `decdn setup` read the network's `currentTermsHash`,
  then gate registration on acceptance:
  - Terminal: print the terms + version + hash, prompt `[y/N]` (default no).
  - Headless/automation: require `--accept-terms` (errors clearly without it) —
    keeps scripted provisioning working while keeping consent explicit.
  - Stale client: if the embedded terms hash != the network's currentTermsHash,
    refuse — never sign terms the operator wasn't shown (ADR 019 § 281).
- `--accept-terms` added to both commands (setup keeps it separate from `--yes`,
  which only skips the bond confirmation).
- Terms display + prompt go to stderr so `--json` stdout stays clean.

Tests: pure `decide` matrix, real `ensure_accepted` branches (headless/flag/
stale), and a lock on `keccak256(TERMS.md)` so a terms edit is a gated event
paired with a governance setCurrentTermsHash bump.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* fix(cli): require both stdin+stderr to be terminals before prompting for terms

Gemini review on #1079: if stderr is redirected but stdin is a TTY, the terms
+ prompt print to the invisible stderr and the process blocks on stdin — a
silent hang. Gate the interactive path on both streams being terminals;
otherwise fall back to requiring --accept-terms.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* fix(cli): gate terms on dry-run + before bond, off the runtime thread

Review round on #1079 (Copilot + CodeRabbit):

- register --dry-run now also enforces terms acceptance: a dry run still emits a
  real, submit-able signature committing to termsHash, so it must not be produced
  over unseen/stale terms. (Copilot)
- setup accepts terms BEFORE bond::execute (gated on !already_registered) so a
  refusal / stale-client aborts before the bond is spent, not after. Extracted
  `accept_terms_if_registering` helper (keeps setup::run under the cognitive-
  complexity limit). (CodeRabbit)
- New `terms::ensure_accepted_async` runs the blocking prompt via spawn_blocking
  so it never parks a tokio worker; call sites use it. (CodeRabbit)
- (stderr-redirect interactive check already landed in the prior commit.)

Co-Authored-By: Claude Opus 4.8 <[email protected]>

---------

Co-authored-by: Claude Opus 4.8 <[email protected]>
yigitdot added a commit that referenced this pull request Jul 8, 2026
Resolve conflict in contracts/test/CapacityBondRegionE2E.t.sol: main (#1078)
inserted REG_TERMS_HASH inside the AUTO-GENERATED ed25519-vector marker block.
That block is now generator-authoritative (freshness CI job regenerates it and
fails on any diff), and termsHash is not part of the ed25519 ownership digest,
so REG_TERMS_HASH is moved just below the END AUTO-GENERATED frame. The block's
regen comment keeps the PR's '--write' wording that the generator emits.

Co-Authored-By: Claude Opus 4.8 <[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.

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

2 participants