polar icon indicating copy to clipboard operation
polar copied to clipboard

Bug: balances for Core Lightning nodes are not updated correctly sometimes

Open ktecho opened this issue 1 year ago • 6 comments

Describe the bug Sometimes, after paying an invoice, the balance of the channel is not updated correctly, and the colors of the the lines in the channel are wrong too. This happens afaik only for Core Lightning nodes.

To Reproduce

  1. Git clone Polar from master (it fails also for v1.3.0 AppImage)
  2. Open Polar (yarn ; yarn package; ./dist/polar-linux-x86_64-v1.3.0.AppImage).
  3. Create a network with 3 Core-Lightning nodes
  4. Link each node with the next one using "create channel" option. So Alice to Bob, Bot to Carol. Default options in the dialog.
  5. Create an invoice in the last node (Carol). 150.000 sats.
  6. Pay the invoice from the first node (Alice).
  7. Sometimes (not always), balance information is not correct (see screenshot below).

Expected behavior Information and graphs about channels and balances must be accurate.

Screenshots So for the first channel, it seems like it didn't paid the invoice:

image

The second channel is fine. It got the correct information:

image

The graph also showns the wrong balance:

image

Desktop (please complete the following information):

  • OS: Kubuntu 22.04
  • Polar Version: master (2022-07-29). It also fails for v1.3.0

I'll tell what I found about this in next message.

ktecho avatar Jul 29 '22 15:07 ktecho

What I've found after investigating the issue, is that after paying the invoice, channel/listChannels is done too soon for the first node, so the balance is not updated yet. For the rest of the nodes, the channel/listChannels is done later, so it's always correct.

I've seen this duplicating the channel/listChannels call that's done in getChannels() in clightningService.ts, so the first call has the wrong balance, but the second one done 100 ms later has the correct information.

I've been trying to use some calls to get the information about it the last payment is fully done or is still being made. I asked some Blockstream employees and they gave me some hints, but:

1- They told me to waitsendpay, but the function seems like it's missing from the RTL REST API. 2- They also told me to do peer/listpeers to check that there are not HTLCs in flight, but the peer/listpeers call in RTL does not return all the required fields.

Do you have any recommendation on what we could do? Thanks!

ktecho avatar Jul 29 '22 15:07 ktecho

I've ran into this issue before as well. The manual workaround is to just hit the refresh button in the sidebar, but it would be better to try to fix it.

Since RTL doesn't currently support the API's that we need, the best course of action would be to open a PR in the RTL repo to add them. I've done this in the past when I needed additional data for Polar. Also, I'm sure they would appreciate the updates.

jamaljsr avatar Jul 30 '22 04:07 jamaljsr

I could add the methods in RTL, but having into account that the docker images are already generated and will have the old RTL, could we regenerate all the Core Lightning docker images so they contain the latest RTL API?

ktecho avatar Aug 04 '22 22:08 ktecho

Yes, I can rebuild and push new images to DockerHub with the updated RTL.

jamaljsr avatar Aug 04 '22 22:08 jamaljsr

Cool! I could give it a look next week if children left some free energy in me... :)

ktecho avatar Aug 04 '22 22:08 ktecho

lol.. i know the feeling as well. Good luck 😁

jamaljsr avatar Aug 04 '22 23:08 jamaljsr