Skip to content

probing: add a ProbeObserver hook for individual probe outcomes - #7

Open
kaloudis wants to merge 1 commit into
probing-servicefrom
probe-event-observer
Open

kaloudis wants to merge 1 commit into
probing-servicefrom
probe-event-observer

Conversation

@kaloudis

Copy link
Copy Markdown

Part 1 of 3 for ZeusLN/mytikas#130. Targets probing-service, not main.

Why

LDK folds every probe result into the scorer's decayed liquidity bounds and
throws the individual event away. By the time anything downstream reads
ChannelLiquidities, each probe's path, timing, amount and failing hop have
been collapsed into one (min, max) interval per channel direction and are
unrecoverable. Today handle_background_probe_successful / _failed do
nothing but log_debug!.

What

An opt-in sink, unset by default:

  • ProbeOutcome — payment id, status, destination, path pubkeys and scids,
    delivered amount, routing fee.
  • ProbeStatusSucceeded, or Failed { failing_scid } when LDK attributed
    one. It often cannot, and when it can the scid may be an SCID alias rather
    than a public-graph scid, so the docs tell consumers to tolerate a miss.
  • ProbeObserver — one callback, documented as must not block: it runs
    inline on the event-handling path.
  • ProbingConfigBuilder::probe_observer registers it.

The ProbeFailed arm in event.rs now destructures short_channel_id, which
it previously discarded. Both handlers already fire for probes sent via
send_probes as well as background ones, so targeted probing is covered by the
same hook with no extra wiring.

ProbingConfig loses its derived Debug (Arc<dyn ProbeObserver> cannot
derive one) and gains a hand-written impl, mirroring how
ProbingStrategyKind::Custom is already handled.

Note on what is not here

There is no failure-reason field, because LDK's ProbeFailed does not carry
one at this revision: { payment_id, payment_hash, path, short_channel_id }.
Anything wanting PaymentFailureReason on a probe needs an upstream change
first.

Testing

Five unit tests over the path-to-outcome mapping, including the two edge cases
that would otherwise panic or mislead: an empty path yields nothing rather than
indexing hops.last(), and a single-hop path reports the full amount with a
zero routing fee (LDK stores the delivered value in the last hop's
fee_msat, so the naive sum is wrong).

  • cargo test --lib: 46 passed, including the 5 new ones.
  • cargo check --lib clean with and without --features uniffi.
  • cargo doc --no-deps clean (intra-doc links resolve).
  • cargo fmt --check: the three files touched here are clean. The tree has
    pre-existing diffs in chain/mod.rs, lib.rs and wallet/mod.rs that this
    branch does not touch, so the new code was hand-matched rather than running
    a formatter over the tree.

LDK folds every probe result into the scorer's decayed liquidity bounds and
throws the individual event away. By the time anything downstream reads
ChannelLiquidities, each probe's path, timing, amount and failing hop have
been collapsed into one (min, max) interval per channel direction and are
unrecoverable.

Add an opt-in sink so a consumer can retain them:

- ProbeOutcome: payment id, status, destination, path pubkeys and scids,
  delivered amount, routing fee.
- ProbeStatus: Succeeded, or Failed with the failing scid when LDK attributed
  one (it often cannot, and the scid may be an alias rather than a public-graph
  scid, so consumers must tolerate a miss).
- ProbeObserver: one callback, documented as must-not-block because it runs
  inline on the event-handling path.
- ProbingConfigBuilder::probe_observer registers it; unset means today's
  behavior exactly.

The ProbeFailed arm in event.rs now destructures short_channel_id, which it
previously discarded, and handle_background_probe_failed takes it through. Both
handlers already fire for probes sent via send_probes as well as background
ones, so targeted probing is covered by the same hook.

ProbingConfig loses its derived Debug (Arc<dyn ProbeObserver> cannot derive
one) and gains a hand-written impl, mirroring how ProbingStrategyKind::Custom
is already handled.

Five unit tests cover the path-to-outcome mapping, including the two edge
cases that would otherwise panic or mislead: an empty path yields nothing, and
a single-hop path reports the full amount with a zero routing fee.
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.

1 participant