-
Notifications
You must be signed in to change notification settings - Fork 17
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
fix!: just in time updates would break references in same batch #329
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
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.
Issue being fixed or feature implemented
There was a very bad issue that would lead to state corruption. To understand the issue we first need a refresher on just in time updates. Just in time updates are updates that can modify a value being updated during batch execution. This is important for our fee system in drive. For example if you have a field "cat" that was 3 bytes and you added it in epoch 0, then modified it to cats in epoch 1. you would have added 3 bytes in epoch 0 and 1 byte in epoch 1.
Just in time updates does the merge automatically so the client library only needs to push "cats", then GroveDB sees that there is a value already present "cat" and asks the client library to merge the element flags (which in drive contain information about the byte storage).
References in a batch would not take into account this merge and would instead use the unmerged inserted value. This would lead to incorrect hashes being stored for references which would break the proof system.
We also found an issue with Merks being required too often which is fixed in this PR.
What was done?
When we insert an item or a sum item, we merge the element flags before assigning to the reference. This is not cached and there are improvements to be had on this system.
Merks are now properly cached and are not requeried as often.
There was some refactoring done and some renaming as well to make this fix easier to understand.
How Has This Been Tested?
Added many tests.
Breaking Changes
This is a breaking change.
Checklist:
For repository code-owners and collaborators only