renepickhardt / pickhardtpayments

python package to showcase, test and build your own version of Pickhardt Payments
Apache License 2.0
42 stars 14 forks source link

Support LND channel graph format #22

Open VasanthManiVasi opened 2 years ago

VasanthManiVasi commented 2 years ago

This adds support for the ChannelGraph in lnd format.

It converts the lnd format to cln format and then loads the graph

VasanthManiVasi commented 2 years ago

Thanks a lot for the review and suggestions!

DescribeGraph.json in LND does not seem to provide channel flags and message flags. Should it be None or set to 0 (since they're bit flags)?

For features, since they're not provided along with the RoutingPolicy of each node in an LND channel edge, we have to search for the corresponding channel node(s) by pubkey in the "nodes" field of DescribeGraph.json (which can be potentially slow as we have to search nodes everytime for each channel direction that we are adding), and then reverse map the dict to feature bits following this: https://github.com/lightningnetwork/lnd/blob/master/lnwire/features.go Could you please share your thoughts about it?

renepickhardt commented 2 years ago

DescribeGraph.json in LND does not seem to provide channel flags and message flags. Should it be None or set to 0 (since they're bit flags)?

I think the python way of doing it would be None though I am pretty sure that the message flag are not of importance for us. Maybe we should just remove them from Channel? I just wrapped everything that I saw from cln without thinking. So I guess the best is to use None for now and maybe even deprecate this property.

For features, since they're not provided along with the RoutingPolicy of each node in an LND channel edge, we have to search for the corresponding channel node(s) by pubkey in the "nodes" field of DescribeGraph.json (which can be potentially slow as we have to search nodes everytime for each channel direction that we are adding), and then reverse map the dict to feature bits following this: https://github.com/lightningnetwork/lnd/blob/master/lnwire/features.go

yeah I think we could just parse the nodes from describe graph and get the features of the nodes and do it the way that you suggested. I think runtime of the import is not a concern (unless we get really slow) as that should hopefully happen only once.

VasanthManiVasi commented 2 years ago

Yup, I think it would be better to remove channel fields that are not needed for us.. I could be wrong but I think message flags, channel flags and features might not contribute much information for pickhardt payments, so can they be safely removed from ChannelFields?

renepickhardt commented 2 years ago

let us keep the features. When we upgrade channels to PTLCs we might be in a situation that we can only send the payment via legacy channels or PTLC channels. While it is not clear how we upgrade I would assume a feature bit will be set so Ican forsee why this will be useful in the futre. but we can remove messages I think

VasanthManiVasi commented 2 years ago

I've removed channel flags and added support for features, but it's very slow as it has to linearly search for nodes (to get their features) each time when adding channels. It took 162.63 seconds for a channel graph with 13536 nodes and 74496 channels. @renepickhardt

VasanthManiVasi commented 2 years ago

Woops, forgot about that.. Thanks!

renepickhardt commented 2 years ago

LGTM. Thank you very much! Need to run / test code. Not sure if I will be able to merge this week.

If anyone else wants to do a review that will be great!