Merged
Conversation
This file contains hidden or 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.
This PR addresses multiple issues in the hdiff code:
hasStateUsingStateDiff()that's called indb.HasState()was returning true for any slot that fell on the hdiff tree levels. This is wrong because those states might not actually be saved. This PR fixes that by actually looking in the db to check.saveStateByDiff()indb.SaveState()to actually save the states in the hdiff tree. this was missed previously. the reason for the if guards.stateDiffCache != nilover this call is that when syncing from genesis, the call to initialize state diff comes after the call ofSaveState()to save the genesis state. which would cause a panic here. with this guard, that save goes to the legacystateBucket. but the state will later get saved in the hdiff tree wheninitializeStateDiff()is called.getStateUsingStateDiff()whencomputeLevel(slot)returns -1.initializeStateDiff()higher when doing checkpoint sync. specifically moves it before the call toSaveState(). otherwise there is a bug: state diff tries to save that state in the tree because it has offset 0 from the genesis call, then it would error out because the checkpoint slot doesn't have the necessary parents in the tree. (the offset isn't updated yet). this move makes it so the offset is updated before saving the state. theSaveState()call is also skipped after initializing state diff, because it's redundant.NOTE: maybe if this pattern is good, we want to do the same in genesis.go to avoid writing to the legacyThis is done in Hdiff fixes 2 #16534stateBucketentirely.