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

[WIP] Improved ExWire Block Sync #694

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

hayesgm
Copy link
Contributor

@hayesgm hayesgm commented Dec 3, 2018

Based on the lessons of Warp Sync, this patch (work in process) starts to improve standard block sync. We:

  1. Process blocks in a new GenServer. This means that block processing doesn't block us from responding to packets like ping that would otherwise cause peers to drop us.
  2. Move processing to its own module StandardProcessor. If we decide to implement fast sync (we probably shouldn't), then that could be FastProcessor. Note: standard and fast syncs work the same way, more or less, warp sync is completely different and thus has its own separate code.
  3. Clean up sync and try to keep it free of too much business logic.
  4. Implement Pv63 and be a good peer responding to packets. We opt not to request any fast-sync packets.

This is still plenty work in progress, but I wanted to open up a PR to show the progress. Certain aspects, like fast sync as an option, will probably go away.

When packets come in, sometimes they are incomplete. We previously handled packets that had a valid header but insufficient body size. This patch adds support for packets that don't even have complete headers. We queue the packet into queued data and wait for more data before processing.
This patch connects Warp Sync to the correct packets that come back from Parity when warp syncing. There were a few issues with the algorithm for determining packet ids. It appears that each capability has a size (to allow for protocol upgrades) and we skip that many before the next protocol. These aren't documented from come by Parity's source code. Additionally, it appears that once you negotiate a protocol, you still use the offests from Pv62 but from the higher negotiated ids. It's all a bit weird, but this seems to get everything working. Finally, we had an issue with default map getting called *a lot*, so we instead opt to hard-code the value and try to pass nil around instead of default map.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant