Skip to content

Commit 6ca9000

Browse files
committed
Expose background probing service
Allow operators to enable either built-in probing strategy through the config file, CLI arguments, or environment variables. Validate strategy settings and document the risk of probes locking outbound liquidity. AI assistance: OpenAI Codex was used to implement and verify this change.
1 parent c03b94f commit 6ca9000

4 files changed

Lines changed: 417 additions & 0 deletions

File tree

contrib/ldk-server-config.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,23 @@ alias = "ldk_server" # Lightning node alias
99
#rgs_server_url = "https://rapidsync.lightningdevkit.org/snapshot/v2/" # Optional: RGS URL for rapid gossip sync
1010
#async_payments_role = "client" # Optional async payments role: "client" or "server"
1111

12+
# Background probing service (optional)
13+
# CAUTION: Probes send real HTLCs and can lock outbound liquidity until they time out.
14+
# See docs/configuration.md for complete field descriptions.
15+
# Set only the field required by the selected strategy.
16+
# "high_degree" requires top_node_count. "random_walk" requires max_hops.
17+
#[probing]
18+
#strategy = "high_degree" # "high_degree" or "random_walk"
19+
#top_node_count = 100 # Required for "high_degree"
20+
# LDK Node clamps max_hops to the range 2 through 19.
21+
#max_hops = 5 # Required for "random_walk"
22+
#interval_secs = 10 # Time between probe attempts (default: 10 seconds)
23+
# Built-in probes use at least 1000000 msat before routing fees. Lower limits prevent all probes.
24+
#max_locked_msat = 100000000 # Maximum total in-flight probe liquidity (default: 100k sats)
25+
# This virtual scorer cost is not paid. It decreases to zero over 24 hours.
26+
#diversity_penalty_msat = 250 # Optional. Only affects "high_degree".
27+
#cooldown_secs = 3600 # Node re-probe cooldown for "high_degree" (default: 1 hour)
28+
1229
# Storage settings
1330
[storage.disk]
1431
dir_path = "/tmp/ldk-server/" # Path for LDK and BDK data persistence, optional, defaults to ~/Library/Application Support/ldk-server/ on macOS, ~/.ldk-server/ on Linux

docs/configuration.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,44 @@ this node to go offline. Set `async_payments_role = "server"` to hold async paym
5959
and onion messages for peers. The server role requires an announceable node configuration.
6060
Leave the field unset to disable async payments.
6161

62+
### `[probing]`
63+
64+
Enables LDK Node's background probing service to train the payment scorer with current
65+
channel-liquidity information. Probing is disabled when this section and the corresponding
66+
CLI/environment options are absent.
67+
68+
The `strategy` field selects one of two path-selection methods:
69+
70+
- **`"high_degree"`** probes toward highly connected public nodes. The service uses the
71+
payment scorer to select a path.
72+
- **`"random_walk"`** constructs random paths through the public graph. This strategy does
73+
not use the payment scorer to select a path.
74+
75+
The section accepts these fields:
76+
77+
| Field | Requirement and default | Description |
78+
| --- | --- | --- |
79+
| `strategy` | Required. | Selects `"high_degree"` or `"random_walk"`. |
80+
| `top_node_count` | Required for `"high_degree"`. | Sets the number of highly connected public nodes in the destination set. The strategy cycles through this set. The value must be greater than `0`. |
81+
| `max_hops` | Required for `"random_walk"`. | Sets the maximum number of hops in a random path. LDK Node clamps the value to the range `2` through `19`. |
82+
| `interval_secs` | Optional. The default is `10`. | Sets the number of seconds between probe attempts. LDK Node changes `0` to its minimum interval of 100 milliseconds. |
83+
| `max_locked_msat` | Optional. The default is `100000000` (100,000 satoshis). | Limits the total amount and pending fees of in-flight probes. The service skips a probe that exceeds the remaining limit. Built-in probes use 1,000,000 through 10,000,000 millisatoshis before routing fees. |
84+
| `diversity_penalty_msat` | Optional. The default is `0`. | Adds a virtual routing cost to recently probed channels. The service does not pay this amount. The cost decreases to zero over 24 hours and encourages different paths. This field only affects `"high_degree"`. |
85+
| `cooldown_secs` | Optional. The default is `3600`. | Sets the time before `"high_degree"` can select the same destination again. The strategy starts a new cycle immediately after it probes all destinations. |
86+
87+
```toml
88+
[probing]
89+
strategy = "high_degree"
90+
top_node_count = 100
91+
interval_secs = 30
92+
max_locked_msat = 100000000
93+
diversity_penalty_msat = 250
94+
cooldown_secs = 3600
95+
```
96+
97+
> **Caution:** Probes send real HTLCs over real channels. A probe can lock outbound liquidity
98+
> until its HTLC expires. Use `max_locked_msat` to limit this risk.
99+
62100
### `[storage.disk]`
63101

64102
Where persistent data is stored. Defaults to `~/.ldk-server/` on Linux and

ldk-server/src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ fn main() {
207207
builder.set_gossip_source_rgs(rgs_server_url);
208208
}
209209

210+
if let Some(probing_config) = config_file.probing_config {
211+
builder.set_probing_config(probing_config);
212+
}
213+
210214
if let Err(e) = builder.set_async_payments_role(config_file.async_payments_role) {
211215
error!("Failed to configure async payments role: {e}");
212216
std::process::exit(-1);

0 commit comments

Comments
 (0)