mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 13:25:43 +01:00
lightningd: --dev-low-prio-anchor-blocks and test for low-priority anchors.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
de30f9c4b2
commit
20257c3308
@ -219,7 +219,7 @@ struct anchor_details *create_anchor_details(const tal_t *ctx,
|
||||
final_deadline = adet->vals[tal_count(adet->vals) - 1].block;
|
||||
|
||||
/* "Two weeks later" */
|
||||
v.block = final_deadline + 2016;
|
||||
v.block = final_deadline + ld->dev_low_prio_anchor_blocks;
|
||||
v.msat = AMOUNT_MSAT(0);
|
||||
v.important = false;
|
||||
tal_arr_expand(&adet->vals, v);
|
||||
|
@ -143,6 +143,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
|
||||
ld->dev_no_htlc_timeout = false;
|
||||
ld->dev_no_version_checks = false;
|
||||
ld->dev_max_funding_unconfirmed = 2016;
|
||||
ld->dev_low_prio_anchor_blocks = 2016;
|
||||
ld->dev_ignore_modern_onion = false;
|
||||
ld->dev_disable_commit = -1;
|
||||
ld->dev_no_ping_timer = false;
|
||||
|
@ -307,6 +307,9 @@ struct lightningd {
|
||||
bool dev_throttle_gossip;
|
||||
bool dev_suppress_gossip;
|
||||
|
||||
/* How long to aim for low-priority commitment closes */
|
||||
u32 dev_low_prio_anchor_blocks;
|
||||
|
||||
/* Speedup reconnect delay, for testing. */
|
||||
bool dev_fast_reconnect;
|
||||
|
||||
|
@ -969,15 +969,19 @@ static void dev_register_opts(struct lightningd *ld)
|
||||
opt_set_bool,
|
||||
&ld->dev_limit_connections_inflight,
|
||||
"Throttle connection limiting down for testing.");
|
||||
clnopt_witharg("--autoconnect-seeker-peers", OPT_SHOWINT,
|
||||
opt_set_u32, opt_show_u32,
|
||||
&ld->autoconnect_seeker_peers,
|
||||
"Seeker autoconnects to maintain this minimum number of gossip peers");
|
||||
clnopt_witharg("--dev-low-prio-anchor-blocks", OPT_DEV|OPT_SHOWINT,
|
||||
opt_set_u32, opt_show_u32,
|
||||
&ld->dev_low_prio_anchor_blocks,
|
||||
"How many blocks to aim for low-priority anchor closes (default: 2016)");
|
||||
/* This is handled directly in daemon_developer_mode(), so we ignore it here */
|
||||
clnopt_noarg("--dev-debug-self", OPT_DEV,
|
||||
opt_ignore,
|
||||
NULL,
|
||||
"Fire up a terminal window with a debugger in it on initialization");
|
||||
clnopt_witharg("--autoconnect-seeker-peers", OPT_SHOWINT,
|
||||
opt_set_u32, opt_show_u32,
|
||||
&ld->autoconnect_seeker_peers,
|
||||
"Seeker autoconnects to maintain this minimum number of gossip peers");
|
||||
}
|
||||
|
||||
static const struct config testnet_config = {
|
||||
|
@ -4219,3 +4219,32 @@ def test_onchain_slow_anchor(node_factory, bitcoind):
|
||||
|
||||
# We will have a super-low-prio anchor spend.
|
||||
l1.daemon.wait_for_log(r"Low-priority anchorspend aiming for block {} \(feerate 253\)".format(close_start_depth + 2016))
|
||||
|
||||
# Restart with reduced block time.
|
||||
l1.stop()
|
||||
l1.daemon.opts['dev-low-prio-anchor-blocks'] = 20
|
||||
l1.start()
|
||||
|
||||
l1.daemon.wait_for_log("Low-priority anchorspend aiming for block {}".format(close_start_depth + 20))
|
||||
l1.daemon.wait_for_log("Anchorspend for local commit tx")
|
||||
|
||||
# Won't go under 12 blocks though.
|
||||
|
||||
# Make sure it sees all these blocks at once, to avoid test flakes!
|
||||
l1.stop()
|
||||
bitcoind.generate_block(7)
|
||||
l1.start()
|
||||
|
||||
height = bitcoind.rpc.getblockchaininfo()['blocks']
|
||||
l1.daemon.wait_for_log(r"Low-priority anchorspend aiming for block {} \(feerate 7458\)".format(height + 13))
|
||||
l1.daemon.wait_for_log(r"Anchorspend for local commit tx fee 12335sat \(w=714\), commit_tx fee 4545sat \(w=768\): package feerate 11390 perkw")
|
||||
assert not l1.daemon.is_in_log("Low-priority anchorspend aiming for block {}".format(height + 12))
|
||||
|
||||
bitcoind.generate_block(1)
|
||||
height = bitcoind.rpc.getblockchaininfo()['blocks']
|
||||
l1.daemon.wait_for_log(r"Low-priority anchorspend aiming for block {} \(feerate 7500\)".format(height + 12))
|
||||
# Note: fee is too similar, so won't try to RBF, so no "Anchorspend for local commit tx"
|
||||
|
||||
bitcoind.generate_block(1)
|
||||
height = bitcoind.rpc.getblockchaininfo()['blocks']
|
||||
l1.daemon.wait_for_log(r"Low-priority anchorspend aiming for block {} \(feerate 7500\)".format(height + 12))
|
||||
|
Loading…
Reference in New Issue
Block a user