Skip to content

fix(node,cli): observable origin-replay range guard + zero-address guards on all resolved addresses (#1152, #1153) - #1209

Merged
thiras merged 3 commits into
mainfrom
fix/observable-replay-range-and-cli-zero-address-guards
Jul 15, 2026
Merged

thiras merged 3 commits into
mainfrom
fix/observable-replay-range-and-cli-zero-address-guards

Conversation

@yigitdot

@yigitdot yigitdot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Fixes two pre-existing latent bugs spun out of the #1151 review. Both touch adjacent resolver/bootstrap code, are small and independent, and ship together as one PR.

Closes #1152.
Closes #1153.

#1152 — origin-directory genesis replay silently proceeds on a from > latest range anomaly

bootstrap_cache (crates/node/src/dht/chain_origin_directory.rs) replays ContentClaimed over backfill_windows(replay_from, latest, …). Since the replay floor now resumes from a persisted checkpoint (#1108), a stale/lagging RPC head can put replay_from > latest; backfill_windows yields no windows for an inverted range, so the replay was silently skipped with no log or metric.

The fix makes the anomaly observable without changing the graceful posture — it does not propagate the error, because the bootstrap call site (runtime/mod.rs) is one-shot with no retry and a propagated Err would turn a transient RPC anomaly into a fatal node-startup crash. Instead it warns and bumps a new counter, mirroring the buyer-reconcile consumer of the same check_backfill_range helper (buyer_channel.rs):

#1153 — zero-address guard only on the appeal address

Only slash_appeal_address was guarded against Address::ZERO. The identical rationale (a zero address parses fine but is never a real deployment and only surfaces as an opaque on-chain revert) applies verbatim to the other three resolved contract addresses. All four now route through a shared parse_nonzero_address helper in crates/cli/src/commands/chain_ctx.rs:

  • capacity_bond_address (resolve)
  • slash_appeal_address (resolve_appeal)
  • publisher_registry_address, origin_assignment_address (resolve_publish, present-but-zero only; unset optionals still resolve to None)

A misconfigured 0x0000…0000 now fails fast at resolve time with a clear "must not be the zero address" error. This is a new hard error on 0x0 for the three previously-unguarded addresses (noted in the CHANGELOG).

Tests

  • CLI: new zero-address rejection tests for capacity_bond_address, publisher_registry_address, origin_assignment_address (mirroring the existing appeal test).
  • Node: origin_directory_bootstrap_range_anomaly counter unit test (starts at 0, increments) — the range-validation logic itself is already covered by check_backfill_range_boundary; the RPC path isn't behind a mock seam, so a new seam was out of scope.

Verification

cargo build && cargo clippy --workspace --all-targets -- -D warnings   # clean
cargo nextest run -p decdn-cli -p decdn-node --no-fail-fast            # 1017 passed
cargo fmt -- --check                                                    # clean

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • CLI address resolution now rejects zero contract/account addresses earlier, failing fast with clearer configuration errors.
    • Bootstrap content-claim replay no longer errors on an invalid/inverted replay range; it warns, skips the affected replay, and keeps operating in routing-only mode.
  • Monitoring
    • Added an anomaly metric for skipped inverted-range bootstrap replays, alongside the warning.
  • Documentation
    • Changelog updated to reflect the new address validation and bootstrap replay behavior.

…ards on all resolved addresses (#1152, #1153)

#1152: bootstrap_cache replays ContentClaimed over [replay_from, latest].
Since the replay floor resumes from a persisted checkpoint (#1108), a stale
RPC head can put replay_from > latest, and backfill_windows silently yields
no windows — skipping the replay with no signal. Guard the range with
check_backfill_range: warn + bump a new
decdn_origin_directory_bootstrap_range_anomaly_total counter, keeping the
routing-only posture (bootstrap is one-shot; propagating would crash startup).
Mirrors the buyer-reconcile consumer of the same range check.

#1153: route all four resolved contract addresses (capacity_bond,
slash_appeal, publisher_registry, origin_assignment) through a shared
parse_nonzero_address guard so a misconfigured 0x0 fails fast at resolve time
instead of as an opaque on-chain revert. Previously only slash_appeal was
guarded.

Adds unit tests for the three newly-guarded addresses and the new metrics
counter, plus CHANGELOG entries.

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

coderabbitai Bot commented Jul 15, 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: b834795f-9d61-4041-8c19-3d72fd5350d0

📥 Commits

Reviewing files that changed from the base of the PR and between 7e24f03 and b8216da.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • crates/node/src/dht/chain_origin_directory.rs
  • crates/node/src/metrics.rs
🚧 Files skipped from review as they are similar to previous changes (3)
  • crates/node/src/metrics.rs
  • CHANGELOG.md
  • crates/node/src/dht/chain_origin_directory.rs

Walkthrough

The PR adds non-zero Ethereum address validation across CLI coordinate resolvers and changes origin-directory bootstrap replay to detect inverted ranges, emit warnings, increment a metric, and skip replay for the affected boot.

Changes

CLI address validation

Layer / File(s) Summary
Non-zero address resolution
crates/cli/src/commands/chain_ctx.rs, CHANGELOG.md
A shared labeled parser rejects zero addresses for resolved contract fields, including optional publish addresses, with tests covering the new errors.

Origin bootstrap anomaly handling

Layer / File(s) Summary
Bootstrap anomaly metric
crates/node/src/metrics.rs
Adds and tests the decdn_origin_directory_bootstrap_range_anomaly_total counter and its increment method.
Bootstrap replay range guard
crates/node/src/dht/chain_origin_directory.rs, CHANGELOG.md
Bootstrap validates replay ranges, warns and records an anomaly for inverted ranges, then skips content-claim replay for that boot.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ChainOriginDirectory
  participant check_backfill_range
  participant Metrics
  ChainOriginDirectory->>check_backfill_range: Validate replay range
  check_backfill_range-->>ChainOriginDirectory: Return range status
  ChainOriginDirectory->>Metrics: Increment anomaly counter on inverted range
  ChainOriginDirectory-->>ChainOriginDirectory: Skip ContentClaimed replay for this boot
Loading

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 15, 2026 •

Copy link
Copy Markdown

Contracts coverage

Line coverage: 88.92% (2488/2798 lines)
▼ -0.05pp vs base (88.97% → 88.92%)
Run: 29458334077

@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 introduces two main improvements. First, it updates the CLI to reject the zero address for all resolved contract addresses (including capacity bond, publisher registry, and origin assignment addresses) using a shared parse_nonzero_address guard to fail fast with a clear error. Second, it ensures that the origin-directory genesis replay does not silently skip on an inverted block range (e.g., due to a lagging RPC head); it now logs a warning and increments a new decdn_origin_directory_bootstrap_range_anomaly_total metric. Corresponding unit tests have been added for both features. 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.

@github-actions

github-actions Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 80.45% (was 80.44%, ▲ +0.01%) — 47603/59169 lines

File Coverage Lines Δ
crates/cli/src/commands/chain_ctx.rs 91.67% 572/624 ▲ +0.42%
crates/node/src/dht/chain_origin_directory.rs 63.96% 637/996 ▼ 0.26%
crates/node/src/metrics.rs 86.15% 1138/1321 ▲ +0.19%
History
Commit Total Δ vs base
cc94ef4 80.43% ▲ +0.01%
7e24f03 80.71% ▲ +0.01%
b8216da (HEAD) 80.45% ▲ +0.01%

…esses (#1153)

PR review flagged the doc/CHANGELOG wording ('every'/'sole'/'all four')
as overclaiming: other CLI contract addresses (fetch.rs, channel.rs,
setup.rs) still parse via plain parse_address and accept 0x0. Narrow the
parse_nonzero_address doc, the resolve_appeal comment, and the CHANGELOG
to state precisely that the guard covers the four addresses resolved by
resolve / resolve_appeal / resolve_publish, and note the remaining gap is
tracked separately. No behavior change.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…oritative getOrigins (#1152)

When the origin-directory genesis replay is skipped on an inverted range,
`namespaces_of` stays empty, so the `getOrigins` loop is a no-op and
per-namespace membership is absent that boot — claimed hashes fall back to
the default-open set (namespace 0) until the live tail re-surfaces claims.
The prior "membership stays authoritative via getOrigins" wording overclaimed
coverage. Reword the guard comment, warn! string, both metric doc comments,
and the CHANGELOG entry to match.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@thiras
thiras merged commit f49b2ba into main Jul 15, 2026
23 checks passed
@thiras
thiras deleted the fix/observable-replay-range-and-cli-zero-address-guards branch July 15, 2026 23:32
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