-
Notifications
You must be signed in to change notification settings - Fork 407
Tweak and Expand the chanmon_consistency fuzz target #753
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
Tweak and Expand the chanmon_consistency fuzz target #753
Conversation
Codecov Report
@@ Coverage Diff @@
## main #753 +/- ##
==========================================
- Coverage 91.45% 91.38% -0.07%
==========================================
Files 37 37
Lines 22249 22249
==========================================
- Hits 20347 20333 -14
- Misses 1902 1916 +14
Continue to review full report at Codecov.
|
95671e2
to
ecb3fb5
Compare
ecb3fb5
to
6626d08
Compare
fuzz/src/chanmon_consistency.rs
Outdated
match err.as_str() { | ||
"Peer for first hop currently disconnected/pending monitor update!" => test_return!(), | ||
_ if err.starts_with("Cannot push more than their max accepted HTLCs ") => test_return!(), | ||
_ if err.starts_with("Cannot send value that would put us over the max HTLC value in flight our peer will accept ") => test_return!(), | ||
_ if err.starts_with("Cannot send value that would put our balance under counterparty-announced channel reserve value") => test_return!(), | ||
_ if err.starts_with("Cannot send value that would overdraw remaining funds.") => test_return!(), | ||
_ if err.starts_with("Cannot send value that would not leave enough to pay for fees.") => test_return!(), | ||
_ => panic!(err), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critically, we keep going after hitting an error, as there's no
reason channels should get out of sync even if a send fails.
Doesn't this still result in the test returning if a send fails?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No - we only return
from do_test
if either we read a byte we don't know how to process or we run out of bytes. Prior to this we would test_return!()
if we max out sending over a channel as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aye, think it was changed as the quoted code is using test_return!
but now is {}
. So should be good.
0x03 => *monitor_a.update_ret.lock().unwrap() = Ok(()), | ||
0x04 => *monitor_b.update_ret.lock().unwrap() = Ok(()), | ||
0x05 => *monitor_c.update_ret.lock().unwrap() = Ok(()), | ||
0x06 => { | ||
0x04 => *monitor_a.update_ret.lock().unwrap() = Ok(()), | ||
0x05 => *monitor_b.update_ret.lock().unwrap() = Ok(()), | ||
0x06 => *monitor_c.update_ret.lock().unwrap() = Ok(()), | ||
|
||
0x08 => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you help me understand why values like 0x03
and 0x07
are skipped?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep related message groups having the same binary prefix. Honestly it probably doesn't matter, but fuzzers do do some bit-twiddling-based tweaking and I figured no reason to not have bit-twiddling often have similar effects. I noted it in a new comment.
Instead of simply always considering a payment-send failure as acceptable (and aborting fuzzing), we check that a payment send failure is from a list of errors that we know we can hit, mostly around maxing out our channel balance. Critically, we keep going after hitting an error, as there's no reason channels should get out of sync even if a send fails.
This should make it a bit easier for the fuzzer to hit any given balance breakdown during run as well as tweaks the command strings to be more bit-pattern friendly.
In previous versions of related commits, the macros in chanmon_consistency ended up blowing up rustc a bit resulting in 20+GB memory usage and long compile times. Shorter function bodies by avoiding macros where possible fix this.
We should never generate Ignore-action HandleError events anymore
This adds a new command string in the chanmon_consistency fuzzer which tests that, once all pending HTLCs are settled, at least one side of a channel can still send funds. While this should have caught the recent(ish) spec bug where channels could get stuck, I did not attempt to reproduce said bug with this patch.
6626d08
to
6563f7a
Compare
Gonna take so that we can talk about/analyze things like #757 against git latest instead of against some random branch. |
I spent some time with chanmon_consistency to expand the errors it could catch. Luckily no bugs turned up (yet) from this work.