-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
state sync: reverse sync implementation #6463
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmwaters
requested review from
alexanderbez,
ebuchman,
tessr and
tychoish
as code owners
May 12, 2021 21:39
Codecov Report
@@ Coverage Diff @@
## master #6463 +/- ##
==========================================
+ Coverage 60.96% 61.10% +0.13%
==========================================
Files 293 295 +2
Lines 27435 27870 +435
==========================================
+ Hits 16727 17029 +302
- Misses 9011 9124 +113
- Partials 1697 1717 +20
|
tac0turtle
reviewed
May 14, 2021
tac0turtle
reviewed
May 14, 2021
alexanderbez
changed the title
statesync: reversesync
state sync: reverse sync implementation
May 24, 2021
tychoish
suggested changes
May 24, 2021
alexanderbez
reviewed
Jun 1, 2021
Co-authored-by: Aleksandr Bezobchuk <[email protected]>
tychoish
approved these changes
Jun 3, 2021
tychoish
approved these changes
Jun 7, 2021
4 tasks
4 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 implements ADR-068 allowing state synced nodes to fetch prior light blocks which can be needed in verifying any future evidence that may arise.
How it works
Backfill
(the new method within the state sync reactor) runs directly after a node has verified and applied application state. I will provide a quick overview of how all the new pieces work so as to give you context before looking into the code. There are 2 new pieces:dispatcher
which is tied with the state sync reactor and allows for concurrent processes to request light blocks.blockQueue
which is initiated with a start height and an end height and allows for concurrent workers to use the dispatcher to get a light block and add it to the queue. The queue is then responsible for serializing the incoming blocks and giving them to another process to verify them.The backfill method is then simply:
header[height].Hash() == header[height + 1].LastBlockID.Hash
FIXME's
There are various incongruities that have arisen from these changes. The main one to consider is that prior we considered the
Base
andHeight
of the blockchain based from the first and lastBlockMeta
. Adding headers and commits to theBlockStore
means that theBase
might not be the height of the earliest block rather the height of the earliest light block. A client may run/status
to work out the earliest height and then call/block
at that height only to find that it's not there. I have left this behavior as is however we might want to explore other solutions.The other minor one is in the
BlockStore
. TheBlockStore
saves headers by savingBlockMeta
which includes the header as well as other information. This other information isBlockSize
andNumTxs
which from the light block we don't know hence I've filled them with-1
this is hacky and it means that the BlockMeta isn't really complete.