Repository navigation
refactor(client-pull): promote discovery/probe/endpoint/provider to public modules - #1022
Conversation
…ublic modules The client fetch path was split: decdn-client-pull held the reusable cdn/client/v1 paid-fetch + buyer-channel kernels, but discovery, probe, the client iroh-endpoint builder, and the wallet provider builder lived in the decdn-cli *bin* crate, which nothing can depend on. That left one shared "discover -> probe -> open/reuse channel -> paid-fetch" path with its discovery half unreachable as a library. Move them into public decdn-client-pull modules (pure relocation, no behavior change): cli/commands/discovery.rs -> client-pull/src/discovery.rs cli/commands/probe_client.rs -> client-pull/src/probe.rs cli/commands/client_endpoint.rs -> client-pull/src/endpoint.rs cli/commands/chain_ctx::build_provider -> client-pull/src/provider.rs Repoint cli (fetch, bundle_pull, channel, probe, bond, register, setup) and the node probe_0rtt test at the new locations. The node's decdn-cli dev-dep existed only for that test's probe_once import and is now removed. endpoint pulls in decdn-common (iroh-blobs-free per #578, so the CLI's iroh-blobs-free invariant still holds). Closes #1021. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (17)
💤 Files with no reviewable changes (2)
Walkthrough
ChangesPromote shared client modules into decdn-client-pull
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
This PR promotes the client-side “discover → probe → endpoint → provider” toolkit out of the decdn-cli bin crate into public modules in decdn-client-pull, enabling reuse of the full cdn/client/v1 client fetch path by non-CLI consumers while keeping behavior unchanged.
Changes:
- Added new public
decdn-client-pullmodules:discovery,probe,endpoint, andprovider. - Repointed CLI commands and the node 0-RTT probe integration test to use
decdn-client-pullinstead ofdecdn-cli::commands. - Removed the
decdn-clidev-dependency fromdecdn-nodetests and updated Cargo metadata accordingly.
Reviewed changes
Copilot reviewed 15 out of 18 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/node/tests/probe_0rtt.rs | Switch probe helper import to decdn_client_pull::probe. |
| crates/node/Cargo.toml | Drop decdn-cli dev-dependency previously used only by the integration test. |
| crates/client-pull/src/provider.rs | New public provider builder (build_provider) extracted from CLI plumbing. |
| crates/client-pull/src/probe.rs | Update rustdoc links to point at the new public probe module path. |
| crates/client-pull/src/lib.rs | Export new public modules (discovery, endpoint, probe, provider). |
| crates/client-pull/src/endpoint.rs | New public endpoint + relay/discovery resolution module (with tests). |
| crates/client-pull/src/discovery.rs | New public registry-backed discovery + selection/ranking module (with tests). |
| crates/client-pull/Cargo.toml | Add decdn-common dependency and tempfile dev-dependency to support endpoint module + tests. |
| crates/cli/src/commands/setup.rs | Repoint provider construction to decdn_client_pull::provider::build_provider. |
| crates/cli/src/commands/register.rs | Repoint provider construction to decdn_client_pull::provider::build_provider. |
| crates/cli/src/commands/probe.rs | Repoint probe + endpoint imports to decdn_client_pull::{probe, endpoint}. |
| crates/cli/src/commands/mod.rs | Stop exporting CLI-private discovery/endpoint/probe_client modules. |
| crates/cli/src/commands/fetch.rs | Repoint discovery/probe/endpoint/provider wiring to decdn-client-pull. |
| crates/cli/src/commands/channel.rs | Repoint endpoint/provider usage to decdn-client-pull. |
| crates/cli/src/commands/chain_ctx.rs | Remove in-CLI provider builder and document the new library entrypoint. |
| crates/cli/src/commands/bundle_pull.rs | Repoint discovery/endpoint/provider usage to decdn-client-pull. |
| crates/cli/src/commands/bond.rs | Repoint provider construction to decdn_client_pull::provider::build_provider. |
| Cargo.lock | Reflect dependency graph updates (add decdn-common/tempfile under decdn-client-pull, remove decdn-cli under node). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage reportTotal: 83.20% (was 83.20%, ● 0.00%) — 41946/50417 lines
History
|
There was a problem hiding this comment.
Code Review
This pull request refactors and extracts several client-side paid-pull components (such as discovery, endpoint, probe, and provider) from the decdn-cli crate into the decdn-client-pull crate to make them reusable. This includes moving the build_provider helper and updating all command invocations and integration tests to use the new paths. Feedback on the changes suggests improving debuggability in crates/client-pull/src/provider.rs by using redact_userinfo to redact only credentials from invalid RPC URLs rather than hiding the entire URL.
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.
| /// # Errors | ||
| /// | ||
| /// Fails if `rpc_url` is not a valid URL. The value is never echoed into the | ||
| /// error: an `rpc_url` secret commonly lives in the path/query, which userinfo | ||
| /// redaction wouldn't scrub, so the value is hidden entirely (matching | ||
| /// `config validate`'s `<redacted> (N chars)`). | ||
| pub fn build_provider( | ||
| rpc_url: &str, | ||
| signer: &PrivateKeySigner, | ||
| ) -> anyhow::Result<impl Provider + Clone> { | ||
| Ok(ProviderBuilder::new() | ||
| .wallet(EthereumWallet::from(signer.clone())) | ||
| .connect_http(rpc_url.parse().with_context(|| { | ||
| format!( | ||
| "rpc_url is not a valid URL (<redacted>, {} chars)", | ||
| rpc_url.len() | ||
| ) | ||
| })?)) | ||
| } |
There was a problem hiding this comment.
The current error message for an invalid rpc_url redacts the entire URL, which can make debugging difficult. While this is done for security reasons to avoid leaking secrets in the path or query string, it violates the repository's general rule to avoid omitting the URL entirely to preserve debugging context.
A better approach, consistent with how relay_url errors are handled in endpoint.rs, is to use the redact_userinfo function. This improves debuggability by showing the host and path, which are often crucial for diagnosing connection issues, while still redacting credentials in the userinfo part of the URL.
Please also update the function's documentation to reflect this change and warn that secrets in the path or query string may still be visible. You'll need to add use decdn_common::redact::redact_userinfo; to the file.
| /// # Errors | |
| /// | |
| /// Fails if `rpc_url` is not a valid URL. The value is never echoed into the | |
| /// error: an `rpc_url` secret commonly lives in the path/query, which userinfo | |
| /// redaction wouldn't scrub, so the value is hidden entirely (matching | |
| /// `config validate`'s `<redacted> (N chars)`). | |
| pub fn build_provider( | |
| rpc_url: &str, | |
| signer: &PrivateKeySigner, | |
| ) -> anyhow::Result<impl Provider + Clone> { | |
| Ok(ProviderBuilder::new() | |
| .wallet(EthereumWallet::from(signer.clone())) | |
| .connect_http(rpc_url.parse().with_context(|| { | |
| format!( | |
| "rpc_url is not a valid URL (<redacted>, {} chars)", | |
| rpc_url.len() | |
| ) | |
| })?)) | |
| } | |
| /// # Errors | |
| /// | |
| /// Fails if rpc_url is not a valid URL. The error will include a redacted | |
| /// version of the URL to aid in debugging. Note that only the userinfo part | |
| /// (e.g., user:pass@) is redacted; secrets in the path or query string may | |
| /// still be visible in logs. | |
| pub fn build_provider( | |
| rpc_url: &str, | |
| signer: &PrivateKeySigner, | |
| ) -> anyhow::Result<impl Provider + Clone> { | |
| Ok(ProviderBuilder::new() | |
| .wallet(EthereumWallet::from(signer.clone())) | |
| .connect_http(rpc_url.parse().with_context(|| { | |
| format!( | |
| "rpc_url is not a valid URL: {}", | |
| redact_userinfo(rpc_url) | |
| ) | |
| })?)) | |
| } |
References
- When displaying or logging URLs that may contain sensitive credentials or API keys (such as RPC URLs), redact the userinfo (e.g., 'user:pass@') before outputting them to logs or error messages, rather than omitting the URL entirely, to preserve debugging context while preventing credential leakage.
There was a problem hiding this comment.
Thanks — but keeping the full redaction here is intentional, and redact_userinfo would be a regression for this specific field.
redact_userinfo only strips the user:pass@ userinfo and preserves the host + path + query. For relay URLs (where it's used in endpoint.rs) that's correct. But rpc_url secrets almost always live in the path, not userinfo — e.g. Alchemy https://eth-mainnet.g.alchemy.com/v2/<API_KEY> or Infura .../v3/<KEY>. redact_userinfo would leave that key fully visible in the error.
That's exactly why the codebase has two tiers: redact_userinfo (relay URLs) vs sanitize_rpc_display/strip_urls → full <redacted-url> (rpc_url). The full-redaction form here matches:
- the sibling
discovery::active_nodesin this same crate (identical<redacted>, N charson the rpc_url parse), and - the
config validatepolicy of never echoingrpc_url.
This PR is also a pure relocation (no behavior change), and build_provider came over verbatim from chain_ctx. Changing the redaction tier would both diverge from active_nodes and risk leaking provider API keys, so I'm leaving it as-is.
What
Promotes the client-side fetch toolkit out of the
decdn-clibin crate into publicdecdn-client-pullmodules, so any client of thecdn/client/v1data plane — not just thedecdnbinary — can reuse the full "discover → probe → open/reuse channel → paid-fetch" path.Pure relocation, no behavior change:
cli/commands/discovery.rs(active_nodes,select_candidates,rank)client-pull/src/discovery.rscli/commands/probe_client.rs(probe_once,ProbeMetrics)client-pull/src/probe.rscli/commands/client_endpoint.rs(relay/discovery endpoint builder)client-pull/src/endpoint.rscli/commands/chain_ctx::build_provider(wallet provider builder)client-pull/src/provider.rsWhy
decdn-client-pullalready held the reusablecdn/client/v1paid-fetch and buyer-channel kernels, but the discovery half lived in thedecdn-clibin crate (marked "only ever a dev-dependency"), so it was unreachable as a library. This removes that asymmetry and gives the repo one documented public client-fetch surface shared by the CLI and any future client. Justified on its own merits; also unblocks the out-of-repodecdn-gatewayspun out of #866.Changes
git mv, history preserved) + extractbuild_providerintoprovider.rs.clicall sites:fetch,bundle_pull,channel,probe,bond,register,setup.node/tests/probe_0rtt.rstodecdn_client_pull::probe; drop the now-unuseddecdn-clidev-dep fromnode.client-pullgains adecdn-commondep (forendpoint) — iroh-blobs-free per CLI binary-split regression: publisher links cache crate (iroh-blobs/AWS SDK) #578, so the CLI's iroh-blobs-free invariant is preserved (verified withcargo tree -p decdn-cli -e normal -i iroh-blobs→ empty).chain_ctxkeeps its CLI-coupled config/keystore plumbing; onlybuild_providermoved.The
nodecrate's separateprobe_client.rs(aSend + Syncvariant for its concurrent probe loop) is intentionally left in place — consolidating it is a different, riskier change out of scope here.Verification
cargo build,cargo clippy --all-targets,cargo fmt --check,cargo doc -D warnings,cargo deny check— all clean (pre-commit + local).cargo nextest run -p decdn-client-pull -p decdn-cli→ 261 passed (includes the relocateddiscovery::/endpoint::tests).cargo nextest run -p decdn-node -E 'binary(probe_0rtt)'→ 5 passed (the repointed import).Closes #1021.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes