Skip to content

Conversation

@thomash-acinq
Copy link
Contributor

Same as #2071 but do not use the balance estimates for anything.

@pm47
Copy link
Member

pm47 commented May 10, 2022

A general observation, I think we should better separate two things:

  • the routing table management:
    • validation of public channels
    • sync queries
    • network graph construction
  • the network graph:
    • route calculation
    • metadata from past payments (topic of this PR)

Those are already two separate objects (Router.Data and DirectedGraph) but I feel like we should do more. Not sure how!

@thomash-acinq thomash-acinq force-pushed the balance-estimate-only branch from 95d1aa4 to 283c64d Compare May 11, 2022 12:15
@thomash-acinq thomash-acinq force-pushed the balance-estimate-only branch from 283c64d to d107c5b Compare May 11, 2022 14:00
@thomash-acinq thomash-acinq marked this pull request as ready for review May 11, 2022 14:38
@thomash-acinq thomash-acinq requested a review from t-bast May 11, 2022 14:38
@thomash-acinq
Copy link
Contributor Author

Those are already two separate objects (Router.Data and DirectedGraph) but I feel like we should do more. Not sure how!

Now there is a third one: BalancesEstimates

@t-bast This only records some metrics but the estimates are not use anywhere.

- Add a bit more documentation
- Small code cleanup / refactor
@t-bast t-bast mentioned this pull request May 12, 2022
Copy link
Member

@t-bast t-bast left a comment

Choose a reason for hiding this comment

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

This isn't an easy PR to review! I've spent some time playing around with the code, and did a few refactoring and clean-up in #2266 without changing any business logic.

I have one main fundamental comment about how we handle multiple channels, and a few questions on some of the formulas, but otherwise it looks mostly good to me, this is good work!

sender.send(paymentFSM, addCompleted(HtlcResult.RemoteFail(UpdateFailHtlc(ByteVector32.Zeroes, 0, Sphinx.FailurePacket.create(sharedSecrets1.head._1, failure)))))

// payment lifecycle will ask the router to temporarily exclude this channel from its route calculations
routerForwarder.expectMsgType[ChannelCouldNotRelay]
Copy link
Member

Choose a reason for hiding this comment

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

We need more tests to verify that the payment lifecycle correctly sends all balance-related events to the router.

}
}

def addChannel(capacity: Satoshi): BalanceEstimate = copy(high = high + toMilliSatoshi(capacity), totalCapacity = totalCapacity + capacity)
Copy link
Member

Choose a reason for hiding this comment

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

I'm still making the same comment I initially made on the first iteration of this feature: I think it really doesn't make sense to add channel capacities, I believe we should take the max of the channel capacities instead (which means we need to keep a list of channel capacities to correctly handle removing channels).

If nodes have more than a few channels between them, the high bound will be completely unreasonable and the decay will tend to restore it way too quickly to an impossible amount (since the balance estimates will be used in the context of a single HTLC, not for the whole flow of a payment).

Also, you're not even using it consistently: BalanceEstimates.addChannel doesn't add the capacities whereas other functions do...which shows we probably need more unit tests 😉

What about having the balance estimate contain a capacities: Seq[MilliSatoshi]? This also lets us know how many channels exist between these peers, which may help us choose to use this pair of nodes for more than one HTLC when using MPP.

@thomash-acinq
Copy link
Contributor Author

replaced by #2272

@t-bast t-bast deleted the balance-estimate-only branch November 15, 2022 13:30
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.

4 participants