feat(scoring): add public diagnostics for ChannelLiquidities#2
Draft
feat(scoring): add public diagnostics for ChannelLiquidities#2
Conversation
Adds a read-only diagnostic surface so external tools can inspect the contents of a serialized ProbabilisticScorer / ChannelLiquidities file without needing access to the private liquidity_history internals. ChannelLiquidities exposes one ChannelLiquidityDiagnostic per stored SCID, sorted for deterministic output. Each diagnostic surfaces the non-directional liquidity offsets, last-updated timestamps, and the raw 32-bucket weight arrays from HistoricalLiquidityTracker plus its total_valid_points_tracked summary - the LDK-internal scalar that weighs the historical bucket distribution. Directional resolution is deliberately not part of this surface, since it requires a NetworkGraph for capacity and node-id ordering. ProbabilisticScorer::diagnostics() delegates to ChannelLiquidities and exists as a convenience for callers that hold a live scorer instance. The accompanying test exercises both the populated and empty-history paths via a probe-style failure, and confirms that diagnostics survive a Writeable -> Readable round-trip on both ProbabilisticScorer and the served ChannelLiquidities wire format.
This was referenced Apr 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a public read-only diagnostic surface to
ChannelLiquiditiesandProbabilisticScorerso external tools can inspect serialized scorer files without needing access to the privateliquidity_historyinternals.Depends on:
scorer-inspectCLI that consumes these accessorsexportPathfindingScores()to produce the bytes the inspector readsSummary
pub struct ChannelLiquidityDiagnosticexposing per-SCID liquidity offsets, last-updated timestamps, and the raw 32-bucket weight arrays fromHistoricalLiquidityTrackerplus itstotal_valid_points_trackedsummary.ChannelLiquidities::diagnostics()andProbabilisticScorer::diagnostics()returningVec<ChannelLiquidityDiagnostic>, sorted by SCID for deterministic output.pub(super)accessors (HistoricalBucketRangeTracker::buckets,HistoricalLiquidityTracker::total_valid_points_tracked) so the diagnostic function can read bucket state without exposing the internal types.Directional resolution (turning the non-directional offsets into per-direction sat values) is intentionally left out of this surface — that requires a
NetworkGraphfor capacity and node-id ordering and is best done by the consumer.The motivation is a separate
scorer-inspectCLI (linked above) that reads.binfiles served at URLs likescores.zeusln.com/latest.binor produced locally byNode::export_pathfinding_scores, and emits text/CSV/JSON diagnostics. With these accessors that consumer can be a thin shim instead of duplicating internal types.Test plan
diagnostics_distinguishes_history_populated_from_emptybuilds a scorer with one probe-driven entry and one empty entry, callsdiagnostics()on bothChannelLiquiditiesandProbabilisticScorer, and verifies the populated/empty distinction is preserved through aWriteable -> Readableround-trip on both wire shapes.cargo test -p lightning --lib routing::scoring— all 33 scoring tests pass.🤖 Generated with Claude Code