Skip to content

cln: add alternative bitcoin backend config option#583

Closed
elsirion wants to merge 1 commit intofort-nix:masterfrom
elsirion:2023-01-trusteedcoin
Closed

cln: add alternative bitcoin backend config option#583
elsirion wants to merge 1 commit intofort-nix:masterfrom
elsirion:2023-01-trusteedcoin

Conversation

@elsirion
Copy link
Contributor

Getting a CLN node up and running in pruned mode is annoying and seems impossible when using https://prunednode.today/. It appears the easiest way to bootstrap a CLN node in such an environment is using an alternative chain data plugin like trustedcoin till CLN has processed all relevant blocks and then switching over to the pruned bitcoind again.

With this change users will be able to activate such a plugin with the alternativeBitcoinBackend option. If someone ever gets around to properly packaging trustedcoin we could make it a normal plugin (that also removes the bitcoin-datadir=${config.services.bitcoind.dataDir} line when active). The current approach is a bit more flexible and you could e.g. write and use your own version of trustedcoin with it.

    clightning = {
      enable = true;
      alternativeBitcoinBackend = "${trustedcoin}/usr/bin/trustedcoin";
    };

Properly packaging trustedcoin seemed too much work since I don't know go that well, I'm going with the following hack for now:

  autopatchelf = import (fetchTarball {
    url = "https://github.com/svanderburg/nix-patchtools/archive/6cc6fa4e0d8e1f24be155f6c60af34c8756c9828.tar.gz";
    sha256 = "sha256:0yff6fj0jv1d6kmrq4div1z8xxvgiqfndhfcqr9snw1h1mkr4yva";
  });
  trustedcoin = pkgs.stdenv.mkDerivation {
    name = "trustedcoin";
    src = pkgs.fetchurl {
      url = "https://github.com/nbd-wtf/trustedcoin/releases/download/v0.6.1/trustedcoin-v0.6.1-linux-amd64.tar.gz";
      sha256 = "sha256-J0oWvlsQPYiZCcwOv2G8c1O5A/ghM7JZG2VCLdBXBP8=";
    };
    buildInputs = [ autopatchelf ];
    libs = pkgs.lib.makeLibraryPath [ pkgs.glibc ];
    unpackPhase = ''
      tar -xzf "$src"
    '';
    installPhase = ''
      mkdir -p $out/usr/bin
      mv trustedcoin $out/usr/bin
      autopatchelf $out/usr/bin
    '';
    dontStrip = true;
  };

@elsirion elsirion force-pushed the 2023-01-trusteedcoin branch from 5423c18 to 74da216 Compare January 11, 2023 17:17
@erikarvstedt
Copy link
Collaborator

erikarvstedt commented Jan 11, 2023

Stalled PR #533 adds a trustedcoin package and plugin, and clightning module changes that roughly equal this PR.
You've just answered my question raised in #533 (comment), so the proposed CLN module changes (which keep a bitcoind dependency) seem to be the right way to go.

Do you want to pull in the pkg/plugin from #553?

@elsirion
Copy link
Contributor Author

I just didn't check the open PRs, this was more of a quickfix for myself that I thought to upstream in case people find it useful. #533 seems like the better design, probably just needs a rebase?

@elsirion
Copy link
Contributor Author

elsirion commented Mar 5, 2023

Superseded by #597.

@elsirion elsirion closed this Mar 5, 2023
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

Successfully merging this pull request may close these issues.

2 participants