-
Notifications
You must be signed in to change notification settings - Fork 310
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
Readme file for the world state package #436
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1 +1,31 @@ | ||||||
# World State | ||||||
|
||||||
## Overview | ||||||
|
||||||
The primary functions of the world state package are to maintain the collection of Merkle Trees comprising the global state of the system and to offer an interface with which the trees can be queried. | ||||||
|
||||||
The following components enable the package to perform it's role. | ||||||
|
||||||
### The Merkle Tree DB, a collection of Merkle Trees of varying types. | ||||||
|
||||||
- Append only 'Standard' merkle trees. New values are inserted into the next available leaf index. Values are never updated. | ||||||
- Indexed trees are also append only from an external perspective but prior values can be updated internally. The reason for this is that the Indexed Tree leaves not only store the value but the index of the next highest leaf. New insertions can require prior leaves to be updated. | ||||||
- Sparse trees that can be updated at any index. The 'size' of the tree is defined by the number of non-empty leaves, not by the highest populated leaf index as is the case with a Standard Tree. | ||||||
|
||||||
All Merkle Trees have commit/rollback semantics. Modifications to the trees are cached until 'committed'. The modifications can be discarded by calling 'rollback' which will return the tree to the last committed state. | ||||||
|
||||||
### The Synchroniser | ||||||
|
||||||
The synchroniser's role is to periodically poll for new block information and reconcile that information with the current state of the Merkle Trees. | ||||||
|
||||||
Onc a new block is received, the synchroniser checks the uncommitted root values of all of the trees against the roots published as part of the block. If they are all equal, the tree state is committed. If they are not equal, the tree states are rolled back to the last committed state before the published data is inserted and committed. | ||||||
|
||||||
### The Merkle Tree Interface | ||||||
|
||||||
The interface to the Merkle Tree DB offers a unified asynchronous API to the set of trees available. Reads from the Merkle Trees need to be marked as to whether they should include uncommitted state. For this reason, the MerkleTreeOperationsFacade exist to abstract this details away from the end consumer. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
# Building/Testing | ||||||
|
||||||
Building the package is as simple as calling `yarn build` from the package root. | ||||||
|
||||||
Running `yarn test` will execute the packages unit tests. |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.