Support BFT mining coordinator being temporarily stopped while syncing #7657
+47
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR description
When a new BFT node starts syncing against an existing chain, its BFT block timer tries to propose blocks even though it does not have the current state of the chain. This can result in exceptions such as:
BFT nodes should not try to propose blocks until they are in sync with the rest of the chain. This PR makes the following changes:
BftProcessor
so that the existingstop()
call isn't necessarily terminal. Today it only appears to be used on shutdown. This PR makes it possible tostop()
aBftProcessor
in such a way that it can be restarted again without the node restartingBftMiningCoordinator
to restart theBftProcessor
when it the coordinator is restartedThe result is that a node can begin doing BFT work (e.g. in the case where it is a single node with nobody to sync with, or where it is a validator for a brand new chain), but then stop its BFT work if it determines that it has a sync peer and starts downloading from it. Once syncing has completed the BFT work can then resume, this time with up-to-date state for the chain.