Merge fort-nix/nix-bitcoin#487: Add feeadjust core lightning plugin
f9315db52c
clightning/feeadjuster: add test (Erik Arvstedt)1054e9a3b1
Add cln feeadjuster plugin (elsirion) Pull request description: ACKs for top commit: erikarvstedt: ACKf9315db52c
jonasnick: ACKf9315db52c
Tree-SHA512: 878b5c2455d71cfd8503774f3f29fc36c7fc5337b583a850c4d944348e102a23de92aba6fadf4304cfd81a5684869f9c0b8cbe1673cf72b2b57f5846b2c73183
This commit is contained in:
commit
95e4a3fa9e
@ -14,6 +14,7 @@ in {
|
|||||||
imports = [
|
imports = [
|
||||||
./clboss.nix
|
./clboss.nix
|
||||||
./commando.nix
|
./commando.nix
|
||||||
|
./feeadjuster.nix
|
||||||
./prometheus.nix
|
./prometheus.nix
|
||||||
./summary.nix
|
./summary.nix
|
||||||
./zmq.nix
|
./zmq.nix
|
||||||
|
78
modules/clightning-plugins/feeadjuster.nix
Normal file
78
modules/clightning-plugins/feeadjuster.nix
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
{ config, lib, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
let
|
||||||
|
options.services.clightning.plugins.feeadjuster = {
|
||||||
|
enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Enable feeaduster (clightning plugin).
|
||||||
|
This plugin auto-updates channel fees to keep channels balanced.
|
||||||
|
|
||||||
|
See here for for all available options:
|
||||||
|
https://github.com/lightningd/plugins/blob/master/feeadjuster/feeadjuster.py
|
||||||
|
Extra options can be set via `services.clightning.extraConfig`.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
fuzz = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
description = "Enable update threshold randomization and hysteresis.";
|
||||||
|
};
|
||||||
|
adjustOnForward = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "Automatically update fees on forward events.";
|
||||||
|
};
|
||||||
|
method = mkOption {
|
||||||
|
type = types.enum [ "soft" "default" "hard" ];
|
||||||
|
default = "default";
|
||||||
|
description = ''
|
||||||
|
Adjustment method to calculate channel fees.
|
||||||
|
`soft`: less difference when adjusting fees.
|
||||||
|
`hard`: greater difference when adjusting fees.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
adjustDaily = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
description = "Automatically update fees daily.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
cfg = config.services.clightning.plugins.feeadjuster;
|
||||||
|
inherit (config.services) clightning;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
inherit options;
|
||||||
|
|
||||||
|
config = mkIf (cfg.enable && clightning.enable) {
|
||||||
|
services.clightning.extraConfig = ''
|
||||||
|
plugin=${config.nix-bitcoin.pkgs.clightning-plugins.feeadjuster.path}
|
||||||
|
feeadjuster-adjustment-method="${cfg.method}"
|
||||||
|
'' + optionalString (!cfg.fuzz) ''
|
||||||
|
feeadjuster-deactivate-fuzz
|
||||||
|
'' + optionalString (!cfg.adjustOnForward) ''
|
||||||
|
feeadjuster-deactivate-fee-update
|
||||||
|
'';
|
||||||
|
|
||||||
|
systemd = mkIf cfg.adjustDaily {
|
||||||
|
services.clightning-feeadjuster = {
|
||||||
|
# Only run when clightning is running
|
||||||
|
requisite = [ "clightning.service" ];
|
||||||
|
after = [ "clightning.service" ];
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
User = "clightning";
|
||||||
|
ExecStart = "${clightning.package}/bin/lightning-cli --lightning-dir ${clightning.dataDir} feeadjust";
|
||||||
|
};
|
||||||
|
unitConfig.JoinsNamespaceOf = [ "clightning.service" ];
|
||||||
|
startAt = [ "daily" ];
|
||||||
|
};
|
||||||
|
timers.clightning-feeadjuster.timerConfig = {
|
||||||
|
RandomizedDelaySec = "6h";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
@ -39,6 +39,9 @@ let
|
|||||||
scriptName = "cl-zmq";
|
scriptName = "cl-zmq";
|
||||||
extraPkgs = [ twisted txzmq ];
|
extraPkgs = [ twisted txzmq ];
|
||||||
};
|
};
|
||||||
|
feeadjuster = {
|
||||||
|
description = "Dynamically changes channel fees to keep your channels more balanced";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
basePkgs = [ nbPython3Packages.pyln-client ];
|
basePkgs = [ nbPython3Packages.pyln-client ];
|
||||||
|
@ -134,6 +134,7 @@ let
|
|||||||
(mkIf config.test.features.clightningPlugins {
|
(mkIf config.test.features.clightningPlugins {
|
||||||
services.clightning.plugins = {
|
services.clightning.plugins = {
|
||||||
clboss.enable = true;
|
clboss.enable = true;
|
||||||
|
feeadjuster.enable = true;
|
||||||
helpme.enable = true;
|
helpme.enable = true;
|
||||||
monitor.enable = true;
|
monitor.enable = true;
|
||||||
prometheus.enable = true;
|
prometheus.enable = true;
|
||||||
|
@ -127,20 +127,24 @@ def _():
|
|||||||
def _():
|
def _():
|
||||||
assert_running("clightning")
|
assert_running("clightning")
|
||||||
assert_matches("runuser -u operator -- lightning-cli getinfo | jq", '"id"')
|
assert_matches("runuser -u operator -- lightning-cli getinfo | jq", '"id"')
|
||||||
if test_data["clightning-plugins"]:
|
|
||||||
|
enabled_plugins = test_data["clightning-plugins"]
|
||||||
|
if enabled_plugins:
|
||||||
plugin_list = succeed("lightning-cli plugin list")
|
plugin_list = succeed("lightning-cli plugin list")
|
||||||
plugins = json.loads(plugin_list)["plugins"]
|
plugins = json.loads(plugin_list)["plugins"]
|
||||||
active = set(plugin["name"] for plugin in plugins if plugin["active"])
|
active = set(plugin["name"] for plugin in plugins if plugin["active"])
|
||||||
failed = set(test_data["clightning-plugins"]).difference(active)
|
failed = set(enabled_plugins).difference(active)
|
||||||
if failed:
|
if failed:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
f"The following clightning plugins are inactive:\n{failed}.\n\n"
|
f"The following clightning plugins are inactive:\n{failed}.\n\n"
|
||||||
f"Output of 'lightning-cli plugin list':\n{plugin_list}"
|
f"Output of 'lightning-cli plugin list':\n{plugin_list}"
|
||||||
)
|
)
|
||||||
else:
|
active = [os.path.splitext(os.path.basename(p))[0] for p in enabled_plugins]
|
||||||
machine.log("Active clightning plugins:")
|
machine.log("\n".join(["Active clightning plugins:", *active]))
|
||||||
for p in test_data["clightning-plugins"]:
|
|
||||||
machine.log(os.path.basename(p))
|
if "feeadjuster" in active:
|
||||||
|
# This is a one-shot service, so this command only succeeds if the service succeeds
|
||||||
|
succeed("systemctl start clightning-feeadjuster")
|
||||||
|
|
||||||
@test("lnd")
|
@test("lnd")
|
||||||
def _():
|
def _():
|
||||||
|
Loading…
Reference in New Issue
Block a user