-
Notifications
You must be signed in to change notification settings - Fork 75
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
[ETCM-247] Fix Fetcher updates #760
[ETCM-247] Fix Fetcher updates #760
Conversation
eb62350
to
525365d
Compare
- Fetcher will update last block and know top(only if is needed) if a mined or checkpointed block was imported - Fetcher will update know top if detect a block header with better top
525365d
to
5fda427
Compare
|
||
"given a previously mined blockchain" in customTestCaseResourceM(FakePeer.start2FakePeersRes()) { | ||
case (peer1, peer2) => | ||
val blockHeadersPerRequest = 200 |
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.
Should we use here peer2.syncConfig.blockHeadersPerRequest
?
//keep fetcher state updated in case new checkpoint block or mined block was imported | ||
case LastBlockChanged(blockNr) => { | ||
log.debug(s"New last block $blockNr imported from the inside") | ||
val newState = state.withLastBlock(blockNr).withPossibleNewTopAt(blockNr) |
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.
Last block seems to also involve the last headers fetched, what if we are already in progress of fetching blocks from the network with block number higher than the one imported (as it's likely the case for checkpoint blocks)? Doesn't this break the consistency of the fetcher?
Maybe the new last block should be blockNr.max(state.lastBlock)
or sth like that
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.
good catch
@@ -232,6 +255,9 @@ class BlockImporter( | |||
case ChainReorganised(oldBranch, newBranch, totalDifficulties) => | |||
updateTxPool(newBranch, oldBranch) | |||
broadcastBlocks(newBranch, totalDifficulties) | |||
if (informFetcherOnLastBlockChanged) { |
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.
Minor - after changes introduced in ETCM-175 (on develop already), it should be enough to call fetcher from RegularSync
actor after receiving update about imported block.
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.
LGTM!
.\\ //.
. \ \ / /.
.\ ,\ /` /,.-
-. \ /'/ / .
` - `-' \ -
'. /.\`
- .-
:`//.'
.`.'
.' BP
Description
According to https://jira.iohk.io/browse/ETCM-247, the desyncronization between importer and fetcher could cause several issues.
The goal of this PR is to provide an easy fix in order to keep fetcher state updated in case a node is only importing throw new mined blocks, or new checkpoint blocks.
Also, notice that previous to this PR, if a node(node2) wants to sync with other(node1), requires that its peer(node 1) is continuously generating blocks, if is not the case is going to catch up with only the first
n
number of blocks (according toblock-headers-per-request
). By subscribing to new block headers, now fetcher can update its vision about know top and react to this.^ issue: Block downloading doesn't start without any new block received from the network
Proposed Solution
Testing
TODO
Add tests for fetcher once ETCM-211 got merged (use code: ETCM-248)