Skip to content

fix(cli,incentive): reject zero address for all parsed contract addresses + fix bindNodeId runbook (#1213, #1195) - #1218

Merged
thiras merged 2 commits into
mainfrom
fix/cli-zero-address-guards-1213-1195
Jul 16, 2026
Merged

thiras merged 2 commits into
mainfrom
fix/cli-zero-address-guards-1213-1195

Conversation

@thiras

@thiras thiras commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Two small CLI/docs hardening fixes, batched. Both are correctness gaps noticed while the surrounding code was fresh.

Closes #1213. Closes #1195.

#1213 — reject the zero address for every parsed contract address

The #1153 guard (parse_nonzero_address) was applied only to the four addresses resolved by resolve / resolve_appeal / resolve_publish, leaving other CLI contract-address parse sites on the permissive parse_address (which accepts 0x0000…0000). The same logical address was guarded via resolve() but not via fetch.

  • Routed the remaining CLI contract sites through parse_nonzero_address: fetch (payment_channel_address, slash_judge_address, capacity_bond_address), channel (payment_channel_address), setup (usdc_address).
  • Extended the same guard to the swap contract addresses parsed in incentive::swap_venue::from_config (router/quoter/pool/usdc) via a local parse_nonzero helper (incentive can't depend on cli), preserving the existing error-message wording so the malformed-address tests keep matching.
  • Account/EOA addresses (--provider-address, operator) deliberately stay on parse_address — the "never a real deployment" rationale is contract-specific.

New hard error on 0x0 (present-but-zero only; unset optionals still resolve to None).

#1195 — fix the bindNodeId runbook ABI

adr/appendix-operator-key-rotation.md documented CapacityBond.bindNodeId(newNodeId, signature), but the contract takes three args — bindNodeId(bytes32 nodeId, bytes bindingSignature, bytes ed25519Signature) — so a call built from the doc reverts. Updated the "API used" line and procedure steps 4–5 (step 4 now builds both the EIP-712 binding signature and the ed25519 ownership proof).

Tests

11 new zero-address rejection tests — the fetch/channel resolvers and every swap address across both venues. Each asserts both the address label and the distinctive "must not be the zero address" message.

Verification

  • cargo build && cargo clippy --all-targets — clean
  • cargo nextest run -p decdn-incentive -p decdn-cli — 541 passed
  • cargo fmt --check — clean
  • Full pre-commit run --all-files gate passed (incl. ADR reference-hygiene for the doc change)

No Solidity, gossip, or protocol/wire changes.

Reviewed

Ran the multi-agent PR review (code / tests / comments / silent-failure). All approved; the three low-severity doc-accuracy suggestions are folded into the fix commit.

Follow-up (out of scope)

The decdn-node daemon parses the same contracts unguarded (crates/node/src/runtime/mod.rs), so a 0x0 misconfig there still surfaces as the opaque late revert this PR eliminates on the CLI. Tracked in #1219.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • CLI validation now rejects zero addresses across fetch, channel, setup, resolver, and incentive swap configuration flows.
    • Invalid contract addresses are reported immediately with clearer validation errors.
    • Account, operator, provider, and other EOA address handling remains unchanged.
  • Documentation

    • Updated the changelog and operator key-rotation runbook to reflect current validation and signature requirements.

…sses (#1213)

The #1153 guard (`parse_nonzero_address`) was applied only to the four
addresses resolved by `resolve` / `resolve_appeal` / `resolve_publish`,
leaving several other CLI contract-address parse sites on the plain
`parse_address`, which accepts `0x0000…0000` — the same logical address
was guarded via `resolve()` but not via `fetch`.

Route the remaining CLI contract sites through `parse_nonzero_address`:
`fetch` (`payment_channel_address`, `slash_judge_address`,
`capacity_bond_address`), `channel` (`payment_channel_address`), and
`setup` (`usdc_address`). Extend the same guard to the swap contract
addresses parsed in `incentive::swap_venue::from_config`
(router/quoter/pool/usdc) via a local `parse_nonzero` helper — `incentive`
cannot depend on `cli`, so the guard is duplicated with the existing
error-message wording preserved.

Account/EOA addresses (`--provider-address`, `operator`) deliberately stay
on `parse_address` — the "never a real deployment" rationale is
contract-specific. New hard error on `0x0` (present-but-zero only; unset
optionals still resolve to `None`).

Adds zero-address rejection tests for the fetch/channel resolvers and every
swap address across both venues; broadens the `parse_nonzero_address` doc
comment and adds a CHANGELOG entry.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 16, 2026 00:16
@coderabbitai

coderabbitai Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: 094afaf0-93ba-41a7-9fe5-dd52093ac219

📥 Commits

Reviewing files that changed from the base of the PR and between 2e30cd1 and e0f7eee.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • adr/appendix-operator-key-rotation.md
  • crates/cli/src/commands/chain_ctx.rs
  • crates/cli/src/commands/channel.rs
  • crates/cli/src/commands/fetch.rs
  • crates/cli/src/commands/setup.rs
  • crates/incentive/src/swap_venue.rs

Walkthrough

The change extends zero-address validation to CLI contract address parsing and incentive swap-venue configuration, adds rejection tests, updates the breaking-change notes, and revises the iroh node-key rotation runbook for two bindNodeId signatures.

Changes

Zero Address Validation

Layer / File(s) Summary
CLI contract address guards
crates/cli/src/commands/{chain_ctx,channel,fetch,setup}.rs, CHANGELOG.md
Contract addresses in channel, fetch, and setup flows now use non-zero parsing, with tests covering payment channel, slash judge, capacity bond, and payment token addresses.
Swap venue address guards
crates/incentive/src/swap_venue.rs
Uniswap V3 and Balancer V3 address fields use a shared non-zero parser, with tests covering each supported swap address.

Operator Key Rotation Documentation

Layer / File(s) Summary
bindNodeId signature procedure
adr/appendix-operator-key-rotation.md
The runbook now documents both the EIP-712 bindingSignature and iroh ed25519Signature required for node-key rotation.

Estimated code review effort: 2 (Simple) | ~15 minutes


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

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

@github-actions

github-actions Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

Contracts coverage

Line coverage: 88.92% (2488/2798 lines)
▲ +0.00pp vs base (88.92% → 88.92%)
Run: 29461267937

@github-actions

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 expands the zero-address guard to cover all parsed contract addresses across the CLI and swap venues, preventing opaque on-chain reverts. It also updates the operator key rotation documentation to include the required ed25519Signature for bindNodeId. I have no further 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 hardens contract-address handling in the CLI (and swap-venue config in decdn-incentive) by rejecting the zero address at parse time, and corrects the operator key-rotation runbook’s documented bindNodeId ABI.

Changes:

  • Route remaining CLI contract-address parse sites through parse_nonzero_address, with new tests covering each address on the fetch, channel, and setup paths.
  • Add an incentive-local non-zero address parser for swap venue contracts (Uniswap V3 + Balancer V3), with comprehensive zero-address rejection tests.
  • Update the operator key-rotation runbook to reflect CapacityBond.bindNodeId’s 3-argument ABI and document the need for both signatures.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/incentive/src/swap_venue.rs Adds local parse_nonzero guard and tests to reject zero swap contract addresses.
crates/cli/src/commands/setup.rs Uses parse_nonzero_address when re-parsing USDC address for ERC20 binding.
crates/cli/src/commands/fetch.rs Zero-guards fetch-path contract addresses and adds targeted tests.
crates/cli/src/commands/channel.rs Zero-guards payment-channel address and adds a regression test.
crates/cli/src/commands/chain_ctx.rs Updates documentation to reflect expanded non-zero guard coverage and rationale.
CHANGELOG.md Documents the expanded zero-address guard coverage across CLI + swap venues.
adr/appendix-operator-key-rotation.md Updates bindNodeId ABI in runbook steps and “API used” line.

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

Comment thread adr/appendix-operator-key-rotation.md Resolved
…oof arg (#1195)

The operator key-rotation runbook documented
`CapacityBond.bindNodeId(newNodeId, signature)`, but the contract takes
three args — `bindNodeId(bytes32 nodeId, bytes bindingSignature, bytes
ed25519Signature)` (CapacityBond.sol) — so a call built from the doc as
written reverts.

Update the "API used" line and procedure steps 4–5 in
`appendix-operator-key-rotation.md`: step 4 now builds both the EIP-712
binding signature and the ed25519 ownership proof over the new NodeId, and
step 5 submits all three args. Edited in place per the repo ADR convention.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@thiras
thiras force-pushed the fix/cli-zero-address-guards-1213-1195 branch from d862bc4 to e0f7eee Compare July 16, 2026 00:22
@github-actions

Copy link
Copy Markdown

Coverage report

Total: 80.53% (was 80.45%, ▲ +0.08%) — 47742/59284 lines

File Coverage Lines Δ
crates/cli/src/commands/chain_ctx.rs 91.67% 572/624 ● 0.00%
crates/cli/src/commands/channel.rs 51.69% 351/679 ▲ +0.65%
crates/cli/src/commands/fetch.rs 44.22% 283/640 ▲ +2.34%
crates/cli/src/commands/setup.rs 43.92% 426/970 ● 0.00%
crates/incentive/src/swap_venue.rs 96.13% 348/362 ▲ +8.63%
History
Commit Total Δ vs base
e0f7eee (HEAD) 80.53% ▲ +0.08%

@thiras
thiras merged commit 1f9f77f into main Jul 16, 2026
23 checks passed
@thiras
thiras deleted the fix/cli-zero-address-guards-1213-1195 branch July 16, 2026 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants