-
Notifications
You must be signed in to change notification settings - Fork 117
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
Fix syncer download order and add sync tests #3168
Conversation
95a329e
to
03e8299
Compare
03e8299
to
8d2a425
Compare
f4635ee
to
fb2053e
Compare
367b5af
to
20a3e47
Compare
Codecov Report
@@ Coverage Diff @@
## main #3168 +/- ##
==========================================
+ Coverage 77.30% 78.11% +0.81%
==========================================
Files 265 266 +1
Lines 31415 31455 +40
==========================================
+ Hits 24284 24572 +288
+ Misses 7131 6883 -248 |
c08fbe7
to
53f2e20
Compare
53f2e20
to
592dda5
Compare
Also stop resetting the syncer when downloaded blocks are behind the tip. (Just ignore the blocks instead.)
113e717
to
19e7caa
Compare
This is a really nice test coverage increase. |
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.
Looks good! The tests are great.
There are two mut
s that I don't understand why they're needed, but it's not a big deal. I'm approving this and we can take a look later if needed.
@@ -740,7 +782,7 @@ where | |||
} | |||
} | |||
|
|||
fn update_metrics(&self) { | |||
fn update_metrics(&mut self) { |
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.
Why is this needed?
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.
If I understand it correctly, those mut
s make the compiler aware that update_metrics
has the sole access to self
. This is needed in a multi-threaded environment, but I can't remember why. I had a discussion about this with Teor.
@@ -395,7 +408,7 @@ where | |||
} | |||
|
|||
/// Get the number of currently in-flight download tasks. | |||
pub fn in_flight(&self) -> usize { | |||
pub fn in_flight(&mut self) -> usize { |
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.
Why is this needed?
Motivation
We want the syncer to download blocks in chain order, as documented.
We want to make sure that the syncer correctly drops blocks that are a long way ahead of the state tip.
This is a follow-up test for PR #3167 for ticket #1389.
Solution
ChainSync
bug fixes:HashSet
orderindexmap
(multiple Zebra dependencies already useindexmap
)Extra Tests:
ChainSync
tests forobtain_tips
,extend_tips
, and wrong block hashesobtain_tips
andextend_tips
ChainSync
tests for duplicateFindBlocks
response hashesMake some futures
std::marker::Send
orstd::marker::Sync
, so they can be spawned:RetryLimit::Future
isstd::marker::Sync
ChainSync::sync
futurestd::marker::Send
by spawning tips futuresImprove test harnesses:
MockService
failure messagesMockService
APIMockChainTip
tozebra-chain
MockChainTipSender
type aliasMockChainTip
inChainSync
and its downloaderReview
I'm not sure who is around to review this PR, maybe @upbqdn?
Reviewer Checklist