Skip to content

Commit

Permalink
options: make anchors enabled by default, add dev-disable-anchors.
Browse files Browse the repository at this point in the history
We still want to test non-anchor channels, as we still support them, but
we've made it non-experimental.  To test non-anchor channels, we
use dev-force-features: -23.

Many tests change, as fees change, and we keep an emergency reserve.

Changelog-Added: Protocol: `option_anchors_zero_fee_htlc_tx` enabled, no longer experimental.
Changelog-Changed: Config: `experimental-anchors` now does nothing (it's enabled by default).
Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Dec 13, 2023
1 parent 49b2120 commit 9281d70
Show file tree
Hide file tree
Showing 13 changed files with 204 additions and 188 deletions.
23 changes: 21 additions & 2 deletions contrib/pyln-testing/pyln/testing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,10 +940,10 @@ def fundbalancedchannel(self, remote_node, total_capacity=FUNDAMOUNT, announce=T
else:
total_capacity = int(total_capacity)

self.fundwallet(total_capacity + 10000)
self.fundwallet(total_capacity + 35000)

if remote_node.config('experimental-dual-fund'):
remote_node.fundwallet(total_capacity + 10000)
remote_node.fundwallet(total_capacity + 35000)
# We cut the total_capacity in half, since the peer's
# expected to contribute that same amount
chan_capacity = total_capacity // 2
Expand Down Expand Up @@ -1275,6 +1275,25 @@ def mock_estimatesmartfee(r):
}
self.daemon.rpcproxy.mock_rpc('estimatesmartfee', mock_estimatesmartfee)

def mock_getmempoolinfo(r):
return {
'id': r['id'],
'error': None,
'result': {
'mempoolminfee': Decimal(feerates[4] * 4) / 10**8,
'minrelaytxfee': Decimal(feerates[4] * 4) / 10**8,
},
}

# Did they want to set minfee as well?
if len(feerates) > 4:
assert len(feerates) == 5
self.daemon.rpcproxy.mock_rpc('getmempoolinfo', mock_getmempoolinfo)

if wait_for_effect:
wait_for(lambda:
self.rpc.feerates(style='perkb')['perkb']['floor'] == feerates[4] * 4)

# Technically, this waits until it's called, not until it's processed.
# We wait until all four levels have been called.
if wait_for_effect:
Expand Down
13 changes: 5 additions & 8 deletions doc/lightningd-config.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,10 @@ specified multuple times. (Added in v23.08).
* **min-emergency-msat**=*msat*

This is the amount of funds to keep in the wallet to close anchor channels (which don't carry their own transaction fees). It defaults to 25000sat, and is only maintained if there are any anchor channels (or, when opening an anchor channel). This amount may be insufficient for multiple closes at once, however.


* **dev-disable-anchors**

This disabled anchor channel support, mainly useful for testing.

### Cleanup control options:

Expand Down Expand Up @@ -785,13 +788,7 @@ this option.

* **experimental-anchors**

Specifying this option turns on the `option_anchors_zero_fee_htlc_tx`
feature, meaning we can open anchor-based channels. This will become
the default for new channels in future, after more testing. Anchor-based
channels use larger commitment transactions, with the trade-off that they
don't have to use a worst-case fee, but can bump the commitment transaction
if it's needed. Note that this means that we need to keep
some funds aside: see `min-emergency-msat`.
This was enabled by default in v23.11, and no longer has an effect.

BUGS
----
Expand Down
2 changes: 1 addition & 1 deletion lightningd/hsm_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ struct ext_key *hsm_init(struct lightningd *ld)
if (feature_offered(ld->our_features->bits[INIT_FEATURE],
OPT_ANCHORS_ZERO_FEE_HTLC_TX)
&& !hsm_capable(ld, WIRE_HSMD_SIGN_ANCHORSPEND)) {
fatal("--experimental-anchors needs HSM capable of signing anchors!");
fatal("anchors needs HSM capable of signing anchors!");
}

if (feature_offered(ld->our_features->bits[INIT_FEATURE],
Expand Down
1 change: 1 addition & 0 deletions lightningd/lightningd.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,7 @@ static struct feature_set *default_features(const tal_t *ctx)
OPTIONAL_FEATURE(OPT_ZEROCONF),
OPTIONAL_FEATURE(OPT_CHANNEL_TYPE),
OPTIONAL_FEATURE(OPT_ROUTE_BLINDING),
OPTIONAL_FEATURE(OPT_ANCHORS_ZERO_FEE_HTLC_TX),
};

for (size_t i = 0; i < ARRAY_SIZE(features); i++) {
Expand Down
21 changes: 15 additions & 6 deletions lightningd/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,15 @@ static char *opt_force_featureset(const char *optarg,
return NULL;
}

static char *opt_unset_anchor_zero_fee_htlc_tx(struct lightningd *ld)
{
feature_set_sub(ld->our_features,
take(feature_set_for_feature(NULL,
OPTIONAL_FEATURE(OPT_ANCHORS_ZERO_FEE_HTLC_TX))));

return NULL;
}

static void dev_register_opts(struct lightningd *ld)
{
/* We might want to debug plugins, which are started before normal
Expand All @@ -782,6 +791,10 @@ static void dev_register_opts(struct lightningd *ld)
opt_set_bool,
&ld->plugins->dev_builtin_plugins_unimportant,
"Make builtin plugins unimportant so you can plugin stop them.");
clnopt_noarg("--dev-disable-anchors", OPT_EARLY|OPT_DEV,
opt_unset_anchor_zero_fee_htlc_tx, ld,
"Disable option_anchors_zero_fee_htlc_tx"
" to open zero-fee-anchor channels");
clnopt_noarg("--dev-no-reconnect", OPT_DEV,
opt_set_invbool,
&ld->reconnect,
Expand Down Expand Up @@ -1235,10 +1248,7 @@ static char *opt_set_quiesce(struct lightningd *ld)

static char *opt_set_anchor_zero_fee_htlc_tx(struct lightningd *ld)
{
/* Requires static_remotekey, but we always set that */
feature_set_or(ld->our_features,
take(feature_set_for_feature(NULL,
OPTIONAL_FEATURE(OPT_ANCHORS_ZERO_FEE_HTLC_TX))));
/* FIXME: deprecated_apis! */
return NULL;
}

Expand Down Expand Up @@ -1446,8 +1456,7 @@ static void register_opts(struct lightningd *ld)
" channels.");
opt_register_early_noarg("--experimental-anchors",
opt_set_anchor_zero_fee_htlc_tx, ld,
"EXPERIMENTAL: enable option_anchors_zero_fee_htlc_tx"
" to open zero-fee-anchor channels");
opt_hidden);
clnopt_witharg("--announce-addr-dns", OPT_EARLY|OPT_SHOWBOOL,
opt_set_bool_arg, opt_show_bool,
&ld->announce_dns,
Expand Down
3 changes: 1 addition & 2 deletions tests/test_bookkeeper.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,7 @@ def test_bookkeeping_missed_chans_leases(node_factory, bitcoind):
opts = {'funder-policy': 'match', 'funder-policy-mod': 100,
'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100,
'plugin': str(coin_mvt_plugin),
'disable-plugin': 'bookkeeper',
'experimental-anchors': None}
'disable-plugin': 'bookkeeper'}

l1, l2 = node_factory.get_nodes(2, opts=opts)

Expand Down
Loading

0 comments on commit 9281d70

Please sign in to comment.