Skip to content

payment retries on simulated network - #320

Open
elnosh wants to merge 5 commits into
bitcoin-dev-project:mainfrom
elnosh:retries
Open

elnosh wants to merge 5 commits into
bitcoin-dev-project:mainfrom
elnosh:retries

Conversation

@elnosh

@elnosh elnosh commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

This adds a payment retries when running in a simulated network. It just sets it to at max try 5.

Note that there was a bug in the reporting to the scorer. While re-working the outcomes to also report the channels where a route failed, (claude) noticed that this was reporting the failure to the scorer with just an index casted as a u64 where LDK is expecting a scid. This is fixed in 85b213d

The retries approach just takes the channel at which the payment failed and passes it to LDK to ignore when calculating the route for the next retry

elnosh and others added 5 commits September 16, 2026 14:08
A failed payment was only reported as the index of the last hop that
its htlc was added on, which does not identify the channel that
rejected it. Report that channel so that the sending node can act on
it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The scorer call in `track_payment` passed the index of the hop that a
htlc failed on where LDK expects the failed channel's short channel
id. It never matched a channel on the path, so LDK scored every hop of
a failed path as having sufficient liquidity. Give the scorer the
channel that the network blamed for the failure instead.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A payment whose htlc was rejected while being added along its route
reported a `htlc_count` of zero, even though a htlc had been
dispatched for it. Count it, as lnd does, so that the column reports
what the payment attempted rather than only what succeeded.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`track_payment` both waited on the shutdown listener and resolved the
payment's outcome in one `select!` arm. Resolving a payment is about
to become a loop, so give it its own function and leave
`track_payment` to race it against shutdown.

No behaviour change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A simulated node reported a payment as failed as soon as its htlc was
rejected, where real nodes re-route it and try again. Resolving a
payment is now a loop. When the network blames a channel for rejecting
the htlc, that channel is added to `previously_failed_channels` and the
payment is re-routed and dispatched again under the same hash, up to
`MAX_RETRIES` (5).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@elnosh

elnosh commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator Author

needed a rebase after #319

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