Repository navigation
fix(node,common,cli,incentive): guard daemon contract addresses against the zero address (#1219) - #1256
Conversation
…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]>
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (6)
WalkthroughThe 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. ChangesAddress validation
Estimated code review effort: 3 (Moderate) | ~20 minutes Note 🎁 Summarized by CodeRabbit FreeYour 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 |
Gas snapshotNo gas changes vs base. |
Contracts coverageLine coverage: 88.92% (2488/2798 lines) |
There was a problem hiding this comment.
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.
|
/gemini review |
There was a problem hiding this comment.
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.
Coverage reportTotal: 81.20% (was 81.13%, ▲ +0.07%) — 48612/59866 lines
History
|
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]>
What
Closes #1219. The zero-address guard #1213 added to the
decdnCLI never reached thedecdn-nodedaemon. Its runtime bring-up re-parsed the resolved contract addresses with a plain.parse(), so a0x0misconfig oncapacity_bond/payment_channel/origin_assignment/publisher_registrypassed 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
decdn_common::address::{parse_address, parse_nonzero_address}, consolidating the two divergent duplicate copies (cli::commands::chain_ctxandincentive::swap_venue) into one.common, notconfig-typesas the issue suggested.config-typesdeliberately carries noalloydependency (it keepsalloyoff the publisher-CLI path, per CLAUDE.md), and the guard needsalloy::primitives::Address.commonis 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 intoincentiveonly because "incentive cannot depend on cli" — but it can depend oncommon, which is what makes the consolidation possible.crates/node/src/runtime/mod.rs) through the shared guard.resolve_blockchainalready zero-checkedslash_judge_addressandcontent_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 bydecdn config check), the runtime guards are uniform defense-in-depth, and the invariant is unit-testable (added in the second commit, see below).Reviewer notes
capacity_bond,slash_judge), so all six daemon contract addresses are covered.--provider-address,operator) keep the permissiveparse_address, per cli: zero-address guard not applied to contract addresses parsed outside the resolve* family (fetch/channel/setup) #1213's rationale.runneeds 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— cleancargo fmt -- --check— cleancargo nextest runon 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