Skip to content

fuzz: cover deferred writing in chanmon_consistency#4465

Draft
joostjager wants to merge 1 commit intolightningdevkit:mainfrom
joostjager:chain-mon-internal-deferred-writes-with-fuzz
Draft

fuzz: cover deferred writing in chanmon_consistency#4465
joostjager wants to merge 1 commit intolightningdevkit:mainfrom
joostjager:chain-mon-internal-deferred-writes-with-fuzz

Conversation

@joostjager
Copy link
Copy Markdown
Contributor

@joostjager joostjager commented Mar 6, 2026

Adds fuzz coverage for #4351

@ldk-reviews-bot
Copy link
Copy Markdown

👋 Hi! I see this is a draft PR.
I'll wait to assign reviewers until you mark it as ready for review.
Just convert it out of draft status when you're ready for review!

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.99%. Comparing base (423c1dc) to head (d4bf3e0).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4465      +/-   ##
==========================================
- Coverage   87.00%   86.99%   -0.02%     
==========================================
  Files         163      163              
  Lines      109002   109002              
  Branches   109002   109002              
==========================================
- Hits        94839    94828      -11     
- Misses      11678    11687       +9     
- Partials     2485     2487       +2     
Flag Coverage Δ
fuzzing 38.35% <ø> (+0.18%) ⬆️
tests 86.09% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@joostjager joostjager force-pushed the chain-mon-internal-deferred-writes-with-fuzz branch from 51afc25 to 0aebb10 Compare March 19, 2026 07:51
@joostjager
Copy link
Copy Markdown
Contributor Author

Rebased

@joostjager
Copy link
Copy Markdown
Contributor Author

Will hold off on this until pre-existing fuzz failures #4496 and #4472 are in

@joostjager joostjager force-pushed the chain-mon-internal-deferred-writes-with-fuzz branch from 0aebb10 to 6274ba0 Compare March 20, 2026 17:52
@joostjager
Copy link
Copy Markdown
Contributor Author

Prerequisites are in, rebased.

@TheBlueMatt
Copy link
Copy Markdown
Collaborator

This LGTM, why is it draft?

@joostjager
Copy link
Copy Markdown
Contributor Author

I first wanted to do a serious local run, but then it turned out there are so many pre-existing fuzz failures that it is hard to see what's new. I've bisected the failures to the various PRs that introduced them.

@joostjager
Copy link
Copy Markdown
Contributor Author

joostjager commented Mar 22, 2026

Although for this PR I could just see if anything pops up that doesnt repro on main. Will do that.

@joostjager
Copy link
Copy Markdown
Contributor Author

joostjager commented Mar 23, 2026

Several newly introduced fuzz failures to address:

7084a32219ffa61b1919192119197084a32219ff4400001d228012ffab
10fa0040801170704040198040111911191f1f1170bbff1170ffb3b2b6
10000150804211be707040198011191f1119401f401f0aa97210b6ff25
10000150804211707040198011191f11191f1a4040a91f7210b6ff25

@joostjager
Copy link
Copy Markdown
Contributor Author

Zoomed in on one of those sequences, and it seems it is reproducible with another string without deferred mode too.

0270801109191109191f1f10b6ff

@joostjager joostjager force-pushed the chain-mon-internal-deferred-writes-with-fuzz branch from 6274ba0 to c6da16e Compare April 15, 2026 04:28
Add a deferred flag to TestChainMonitor that controls whether the
underlying ChainMonitor queues operations instead of executing them
immediately. The flag is derived from the first fuzz input byte so each
of the three nodes can independently run in deferred or immediate mode,
while the same byte also selects the channel type.

In deferred mode, watch_channel and update_channel always return
InProgress. A new flush_and_update_latest_monitors method drains the
queued operations and, when the persister reports Completed, promotes
the pending shadow monitor snapshots to persisted state. This method is
called before release_pending_monitor_events, at each point where the
fuzzer completes pending monitor updates, and after watch_channel during
node reload so the node starts from a consistent state.

The first-byte config layout now uses bits 0 to 2 for initial monitor
status, bits 3 to 4 for channel type, and bits 5 to 7 for deferred
monitor writes. This fixes the rebase conflict where deferred mode
still referenced the pre-channel-type bit layout.

AI tools were used in preparing this commit.
@joostjager joostjager force-pushed the chain-mon-internal-deferred-writes-with-fuzz branch from c6da16e to d4bf3e0 Compare April 15, 2026 04:36
@joostjager
Copy link
Copy Markdown
Contributor Author

Dependency: #4520

@joostjager joostjager self-assigned this Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants