Repository navigation
feat: publisher-pays channels — open-on-behalf + adopt-by-id + reject-bundle resume (#1481) - #1488
Conversation
…keying Re-keys BuyerChannelState by channel_id with a provider secondary index, adds the pinned voucher_signer, bumps BUYER_SUPPORTED_SCHEMA_VERSION 1->2 (v1 records skipped, non-fatal), and fixes the channel-close branch to gate on voucher_signer instead of the watermark proxy (#1481). Co-Authored-By: Claude Opus 4.8 <[email protected]>
…1481) Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
…#1481) Co-Authored-By: Claude Opus 4.8 <[email protected]>
…wallet-less resume (#1481) A wallet-less client has no way to reconstruct its true payment-channel watermark from chain (the claim watermark stays 0 until settlement), so a StaleNonce/AmountRegression/BytesRegression/InsufficientDeposit rejection was previously a dead end for it. StreamError::VoucherRejected now carries an optional WatermarkBundle (node's last-accepted amount/nonce/bytes_delivered plus the client's own last-accepted signature). The node attaches it only for those four gated regression/ exhaustion reasons, and only after confirming the rejected voucher's own signature recovers to the channel's pinned voucher_signer — otherwise anyone who guessed the chain-derivable channel_id could probe the watermark with a garbage voucher. Handler-direct reasons (Expired, RetryLater, CooperativeCloseSigned, RateFloorRaised, WrongChannel, BadSignature, WrongSigner, WrongToken) never carry a bundle. client-pull gains Cumulative::from(&WatermarkBundle) and ChannelLedger::reseed so a caller that receives a bundle can overwrite its local watermark and resume issuing from bundle.nonce + 1 instead of treating the rejection as terminal. Call sites that construct VoucherRejected/UpstreamVoucherRejected (cli bundle_pull, node node_origin(_pull) tests) pick up the new field as fallout of the wire-type change; no behavior change there beyond compiling against the new shape. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…nto the real pull path (#1481) Task 5's node-side gate was correct but nothing consumed the bundle it sent: a wallet-less client hitting a gated StaleNonce/AmountRegression/ BytesRegression/InsufficientDeposit rejection still saw its pull abandoned, identically to before the feature existed. - crates/client-pull/src/lib.rs: fetch_inner (the buffered pull every production entrypoint funnels through, including stream_fetch_shared — the daemon's own node-to-node cache-miss buyer leg) now retries, bounded by MAX_RESUME_ATTEMPTS, when a mid-stream rejection carries a signer-verified WatermarkBundle for a gated reason: it reseeds the channel's ChannelLedger and reopens a fresh stream. Deliberately does NOT jump byte_offset to bundle.bytes_delivered — that field is the CHANNEL's cumulative payment counter (used to reconstruct each voucher's EIP-712 bytesDelivered), not a position within the blob being fetched. Every current caller requests byte_offset == 0, so jumping the wire offset ahead would silently return a truncated tail instead of the full blob the caller relies on getting back; retrying at the caller's original offset is always safe and is all the reseed actually needs. Added Cumulative::from(&WatermarkBundle) reuse via ledger.reseed(), WatermarkBundle::validate() (protocol crate) consulted before a bundle is trusted, and VoucherRejectReason::is_watermark_gated() promoted to the protocol crate as the single source of truth the node's gate and the client's retry both call, replacing node's local duplicate. - crates/node/src/node_origin.rs: voucher_verdict/pull_verdict needed no behavior change — the retry resolves entirely inside client-pull before an error can reach this classifier — but now says so explicitly, so a reader doesn't have to rediscover that by reading another crate. - crates/node/tests/node_origin_pull.rs: new end-to-end test (a_stale_nonce_rejection_with_a_bundle_self_heals_over_the_wire) drives two real ChannelLedgers against a real ClientHandler + real MemoryChannelStateStore over live QUIC, forcing a genuine StaleNonce and asserting the resumed pull returns the correct full blob with no special handling by the caller. Co-Authored-By: Claude Opus 4.8 <[email protected]>
LookupArgs flattened ChainArgs (which already exposes --json via CommonChainArgs) while also declaring its own --json, which trips clap's unique-argument-name assertion and fails cli_command_tree_is_clap_valid. Drop the duplicate field and read the flattened chain.common.json. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…1481) CRITICAL: the client-side resume wired in the previous commit trusted WatermarkBundle.amount/nonce/bytes_delivered after only a length check (WatermarkBundle::validate). The bundle rides inside a mid-stream StreamError, which carries no signature of its own, so those fields were fully attacker-controllable by the upstream node. reseed()ing the ledger to them and retrying would sign a fresh voucher for the (possibly inflated) bundle.amount + delta — a voucher this client genuinely holds the key to sign, redeemable on-chain up to the deposit. A malicious/buggy upstream could drain a channel this way, on any paid pull through fetch_inner (stream_fetch_shared included), not only wallet-less ones. resumable_watermark now additionally reconstructs a decdn_incentive SignedVoucher from ctx.channel_id/ctx.token and the bundle's amount/nonce/bytes_delivered + last_signature, recovers its signer under ctx.voucher_domain, and requires it to equal ctx.client_signer.address() — the client-side half of exactly the check the node's own gate performs before it ever attaches a bundle. A bundle that fails this (wrong key, or the right key over a tampered field) is never reseeded from; the rejection stays terminal, unchanged from pre-#1481 behavior. Also folds in two doc fixes flagged by the same review pass: the VoucherRejected::bundle field doc no longer reads as a wire byte-offset instruction (bytes_delivered is the channel's cumulative payment counter, not a blob offset — matches fetch_inner's own doc), and three stale buyer_channel_state_v1 comments (channel_store.rs, runtime/mod.rs x2) now say _v2, matching the real redb table name. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…-payer recovery ADR 005 gains the WatermarkBundle wire shape and its two signature gates (node attaches only on recovery to voucherSigner; client trusts only when last_signature recovers to its own key), corrects the now-false claim that the VoucherRejected frame ends at the reason byte, and updates the StaleNonce/InsufficientDeposit recovery rows for the delegated (publisher-pays) client. ADR 003 notes a delegated payer cannot topUp or self-refresh from chain. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Warning Review limit reached
Next review available in: 7 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (12)
WalkthroughChangesThe PR adds authenticated watermark bundles to voucher rejections and client-side self-healing, rekeys buyer-channel storage by Payment recovery
Buyer-channel storage and CLI
Estimated code review effort: 5 (Critical) | ~120 minutes 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 |
# Conflicts: # crates/client-pull/src/ledger.rs # crates/client-pull/src/lib.rs
# Conflicts: # crates/node/src/handlers/client/voucher.rs
# Conflicts: # crates/node/src/handlers/client/voucher.rs
Adds StreamError::VoucherRejected::bundle, VoucherRejectReason::is_watermark_gated, and the WatermarkBundle struct + validate() to the public-api snapshot (#1481). Co-Authored-By: Claude Opus 4.8 <[email protected]>
Coverage reportTotal: 80.91% (was 81.29%, ▼ 0.38%) — 53922/66647 lines
History
|
Task 2 added the voucher_signer arg to open_channel; this anvil-e2e-gated test (not compiled by the default-feature suite) still called it with 7 args. Pass Address::ZERO (self-signing — the buyer funds and signs with one key). (#1481) Co-Authored-By: Claude Opus 4.8 <[email protected]>
Closes #1481. Builds on #1478 (delegated
voucherSigner+ voucher-less close), which is merged intomain.Lets a client fetch with no wallet, no on-chain tx, and no USDC: a publisher opens a channel on the client's behalf pinning the client's key as
voucherSigner, and the client signs vouchers locally, adopts the channel by id, and self-heals its watermark on a reject.What's in it
7aa78b4) — re-keysBuyerChannelStatebychannel_id(with a provider secondary index for the auto-open reuse path), addsfunder(the on-chainclient— the only addresstopUpaccepts) andvoucher_signer(the pinned EIP-712 signer), bumpsBUYER_SUPPORTED_SCHEMA_VERSION1→2 (v1 records skipped, non-fatal), and fixes thechannel closebranch to gate onvoucher_signerinstead of a watermark proxy.decdn channel open --provider-address --deposit-micro-usdc [--voucher-signer](44dad1e) — publisher-side; pins a delegate asvoucherSigner, prints{"channelId": …}.decdn node lookup [--node-id|--region] [--probe] [--json](cff0cf7) — unpaidCapacityBond.getActiveNodes()discovery → operator address, optional RTT probe-rank.decdn fetch --channel-id <id>(a5f5d39) — adopt-by-id:getChannel→ verifyvoucherSigner-in-keystore + Open + unexpired → hydrate the watermark from on-chain claimed totals → fetch; the fetch-time top-up is skipped when the local key isn't the funder (topUpis funder-only).d6a87ab,08be6dc,520af94) — on aStaleNonce/AmountRegression/BytesRegression/InsufficientDepositreject, the node attaches its true watermark + the client's echoed last signature toVoucherRejected; the client re-seeds its ledger and resumes, makingStaleNonceself-healing. Two signature gates: the node attaches the bundle only when the rejected voucher recovers to the pinnedvoucher_signer(no watermark leak to achannelIdguesser); the client trusts a bundle only when itslast_signaturerecovers to the client's own key (the bundle rides in an unsignedStreamError, so this prevents a malicious upstream from inflating the watermark and draining the deposit).Plus
6e2cbad(a--jsonclap-collision fix innode lookup) and438deb0(ADR 003/005 sync for the new wire field and delegated-payer recovery).No contract changes
All on-chain surface shipped in #1478. This branch is Rust + ADR docs only.
Verification
cargo nextest run→ 2614/2614 pass, 0 skippedcargo clippy --all-targetsclean,cargo fmt --checkclean, all pre-commit hooks passnode_origin_pull::a_stale_nonce_rejection_with_a_bundle_self_heals_over_the_wire); three tests encode the watermark-forgery attack and assert rejection.Reviews
Each part had a spec+quality review; a whole-branch review (opus) then caught a critical unauthenticated-reseed vector (the client ignored the bundle's
last_signature), fixed in520af94and re-reviewed clean.Deployment notes
VoucherRejectedgains abundlefield (positional postcard, append-only). One-field and two-field peers do not interoperate — this is a single coordinated pre-deployment cut, not a staged rollout._v1→_v2rename makes any pre-existing local buyer store invisible to the CLI (the node rebuilds from chain via reconcile; the CLI re-adopts via--channel-id). Local cache only; acceptable for the testnet cut.Deferred (follow-ups, non-blocking)
channel openidempotency guard;--channel-idcache-hit refill logic;--probefan-out cap vs. plain listing UX.MAX_RESUME_ATTEMPTS = 3is currently a code constant, not ADR-anchored.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
decdn channel openfor opening payment channels with optional delegated voucher signers.decdn node lookupwith node/region filters, latency probing, table output, and JSON output.decdn fetch --channel-idto adopt an existing payment channel directly.Bug Fixes