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

db synchronization #19

Open
dabasov opened this issue Apr 11, 2020 · 0 comments
Open

db synchronization #19

dabasov opened this issue Apr 11, 2020 · 0 comments

Comments

@dabasov
Copy link
Collaborator

dabasov commented Apr 11, 2020

When starting node we must synchronize our local DB and download new blocks.
Further algorithm will describe this process in details:

  1. We discover current blockchain height

  2. We optionally discover top blockchain height from the network (via hello message)

  3. We send
    BlockHeadersRequest {
    low: m
    high: m + d
    }
    Receive
    BlockHeadersResponse{
    headers []*BlockHeader
    }

    We can receive chunk less than m +d height, it's normal. The only requirement here that we must receive correct subchain without block absence, orphans will be filtered.
    If chunk is incorrect, we add ban score and retry request (next)

  • We can receive chunk without head on height m, it is normal, since previous responser could not have this exact fork. In this case we start requesting block headers of potential fork sequentially, until we find parent in current blockchain or hit depthLimit.
  • If we received correct chunk and we are able to add it to existing chain and new chain is correct, we start to download block bodies in parallel.
  • It is possible not to receive arbitrary block. In this case we simply drop chunk till this height and request blocks on next height again (go to start)
  • When we receive all blocks, request next blocks.
    For each request we have peer group (f + 1), we send query to first one and expect to receive correct request in time. If we can't, we go to next peer in group. If we asked every peer, we report error.
@dabasov dabasov closed this as completed May 1, 2020
@dabasov dabasov reopened this May 1, 2020
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

No branches or pull requests

1 participant