Skip to content

Commit 25a3a00

Browse files
authored
Merge pull request #187 from synonymdev/mainnet-probe-amount-profiles
Add mainnet probe amount profiles
2 parents c721347 + 272d94f commit 25a3a00

3 files changed

Lines changed: 27 additions & 4 deletions

File tree

docs/mainnet-probe.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ It is orchestrated nightly by the private `bitkit-nightly` repo (`mainnet-probe.
1717

1818
| Variable | Default | Description |
1919
| --- | --- | --- |
20+
| `PROBE_AMOUNT_PROFILE` | `full` | Default amount set for targets that do not define `amountMsat` or `amountsMsat`: `small`, `large`, `cover`, or `full`. |
2021
| `PROBE_ORDER` | `config` | Order of probes per target: `config` = amounts as listed in target config, `desc` = highest amount first (avoids small probes "warming up" scorer knowledge of the route), `random` = global shuffle of all target+amount pairs. |
2122
| `PROBE_RESET_SCORES` | `false` | When `true`, deletes the persisted pathfinding scores (`scorer` and `external_pathfinding_scores_cache` VSS keys) and restarts the node before probing, so every run starts from a fresh scorer (external scores are re-downloaded on startup). Recommended for scorer A/B experiments; the nightly job enables it by default. Accepts `true/false/1/0/yes/no`. |
2223
| `PROBE_RESET_SCORES_TIMEOUT_SECONDS` | `180` | Timeout for the scores reset devtools command (covers node stop + VSS deletes + node start). |

test/helpers/probe.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ const DEFAULT_READINESS_POLL_MS = 5_000;
5858
const DEFAULT_MIN_GRAPH_CHANNELS = 10_000;
5959
const DEFAULT_RESET_SCORES_TIMEOUT_SECONDS = 180;
6060
const DEFAULT_SCORES_SYNC_MAX_AGE_S = 900;
61+
const DEFAULT_PROBE_AMOUNT_PROFILE = 'full';
62+
const PROBE_AMOUNT_PROFILES = {
63+
small: [1_000_000],
64+
large: [80_000_000],
65+
cover: [1_000_000, 25_000_000, 80_000_000],
66+
full: [1_000_000, 10_000_000, 25_000_000, 50_000_000, 80_000_000],
67+
} as const;
68+
type ProbeAmountProfile = keyof typeof PROBE_AMOUNT_PROFILES;
6169

6270
export type ProbeReadiness = {
6371
ready: boolean;
@@ -102,6 +110,16 @@ export function resolveProbeOrder(): ProbeOrder {
102110
throw new Error(`Invalid PROBE_ORDER value: ${raw} (expected desc, random or config)`);
103111
}
104112

113+
export function resolveProbeAmountProfile(): ProbeAmountProfile {
114+
const profile = process.env.PROBE_AMOUNT_PROFILE ?? DEFAULT_PROBE_AMOUNT_PROFILE;
115+
if (profile === 'small' || profile === 'large' || profile === 'cover' || profile === 'full') {
116+
return profile;
117+
}
118+
throw new Error(
119+
`Invalid PROBE_AMOUNT_PROFILE: ${profile}. Expected 'small', 'large', 'cover', or 'full'.`
120+
);
121+
}
122+
105123
export function buildProbeQueue(targets: ProbeTarget[], order: ProbeOrder): ProbeQueueEntry[] {
106124
const queue = targets.flatMap((target) => {
107125
const amounts = expandProbeTargetAmounts(target);
@@ -127,10 +145,11 @@ function shuffleInPlace<T>(items: T[]): T[] {
127145
}
128146

129147
export function expandProbeTargetAmounts(target: ProbeTarget): number[] {
130-
const amounts = target.amountsMsat ?? (target.amountMsat ? [target.amountMsat] : []);
131-
if (amounts.length === 0) {
132-
throw new Error(`Probe target '${target.name}' must define amountMsat or amountsMsat`);
133-
}
148+
const amounts =
149+
target.amountsMsat ??
150+
(target.amountMsat
151+
? [target.amountMsat]
152+
: [...PROBE_AMOUNT_PROFILES[resolveProbeAmountProfile()]]);
134153

135154
return amounts.map((amountMsat) => {
136155
if (!Number.isInteger(amountMsat) || amountMsat <= 0) {

test/specs/mainnet/probe.e2e.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
parseNonNegativeIntEnv,
77
parseProbeCommandSuccess,
88
probeModeForTargetType,
9+
resolveProbeAmountProfile,
910
resetPathfindingScores,
1011
resolveProbeOrder,
1112
resolveProbeResetScores,
@@ -234,6 +235,8 @@ describe('@probe_mainnet - Lightning probe smoke', () => {
234235
const probes = buildProbeQueue(targets, probeOrder);
235236
const probeDelayMs = resolveProbeDelayMs();
236237
const probeRetries = resolveProbeRetries();
238+
console.info(`→ [Probe] Probe amount profile configured: ${resolveProbeAmountProfile()}`);
239+
console.info(`→ [Probe] Probe order configured: ${resolveProbeOrder()}`);
237240
console.info(`→ [Probe] Probe retries configured: ${probeRetries}`);
238241
console.info(
239242
`→ [Probe] Probe order '${probeOrder}': ${probes

0 commit comments

Comments
 (0)