mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-23 15:00:34 +01:00
lightningd: make sure gossipd knows before we update blockheight.
Without this, we can get spurious failures from lnprototest, which is waiting for lightningd to acknowledge the blockheight in getinfo: ``` 2021-12-21T00:56:21.460Z DEBUG lightningd: Adding block 109: 57a7bd3ade3a88a899e5b442075e9722ccec07e0205f9a913b304a3e2e038e26 2021-12-21T00:56:21.470Z DEBUG lightningd: Adding block 110: 11a280eb76f588e92e20c39999be9d2baff016c3c6bac1837b649a270570b7dd 2021-12-21T00:56:21.479Z DEBUG lightningd: Adding block 111: 02977fc9529b2ab4e0a805c4bc1bcfbff5a4e6577a8b31266341d22e204a1d27 2021-12-21T00:56:21.487Z DEBUG lightningd: Adding block 112: 2402f31c5ddfc9e847e8bbfb7df084d29a5d5d936a4358c109f2f4cf9ea8d828 2021-12-21T00:56:21.496Z DEBUG lightningd: Adding block 113: 5a561fe9423b4df33f004fc09985ee3ef38364d692a56a8b27ecbc6098a16d39 2021-12-21T00:56:21.505Z DEBUG lightningd: Adding block 114: 4502f5ec23c89177872846848848322e8fa6c3fb6f5eb361194e4cd47596dfe9 2021-12-21T00:56:21.511Z DEBUG 02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9-gossipd: Ignoring future channel_announcment for 109x1x0 (current block 108) ``` Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
6bfc3d8692
commit
71f736678f
7 changed files with 37 additions and 3 deletions
|
@ -1178,6 +1178,9 @@ static void new_blockheight(struct daemon *daemon, const u8 *msg)
|
||||||
tal_arr_remove(&daemon->deferred_txouts, i);
|
tal_arr_remove(&daemon->deferred_txouts, i);
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
daemon_conn_send(daemon->master,
|
||||||
|
take(towire_gossipd_new_blockheight_reply(NULL)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEVELOPER
|
#if DEVELOPER
|
||||||
|
@ -1499,6 +1502,7 @@ static struct io_plan *recv_req(struct io_conn *conn,
|
||||||
case WIRE_GOSSIPD_DEV_COMPACT_STORE_REPLY:
|
case WIRE_GOSSIPD_DEV_COMPACT_STORE_REPLY:
|
||||||
case WIRE_GOSSIPD_GOT_ONIONMSG_TO_US:
|
case WIRE_GOSSIPD_GOT_ONIONMSG_TO_US:
|
||||||
case WIRE_GOSSIPD_ADDGOSSIP_REPLY:
|
case WIRE_GOSSIPD_ADDGOSSIP_REPLY:
|
||||||
|
case WIRE_GOSSIPD_NEW_BLOCKHEIGHT_REPLY:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,9 @@ msgdata,gossipd_dev_compact_store_reply,success,bool,
|
||||||
msgtype,gossipd_new_blockheight,3026
|
msgtype,gossipd_new_blockheight,3026
|
||||||
msgdata,gossipd_new_blockheight,blockheight,u32,
|
msgdata,gossipd_new_blockheight,blockheight,u32,
|
||||||
|
|
||||||
|
# gossipd: got it!
|
||||||
|
msgtype,gossipd_new_blockheight_reply,3126
|
||||||
|
|
||||||
msgtype,gossipd_got_onionmsg_to_us,3145
|
msgtype,gossipd_got_onionmsg_to_us,3145
|
||||||
msgdata,gossipd_got_onionmsg_to_us,obs2,bool,
|
msgdata,gossipd_got_onionmsg_to_us,obs2,bool,
|
||||||
msgdata,gossipd_got_onionmsg_to_us,node_alias,pubkey,
|
msgdata,gossipd_got_onionmsg_to_us,node_alias,pubkey,
|
||||||
|
|
|
|
@ -338,6 +338,9 @@ u8 *towire_gossipd_got_onionmsg_to_us(const tal_t *ctx UNNEEDED, bool obs2 UNNEE
|
||||||
/* Generated stub for towire_gossipd_init_reply */
|
/* Generated stub for towire_gossipd_init_reply */
|
||||||
u8 *towire_gossipd_init_reply(const tal_t *ctx UNNEEDED)
|
u8 *towire_gossipd_init_reply(const tal_t *ctx UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_gossipd_init_reply called!\n"); abort(); }
|
{ fprintf(stderr, "towire_gossipd_init_reply called!\n"); abort(); }
|
||||||
|
/* Generated stub for towire_gossipd_new_blockheight_reply */
|
||||||
|
u8 *towire_gossipd_new_blockheight_reply(const tal_t *ctx UNNEEDED)
|
||||||
|
{ fprintf(stderr, "towire_gossipd_new_blockheight_reply called!\n"); abort(); }
|
||||||
/* Generated stub for towire_gossipd_new_peer_reply */
|
/* Generated stub for towire_gossipd_new_peer_reply */
|
||||||
u8 *towire_gossipd_new_peer_reply(const tal_t *ctx UNNEEDED, bool success UNNEEDED, const struct gossip_state *gs UNNEEDED)
|
u8 *towire_gossipd_new_peer_reply(const tal_t *ctx UNNEEDED, bool success UNNEEDED, const struct gossip_state *gs UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_gossipd_new_peer_reply called!\n"); abort(); }
|
{ fprintf(stderr, "towire_gossipd_new_peer_reply called!\n"); abort(); }
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <ccan/err/err.h>
|
#include <ccan/err/err.h>
|
||||||
|
#include <ccan/ptrint/ptrint.h>
|
||||||
#include <common/json_command.h>
|
#include <common/json_command.h>
|
||||||
#include <common/json_helpers.h>
|
#include <common/json_helpers.h>
|
||||||
#include <common/json_tok.h>
|
#include <common/json_tok.h>
|
||||||
|
@ -132,6 +133,7 @@ static unsigned gossip_msg(struct subd *gossip, const u8 *msg, const int *fds)
|
||||||
case WIRE_GOSSIPD_DEV_COMPACT_STORE_REPLY:
|
case WIRE_GOSSIPD_DEV_COMPACT_STORE_REPLY:
|
||||||
case WIRE_GOSSIPD_GET_STRIPPED_CUPDATE_REPLY:
|
case WIRE_GOSSIPD_GET_STRIPPED_CUPDATE_REPLY:
|
||||||
case WIRE_GOSSIPD_ADDGOSSIP_REPLY:
|
case WIRE_GOSSIPD_ADDGOSSIP_REPLY:
|
||||||
|
case WIRE_GOSSIPD_NEW_BLOCKHEIGHT_REPLY:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WIRE_GOSSIPD_GOT_ONIONMSG_TO_US:
|
case WIRE_GOSSIPD_GOT_ONIONMSG_TO_US:
|
||||||
|
@ -144,14 +146,32 @@ static unsigned gossip_msg(struct subd *gossip, const u8 *msg, const int *fds)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void gossipd_new_blockheight_reply(struct subd *gossipd,
|
||||||
|
const u8 *reply,
|
||||||
|
const int *fds UNUSED,
|
||||||
|
void *blockheight)
|
||||||
|
{
|
||||||
|
if (!fromwire_gossipd_new_blockheight_reply(reply)) {
|
||||||
|
/* Shouldn't happen! */
|
||||||
|
log_broken(gossipd->ld->log,
|
||||||
|
"Invalid new_blockheight_reply from gossipd: %s",
|
||||||
|
tal_hex(tmpctx, reply));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now, finally update getinfo's blockheight */
|
||||||
|
gossipd->ld->blockheight = ptr2int(blockheight);
|
||||||
|
}
|
||||||
|
|
||||||
void gossip_notify_new_block(struct lightningd *ld, u32 blockheight)
|
void gossip_notify_new_block(struct lightningd *ld, u32 blockheight)
|
||||||
{
|
{
|
||||||
/* Only notify gossipd once we're synced. */
|
/* Only notify gossipd once we're synced. */
|
||||||
if (!topology_synced(ld->topology))
|
if (!topology_synced(ld->topology))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
subd_send_msg(ld->gossip,
|
subd_req(ld->gossip, ld->gossip,
|
||||||
take(towire_gossipd_new_blockheight(NULL, blockheight)));
|
take(towire_gossipd_new_blockheight(NULL, blockheight)),
|
||||||
|
-1, 0, gossipd_new_blockheight_reply, int2ptr(blockheight));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gossip_topology_synced(struct chain_topology *topo, void *unused)
|
static void gossip_topology_synced(struct chain_topology *topo, void *unused)
|
||||||
|
|
|
@ -215,6 +215,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
|
||||||
|
|
||||||
/*~ This is detailed in chaintopology.c */
|
/*~ This is detailed in chaintopology.c */
|
||||||
ld->topology = new_topology(ld, ld->log);
|
ld->topology = new_topology(ld, ld->log);
|
||||||
|
ld->blockheight = 0;
|
||||||
ld->daemon_parent_fd = -1;
|
ld->daemon_parent_fd = -1;
|
||||||
ld->proxyaddr = NULL;
|
ld->proxyaddr = NULL;
|
||||||
ld->always_use_proxy = false;
|
ld->always_use_proxy = false;
|
||||||
|
|
|
@ -167,6 +167,9 @@ struct lightningd {
|
||||||
/* Our chain topology. */
|
/* Our chain topology. */
|
||||||
struct chain_topology *topology;
|
struct chain_topology *topology;
|
||||||
|
|
||||||
|
/* Blockheight (as acknowledged by gossipd) */
|
||||||
|
u32 blockheight;
|
||||||
|
|
||||||
/* HTLCs in flight. */
|
/* HTLCs in flight. */
|
||||||
struct htlc_in_map htlcs_in;
|
struct htlc_in_map htlcs_in;
|
||||||
struct htlc_out_map htlcs_out;
|
struct htlc_out_map htlcs_out;
|
||||||
|
|
|
@ -1749,7 +1749,7 @@ static struct command_result *json_getinfo(struct command *cmd,
|
||||||
json_array_end(response);
|
json_array_end(response);
|
||||||
}
|
}
|
||||||
json_add_string(response, "version", version());
|
json_add_string(response, "version", version());
|
||||||
json_add_num(response, "blockheight", get_block_height(cmd->ld->topology));
|
json_add_num(response, "blockheight", cmd->ld->blockheight);
|
||||||
json_add_string(response, "network", chainparams->network_name);
|
json_add_string(response, "network", chainparams->network_name);
|
||||||
json_add_amount_msat_compat(response,
|
json_add_amount_msat_compat(response,
|
||||||
wallet_total_forward_fees(cmd->ld->wallet),
|
wallet_total_forward_fees(cmd->ld->wallet),
|
||||||
|
|
Loading…
Add table
Reference in a new issue