fuzz: fix signature weight assumptions#4620
Conversation
|
I've assigned @wpaulino as a reviewer! |
| // The secp256k1 fuzz signer emits dummy signatures without low-S normalization, so | ||
| // DER+sighash can be one byte larger for each of the two HTLC signatures. | ||
| #[cfg(secp256k1_fuzz)] | ||
| let (htlc_success_witness_weight, htlc_timeout_witness_weight) = | ||
| (htlc_success_witness_weight + 2, htlc_timeout_witness_weight + 2); |
There was a problem hiding this comment.
Nit: The +2 correctly adjusts satisfaction_weight in the Input structs (used for the debug assertion at line 740), but the aggregated_htlc_success_input_output_pair_weight() / aggregated_htlc_timeout_input_output_pair_weight() functions called on lines 595/597 still use the unadjusted constants for batch sizing. Under secp256k1_fuzz, the per-HTLC weight is underestimated by 2 WU in those calls.
In practice this is safe — worst case is 483 HTLCs × 2 WU = 966 WU undercounting, which is absorbed by the 1000 WU USER_COINS_WEIGHT_BUDGET margin. But it's a conceptual inconsistency worth noting if this area evolves.
|
Good — I have reviewed the complete diff across all files:
Everything is internally consistent and correct. My prior inline comment about the batch-sizing inconsistency (unadjusted No issues found. |
Disable default lightning features in the fuzz crate and persister so fuzz builds do not inherit grind_signatures. Add a compile-time guard for fuzzing plus grind_signatures. Refresh the splice fuzz seed because the no-low-R weight model changes the signed funding transaction amount and fake-hash txid.
When secp256k1_fuzz is active, dummy ECDSA signatures may serialize one byte larger per signature. Use fuzz-aware witness estimates for keyed-anchor bumping and HTLC resolution so debug weight assertions and aggregation limits use the fuzz signer bound.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4620 +/- ##
==========================================
- Coverage 86.56% 86.54% -0.02%
==========================================
Files 159 159
Lines 109860 109877 +17
Branches 109860 109877 +17
==========================================
- Hits 95100 95096 -4
- Misses 12242 12262 +20
- Partials 2518 2519 +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:
|
This aligns fuzz-build signature-size assumptions with what
secp256k1_fuzzcan produce, avoiding debug-only weight assertion failures. This is a preparation for #4381