Repository navigation
Description
Follow-ups deferred from #753 (buyer-side PaymentChannel openChannel, #744). Both are gated on the not-yet-wired cache-miss hook that calls BuyerChannelService::open_or_reuse_channel (provider-discovery — ADR 001/022), so they're tracked here rather than padding #753. Surfaced by the multi-agent review on #753.
1. Bootstrap chain-log reconciliation for orphaned deposits
Gap. Once openChannel mines, the deposit is escrowed on-chain. If the subsequent ChannelOpened-event decode or the local store.record fails (crates/node/src/buyer_channel.rs, open_and_persist), the channel is tracked only on-chain. The reclaim sweep iterates load_all, so it never sees an unpersisted channel, and there is no chain-log recovery — the deposit is stranded until manual intervention.
Mitigation already shipped in #753 (c0073ea): both post-escrow failure paths now error! with the tx hash so an operator can reconcile/reclaim manually, and a skipped-undecodable buyer record (buyer_load_all) logs at error!.
This issue — automate it. Add a bootstrap reconciliation scan that enumerates on-chain channels where client == self_address (the seller side already demonstrates the ChannelOpened_filter pattern in crates/node/src/payment_settlement.rs) and re-hydrates / reclaims orphaned or undecodable-locally channels. This also rescues buyer rows that became postcard-undecodable after a downgrade (whose channel_id is otherwise unknowable — it lives inside the undecodable bytes).
2. Anvil e2e coverage for the concurrency + corruption paths
crates/node/tests/anvil_settlement_e2e.rs (feature anvil-e2e) currently drives only sequential, single-row scenarios. Two paths added in #753 have no end-to-end coverage:
- Concurrent opens for the same provider. The
opens_in_flightguard /InFlightOpenGuard::claim(crates/node/src/buyer_channel.rs) serializes opens so two racing callers don't each escrow a deposit (the secondrecordwould orphan the first). Add a case that fires two concurrentopen_or_reuse_channel(provider, …)and asserts exactly oneChannelOpened+ one bail-for-retry, then a reuse on retry. This also covers the post-claim TOCTOU re-check. - Mixed corrupt/healthy multi-row reclaim sweep.
buyer_load_allskip-and-warn is unit-tested at the store layer, butreclaim_onceiterating a store seeded with one corrupt + one healthy expired row — proving the corrupt sibling doesn't block reclaim of the healthy one (the actual production manifestation of the feat(node): buyer-side PaymentChannel openChannel for cache-miss settlement (#744) #753 item-1 bug) — is untested. Add an e2e (or areclaim_oncetest with a mock provider) covering it. - Expired-channel rotation via
open_or_reuse_channel. The reclaim-before-reopen + "not yet reclaimable" bail path is currently only reached viasweep_expired_oncedirectly, not throughopen_or_reuse_channel. Add a case that expires a channel and re-callsopen_or_reuse_channel.
Refs
- PR feat(node): buyer-side PaymentChannel openChannel for cache-miss settlement (#744) #753, commits
eff580c(review round 1) andc0073ea(multi-agent review round 2) - Related: Seller-settlement robustness follow-ups (metrics, redeemer tick, downtime backfill) #751 (seller-settlement robustness follow-ups)
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
fix(node): address PR #753 multi-agent review — orphan-deposit escala…
github-actions commentedon Jun 1, 2026
🎯 Triage report
Two well-scoped follow-up tasks deferred from #753 (buyer-side
openChannel): (1) automated bootstrap reconciliation to recover orphaned on-chain deposits that weren't persisted locally, and (2) Anvil e2e coverage for three paths that only have unit-test or no coverage — concurrent opens, mixed-corrupt reclaim sweep, and expired-channel rotation viaopen_or_reuse_channel. A manual mitigation (error-logged tx hash) is already in place for the deposit-stranding scenario. Both tasks are currently blocked on provider-discovery wiring (ADR 001/022).📊 Assessment
mediumadded; existingtechnical,blocked,rust,testingretainedopen_or_reuse_channelbeing wired to the cache-miss hook (provider-discovery — ADR 001/022). An agent could implement the reconciliation scan and the three e2e test cases independently, but the e2e tests for concurrent opens and expired rotation won't have a realistic call path until the hook is live. The orphan-reconciliation scan inBuyerChannelService::run(using the existingChannelOpened_filterpattern frompayment_settlement.rs) could be implemented immediately.🔗 Similar issues
💡 Notes and suggestions
Task 1 — Bootstrap chain-log reconciliation
Approach: mirror
payment_settlement.rs'sChannelOpened_filteron startup, filtered toclient == self_address. Walk each on-chain channel:store.record; if the channel is past its expiry window, go straight toreclaimChannel.Key reference:
open_and_persistincrates/node/src/buyer_channel.rs(the twoerror!sites added in c0073ea are the exact gap this fills).Unblock dependency: None — this can be implemented now. It only needs the RPC provider and the existing
PaymentChannelcontract bindings.Task 2 — Anvil e2e coverage
Three test cases to add in
crates/node/tests/anvil_settlement_e2e.rs(featureanvil-e2e):open_or_reuse_channel(same_provider, ...)tasks concurrently; assert exactly oneChannelOpenedevent mined and one task bails for retry; on retry the second task reuses.reclaim_once; assert the healthy channel is reclaimed and the corrupt row is skipped without blocking.open_or_reuse_channel: expire a channel; callopen_or_reuse_channel; assert it triggers reclaim-before-reopen (or the "not yet reclaimable" bail if the dispute window hasn't closed).Unblock dependency: Cases 1 and 2 can be written against the store/service directly without the cache-miss hook. Case 3 (rotation path) is also reachable by calling
open_or_reuse_channeldirectly in the test — no hook wiring required.Suggested work order
Add this agentic workflows to your repo
To install this agentic workflow, run
feat(node): buyer-side PaymentChannel openChannel for cache-miss sett…
refactor(node): reconcile decision enum + exhaustive store-error matc…
feat(node): bootstrap reconciliation for orphaned buyer channel depos…
refactor(node,incentive): hoist the duplicated buyer-channel redb sto…