Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for block events to backfill in core.App.Start #318

Merged
merged 1 commit into from Jul 29, 2019

Conversation

@albrow
Copy link
Member

albrow commented Jul 29, 2019

In v1.0.6-beta we waited for for block events to backfill before doing anything else in core.App.Start. That feature was accidentally lost when some of my recent PRs changed the way our asynchronous code works. This PR makes our initialization process closer to how it was in v1.0.6-beta, so we wait for backfilling to finish before doing some steps in core.App.Start.

In this PR, the order of initialization is:

  1. Start the snapshot expiration watcher.
  2. Start the order watcher.
  3. Start the ETH balance watcher.
  4. Backfill block events (this blocks).
  5. Start the block watcher.
  6. Start the p2p node.

The main difference is that we won't send orders to/receive orders from any peers until after backfilling has been completed. This is important because if we are behind on blocks we would have a different picture of which orders are valid/invalid compared to our peers.

@fabioberger this PR will still result in the RPC server starting before backfilling is finished. This is due to the fact that it is started asynchronously outside of core.App.Start. I think this is okay, but it does mean you will potentially receive a lot of order events over a short period of time while backfilling is happening. Compared to v1.0.6-beta, it also comes with the advantage of being able to send RPC requests right away. If we include the last known block number in #201 or implement #202, then it would be possible to monitor the progress of backfilling via the JSON-RPC endpoints. What do you think?

@albrow albrow requested a review from fabioberger Jul 29, 2019
@albrow albrow force-pushed the fix/wait-for-block-event-backfill branch from dada27a to 9baefd1 Jul 29, 2019
Copy link
Contributor

fabioberger left a comment

I like this approach a lot. I will add the latest block number to the mesh_stats method call along with a IsSyncing flag since it might not be obvious which block number is considered latest by the Mesh node. Together with this addition, starting the RPC before the node is fully synced will work well.

@albrow albrow merged commit 6e2a937 into development Jul 29, 2019
1 check passed
1 check passed
ci/circleci: build Your tests passed on CircleCI!
Details
@albrow albrow deleted the fix/wait-for-block-event-backfill branch Jul 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.