Skip to content

decdn pool commands read the client's buyer-pools.redb, not the node's buyer.redb #2078

Closed

Description

@thiras

Every decdn pool subcommand opens <data_dir>/buyer-pools.redb — the standalone client's store. On a node host the daemon's buyer state lives in <data_dir>/buyer.redb, so the CLI reads and writes a different file than the node it is pointed at.

This is a separate defect from #2077, and it invalidates that issue's premise. #2077 reasons that pool list "reads only the local buyer store, so it cannot show a pool whose store row is gone". On a node host it never reads that store at all: pool list prints pools=0 even when the row is present and intact.

Evidence

Observed 2026-09-20 on a three-node fleet running decdn-node at 8095370, right after the #2075 adoption path landed. One node logged a successful adoption — which is emitted after store.record(&state) commits:

INFO adopted this node's existing on-chain payment pool; not opening a second one
     pool_id=0x590e3ca0…cfecb0 deposit=10000000 remaining=9808795
INFO BuyerPoolService bootstrap complete … tracked=0 adopted=true

Immediately afterwards, on that same host, as the same decdn user, with --config /etc/decdn/node.toml (so identity.data_dir resolves to the daemon's /var/lib/decdn):

$ decdn pool list --config /etc/decdn/node.toml
pools=0
(no tracked pools)

All three nodes printed pools=0. The command also created a buyer-pools.redb that had not existed on any of them, at mode 0660 — beside the daemon's 0600 stores.

Mechanism

  • daemon → buyer.redb: const BUYER_DB_FILE: &str = "buyer.redb" (crates/node/src/channel_store.rs:102), opened at channel_store.rs:508 via open_hardened_db.
  • CLI → buyer-pools.redb: const BUYER_POOLS_DB_FILE: &str = "buyer-pools.redb" (crates/incentive/src/buyer_pool_redb.rs:33).
  • list (crates/cli/src/commands/pool.rs:939) calls RedbBuyerPoolStore::open(&data_dir), which is the buyer-pools.redb one, and whose open uses Database::create — hence the stray file.

#1246 deliberately shared the codec and table ops between the two so they could not drift in format. The file split is intentional and documented (buyer_pool_redb.rs:1-7). What appears unintended is that the operator-facing CLI has no way to address the node's file, and reports the empty one as fact.

Beyond list: the mutating paths are also affected

Same store handle, so on a node host:

The on-chain legs of all four are unaffected — they go through getPool/getPools and the contract — so this is a local-bookkeeping defect, not a funds-safety one. We closed two genuinely stranded pools this way and verified the on-chain result was correct; the pools in question were untracked by the daemon, so the no-op forget cost nothing.

There is an irony worth noting: RedbBuyerPoolStore::open carries a careful zero-length guard against a truncated store silently wiping a voucher watermark, while on a node host it is creating a fresh, unrelated store and reporting its emptiness as the node's state.

Impact on the #2075 runbook

docs/runbook.md § "Node-to-node pulls never succeed (buyer wallet or pool)", Cause (2), step 1 reads:

Read decdn_buyer_pool_adoption_failures_total. Any increment means the node could not tell whether it already owned a pool and is about to open a second one; decdn pool list (which reads the local store) then shows nothing while the chain says otherwise.

On a node host that output is unconditional, so it confirms the hypothesis no matter what is true. An operator following the runbook will read pools=0 as corroboration of the forgotten-pool bug on a perfectly healthy node.

Separately, the stranded-pool warning cannot be relied on to find these: reconcile_owned_pool returns on AdoptionCheck::AlreadyTracked before report_stranded_pools, so a node that already tracks a pool never enumerates the chain and never warns. We found a second stranded pool (~9.95 USDC, opened when a store reset orphaned its predecessor) on a node that logged tracked=1 adopted=false and warned about nothing. Only a direct getPools read surfaced it.

Suggested direction

Deferring to your judgement on the shape, but the options seem to be:

  1. Have the CLI resolve the node's store when the config it was handed is a node config — the least surprising behavior for --config /etc/decdn/node.toml.
  2. Failing that, make the mismatch loud rather than silent: if data_dir contains a buyer.redb, refuse to create a fresh buyer-pools.redb beside it and say which file is being read.

Either way pool list should name the file it read, so pools=0 is interpretable. #2077's --all would sidestep the read entirely for the diagnostic case, but the mutating paths still need a decision.

Activity

  1. added
    kind:bug
    area:cli
    area:node
    on Sep 20, 2026
  2. self-assigned this
    on Sep 20, 2026
  3. moved this from Backlog to In progress in deCDNon Sep 20, 2026
  4. moved this from In progress to Done in deCDNon Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:cliarea:nodekind:bug

Type

No type

Fields

Priority

None yet

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions