Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routing algorithm applies redundant routing fees per MPP shard #3675

Open
MaxFangX opened this issue Mar 18, 2025 · 1 comment
Open

Routing algorithm applies redundant routing fees per MPP shard #3675

MaxFangX opened this issue Mar 18, 2025 · 1 comment

Comments

@MaxFangX
Copy link
Contributor

MaxFangX commented Mar 18, 2025

For a single path, two-hop payment Sender -> LSP -> Receiver, define the max_sendable amount as

sum(next_outbound_htlc_limit) / (1 + lsp_prop_feerate)

We've have confirmed in our tests that if the LSP has 0 base fee, we are actually able to send precisely this amount.

Rearranging, the equality is

max_sendable * (1 + lsp_prop_feerate) = sum(next_outbound_htlc_limit) (summing over usable channels).

However, if the sender's payment is split across two Sender -> LSP channels, we aren't able to send max_sendable as it fails to find a route. We ran a binary search to find the highest payment amount, accurate to the satoshi, for which routing succeeds in this MPP configuration - let's call this result max_flow. We then get the following equality:

max_flow * (1 + 2 * lsp_prop_feerate) = sum(next_outbound_htlc_limit).

However, we expect max_flow = max_sendable. In other words, the routing algorithm appears to charge the LSP's feerate twice (according to max_flow), even though the Route it returns correctly charges the LSP proportional feerate only once for each Path. This can be further generalized - if a user's liquidity is routed over num_shards shards, the equality becomes:

max_flow * (1 + num_shards * lsp_prop_feerate) = sum(next_outbound_htlc_limit).

So the routing algorithm seems to somehow reapply the proportional fee rate once per shard even though it should only be applied once.

@tnull
Copy link
Contributor

tnull commented Mar 19, 2025

As mentioned on Discord: Yes, this is likely due to our routing algorithm internally first collecting candidates. As we keep track of the overall used liquidity in the first step (but not in detail), we might not be able to apply the "discount" for the follow-up parts that run over the same paths. We only later detect the overpayment and adjust the fees when we choose the best paths and recalculate fees. This might be a limitation of our multi-step approach, and one reason why exploring a 'true' flow-based algorithm could still make sense in the future IMO

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

No branches or pull requests

2 participants