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

Sliding blocks window #24

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

samay-kothari
Copy link
Contributor

@samay-kothari samay-kothari commented Jul 12, 2022

Adding the sliding window functionality where the syncManager maintains a moving window that contains all the headers that have been validated and are ready for block download.
We slide forward on the window and requests for the blocks to be downloaded.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 2659025298

  • 98 of 190 (51.58%) changed or added relevant lines in 5 files are covered.
  • 6 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.009%) to 54.711%

Changes Missing Coverage Covered Lines Changed/Added Lines %
blockchain/blockindex.go 37 39 94.87%
blockchain/chain.go 12 19 63.16%
blockchain/accept.go 37 49 75.51%
blockchain/process.go 12 27 44.44%
blockchain/chainquery.go 0 56 0.0%
Files with Coverage Reduction New Missed Lines %
mempool/mempool.go 1 63.87%
peer/peer.go 1 75.37%
database/ffldb/blockio.go 4 93.68%
Totals Coverage Status
Change from base Build 2573815340: 0.009%
Covered Lines: 26827
Relevant Lines: 49034

💛 - Coveralls

samay-kothari and others added 15 commits August 23, 2022 13:20
go.yml: Fix github workflow and linting errors
ProcessBlockHeader allows for seprately validation and accepting block headers which is needed for header-first block downloads
Exporting chain setup will allow it to be used in other packages, to be used while testing
These tests would be useful for testing valdiation process of block headers introduced by ProcessBlockHeader
Making the required changes in the processBlock and maybeAcceptBlock function, such that they work with the headervalidation process and accept already validated headers.
When the block data is being validated for an already validated header, then we modify the behavioural flag, so that we don't repeat the header validation steps again
HaveBlockWithData is a modification of HaveBlock function, but here we return true only if we have block data also present along with the block node.
Adding the functionality that the headers would be validated as soon as they are recieved from the peer
… and processHeaderBlocks

Adding the tests that would check if a block with validated header give the expected reponse when block data is added to that node.
best header tracks the highest work block node in the index that is not known to be invalid. This is specifically useful when we don't have the block data. However, since block nodes are only added to the index for block headers that pass all sanity and positional checks, which include checking proof of work, it does represent the tip of the header chain with the highest known work that has a reasonably high chance of becoming the best chain tip and is useful for things such as reporting progress and discovering the most suitable blocks to download.
NodeHeightByHash function returns the height of the block with the given hash in the main chain. It does not check of the node is on the main chain, so returns heigh of the node which is created by header validation.
PutNextNeededBlocks populates the provided slice with hashes for the next blocks after the current best chain tip that are needed to make progress towards the current best known header skipping any blocks that already have their data available.
BestHeader returns the header with the most cumulative work that is NOT known to be invalid.
implementing maybeUpdateNextNeededBlocks function that populates the sliding window with next blocks whose headers are validated using the PutNextNeededBlocks function.
fetchNextBlocks function creates and sends a request to the provided peer for next blocks to be downloaded based on the current headers.
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

Successfully merging this pull request may close these issues.

3 participants