-
Notifications
You must be signed in to change notification settings - Fork 637
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(sync): avoid unnecessary block hash fetching during block sync #3241
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3241 +/- ##
=======================================
Coverage 87.76% 87.76%
=======================================
Files 216 216
Lines 44711 44711
=======================================
Hits 39242 39242
Misses 5469 5469 Continue to review full report at Codecov.
|
3a9f6a6
to
d7f61e6
Compare
d7f61e6
to
cfacc1a
Compare
break; | ||
} | ||
let block_exists = chain.block_exists(block_hash).unwrap_or(false); | ||
if block_exists { |
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 only if it exists, but not if it's an orphan?
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.
added a comment
…3241) Currently on every iteration of block sync we would recompute the hashes of blocks that we need to sync, which is extremely slow when the amount of blocks that we need to sync is large. This PR fixes it by caching the hashes and only update it when we are close to syncing all the blocks in the cache. Test plan ----------- * `test_block_sync` * Run nightly tests * Test it on testnet.
…3241) Currently on every iteration of block sync we would recompute the hashes of blocks that we need to sync, which is extremely slow when the amount of blocks that we need to sync is large. This PR fixes it by caching the hashes and only update it when we are close to syncing all the blocks in the cache. Test plan ----------- * `test_block_sync` * Run nightly tests * Test it on testnet.
#3241 introduced an issue during block sync: it maintains `last_block_header` as the block header with largest height in the cache and has this logic that checks whether it is sufficiently close to header head and if it is, then the cache is ignored. However, the issue is that the sync loop runs every 10ms and therefore, it is almost always the case that this condition is triggered and the cache is effectively ignored. This PR fixes it by removing the condition. Test plan --------- Sync a node to testnet with this change and observe major improvements in syncing speed.
Currently on every iteration of block sync we would recompute the hashes of blocks that we need to sync, which is extremely slow when the amount of blocks that we need to sync is large. This PR fixes it by caching the hashes and only update it when we are close to syncing all the blocks in the cache.
Test plan
test_block_sync