Skip to content

Lazy trampoline#10544

Open
ecdsa wants to merge 4 commits intomasterfrom
lazy_trampoline
Open

Lazy trampoline#10544
ecdsa wants to merge 4 commits intomasterfrom
lazy_trampoline

Conversation

@ecdsa
Copy link
Copy Markdown
Member

@ecdsa ecdsa commented Mar 24, 2026

This pull request allows a trampoline node to forward payments without having a channel_db, if it has direct channels to other trampoline nodes.

If we (the trampoline forwarder) receive a trampoline onion and we do not have a direct connection to the next trampoline, we will return an unknown_next_peer error, with a list of trampolines we have a channel with in the error data. The client will use that list to create a longer trampoline route.

Note that trampolines are written in the data field of the unknown_next_peer message. (we could use custom TLV fields instead, but that would only works if the route from the client to the trampoline is of length 1, so I think it is better not to).

Comment thread electrum/lnworker.py Outdated
Comment thread electrum/lnworker.py Outdated
Comment thread electrum/trampoline.py Outdated
Comment thread electrum/lnworker.py Outdated
Comment thread electrum/trampoline.py Outdated
Comment thread electrum/trampoline.py
Comment thread electrum/lnworker.py Outdated
Comment thread electrum/lnworker.py Outdated
Comment thread electrum/trampoline.py
_allocate_fee_along_route(route, budget=budget, trampoline_fee_level=trampoline_fee_level)

# check that we can pay amount and fees
if not is_route_within_budget(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the maximum trampoline fee level _allocate_fee_along_route will allocate the whole budget on all edges with placeholder fees.
If an additional next_trampoline gets added, the sum of the allocated fees will exceed the budget, so is_route_within_budget will fail.
You could deduct the next_trampoline fee from the budget so that the following _allocate_fee_along_route will only allocate the remaining budget to the remaining edges.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean. The budget is passed to _allocate_fee_along_route, so I do not think the sum of allocated fees could exceed the budget. Or am I missing something?

Anyway, that would be a pre-existing issue.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, I see what you mean: the first edge does not have a placeholder fee, and _allocate_fee_along_route does not deduct that from its budget.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the newly added next_trampoline here:

        if next_trampolines and next_trampoline not in invoice_trampolines:
            next_trampoline = _choose_next_trampoline(next_trampoline, next_trampolines_ids, failed_routes)
            _extend_trampoline_route(route, end_node=next_trampoline, fee_info=next_trampolines[next_trampoline])

does already allocate fees for itself from fee_info=next_trampolines[next_trampoline].

Then _allocate_fee_along_route following below will split the whole PaymentFeeBudget between the edges with PLACEHOLDER_FEE on MAX_LEVEL trampoline fees.

So after that the actual allocated fees are budget + next_trampolione fee which exceeds the budget in is_route_within_budget.

So _allocate_fee_along_route should probably consider the fees that have already been allocated before and then only allocate the remaining budget to the edges with placeholder to ensure the whole budget is not exceeded(?)

@ecdsa ecdsa force-pushed the lazy_trampoline branch 12 times, most recently from 357794b to cc6c61a Compare April 4, 2026 14:20
ecdsa added 3 commits April 21, 2026 09:46
If a trampoline forwarder fails to find a path, it may return a list
of trampolines it knows how to reach, so that clients can add these
trampolines to their route.

The list of trampolines and fees is written in the error data of
the 'update_fail_htlc' message.
@ecdsa ecdsa force-pushed the lazy_trampoline branch 3 times, most recently from 8a0a3aa to 73fab0f Compare April 22, 2026 13:21
@ecdsa ecdsa force-pushed the lazy_trampoline branch from 73fab0f to 5628cfb Compare April 22, 2026 13:23
f321x added a commit to f321x/electrum-fork that referenced this pull request Apr 23, 2026
Consider known feerates for route edges when allocating the feerate
along the route by calculating the fees backwards from the destination.

Based on spesmilo#10544
Comment thread electrum/trampoline.py
if next_trampolines and next_trampoline not in invoice_trampolines:
next_trampoline = _choose_next_trampoline(next_trampoline, next_trampolines_ids, failed_routes)
_extend_trampoline_route(route, end_node=next_trampoline, fee_info=next_trampolines[next_trampoline])
# compute first_edge_fee (this is overshooting)
Copy link
Copy Markdown
Member

@f321x f321x Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the same required for the legacy trampoline branch above, e.g. if we have
A ---(free)--> B (my_trampoline) --(next trampoline edge fee)--> C (next Trampoline) --(placeholder fee)--> D (invoice_pubkey) ?

f321x added a commit to f321x/electrum-fork that referenced this pull request Apr 23, 2026
Consider known feerates for route edges when allocating the feerate
along the route by calculating the fees backwards from the destination.

Based on spesmilo#10544
f321x added a commit to f321x/electrum-fork that referenced this pull request Apr 23, 2026
Consider known feerates for route edges when allocating the feerate
along the route by calculating the fees backwards from the destination.

Based on spesmilo#10544
f321x added a commit to f321x/electrum-fork that referenced this pull request Apr 23, 2026
Consider known feerates for route edges when allocating the feerate
along the route by calculating the fees backwards from the destination.

Based on spesmilo#10544
f321x added a commit to f321x/electrum-fork that referenced this pull request Apr 23, 2026
Consider known feerates for route edges when allocating the feerate
along the route by calculating the fees backwards from the destination.

Based on spesmilo#10544
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.

2 participants