developer: consolidiate gossip timing options into one --dev-fast-gossip.

It's generally clearer to have simple hardcoded numbers with an
#if DEVELOPER around it, than apparent variables which aren't, really.

Interestingly, our pruning test was always kinda broken: we have to pass
two cycles, since l2 will refresh the channel once to avoid pruning.

Do the more obvious thing, and cut the network in half and check that
l1 and l3 time out.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-09-18 10:35:05 +09:30
parent 8139164aa0
commit 147eaced2e
33 changed files with 138 additions and 149 deletions

View File

@@ -478,12 +478,10 @@ void peer_start_channeld(struct channel *channel,
channel->remote_upfront_shutdown_script,
remote_ann_node_sig,
remote_ann_bitcoin_sig,
/* Delay announce by 60 seconds after
* seeing block (adjustable if dev) */
ld->topology->poll_seconds * 2,
/* Set at channel open, even if not
* negotiated now! */
channel->option_static_remotekey);
channel->option_static_remotekey,
IFDEV(ld->dev_fast_gossip, false));
/* We don't expect a response: we are triggered by funding_depth_cb. */
subd_send_msg(channel->owner, take(initmsg));

View File

@@ -288,7 +288,13 @@ void peer_start_closingd(struct channel *channel,
channel_reestablish,
p2wpkh_for_keyidx(tmpctx, ld,
channel->final_key_idx),
&last_remote_per_commit_secret);
&last_remote_per_commit_secret,
#if DEVELOPER
ld->dev_fast_gossip
#else
false
#endif
);
/* We don't expect a response: it will give us feedback on
* signatures sent and received, then closing_complete. */

View File

@@ -195,11 +195,10 @@ void gossip_init(struct lightningd *ld, int connectd_fd)
&get_chainparams(ld)->genesis_blockhash, &ld->id,
get_offered_globalfeatures(tmpctx),
ld->rgb,
ld->alias, ld->config.channel_update_interval,
/* gossip_min_interval: 5x the broadcast interval */
ld->config.broadcast_interval_msec / 200,
ld->alias,
ld->announcable,
IFDEV(ld->dev_gossip_time ? &ld->dev_gossip_time: NULL, NULL));
IFDEV(ld->dev_gossip_time ? &ld->dev_gossip_time: NULL, NULL),
IFDEV(ld->dev_fast_gossip, false));
subd_send_msg(ld->gossip, msg);
}

View File

@@ -118,6 +118,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
ld->dev_subdaemon_fail = false;
ld->dev_allow_localhost = false;
ld->dev_gossip_time = 0;
ld->dev_fast_gossip = false;
ld->dev_force_privkey = NULL;
ld->dev_force_bip32_seed = NULL;
ld->dev_force_channel_secrets = NULL;

View File

@@ -48,12 +48,6 @@ struct config {
/* How long between changing commit and sending COMMIT message. */
u32 commit_time_ms;
/* How often to broadcast gossip (msec) */
u32 broadcast_interval_msec;
/* Channel update interval */
u32 channel_update_interval;
/* Do we let the funder set any fee rate they want */
bool ignore_fee_limits;
@@ -207,6 +201,9 @@ struct lightningd {
/* Timestamp to use for gossipd, iff non-zero */
u32 dev_gossip_time;
/* Speedup gossip propagation, for testing. */
bool dev_fast_gossip;
/* Things we've marked as not leaking. */
const void **notleaks;

View File

@@ -949,7 +949,8 @@ void peer_start_openingd(struct peer *peer,
peer->localfeatures,
local_feature_negotiated(peer->localfeatures,
LOCAL_STATIC_REMOTEKEY),
send_msg);
send_msg,
IFDEV(peer->ld->dev_fast_gossip, false));
subd_send_msg(uc->openingd, take(msg));
}

View File

@@ -398,9 +398,6 @@ static void dev_register_opts(struct lightningd *ld)
"Disable automatic reconnect-attempts by this node, but accept incoming");
opt_register_noarg("--dev-fail-on-subdaemon-fail", opt_set_bool,
&ld->dev_subdaemon_fail, opt_hidden);
opt_register_arg("--dev-broadcast-interval=<ms>", opt_set_uintval,
opt_show_uintval, &ld->config.broadcast_interval_msec,
"Time between gossip broadcasts in milliseconds");
opt_register_arg("--dev-disconnect=<filename>", opt_subd_dev_disconnect,
NULL, ld, "File containing disconnection points");
opt_register_noarg("--dev-allow-localhost", opt_set_bool,
@@ -417,10 +414,9 @@ static void dev_register_opts(struct lightningd *ld)
"fee fluctuations, large values may result in large "
"fees.");
opt_register_arg(
"--dev-channel-update-interval=<s>", opt_set_u32, opt_show_u32,
&ld->config.channel_update_interval,
"Time in seconds between channel updates for our own channels.");
opt_register_noarg("--dev-fast-gossip", opt_set_bool,
&ld->dev_fast_gossip,
"Make gossip broadcast 1 second, pruning 14 seconds");
opt_register_arg("--dev-gossip-time", opt_set_u32, opt_show_u32,
&ld->dev_gossip_time,
@@ -473,16 +469,6 @@ static const struct config testnet_config = {
/* Take 0.001% */
.fee_per_satoshi = 10,
/* BOLT #7:
*
* - SHOULD flush outgoing gossip messages once every 60
* seconds, independently of the arrival times of the messages.
*/
.broadcast_interval_msec = 60000,
/* Send a keepalive update at least every week, prune every twice that */
.channel_update_interval = 1209600/2,
/* Testnet sucks */
.ignore_fee_limits = true,
@@ -542,16 +528,6 @@ static const struct config mainnet_config = {
/* Take 0.001% */
.fee_per_satoshi = 10,
/* BOLT #7:
*
* - SHOULD flush outgoing gossip messages once every 60
* seconds, independently of the arrival times of the messages.
*/
.broadcast_interval_msec = 60000,
/* Send a keepalive update at least every week, prune every twice that */
.channel_update_interval = 1209600/2,
/* Mainnet should have more stable fees */
.ignore_fee_limits = false,

View File

@@ -937,12 +937,6 @@ void peer_connected(struct lightningd *ld, const u8 *msg,
fatal("Connectd gave bad CONNECT_PEER_CONNECTED message %s",
tal_hex(msg, msg));
#if DEVELOPER
/* Override broaedcast interval from our config */
hook_payload->pps->dev_gossip_broadcast_msec
= ld->config.broadcast_interval_msec;
#endif
per_peer_state_set_fds(hook_payload->pps,
peer_fd, gossip_fd, gossip_store_fd);