Repository navigation
fix(node): bind metrics/admin before the buyer PaymentChannel bootstrap (#1109) - #1112
Conversation
…ap (#1109) `decdn-node` bound its /metrics and admin RPC listeners only after the buyer-side PaymentChannel bootstrap completed. That bootstrap synchronously awaited a one-time USDC `approve` receipt which could hang for many minutes on a slow/stuck tx (~27 min observed on a live Arbitrum-Sepolia node), leaving an otherwise-healthy, serving node with no observability surface and no "node runtime ready" log for the whole window. Fully background the buyer `BuyerChannelService::bootstrap` and the NodeOrigin pull-through provisioning it feeds into a single `tasks.spawn`, placed after the metrics and admin binds, so observability comes up independent of any chain RPC. The task holds the `Arc<BuyerChannelService>` until shutdown so its AbortOnDrop reclaim/reconcile sweeps keep running for the process lifetime as before, and a new stop oneshot lets shutdown cancel a slow bootstrap. Provisioning is safe to defer: NodeOrigin arms via a write-once OnceLock, so pulls before it land as clean misses. Also bound the `approve` receipt wait in `ensure_allowance` with a 3-minute `APPROVE_RECEIPT_TIMEOUT`, converting an unbounded hang into a sticky "restart to retry" failure; the timeout error names the broadcast tx hash. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (2)
WalkthroughThe change bounds USDC approval receipt waits and moves buyer payment-channel bootstrap and node-origin provisioning into a stoppable background task, with explicit shutdown signaling and non-fatal bootstrap errors. ChangesBuyer service lifecycle
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant NodeRuntime
participant buyer_bootstrap_task
participant BuyerChannelService
participant NodeOrigin
NodeRuntime->>buyer_bootstrap_task: spawn bootstrap task
buyer_bootstrap_task->>BuyerChannelService: bootstrap
BuyerChannelService-->>buyer_bootstrap_task: service result
buyer_bootstrap_task->>NodeOrigin: provision after successful bootstrap
NodeRuntime->>buyer_bootstrap_task: send buyer_bootstrap_stop_tx
buyer_bootstrap_task-->>NodeRuntime: stop and release service hold
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.71% (2452/2764 lines) |
There was a problem hiding this comment.
Code Review
This pull request moves the buyer-side PaymentChannel bootstrap and node-to-node pull-through provisioning to a background task to avoid blocking the startup critical path. It also introduces a timeout for the USDC approve receipt. A compilation error was identified in the timeout definition, as Duration::from_mins is not a valid function in the Rust standard library.
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
This PR fixes a node startup ordering issue where /metrics and admin RPC listeners were bound only after the buyer-side PaymentChannel bootstrap completed (which could block for many minutes while waiting for a one-time USDC approve receipt). The change ensures observability/admin surfaces (and the “node runtime ready” banner) come up independent of chain/RPC delays, while still preserving the buyer service’s process-lifetime reclaim behavior.
Changes:
- Backgrounds buyer
BuyerChannelService::bootstrapand theNodeOriginpull-through provisioning into aJoinSettask, allowing metrics/admin bind and readiness logging to proceed immediately. - Adds a shutdown oneshot to cancel an in-flight buyer bootstrap during graceful shutdown and release the process-lifetime hold.
- Bounds USDC
approvereceipt waiting with a 3-minute timeout and surfaces the tx hash in the timeout error for operator correlation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
crates/node/src/runtime/mod.rs |
Defers buyer bootstrap + pull-through provisioning to a background task and adds a shutdown cancel signal so metrics/admin and readiness are no longer blocked by chain/RPC latency. |
crates/client-pull/src/buyer_channel.rs |
Adds APPROVE_RECEIPT_TIMEOUT and wraps get_receipt() in a timeout that reports the broadcast tx hash on timeout. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage reportTotal: 80.37% (was 80.43%, ▼ 0.06%) — 44762/55698 lines
History
|
Summary
Fixes #1109.
decdn-nodebound its/metricsand admin RPC listeners only after the buyer-side PaymentChannel bootstrap completed. That bootstrap synchronously awaited a one-time USDCapprovereceipt, which can hang for many minutes on a slow/stuck tx (~27 min observed on a live Arbitrum-Sepolia node) — leaving an otherwise-healthy, serving node with no metrics/admin surface and no"node runtime ready"log for the whole window.Changes
crates/node/src/runtime/mod.rs— the buyerBuyerChannelService::bootstrapand the NodeOrigin pull-through provisioning it feeds are now fully backgrounded into a singletasks.spawn, placed after the metrics bind and admin bind. Observability and the"node runtime ready"banner now come up independent of any chain RPC.Arc<BuyerChannelService>until shutdown, so itsAbortOnDropreclaim/reconcile sweeps keep running for the process lifetime exactly as before (even when pull-through is off).buyer_bootstrap_stop_tx/_rxoneshot (fired in the shutdown block,biasedselect) lets graceful shutdown cancel a slow in-flight bootstrap.NodeOriginarms via a write-onceOnceLock, so any pull that races ahead of provisioning lands as a clean miss (no spend, no panic) — the same window that already existed between cache build and provision.crates/client-pull/src/buyer_channel.rs—ensure_allowancenow bounds theapprovereceipt wait with a hardcoded 3-minuteAPPROVE_RECEIPT_TIMEOUT, converting an unbounded hang into a sticky "restart to retry" failure (same posture as an insufficient-gas approve). The timeout error names the broadcast tx hash for operator correlation; the re-approve stays idempotent via the allowance read.Verification
cargo build,cargo clippy --workspace --all-targets,cargo fmt --check— cleancargo nextest run— client-pull 35/35, node 745/745 pass (incl. thenode_to_node_pull_through/node_origin_pullsuites that exercise provisioning)approvestalls and confirm/metrics+ the ready banner come up in seconds while the buyer lane bootstraps in the background.Notes / possible follow-up
The backgrounded task joins the existing
tasksJoinSet convention, so a task panic (vs the handled non-fatalErr) is reaped at shutdown rather than fail-fast — deliberate, matching every other background task and the issue's non-fatal requirement. Apull_through_armed/ buyer-bootstrap-outcome metric would make "pull-through never came up" alertable; called out as a candidate follow-up rather than scope-creeping this fix.🤖 Generated with Claude Code
Summary by CodeRabbit