Add assertions for in-order block [dis]connection in ChannelManager#831
Add assertions for in-order block [dis]connection in ChannelManager#831TheBlueMatt wants to merge 1 commit intolightningdevkit:mainfrom
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 <git@bluematt.me> Co-authored-by: Jeffrey Czyz <jkczyz@gmail.com>
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.
|
| 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.
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.
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 git@bluematt.me
Co-authored-by: Jeffrey Czyz jkczyz@gmail.com
This was initially part of #823 but was dropped to avoid needlessly delaying it.