Skip to content
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

feat(images): add support for Core Lightning v23.08.2 & v24.02.2 #879

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

jamaljsr
Copy link
Owner

Closes #772
Replaces #774

Description

Adds support for Core Lightning v23.08.2 & v24.02.2.

I've migrated to using the Core Lightning embedded REST API plugin clnrest from previously using the third-party c-lightning-REST plugin. Since older versions of CLN do not support the clnrest-port flag, I have dropped support in Polar for versions prior to these two.

Screenshots

image

Copy link

codecov bot commented Apr 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (fc2c325) to head (a016f57).

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #879   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          140       140           
  Lines         4582      4636   +54     
  Branches       851       892   +41     
=========================================
+ Hits          4582      4636   +54     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jamaljsr
Copy link
Owner Author

I'm going to hold off on merging this until right before shipping the next release. The removal of older CLN nodes from nodes.json would break existing Polar users that could apply the out-of-band node version updates.

@toneloc
Copy link

toneloc commented Apr 26, 2024

Awesome! I would like to help test building the CLN Docker images.

Please let me know how I can best help test.

@jamaljsr
Copy link
Owner Author

Hey @toneloc, the images have already been built and pushed to Docker Hub. The instructions for how I build the images are in the docker readme.

If you want to test them out in Polar, you'll need to be running the the code in this PR branch because the new images won't work in v2.2.0. You'll need to setup your dev environment to run Polar from source code. The instructions are in the CONTRIBUTING doc. Just be sure to checkout this branch.

@toneloc
Copy link

toneloc commented Apr 26, 2024

Awesome thanks. FYI, I had to remove --openssl-legacy-provider in package.json to get it to work on my Mac M2 ... but it worked.

After that I was able to start up a Polar network with two v24.02.2 CLN nodes and create a channel and send payments back and forth. All via UI.

If you want me to test anything in particular please lmk. Will let you know if I see anything else notable.

Nice work. Next I want to try to create custom Docker image so I can add in a CLN plugin. Any tips on that please lmk.

@jamaljsr
Copy link
Owner Author

@toneloc Thanks so much for testing and confirming it works for you. That is very helpful.

FYI, I had to remove --openssl-legacy-provider in package.json to get it to work on my Mac M2 ... but it worked.

What version of NodeJS are you running? I've seen issues related to this flag when you aren't running v20.

Next I want to try to create custom Docker image so I can add in a CLN plugin. Any tips on that please lmk.

Getting your plugin into the docker image should be pretty easy. This is how Polar currently installs the c-lightning-REST plugin into the /opt/c-lightning-rest/ dir in the image.

# install nodejs
RUN apt-get update -y \
&& apt-get install -y curl gosu git \
&& curl -sL https://deb.nodesource.com/setup_14.x | bash - \
&& apt-get install -y nodejs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# install c-lightning-REST API plugin
RUN git clone https://github.com/Ride-The-Lightning/c-lightning-REST.git /opt/c-lightning-rest/ \
&& cd /opt/c-lightning-rest \
&& npm install \
&& chmod -R a+rw /opt/c-lightning-rest \
&& mv /opt/c-lightning-rest/clrest.js /opt/c-lightning-rest/plugin.js

You'd just need to get your plugin's files into the image via git clone or COPY. Once the files are inside of the image, you can update the node's startup command in Polar to include the path to your plugin. Similar to this:

--plugin=/opt/c-lightning-rest/plugin.js

@toneloc
Copy link

toneloc commented Apr 27, 2024

What version of NodeJS are you running? I've seen issues related to this flag when you aren't running v20.

I am running Node v20.0.0.

Awesome thanks and cheers. I was able to build the image and test. This is further then I've ever been so kudos to you.

In the Dockerfile I had to remove the line COPY .bashrc /home/clightning/.bashrc and manually change v${CLN_VERSION} to v24.02.2 (and of course also add git clone and CP and MV install lines to Dockerfile, as you mention).

Note that when creating channels the green lines didn't show up between custom nodes, not sure why.

Did not have error without custom nodes. Nothing weird in CLN logs.

Anyway, error and screenshot pasted below. Cheers

[electron] 22:39:20.379 › Failed to sync the network TypeError: Cannot convert undefined or null to object
[electron]     at Function.keys (<anonymous>)
[electron]     at http://localhost:3000/static/js/main.chunk.js:39919:12
[electron]     at Array.forEach (<anonymous>)
[electron]     at updateChartFromNodes (http://localhost:3000/static/js/main.chunk.js:39918:24)
[electron]     at Object.fn (http://localhost:3000/static/js/main.chunk.js:35937:91)
[electron]     at processTicksAndRejections (internal/process/task_queues.js:93:5)
[electron]     at async http://localhost:3000/static/js/main.chunk.js:5693:7
Screenshot 2024-04-26 at 10 40 26 PM

@jamaljsr
Copy link
Owner Author

Oh interesting. From looking at the code involved in that stacktrace, I suspect that this error is not the root cause, but a result of the chart links object being undefined, which shouldn't be possible. Is this the first error displayed in the logs immediately after opening a channel?

Would you mind sharing logs?

  • The files in ~/.polar/logs. Please stop Polar, delete the existing files, then start Polar and reproduce the issue so the logs are isolated.
  • The DevTools console logs would be helpful as well. If you run yarn dev, the DevTools should automatically open. If you go to the Console tab then right click anywhere on the logs and choose "Save as..." to save the logs to a file that you can share.

@toneloc
Copy link

toneloc commented Apr 27, 2024

Look like on restart the line showed up!

Then I created a channel and it is working now. Not sure what happened.

FYI:

Polar logs:

polarlogs.txt

And front end:

localhost-1714237419178.log

The Polar logs look okay. The front end logs may show you something! I'll let you known as I play around.

@michaelWuensch
Copy link

I can also confirm that it works with the new CLN versions. Didn't encounter any issues so far. 👍

@jamaljsr
Copy link
Owner Author

jamaljsr commented May 5, 2024

@michaelWuensch Thanks for the feedback. 👍

The embedded CLN REST API supports WebSocket connections, so we can
remove the currently implemented polling logic with subscribing to
the WebSocket events.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants