Skip to content

feat(node): meter the settlement re-anchor path - #2751

Merged
thiras merged 1 commit into
mainfrom
feat/2710-reanchor-metrics
Oct 29, 2026
Merged

thiras merged 1 commit into
mainfrom
feat/2710-reanchor-metrics

Conversation

@thiras

@thiras thiras commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

What

The end-of-tick re-anchor that #2709 added reported its outcomes only in logs. PoolProjection::reanchor skipped a stale read with no signal at all, so an operator could not see a pool stuck pending: an open that a reorg dropped, a reorg that lowered totalRedeemed or the deposit, or a read that keeps failing.

  • PoolProjection::reanchor returns a ReanchorReport: the number of reads that anchored their pool, and each skipped read with its ReanchorStale reason (BelowFolded, LowerRedeemed, LowerDeposit, checked in that order).
  • reanchor_pools takes &Metrics. Following the sibling-counter convention, it counts:
    • decdn_settlement_reanchor_pending_pools, a gauge set at the end of every tick, 0 included, so it falls back;
    • …_block_read_failures_total and …_behind_watcher_total (the tick reads no pool);
    • …_pool_read_failures_total and …_absent_total;
    • …_skipped_{below_folded,lower_redeemed,lower_deposit}_total, each with a warn! that names the pool, the held value and the read value;
    • …_anchored_total, the denominator.
  • PoolProjection::update takes FnMut, so reanchor can collect its report. rcu may retry the closure, so the report resets at the start of each run.
  • Rows in adr/appendix-observability.md (live), field docs in metrics.rs, and a CHANGELOG entry.

Closes #2710

Reviewer notes

  • Read ReanchorReport / reanchor in pool_view.rs, then reanchor_pools and count_reanchor_skip in payment_settlement.rs.
  • The anchored count comes from the projection, not from reads.len() - skipped.len(). A read for a pool that left the projection mid-tick, or that was folded from its PoolOpened, counts as neither.
  • Out of scope: forgetting a seed whose pool stays absent above its seed block. That changes behavior, not just telemetry, and is filed as node: forget a re-anchor seed whose pool stays absent above the seed block #2750.
  • decdn/devops: the panel for the pending gauge and the skip and failure rates, plus an alert when decdn_settlement_reanchor_pending_pools stays above 0 for more than a few rotations, follow once this merges.

Verification

  • Commit hooks (fmt, clippy, doc, markdownlint, ADR hygiene; cargo deny reports the existing RUSTSEC-2026-0387 advisory, warn-only, already on main)
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo nextest run --workspace: 6158 passed (includes adr_registry_names_are_exported)
  • CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items
  • adr/: make -C adr check-refs
  • A metric name: rows in adr/appendix-observability.md; devops dashboards to follow (see above)
  • CHANGELOG.md entry
  • Mutation check: with the absent increment removed, reanchor_pools_keeps_a_pool_absent_at_the_pinned_block fails.

🤖 Generated with Claude Code

The end-of-tick re-anchor reported its outcomes only in logs, and
PoolProjection::reanchor skipped a stale read with no signal at all, so a
pool stuck pending (a reorg-dropped open, a reorg that lowered
totalRedeemed or the deposit, a persistent read fault) was invisible.

reanchor now returns a ReanchorReport: the anchored count and each skipped
read with its reason. reanchor_pools sets a pending-pools gauge every tick
and counts block-read faults, behind-watcher blocks, getPool faults, absent
pools, the three stale-skip reasons (each with a warn! naming the pool and
both values) and anchors, one sibling counter per reason.

Closes #2710

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 29, 2026 03:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are identified for the settlement re-anchor observability changes.

No open issues 🎉

What changed in this PR

Adds observability to the node’s settlement re-anchor path, following #2709, so operators can detect pools that remain pending without changing settlement behavior.

Changes:

  • Returns successful anchor counts and explicit stale-read reasons from PoolProjection::reanchor, resetting the report on retries.
  • Records pending pools, read failures, skipped reads, and successful anchors, with warnings for stale reads.
  • Extends metric assertions and documents the exported series. Dashboards and absent-pool retirement remain separate follow-ups.
File Description
crates/​node/​src/​pool_view/​tests.rs Checks anchor reports and stale-read reasons.
crates/​node/​src/​pool_view.rs Adds structured re-anchor reports and retry-safe collection.
crates/​node/​src/​payment_settlement/​tests.rs Verifies counters and pending-pool gauge values across outcomes.
crates/​node/​src/​payment_settlement.rs Records re-anchor metrics and logs stale-read details.
crates/​node/​src/​metrics.rs Defines and documents the gauge, counters, and recording methods.
CHANGELOG.md Announces settlement re-anchor telemetry.
adr/​appendix-observability.md Registers the new metrics as live and describes their meaning.

Review effort: Balanced

@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main 8473f6e feat/2710-reanchor-m... 4a1d3b0 +/-
77% 77% 0%
View coverage of the 4 most impacted files.
File main 8473f6e feat/2710-reanchor-m... 4a1d3b0 +/-
crates/node/src...nt/serve_leg.rs 91% 90% -1%
crates/protocol/src/framing.rs 93% 92% -1%
crates/node/src...t_settlement.rs 78% 79% +1%
crates/node/src/pool_view.rs 95% 96% +1%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

@thiras
thiras merged commit bb0bfd1 into main Oct 29, 2026
38 checks passed
@thiras
thiras deleted the feat/2710-reanchor-metrics branch October 29, 2026 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

node: meter the settlement re-anchor path (pending pools, skipped and faulted re-reads)

2 participants