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

Running Lightning Network Cluster in a Container for Testing #536

Open
DanGould opened this issue Aug 17, 2022 · 2 comments
Open

Running Lightning Network Cluster in a Container for Testing #536

DanGould opened this issue Aug 17, 2022 · 2 comments

Comments

@DanGould
Copy link

I'd like to automate integration testing using nix-bitcoin. Our project opens lightning channels, so I'd like to run bitcoind and a cluster of 2 LND nodes. I believe using nix lets us control the environment such that we could even onboard devs in a repl.it link like @Kodylow did at btc++.

Because some teammates run mac, and some linux, it seems like the NixOS VM isn't ready for this solution yet. If I understand correctly we could run such a NixOS VM in a docker container to solve this problem for now. We've got to use docker to support Umbrel and btcpayserver plugins, anyhow. Building that container from Nix also seems like the best way to a reproducible, maintainable build.

So far I've written a flake to 1. nix-build the binary 2. nix-develop in a defaultShell that includes tools to build that binary and 3. Spit out a docker container that includes the build.

I'm lost on how to get bitcoind, and then LND instances running in that container. Does it make to write logic that runs them in the flake? What do you make of the docker approach? If the approach makes sense, how does one define a running bitcoind and lightning cluster from a flake?

I figure others will want to do this in the future so an issue here could help.

@nepet
Copy link

nepet commented Aug 18, 2022

So, we are not using any flake, but we are using nix-bitcoin or better the nix-pkgs bitcoin elementsd clightning and some helper packages for our dev environment on https://github.com/ElementsProject/peerswap.

We use the nix-shell command to spawn a shell that has the dependencies set and a helper shell script to spawn a network with several nodes. This is currently in a bad shape as we mix it also with some docker containers for the local playground, but the integration tests use the packages from the nix-shell environment.

Maybe take a look at the repo and especially at the following files:

  • packages.nix
  • shell.nix
  • testframework/... for usage in the bitcoin and lightning proxies
  • .github/ci.yaml for caching in github ci
  • .contrib/startup_regtest.sh this is in a bad shape and uses a docker compose setup but could be changed to use the binaries provided by the nix-shell

Hope this is a helpful starting point.
By the way: mac is also possible if the nix-pkgs are usable on mac, I added mac compatibility to the clightning nix package some time ago for example.

Maybe we could write a walk-trough/tutorial some time.

Cheers,
Peter

@DanGould
Copy link
Author

DanGould commented Sep 6, 2022

@nepet This is the way to go. Thank you for your thorough response.

re: .contrrib/startup_regtest.sh using the binaries provided by nix-shell, is there any way to use the declarative nix modules/configuration setup to avoid shell scripting the startup? I'm a bit confused between how things run in NixOS vm vs in binaries the shell has access to

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@DanGould @nepet and others