Skip to content

fuzz: add test for the gossipd message processing#9115

Open
NishantBansal2003 wants to merge 3 commits into
ElementsProject:masterfrom
NishantBansal2003:fuzz-gossipd
Open

fuzz: add test for the gossipd message processing#9115
NishantBansal2003 wants to merge 3 commits into
ElementsProject:masterfrom
NishantBansal2003:fuzz-gossipd

Conversation

@NishantBansal2003
Copy link
Copy Markdown
Contributor

Add state machine fuzz tests for gossipd message processing. Currently, all message states handled by gossipd are covered here, but other gossip messages like gossip_timestamp_filter, query_short_channel_id, and query_channel_range are handled by connectd, so those states need to be explicitly tested in separate fuzz tests.

Most of the work here is based on #8423, so I've added the PR author as a co-author. I also rebased the changes and fixed the entropy issue afterward. Additionally, some new states have been added (e.g. UTXO lookup, update blockheight, seeker state machine), and a few existing states have been updated to support e2e message processing (e.g. UTXO lookup in channel announcements).

Also, in the ref PR there was a discussion about issues with multi worker fuzzing. I’ve addressed that in 26f7b52. I think with this we can run regression tests on some previously observed edge-cases

Checklist

Before submitting the PR, ensure the following tasks are completed. If an item is not applicable to your PR, please mark it as checked:

  • The changelog has been updated in the relevant commit(s) according to the guidelines.
  • Tests have been added or modified to reflect the changes.
  • Documentation has been reviewed and updated as needed.
  • Related issues have been listed and linked, including any that this PR closes.
  • Important All PRs must consider how to reverse any persistent changes for tools/lightning-downgrade

NishantBansal2003 and others added 3 commits May 5, 2026 22:43
Use tal_strcat() to derive the .tmp, .compact, and .corrupt paths from
GOSSIP_STORE_FILENAME at runtime, instead of hardcoding the literals.

No behaviour change in production. This is done for fuzz-gossipd: it
lets the fuzz target override GOSSIP_STORE_FILENAME with a per-process
path, so parallel libFuzzer workers don't race on the same files in CWD.

Changelog-None

Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Changelog-None

Co-authored-by: Chandra Pratap <Chand-ra@users.noreply.github.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Comment thread gossipd/gossip_store.c

#define GOSSIP_STORE_TEMP_FILENAME "gossip_store.tmp"
#define GOSSIP_STORE_TEMP_FILENAME tal_strcat(tmpctx, GOSSIP_STORE_FILENAME, ".tmp")
#define GOSSIP_STORE_CORRUPT_FILENAME tal_strcat(tmpctx, GOSSIP_STORE_FILENAME, ".corrupt")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The correct C way to do this is:

#define GOSSIP_STORE_TEMP_FILENAME    GOSSIP_STORE_FILENAME ".tmp"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but that would fail in our fuzzing setup, where we need to define a different GOSSIP_STORE_FILENAME for each worker to avoid corruption from multiple fuzz workers accessing the same file. String concatenation only works with string literals, but here we need GOSSIP_STORE_FILENAME to be a variable so that it can vary across workers

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