-
Notifications
You must be signed in to change notification settings - Fork 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
Create New Beacon State Data Structure #4602
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
Codecov Report
@@ Coverage Diff @@
## master #4602 +/- ##
=======================================
Coverage 22.69% 22.69%
=======================================
Files 54 54
Lines 4257 4257
=======================================
Hits 966 966
Misses 3150 3150
Partials 141 141 |
rauljordan
commented
Jan 21, 2020
rauljordan
commented
Jan 21, 2020
prestonvanloon
requested changes
Jan 21, 2020
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.
Awesome patch!
Two concerns:
- Please confirm that you are using safe copy for byte slices in getters.
- Please complete godoc comments.
prestonvanloon
previously approved these changes
Jan 21, 2020
terencechain
previously approved these changes
Jan 21, 2020
0xKiwi
reviewed
Jan 21, 2020
rauljordan
dismissed stale reviews from terencechain and prestonvanloon
via
January 21, 2020 22:32
354ed4e
0xKiwi
approved these changes
Jan 21, 2020
16 tasks
cryptomental
pushed a commit
to cryptomental/prysm
that referenced
this pull request
Feb 24, 2020
* begin state service * begin on the state trie idea * created beacon state structure * add in the full clone getter * return by value instead * add all setters * new state setters are being completed * arrays roots exposed * close to finishing all these headerssss * functionality complete * added in proto benchmark test * test for compatibility * add test for compat * comments fixed * add clone * add clone * remove underlying copies * make it immutable * integrate it into chainservice * revert * wrap up comments for package * address all comments and godocs * address all comments * clone the pending attestation properly * properly clone remaining items * tests pass fixed bug * prevent nil pointer exceptions * fixed up some bugs in the clone comparisons Co-authored-by: Nishant Das <[email protected]> Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
cryptomental
pushed a commit
to cryptomental/prysm
that referenced
this pull request
Feb 28, 2020
* begin state service * begin on the state trie idea * created beacon state structure * add in the full clone getter * return by value instead * add all setters * new state setters are being completed * arrays roots exposed * close to finishing all these headerssss * functionality complete * added in proto benchmark test * test for compatibility * add test for compat * comments fixed * add clone * add clone * remove underlying copies * make it immutable * integrate it into chainservice * revert * wrap up comments for package * address all comments and godocs * address all comments * clone the pending attestation properly * properly clone remaining items * tests pass fixed bug * prevent nil pointer exceptions * fixed up some bugs in the clone comparisons Co-authored-by: Nishant Das <[email protected]> Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Priority: Critical
Highest, immediate priority item
Ready For Review
A pull request ready for code review
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 resolves #2011
Description
Write why you are making the changes in this pull request
We need a way to avoid cloning the beacon state 56 times per slot as we get closer to a mainnet release. This PR adds a new beacon state data structure that recomputes its hashtreeroot on writes to fields and provides getters which copy fields on reads to maintain immutability. This PR will be backwards compatible with our current beacon state, and will help runtime a lot.
Write a summary of the changes you are making
Adds a new beacon state struct which looks like this:
Link anything that would be helpful or relevant to the reviewers
We should expect resource consumption and bottlenecks to reduce significantly. This PR only implements the new data structure with tests but does not yet integrate it into our runtime.
Next Steps
Next, we need to begin integrating this new type throughout the repo. We would first need to amend the db.SaveState and db.HeadState functions to take in and return this type. Then, we would to modify the head fetcher (from the chain service) to use this type instead. Afterwards, we can just go package by package, checking for any instances of
.HeadState()
and replacing with appropriate getters instead. TheHeadState()
function should no longer clone, but instead just return the new beacon state type because all its fields are protected behind getters that copy.