Skip to content

Commit c7c304b

Browse files
committed
gossmap: don't log every time we don't like a cupdate.
This happens for about 300 channels, from every process that loads the gossmap. It's not very useful to flood the logs, so just log a summary. To be fair, on my node, this is only the 11th most common message, so we will revisit the others too: ``` 1589311 DEBUG 02e01367e1d7818a7e9a0e8a52badd5c32615e07568dbe0497b6a47f9bef89d6af-connectd: peer_out WIRE_WARNING 139993 DEBUG lightningd: fixup_scan: block 786151 with 1203 txs 55388 DEBUG plugin-bcli: Log pruned 1001 entries (mem 10508118 -> 10298662) 33000 DEBUG gossipd: Unreasonable timestamp in 0102000a38ec41f9137a5a560dac6effbde059c12cb727344821cbdd4ef46964a4791a0f67cd997499a6062fc8b4284bf1b47a91541fd0e65129505f02e4d08542b16fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d61900000000000d9d56000ba40001690fe262010100900000000000000001000003e8000001f30000000000989680 23515 DEBUG hsmd: Client: Received message 14 from client 22269 DEBUG 024b9a1fa8e006f1e3937f65f66c408e6da8e1ca728ea43222a7381df1cc449605-hsmd: Got WIRE_HSMD_ECDH_REQ 14409 DEBUG gossipd: Enqueueing update for announce 0102002f7e4b4deb19947c67292e70cb22f7fac837fa9ee6269393f3c513d0431d52672e7387625856c19299cfd584e1a3f39e0f98df13c99090df9f4d5cca8446776fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d61900000000000e216b0008050001692e1c390101009000000000000003e800000000000013880000004526945a00 12534 DEBUG gossipd: Previously-rejected announce for 514127x248x1 ===> 12092 DEBUG connectd: Bad cupdate for 641641x1164x1/1, ignoring (delta=80, fee=1073742199/58) 10761 DEBUG 02e01367e1d7818a7e9a0e8a52badd5c32615e07568dbe0497b6a47f9bef89d6af-channeld-chan#70770: Got it! 10761 DEBUG 02e01367e1d7818a7e9a0e8a52badd5c32615e07568dbe0497b6a47f9bef89d6af-channeld-chan#70770: ... , awaiting 1120 10761 DEBUG 02e01367e1d7818a7e9a0e8a52badd5c32615e07568dbe0497b6a47f9bef89d6af-channeld-chan#70770: Sending master 1020 ``` Signed-off-by: Rusty Russell <[email protected]>
1 parent ed43977 commit c7c304b

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

common/gossmap.c

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -503,16 +503,14 @@ static struct gossmap_chan *add_channel(struct gossmap *map,
503503
return chan;
504504
}
505505

506-
/* Does not set hc->nodeidx! */
507-
static void fill_from_update(struct gossmap *map,
506+
/* Does not set hc->nodeidx!
507+
* Returns false if it doesn't fit in our representation: this happens
508+
* on the real network, as people set absurd fees
509+
*/
510+
static bool fill_from_update(struct gossmap *map,
508511
struct short_channel_id_dir *scidd,
509512
struct half_chan *hc,
510-
u64 cupdate_off,
511-
void (*logcb)(void *cbarg,
512-
enum log_level level,
513-
const char *fmt,
514-
...),
515-
void *cbarg)
513+
u64 cupdate_off)
516514
{
517515
/* Note that first two bytes are message type */
518516
const u64 scid_off = cupdate_off + 2 + (64 + 32);
@@ -543,18 +541,15 @@ static void fill_from_update(struct gossmap *map,
543541
hc->proportional_fee = proportional_fee;
544542
hc->delay = delay;
545543

546-
/* Check they fit: we turn off if not, log (at debug, it happens!). */
544+
/* Check they fit: we turn off if not. */
547545
if (hc->base_fee != base_fee
548546
|| hc->proportional_fee != proportional_fee
549547
|| hc->delay != delay) {
550548
hc->htlc_max = 0;
551549
hc->enabled = false;
552-
if (logcb)
553-
logcb(cbarg, LOG_DBG,
554-
"Bad cupdate for %s, ignoring (delta=%u, fee=%u/%u)",
555-
fmt_short_channel_id_dir(tmpctx, scidd),
556-
delay, base_fee, proportional_fee);
550+
return false;
557551
}
552+
return true;
558553
}
559554

560555
/* BOLT #7:
@@ -572,23 +567,24 @@ static void fill_from_update(struct gossmap *map,
572567
* * [`u32`:`fee_proportional_millionths`]
573568
* * [`u64`:`htlc_maximum_msat`]
574569
*/
575-
static void update_channel(struct gossmap *map, u64 cupdate_off)
570+
static bool update_channel(struct gossmap *map, u64 cupdate_off)
576571
{
577572
struct short_channel_id_dir scidd;
578573
struct gossmap_chan *chan;
579574
struct half_chan hc;
575+
bool ret;
580576

581-
fill_from_update(map, &scidd, &hc, cupdate_off,
582-
map->logcb, map->cbarg);
577+
ret = fill_from_update(map, &scidd, &hc, cupdate_off);
583578
chan = gossmap_find_chan(map, &scidd.scid);
584579
/* This can happen if channel gets deleted! */
585580
if (!chan)
586-
return;
581+
return ret;
587582

588583
/* Preserve this */
589584
hc.nodeidx = chan->half[scidd.dir].nodeidx;
590585
chan->half[scidd.dir] = hc;
591586
chan->cupdate_off[scidd.dir] = cupdate_off;
587+
return ret;
592588
}
593589

594590
static void remove_channel_by_deletemsg(struct gossmap *map, u64 del_off)
@@ -677,7 +673,7 @@ static bool csum_matches(const struct gossmap *map,
677673
/* Returns false only if must_be_clean is true. */
678674
static bool map_catchup(struct gossmap *map, bool must_be_clean, bool *changed)
679675
{
680-
size_t reclen;
676+
size_t reclen, num_bad_cupdates = 0;
681677

682678
*changed = false;
683679

@@ -749,7 +745,7 @@ static bool map_catchup(struct gossmap *map, bool must_be_clean, bool *changed)
749745
if (redundant && must_be_clean)
750746
return false;
751747
} else if (type == WIRE_CHANNEL_UPDATE)
752-
update_channel(map, off);
748+
num_bad_cupdates += update_channel(map, off);
753749
else if (type == WIRE_GOSSIP_STORE_DELETE_CHAN)
754750
remove_channel_by_deletemsg(map, off);
755751
else if (type == WIRE_NODE_ANNOUNCEMENT)
@@ -775,6 +771,12 @@ static bool map_catchup(struct gossmap *map, bool must_be_clean, bool *changed)
775771
*changed = true;
776772
}
777773

774+
if (num_bad_cupdates != 0)
775+
map->logcb(map->cbarg,
776+
LOG_DBG,
777+
"Got %zu bad cupdates, ignoring them (expected on mainnet)",
778+
num_bad_cupdates);
779+
778780
return true;
779781
}
780782

@@ -1168,7 +1170,7 @@ void gossmap_apply_localmods(struct gossmap *map,
11681170
off = insert_local_space(&map->local_updates, tal_bytelen(cupdatemsg));
11691171
memcpy(map->local_updates + off, cupdatemsg, tal_bytelen(cupdatemsg));
11701172
chan->cupdate_off[h] = map->map_size + tal_bytelen(map->local_announces) + off;
1171-
fill_from_update(map, &scidd, &chan->half[h], chan->cupdate_off[h], NULL, NULL);
1173+
fill_from_update(map, &scidd, &chan->half[h], chan->cupdate_off[h]);
11721174

11731175
/* We wrote the right update, correct? */
11741176
assert(short_channel_id_eq(scidd.scid, mod->scid));

0 commit comments

Comments
 (0)