options: make anchors enabled by default, ignore experimental-anchors.

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.

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 <rusty@rustcorp.com.au>


Header from folded patch 'fixup!_options__make_anchors_enabled_by_default,_ignore_experimental-anchors.patch':

fixup! options: make anchors enabled by default, ignore experimental-anchors.
This commit is contained in:
Rusty Russell 2024-02-06 14:43:28 +10:30
parent 0a2f03ac1e
commit 689e596036
12 changed files with 144 additions and 128 deletions

View file

@ -939,10 +939,10 @@ class LightningNode(object):
else: else:
total_capacity = int(total_capacity) total_capacity = int(total_capacity)
self.fundwallet(total_capacity + 10000) self.fundwallet(total_capacity + 35000)
if remote_node.config('experimental-dual-fund'): 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 # We cut the total_capacity in half, since the peer's
# expected to contribute that same amount # expected to contribute that same amount
chan_capacity = total_capacity // 2 chan_capacity = total_capacity // 2
@ -1274,6 +1274,25 @@ class LightningNode(object):
} }
self.daemon.rpcproxy.mock_rpc('estimatesmartfee', mock_estimatesmartfee) 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. # Technically, this waits until it's called, not until it's processed.
# We wait until all four levels have been called. # We wait until all four levels have been called.
if wait_for_effect: if wait_for_effect:

View file

@ -461,7 +461,6 @@ specified multuple times. (Added in v23.08).
* **min-emergency-msat**=*msat* * **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. 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.
### Cleanup control options: ### Cleanup control options:
@ -793,15 +792,6 @@ protocol to update channel types. At the moment, we only support setting
this option. 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`.
BUGS BUGS
---- ----

View file

@ -160,7 +160,7 @@ struct ext_key *hsm_init(struct lightningd *ld)
if (feature_offered(ld->our_features->bits[INIT_FEATURE], if (feature_offered(ld->our_features->bits[INIT_FEATURE],
OPT_ANCHORS_ZERO_FEE_HTLC_TX) OPT_ANCHORS_ZERO_FEE_HTLC_TX)
&& !hsm_capable(ld, WIRE_HSMD_SIGN_ANCHORSPEND)) { && !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], if (feature_offered(ld->our_features->bits[INIT_FEATURE],

View file

@ -906,11 +906,14 @@ static struct feature_set *default_features(const tal_t *ctx)
OPTIONAL_FEATURE(OPT_ZEROCONF), OPTIONAL_FEATURE(OPT_ZEROCONF),
OPTIONAL_FEATURE(OPT_CHANNEL_TYPE), OPTIONAL_FEATURE(OPT_CHANNEL_TYPE),
OPTIONAL_FEATURE(OPT_ROUTE_BLINDING), OPTIONAL_FEATURE(OPT_ROUTE_BLINDING),
/* Removed later for elements */
OPTIONAL_FEATURE(OPT_ANCHORS_ZERO_FEE_HTLC_TX),
}; };
for (size_t i = 0; i < ARRAY_SIZE(features); i++) { for (size_t i = 0; i < ARRAY_SIZE(features); i++) {
struct feature_set *f struct feature_set *f;
= feature_set_for_feature(NULL, features[i]);
f = feature_set_for_feature(NULL, features[i]);
if (!ret) if (!ret)
ret = tal_steal(ctx, f); ret = tal_steal(ctx, f);
else else

View file

@ -1258,10 +1258,7 @@ static char *opt_set_quiesce(struct lightningd *ld)
static char *opt_set_anchor_zero_fee_htlc_tx(struct lightningd *ld) static char *opt_set_anchor_zero_fee_htlc_tx(struct lightningd *ld)
{ {
/* Requires static_remotekey, but we always set that */ /* FIXME: deprecated_apis! */
feature_set_or(ld->our_features,
take(feature_set_for_feature(NULL,
OPTIONAL_FEATURE(OPT_ANCHORS_ZERO_FEE_HTLC_TX))));
return NULL; return NULL;
} }
@ -1469,8 +1466,7 @@ static void register_opts(struct lightningd *ld)
" channels."); " channels.");
opt_register_early_noarg("--experimental-anchors", opt_register_early_noarg("--experimental-anchors",
opt_set_anchor_zero_fee_htlc_tx, ld, opt_set_anchor_zero_fee_htlc_tx, ld,
"EXPERIMENTAL: enable option_anchors_zero_fee_htlc_tx" opt_hidden);
" to open zero-fee-anchor channels");
clnopt_witharg("--announce-addr-dns", OPT_EARLY|OPT_SHOWBOOL, clnopt_witharg("--announce-addr-dns", OPT_EARLY|OPT_SHOWBOOL,
opt_set_bool_arg, opt_show_bool, opt_set_bool_arg, opt_show_bool,
&ld->announce_dns, &ld->announce_dns,
@ -1789,6 +1785,13 @@ void handle_early_opts(struct lightningd *ld, int argc, char *argv[])
else else
ld->config = mainnet_config; ld->config = mainnet_config;
/* No anchors if we're elements */
if (chainparams->is_elements) {
feature_set_sub(ld->our_features,
feature_set_for_feature(tmpctx,
OPTIONAL_FEATURE(OPT_ANCHORS_ZERO_FEE_HTLC_TX)));
}
/* Set the ln_port given from chainparams */ /* Set the ln_port given from chainparams */
ld->config.ip_discovery_port = chainparams->ln_port; ld->config.ip_discovery_port = chainparams->ln_port;

View file

@ -355,8 +355,7 @@ def test_bookkeeping_missed_chans_leases(node_factory, bitcoind):
opts = {'funder-policy': 'match', 'funder-policy-mod': 100, opts = {'funder-policy': 'match', 'funder-policy-mod': 100,
'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100, 'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100,
'plugin': str(coin_mvt_plugin), 'plugin': str(coin_mvt_plugin),
'disable-plugin': 'bookkeeper', 'disable-plugin': 'bookkeeper'}
'experimental-anchors': None}
l1, l2 = node_factory.get_nodes(2, opts=opts) l1, l2 = node_factory.get_nodes(2, opts=opts)

View file

@ -361,8 +361,10 @@ def closing_negotiation_step(node_factory, bitcoind, chainparams, opts):
orate = feerate_for(21000) # closing fee negotiation starts at 21000 orate = feerate_for(21000) # closing fee negotiation starts at 21000
prate = feerate_for(20000) # closing fee negotiation starts at 20000 prate = feerate_for(20000) # closing fee negotiation starts at 20000
opener, peer = node_factory.line_graph(2, opts=[{'feerates': (orate, orate, orate, orate)}, opener, peer = node_factory.line_graph(2, opts=[{'feerates': (orate, orate, orate, orate),
{'feerates': (prate, prate, prate, prate)}]) 'dev-force-features': "-23"},
{'feerates': (prate, prate, prate, prate),
'dev-force-features': "-23"}])
opener_id = opener.info['id'] opener_id = opener.info['id']
peer_id = peer.info['id'] peer_id = peer.info['id']
@ -501,8 +503,8 @@ def test_penalty_inhtlc(node_factory, bitcoind, executor, chainparams, anchors):
# Feerates identical so we don't get gratuitous commit to update them # Feerates identical so we don't get gratuitous commit to update them
opts = {'dev-disable-commit-after': 1, opts = {'dev-disable-commit-after': 1,
'plugin': coin_mvt_plugin} 'plugin': coin_mvt_plugin}
if anchors: if anchors is False:
opts['experimental-anchors'] = None opts['dev-force-features'] = "-23"
# FIXME: | for dicts was added in Python 3.9 apparently. # FIXME: | for dicts was added in Python 3.9 apparently.
l1, l2 = node_factory.line_graph(2, opts=[{**opts, **{'may_fail': True, l1, l2 = node_factory.line_graph(2, opts=[{**opts, **{'may_fail': True,
@ -632,8 +634,8 @@ def test_penalty_outhtlc(node_factory, bitcoind, executor, chainparams, anchors)
opts = {'dev-disable-commit-after': 3, opts = {'dev-disable-commit-after': 3,
'plugin': coin_mvt_plugin} 'plugin': coin_mvt_plugin}
if anchors: if anchors is False:
opts['experimental-anchors'] = None opts['dev-force-features'] = "-23"
# First we need to get funds to l2, so suppress after second. # First we need to get funds to l2, so suppress after second.
# Feerates identical so we don't get gratuitous commit to update them # Feerates identical so we don't get gratuitous commit to update them
@ -764,11 +766,9 @@ def test_channel_lease_falls_behind(node_factory, bitcoind):
their blockheight, the lessor fails the channel their blockheight, the lessor fails the channel
''' '''
opts = [{'funder-policy': 'match', 'funder-policy-mod': 100, opts = [{'funder-policy': 'match', 'funder-policy-mod': 100,
'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100, 'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100},
'experimental-anchors': None},
{'funder-policy': 'match', 'funder-policy-mod': 100, {'funder-policy': 'match', 'funder-policy-mod': 100,
'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100, 'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100}]
'experimental-anchors': None}]
l1, l2, = node_factory.get_nodes(2, opts=opts) l1, l2, = node_factory.get_nodes(2, opts=opts)
amount = 500000 amount = 500000
@ -805,8 +805,7 @@ def test_channel_lease_post_expiry(node_factory, bitcoind, chainparams):
opts = {'funder-policy': 'match', 'funder-policy-mod': 100, opts = {'funder-policy': 'match', 'funder-policy-mod': 100,
'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100, 'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100,
'may_reconnect': True, 'plugin': coin_mvt_plugin, 'may_reconnect': True, 'plugin': coin_mvt_plugin,
'dev-no-reconnect': None, 'dev-no-reconnect': None}
'experimental-anchors': None}
l1, l2, = node_factory.get_nodes(2, opts=opts) l1, l2, = node_factory.get_nodes(2, opts=opts)
@ -909,8 +908,7 @@ def test_channel_lease_unilat_closes(node_factory, bitcoind):
''' '''
opts = {'funder-policy': 'match', 'funder-policy-mod': 100, opts = {'funder-policy': 'match', 'funder-policy-mod': 100,
'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100, 'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100,
'funder-lease-requests-only': False, 'funder-lease-requests-only': False}
'experimental-anchors': None}
l1, l2, l3 = node_factory.get_nodes(3, opts=opts) l1, l2, l3 = node_factory.get_nodes(3, opts=opts)
# Allow l2 some warnings # Allow l2 some warnings
@ -1020,12 +1018,10 @@ def test_channel_lease_lessor_cheat(node_factory, bitcoind, chainparams):
opts = [{'funder-policy': 'match', 'funder-policy-mod': 100, opts = [{'funder-policy': 'match', 'funder-policy-mod': 100,
'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100, 'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100,
'may_reconnect': True, 'allow_warning': True, 'may_reconnect': True, 'allow_warning': True,
'experimental-anchors': None,
'plugin': balance_snaps}, 'plugin': balance_snaps},
{'funder-policy': 'match', 'funder-policy-mod': 100, {'funder-policy': 'match', 'funder-policy-mod': 100,
'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100, 'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100,
'may_reconnect': True, 'allow_broken_log': True, 'may_reconnect': True, 'allow_broken_log': True,
'experimental-anchors': None,
'plugin': balance_snaps}] 'plugin': balance_snaps}]
l1, l2, = node_factory.get_nodes(2, opts=opts) l1, l2, = node_factory.get_nodes(2, opts=opts)
@ -1192,21 +1188,25 @@ def test_penalty_htlc_tx_fulfill(node_factory, bitcoind, chainparams, anchors):
coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py') coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py')
balance_snaps = os.path.join(os.getcwd(), 'tests/plugins/balance_snaps.py') balance_snaps = os.path.join(os.getcwd(), 'tests/plugins/balance_snaps.py')
opts = {'may_reconnect': True,
'dev-no-reconnect': None}
if anchors:
commitfee = 3755
else:
commitfee = 11005
opts = {**opts, 'dev-force-features': "-23"}
l1, l2, l3, l4 = node_factory.line_graph(4, l1, l2, l3, l4 = node_factory.line_graph(4,
opts=[{'disconnect': ['-WIRE_UPDATE_FULFILL_HTLC'], opts=[{'disconnect': ['-WIRE_UPDATE_FULFILL_HTLC'],
'may_reconnect': True, **opts},
'dev-no-reconnect': None},
{'plugin': [coin_mvt_plugin, balance_snaps], {'plugin': [coin_mvt_plugin, balance_snaps],
'disable-mpp': None, 'disable-mpp': None,
'dev-no-reconnect': None, **opts,
'may_reconnect': True,
'allow_broken_log': True}, 'allow_broken_log': True},
{'plugin': [coin_mvt_plugin, balance_snaps], {'plugin': [coin_mvt_plugin, balance_snaps],
'dev-no-reconnect': None, **opts,
'may_reconnect': True,
'allow_broken_log': True}, 'allow_broken_log': True},
{'dev-no-reconnect': None, opts],
'may_reconnect': True}],
wait_for_announce=True) wait_for_announce=True)
channel_id = first_channel_id(l2, l3) channel_id = first_channel_id(l2, l3)
@ -1257,7 +1257,7 @@ def test_penalty_htlc_tx_fulfill(node_factory, bitcoind, chainparams, anchors):
# reconnect with l1, which will fulfill the payment # reconnect with l1, which will fulfill the payment
l2.rpc.connect(l1.info['id'], 'localhost', l1.port) l2.rpc.connect(l1.info['id'], 'localhost', l1.port)
l2.daemon.wait_for_log('got commitsig .*: feerate 11005, blockheight: 0, 0 added, 1 fulfilled, 0 failed, 0 changed') l2.daemon.wait_for_log('got commitsig .*: feerate {}, blockheight: 0, 0 added, 1 fulfilled, 0 failed, 0 changed'.format(commitfee))
# l2 moves on for closed l3 # l2 moves on for closed l3
bitcoind.generate_block(1) bitcoind.generate_block(1)
@ -1403,9 +1403,9 @@ def test_penalty_htlc_tx_timeout(node_factory, bitcoind, chainparams, anchors):
'allow_broken_log': True, 'allow_broken_log': True,
} }
] ]
if anchors: if anchors is False:
for opt in opts: for opt in opts:
opt['experimental-anchors'] = None opt['dev-force-features'] = "-23"
l1, l2, l3, l4, l5 = node_factory.get_nodes(5, opts=opts) l1, l2, l3, l4, l5 = node_factory.get_nodes(5, opts=opts)
@ -1586,8 +1586,8 @@ def test_penalty_rbf_normal(node_factory, bitcoind, executor, chainparams, ancho
coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py') coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py')
to_self_delay = 10 to_self_delay = 10
opts = {'dev-disable-commit-after': 1} opts = {'dev-disable-commit-after': 1}
if anchors: if anchors is False:
opts['experimental-anchors'] = None opts['dev-force-features'] = "-23"
# l1 is the thief, which causes our honest upstanding lightningd # l1 is the thief, which causes our honest upstanding lightningd
# code to break, so l1 can fail. # code to break, so l1 can fail.
@ -1938,8 +1938,8 @@ def test_onchain_timeout(node_factory, bitcoind, executor, chainparams, anchors)
coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py') coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py')
opts = {'plugin': coin_mvt_plugin} opts = {'plugin': coin_mvt_plugin}
if anchors: if anchors is False:
opts['experimental-anchors'] = None opts['dev-force-features'] = "-23"
# HTLC 1->2, 1 fails just after it's irrevocably committed # HTLC 1->2, 1 fails just after it's irrevocably committed
disconnects = ['+WIRE_REVOKE_AND_ACK*3', 'permfail'] disconnects = ['+WIRE_REVOKE_AND_ACK*3', 'permfail']
@ -2063,8 +2063,8 @@ def test_onchain_middleman_simple(node_factory, bitcoind, chainparams, anchors):
coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py') coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py')
opts = {'plugin': coin_mvt_plugin} opts = {'plugin': coin_mvt_plugin}
if anchors: if anchors is False:
opts['experimental-anchors'] = None opts['dev-force-features'] = "-23"
# HTLC 1->2->3, 1->2 goes down after 2 gets preimage from 3. # HTLC 1->2->3, 1->2 goes down after 2 gets preimage from 3.
disconnects = ['-WIRE_UPDATE_FULFILL_HTLC', 'permfail'] disconnects = ['-WIRE_UPDATE_FULFILL_HTLC', 'permfail']
@ -2198,8 +2198,8 @@ def test_onchain_middleman_their_unilateral_in(node_factory, bitcoind, chainpara
coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py') coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py')
opts = {'plugin': coin_mvt_plugin} opts = {'plugin': coin_mvt_plugin}
if anchors: if anchors is False:
opts['experimental-anchors'] = None opts['dev-force-features'] = "-23"
l1_disconnects = ['=WIRE_UPDATE_FULFILL_HTLC', 'permfail'] l1_disconnects = ['=WIRE_UPDATE_FULFILL_HTLC', 'permfail']
l2_disconnects = ['-WIRE_UPDATE_FULFILL_HTLC'] l2_disconnects = ['-WIRE_UPDATE_FULFILL_HTLC']
@ -2328,8 +2328,8 @@ def test_onchain_their_unilateral_out(node_factory, bitcoind, chainparams, ancho
# We track channel balances, to verify that accounting is ok. # We track channel balances, to verify that accounting is ok.
coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py') coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py')
opts = {'plugin': coin_mvt_plugin} opts = {'plugin': coin_mvt_plugin}
if anchors: if anchors is False:
opts['experimental-anchors'] = None opts['dev-force-features'] = "-23"
disconnects = ['-WIRE_UPDATE_FAIL_HTLC', 'permfail'] disconnects = ['-WIRE_UPDATE_FAIL_HTLC', 'permfail']
@ -3364,8 +3364,8 @@ def test_closing_higherfee(node_factory, bitcoind, executor, anchors):
opts = {'may_reconnect': True, opts = {'may_reconnect': True,
'dev-no-reconnect': None, 'dev-no-reconnect': None,
'feerates': (7500, 7500, 7500, 7500)} 'feerates': (7500, 7500, 7500, 7500)}
if anchors: if anchors is False:
opts['experimental-anchors'] = None opts['dev-force-features'] = "-23"
# We change the feerate before it starts negotiating close, so it aims # We change the feerate before it starts negotiating close, so it aims
# for *higher* than last commit tx. # for *higher* than last commit tx.
@ -3739,10 +3739,8 @@ def test_closing_anchorspend_htlc_tx_rbf(node_factory, bitcoind):
# We want an outstanding HTLC for l1, so it uses anchor to push. # We want an outstanding HTLC for l1, so it uses anchor to push.
# Set feerates to lowball for now. # Set feerates to lowball for now.
l1, l2 = node_factory.line_graph(2, opts=[{'feerates': (1000,) * 4, l1, l2 = node_factory.line_graph(2, opts=[{'feerates': (1000,) * 4,
'experimental-anchors': None,
'min-emergency-msat': 546000}, 'min-emergency-msat': 546000},
{'feerates': (1000,) * 4, {'feerates': (1000,) * 4,
'experimental-anchors': None,
'disconnect': ['-WIRE_UPDATE_FAIL_HTLC']}]) 'disconnect': ['-WIRE_UPDATE_FAIL_HTLC']}])
assert 'anchors_zero_fee_htlc_tx/even' in only_one(l1.rpc.listpeerchannels()['channels'])['channel_type']['names'] assert 'anchors_zero_fee_htlc_tx/even' in only_one(l1.rpc.listpeerchannels()['channels'])['channel_type']['names']
@ -3821,9 +3819,9 @@ def test_closing_anchorspend_htlc_tx_rbf(node_factory, bitcoind):
def test_htlc_no_force_close(node_factory, bitcoind, anchors): def test_htlc_no_force_close(node_factory, bitcoind, anchors):
"""l2<->l3 force closes while an HTLC is in flight from l1, but l2 can't timeout because the feerate has spiked. It should do so anyway.""" """l2<->l3 force closes while an HTLC is in flight from l1, but l2 can't timeout because the feerate has spiked. It should do so anyway."""
opts = [{}, {}, {'disconnect': ['-WIRE_UPDATE_FULFILL_HTLC']}] opts = [{}, {}, {'disconnect': ['-WIRE_UPDATE_FULFILL_HTLC']}]
if anchors: if anchors is False:
for opt in opts: for opt in opts:
opt['experimental-anchors'] = None opt['dev-force-features'] = "-23"
l1, l2, l3 = node_factory.line_graph(3, opts=opts) l1, l2, l3 = node_factory.line_graph(3, opts=opts)
@ -3933,10 +3931,8 @@ def test_closing_minfee(node_factory, bitcoind):
def test_peer_anchor_push(node_factory, bitcoind, executor, chainparams): def test_peer_anchor_push(node_factory, bitcoind, executor, chainparams):
"""Test that we use anchor on peer's commit to CPFP tx""" """Test that we use anchor on peer's commit to CPFP tx"""
l1, l2, l3 = node_factory.line_graph(3, opts=[{}, l1, l2, l3 = node_factory.line_graph(3, opts=[{},
{'experimental-anchors': None, {'min-emergency-msat': 546000},
'min-emergency-msat': 546000}, {'disconnect': ['-WIRE_UPDATE_FULFILL_HTLC']}],
{'experimental-anchors': None,
'disconnect': ['-WIRE_UPDATE_FULFILL_HTLC']}],
wait_for_announce=True) wait_for_announce=True)
# We splinter l2's funds so it's forced to use more than one UTXO to push. # We splinter l2's funds so it's forced to use more than one UTXO to push.

View file

@ -388,9 +388,9 @@ def test_opening_tiny_channel(node_factory, anchors):
{'min-capacity-sat': l2_min_capacity, 'dev-no-reconnect': None}, {'min-capacity-sat': l2_min_capacity, 'dev-no-reconnect': None},
{'min-capacity-sat': l3_min_capacity, 'dev-no-reconnect': None}, {'min-capacity-sat': l3_min_capacity, 'dev-no-reconnect': None},
{'min-capacity-sat': l4_min_capacity, 'dev-no-reconnect': None}] {'min-capacity-sat': l4_min_capacity, 'dev-no-reconnect': None}]
if anchors: if anchors is False:
for opt in opts: for opt in opts:
opt['experimental-anchors'] = None opt['dev-force-features'] = "-23"
l1, l2, l3, l4 = node_factory.get_nodes(4, opts=opts) l1, l2, l3, l4 = node_factory.get_nodes(4, opts=opts)
l1.rpc.connect(l2.info['id'], 'localhost', l2.port) l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
l1.rpc.connect(l3.info['id'], 'localhost', l3.port) l1.rpc.connect(l3.info['id'], 'localhost', l3.port)
@ -2061,8 +2061,8 @@ def test_multifunding_feerates(node_factory, bitcoind, anchors):
commitment_tx_feerate = str(commitment_tx_feerate_int) + 'perkw' commitment_tx_feerate = str(commitment_tx_feerate_int) + 'perkw'
opts = {'log-level': 'debug'} opts = {'log-level': 'debug'}
if anchors: if anchors is False:
opts['experimental-anchors'] = None opts['dev-force-features'] = "-23"
l1, l2, l3 = node_factory.get_nodes(3, opts=opts) l1, l2, l3 = node_factory.get_nodes(3, opts=opts)
l1.fundwallet(1 << 26) l1.fundwallet(1 << 26)
@ -2472,18 +2472,16 @@ def test_fee_limits(node_factory, bitcoind):
if 'anchors_zero_fee_htlc_tx/even' in only_one(l1.rpc.listpeerchannels()['channels'])['channel_type']['names']: if 'anchors_zero_fee_htlc_tx/even' in only_one(l1.rpc.listpeerchannels()['channels'])['channel_type']['names']:
fee = 1255 fee = 1255
range = '2000-75000'
else: else:
fee = 258 fee = 258
range = '1875-75000' l1.daemon.wait_for_log(f'Received WARNING .*: update_fee {fee} outside range 2000-75000')
l1.daemon.wait_for_log(f'Received WARNING .*: update_fee {fee} outside range {range}')
# They hang up on *us* # They hang up on *us*
l1.daemon.wait_for_log('Peer transient failure in CHANNELD_NORMAL: channeld: Owning subdaemon channeld died') l1.daemon.wait_for_log('Peer transient failure in CHANNELD_NORMAL: channeld: Owning subdaemon channeld died')
# Disconnects, but does not error. Make sure it's noted in their status though. # Disconnects, but does not error. Make sure it's noted in their status though.
# FIXME: does not happen for l1! # FIXME: does not happen for l1!
# assert 'update_fee 253 outside range 1875-75000' in only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])['status'][0] # assert 'update_fee 253 outside range 1875-75000' in only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])['status'][0]
assert f'update_fee {fee} outside range {range}' in only_one(l2.rpc.listpeerchannels(l1.info['id'])['channels'])['status'][0] assert f'update_fee {fee} outside range 2000-75000' in only_one(l2.rpc.listpeerchannels(l1.info['id'])['channels'])['status'][0]
assert only_one(l2.rpc.listpeerchannels()['channels'])['feerate']['perkw'] != fee assert only_one(l2.rpc.listpeerchannels()['channels'])['feerate']['perkw'] != fee
# Make l2 accept those fees, and it should recover. # Make l2 accept those fees, and it should recover.
@ -2537,6 +2535,7 @@ def test_fee_limits(node_factory, bitcoind):
l1.rpc.close(chan) l1.rpc.close(chan)
@unittest.skipIf(TEST_NETWORK != 'regtest', 'Assumes anchors')
def test_update_fee_dynamic(node_factory, bitcoind): def test_update_fee_dynamic(node_factory, bitcoind):
# l1 has no fee estimates to start. # l1 has no fee estimates to start.
l1 = node_factory.get_node(options={'log-level': 'io', l1 = node_factory.get_node(options={'log-level': 'io',
@ -2552,8 +2551,14 @@ def test_update_fee_dynamic(node_factory, bitcoind):
with pytest.raises(RpcError, match='Cannot estimate fees'): with pytest.raises(RpcError, match='Cannot estimate fees'):
l1.fundchannel(l2, 10**6) l1.fundchannel(l2, 10**6)
# Explicit feerate works. # Explicit feerate does not work still (doesn't apply for anchors!)
l1.fundchannel(l2, 10**6, feerate='10000perkw') # We could make it, but we need a separate commitment feerate for
# anchors vs non-anchors, so easier after anchors are compulsory.
with pytest.raises(RpcError, match='Cannot estimate fees'):
l1.fundchannel(l2, 10**6, feerate='10000perkw')
l1.set_feerates((2000, 2000, 2000, 2000))
l1.fundchannel(l2, 10**6)
l1.set_feerates((15000, 11000, 7500, 3750)) l1.set_feerates((15000, 11000, 7500, 3750))
@ -2905,18 +2910,11 @@ def test_no_fee_estimate(node_factory, bitcoind, executor):
with pytest.raises(RpcError, match=r'Cannot estimate fees'): with pytest.raises(RpcError, match=r'Cannot estimate fees'):
l1.rpc.fundchannel(l2.info['id'], 10**6, 'slow') l1.rpc.fundchannel(l2.info['id'], 10**6, 'slow')
# Can with manual feerate. # With anchors, not even with manual feerate!
l1.rpc.withdraw(l2.rpc.newaddr()['bech32'], 10000, '1500perkb') l1.rpc.withdraw(l2.rpc.newaddr()['bech32'], 10000, '1500perkb')
l1.rpc.fundchannel(l2.info['id'], 10**6, '2000perkw', minconf=0) if TEST_NETWORK == 'regtest':
with pytest.raises(RpcError, match=r'Cannot estimate fees'):
# Make sure we clean up cahnnel for later attempt. l1.rpc.fundchannel(l2.info['id'], 10**6, '2000perkw', minconf=0)
l1.daemon.wait_for_log('sendrawtx exit 0')
l1.rpc.dev_fail(l2.info['id'])
l1.daemon.wait_for_log('Failing due to dev-fail command')
l1.wait_for_channel_onchain(l2.info['id'])
bitcoind.generate_block(6)
wait_for(lambda: only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])['state'] == 'ONCHAIN')
wait_for(lambda: only_one(l2.rpc.listpeerchannels(l1.info['id'])['channels'])['state'] == 'ONCHAIN')
# But can accept incoming connections. # But can accept incoming connections.
l1.rpc.connect(l2.info['id'], 'localhost', l2.port) l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
@ -3559,10 +3557,17 @@ def test_wumbo_channels(node_factory, bitcoind):
@pytest.mark.openchannel('v2') @pytest.mark.openchannel('v2')
@pytest.mark.parametrize("anchors", [False, True]) @pytest.mark.parametrize("anchors", [False, True])
def test_channel_features(node_factory, bitcoind, anchors): def test_channel_features(node_factory, bitcoind, anchors):
if anchors: if TEST_NETWORK == 'regtest':
opts = {'experimental-anchors': None} if anchors is False:
opts = {'dev-force-features': "-23"}
else:
opts = {}
else: else:
opts = {} # We have to force this ON for elements!
if anchors is False:
opts = {}
else:
opts = {'dev-force-features': "+23"}
l1, l2 = node_factory.line_graph(2, fundchannel=False, opts=opts) l1, l2 = node_factory.line_graph(2, fundchannel=False, opts=opts)
bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['bech32'], 0.1) bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['bech32'], 0.1)

View file

@ -1590,8 +1590,8 @@ def test_ipv4_and_ipv6(node_factory):
def test_feerates(node_factory, anchors): def test_feerates(node_factory, anchors):
opts = {'log-level': 'io', opts = {'log-level': 'io',
'dev-no-fake-fees': True} 'dev-no-fake-fees': True}
if anchors: if anchors is False:
opts['experimental-anchors'] = None opts['dev-force-features'] = "-23"
l1 = node_factory.get_node(options=opts, start=False) l1 = node_factory.get_node(options=opts, start=False)
l1.daemon.rpcproxy.mock_rpc('estimatesmartfee', { l1.daemon.rpcproxy.mock_rpc('estimatesmartfee', {
@ -2043,8 +2043,8 @@ def test_bitcoind_fail_first(node_factory, bitcoind):
def test_bitcoind_feerate_floor(node_factory, bitcoind, anchors): def test_bitcoind_feerate_floor(node_factory, bitcoind, anchors):
"""Don't return a feerate less than minrelaytxfee/mempoolminfee.""" """Don't return a feerate less than minrelaytxfee/mempoolminfee."""
opts = {} opts = {}
if anchors: if anchors is False:
opts['experimental-anchors'] = None opts['dev-force-features'] = "-23"
l1 = node_factory.get_node(options=opts) l1 = node_factory.get_node(options=opts)
assert l1.rpc.feerates('perkb') == { assert l1.rpc.feerates('perkb') == {
@ -2254,6 +2254,7 @@ def test_list_features_only(node_factory):
'option_payment_secret/even', 'option_payment_secret/even',
'option_basic_mpp/odd', 'option_basic_mpp/odd',
'option_support_large_channel/odd', 'option_support_large_channel/odd',
'option_anchors_zero_fee_htlc_tx/odd',
'option_route_blinding/odd', 'option_route_blinding/odd',
'option_shutdown_anysegwit/odd', 'option_shutdown_anysegwit/odd',
'option_channel_type/odd', 'option_channel_type/odd',

View file

@ -22,8 +22,7 @@ def find_next_feerate(node, peer):
@pytest.mark.openchannel('v2') @pytest.mark.openchannel('v2')
def test_queryrates(node_factory, bitcoind): def test_queryrates(node_factory, bitcoind):
opts = {'dev-no-reconnect': None, opts = {'dev-no-reconnect': None}
'experimental-anchors': None}
l1, l2 = node_factory.get_nodes(2, opts=opts) l1, l2 = node_factory.get_nodes(2, opts=opts)
@ -581,7 +580,6 @@ def test_v2_rbf_liquidity_ad(node_factory, bitcoind, chainparams):
opts = {'funder-policy': 'match', 'funder-policy-mod': 100, opts = {'funder-policy': 'match', 'funder-policy-mod': 100,
'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100, 'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100,
'experimental-anchors': None,
'may_reconnect': True} 'may_reconnect': True}
l1, l2 = node_factory.get_nodes(2, opts=opts) l1, l2 = node_factory.get_nodes(2, opts=opts)
@ -1554,13 +1552,11 @@ def test_inflight_dbload(node_factory, bitcoind):
disconnects = ["@WIRE_COMMITMENT_SIGNED"] disconnects = ["@WIRE_COMMITMENT_SIGNED"]
opts = [{'experimental-dual-fund': None, 'dev-no-reconnect': None, opts = [{'experimental-dual-fund': None, 'dev-no-reconnect': None,
'may_reconnect': True, 'disconnect': disconnects, 'may_reconnect': True, 'disconnect': disconnects},
'experimental-anchors': None},
{'experimental-dual-fund': None, 'dev-no-reconnect': None, {'experimental-dual-fund': None, 'dev-no-reconnect': None,
'may_reconnect': True, 'funder-policy': 'match', 'may_reconnect': True, 'funder-policy': 'match',
'funder-policy-mod': 100, 'lease-fee-base-sat': '100sat', 'funder-policy-mod': 100, 'lease-fee-base-sat': '100sat',
'lease-fee-basis': 100, 'lease-fee-basis': 100}]
'experimental-anchors': None}]
l1, l2 = node_factory.get_nodes(2, opts=opts) l1, l2 = node_factory.get_nodes(2, opts=opts)
@ -1657,8 +1653,12 @@ def test_zeroconf_open(bitcoind, node_factory):
# and use their own mindepth=6, while l2 uses mindepth=2 from the # and use their own mindepth=6, while l2 uses mindepth=2 from the
# plugin # plugin
ret = l1.rpc.fundchannel(l2.info['id'], 'all', mindepth=0) ret = l1.rpc.fundchannel(l2.info['id'], 'all', mindepth=0)
assert ret['channel_type'] == {'bits': [12, 50], 'names': ['static_remotekey/even', 'zeroconf/even']} if TEST_NETWORK == 'regtest':
assert only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])['channel_type'] == {'bits': [12, 50], 'names': ['static_remotekey/even', 'zeroconf/even']} channel_type = {'bits': [12, 22, 50], 'names': ['static_remotekey/even', 'anchors_zero_fee_htlc_tx/even', 'zeroconf/even']}
else:
channel_type = {'bits': [12, 50], 'names': ['static_remotekey/even', 'zeroconf/even']}
assert ret['channel_type'] == channel_type
assert only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])['channel_type'] == channel_type
assert l1.db.query('SELECT minimum_depth FROM channels WHERE minimum_depth != 1') == [{'minimum_depth': 0}] assert l1.db.query('SELECT minimum_depth FROM channels WHERE minimum_depth != 1') == [{'minimum_depth': 0}]
assert l2.db.query('SELECT minimum_depth FROM channels') == [{'minimum_depth': 0}] assert l2.db.query('SELECT minimum_depth FROM channels') == [{'minimum_depth': 0}]
@ -1737,7 +1737,7 @@ def test_zeroconf_public(bitcoind, node_factory, chainparams):
assert('short_channel_id' not in l2chan) assert('short_channel_id' not in l2chan)
# Channel is "proposed" # Channel is "proposed"
chan_val = 993888000 if chainparams['elements'] else 996363000 chan_val = 993888000 if chainparams['elements'] else 970073000
l1_mvts = [ l1_mvts = [
{'type': 'chain_mvt', 'credit_msat': chan_val, 'debit_msat': 0, 'tags': ['channel_proposed', 'opener']}, {'type': 'chain_mvt', 'credit_msat': chan_val, 'debit_msat': 0, 'tags': ['channel_proposed', 'opener']},
{'type': 'channel_mvt', 'credit_msat': 0, 'debit_msat': 20000000, 'tags': ['pushed'], 'fees_msat': '0msat'}, {'type': 'channel_mvt', 'credit_msat': 0, 'debit_msat': 20000000, 'tags': ['pushed'], 'fees_msat': '0msat'},
@ -1875,12 +1875,10 @@ def test_v2_replay_bookkeeping(node_factory, bitcoind):
opts = [{'funder-policy': 'match', 'funder-policy-mod': 100, opts = [{'funder-policy': 'match', 'funder-policy-mod': 100,
'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100, 'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100,
'rescan': 10, 'funding-confirms': 6, 'may_reconnect': True, 'rescan': 10, 'funding-confirms': 6, 'may_reconnect': True},
'experimental-anchors': None},
{'funder-policy': 'match', 'funder-policy-mod': 100, {'funder-policy': 'match', 'funder-policy-mod': 100,
'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100, 'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100,
'may_reconnect': True, 'may_reconnect': True}]
'experimental-anchors': None}]
l1, l2, = node_factory.get_nodes(2, opts=opts) l1, l2, = node_factory.get_nodes(2, opts=opts)
amount = 500000 amount = 500000
@ -1938,12 +1936,10 @@ def test_buy_liquidity_ad_check_bookkeeping(node_factory, bitcoind):
opts = [{'funder-policy': 'match', 'funder-policy-mod': 100, opts = [{'funder-policy': 'match', 'funder-policy-mod': 100,
'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100, 'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100,
'rescan': 10, 'disable-plugin': 'bookkeeper', 'rescan': 10, 'disable-plugin': 'bookkeeper',
'funding-confirms': 6, 'may_reconnect': True, 'funding-confirms': 6, 'may_reconnect': True},
'experimental-anchors': None},
{'funder-policy': 'match', 'funder-policy-mod': 100, {'funder-policy': 'match', 'funder-policy-mod': 100,
'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100, 'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100,
'may_reconnect': True, 'may_reconnect': True}]
'experimental-anchors': None}]
l1, l2, = node_factory.get_nodes(2, opts=opts) l1, l2, = node_factory.get_nodes(2, opts=opts)
amount = 500000 amount = 500000
@ -2434,7 +2430,7 @@ def test_no_anchor_liquidity_ads(node_factory, bitcoind):
'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100, 'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100,
'may_reconnect': True, 'funder-lease-requests-only': False} 'may_reconnect': True, 'funder-lease-requests-only': False}
l1_opts = l2_opts.copy() l1_opts = l2_opts.copy()
l1_opts['experimental-anchors'] = None l2_opts['dev-no-anchors'] = None
l1, l2 = node_factory.get_nodes(2, opts=[l1_opts, l2_opts]) l1, l2 = node_factory.get_nodes(2, opts=[l1_opts, l2_opts])
feerate = 2000 feerate = 2000
@ -2465,8 +2461,8 @@ def test_no_anchor_liquidity_ads(node_factory, bitcoind):
@pytest.mark.parametrize("anchors", [False, True]) @pytest.mark.parametrize("anchors", [False, True])
def test_commitment_feerate(bitcoind, node_factory, anchors): def test_commitment_feerate(bitcoind, node_factory, anchors):
opts = {} opts = {}
if anchors: if anchors is False:
opts['experimental-anchors'] = None opts['dev-force-features'] = "-23"
l1, l2 = node_factory.get_nodes(2, opts=opts) l1, l2 = node_factory.get_nodes(2, opts=opts)
@ -2516,8 +2512,7 @@ def test_commitment_feerate(bitcoind, node_factory, anchors):
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd has different tx costs') @unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd has different tx costs')
def test_anchor_min_emergency(bitcoind, node_factory): def test_anchor_min_emergency(bitcoind, node_factory):
l1, l2 = node_factory.line_graph(2, opts={'experimental-anchors': None}, l1, l2 = node_factory.line_graph(2, fundchannel=False)
fundchannel=False)
addr = l1.rpc.newaddr()['bech32'] addr = l1.rpc.newaddr()['bech32']
bitcoind.rpc.sendtoaddress(addr, 5000000 / 10**8) bitcoind.rpc.sendtoaddress(addr, 5000000 / 10**8)

View file

@ -755,8 +755,8 @@ def test_wait_sendpay(node_factory, executor):
def test_sendpay_cant_afford(node_factory, anchors): def test_sendpay_cant_afford(node_factory, anchors):
# Set feerates the same so we don't have to wait for update. # Set feerates the same so we don't have to wait for update.
opts = {'feerates': (15000, 15000, 15000, 15000)} opts = {'feerates': (15000, 15000, 15000, 15000)}
if anchors: if anchors is False:
opts['experimental-anchors'] = None opts['dev-force-features'] = "-23"
l1, l2 = node_factory.line_graph(2, fundamount=10**6, opts=opts) l1, l2 = node_factory.line_graph(2, fundamount=10**6, opts=opts)
@ -2686,17 +2686,16 @@ def test_lockup_drain(node_factory, bitcoind):
l2.pay(l1, total // 2) l2.pay(l1, total // 2)
@unittest.skipIf(TEST_NETWORK != 'regtest', 'Assumes anchors')
def test_htlc_too_dusty_outgoing(node_factory, bitcoind, chainparams): def test_htlc_too_dusty_outgoing(node_factory, bitcoind, chainparams):
""" Try to hit the 'too much dust' limit, should fail the HTLC """ """ Try to hit the 'too much dust' limit, should fail the HTLC """
feerate = 10000
# elements txs are bigger so they become dusty faster # elements txs are bigger so they become dusty faster
max_dust_limit_sat = 100000 if chainparams['elements'] else 50000 max_dust_limit_sat = 1000 if chainparams['elements'] else 500
non_dust_htlc_val_sat = 20000 if chainparams['elements'] else 10000 non_dust_htlc_val_sat = 2000 if chainparams['elements'] else 1000
htlc_val_sat = 10000 if chainparams['elements'] else 5000 htlc_val_sat = 250
l1, l2 = node_factory.line_graph(2, opts={'may_reconnect': True, l1, l2 = node_factory.line_graph(2, opts={'may_reconnect': True,
'feerates': (feerate, feerate, feerate, feerate),
'max-dust-htlc-exposure-msat': '{}sat'.format(max_dust_limit_sat), 'max-dust-htlc-exposure-msat': '{}sat'.format(max_dust_limit_sat),
'allow_warning': True}) 'allow_warning': True})

View file

@ -43,6 +43,9 @@ def expected_peer_features(extra=[]):
if EXPERIMENTAL_SPLICING: if EXPERIMENTAL_SPLICING:
features += [35] # option_quiesce features += [35] # option_quiesce
features += [163] # option_experimental_splice features += [163] # option_experimental_splice
if TEST_NETWORK != 'liquid-regtest':
# Anchors, except for elements
features += [23]
return hex_bits(features + extra) return hex_bits(features + extra)
@ -57,6 +60,9 @@ def expected_node_features(extra=[]):
if EXPERIMENTAL_SPLICING: if EXPERIMENTAL_SPLICING:
features += [35] # option_quiesce features += [35] # option_quiesce
features += [163] # option_experimental_splice features += [163] # option_experimental_splice
if TEST_NETWORK != 'liquid-regtest':
# Anchors, except for elements
features += [23]
return hex_bits(features + extra) return hex_bits(features + extra)