Browse Source

gossip_store: make private channels more similar to channel_announcement

Instead of a boutique message, use a "real" channel_announcement for
private channels (with fake sigs and pubkeys).  This makes it far
easier for gossmap to handle local channels.

Backwards compatible update, since we update old stores.

We also fix devtools/dump-gossipstore to know about the tombstone markers.

Since we increment our channel_announce count for local channels now,
the stats in the tests changed too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
travis-experimental
Rusty Russell 4 years ago
parent
commit
83aea6b2bb
  1. 2
      channeld/Makefile
  2. 16
      channeld/channeld.c
  3. 1
      common/Makefile
  4. 2
      common/gossip_store.h
  5. 50
      common/private_channel_announcement.c
  6. 17
      common/private_channel_announcement.h
  7. 13
      devtools/dump-gossipstore.c
  8. 1
      gossipd/Makefile
  9. 82
      gossipd/gossip_store.c
  10. 19
      gossipd/gossip_store_wire.csv
  11. 76
      gossipd/gossip_store_wiregen.c
  12. 21
      gossipd/gossip_store_wiregen.h
  13. 24
      gossipd/gossipd.c
  14. 11
      gossipd/gossipd_peerd_wire.csv
  15. 41
      gossipd/gossipd_peerd_wiregen.c
  16. 14
      gossipd/gossipd_peerd_wiregen.h
  17. 44
      gossipd/routing.c
  18. 7
      gossipd/routing.h
  19. 19
      gossipd/test/run-bench-find_route.c
  20. 6
      gossipd/test/run-check_channel_announcement.c
  21. 19
      gossipd/test/run-find_route-specific.c
  22. 19
      gossipd/test/run-find_route.c
  23. 19
      gossipd/test/run-overlong.c
  24. 6
      gossipd/test/run-txout_failure.c
  25. 17
      tests/test_gossip.py

2
channeld/Makefile

@ -71,6 +71,7 @@ CHANNELD_COMMON_OBJS := \
common/permute_tx.o \
common/ping.o \
common/psbt_open.o \
common/private_channel_announcement.o \
common/pseudorand.o \
common/read_peer_msg.o \
common/setup.o \
@ -86,6 +87,7 @@ CHANNELD_COMMON_OBJS := \
common/wire_error.o \
common/wireaddr.o \
gossipd/gossipd_peerd_wiregen.o \
gossipd/gossip_store_wiregen.o \
lightningd/gossip_msg.o \
wire/fromwire.o \
wire/towire.o

16
channeld/channeld.c

@ -49,6 +49,7 @@
#include <common/ping.h>
#include <common/psbt_internal.h>
#include <common/psbt_open.h>
#include <common/private_channel_announcement.h>
#include <common/read_peer_msg.h>
#include <common/sphinx.h>
#include <common/status.h>
@ -60,6 +61,7 @@
#include <errno.h>
#include <fcntl.h>
#include <gossipd/gossipd_peerd_wiregen.h>
#include <gossipd/gossip_store_wiregen.h>
#include <hsmd/hsmd_wiregen.h>
#include <inttypes.h>
#include <secp256k1.h>
@ -380,16 +382,20 @@ static const u8 *get_local_channel_update(const tal_t *ctx, struct peer *peer)
static void make_channel_local_active(struct peer *peer)
{
u8 *msg;
const u8 *ann;
const u8 *annfeatures = get_agreed_channelfeatures(tmpctx,
peer->our_features,
peer->their_features);
ann = private_channel_announcement(tmpctx,
&peer->short_channel_ids[LOCAL],
&peer->node_ids[LOCAL],
&peer->node_ids[REMOTE],
annfeatures);
/* Tell gossipd about local channel. */
msg = towire_gossipd_local_add_channel(NULL,
&peer->short_channel_ids[LOCAL],
&peer->node_ids[REMOTE],
peer->channel->funding,
annfeatures);
msg = towire_gossip_store_private_channel(NULL,
peer->channel->funding, ann);
wire_sync_write(peer->pps->gossip_fd, take(msg));
/* Tell gossipd and the other side what parameters we expect should

1
common/Makefile

@ -57,6 +57,7 @@ COMMON_SRC_NOGEN := \
common/permute_tx.c \
common/ping.c \
common/psbt_open.c \
common/private_channel_announcement.c \
common/pseudorand.c \
common/random_select.c \
common/read_peer_msg.c \

2
common/gossip_store.h

@ -10,7 +10,7 @@ struct per_peer_state;
/**
* gossip_store -- On-disk storage related information
*/
#define GOSSIP_STORE_VERSION 8
#define GOSSIP_STORE_VERSION 9
/**
* Bit of length we use to mark a deleted record.

50
common/private_channel_announcement.c

@ -0,0 +1,50 @@
#include <assert.h>
#include <bitcoin/chainparams.h>
#include <bitcoin/privkey.h>
#include <bitcoin/pubkey.h>
#include <common/node_id.h>
#include <common/private_channel_announcement.h>
#include <wire/peer_wiregen.h>
const u8 *private_channel_announcement(const tal_t *ctx,
const struct short_channel_id *scid,
const struct node_id *local_node_id,
const struct node_id *remote_node_id,
const u8 *features)
{
struct pubkey dummy_pubkey;
const struct node_id *node[2];
struct secret not_a_secret;
/* Make an all-zero sig. */
static const u8 zeros[64];
size_t zlen = sizeof(zeros);
const u8 *zerop = zeros;
secp256k1_ecdsa_signature zerosig;
fromwire_secp256k1_ecdsa_signature(&zerop, &zlen, &zerosig);
assert(zerop != NULL);
memset(&not_a_secret, 1, sizeof(not_a_secret));
if (!pubkey_from_secret(&not_a_secret, &dummy_pubkey))
abort();
/* node ids are in ascending order. */
if (node_id_cmp(remote_node_id, local_node_id) > 0) {
node[0] = local_node_id;
node[1] = remote_node_id;
} else {
node[0] = remote_node_id;
node[1] = local_node_id;
}
return towire_channel_announcement(ctx,
&zerosig, &zerosig,
&zerosig, &zerosig,
features,
&chainparams->genesis_blockhash,
scid,
node[0],
node[1],
&dummy_pubkey,
&dummy_pubkey);
}

17
common/private_channel_announcement.h

@ -0,0 +1,17 @@
#ifndef LIGHTNING_COMMON_PRIVATE_CHANNEL_ANNOUNCEMENT_H
#define LIGHTNING_COMMON_PRIVATE_CHANNEL_ANNOUNCEMENT_H
#include "config.h"
#include <ccan/short_types/short_types.h>
#include <ccan/tal/tal.h>
struct short_channel_id;
struct node_id;
/* Helper to create a fake channel announcement for local channels. */
const u8 *private_channel_announcement(const tal_t *ctx,
const struct short_channel_id *scid,
const struct node_id *local_node_id,
const struct node_id *remote_node_id,
const u8 *features);
#endif /* LIGHTNING_COMMON_PRIVATE_CHANNEL_ANNOUNCEMENT_H */

13
devtools/dump-gossipstore.c

@ -53,6 +53,7 @@ int main(int argc, char *argv[])
while (read(fd, &hdr, sizeof(hdr)) == sizeof(hdr)) {
struct amount_sat sat;
struct short_channel_id scid;
u32 msglen = be32_to_cpu(hdr.len);
u8 *msg, *inner;
bool deleted, push;
@ -92,13 +93,19 @@ int main(int argc, char *argv[])
printf("t=%u node_announcement: %s\n",
be32_to_cpu(hdr.timestamp),
tal_hex(msg, msg));
} else if (fromwire_peektype(msg) == WIRE_GOSSIPD_LOCAL_ADD_CHANNEL) {
printf("local_add_channel: %s\n",
tal_hex(msg, msg));
} else if (fromwire_gossip_store_private_channel(msg, msg, &sat,
&inner)) {
printf("private channel_announcement: %s %s\n",
type_to_string(tmpctx, struct amount_sat, &sat),
tal_hex(msg, inner));
} else if (fromwire_gossip_store_private_update(msg, msg,
&inner)) {
printf("private channel_update: %s\n",
tal_hex(msg, inner));
} else if (fromwire_gossip_store_delete_chan(msg, &scid)) {
printf("delete channel: %s\n",
type_to_string(tmpctx, struct short_channel_id,
&scid));
} else {
warnx("Unknown message %u",
fromwire_peektype(msg));

1
gossipd/Makefile

@ -53,6 +53,7 @@ GOSSIPD_COMMON_OBJS := \
common/ping.o \
common/psbt_open.o \
common/pseudorand.o \
common/private_channel_announcement.o \
common/random_select.o \
common/setup.o \
common/status.o \

82
gossipd/gossip_store.c

@ -1,5 +1,6 @@
#include "gossip_store.h"
#include <bitcoin/chainparams.h>
#include <ccan/array_size/array_size.h>
#include <ccan/crc32c/crc32c.h>
#include <ccan/endian/endian.h>
@ -7,7 +8,9 @@
#include <ccan/read_write_all/read_write_all.h>
#include <ccan/tal/str/str.h>
#include <common/gossip_store.h>
#include <common/private_channel_announcement.h>
#include <common/status.h>
#include <common/type_to_string.h>
#include <common/utils.h>
#include <errno.h>
#include <fcntl.h>
@ -117,21 +120,63 @@ static bool append_msg(int fd, const u8 *msg, u32 timestamp,
}
#ifdef COMPAT_V082
static u8 *mk_private_channelmsg(const tal_t *ctx,
struct routing_state *rstate,
const struct short_channel_id *scid,
const struct node_id *remote_node_id,
struct amount_sat sat,
const u8 *features)
{
const u8 *ann = private_channel_announcement(tmpctx, scid,
&rstate->local_id,
remote_node_id,
features);
return towire_gossip_store_private_channel(ctx, sat, ann);
}
/* The upgrade from version 7 is trivial */
static bool can_upgrade(u8 oldversion)
{
return oldversion == 7;
return oldversion == 7 || oldversion == 8;
}
static bool upgrade_field(u8 oldversion, u8 **msg)
static bool upgrade_field(u8 oldversion,
struct routing_state *rstate,
u8 **msg)
{
assert(can_upgrade(oldversion));
/* We only need to upgrade this */
if (fromwire_peektype(*msg) == WIRE_GOSSIPD_LOCAL_ADD_CHANNEL) {
if (fromwire_peektype(*msg) == WIRE_GOSSIPD_LOCAL_ADD_CHANNEL_OBS
&& oldversion == 7) {
/* Append two 0 bytes, for (empty) feature bits */
tal_resizez(msg, tal_bytelen(*msg) + 2);
}
/* We turn these (v8) into a WIRE_GOSSIP_STORE_PRIVATE_CHANNEL */
if (fromwire_peektype(*msg) == WIRE_GOSSIPD_LOCAL_ADD_CHANNEL_OBS) {
struct short_channel_id scid;
struct node_id remote_node_id;
struct amount_sat satoshis;
u8 *features;
u8 *storemsg;
if (!fromwire_gossipd_local_add_channel_obs(tmpctx, *msg,
&scid,
&remote_node_id,
&satoshis,
&features))
return false;
storemsg = mk_private_channelmsg(tal_parent(*msg),
rstate,
&scid,
&remote_node_id,
satoshis,
features);
tal_free(*msg);
*msg = storemsg;
}
return true;
}
#else
@ -140,7 +185,9 @@ static bool can_upgrade(u8 oldversion)
return false;
}
static bool upgrade_field(u8 oldversion, u8 **msg)
static bool upgrade_field(u8 oldversion,
struct routing_state *rstate,
u8 **msg)
{
abort();
}
@ -148,7 +195,7 @@ static bool upgrade_field(u8 oldversion, u8 **msg)
/* Read gossip store entries, copy non-deleted ones. This code is written
* as simply and robustly as possible! */
static u32 gossip_store_compact_offline(void)
static u32 gossip_store_compact_offline(struct routing_state *rstate)
{
size_t count = 0, deleted = 0;
int old_fd, new_fd;
@ -206,7 +253,7 @@ static u32 gossip_store_compact_offline(void)
}
if (oldversion != version) {
if (!upgrade_field(oldversion, &msg)) {
if (!upgrade_field(oldversion, rstate, &msg)) {
tal_free(msg);
goto close_and_delete;
}
@ -263,7 +310,7 @@ struct gossip_store *gossip_store_new(struct routing_state *rstate,
struct gossip_store *gs = tal(rstate, struct gossip_store);
gs->count = gs->deleted = 0;
gs->writable = true;
gs->timestamp = gossip_store_compact_offline();
gs->timestamp = gossip_store_compact_offline(rstate);
gs->fd = open(GOSSIP_STORE_FILENAME, O_RDWR|O_CREAT, 0600);
if (gs->fd < 0)
status_failed(STATUS_FAIL_INTERNAL_ERROR,
@ -464,7 +511,7 @@ bool gossip_store_compact(struct gossip_store *gs)
goto unlink_disable;
/* We track location of all these message types. */
if (msgtype == WIRE_GOSSIPD_LOCAL_ADD_CHANNEL
if (msgtype == WIRE_GOSSIP_STORE_PRIVATE_CHANNEL
|| msgtype == WIRE_GOSSIP_STORE_PRIVATE_UPDATE
|| msgtype == WIRE_CHANNEL_ANNOUNCEMENT
|| msgtype == WIRE_CHANNEL_UPDATE
@ -709,7 +756,7 @@ u32 gossip_store_load(struct routing_state *rstate, struct gossip_store *gs)
const char *bad;
size_t stats[] = {0, 0, 0, 0};
struct timeabs start = time_now();
const u8 *chan_ann = NULL;
u8 *chan_ann = NULL;
u64 chan_ann_off = 0; /* Spurious gcc-9 (Ubuntu 9-20190402-1ubuntu1) 9.0.1 20190402 (experimental) warning */
gs->writable = false;
@ -737,6 +784,14 @@ u32 gossip_store_load(struct routing_state *rstate, struct gossip_store *gs)
}
switch (fromwire_peektype(msg)) {
case WIRE_GOSSIP_STORE_PRIVATE_CHANNEL:
if (!routing_add_private_channel(rstate, NULL, msg,
gs->len)) {
bad = "Bad add_private_channel";
goto badmsg;
}
stats[0]++;
break;
case WIRE_GOSSIP_STORE_CHANNEL_AMOUNT:
if (!fromwire_gossip_store_channel_amount(msg,
&satoshis)) {
@ -790,13 +845,6 @@ u32 gossip_store_load(struct routing_state *rstate, struct gossip_store *gs)
}
stats[2]++;
break;
case WIRE_GOSSIPD_LOCAL_ADD_CHANNEL:
if (!handle_local_add_channel(rstate, NULL,
msg, gs->len)) {
bad = "Bad local_add_channel";
goto badmsg;
}
break;
default:
bad = "Unknown message";
goto badmsg;

19
gossipd/gossip_store_wire.csv

@ -1,12 +1,19 @@
# gossip_store messages: messages persisted in the gossip_store
# We store raw messages here, so these numbers must not overlap with
# 256/257/258 or gossipd_local_add_channel (3503)
# 256/257/258.
#include <common/amount.h>
#include <common/node_id.h>
# This always follows the channel_announce.
# This always follows the channel_announce / private_announce
msgtype,gossip_store_channel_amount,4101
msgdata,gossip_store_channel_amount,satoshis,amount_sat,
# Mimics a channel_announce, except signatures are all-zero
msgtype,gossip_store_private_channel,4104
msgdata,gossip_store_private_channel,satoshis,amount_sat,
msgdata,gossip_store_private_channel,len,u16,
msgdata,gossip_store_private_channel,announcement,u8,len
msgtype,gossip_store_private_update,4102
msgdata,gossip_store_private_update,len,u16,
msgdata,gossip_store_private_update,update,u8,len
@ -14,3 +21,11 @@ msgdata,gossip_store_private_update,update,u8,len
msgtype,gossip_store_delete_chan,4103
msgdata,gossip_store_delete_chan,scid,short_channel_id,
# FIXME: Here for COMPAT with v0.9.0 and before only.
msgtype,gossipd_local_add_channel_obs,3503
msgdata,gossipd_local_add_channel_obs,short_channel_id,short_channel_id,
msgdata,gossipd_local_add_channel_obs,remote_node_id,node_id,
msgdata,gossipd_local_add_channel_obs,satoshis,amount_sat,
msgdata,gossipd_local_add_channel_obs,flen,u16,
msgdata,gossipd_local_add_channel_obs,features,u8,flen

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

76
gossipd/gossip_store_wiregen.c

@ -16,7 +16,7 @@
/* gossip_store messages: messages persisted in the gossip_store */
/* We store raw messages here */
/* 256/257/258 or gossipd_local_add_channel (3503) */
/* 256/257/258. */
const char *gossip_store_wire_name(int e)
{
@ -24,8 +24,10 @@ const char *gossip_store_wire_name(int e)
switch ((enum gossip_store_wire)e) {
case WIRE_GOSSIP_STORE_CHANNEL_AMOUNT: return "WIRE_GOSSIP_STORE_CHANNEL_AMOUNT";
case WIRE_GOSSIP_STORE_PRIVATE_CHANNEL: return "WIRE_GOSSIP_STORE_PRIVATE_CHANNEL";
case WIRE_GOSSIP_STORE_PRIVATE_UPDATE: return "WIRE_GOSSIP_STORE_PRIVATE_UPDATE";
case WIRE_GOSSIP_STORE_DELETE_CHAN: return "WIRE_GOSSIP_STORE_DELETE_CHAN";
case WIRE_GOSSIPD_LOCAL_ADD_CHANNEL_OBS: return "WIRE_GOSSIPD_LOCAL_ADD_CHANNEL_OBS";
}
snprintf(invalidbuf, sizeof(invalidbuf), "INVALID %i", e);
@ -36,8 +38,10 @@ bool gossip_store_wire_is_defined(u16 type)
{
switch ((enum gossip_store_wire)type) {
case WIRE_GOSSIP_STORE_CHANNEL_AMOUNT:;
case WIRE_GOSSIP_STORE_PRIVATE_CHANNEL:;
case WIRE_GOSSIP_STORE_PRIVATE_UPDATE:;
case WIRE_GOSSIP_STORE_DELETE_CHAN:;
case WIRE_GOSSIPD_LOCAL_ADD_CHANNEL_OBS:;
return true;
}
return false;
@ -48,7 +52,7 @@ bool gossip_store_wire_is_defined(u16 type)
/* WIRE: GOSSIP_STORE_CHANNEL_AMOUNT */
/* This always follows the channel_announce. */
/* This always follows the channel_announce / private_announce */
u8 *towire_gossip_store_channel_amount(const tal_t *ctx, struct amount_sat satoshis)
{
u8 *p = tal_arr(ctx, u8, 0);
@ -69,6 +73,37 @@ bool fromwire_gossip_store_channel_amount(const void *p, struct amount_sat *sato
return cursor != NULL;
}
/* WIRE: GOSSIP_STORE_PRIVATE_CHANNEL */
/* Mimics a channel_announce */
u8 *towire_gossip_store_private_channel(const tal_t *ctx, struct amount_sat satoshis, const u8 *announcement)
{
u16 len = tal_count(announcement);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIP_STORE_PRIVATE_CHANNEL);
towire_amount_sat(&p, satoshis);
towire_u16(&p, len);
towire_u8_array(&p, announcement, len);
return memcheck(p, tal_count(p));
}
bool fromwire_gossip_store_private_channel(const tal_t *ctx, const void *p, struct amount_sat *satoshis, u8 **announcement)
{
u16 len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIP_STORE_PRIVATE_CHANNEL)
return false;
*satoshis = fromwire_amount_sat(&cursor, &plen);
len = fromwire_u16(&cursor, &plen);
// 2nd case announcement
*announcement = len ? tal_arr(ctx, u8, len) : NULL;
fromwire_u8_array(&cursor, &plen, *announcement, len);
return cursor != NULL;
}
/* WIRE: GOSSIP_STORE_PRIVATE_UPDATE */
u8 *towire_gossip_store_private_update(const tal_t *ctx, const u8 *update)
{
@ -117,4 +152,39 @@ bool fromwire_gossip_store_delete_chan(const void *p, struct short_channel_id *s
fromwire_short_channel_id(&cursor, &plen, scid);
return cursor != NULL;
}
// SHA256STAMP:f6c526c196880b46255eec167cd2dccccfc2e8cfae312683889dc67418a2d0b4
/* WIRE: GOSSIPD_LOCAL_ADD_CHANNEL_OBS */
/* FIXME: Here for COMPAT with v0.9.0 and before only. */
u8 *towire_gossipd_local_add_channel_obs(const tal_t *ctx, const struct short_channel_id *short_channel_id, const struct node_id *remote_node_id, struct amount_sat satoshis, const u8 *features)
{
u16 flen = tal_count(features);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_LOCAL_ADD_CHANNEL_OBS);
towire_short_channel_id(&p, short_channel_id);
towire_node_id(&p, remote_node_id);
towire_amount_sat(&p, satoshis);
towire_u16(&p, flen);
towire_u8_array(&p, features, flen);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_local_add_channel_obs(const tal_t *ctx, const void *p, struct short_channel_id *short_channel_id, struct node_id *remote_node_id, struct amount_sat *satoshis, u8 **features)
{
u16 flen;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_LOCAL_ADD_CHANNEL_OBS)
return false;
fromwire_short_channel_id(&cursor, &plen, short_channel_id);
fromwire_node_id(&cursor, &plen, remote_node_id);
*satoshis = fromwire_amount_sat(&cursor, &plen);
flen = fromwire_u16(&cursor, &plen);
// 2nd case features
*features = flen ? tal_arr(ctx, u8, flen) : NULL;
fromwire_u8_array(&cursor, &plen, *features, flen);
return cursor != NULL;
}
// SHA256STAMP:41597b4d43114d650fc300cd4df2c4f7f993a09d9ff427f3f6c0c7248a4b47cd

21
gossipd/gossip_store_wiregen.h

@ -8,12 +8,17 @@
#include <wire/tlvstream.h>
#include <wire/wire.h>
#include <common/amount.h>
#include <common/node_id.h>
enum gossip_store_wire {
/* This always follows the channel_announce. */
/* This always follows the channel_announce / private_announce */
WIRE_GOSSIP_STORE_CHANNEL_AMOUNT = 4101,
/* Mimics a channel_announce */
WIRE_GOSSIP_STORE_PRIVATE_CHANNEL = 4104,
WIRE_GOSSIP_STORE_PRIVATE_UPDATE = 4102,
WIRE_GOSSIP_STORE_DELETE_CHAN = 4103,
/* FIXME: Here for COMPAT with v0.9.0 and before only. */
WIRE_GOSSIPD_LOCAL_ADD_CHANNEL_OBS = 3503,
};
const char *gossip_store_wire_name(int e);
@ -29,10 +34,15 @@ bool gossip_store_wire_is_defined(u16 type);
/* WIRE: GOSSIP_STORE_CHANNEL_AMOUNT */
/* This always follows the channel_announce. */
/* This always follows the channel_announce / private_announce */
u8 *towire_gossip_store_channel_amount(const tal_t *ctx, struct amount_sat satoshis);
bool fromwire_gossip_store_channel_amount(const void *p, struct amount_sat *satoshis);
/* WIRE: GOSSIP_STORE_PRIVATE_CHANNEL */
/* Mimics a channel_announce */
u8 *towire_gossip_store_private_channel(const tal_t *ctx, struct amount_sat satoshis, const u8 *announcement);
bool fromwire_gossip_store_private_channel(const tal_t *ctx, const void *p, struct amount_sat *satoshis, u8 **announcement);
/* WIRE: GOSSIP_STORE_PRIVATE_UPDATE */
u8 *towire_gossip_store_private_update(const tal_t *ctx, const u8 *update);
bool fromwire_gossip_store_private_update(const tal_t *ctx, const void *p, u8 **update);
@ -41,6 +51,11 @@ bool fromwire_gossip_store_private_update(const tal_t *ctx, const void *p, u8 **
u8 *towire_gossip_store_delete_chan(const tal_t *ctx, const struct short_channel_id *scid);
bool fromwire_gossip_store_delete_chan(const void *p, struct short_channel_id *scid);
/* WIRE: GOSSIPD_LOCAL_ADD_CHANNEL_OBS */
/* FIXME: Here for COMPAT with v0.9.0 and before only. */
u8 *towire_gossipd_local_add_channel_obs(const tal_t *ctx, const struct short_channel_id *short_channel_id, const struct node_id *remote_node_id, struct amount_sat satoshis, const u8 *features);
bool fromwire_gossipd_local_add_channel_obs(const tal_t *ctx, const void *p, struct short_channel_id *short_channel_id, struct node_id *remote_node_id, struct amount_sat *satoshis, u8 **features);
#endif /* LIGHTNING_GOSSIPD_GOSSIP_STORE_WIREGEN_H */
// SHA256STAMP:f6c526c196880b46255eec167cd2dccccfc2e8cfae312683889dc67418a2d0b4
// SHA256STAMP:41597b4d43114d650fc300cd4df2c4f7f993a09d9ff427f3f6c0c7248a4b47cd

24
gossipd/gossipd.c

@ -46,6 +46,7 @@
#include <fcntl.h>
#include <gossipd/broadcast.h>
#include <gossipd/gossip_generation.h>
#include <gossipd/gossip_store_wiregen.h>
#include <gossipd/gossipd.h>
#include <gossipd/gossipd_peerd_wiregen.h>
#include <gossipd/gossipd_wiregen.h>
@ -512,10 +513,6 @@ static struct io_plan *peer_msg_in(struct io_conn *conn,
case WIRE_GOSSIPD_GET_UPDATE:
ok = handle_get_local_channel_update(peer, msg);
goto handled_cmd;
case WIRE_GOSSIPD_LOCAL_ADD_CHANNEL:
ok = handle_local_add_channel(peer->daemon->rstate, peer,
msg, 0);
goto handled_cmd;
case WIRE_GOSSIPD_LOCAL_CHANNEL_UPDATE:
ok = handle_local_channel_update(peer->daemon, &peer->id, msg);
goto handled_cmd;
@ -529,6 +526,12 @@ static struct io_plan *peer_msg_in(struct io_conn *conn,
break;
}
if (fromwire_peektype(msg) == WIRE_GOSSIP_STORE_PRIVATE_CHANNEL) {
ok = routing_add_private_channel(peer->daemon->rstate, peer,
msg, 0);
goto handled_cmd;
}
/* Anything else should not have been sent to us: close on it */
status_peer_broken(&peer->id, "unexpected cmd of type %i %s",
fromwire_peektype(msg),
@ -989,21 +992,22 @@ static u8 *get_channel_features(const tal_t *ctx,
struct node_id node_id;
struct pubkey bitcoin_key;
struct amount_sat sats;
const u8 *ann;
u8 *ann;
/* This is where we stash a flag to indicate it exists. */
if (!chan->half[0].any_features)
return NULL;
/* Could be a channel_announcement, could be a local_add_channel */
ann = gossip_store_get(tmpctx, gs, chan->bcast.index);
ann = cast_const(u8 *, gossip_store_get(tmpctx, gs, chan->bcast.index));
/* Could be a private_channel */
fromwire_gossip_store_private_channel(tmpctx, ann, &sats, &ann);
if (!fromwire_channel_announcement(ctx, ann, &sig, &sig, &sig, &sig,
&features, &chain_hash,
&short_channel_id,
&node_id, &node_id,
&bitcoin_key, &bitcoin_key)
&& !fromwire_gossipd_local_add_channel(ctx, ann, &short_channel_id,
&node_id, &sats, &features))
&bitcoin_key, &bitcoin_key))
status_failed(STATUS_FAIL_INTERNAL_ERROR,
"bad channel_announcement / local_add_channel at %u: %s",
chan->bcast.index, tal_hex(tmpctx, ann));

11
gossipd/gossipd_peerd_wire.csv

@ -1,7 +1,6 @@
# These must be distinct from WIRE_CHANNEL_ANNOUNCEMENT etc. gossip msgs!
#include <bitcoin/short_channel_id.h>
#include <common/amount.h>
#include <common/node_id.h>
# Channel daemon can ask for updates for a specific channel, for sending
# errors.
@ -13,16 +12,6 @@ msgtype,gossipd_get_update_reply,3601
msgdata,gossipd_get_update_reply,len,u16,
msgdata,gossipd_get_update_reply,update,u8,len
# Both sides have seen the funding tx being locked, but we have not
# yet reached the announcement depth. So we add the channel locally so
# we (and peer) can update it already.
msgtype,gossipd_local_add_channel,3503
msgdata,gossipd_local_add_channel,short_channel_id,short_channel_id,
msgdata,gossipd_local_add_channel,remote_node_id,node_id,
msgdata,gossipd_local_add_channel,satoshis,amount_sat,
msgdata,gossipd_local_add_channel,flen,u16,
msgdata,gossipd_local_add_channel,features,u8,flen
# Send this channel_update.
msgtype,gossipd_local_channel_update,3504
msgdata,gossipd_local_channel_update,short_channel_id,short_channel_id,

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

41
gossipd/gossipd_peerd_wiregen.c

@ -23,7 +23,6 @@ const char *gossipd_peerd_wire_name(int e)
switch ((enum gossipd_peerd_wire)e) {
case WIRE_GOSSIPD_GET_UPDATE: return "WIRE_GOSSIPD_GET_UPDATE";
case WIRE_GOSSIPD_GET_UPDATE_REPLY: return "WIRE_GOSSIPD_GET_UPDATE_REPLY";
case WIRE_GOSSIPD_LOCAL_ADD_CHANNEL: return "WIRE_GOSSIPD_LOCAL_ADD_CHANNEL";
case WIRE_GOSSIPD_LOCAL_CHANNEL_UPDATE: return "WIRE_GOSSIPD_LOCAL_CHANNEL_UPDATE";
case WIRE_GOSSIPD_NEW_STORE_FD: return "WIRE_GOSSIPD_NEW_STORE_FD";
case WIRE_GOSSIPD_LOCAL_CHANNEL_ANNOUNCEMENT: return "WIRE_GOSSIPD_LOCAL_CHANNEL_ANNOUNCEMENT";
@ -38,7 +37,6 @@ bool gossipd_peerd_wire_is_defined(u16 type)
switch ((enum gossipd_peerd_wire)type) {
case WIRE_GOSSIPD_GET_UPDATE:;
case WIRE_GOSSIPD_GET_UPDATE_REPLY:;
case WIRE_GOSSIPD_LOCAL_ADD_CHANNEL:;
case WIRE_GOSSIPD_LOCAL_CHANNEL_UPDATE:;
case WIRE_GOSSIPD_NEW_STORE_FD:;
case WIRE_GOSSIPD_LOCAL_CHANNEL_ANNOUNCEMENT:;
@ -103,43 +101,6 @@ bool fromwire_gossipd_get_update_reply(const tal_t *ctx, const void *p, u8 **upd
return cursor != NULL;
}
/* WIRE: GOSSIPD_LOCAL_ADD_CHANNEL */
/* Both sides have seen the funding tx being locked */
/* yet reached the announcement depth. So we add the channel locally so */
/* we (and peer) can update it already. */
u8 *towire_gossipd_local_add_channel(const tal_t *ctx, const struct short_channel_id *short_channel_id, const struct node_id *remote_node_id, struct amount_sat satoshis, const u8 *features)
{
u16 flen = tal_count(features);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_LOCAL_ADD_CHANNEL);
towire_short_channel_id(&p, short_channel_id);
towire_node_id(&p, remote_node_id);
towire_amount_sat(&p, satoshis);
towire_u16(&p, flen);
towire_u8_array(&p, features, flen);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_local_add_channel(const tal_t *ctx, const void *p, struct short_channel_id *short_channel_id, struct node_id *remote_node_id, struct amount_sat *satoshis, u8 **features)
{
u16 flen;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_LOCAL_ADD_CHANNEL)
return false;
fromwire_short_channel_id(&cursor, &plen, short_channel_id);
fromwire_node_id(&cursor, &plen, remote_node_id);
*satoshis = fromwire_amount_sat(&cursor, &plen);
flen = fromwire_u16(&cursor, &plen);
// 2nd case features
*features = flen ? tal_arr(ctx, u8, flen) : NULL;
fromwire_u8_array(&cursor, &plen, *features, flen);
return cursor != NULL;
}
/* WIRE: GOSSIPD_LOCAL_CHANNEL_UPDATE */
/* Send this channel_update. */
u8 *towire_gossipd_local_channel_update(const tal_t *ctx, const struct short_channel_id *short_channel_id, bool disable, u16 cltv_expiry_delta, struct amount_msat htlc_minimum_msat, u32 fee_base_msat, u32 fee_proportional_millionths, struct amount_msat htlc_maximum_msat)
@ -226,4 +187,4 @@ bool fromwire_gossipd_local_channel_announcement(const tal_t *ctx, const void *p
fromwire_u8_array(&cursor, &plen, *cannount, len);
return cursor != NULL;
}
// SHA256STAMP:b7bd26d45b133237284bcea72ab584555716c57d414abebe71026279924cb4f2
// SHA256STAMP:c4575b41c403e4760d2a8674edfa45476e15fd8945be672b0e4c120d330e96aa

14
gossipd/gossipd_peerd_wiregen.h

@ -9,7 +9,6 @@
#include <wire/wire.h>
#include <bitcoin/short_channel_id.h>
#include <common/amount.h>
#include <common/node_id.h>
enum gossipd_peerd_wire {
/* Channel daemon can ask for updates for a specific channel */
@ -17,10 +16,6 @@ enum gossipd_peerd_wire {
WIRE_GOSSIPD_GET_UPDATE = 3501,
/* If channel isn't known */
WIRE_GOSSIPD_GET_UPDATE_REPLY = 3601,
/* Both sides have seen the funding tx being locked */
/* yet reached the announcement depth. So we add the channel locally so */
/* we (and peer) can update it already. */
WIRE_GOSSIPD_LOCAL_ADD_CHANNEL = 3503,
/* Send this channel_update. */
WIRE_GOSSIPD_LOCAL_CHANNEL_UPDATE = 3504,
/* Update your gossip_store fd: + gossip_store_fd */
@ -52,13 +47,6 @@ bool fromwire_gossipd_get_update(const void *p, struct short_channel_id *short_c
u8 *towire_gossipd_get_update_reply(const tal_t *ctx, const u8 *update);
bool fromwire_gossipd_get_update_reply(const tal_t *ctx, const void *p, u8 **update);
/* WIRE: GOSSIPD_LOCAL_ADD_CHANNEL */
/* Both sides have seen the funding tx being locked */
/* yet reached the announcement depth. So we add the channel locally so */
/* we (and peer) can update it already. */
u8 *towire_gossipd_local_add_channel(const tal_t *ctx, const struct short_channel_id *short_channel_id, const struct node_id *remote_node_id, struct amount_sat satoshis, const u8 *features);
bool fromwire_gossipd_local_add_channel(const tal_t *ctx, const void *p, struct short_channel_id *short_channel_id, struct node_id *remote_node_id, struct amount_sat *satoshis, u8 **features);
/* WIRE: GOSSIPD_LOCAL_CHANNEL_UPDATE */
/* Send this channel_update. */
u8 *towire_gossipd_local_channel_update(const tal_t *ctx, const struct short_channel_id *short_channel_id, bool disable, u16 cltv_expiry_delta, struct amount_msat htlc_minimum_msat, u32 fee_base_msat, u32 fee_proportional_millionths, struct amount_msat htlc_maximum_msat);
@ -76,4 +64,4 @@ bool fromwire_gossipd_local_channel_announcement(const tal_t *ctx, const void *p
#endif /* LIGHTNING_GOSSIPD_GOSSIPD_PEERD_WIREGEN_H */
// SHA256STAMP:b7bd26d45b133237284bcea72ab584555716c57d414abebe71026279924cb4f2
// SHA256STAMP:c4575b41c403e4760d2a8674edfa45476e15fd8945be672b0e4c120d330e96aa

44
gossipd/routing.c

@ -295,9 +295,9 @@ struct routing_state *new_routing_state(const tal_t *ctx,
{
struct routing_state *rstate = tal(ctx, struct routing_state);
rstate->nodes = new_node_map(rstate);
rstate->gs = gossip_store_new(rstate, peers);
rstate->timers = timers;
rstate->local_id = *local_id;
rstate->gs = gossip_store_new(rstate, peers);
rstate->local_channel_announced = false;
rstate->last_timestamp = 0;
@ -2261,11 +2261,11 @@ void remove_channel_from_store(struct routing_state *rstate,
if (is_chan_public(chan)) {
update_type = WIRE_CHANNEL_UPDATE;
announcment_type = WIRE_CHANNEL_ANNOUNCEMENT;
gossip_store_mark_channel_deleted(rstate->gs, &chan->scid);
} else {
update_type = WIRE_GOSSIP_STORE_PRIVATE_UPDATE;
announcment_type = WIRE_GOSSIPD_LOCAL_ADD_CHANNEL;
announcment_type = WIRE_GOSSIP_STORE_PRIVATE_CHANNEL;
}
gossip_store_mark_channel_deleted(rstate->gs, &chan->scid);
/* If these aren't in the store, these are noops. */
gossip_store_delete(rstate->gs,
@ -2815,23 +2815,37 @@ void route_prune(struct routing_state *rstate)
}
}
bool handle_local_add_channel(struct routing_state *rstate,
const struct peer *peer,
const u8 *msg, u64 index)
bool routing_add_private_channel(struct routing_state *rstate,
const struct peer *peer,
const u8 *msg, u64 index)
{
struct short_channel_id scid;
struct node_id remote_node_id;
struct node_id node_id[2];
struct pubkey ignorekey;
struct amount_sat sat;
struct chan *chan;
u8 *features;
u8 *features, *chan_ann;
secp256k1_ecdsa_signature ignoresig;
struct bitcoin_blkid chain_hash;
if (!fromwire_gossipd_local_add_channel(msg, msg, &scid, &remote_node_id,
&sat, &features)) {
status_peer_broken(peer ? &peer->id : NULL,
"Unable to parse local_add_channel message: %s",
tal_hex(msg, msg));
if (!fromwire_gossip_store_private_channel(tmpctx, msg,
&sat, &chan_ann))
return false;
if (!fromwire_channel_announcement(tmpctx, chan_ann,
&ignoresig,
&ignoresig,
&ignoresig,
&ignoresig,
&features,
&chain_hash,
&scid,
&node_id[0],
&node_id[1],
&ignorekey,
&ignorekey))
return false;
}
/* Can happen on channeld restart. */
if (get_channel(rstate, &scid)) {
@ -2845,7 +2859,7 @@ bool handle_local_add_channel(struct routing_state *rstate,
type_to_string(tmpctx, struct short_channel_id, &scid));
/* Create new (unannounced) channel */
chan = new_chan(rstate, &scid, &rstate->local_id, &remote_node_id, sat,
chan = new_chan(rstate, &scid, &node_id[0], &node_id[1], sat,
features);
if (!index)
index = gossip_store_add(rstate->gs, msg, 0, false, NULL);

7
gossipd/routing.h

@ -478,10 +478,9 @@ bool routing_add_node_announcement(struct routing_state *rstate,
* is the case for private channels or channels that have not yet reached
* `announce_depth`.
*/
bool handle_local_add_channel(struct routing_state *rstate,
const struct peer *peer,
const u8 *msg,
u64 index);
bool routing_add_private_channel(struct routing_state *rstate,
const struct peer *peer,
const u8 *msg, u64 index);
/**
* Get the local time.

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

@ -40,12 +40,15 @@ char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr
/* Generated stub for fromwire_gossip_store_channel_amount */
bool fromwire_gossip_store_channel_amount(const void *p UNNEEDED, struct amount_sat *satoshis UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_channel_amount called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_private_channel */
bool fromwire_gossip_store_private_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct amount_sat *satoshis UNNEEDED, u8 **announcement UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_private_channel called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_private_update */
bool fromwire_gossip_store_private_update(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **update UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_private_update called!\n"); abort(); }
/* Generated stub for fromwire_gossipd_local_add_channel */
bool fromwire_gossipd_local_add_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct node_id *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED, u8 **features UNNEEDED)
{ fprintf(stderr, "fromwire_gossipd_local_add_channel called!\n"); abort(); }
/* Generated stub for fromwire_gossipd_local_add_channel_obs */
bool fromwire_gossipd_local_add_channel_obs(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct node_id *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED, u8 **features UNNEEDED)
{ fprintf(stderr, "fromwire_gossipd_local_add_channel_obs called!\n"); abort(); }
/* Generated stub for fromwire_wireaddr */
bool fromwire_wireaddr(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct wireaddr *addr UNNEEDED)
{ fprintf(stderr, "fromwire_wireaddr called!\n"); abort(); }
@ -79,6 +82,13 @@ void *notleak_(const void *ptr UNNEEDED, bool plus_children UNNEEDED)
/* Generated stub for peer_supplied_good_gossip */
void peer_supplied_good_gossip(struct peer *peer UNNEEDED, size_t amount UNNEEDED)
{ fprintf(stderr, "peer_supplied_good_gossip called!\n"); abort(); }
/* Generated stub for private_channel_announcement */
const u8 *private_channel_announcement(const tal_t *ctx UNNEEDED,
const struct short_channel_id *scid UNNEEDED,
const struct node_id *local_node_id UNNEEDED,
const struct node_id *remote_node_id UNNEEDED,
const u8 *features UNNEEDED)
{ fprintf(stderr, "private_channel_announcement called!\n"); abort(); }
/* Generated stub for sanitize_error */
char *sanitize_error(const tal_t *ctx UNNEEDED, const u8 *errmsg UNNEEDED,
struct channel_id *channel_id UNNEEDED)
@ -98,6 +108,9 @@ u8 *towire_gossip_store_channel_amount(const tal_t *ctx UNNEEDED, struct amount_
/* Generated stub for towire_gossip_store_delete_chan */
u8 *towire_gossip_store_delete_chan(const tal_t *ctx UNNEEDED, const struct short_channel_id *scid UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_delete_chan called!\n"); abort(); }
/* Generated stub for towire_gossip_store_private_channel */
u8 *towire_gossip_store_private_channel(const tal_t *ctx UNNEEDED, struct amount_sat satoshis UNNEEDED, const u8 *announcement UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_private_channel called!\n"); abort(); }
/* Generated stub for towire_gossip_store_private_update */
u8 *towire_gossip_store_private_update(const tal_t *ctx UNNEEDED, const u8 *update UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_private_update called!\n"); abort(); }

6
gossipd/test/run-check_channel_announcement.c

@ -41,9 +41,9 @@ bool cupdate_different(struct gossip_store *gs UNNEEDED,
/* Generated stub for fmt_wireaddr_without_port */
char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr *a UNNEEDED)
{ fprintf(stderr, "fmt_wireaddr_without_port called!\n"); abort(); }
/* Generated stub for fromwire_gossipd_local_add_channel */
bool fromwire_gossipd_local_add_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct node_id *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED, u8 **features UNNEEDED)
{ fprintf(stderr, "fromwire_gossipd_local_add_channel called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_private_channel */
bool fromwire_gossip_store_private_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct amount_sat *satoshis UNNEEDED, u8 **announcement UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_private_channel called!\n"); abort(); }
/* Generated stub for fromwire_wireaddr */
bool fromwire_wireaddr(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct wireaddr *addr UNNEEDED)
{ fprintf(stderr, "fromwire_wireaddr called!\n"); abort(); }

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

@ -27,12 +27,15 @@ char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr
/* Generated stub for fromwire_gossip_store_channel_amount */
bool fromwire_gossip_store_channel_amount(const void *p UNNEEDED, struct amount_sat *satoshis UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_channel_amount called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_private_channel */
bool fromwire_gossip_store_private_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct amount_sat *satoshis UNNEEDED, u8 **announcement UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_private_channel called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_private_update */
bool fromwire_gossip_store_private_update(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **update UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_private_update called!\n"); abort(); }
/* Generated stub for fromwire_gossipd_local_add_channel */
bool fromwire_gossipd_local_add_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct node_id *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED, u8 **features UNNEEDED)
{ fprintf(stderr, "fromwire_gossipd_local_add_channel called!\n"); abort(); }
/* Generated stub for fromwire_gossipd_local_add_channel_obs */
bool fromwire_gossipd_local_add_channel_obs(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct node_id *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED, u8 **features UNNEEDED)
{ fprintf(stderr, "fromwire_gossipd_local_add_channel_obs called!\n"); abort(); }
/* Generated stub for fromwire_wireaddr */
bool fromwire_wireaddr(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct wireaddr *addr UNNEEDED)
{ fprintf(stderr, "fromwire_wireaddr called!\n"); abort(); }
@ -66,6 +69,13 @@ void *notleak_(const void *ptr UNNEEDED, bool plus_children UNNEEDED)
/* Generated stub for peer_supplied_good_gossip */
void peer_supplied_good_gossip(struct peer *peer UNNEEDED, size_t amount UNNEEDED)
{ fprintf(stderr, "peer_supplied_good_gossip called!\n"); abort(); }
/* Generated stub for private_channel_announcement */
const u8 *private_channel_announcement(const tal_t *ctx UNNEEDED,
const struct short_channel_id *scid UNNEEDED,
const struct node_id *local_node_id UNNEEDED,
const struct node_id *remote_node_id UNNEEDED,
const u8 *features UNNEEDED)
{ fprintf(stderr, "private_channel_announcement called!\n"); abort(); }
/* Generated stub for sanitize_error */
char *sanitize_error(const tal_t *ctx UNNEEDED, const u8 *errmsg UNNEEDED,
struct channel_id *channel_id UNNEEDED)
@ -85,6 +95,9 @@ u8 *towire_gossip_store_channel_amount(const tal_t *ctx UNNEEDED, struct amount_
/* Generated stub for towire_gossip_store_delete_chan */
u8 *towire_gossip_store_delete_chan(const tal_t *ctx UNNEEDED, const struct short_channel_id *scid UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_delete_chan called!\n"); abort(); }
/* Generated stub for towire_gossip_store_private_channel */
u8 *towire_gossip_store_private_channel(const tal_t *ctx UNNEEDED, struct amount_sat satoshis UNNEEDED, const u8 *announcement UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_private_channel called!\n"); abort(); }
/* Generated stub for towire_gossip_store_private_update */
u8 *towire_gossip_store_private_update(const tal_t *ctx UNNEEDED, const u8 *update UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_private_update called!\n"); abort(); }

19
gossipd/test/run-find_route.c

@ -27,12 +27,15 @@ char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr
/* Generated stub for fromwire_gossip_store_channel_amount */
bool fromwire_gossip_store_channel_amount(const void *p UNNEEDED, struct amount_sat *satoshis UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_channel_amount called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_private_channel */
bool fromwire_gossip_store_private_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct amount_sat *satoshis UNNEEDED, u8 **announcement UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_private_channel called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_private_update */
bool fromwire_gossip_store_private_update(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **update UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_private_update called!\n"); abort(); }
/* Generated stub for fromwire_gossipd_local_add_channel */
bool fromwire_gossipd_local_add_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct node_id *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED, u8 **features UNNEEDED)
{ fprintf(stderr, "fromwire_gossipd_local_add_channel called!\n"); abort(); }
/* Generated stub for fromwire_gossipd_local_add_channel_obs */
bool fromwire_gossipd_local_add_channel_obs(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct node_id *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED, u8 **features UNNEEDED)
{ fprintf(stderr, "fromwire_gossipd_local_add_channel_obs called!\n"); abort(); }
/* Generated stub for fromwire_wireaddr */
bool fromwire_wireaddr(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct wireaddr *addr UNNEEDED)
{ fprintf(stderr, "fromwire_wireaddr called!\n"); abort(); }
@ -66,6 +69,13 @@ void *notleak_(const void *ptr UNNEEDED, bool plus_children UNNEEDED)
/* Generated stub for peer_supplied_good_gossip */
void peer_supplied_good_gossip(struct peer *peer UNNEEDED, size_t amount UNNEEDED)
{ fprintf(stderr, "peer_supplied_good_gossip called!\n"); abort(); }
/* Generated stub for private_channel_announcement */
const u8 *private_channel_announcement(const tal_t *ctx UNNEEDED,
const struct short_channel_id *scid UNNEEDED,
const struct node_id *local_node_id UNNEEDED,
const struct node_id *remote_node_id UNNEEDED,
const u8 *features UNNEEDED)
{ fprintf(stderr, "private_channel_announcement called!\n"); abort(); }
/* Generated stub for sanitize_error */
char *sanitize_error(const tal_t *ctx UNNEEDED, const u8 *errmsg UNNEEDED,
struct channel_id *channel_id UNNEEDED)
@ -85,6 +95,9 @@ u8 *towire_gossip_store_channel_amount(const tal_t *ctx UNNEEDED, struct amount_
/* Generated stub for towire_gossip_store_delete_chan */
u8 *towire_gossip_store_delete_chan(const tal_t *ctx UNNEEDED, const struct short_channel_id *scid UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_delete_chan called!\n"); abort(); }
/* Generated stub for towire_gossip_store_private_channel */
u8 *towire_gossip_store_private_channel(const tal_t *ctx UNNEEDED, struct amount_sat satoshis UNNEEDED, const u8 *announcement UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_private_channel called!\n"); abort(); }
/* Generated stub for towire_gossip_store_private_update */
u8 *towire_gossip_store_private_update(const tal_t *ctx UNNEEDED, const u8 *update UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_private_update called!\n"); abort(); }

19
gossipd/test/run-overlong.c

@ -27,12 +27,15 @@ char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr
/* Generated stub for fromwire_gossip_store_channel_amount */
bool fromwire_gossip_store_channel_amount(const void *p UNNEEDED, struct amount_sat *satoshis UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_channel_amount called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_private_channel */
bool fromwire_gossip_store_private_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct amount_sat *satoshis UNNEEDED, u8 **announcement UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_private_channel called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_private_update */
bool fromwire_gossip_store_private_update(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **update UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_private_update called!\n"); abort(); }
/* Generated stub for fromwire_gossipd_local_add_channel */
bool fromwire_gossipd_local_add_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct node_id *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED, u8 **features UNNEEDED)
{ fprintf(stderr, "fromwire_gossipd_local_add_channel called!\n"); abort(); }
/* Generated stub for fromwire_gossipd_local_add_channel_obs */
bool fromwire_gossipd_local_add_channel_obs(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct node_id *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED, u8 **features UNNEEDED)
{ fprintf(stderr, "fromwire_gossipd_local_add_channel_obs called!\n"); abort(); }
/* Generated stub for fromwire_wireaddr */
bool fromwire_wireaddr(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct wireaddr *addr UNNEEDED)
{ fprintf(stderr, "fromwire_wireaddr called!\n"); abort(); }
@ -66,6 +69,13 @@ void *notleak_(const void *ptr UNNEEDED, bool plus_children UNNEEDED)
/* Generated stub for peer_supplied_good_gossip */
void peer_supplied_good_gossip(struct peer *peer UNNEEDED, size_t amount UNNEEDED)
{ fprintf(stderr, "peer_supplied_good_gossip called!\n"); abort(); }
/* Generated stub for private_channel_announcement */
const u8 *private_channel_announcement(const tal_t *ctx UNNEEDED,
const struct short_channel_id *scid UNNEEDED,
const struct node_id *local_node_id UNNEEDED,
const struct node_id *remote_node_id UNNEEDED,
const u8 *features UNNEEDED)
{ fprintf(stderr, "private_channel_announcement called!\n"); abort(); }
/* Generated stub for sanitize_error */
char *sanitize_error(const tal_t *ctx UNNEEDED, const u8 *errmsg UNNEEDED,
struct channel_id *channel_id UNNEEDED)
@ -85,6 +95,9 @@ u8 *towire_gossip_store_channel_amount(const tal_t *ctx UNNEEDED, struct amount_
/* Generated stub for towire_gossip_store_delete_chan */
u8 *towire_gossip_store_delete_chan(const tal_t *ctx UNNEEDED, const struct short_channel_id *scid UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_delete_chan called!\n"); abort(); }
/* Generated stub for towire_gossip_store_private_channel */
u8 *towire_gossip_store_private_channel(const tal_t *ctx UNNEEDED, struct amount_sat satoshis UNNEEDED, const u8 *announcement UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_private_channel called!\n"); abort(); }
/* Generated stub for towire_gossip_store_private_update */
u8 *towire_gossip_store_private_update(const tal_t *ctx UNNEEDED, const u8 *update UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_private_update called!\n"); abort(); }

6
gossipd/test/run-txout_failure.c

@ -12,9 +12,9 @@ bool cupdate_different(struct gossip_store *gs UNNEEDED,
/* Generated stub for fmt_wireaddr_without_port */
char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr *a UNNEEDED)
{ fprintf(stderr, "fmt_wireaddr_without_port called!\n"); abort(); }
/* Generated stub for fromwire_gossipd_local_add_channel */
bool fromwire_gossipd_local_add_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct node_id *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED, u8 **features UNNEEDED)
{ fprintf(stderr, "fromwire_gossipd_local_add_channel called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_private_channel */
bool fromwire_gossip_store_private_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct amount_sat *satoshis UNNEEDED, u8 **announcement UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_private_channel called!\n"); abort(); }
/* Generated stub for fromwire_wireaddr */
bool fromwire_wireaddr(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct wireaddr *addr UNNEEDED)
{ fprintf(stderr, "fromwire_wireaddr called!\n"); abort(); }

17
tests/test_gossip.py

@ -918,7 +918,7 @@ def test_gossip_store_load(node_factory):
"""Make sure we can read canned gossip store"""
l1 = node_factory.get_node(start=False)
with open(os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, 'gossip_store'), 'wb') as f:
f.write(bytearray.fromhex("08" # GOSSIP_STORE_VERSION
f.write(bytearray.fromhex("09" # GOSSIP_STORE_VERSION
"000001b0" # len
"fea676e8" # csum
"5b8d9b44" # timestamp
@ -950,7 +950,7 @@ def test_gossip_store_load_announce_before_update(node_factory):
"""Make sure we can read canned gossip store with node_announce before update. This happens when a channel_update gets replaced, leaving node_announce before it"""
l1 = node_factory.get_node(start=False)
with open(os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, 'gossip_store'), 'wb') as f:
f.write(bytearray.fromhex("08" # GOSSIP_STORE_VERSION
f.write(bytearray.fromhex("09" # GOSSIP_STORE_VERSION
"000001b0" # len
"fea676e8" # csum
"5b8d9b44" # timestamp
@ -993,7 +993,7 @@ def test_gossip_store_load_amount_truncated(node_factory):
"""Make sure we can read canned gossip store with truncated amount"""
l1 = node_factory.get_node(start=False, allow_broken_log=True)
with open(os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, 'gossip_store'), 'wb') as f:
f.write(bytearray.fromhex("08" # GOSSIP_STORE_VERSION
f.write(bytearray.fromhex("09" # GOSSIP_STORE_VERSION
"000001b0" # len
"fea676e8" # csum
"5b8d9b44" # timestamp
@ -1342,9 +1342,10 @@ def setup_gossip_store_test(node_factory, bitcoind):
wait_for(lambda: [c['base_fee_millisatoshi'] for c in l2.rpc.listchannels(scid12)['channels']] == [20, 20])
# Records in store now looks (something) like:
# DELETED: local-add-channel (scid23)
# DELETED: private channel_announcement (scid23)
# DELETED: private channel_update (scid23/0)
# DELETED: private channel_update (scid23/1)
# delete channel (scid23)
# channel_announcement (scid23)
# channel_amount
# DELETED: channel_update (scid23/0)
@ -1352,7 +1353,7 @@ def setup_gossip_store_test(node_factory, bitcoind):
# node_announcement
# node_announcement
# channel_update (scid23)
# local_add_channel (scid12)
# private channel_announcement (scid12)
# DELETED: private channel_update (scid12/0)
# DELETED: private channel_update (scid12/1)
# channel_update (scid23)
@ -1419,7 +1420,7 @@ def test_gossip_store_load_no_channel_update(node_factory):
# A channel announcement with no channel_update.
with open(os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, 'gossip_store'), 'wb') as f:
f.write(bytearray.fromhex("08" # GOSSIP_STORE_VERSION
f.write(bytearray.fromhex("09" # GOSSIP_STORE_VERSION
"000001b0" # len
"fea676e8" # csum
"5b8d9b44" # timestamp
@ -1446,7 +1447,7 @@ def test_gossip_store_load_no_channel_update(node_factory):
l1.rpc.call('dev-compact-gossip-store')
with open(os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, 'gossip_store'), "rb") as f:
assert bytearray(f.read()) == bytearray.fromhex("08")
assert bytearray(f.read()) == bytearray.fromhex("09")
@unittest.skipIf(not DEVELOPER, "gossip without DEVELOPER=1 is slow")
@ -1457,7 +1458,7 @@ def test_gossip_store_compact_on_load(node_factory, bitcoind):
wait_for(lambda: l2.daemon.is_in_log(r'gossip_store_compact_offline: [5-8] deleted, 9 copied'))
wait_for(lambda: l2.daemon.is_in_log(r'gossip_store: Read 1/4/2/0 cannounce/cupdate/nannounce/cdelete from store \(0 deleted\) in [0-9]* bytes'))
wait_for(lambda: l2.daemon.is_in_log(r'gossip_store: Read 2/4/2/0 cannounce/cupdate/nannounce/cdelete from store \(0 deleted\) in [0-9]* bytes'))
def test_gossip_announce_invalid_block(node_factory, bitcoind):

Loading…
Cancel
Save