Skip to content

Lazy trampoline#10544

Open
ecdsa wants to merge 3 commits intomasterfrom
lazy_trampoline
Open

Lazy trampoline#10544
ecdsa wants to merge 3 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 9 times, most recently from 539aedc to 6759312 Compare April 4, 2026 12:42
@ecdsa ecdsa force-pushed the lazy_trampoline branch 2 times, most recently from 19ac4cd to 357794b Compare April 4, 2026 14:06
ecdsa added 2 commits April 4, 2026 16:20
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 from 357794b to cc6c61a Compare April 4, 2026 14:20
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