funding: add coverage-guided fuzz harness for the channel-opening state machine - #10972
funding: add coverage-guided fuzz harness for the channel-opening state machine#10972MPins wants to merge 2 commits into
Conversation
🟢 PR Severity: LOW
🟢 Low (1 file)
AnalysisThis PR consists solely of a new file, Since this is the only file in the diff and it's a test file, it's also excluded from the file-count/line-count bump calculation (0 non-test files, 0 non-test lines changed), so no severity bump applies. No production code in To override, add a |
a0fcd4f to
3143430
Compare
13523ab to
e094463
Compare
Add FuzzFundingManagerFSM, a native Go fuzz harness that drives the funding manager's channel-opening state machine. A single shared SUT (Alice) is exercised against a per-flow counterparty manager (Bob), with the corpus byte stream decoded into a sequence of events over one or more concurrent funding flows. The harness treats the SUT as the system under test and imposes all adversarial/inconsistent values from the counterparty side, so the SUT validates and rejects them while, as originator, only ever emitting valid values.
createTestFundingManager takes a privKey but hardcoded alicePrivKey for the wallet controller, the signer and the secret key ring, so every manager derived funding and commitment keys from Alice's root key regardless of the identity it presented. chanIDSeed was likewise left as 32 zero bytes, making every manager produce the same pending channel ID sequence. Since lnwallet keys fundingIntents by pending channel ID alone and not by peer, that collides in a manager acting as funder for one channel and fundee for another, compiling the funder's reservation against the fundee's coinless intent. Use privKey for all three components and seed chanIDSeed from it.
e094463 to
e68ba03
Compare
Bartok9
left a comment
There was a problem hiding this comment.
Review
Thanks for investing in a real coverage-guided funding-state fuzz harness — this is high-value (channel open is a classic adversarial surface) and matches the spirit of growing fuzz coverage rather than only happy-path unit tests.
Concept ACK on the direction: event enum (funder/fundee, peer adversarial modes, conf/reorg, disconnect/reconnect) is the right shape for a state-machine fuzzer.
Please clarify before a full ACK
- Default CI / developer cost — Is the fuzz target skipped in plain
go test ./funding(build tags, short mode, or fuzz-only entrypoints)? A ~3kLOC harness is worth it if day-to-day tests stay fast; please document the intendedgo test -fuzz=... -fuzztime=invocation in the PR body orfundingpackage comment. - Failure oracle — Beyond panics, which invariants are checked (e.g. consistent chan IDs after confirm, no progress after fatal remote errors, funding tx / short chan id agreement across roles)? A short bullet list would help reviewers trust the harness.
- Entropy — Confirm peer/crypto/timing inputs are derived from fuzz data (no unintended wall-clock flakiness except explicit timeout paths).
- go.mod alignment — On a quick skim the new file imports look sensitive to btcd module paths; CI on this branch is the source of truth — green module build is enough.
Happy to re-review after the CI/skip + oracle notes land. Not requesting changes on concept — just wanting the operational story explicit for maintainers.
Overview
This PR adds
FuzzFundingManagerFSM, a native Go coverage-guided fuzz harness that exercises the funding manager's channel-opening state machine end to end. It decodes the corpus byte stream into a sequence ofevents driving one or more concurrent funding flows against the manager.
Design
*Manager; each flow gets its own counterparty (Bob) manager. The SUT is what we're testing, so all adversarial or inconsistent values are imposed by the counterparty and the SUT must validate/reject them — as originator the SUT only ever emits valid values.channel_readymust be parked, not opened.