Skip to content

Node metrics/admin listeners bind only after the buyer PaymentChannel bootstrap (blocks ~27 min on slow approve) #1109

Closed

Description

@thiras

Summary

decdn-node does not bind its /metrics (9090) or admin RPC (9191) listeners until the buyer-side PaymentChannel bootstrap completes. On startup that bootstrap synchronously awaits a one-time USDC approve receipt; when the tx is slow to confirm (slow/flaky RPC, congested chain, underpriced/stuck tx) it blocks for many minutes — ~27 min observed on a live Arbitrum-Sepolia node — during which the node is otherwise healthy (QUIC udp/4433 listening, isActiveNode=true, NRestarts=0) but has no metrics/admin surface and never logs "node runtime ready".

Impact

Root cause — startup ordering in crates/node/src/runtime/mod.rs::run()

  • The iroh/QUIC endpoint binds early (build_endpoint, ~L615) — hence QUIC is up almost immediately.
  • The buyer PaymentChannel bootstrap is awaited synchronously at L1161–1182 → ensure_allowance (crates/node/src/buyer_channel.rs:278) → crates/client-pull/src/buyer_channel.rs::ensure_allowance, which awaits:
    erc20.approve(spender, U256::MAX).send().await?.get_receipt().await?
    get_receipt() blocks until the one-time approve is mined.
  • Everything after that await is gated behind it: router spawn (L1199), DHT bootstrap (L1213), metrics bind (L1228), admin bind (L1443), and finally "node runtime ready" (L1792).

The comment at L1130–1133 explicitly states the buyer bootstrap is non-fatal and "must not block the node's core seller function" — but by sitting synchronously ahead of the observability/admin binds, it blocks all visibility into that function. Notably, the reclaim loop (buyer_channel.rs:295) and orphan reconciler (:316) in the same bootstrap are already spawned as background tasks — the blocking approve is the outlier.

Suggested fix (either or both)

  1. Bind metrics + admin (and spawn the router) before the buyer bootstrap await, so observability comes up independent of the buyer/chain path.
  2. Background the buyer bootstrap (spawn it like its own reclaim loop — its failure path already says "restart to retry") and add a bounded timeout on the approve get_receipt() so a stuck tx never hangs even the buyer lane.

Repro

Point a node at an RPC/chain where the one-time USDC approve is slow to confirm (or the wallet's first approve is underpriced so it sits pending). Observe /metrics refusing connections and no "node runtime ready" log line for many minutes, while QUIC serves and the systemd unit is active (running).

Metadata

Metadata

Assignees

Labels

kind:bugprio:high

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions