-
Notifications
You must be signed in to change notification settings - Fork 75
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
ETCM-732: Handle missing state node in regular sync after fast sync is done #961
Conversation
blockImporter ! BlockFetcher.PickedBlocks(NonEmptyList.fromListUnsafe(List(invalidBlock))) | ||
|
||
eventually { | ||
Thread.sleep(1000) |
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 the Thread.sleep
if you are using eventually
?
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 saw the Thread.sleep
in some of the existing tests, so I reused it here. I will try to remove them and define a custom akka Patience
for the eventually
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 have tried to use eventually
without any Thread.sleep
s and defining implicit/explicit Patience
but for some reason it does not re-run the test if it fails. This is probably the reason that Thread.sleep
s are introduced.
a8dd010
to
47b5836
Compare
@@ -150,7 +152,7 @@ class BlockImporterItSpec | |||
blockImporter ! BlockFetcher.PickedBlocks(NonEmptyList.fromListUnsafe(newBranch)) | |||
|
|||
//because the blocks are not valid, we shouldn't reorganise, but at least stay with a current chain, and the best block of the current chain is oldBlock4 | |||
eventually { blockchain.getBestBlock().get shouldEqual oldBlock4 } | |||
eventually {Thread.sleep(1000); blockchain.getBestBlock().get shouldEqual oldBlock4 } |
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.
wouldn't it be cleaner to adjust the implicit def patienceConfig: PatienceConfig = defaultPatienceConfig
?
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.
@dzajkowski I have tried both mixing our LongPatience
trait into the test, and defining patience config directly before the eventually
block. From the debug, I see that the my values are used, but for some reason method is not re-run.
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.
interesting, let me give it a look
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.
eventually
does not mix well with AsyncFlatSpecLike
. either a Future
and AsyncFlatSpecLike
or AnyFlatSpecLike
with eventually
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.
@dzajkowski Done.
case MPTError(reason) if reason.isInstanceOf[MissingNodeException] => | ||
BlockImportFailedDueToMissingNode(reason.asInstanceOf[MissingNodeException]) | ||
case err => BlockImportFailed(s"Error while trying to reorganise chain: $err") | ||
}, |
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.
this could also be written as:
{
case MPTError(reason: MissingNodeException) => BlockImportFailedDueToMissingNode(reason)
case err => BlockImportFailed(s"Error while trying to reorganise chain: $err")
},
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.
Done.
2db9ba8
to
7f30074
Compare
7f30074
to
98b2915
Compare
Description
Instead of handling failures of a
Task
,BlockImporter
now handles appropriate error that indicates that block could not be imported due to a missing state node.Proposed Solution
Since the error is now wrapped into instance of an
Either
, using pattern matching we can act on a newly introduced error typeBlockImportFailedDueToMissingNode
Testing
Issue cannot be reproduced on every run of fast sync. Once it is reproduced, observe that missing state node error is logged (during regular sync) and that
BlockFetcher
will try to fetch missing state node, after which regular sync continues as usual without any errors.