Skip to content

fix(node,common,cli,incentive): guard daemon contract addresses against the zero address (#1219) - #1256

Merged
thiras merged 2 commits into
mainfrom
fix/1219-daemon-zero-address-guard
Jul 17, 2026
Merged

thiras merged 2 commits into
mainfrom
fix/1219-daemon-zero-address-guard

Conversation

@yigitdot

@yigitdot yigitdot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

What

Closes #1219. The zero-address guard #1213 added to the decdn CLI never reached the decdn-node daemon. Its runtime bring-up re-parsed the resolved contract addresses with a plain .parse(), so a 0x0 misconfig on capacity_bond / payment_channel / origin_assignment / publisher_registry passed config resolution (which only checksum-validates those) and surfaced as an opaque late on-chain revert — exactly the failure #1153/#1213 set out to eliminate. The workspace was left half-guarded: CLI guarded, daemon not.

Changes

  • New shared guard decdn_common::address::{parse_address, parse_nonzero_address}, consolidating the two divergent duplicate copies (cli::commands::chain_ctx and incentive::swap_venue) into one.
    • Homed in common, not config-types as the issue suggested. config-types deliberately carries no alloy dependency (it keeps alloy off the publisher-CLI path, per CLAUDE.md), and the guard needs alloy::primitives::Address. common is the one alloy-carrying crate all three consumers already depend on (node → common, cli → common, incentive → common). cli: zero-address guard not applied to contract addresses parsed outside the resolve* family (fetch/channel/setup) #1213 duplicated the guard into incentive only because "incentive cannot depend on cli" — but it can depend on common, which is what makes the consolidation possible.
  • Routed all six daemon contract-address parse sites (crates/node/src/runtime/mod.rs) through the shared guard.
  • Reject zero at config resolution too. resolve_blockchain already zero-checked slash_judge_address and content_blacklist_address; this extends the same guard to the other four (capacity_bond, payment_channel, origin_assignment, publisher_registry). So a zero address now fails at config load (caught by decdn config check), the runtime guards are uniform defense-in-depth, and the invariant is unit-testable (added in the second commit, see below).
  • CLI and incentive now call the shared guard via re-export / import; behaviour and error wording are unchanged, so their existing zero/malformed-address tests still pass.

Reviewer notes

  • The issue enumerated four sites; I found two more of the same class (capacity_bond, slash_judge), so all six daemon contract addresses are covered.
  • Only contract addresses are guarded; EOA/account addresses (--provider-address, operator) keep the permissive parse_address, per cli: zero-address guard not applied to contract addresses parsed outside the resolve* family (fetch/channel/setup) #1213's rationale.
  • Second commit is a review-driven addition: a comprehensive review flagged that the four newly-guarded fields were enforced only by the runtime guard, which isn't unit-testable (run needs a live iroh endpoint + anvil). Adding the resolution-layer guard makes the invariant testable and consistent with the existing two fields.

Verification

  • cargo clippy --workspace --all-targets -- -D warnings — clean
  • cargo fmt -- --check — clean
  • cargo nextest run on all four affected crates — 1759 passed, 0 failed, including 4 new guard unit tests, 4 new resolution-layer zero-address tests, and the migrated CLI/incentive zero/malformed tests

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation for blockchain and service configuration addresses.
    • Configuration now clearly rejects invalid or zero addresses instead of allowing misconfigured services to start.
    • Standardized address parsing across CLI, node, and swap venue components.
    • Error messages now identify the affected configuration field and provide more actionable feedback.

…st the zero address (#1219)

The zero-address guard #1213 added to the CLI never reached the decdn-node
daemon: its runtime bring-up re-parsed the resolved contract addresses with a
plain `.parse()`, so a 0x0 capacity_bond / payment_channel / origin_assignment
/ publisher_registry misconfig passed config resolution (which only
checksum-validates those) and surfaced as an opaque on-chain revert — exactly
the failure #1153/#1213 set out to eliminate.

- Add one shared guard decdn_common::address::{parse_address,
  parse_nonzero_address}, consolidating the two divergent copies
  (cli::chain_ctx and incentive::swap_venue). Homed in common, not config-types
  as the issue suggested: config-types deliberately carries no alloy dep, and
  common is the one alloy-carrying crate all three consumers (node, cli,
  incentive) already depend on.
- Route all six daemon contract-address parse sites through it. Four
  (capacity_bond, payment_channel, origin_assignment, publisher_registry) were
  genuinely unguarded; slash_judge and content_blacklist are already zero-checked
  at resolve_blockchain, so those two are uniform defense-in-depth.
- CLI and incentive now call the shared guard; behaviour and error wording are
  unchanged, so their existing zero/malformed-address tests still pass.

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

coderabbitai Bot commented Jul 17, 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: dffe6d7c-9e41-466a-b8d2-68d6b83ee096

📥 Commits

Reviewing files that changed from the base of the PR and between bffef4f and 1a0250d.

📒 Files selected for processing (6)
  • crates/cli/src/commands/chain_ctx.rs
  • crates/common/src/address.rs
  • crates/common/src/config/mod.rs
  • crates/common/src/lib.rs
  • crates/incentive/src/swap_venue.rs
  • crates/node/src/runtime/mod.rs

Walkthrough

The change introduces shared labeled Ethereum address parsers, rejects zero contract addresses during configuration resolution, and applies centralized nonzero parsing across CLI, swap venue, and node runtime address construction.

Changes

Address validation

Layer / File(s) Summary
Shared address parsing contract
crates/common/src/address.rs, crates/common/src/lib.rs, crates/cli/src/commands/chain_ctx.rs
Adds shared parsing and zero-address helpers with unit tests, exports the module, and re-exports the helpers for CLI callers.
Blockchain configuration validation
crates/common/src/config/mod.rs
Rejects zero payment channel, capacity bond, origin assignment, and publisher registry addresses, with corresponding resolution tests.
Swap venue address parsing
crates/incentive/src/swap_venue.rs
Replaces the local parser with shared nonzero parsing for Uniswap v3 and Balancer v3 addresses.
Node runtime address parsing
crates/node/src/runtime/mod.rs
Uses shared nonzero parsing for configured addresses used by runtime services and chain initialization.

Estimated code review effort: 3 (Moderate) | ~20 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

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@github-actions

github-actions Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

Contracts coverage

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

@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 consolidates Ethereum address parsing and zero-address validation logic into a single shared module, decdn-common::address, eliminating duplicate implementations across the CLI, daemon, and incentive crates. It also introduces comprehensive unit tests for these shared parsing helpers. I have no feedback to provide as there are no review comments to assess.

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.

@yigitdot
yigitdot requested a review from Copilot July 17, 2026 00:46

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@yigitdot

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 consolidates Ethereum address parsing logic across the deCDN codebase by introducing a shared address module in the decdn-common crate. The local implementations of parse_address and parse_nonzero_address in the CLI, node runtime, and incentive crates have been removed and replaced with the centralized helper functions. This ensures consistent zero-address validation and error formatting across all binaries, backed by a new suite of unit tests. No review comments were provided, so there is no additional feedback to address.

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.

@github-actions

github-actions Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 81.20% (was 81.13%, ▲ +0.07%) — 48612/59866 lines

File Coverage Lines Δ
crates/cli/src/commands/chain_ctx.rs 91.50% 560/612 ▼ 0.16%
crates/common/src/address.rs 100.00% 32/32 new
crates/common/src/config/mod.rs 97.01% 6677/6883 ▼ 0.01%
crates/incentive/src/swap_venue.rs 96.03% 339/353 ▼ 0.10%
crates/node/src/runtime/mod.rs 50.05% 1083/2164 ▲ +0.55%
History
Commit Total Δ vs base
4ae0b39 81.17% ▲ +0.04%
1a0250d (HEAD) 81.20% ▲ +0.07%

 review)

PR #1256 review flagged that four daemon contract addresses (capacity_bond,
payment_channel, origin_assignment, publisher_registry) had their zero-rejection
enforced only by the runtime bring-up guard, which is not unit-testable
(resolve/run needs a live iroh endpoint + anvil) — so a future refactor
reverting the guard would reintroduce the #1219 footgun with no failing test.

Add the same resolution-layer zero-guard the slash_judge/content_blacklist
fields already carry, so all six daemon contract addresses are rejected at
config load (caught early by decdn config check) and the runtime guards become
uniform defense-in-depth. Mirror the existing zero-address resolution tests for
the four fields.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@yigitdot
yigitdot requested review from alpergundogdu and thiras and removed request for alpergundogdu and thiras July 17, 2026 01:53
@thiras
thiras merged commit a338b00 into main Jul 17, 2026
23 checks passed
@thiras
thiras deleted the fix/1219-daemon-zero-address-guard branch July 17, 2026 17:40
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.

Node: apply the zero-address contract guard to the daemon's runtime parse sites (follow-up to #1213)

3 participants