-
Notifications
You must be signed in to change notification settings - Fork 407
Add assertions for in-order block [dis]connection in ChannelManager #831
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
Add assertions for in-order block [dis]connection in ChannelManager #831
Conversation
Sadly the connected-in-order tests have to be skipped in our normal test suite as many tests violate it. Luckily we can still enforce it in the tests which run in other crates. Co-authored-by: Matt Corallo <[email protected]> Co-authored-by: Jeffrey Czyz <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #831 +/- ##
==========================================
+ Coverage 90.98% 90.99% +0.01%
==========================================
Files 48 48
Lines 26538 26546 +8
==========================================
+ Hits 24145 24155 +10
+ Misses 2393 2391 -2
Continue to review full report at Codecov.
|
} | ||
self.max_height = cmp::max(self.height, self.max_height); | ||
} | ||
|
||
fn disconnect_block(&mut self) { | ||
if self.height > 0 && (self.max_height < 6 || self.height >= self.max_height - 6) { | ||
let header = BlockHeader { version: 0x20000000, prev_blockhash: self.header_hashes[self.height], merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; | ||
let header = BlockHeader { version: 0x20000000, prev_blockhash: self.header_hashes[self.height - 1].0, merkle_root: Default::default(), time: self.header_hashes[self.height].1, bits: 42, nonce: 42 }; |
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.
Thanks for fixing! Was the time
here the problem? Wondering why it was fine as a constant prior to the change.
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.
It has to match what was used in connect_block (as otherwise the hashes wont match), so we have to store it somehow. We both had an off-by-one in the prev_blockhash
lookup and we didn't have a way to make time match.
A thought -- instead of adding |
Gonna close this, as @valentinewallace points out, it likely makes sense to pull more bits of 838 into its own PR than just this commit. |
Sadly the connected-in-order tests have to be skipped in our normal
test suite as many tests violate it. Luckily we can still enforce
it in the tests which run in other crates.
Co-authored-by: Matt Corallo [email protected]
Co-authored-by: Jeffrey Czyz [email protected]
This was initially part of #823 but was dropped to avoid needlessly delaying it.