Skip to content

Conversation

@milenkara
Copy link
Contributor

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 type BlockImportFailedDueToMissingNode

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.

blockImporter ! BlockFetcher.PickedBlocks(NonEmptyList.fromListUnsafe(List(invalidBlock)))

eventually {
Thread.sleep(1000)
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

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.sleeps 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.sleeps are introduced.

@milenkara milenkara force-pushed the bug/ETCM-732-MissingRootNode branch from a8dd010 to 47b5836 Compare April 12, 2021 14:30

//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 }
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor Author

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")
},
Copy link
Contributor

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")
          },

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@milenkara milenkara force-pushed the bug/ETCM-732-MissingRootNode branch 2 times, most recently from 2db9ba8 to 7f30074 Compare April 16, 2021 09:14
@milenkara milenkara force-pushed the bug/ETCM-732-MissingRootNode branch from 7f30074 to 98b2915 Compare April 16, 2021 12:59
@milenkara milenkara merged commit 00a4442 into develop Apr 16, 2021
@milenkara milenkara deleted the bug/ETCM-732-MissingRootNode branch April 16, 2021 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants