Skip to content

node: settleChannel finalization sweep has no metrics and no structured outcome field — transient RPC vs on-chain revert indistinguishable in metrics #810

Closed

Description

@alpergundogdu

When seller-side payment-channel finalization (settleChannel) fails, an operator cannot triage it from metrics, and cannot distinguish a transient JSON-RPC failure from a permanent on-chain revert without grepping raw tracing output. The three outcomes already emit distinct log messages, but carry no structured outcome field and increment no metrics counters at all.

This is an observability gap, not a correctness bug — the revert path is already handled gracefully (drop_pending_if_finalized drops or re-stamps the pending entry, see payment_settlement.rs:2064). The problem is purely that settlement health is invisible to metric-based alerting.

Where

try_settle — crates/node/src/payment_settlement.rs:2016. Three outcomes, distinct warn!/info! messages, zero metrics:

Outcome Line Current signal
Transient — settleChannel().send() errored (RPC timeout / network) 2024 warn! "send failed; will retry next sweep"
Transient — get_receipt() errored 2031 warn! "receipt failed; will retry next sweep"
Permanent — receipt.status() == false (on-chain revert, e.g. ChannelNotClosing / already finalized) 2046 warn! "reverted; checking whether it was already finalized"
Success 2036 info! "settled channel"

Gaps

  • No metric for the settleChannel finalization sweep — any outcome. The existing settlement counters settlement_auto_triggered / settlement_auto_failures (metrics.rs:292) cover only the closeChannel auto-trigger path — a different lifecycle stage. The finalization sweep (settleChannel) has no counter for success, transient failure, or revert. An operator alerting on metrics is blind to whether settlement is actually landing.
  • Transient vs permanent is metric-indistinguishable. Even once a counter exists, the two transient paths (send / receipt) and the permanent on-chain revert need separate counts (or a labeled outcome) so operators can tell "RPC is flaky, will self-heal" from "settlement is permanently reverting and the pending obligation is stuck".
  • Logs carry no structured outcome field. The three sites differ only by message string, so triage relies on substring matching. Add an outcome = "transient_send" | "transient_receipt" | "reverted" | "ok" field to make log-based filtering/alerting reliable.
  • (Related, separate path) redemption_failures is a single lumped counter. metrics.rs:276 collapses getChannel/withdraw RPC errors and receipt failures into one count — the same transient/permanent blindness on the redemption side. [your call] whether to split it here or leave out of scope; the finalization sweep is the primary gap.

Suggested fix

  • Add counters for the finalization sweep, split by outcome — e.g. decdn_settlement_finalize_total with an outcome label, or three counters (..._ok / ..._transient / ..._reverted) to match the existing flat _total convention. Wire them into the four arms of try_settle.
  • Add the outcome structured field to the existing warn!/info! sites in try_settle.
  • Optionally apply the same transient/permanent split to redemption_failures for parity (the redemption path has the identical limitation).

Notes

Activity

  1. added
    kind:feature
    rust
    prio:low
    on Jun 4, 2026
  2. github-actions commented on Jun 4, 2026

    @github-actions

    🎯 Triage report

    Observability gap in crates/node/src/payment_settlement.rs: the try_settle function (settleChannel finalization sweep) emits distinct log messages for four outcomes but increments no metrics counters, making settlement health invisible to alerting. The existing settlement_auto_triggered/settlement_auto_failures counters cover only the closeChannel auto-trigger phase, leaving the entire finalization sweep unmonitored. Correctness is not affected — the fix is purely additive instrumentation.

    📊 Assessment

    Dimension Value Reasoning
    Type Task Pure observability addition; no correctness change
    Labels enhancement, technical, rust, low (already applied) Accurate; low priority appropriate for a non-blocking observability gap
    Coding agent Suitable Scope is fully defined: specific file/lines, specific counter names suggested, clear success criteria (four arms of try_settle each emit a counter + structured outcome field)

    🔗 Similar issues

    💡 Notes and suggestions

    Implementation checklist:

    • Add decdn_settlement_finalize_total counter with outcome label (ok / transient_send / transient_receipt / reverted) to crates/node/src/metrics.rs — or use three flat counters (_ok_total, _transient_total, _reverted_total) if the codebase convention prefers flat names (check existing settlement_auto_* convention at metrics.rs:292)
    • Wire counter increments into the four arms of try_settle at payment_settlement.rs:2016–2046
    • Add outcome = "transient_send" | "transient_receipt" | "reverted" | "ok" structured field to the four existing warn!/info! log sites in try_settle
    • Register the new metric in adr/appendix-observability.md (canonical metric registry — see how Observability: surface ChainStakerSet watcher drift via a metric (not just a warn! log) #783 was handled for the decdn_staker_set_* entries)
    • Optional (flagged as author's call): split redemption_failures (metrics.rs:276) into transient/permanent for parity

    Suggested alert rule (for operator docs):

    alert: SettlementFinalizingReverting
    expr: increase(decdn_settlement_finalize_total{outcome="reverted"}[1h]) > 0
    

    Key cross-references: payment_settlement.rs lines 2016–2064; metrics.rs lines 276 and 292; adr/appendix-observability.md.

    Generated by Agentic Triage for issue #810 · sonnet46 514.6K · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

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

Metadata

Metadata

Assignees

Labels

kind:featureprio:lowrust

Type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions