Skip to content

Commit

Permalink
queries: make sure scids are in order.
Browse files Browse the repository at this point in the history
I thought LND had a bug, but turns out it doesn't like out-of-order
short_channel_ids: in fact, the spec says they have to be in order!

This means we use uintmap instead of a htable for unknown_scids and
stale_scids so they're nicely ordered.

But our nodes-missing-announcements probe is harder since they can
also contain duplicates: we switch that to iterate through channels
rather than nodes.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and niftynei committed Oct 11, 2019
1 parent 1f9de04 commit 9485919
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 140 deletions.
11 changes: 10 additions & 1 deletion gossipd/queries.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,17 @@ bool query_short_channel_ids(struct daemon *daemon,
return false;

encoded = encoding_start(tmpctx);
for (size_t i = 0; i < tal_count(scids); i++)
for (size_t i = 0; i < tal_count(scids); i++) {
/* BOLT #7:
*
* Encoding types:
* * `0`: uncompressed array of `short_channel_id` types, in
* ascending order.
* * `1`: array of `short_channel_id` types, in ascending order
*/
assert(i == 0 || scids[i].u64 > scids[i-1].u64);
encoding_add_short_channel_id(&encoded, &scids[i]);
}

if (!encoding_end_prepend_type(&encoded, max_encoded_bytes)) {
status_broken("query_short_channel_ids: %zu is too many",
Expand Down
Loading

0 comments on commit 9485919

Please sign in to comment.