WIP WIP WIP: Break our node logic into a three stages system #123
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.
This PR aims to build a three stage process to start and maintain a node. This will be helpful in projects like #64 and #115, and the general workflow is:
ChainSeletor
will find the best chain we know about. Currently, it will simply find the most work chain and follow that. But we can add the logic needed for Proof-of-Work fraud proof: Tracker issue #115 here. After this stage finishes, we are guaranteed to be in the most-work chain we've found among our peers (and after Proof-of-Work fraud proof: Tracker issue #115 is finished, we are almost certain that this chain is valid).BackfillNode
will download a range of blocks and verify them. This stage is used to backfill our chain and make sure that: i) this chain is valid ii) the state we started working is the right one.RunningNode
is the same we have now. It handles requests by users, new blocks and so on. AfterChainSelector
returns, we can start aRunningNode
and multipleSyncPeers
in parallel, so our user can start using their node as soon asChainSelector
returns (which should be fairly quick).RunningNode
should also download the BIP158 block filters, allowing users to find historical transactions before the backfill process finishes.