LNP-WG / lnp-node

Lightning network protocol daemon (suitable for generalized Lightning Network)
MIT License
145 stars 40 forks source link

channel data inconsistency between peers #31

Closed St333p closed 3 years ago

St333p commented 3 years ago

Playing around with lnp-node, I noticed some inconsistencies between the view of the two peers over a channel they have in common.

My setting is composed of:

My goal was to perform a LN transfer for both btc and one rgb asset, with the following workflow:

  1. A listens for connections
  2. B initiates peer connection
  3. B proposes channel
  4. B funds channel (btc)
  5. B performs btc transfer
  6. B refills channel with rgb asset
  7. B performs rgb transfer

Here is a list of things that seem wrong to me:

After having a quick look at the code I think I can fix at least some of the listed problems. The last two will require some debugging and I'm not sure I'll be able to solve them.

Can please anyone confirm these are not expected behaviors before I spend time fixing them?

EDIT: I'm working on this and I managed to solve issues identified by the ticked box.

St333p commented 3 years ago

I figured that asset transfer fails because of endianess inconsistency between input and output data, so I'll update it in the issue description. In fact:

St333p commented 3 years ago

I'm stuggling a bit with the 7th point. From what i can see, remote_id is never set in src/bin/peerd.rs for the peer that receives the connection and in fact from the pov of A, a lnp-cli info <peer> returns an empty list for remote_id. However, it's still not clear to me how A gets to show its own nodeid in the list of peers, my best bet points at how id is assigned at line 203 in peerd.rs (b901fb0), since it contains local_node as nodeid. I have the feeling that at that point in the workflow the remote nodeid is not yet available and it should be set later on, but I can't figure out where to get it from nor where it should be set in order to solve the issue. Any help on this is very well appreciated.

EDIT: after another debugging session I figured that initiator's nodeid is available at the end of the noise protocol to the receiver. I still don't understand where precisely in code the noise protocol gets executed between peers and so how to retrieve initiator nodeid from that.

St333p commented 3 years ago

As for asset identifiers, I have the feeling that the cleanest possible solution would be to switch everything over to bech32 encoding, also for consistency with rgb-node. This could be obtained by having the rgb-node Asset api return a bech32 encoded string or by implementing a the conversion between hex and bech32 encodings in lnpbp::bp::chain::AssetId. Am I right?

St333p commented 3 years ago

Updates from 20.12.09 call:

As a result, the best approach is probably to close this issue with a PR that addresses the lesser issue that I already solved and open a new one to just keep track of the missing points and point to the right info until lnpbp core library is released.

St333p commented 3 years ago

bugs 1-4 were solved by #32 bug 5 is waiting for an update in rust-lnpbp and has a dedicated issue #33 bug 6-7 are linked to each other and are waiting for an update in rust-lnpbp, here is the dedicated issue #34