Repository navigation
fix(client,cli)!: sign each data dir's owned lanes with a derived key - #2482
Merged
Merged
Conversation
…#2468) `decdn get` signed vouchers with the wallet key, and a fresh `--data-dir` adopts the wallet's live pool. Two data dirs on one wallet therefore signed the same `(pool, signer, provider)` lanes from separate watermarks. Providers rejected the run that fell behind as `UnderFold`, and the runs spent their resume budget re-fetching bytes elsewhere: about 36% of traffic was wasted on testnet. Each client data dir now signs with a lane key derived from the wallet key and a random salt kept in `buyer-pools.redb` (new `buyer_lane_salt_v1` table, `BuyerPoolStore::lane_salt`). The derived key is never stored. The wallet key still owns the pool, sends its transactions, keys the store row, and signs the capability that authorizes the lane key. The lane key signs the vouchers and the client identity binding, which the node keys the lane on. Data dirs share the pool but never a lane, so the `AlreadyOpen` advice to run concurrent pulls from separate data dirs is safe on the wallet's own pool. The node keeps signing its upstream lanes with the node key (`OwnedPayer::sole`); delegated runs are unchanged. BREAKING CHANGE: decdn-client SDK. An owned pool pays through `buyer_pool::OwnedPayer` (`for_store` / `sole`); `self_owned_lane_ctx` and `issue_self_capability` take it, and `lanes::LanePayer::Owned` holds it. `open_pool` and `opened_from_receipt` take no signer, and `OpenedPool` drops `ctx` and `capability`. `bundle::Funding::SelfOwned` names its key `owner`. `BuyerPoolStore` gains the required `lane_salt` method. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Shared-pool spending can remain invisible to funding recovery, preventing funded clients from resuming.
2 open findings
What changed in this PR
Separates client data directories’ voucher signers to prevent shared-wallet lane collisions while retaining one shared payment pool.
Changes:
- Derives lane keys from the wallet key and a durable per-store salt.
- Separates pool ownership from voucher signing across client and CLI paths.
- Updates SDK APIs, documentation, and regression coverage.
| File | Description |
|---|---|
| crates/node/tests/anvil_settlement_e2e.rs | Adapts capability setup. |
| crates/node/src/pool_store.rs | Delegates salt storage. |
| crates/node/src/buyer_pool/tests.rs | Preserves node-key signing coverage. |
| crates/node/src/buyer_pool.rs | Uses sole-key payer. |
| crates/incentive/src/store.rs | Clarifies concurrent-store documentation. |
| crates/incentive/src/lib.rs | Exports lane-key module. |
| crates/incentive/src/lane_signer/tests.rs | Tests deterministic derivation. |
| crates/incentive/src/lane_signer.rs | Implements salted lane-key derivation. |
| crates/incentive/src/buyer_pool.rs | Adds store salt interface. |
| crates/incentive/src/buyer_pool_table/tests.rs | Tests salt persistence. |
| crates/incentive/src/buyer_pool_table.rs | Persists salt durably. |
| crates/incentive/src/buyer_pool_redb/tests.rs | Tests store-level salt isolation. |
| crates/incentive/src/buyer_pool_redb.rs | Exposes persisted salt. |
| crates/e2e/tests/pool_floor_ceiling_aggregate.rs | Adapts pool-opening call. |
| crates/e2e/tests/cli_fetch_two_data_dirs.rs | Tests concurrent isolated lanes. |
| crates/e2e/tests/cli_fetch_topup.rs | Tracks derived lanes. |
| crates/e2e/tests/cli_fetch_multi_source.rs | Matches voucher signers. |
| crates/e2e/tests/cli_bundle_pull_pool_id.rs | Checks derived-lane accounting. |
| crates/e2e/tests/cli_bundle_pull_multi_source.rs | Matches voucher signers. |
| crates/e2e/src/client.rs | Adapts fixture payer construction. |
| crates/common/src/cli/fetch.rs | Explains keystore signing roles. |
| crates/client/tests/snapshots/public_api__public_api.snap | Records SDK API changes. |
| crates/client/src/lib.rs | Updates signing documentation. |
| crates/client/src/lanes/tests.rs | Adjusts test imports. |
| crates/client/src/lanes.rs | Builds lanes with separated keys. |
| crates/client/src/lane_sources/tests.rs | Tests owner-row routing. |
| crates/client/src/lane_sources.rs | Routes funding through owner. |
| crates/client/src/funding/tests.rs | Tests bindings and salt failures. |
| crates/client/src/funding/adoption_tests.rs | Tests disjoint adopted lanes. |
| crates/client/src/funding.rs | Separates funding and lane signers. |
| crates/client/src/buyer_pool/tests.rs | Tests payer signing roles. |
| crates/client/src/buyer_pool.rs | Introduces OwnedPayer. |
| crates/client/src/bundle/engine/tests.rs | Adjusts test imports. |
| crates/client/src/bundle/engine.rs | Carries bundle payer roles. |
| crates/client/src/bundle.rs | Derives owned bundle signers. |
| crates/client/examples/common/mod.rs | Demonstrates derived-key usage. |
| crates/cli/src/commands/pool/tests.rs | Adapts store test double. |
| crates/cli/src/commands/pool.rs | Adapts pool-opening call. |
| crates/cli/src/commands/fetch.rs | Initializes derived fetch signers. |
| crates/cli/src/commands/buyer_store.rs | Clarifies shared-deposit warning. |
| crates/cli/src/commands/bundle_pull.rs | Supplies pool owner key. |
| CHANGELOG.md | Documents fix and SDK breaks. |
| adr/012-client.md | Describes lane keys and exposure. |
| adr/003-payments.md | Updates signer-role guidance. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 10 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
#2468) A data dir tracks only its own lanes. With one lane key per data dir, a pool another data dir on the wallet drained read full to this one: the low-water refill did not fire, and a funding recovery step only settled, so the run ended "funding needed" with a funded wallet. `BuyerPoolState::reconcile_with_chain` raises a row to the pool's on-chain deposit and counts at least `totalRedeemed` as spent, less the row's own lanes so they count once. The run's first lane build applies it to the reused row (`still_open`, which already reads `getPool`), and each funding recovery step caps the run's remaining deposit at what the chain shows. ADR 012 now describes a leaked lane key as its own exposure: the lane key sits in process memory beside the owner key and can leak alone. The capability is uncapped and never expires, so the response is to close the affected pools and draw a new salt, not to wait. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 16, 2026
thiras
added a commit
that referenced
this pull request
Oct 16, 2026
#2488) * fix(node,cli)!: report the pool owner as a lane's counterparty (#2484) admin_v1_lanes filled LaneSnapshot.counterparty with the lane signer. Since #2482 every `decdn get` lane signs with a key derived for its data dir, so `decdn node lanes` showed that key, not the wallet that funds the pool, and an operator looking a client up by its funding wallet found nothing. The node now reads the owner (getPool.owner) from the event-fed pool view the serve gates already use, with no chain call. counterparty becomes Option<String>: None when the view holds no entry for the pool, never the signer. `decdn node lanes` prints `unknown` there, `--json` prints null. Tests seed an owner distinct from the signer at every layer, and the two multi-source CLI e2e journeys now assert that a derived-key lane reports its funding wallet as the counterparty. Closes #2484 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(node): name the owner of a lane carried across a restart The pool projection lives in memory and the settlement watcher resumes at its checkpoint, so after any restart every carried-over lane read `None` until its pool saw a new request. That covered most lanes an operator checks, including settlement-eligible ones. admin_v1_lanes now resolves owners through PoolOwners: the projection, then an owner cache, then one bounded getPool per pool in neither, eight at a time. A pool's owner never changes, so the cache keeps every owner it reads. The read uses its own binding, not ResolvingPoolView, so a failed read never negative-caches a pool the serve path reads. A failed read reports None, logs one warning per call, and is retried next call. Review follow-ups: the e2e topup and coalesce helpers find the lane by signer and then assert the owner; the JSON test requires the key; the pool_view backfill docs describe the restart case and the real resolver. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What
decdn getsigned vouchers with the wallet key, and a fresh--data-diradopts the wallet's live pool. So two data dirs on one wallet signed the same(pool, signer, provider)lanes from separate watermarks. Providers rejected the lagging run asUnderFold, and the runs burned their resume budget re-fetching elsewhere (~36% wasted traffic in the testnet repro). TheAlreadyOpenmessage recommended exactly this setup.Each client data dir now signs its owned lanes with a lane key derived from the wallet key and a random salt kept in its
buyer-pools.redb. The derivation iskeccak256("decdn/client-lane-signer/v1" ‖ owner_sk ‖ salt), the salt lives in the newbuyer_lane_salt_v1table, and the lane key is never stored. This uses the capability delegation ADR 003 already specifies: no wire, ABI or contract change.openPool/topUp/approve, keys the buyer-store row, signs the capability for the lane keyData dirs share the pool but never a lane, so the
AlreadyOpenadvice is safe on the wallet's own pool.Closes #2468
Reviewer notes
Start with
crates/incentive/src/lane_signer.rs, thenOwnedPayerincrates/client/src/buyer_pool.rs, thenopen_or_reuse_pool/build_pool_ctx/attach_client_bindingincrates/client/src/funding.rs.Unchanged on purpose:
OwnedPayer::sole, pinned bypin_ctx_signs_with_the_node_key).--capabilityruns still sign with the delegate key, so two data dirs on one delegate key still share its lanes. The docs and CHANGELOG say so.Binding:
attach_client_bindingnow signs with the context's ownclient_signer, so the binding key equals the voucher key by construction.Existing data dirs: a store draws a salt on first use. Its wallet-signed lanes stay in the row and count as pool spend; new vouchers sign on fresh lanes. Nothing is stranded or paid twice.
SDK break (
decdn-client):OwnedPayer;open_pool/opened_from_receipttake no signer, andOpenedPooldropsctxandcapability;self_owned_lane_ctxandissue_self_capabilitytake&OwnedPayer;Funding::SelfOwned { owner };BuyerPoolStore::lane_saltis a new required method.The public-API snapshot is regenerated.
A salt read/record failure carries
LocalPullFaultand a repair hint, so it never retries or falls back to another key.Follow-up, not fixed here: the node's admin
lanes()fillscounterpartywith the lane signer, although its DTO doc says pool owner (crates/node/src/admin.rs:1001). It was already wrong for delegated clients and now affects every CLI client. The two multi-source e2e tests now match onvoucher_signer.Not done: the testnet re-run of the issue's three-pull repro.
Verification
cargo fmt -- --checkCARGO_BUILD_WARNINGS=deny cargo clippy --workspace --all-targets --all-features(ran ascargo clippy --workspace --all-features --all-targets -- -D warnings)cargo nextest run --workspace --all-features: 5068 passedCARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-itemscargo nextest run -p decdn-e2e -p decdn-node --features anvil-e2e -E 'binary_id(decdn-e2e::*) | binary(anvil_settlement_e2e)': 80 passedcli_fetch_two_data_dirse2e:for_storesigns with the wallet key.cast keccak+cast wallet addresscontracts/changed: n/aCHANGELOG.mdentries (Fixed + Changed (BREAKING))🤖 Generated with Claude Code