-
Notifications
You must be signed in to change notification settings - Fork 14
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
Support LND channel graph format #22
base: main
Are you sure you want to change the base?
Support LND channel graph format #22
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks very good! besides the missing fields I have only a few stylistic suggestions and tiny questions.
I also very much like how you made it backwards compatible. I was initially thinking of having also a LNDCHannel Base class from which all the others derrive (and I did not like my idea which is why I didn't support lnd yet). but I think the way it is being done here is much more elegant!
Btw does anyone know if there is a checker available that something is the correct lnd or cln json format? If it was we could basically do the check before conversion but I guess that is really unneccesary as the JSON might very well change at some point in time
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 |
I think the python way of doing it would be
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. |
Yup, I think it would be better to remove channel fields that are not needed for us.. |
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 |
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can index nodes in a dict
and avoid linear pass through the list for every time that you want to fetch and element.
pickhardtpayments/ChannelGraph.py
Outdated
cln_channel[LND_CLN_POLICY_MAP[key]] = val | ||
|
||
def _find_node(pubkey, nodes_list): | ||
for node in nodes_list: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't you initially just load all nodes into a dict
with pubkey
as index and then just fetch them instead of going linearly through the list everytime you need it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 9c733e1
Woops, forgot about that.. Thanks! |
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! |
This adds support for the ChannelGraph in lnd format.
It converts the lnd format to cln format and then loads the graph