feat: add scorer-kit#20
Draft
ovitrif wants to merge 7 commits into
Draft
Conversation
4 tasks
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.
Context
This PR moves the offline scorer-file tooling previously introduced via synonymdev/ldk-node#79 into the scorer repo as
scorer-kitand extends it for local/operator workflows around serialized LDKChannelLiquiditiesfiles.The tool can inspect scorer binaries, decode them to JSON, compare two snapshots, validate bytes, derive selected-channel allowlists, and write new scorer binaries. It uses the scorer diagnostics/merge/filter API from the stacked rust-lightning PR synonymdev/rust-lightning#3 via an aliased dependency, so the existing scorer node/prober dependency graph remains on its current LDK crate set.
What Changed
src/bin/scorer-kit.rswithinspect,decode,compare,merge,node-scids, andvalidatesubcommands.merge:richer-history,prefer-first,prefer-last,combine, andnewer.--overlay-scid/--overlay-scids-file: the first input remains the baseline, later inputs are filtered to explicitly listed short-channel-ids before merge policy is applied.node-scidsfor deriving an overlay SCID allowlist from a serialized LDKNetworkGraph, one or more node pubkeys, and an optional incoming scorer-file intersection.node-scids --invoice <bolt11>to recover the target pubkey from an invoice when a direct node pubkey is not already available.data/scores/with sanitizedsource-z/source-blabels.data/scores/merged.binas the selected overlay scorer candidate, plusmerged.decoded.jsonandmerged.report.json.scorer-kitflows in the README.Current Sample Result
Using the current two source samples, the broad
richer-historymerge produced a 16,609-entry scorer file. The audit report recorded 1,184 duplicate short-channel-id decisions: 389 kept from the existing input, 795 replaced by the incoming input, and 0 combined.That broad merge remains useful for analysis, but the safer production-style workflow is now the selected overlay path: start with
source-zas the baseline, passsource-bas the incoming overlay, use--policy prefer-last, and provide an explicit SCID allowlist with--overlay-scids-file.The tracked selected overlay candidate uses a 20-SCID allowlist, reduced the incoming file to 5 score entries before merge, replaced 3 overlapping entries, preserved the rest of the baseline, and added 2 unique incoming entries. The serialized candidate is committed as
data/scores/merged.bin, withmerged.decoded.jsonandmerged.report.jsonalongside it.Notes
Scorer binaries are keyed by short-channel-id and do not contain node pubkeys. Node-level selection therefore needs a serialized LDK network graph, an invoice payee, or another external channel map to produce the SCID allowlist before running
scorer-kit merge.Test Plan
cargo check --bin scorer-kitcargo test --bin scorer-kit(8 scorer-kit unit tests)cargo testscorer-kit node-scids --helpscorer-kit validate data/scores/merged.binscorer-kit validate <source-z.bin> <source-b.bin>scorer-kit inspect <source-z.bin> --label source-z --top 5scorer-kit inspect <source-b.bin> --label source-b --top 5scorer-kit compare <source-z.bin> <source-b.bin> --left-label source-z --right-label source-bscorer-kit merge <source-z.bin> <source-b.bin> --label source-z --label source-b --output target/scorer-kit/merged.bin --report data/scores/merged-richer-history.report.json --policy richer-historyscorer-kit merge <source-z.bin> <source-b.bin> --label source-z --label source-b --policy prefer-last --overlay-scid <unique-scid> --output target/scorer-kit/merged-one-overlay.bin --report target/scorer-kit/merged-one-overlay.report.jsonscorer-kit merge <source-z.bin> <source-b.bin> --label source-z --label source-b --policy prefer-last --overlay-scid <overlapping-scid> --output target/scorer-kit/merged-one-overlap.bin --report target/scorer-kit/merged-one-overlap.report.jsonscorer-kit merge <source-z.bin> <source-b.bin> --label source-z --label source-b --policy prefer-last --overlay-scids-file <20-scid-allowlist> --output target/scorer-kit/selected-node.bin --report target/scorer-kit/selected-node.report.json