Browse Source

gossipd: remove unnecessary dev_unknown_channel_satoshis arg.

We now have a test blockchain for MCP which has the correct channels,
so this is not needed.

Also fix a benchmark script bug where 'mv "$DIR"/log
"$DIR"/log.old.$$' would fail if you log didn't exist from a previous run.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
htlc_accepted_hook
Rusty Russell 6 years ago
parent
commit
cb9c44ef27
  1. 1
      gossipd/gossip_wire.csv
  2. 7
      gossipd/gossipd.c
  3. 14
      gossipd/routing.c
  4. 7
      gossipd/routing.h
  5. 2
      gossipd/test/run-bench-find_route.c
  6. 2
      gossipd/test/run-find_route-specific.c
  7. 2
      gossipd/test/run-find_route.c
  8. 2
      gossipd/test/run-overlong.c
  9. 4
      lightningd/gossip_control.c
  10. 1
      lightningd/lightningd.c
  11. 3
      lightningd/lightningd.h
  12. 14
      lightningd/options.c
  13. 6
      tools/bench-gossipd.sh

1
gossipd/gossip_wire.csv

@ -15,7 +15,6 @@ gossipctl_init,,update_channel_interval,u32
gossipctl_init,,num_announcable,u16 gossipctl_init,,num_announcable,u16
gossipctl_init,,announcable,num_announcable*struct wireaddr gossipctl_init,,announcable,num_announcable*struct wireaddr
gossipctl_init,,dev_gossip_time,?u32 gossipctl_init,,dev_gossip_time,?u32
gossipctl_init,,dev_unknown_channel_satoshis,?struct amount_sat
# Pass JSON-RPC getnodes call through # Pass JSON-RPC getnodes call through
gossip_getnodes_request,3005 gossip_getnodes_request,3005

Can't render this file because it has a wrong number of fields in line 6.

7
gossipd/gossipd.c

@ -1976,7 +1976,6 @@ static struct io_plan *gossip_init(struct io_conn *conn,
{ {
u32 update_channel_interval; u32 update_channel_interval;
u32 *dev_gossip_time; u32 *dev_gossip_time;
struct amount_sat *dev_unknown_channel_satoshis;
if (!fromwire_gossipctl_init(daemon, msg, if (!fromwire_gossipctl_init(daemon, msg,
/* 60,000 ms /* 60,000 ms
@ -1990,8 +1989,7 @@ static struct io_plan *gossip_init(struct io_conn *conn,
* (unless --dev-channel-update-interval) */ * (unless --dev-channel-update-interval) */
&update_channel_interval, &update_channel_interval,
&daemon->announcable, &daemon->announcable,
&dev_gossip_time, &dev_gossip_time)) {
&dev_unknown_channel_satoshis)) {
master_badmsg(WIRE_GOSSIPCTL_INIT, msg); master_badmsg(WIRE_GOSSIPCTL_INIT, msg);
} }
@ -2001,8 +1999,7 @@ static struct io_plan *gossip_init(struct io_conn *conn,
&daemon->id, &daemon->id,
update_channel_interval * 2, update_channel_interval * 2,
&daemon->peers, &daemon->peers,
dev_gossip_time, dev_gossip_time);
dev_unknown_channel_satoshis);
/* Load stored gossip messages */ /* Load stored gossip messages */
gossip_store_load(daemon->rstate, daemon->rstate->broadcasts->gs); gossip_store_load(daemon->rstate, daemon->rstate->broadcasts->gs);

14
gossipd/routing.c

@ -159,8 +159,7 @@ struct routing_state *new_routing_state(const tal_t *ctx,
const struct node_id *local_id, const struct node_id *local_id,
u32 prune_timeout, u32 prune_timeout,
struct list_head *peers, struct list_head *peers,
const u32 *dev_gossip_time, const u32 *dev_gossip_time)
const struct amount_sat *dev_unknown_channel_satoshis)
{ {
struct routing_state *rstate = tal(ctx, struct routing_state); struct routing_state *rstate = tal(ctx, struct routing_state);
rstate->nodes = new_node_map(rstate); rstate->nodes = new_node_map(rstate);
@ -188,7 +187,6 @@ struct routing_state *new_routing_state(const tal_t *ctx,
rstate->gossip_time->ts.tv_nsec = 0; rstate->gossip_time->ts.tv_nsec = 0;
} else } else
rstate->gossip_time = NULL; rstate->gossip_time = NULL;
rstate->dev_unknown_channel_satoshis = dev_unknown_channel_satoshis;
#endif #endif
return rstate; return rstate;
@ -1615,16 +1613,6 @@ void handle_pending_cannouncement(struct routing_state *rstate,
if (!pending) if (!pending)
return; return;
#if DEVELOPER
if (rstate->dev_unknown_channel_satoshis) {
outscript = scriptpubkey_p2wsh(pending,
bitcoin_redeem_2of2(pending,
&pending->bitcoin_key_1,
&pending->bitcoin_key_2));
sat = *rstate->dev_unknown_channel_satoshis;
}
#endif
/* BOLT #7: /* BOLT #7:
* *
* The receiving node: * The receiving node:

7
gossipd/routing.h

@ -244,10 +244,6 @@ struct routing_state {
#if DEVELOPER #if DEVELOPER
/* Override local time for gossip messages */ /* Override local time for gossip messages */
struct timeabs *gossip_time; struct timeabs *gossip_time;
/* Instead of ignoring unknown channels, pretend they're valid
* with this many satoshis (if non-NULL) */
const struct amount_sat *dev_unknown_channel_satoshis;
#endif #endif
}; };
@ -271,8 +267,7 @@ struct routing_state *new_routing_state(const tal_t *ctx,
const struct node_id *local_id, const struct node_id *local_id,
u32 prune_timeout, u32 prune_timeout,
struct list_head *peers, struct list_head *peers,
const u32 *dev_gossip_time, const u32 *dev_gossip_time);
const struct amount_sat *dev_unknown_channel_satoshis);
/** /**
* Add a new bidirectional channel from id1 to id2 with the given * Add a new bidirectional channel from id1 to id2 with the given

2
gossipd/test/run-bench-find_route.c

@ -217,7 +217,7 @@ int main(int argc, char *argv[])
setup_tmpctx(); setup_tmpctx();
me = nodeid(0); me = nodeid(0);
rstate = new_routing_state(tmpctx, NULL, &me, 0, NULL, NULL, NULL); rstate = new_routing_state(tmpctx, NULL, &me, 0, NULL, NULL);
opt_register_noarg("--perfme", opt_set_bool, &perfme, opt_register_noarg("--perfme", opt_set_bool, &perfme,
"Run perfme-start and perfme-stop around benchmark"); "Run perfme-start and perfme-stop around benchmark");

2
gossipd/test/run-find_route-specific.c

@ -174,7 +174,7 @@ int main(void)
strlen("02cca6c5c966fcf61d121e3a70e03a1cd9eeeea024b26ea666ce974d43b242e636"), strlen("02cca6c5c966fcf61d121e3a70e03a1cd9eeeea024b26ea666ce974d43b242e636"),
&d); &d);
rstate = new_routing_state(tmpctx, NULL, &a, 0, NULL, NULL, NULL); rstate = new_routing_state(tmpctx, NULL, &a, 0, NULL, NULL);
/* [{'active': True, 'short_id': '6990:2:1/1', 'fee_per_kw': 10, 'delay': 5, 'message_flags': 0, 'channel_flags': 1, 'destination': '0230ad0e74ea03976b28fda587bb75bdd357a1938af4424156a18265167f5e40ae', 'source': '02ea622d5c8d6143f15ed3ce1d501dd0d3d09d3b1c83a44d0034949f8a9ab60f06', 'last_update': 1504064344}, */ /* [{'active': True, 'short_id': '6990:2:1/1', 'fee_per_kw': 10, 'delay': 5, 'message_flags': 0, 'channel_flags': 1, 'destination': '0230ad0e74ea03976b28fda587bb75bdd357a1938af4424156a18265167f5e40ae', 'source': '02ea622d5c8d6143f15ed3ce1d501dd0d3d09d3b1c83a44d0034949f8a9ab60f06', 'last_update': 1504064344}, */

2
gossipd/test/run-find_route.c

@ -208,7 +208,7 @@ int main(void)
memset(&tmp, 'a', sizeof(tmp)); memset(&tmp, 'a', sizeof(tmp));
node_id_from_privkey(&tmp, &a); node_id_from_privkey(&tmp, &a);
rstate = new_routing_state(tmpctx, NULL, &a, 0, NULL, NULL, NULL); rstate = new_routing_state(tmpctx, NULL, &a, 0, NULL, NULL);
new_node(rstate, &a); new_node(rstate, &a);

2
gossipd/test/run-overlong.c

@ -132,7 +132,7 @@ int main(void)
node_id_from_privkey(&tmp, &ids[i]); node_id_from_privkey(&tmp, &ids[i]);
} }
/* We are node 0 */ /* We are node 0 */
rstate = new_routing_state(tmpctx, NULL, &ids[0], 0, NULL, NULL, NULL); rstate = new_routing_state(tmpctx, NULL, &ids[0], 0, NULL, NULL);
for (size_t i = 0; i < NUM_NODES; i++) { for (size_t i = 0; i < NUM_NODES; i++) {
struct chan *chan; struct chan *chan;

4
lightningd/gossip_control.c

@ -168,10 +168,8 @@ void gossip_init(struct lightningd *ld, int connectd_fd)
ld->alias, ld->config.channel_update_interval, ld->alias, ld->config.channel_update_interval,
ld->announcable, ld->announcable,
#if DEVELOPER #if DEVELOPER
ld->dev_gossip_time ? &ld->dev_gossip_time: NULL, ld->dev_gossip_time ? &ld->dev_gossip_time: NULL
ld->dev_unknown_channel_satoshis
#else #else
NULL,
NULL NULL
#endif #endif
); );

1
lightningd/lightningd.c

@ -117,7 +117,6 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
ld->dev_subdaemon_fail = false; ld->dev_subdaemon_fail = false;
ld->dev_allow_localhost = false; ld->dev_allow_localhost = false;
ld->dev_gossip_time = 0; ld->dev_gossip_time = 0;
ld->dev_unknown_channel_satoshis = NULL;
#endif #endif
/*~ These are CCAN lists: an embedded double-linked list. It's not /*~ These are CCAN lists: an embedded double-linked list. It's not

3
lightningd/lightningd.h

@ -198,9 +198,6 @@ struct lightningd {
/* Timestamp to use for gossipd, iff non-zero */ /* Timestamp to use for gossipd, iff non-zero */
u32 dev_gossip_time; u32 dev_gossip_time;
/* What to override unknown channels with, iff non-NULL */
struct amount_sat *dev_unknown_channel_satoshis;
/* Things we've marked as not leaking. */ /* Things we've marked as not leaking. */
const void **notleaks; const void **notleaks;
#endif /* DEVELOPER */ #endif /* DEVELOPER */

14
lightningd/options.c

@ -438,15 +438,6 @@ static char *opt_subprocess_debug(const char *optarg, struct lightningd *ld)
return NULL; return NULL;
} }
static char *opt_set_dev_unknown_channel_satoshis(const char *optarg,
struct lightningd *ld)
{
tal_free(ld->dev_unknown_channel_satoshis);
ld->dev_unknown_channel_satoshis = tal(ld, struct amount_sat);
return opt_set_u64(optarg,
&ld->dev_unknown_channel_satoshis->satoshis); /* Raw: dev code */
}
static void dev_register_opts(struct lightningd *ld) static void dev_register_opts(struct lightningd *ld)
{ {
opt_register_noarg("--dev-no-reconnect", opt_set_invbool, opt_register_noarg("--dev-no-reconnect", opt_set_invbool,
@ -483,10 +474,7 @@ static void dev_register_opts(struct lightningd *ld)
opt_register_arg("--dev-gossip-time", opt_set_u32, opt_show_u32, opt_register_arg("--dev-gossip-time", opt_set_u32, opt_show_u32,
&ld->dev_gossip_time, &ld->dev_gossip_time,
"UNIX time to override gossipd to use."); "UNIX time to override gossipd to use.");
opt_register_arg("--dev-unknown-channel-satoshis", }
opt_set_dev_unknown_channel_satoshis, NULL, ld,
"Amount to pretend is in channels which we can't find funding tx for.");
}
#endif #endif
static const struct config testnet_config = { static const struct config testnet_config = {

6
tools/bench-gossipd.sh

@ -81,7 +81,7 @@ fi
DEVELOPER=$(grep '^DEVELOPER=' config.vars | cut -d= -f2-) DEVELOPER=$(grep '^DEVELOPER=' config.vars | cut -d= -f2-)
if [ "$DEVELOPER" = 1 ]; then if [ "$DEVELOPER" = 1 ]; then
LIGHTNINGD="./lightningd/lightningd --network=regtest --dev-gossip-time=1550513768 --dev-unknown-channel-satoshis=100000" LIGHTNINGD="./lightningd/lightningd --network=regtest --dev-gossip-time=1550513768"
else else
# Means we can't do the peer_read_all test properly, since it will time out. # Means we can't do the peer_read_all test properly, since it will time out.
LIGHTNINGD="./lightningd/lightningd --network=regtest" LIGHTNINGD="./lightningd/lightningd --network=regtest"
@ -100,8 +100,8 @@ if $CSV; then echo $TARGETS | tr ' ' ,; fi
# First, measure load time. # First, measure load time.
rm -f "$DIR"/peer rm -f "$DIR"/peer
mv "$DIR"/log "$DIR"/log.old.$$ [ ! -f "$DIR"/log ] || mv "$DIR"/log "$DIR"/log.old.$$
$LIGHTNINGD --lightning-dir="$DIR" --log-file="$DIR"/log --bind-addr="$DIR"/peer & $LIGHTNINGD --lightning-dir="$DIR" --log-file="$DIR"/log --log-level=debug --bind-addr="$DIR"/peer &
rm -f "$DIR"/stats rm -f "$DIR"/stats
ID=$(wait_for_start) ID=$(wait_for_start)

Loading…
Cancel
Save