-
Notifications
You must be signed in to change notification settings - Fork 428
fuzz: chanmon_consistency payment tracking and assertions #4321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Replace the separate `p_id: u8` (for payment hash generation) and `p_idx: u64` (for payment IDs) with a single `p_ctr: u64` counter. The two counters served different purposes but can be unified since `create_inbound_payment_for_hash` doesn't perform duplicate detection with the parameters we use. This simplifies the code by removing redundant state. Co-Authored-By: Claude Opus 4.5 <[email protected]> Co-Authored-By: Matt Corallo <[email protected]>
|
👋 Thanks for assigning @TheBlueMatt as a reviewer! |
Change `get_payment_secret_hash` to return `(PaymentSecret, PaymentHash)` directly instead of `Option<...>`. The function calls `create_inbound_payment_for_hash` with `min_value_msat=None` and `min_final_cltv_expiry=None`, which cannot fail. Remove the retry loop and use `.expect()` since the call will always succeed with these parameters. Co-Authored-By: Claude Opus 4.5 <[email protected]> Co-Authored-By: Matt Corallo <[email protected]>
Rename `middle_chan_id` to `middle_scid` and `dest_chan_id` to `dest_scid` in `send_hop_noret` and `send_hop_payment`. These parameters are short channel IDs (SCIDs), not channel IDs, so the rename improves clarity. Co-Authored-By: Claude Opus 4.5 <[email protected]> Co-Authored-By: Matt Corallo <[email protected]>
f4df930 to
486b7cd
Compare
Add transaction tracking to TestBroadcaster and verify no unexpected broadcasts occur during normal fuzzing operation: - Store all broadcast transactions in TestBroadcaster - Clear the broadcast set after initial channel opens - Assert in test_return! that no transactions were broadcast Co-Authored-By: Claude Opus 4.5 <[email protected]>
Replace the standalone `send_noret` and `send_hop_noret` functions with closures defined inside the main loop. This allows them to capture the `nodes` array and use simple node indices (0, 1, 2) instead of passing `&nodes[x]` references at each call site. The `send_payment` and `send_hop_payment` functions are modified to take pre-computed `PaymentSecret`, `PaymentHash`, and `PaymentId` parameters, with the closures handling the credential generation. This centralizes where `PaymentId` is constructed, which will make it easier to add payment tracking in a future change. Co-Authored-By: Claude Opus 4.5 <[email protected]> Co-Authored-By: Matt Corallo <[email protected]>
Track payment lifecycle by maintaining pending_payments and resolved_payments arrays per node: - When sending a payment, add its PaymentId to pending_payments - On PaymentSent/PaymentFailed events, move the PaymentId from pending to resolved (or assert it was already resolved for duplicate events) This tracking enables verifying payment state consistency after node restarts. Co-Authored-By: Claude Opus 4.5 <[email protected]> Co-Authored-By: Matt Corallo <[email protected]>
5c9a6e1 to
a25cd85
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4321 +/- ##
=======================================
Coverage 86.61% 86.61%
=======================================
Files 158 158
Lines 102730 102730
Branches 102730 102730
=======================================
Hits 88984 88984
+ Misses 11328 11327 -1
- Partials 2418 2419 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@TheBlueMatt not sure if you want to review your own dissected code |
This refactors the chanmon_consistency fuzzer to simplify payment handling and add verification. The payment counters are consolidated, helper functions are converted to closures using node indices, and transaction broadcast tracking is added with assertions to catch unexpected broadcasts. Finally, payment lifecycle tracking is introduced to enable verifying payment state consistency.
Picked from https://github.com/TheBlueMatt/rust-lightning/tree/2025-04-fuzz-pending-payments