-
Notifications
You must be signed in to change notification settings - Fork 75
[FIX] blacklist for longer in case of header validation failure #840
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
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.
One doubt only. Apart from that code LGTM
handleRewind( | ||
header, | ||
peerToBlackList, | ||
syncConfig.fastSyncBlockValidationN, |
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.
I am not sure if we shouldn't rewind more blocks in case of critical failure. Some times ago I stuck in the wrong fork and only the increasing number of blocks helped me. WDYT?
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.
to be honest all those number were derived from old geth pr which also proided some security analysis so i am not eager the change those just before release, also until we will have proper branch resolving during fast sync all we do here i a little hacky either way. So i would leave it as it is.
What does it mean that 2 are on wrong fork "for us"? Which criteria tells that it's wrong? Is it a hard fork we don't want to follow? Or rather if we do we get validation error because of the implementation differences? |
Is it a hard fork we don't want to follow. i.e take Thanos, hard fork, it changes how proof of work validation work and we do not want to follow nodes which do not activated it. |
@@ -431,14 +431,20 @@ class FastSync( | |||
// we blacklist peer just in case we got malicious peer which would send us bad blocks, forcing us to rollback | |||
// to genesis | |||
log.warning("Parent chain weight not found for block {}, not processing rest of headers", header.idTag) | |||
handleRewind(header, peer, syncConfig.fastSyncBlockValidationN) | |||
handleRewind(header, peer, syncConfig.fastSyncBlockValidationN, syncConfig.blacklistDuration) | |||
case HeadersProcessingFinished => | |||
processSyncing() | |||
case ImportedPivotBlock => | |||
updatePivotBlock(ImportedLastBlock) | |||
case ValidationFailed(header, peerToBlackList) => | |||
log.warning(s"validation fo header ${header.idTag} failed") |
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.
log.warning(s"validation fo header ${header.idTag} failed") | |
log.warning(s"validation of header ${header.idTag} failed") |
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 reasonable. I don't fully understand what the default case is, the "missing parent weight".
46694ea
to
e9006ef
Compare
this can happen when lets say there is minor fork in the chain. Let say we are on block In this case we also rewind blockchain a little bit, and hope fork will be resolved the next time we will get to this place. |
Description
Increases duration for critical offences in fast sync.
Imagine scenario with 3 remote peers - two of them are on wrong fork for us, and only one of them is on correct for, and those two on wrong fork are slightly beter than this on good fork.
Such scenario is possible:
2.we sync up with the second peer on wrong fork, ultimately blacklisting him due to validation error. We rollback N blocks and start from behind
By increasing blacklist time for validation errors we make sure we will have time to try other peers.
btw. I did not introduce it to regular sync as it not easy to grab header validation error there and i would like to avoid big code changes before release