Repository navigation
feat(cli): decdn setup — guided node onboarding wizard (#933) - #953
Conversation
Implement `decdn setup`, the operator-onboarding wizard from ADR 019 §Deferred: thin orchestration over the existing primitives (`key-gen`, `node bond`, `node register`) with Phase 1 pre-flight checks and a Phase 5 readiness summary. It introduces no new on-chain logic — every contract call reuses an existing primitive (`bond::execute`, `register::submit_registration`) or a read-only `CapacityBond` view. Flow: pre-flight → confirm → bond → register → readiness, decrypting the keystore once for the on-chain phase (the signer is built up front and shared across bond + register). Pre-flight checks (all read-only; abort before any tx): - RPC reachability + chain-id match (a mismatch silently dooms signatures) - clock skew vs the RPC's RFC-7231 Date header, ≤10s per ADR 019 (no NTP dep); undetermined renders WARN, not a false pass - TOKEN balance ≥ bond shortfall - native-gas balance ≥ estimated Phase 2 gas Register is guarded against silent node-key divergence: setup bails if the operator is already bound to a different node key rather than reporting success for an unregistered local key. Bond is idempotent (stake-to-tier); a re-run converges. `--dry-run` previews without submitting; `--yes` skips the confirm. Refactors to enable reuse (no behavior change): - bond.rs: Plan/Outcome/build_plan/execute/write_plan widened to pub(crate) - register.rs: extract submit_registration + write_outcome (owned RegisterOutcome replacing borrowed Params) so setup shares the signer/provider Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces a new guided node onboarding wizard command, decdn setup, which orchestrates existing primitives (key-gen, node bond, and node register) alongside pre-flight checks (e.g., clock synchronization, token balance, and native gas checks) and provides a final readiness summary. To support this orchestration, several structs and functions in the bond and register commands were refactored and made pub(crate) for reuse. Feedback on these changes highlights two key improvements: redacting sensitive userinfo from RPC URLs in error messages to prevent credential leakage, and validating the range of the parsed year in parse_http_date to avoid potential integer overflow and panics.
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.
There was a problem hiding this comment.
Pull request overview
Adds a new decdn setup CLI subcommand implementing ADR 019’s guided operator onboarding flow by orchestrating existing primitives (key generation, bonding, registration) and surfacing pre-flight checks plus a final readiness summary.
Changes:
- Introduces
SetupArgsincommonand wiresCommand::Setupthrough the CLI entrypoint. - Implements the
decdn setuporchestration flow with pre-flight checks (chain-id match, clock skew, balances), optional confirmation, and readiness output (human + aggregated JSON). - Refactors
bondandregistercommand internals (pub(crate)plan/outcome helpers +submit_registration) for reuse bysetup.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/common/src/cli/setup.rs | Adds clap args for the new decdn setup subcommand. |
| crates/common/src/cli/mod.rs | Exposes setup module and adds Command::Setup. |
| crates/cli/src/main.rs | Dispatches Command::Setup to commands::setup::run. |
| crates/cli/src/commands/setup.rs | Implements the guided onboarding wizard, pre-flight checks, and readiness/JSON summary. |
| crates/cli/src/commands/register.rs | Extracts submit_registration and write_outcome to support reuse from setup. |
| crates/cli/src/commands/mod.rs | Registers the new setup commands module. |
| crates/cli/src/commands/bond.rs | Widens plan/outcome/build/execute/write helpers to pub(crate) for reuse by setup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage reportTotal: 83.58% (was 84.21%, ▼ 0.63%) — 38722/46328 lines
History
|
…larify prompts - Redact `user:pass@` userinfo from the rpc_url shown in the malformed-URL error, via the existing shared `decdn_common::redact::redact_userinfo` (setup.rs `dry_run_without_keys` + the identical pre-existing site in `chain_ctx::build_provider`). - Bound the parsed year to `1970..=9999` in `parse_http_date` so a malformed/ adversarial `Date` header can't overflow `days_from_civil(...) * 86_400` (i64). IMF-fixdate years are 4-digit, so this rejects nothing valid; added a regression test. - Correct the `parse_http_date` doc to match its deliberately-lenient behavior (weekday ignored, zone trusted as GMT) instead of claiming strict validation. - Reword the bond confirmation so the `shortfall == 0` case no longer implies register-only — `declareMbps` may still submit. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
… bound Follow-up to the PR #953 review (silent-failure-hunter): - An rpc_url secret commonly lives in the path/query (Infura/Alchemy keys), which `redact_userinfo` (userinfo-only) doesn't scrub. Switch the two malformed-URL error sites (`setup::dry_run_without_keys`, `chain_ctx::build_provider`) to hide the value entirely as `<redacted> (N chars)`, matching the established `config validate` policy. - Add an in-band upper-boundary assertion (year 9999 parses) so an off-by-one in the `parse_http_date` `..=9999` year bound is caught. Note: the broader transport-error rpc_url leak (reqwest Display echoes the full URL through alloy errors on any failed RPC call) is pre-existing and codebase-wide (bond/register/node); tracked separately rather than patched piecemeal here. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Summary
Implements
decdn setup(closes #933), the operator-onboarding wizard from ADR 019 §Deferred. It is thin orchestration over the existing primitives (key-gen,node bond#932,node register#929) with the Phase 1 pre-flight checks ADR 019 §Context calls for and a Phase 5 readiness summary — no new on-chain logic (every contract call reusesbond::execute/register::submit_registrationor a read-onlyCapacityBondview).Flow: pre-flight → confirm → bond → register → readiness, decrypting the keystore once for the on-chain phase (the signer is built up front and shared across bond + register).
Pre-flight checks (read-only; abort before any tx)
resolved.chain_id).Dateheader, ≤10s per ADR 019 Phase 1 step 2 — no new NTP dependency. An undetermined reference rendersWARN(non-blocking), not a falseok.Safety properties
--dry-runpreviews without submitting (and still validates the tier band);--yesskips the interactive confirm for CI.Refactors to enable reuse (no behavior change)
bond.rs:Plan/Outcome/build_plan/execute/write_planwidened topub(crate).register.rs: extractedsubmit_registration+write_outcome(ownedRegisterOutcomereplacing the borrowedParams) so setup shares one signer/provider load. Original register output contract preserved; added a submitted-tx test.Review
A multi-agent review (code / silent-failure / type-design / comments / tests) ran on this branch; all material findings were fixed — notably the register-key divergence guard, the
--json --dry-runsingle-object output, the keys-absent dry-run band check, aPreflightstruct that removes a 16-arg/5-bool emitter, and the ADR-citation/clock-threshold doc corrections.Test plan
cargo build,cargo clippy --workspace --all-targets— cleancargo fmt -- --check— cleancargo nextest run— 1885/1885 pass (13 new setup unit tests: RFC-7231 parsing + boundaries,days_from_civil,Preflightpredicates,build_summarydiscriminants,precheck_keys)cargo deny check— clean (confirms no new dependency)decdn setup --helprenders🤖 Generated with Claude Code