-
Notifications
You must be signed in to change notification settings - Fork 96
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
Adds curated clightning plugins #259
Adds curated clightning plugins #259
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way this is a really fantastic project and I learned a lot about nix by poking around!
Hi, me too. Thank you for the PR! The plugins look quite interesting, looking forward to trying them out
How do you build a plugin with nix build? clightning-plugins
is an attrset with paths that don't exist on my system instead of a derivation.
There are a few things we should add before merging this:
- Add
clightning-plugins
build test to travis (similar to the other packages) - Add functional test by enabling the plugins in tests.nix and checking whether
lightning-cli plugins list
shows the plugins - Usually we also have scripts that print the hash of the latest version of a package and verify signature. They're called
get-sha256.sh
in other packages. This would be less useful here, because I don't see any signatures that we could verify. But it could help figuring out what the latest version is without using a browser.
By the way mach-nix looks interesting - nix-based alternative to poetry? yes please. Sent them donation sats (with my nix-bitcoin clightning node).
The way that I have currently abstracted things, there is nothing you can pass into pkgs.writeScript "run-plugin" "${pkgs.nix-bitcoin.clightning-plugin.drain}" to # modules/clightning.nix
{ configuration.nix-bitcoin.clightning.plugins = {
autopilot = pkgs.nix-bitcoin.clightning-plugins.autopilot + "/autopilot.py";
# etc
};
} # configuration.nix
{ services.clightning.plugins = with configuration.nix-bitcoin.clightning.plugins; [ autopilot donation ]; etc
} Another possibility is we could configure
No. I should spell this out a bit more. I added a configuration option { services.clightning.extraConfig = "plugin=${myPlugin}"; } # or "plugin=${myPluginDrv + "/myPlugin.py"}" The
I will add the list of plugins to the readme. Your testing suggestions seem reasonable. I'll work on adding that missing stuff. |
I just realized that by using the |
I tried to run the test suite myself using |
What formatting tool does the project use for python scripts? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose to structure things this way because each plugin script has a different name and I thought it would be more user friendly to expose the path to the executable rather than the derivation
I didn't see anything wrong with your approach. Seemed to work. Nice that you found the plugin-dir option. nix-build
is straightforward now.
No. I should spell this out a bit more.
Sorry, I wasn't referring to enabling plugins but to configuring plugins themselves. For example autopilot adds new command line options. I'm wondering whether these command line options can just as well be added to the clightning config.
I tried to run the test suite myself using test/run-tests.sh but several derivations failed to build for me: elementsd, joinmarket (problem with coincurve), and lightning-charge
That shouldn't happen. What error do you get?
What formatting tool does the project use for python scripts?
Not exaclty sure. We inherit it as part of the NixOS test framewor.
latest="$(git rev-parse master)" | ||
|
||
echo "ref: ${latest}" | ||
echo "sha256: $(git archive --format tar.gz --prefix=clightning-plugins-"${latest}"/ ${latest} | sha256sum | cut -d\ -f1)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should either
a) yield two sha256's that can be used with fetchFromGitHub
for both mach-nix
and plugins
OR
b) switch mach-nix
and plugins
to fetchurl
in default.nix
so they can use the sha256 hashes generated by this get-sha256.sh
.
I tested the basic functionality by enabling and functionally testing both
I agree, all plugins with relevant config options should have corresponding nix-bitcoin options with sane default values. When the plugin is enabled by the user, it should automatically insert these config options into the clightning config.
The test you added ran for me. I like the test mechanism. I don't think all the TODO's need to be implemented before we can merge. The currently integrated plugins already provide a great amount of additional functionality to the user. We should document the available plugins for the user and how to enable them in |
I just pushed a new version taking your comments into consideration.
My problem running the test suite comes down to a permission problem with my workstation installation. I haven't tried to work it out yet but I can run the tests on a separate nixos system. I added some code for |
Great contribution, welcome to nix-bitcoin!
Luckily, most plugin dependencies are readily available in nixpkgs and our own joinmarket Python packages (thanks @nixbitcoin). Downside: The Python pkg versions don't always exactly match the plugin requirements, but the test suite runs fine. Could you do some manual checks? I've also added these minor changes to
This PR needs some more fixes, but let's tackle the More questionsWhy is the |
@GambolingPangolin The |
I've noticed that Travis sometimes fails with error
|
The nice thing about the mach-nix approach was that it didn't (seem to) require a lot of maintenance work, but I agree that it apparently has serious downsides. When we go forward with @erikarvstedt's suggestions we should only add plugins that people actually want to use. Many of the plugins are just proof of concepts, not actively maintained or very unlikely to be useful to anyone (imo). Not adding those would be more appropriate given the resources of the nix-bitcoin project.
I'm worried about this because one can imagine how an exception can result in loss of funds (for example with the rebalance or jitrebalance plugins). |
@erikarvstedt I agree with your critique of I agree with @jonasnick that we should take care to satisfy the version
The autopilot plugin dies immediately on my system without producing meaningful
There are method namespace collisions including
I really appreciate any advice you might have! Here is the output: @jonasnick I think that supporting only the plugins that people want to use is |
@GambolingPangolin, let's continue fixing your build failure here. I've rebased and updated my branch to ensure that plugin requirements are met. |
trap "rm -rf $TMPDIR" EXIT | ||
|
||
cd "$TMPDIR" | ||
echo "Fetching latest DavHau/mach-nix release" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we still calculating the sha256 for mach-nix
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad! This is an oversight.
test/tests.py
Outdated
@@ -134,10 +134,25 @@ def _(): | |||
succeed("su operator -c 'liquidswap-cli --help'") | |||
|
|||
|
|||
# backup requires manual setup, so we skip it in this test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICT backup plugin is no longer available
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also an oversight. We are no longer shipping the backup plugin anyway.
pkgs/clightning-plugins/default.nix
Outdated
owner = "lightningd"; | ||
repo = "plugins"; | ||
rev = "6cd472636926f05a9c472139fabe1ff11c90aa6a"; | ||
sha256 = "13cccwxanhmwmhr4prs13gn5am9l2xqckk80ad41kp2a4jq4gdsy"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be 1lisx85vzsfzjhdc6zdz0l6bcrdgg6rp5xbc5jmx93mv8qqg2cns
. For some reason it still deployed on my end with this but didn't copy over the new version of the scripts (noticed because I was still getting proxy errors with summary
). Seems like the src
doesn't update properly until you change the sha256
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dammit. I pasted from the wrong buffer! When I did a test deployment, it succeeded like in your case and I even saw new paths with the suffix 6cd4726
both in the deployment output and in the clightning config. This seems like a problem. Builds should always fail if the integrity check fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The store path of a fixed-output derivation is only determined by its name and the sha256
attr. The other attrs are only used when building the drv. To trigger a rebuild (and a new integrity check) you have to change the sha256
(or the name) to yield a store path that doesn't already exist in /nix/store
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok that makes sense. In light of this behavior, how about we make use the first 7 digits of the sha256 for the version instead of the first digits of the rev?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a version number is unavailable, version
should consist of a maximally unambiguous and easily identifiable fact about the source. In nixpkgs, it's common practice to use the src's git rev. See:
cd $(nix eval '(<nixpkgs>)'); nix run nixpkgs.ripgrep -c rg "version = .*substring"
The src sha256
fails at the "easily identifiable" part and its value is already implicitly used to calculate the plugin drv hash (/nix/store/{HASH}-...
).
Thanks, this looks great. Here's a last batch of fixups. My three initial pypkgs-related commits are complex enough to be kept separate. So please don't squash them this time. There's a nondeterministic error (log) in the |
@erikarvstedt Your tweaks look amazing! Where did you learn all of the nix trix? The only thing that I noticed is that some of the subsection headers in Do you have any opinion on how to organize the new commits? I'm planning on grouping them into 2 or 3 logical commits. |
During the last two years I've made nix my main platform for desktop and server computing. So it's just daily practice and lots of reading in the
Yes, a separate PR would be great.
Just
|
Here's a squashed version of the branch. |
Remove obsolete passthru from joinmarket because joinmarket packages are now accessible via pkgs/python-packages.
Needed for the following commit which adds derivation outputs to `dataFile`.
The intermittent bug that you observed appears to be this which also has a ticket for when it shows up in The way you organized the commits seems pretty much perfect. So I'm going to rebase them and push to this branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 1d44b99
Great work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
ACK 1d44b99340eb4535950f53579ff195de22e8b6cc
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCgAdFiEEV3o0Un8+KoXoD+Fk3RH5rVMIs7oFAl+2V9sACgkQ3RH5rVMI
s7rESA/+OTh5+7u3PVVTCDAK7srYotb/Wh7ZHpj8IyJsUmFEYOBI7dfY9H17cOFZ
GO+IayGG/iugeNTjgSx5vd5BVjRwZ+vBPfjzKmuvHPSfvUA4oKBfMHnAR84saXOM
XeHw9zaH/m/bqy2i4OIcCW1fukUyjRk//f6I1HA+PtiZdVzwz6FwfiD21aWPIJH6
UtEzzUYfXSo/9O8Fw3/48INHtSz/XVhr0Cyqbi1rGiw+Iu3z3WJjkQqkWleIxwtU
WjwOrYMwjCbq5zBKE/9NIk3RizcCsngpvy4Qg2LU966rQddBwaBKF7wmi0KDBcqD
vyOjq8hXtDuW1SrWo23L1xtRh/0Q3XixHFUjSjkifNogjwxpqlYXOYF+UTInt/wJ
2SxljvvaIsvt+j1+40MVUTO868USNLwfOhBjFCiX2TJ0EVu4TjeVIkeVHXwdmGCc
Y9ozDPbZZ1wWey7axWjCIx4ADO2+jwnobGaAvyNvdzXwF9y5cHbeh0I7lDLkOiM4
uwkCwjr3s5xjoDEhwsPp2ow+fC59jnSqoMLcIjQBIT5i6IeGYkB8L8tbohXfzJkJ
UWMsjoPzhQ0wnqrOS4XIeaQV3F9/ZpVWPolDp2Fqz8pyxrMlunCBqEz+m5ajWPEm
rrX0eViwXsTLYqPOlzNtLnyTHHzZI4N6Qof6C+E5zSg8vJOpbpg=
=34FD
-----END PGP SIGNATURE-----
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks everyone! I really like that we're checking the requirements now. Substituting versions is still sketchy (in particular major versions), but I suppose it's the best we can do for now.
During the last two years I've made nix my main platform for desktop and server computing. So it's just daily practice and lots of reading in the nixpkgs sources.
@erikarvstedt that truly must be a lot of reading. Thanks for caring so much about the quality of nix-bitcoin and teaching us plebs in the process :)
Just as an aside, we should also add CLBOSS https://lists.ozlabs.org/pipermail/c-lightning/2020-October/000197.html at some point. |
This change adds an option to the
clightning
module to configure plugins and makes most of the plugins in the lightningd/plugins repository available in the attribute setpkgs.nix-bitcoin.clightning-plugins
(see example/configuration.nix).To configure
clightning
to use a new plugin with nix derivationsomePlugin
, the admin would simply add(somePlugin + "/bin/plugin")
or whatever to the list of enabled plugins.Instead of relying on the curated Python package set, I used mach-nix to build a closure from each plugin's
requirements.txt
. (This might be useful elsewhere innix-bitcoin
; I haven't checked.)I tested that all of the plugins build successfully and that a subset of them run correctly with
clighting
using the intended configuration syntax forms.This could be considered to close #71.
By the way this is a really fantastic project and I learned a lot about
nix
by poking around!