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.
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(store): properly update store head #207
fix(store): properly update store head #207
Changes from 21 commits
9e25e4a
bad94ca
8b1bbc7
8f62e7d
4b13167
2dbec93
b4738e4
bc1a111
7fc0dfd
742a2ba
9cb41db
1a0ed39
1d53e1a
da710eb
cdb5de9
0c93588
7bb1d5c
61a6b31
a197550
09d798e
e552672
4572354
1cdbdb8
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Putting this only after flush means the
writeHead
is gonna be advanced only after only every 2048 headers(default), which means theHead
method is gonna lag for 2048 headers. The Head should reflect the actual height, otherwise the node is always gonna consider its Head as not "recent", which is a bug.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.
So here we've a conflict of interests:
.Head()
to return head really written to the disk (basically that's the reason of this PR).Time to flip a coin a guess.
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.
No need to flip a coin. Head doesnt have to be consistent with disk. We do not gain anything by doing so
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.
From my perspective, the reason for this PR is to fix the bug introduced after adjacency PRs, where head wasnt properly updated if non-adjacent headers are written. The Head wasnt atomic with the disk before that and thats expected behavior, because otherwise its a bug, as explained in OP
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.
CC: @renaynay
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.
One more thing we realized in sync. We must update head reference on disk in here. Otherwise the in-mem pointer will go out of sync with the one on disk
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.
Thanks for the clarification
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.
One more thing. We also don't update the heightSub reference after advancing here