Skip to content

Seller-settlement robustness follow-ups (metrics, redeemer tick, downtime backfill) #751

Closed

Description

@thiras

Deferred items from the comprehensive review of #327 / PR #743 (none block the PR; all are robustness/observability or contained refactors).

Correctness gap

  • Opened-during-downtime backfill. payment_settlement::run_watcher_once uses .watch() filters, which only deliver logs from the current block forward. A channel a client opens against this node while the node is down is never registered (it isn't in the store either), so its vouchers are rejected with WrongChannel indefinitely. Add a startup log-backfill: persist a last-seen block and query ChannelOpened (provider == self) over the gap on bootstrap, registering each. Documented as a known gap in the module doc in 34a91ae.

Robustness

  • Independent redeemer tick. redeemer_loop acts only on hints from the bounded (256) advisory channel. Under high channel fan-out, hints can be dropped and threshold redemption stalls until shutdown/expiry-sweep. Add a low-frequency self-tick that scans load_all for above-threshold channels. (Also covers a withdraw whose receipt errored but later mined, and a channel that goes quiet just below threshold.)
  • Quiesce the redeemer before the shutdown close. close_open_channels_on_shutdown runs while redeemer_loop is still live (it's only aborted when the service drops, after run() returns), so a shutdown closeChannel can race an in-flight withdraw → a benign revert + a misleading warn!. Abort/await the redeemer first, or downgrade the expected race log.

Observability

  • Metrics for the silent/near-silent paths: dropped redeem hints (try_send Full), redemption-attempt failures (redeemer_loop), and swallowed handler-persist failures in the watcher (register_open_channel / update_channel_deposit / forget_channel). Today a real problem in any of these is only a single warn! line.
  • A VoucherRejectReason::Expired (or StreamError::ChannelExpired) wire code so the expiry serve-gate surfaces an actionable reason instead of an opaque anyhow::bail! stream drop.

Type hygiene (contained refactors)

Context: PR #743, review threads on commits 5d658d8 / 076b919 / 34a91ae.

Activity

  1. self-assigned this
    on May 31, 2026
  2. added
    kind:bug
    prio:medium
    rust
    on May 31, 2026
  3. github-actions commented on May 31, 2026

    @github-actions

    🎯 Triage report

    Post-PR #743 follow-up tracker covering seven deferred items across correctness, robustness, observability, and type hygiene in the seller-side payment settlement crate (incentive). The correctness gap (downtime backfill) is the most impactful: channels opened while the node is offline are permanently unregisterable until the next restart with the fix, silently causing WrongChannel rejections for those clients. The remaining items are robustness/observability improvements or contained refactors, all well-scoped.

    📊 Assessment

    Dimension Value Reasoning
    Type Task Tracking checklist of deferred follow-up work, not a single defect report
    Labels bug, technical, rust, medium Contains a genuine correctness gap (backfill); all items are Rust implementation work in incentive; medium priority — no data loss, just dropped vouchers and silent errors
    Coding agent Needs more info Each sub-task is individually well-specified, but most require navigating the incentive crate's channel store, watcher, and redeemer internals. The downtime-backfill and independent-redeemer-tick items are closest to "suitable" once someone confirms the current block-persistence mechanism. The type-hygiene items are the most self-contained and likely the easiest entry point.
    💡 Notes and suggestions

    Recommended work order:

    1. VoucherRejectReason::Expired wire code — purely additive, no cross-crate state touch, good warm-up.
    2. TrailerV2 bundle (cosmetic) — isolated codec change, easy to test with round-trip property tests.
    3. ChannelState hydration constructor — compiler-enforce the apply_voucher-only invariant; unblocks safer work on the redeemer.
    4. Independent redeemer tick — add a tokio::time::interval alongside the hint channel receiver in redeemer_loop; scan load_all, filter above_threshold, submit withdraw.
    5. Quiesce redeemer on shutdown — store the JoinHandle for redeemer_loop, abort()+await it before entering close_open_channels_on_shutdown; downgrade the existing warn! on the now-expected race to debug! in the interim if full quiesce is non-trivial.
    6. Metrics — instrument the try_send full path, redemption failures, and watcher persist failures; agree on the metrics subsystem (prometheus counters via the existing metrics crate).
    7. Downtime backfill — most complex; requires a persisted last_seen_block (likely in the same store as channel state), a get_logs call on bootstrap filtered to ChannelOpened(provider == self) over the gap, and careful handling of reorgs / very large gaps.

    Correctness gap details:
    run_watcher_once subscribes via .watch() which only delivers future logs. On bootstrap, the node should: (a) read persisted last_seen_block, (b) call eth_getLogs for ChannelOpened events with provider == self.address between last_seen_block+1 and current_block, (c) call register_open_channel for each, (d) update last_seen_block. This must be idempotent (upsert semantics on the store) to handle repeated restarts or RPC failures mid-backfill.

    Redeemer race on shutdown:
    The simplest fix is to store redeemer_task: JoinHandle<()> on the service struct and call redeemer_task.abort(); let _ = redeemer_task.await; at the top of close_open_channels_on_shutdown. If that's a large refactor, an acceptable interim is downgrading the warn! on the revert to debug!("expected revert: redeemer raced shutdown closeChannel").

    Generated by Agentic Triage for issue #751 · sonnet46 476K · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
    
  4. added 7 commits that reference this issue on Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind:bugprio:mediumrust

Type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions