Skip to content

Gossmap: compaction support#8869

Merged
rustyrussell merged 1 commit intoElementsProject:masterfrom
rustyrussell:gossmap-compact
Feb 9, 2026
Merged

Gossmap: compaction support#8869
rustyrussell merged 1 commit intoElementsProject:masterfrom
rustyrussell:gossmap-compact

Conversation

@rustyrussell
Copy link
Contributor

@rustyrussell rustyrussell commented Jan 28, 2026

Based on #8878 -- Merged

We used to do compaction of the gossip store, but it was buggy. So now we do it on every startup (which is slow). Better is to do it when required, using a separate process.

@rustyrussell rustyrussell added this to the v26.04 milestone Jan 28, 2026
@rustyrussell rustyrussell requested a review from cdecker as a code owner January 28, 2026 03:43
@rustyrussell rustyrussell force-pushed the gossmap-compact branch 7 times, most recently from e967d40 to 2639a79 Compare February 3, 2026 02:59
@rustyrussell rustyrussell force-pushed the gossmap-compact branch 6 times, most recently from 9024e31 to cc2fade Compare February 6, 2026 21:16
@rustyrussell rustyrussell enabled auto-merge (rebase) February 6, 2026 23:03
@daywalker90
Copy link
Collaborator

I have tested cc2fade and i get a crash with this test:

def test_gossip(node_factory, bitcoind):
    l1, l2, l3, l4 = node_factory.get_nodes(
        4,
        opts=[
            {},
            {},
            {},
            {},
        ],
    )
    nodes = [l1, l2, l3, l4]

    l1.fundwallet(10_000_000)
    l2.fundwallet(10_000_000)
    l3.fundwallet(10_000_000)
    l4.fundwallet(10_000_000)
    l2.rpc.fundchannel(
        l4.info["id"] + "@localhost:" + str(l4.port),
        1_000_000,
    )
    l3.rpc.fundchannel(
        l4.info["id"] + "@localhost:" + str(l4.port),
        1_000_000,
    )
    l4.rpc.fundchannel(
        l1.info["id"] + "@localhost:" + str(l1.port),
        1_000_000,
    )
    bitcoind.generate_block(1)
    sync_blockheight(bitcoind, nodes)
    l4.rpc.fundchannel(
        l1.info["id"] + "@localhost:" + str(l1.port),
        1_000_000,
    )

    bitcoind.generate_block(6)
    sync_blockheight(bitcoind, nodes)

    wait_for(lambda: len(l1.rpc.listpeerchannels()["channels"]) == 2)
    l4_chans = l1.rpc.listpeerchannels(l4.info["id"])["channels"]
    scid_l1_l4_1 = l4_chans[0]["short_channel_id"]
    scid_l2_l4 = l2.rpc.listpeerchannels(l4.info["id"])["channels"][0][
        "short_channel_id"
    ]

    wait_for(lambda: len(l1.rpc.listchannels()["channels"]) == 8)

    l1.rpc.close(scid_l1_l4_1)
    bitcoind.generate_block(6, wait_for_mempool=1)
    sync_blockheight(bitcoind, nodes)

    # wait_for(lambda: len(l1.rpc.listchannels()["channels"]) == 6)

    l1.restart()
    l1.rpc.connect(l2.info["id"] + "@localhost:" + str(l2.port))
    l1.rpc.connect(l3.info["id"] + "@localhost:" + str(l3.port))
    l1.rpc.connect(l4.info["id"] + "@localhost:" + str(l4.port))

    # wait_for(lambda: len(l1.rpc.listchannels()["channels"]) == 6)

    l2.rpc.close(scid_l2_l4)
    bitcoind.generate_block(1, wait_for_mempool=1)
    sync_blockheight(bitcoind, nodes)

    # wait_for(lambda: len(l1.rpc.listchannels()["channels"]) == 4)

    l1.rpc.call("dev-compact-gossip-store", [])

    # wait_for(lambda: len(l1.rpc.listpeerchannels()["channels"]) == 2)
    # wait_for(lambda: len(l1.rpc.listchannels()["channels"]) == 4)

    l4.rpc.fundchannel(
        l1.info["id"] + "@localhost:" + str(l1.port),
        1_000_000,
    )

    bitcoind.generate_block(6)
    sync_blockheight(bitcoind, nodes)

    wait_for(lambda: len(l1.rpc.listchannels()["channels"]) == 6)
lightningd-1 2026-02-07T14:29:18.185Z **BROKEN** gossipd: gossip_store: get delete entry offset 4055/4151 (version v25.12-278-gcc2fade)
lightningd-1 2026-02-07T14:29:18.185Z **BROKEN** gossipd: backtrace: common/daemon.c:46 (send_backtrace) 0x562ed90bdbfd
lightningd-1 2026-02-07T14:29:18.185Z **BROKEN** gossipd: backtrace: common/status.c:207 (status_failed) 0x562ed90c2515
lightningd-1 2026-02-07T14:29:18.185Z **BROKEN** gossipd: backtrace: gossipd/gossip_store.c:534 (gossip_store_get_with_hdr) 0x562ed90b637c
lightningd-1 2026-02-07T14:29:18.185Z **BROKEN** gossipd: backtrace: gossipd/gossip_store.c:559 (check_msg_type) 0x562ed90b63f7
lightningd-1 2026-02-07T14:29:18.185Z **BROKEN** gossipd: backtrace: gossipd/gossip_store.c:577 (gossip_store_set_flag) 0x562ed90b67fc
lightningd-1 2026-02-07T14:29:18.185Z **BROKEN** gossipd: backtrace: gossipd/gossip_store.c:629 (gossip_store_del) 0x562ed90b6a03
lightningd-1 2026-02-07T14:29:18.185Z **BROKEN** gossipd: backtrace: gossipd/gossmap_manage.c:1362 (gossmap_manage_new_block) 0x562ed90b9b31
lightningd-1 2026-02-07T14:29:18.185Z **BROKEN** gossipd: backtrace: gossipd/gossipd.c:430 (new_blockheight) 0x562ed90b4730
lightningd-1 2026-02-07T14:29:18.185Z **BROKEN** gossipd: backtrace: gossipd/gossipd.c:532 (recv_req) 0x562ed90b4a79
lightningd-1 2026-02-07T14:29:18.185Z **BROKEN** gossipd: backtrace: common/daemon_conn.c:35 (handle_read) 0x562ed90bde7c
lightningd-1 2026-02-07T14:29:18.185Z **BROKEN** gossipd: backtrace: ccan/ccan/io/io.c:60 (next_plan) 0x562ed90cc80c
lightningd-1 2026-02-07T14:29:18.185Z **BROKEN** gossipd: backtrace: ccan/ccan/io/io.c:422 (do_plan) 0x562ed90ccae5
lightningd-1 2026-02-07T14:29:18.185Z **BROKEN** gossipd: backtrace: ccan/ccan/io/io.c:439 (io_ready) 0x562ed90ccb9e
lightningd-1 2026-02-07T14:29:18.185Z **BROKEN** gossipd: backtrace: ccan/ccan/io/poll.c:470 (io_loop) 0x562ed90cdfab
lightningd-1 2026-02-07T14:29:18.185Z **BROKEN** gossipd: backtrace: gossipd/gossipd.c:609 (main) 0x562ed90b5434
lightningd-1 2026-02-07T14:29:18.185Z **BROKEN** gossipd: backtrace: ../sysdeps/nptl/libc_start_call_main.h:58 (__libc_start_call_main) 0x7fc07be32ca7
lightningd-1 2026-02-07T14:29:18.185Z **BROKEN** gossipd: backtrace: ../csu/libc-start.c:360 (__libc_start_main_impl) 0x7fc07be32d64
lightningd-1 2026-02-07T14:29:18.185Z **BROKEN** gossipd: backtrace: (null):0 ((null)) 0x562ed90b38a0
lightningd-1 2026-02-07T14:29:18.185Z **BROKEN** gossipd: backtrace: (null):0 ((null)) 0xffffffffffffffff
lightningd-1 2026-02-07T14:29:18.185Z **BROKEN** gossipd: STATUS_FAIL_INTERNAL_ERROR: gossip_store: get delete entry offset 4055/4151

It's a test from one of my plugins where i removed all my plugin specific lines. Also i would really like it if the commented wait_for lines work (they should, right?).

@rustyrussell
Copy link
Contributor Author

It's a test from one of my plugins where i removed all my plugin specific lines. Also i would really like it if the commented wait_for lines work (they should, right?).

Nice catch! It's because I didn't correctly reset the "dying_chans" array. Fixed now, and added a reduced version of this test to be sure.

The reason your wait_for lines didn't work is that we don't immediately consider a channel closed: we give it 12 blocks before stopping its use. That allows us to keep using the channel if it turns out to be a splice. We make an exception for our own channels (in that case, we will know about the splice).

@rustyrussell rustyrussell force-pushed the gossmap-compact branch 2 times, most recently from dd4c02f to 4b347dc Compare February 8, 2026 12:39
In November 2022 we seemed to increase parallelism from 2 and 3 to 10!
That is a huge load for these CI boxes, and does explain some of our
flakes.

We only run in parallel because some tests sleep, but it's diminishing
returns (GH runners have 4 VCPUs, 16GB RAM).

This reduces it so:
- Normal runs are -n 4
- Valgrind runs are -n 2
- Sanitizer runs are -n 3

If I use my beefy build box (64BG RAM) but reduce it to 4 CPUs:

Time for pytest -n 5:
Time for pytest -n 4:
Time for pytest -n 3:

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
@rustyrussell rustyrussell merged commit 1b1274d into ElementsProject:master Feb 9, 2026
62 of 66 checks passed
@daywalker90
Copy link
Collaborator

What happened here? Where is the gossip compaction code? I can't find it on master.

@rustyrussell
Copy link
Contributor Author

Something went badly wrong, I just noticed the same thing!

@rustyrussell
Copy link
Contributor Author

I will open a new PR.

@rustyrussell rustyrussell deleted the gossmap-compact branch February 16, 2026 04:21
@rustyrussell rustyrussell mentioned this pull request Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants