Skip to content
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

relax the restriction of delete latest version #483

Closed
wants to merge 1 commit into from

Conversation

yihuang
Copy link
Collaborator

@yihuang yihuang commented Mar 11, 2022

Closes: #482

This is required for the rollback command to work in cosmos-sdk (cosmos/cosmos-sdk#11333 (comment)).
I'm not sure if there are other consequences of this, but my local test with rollback command seems fine using this change.

nodedb.go Outdated Show resolved Hide resolved
if !tree.VersionExists(version) {
return errors.Wrap(ErrVersionDoesNotExist, "")
}
if err := tree.ndb.DeleteVersion(version, true); err != nil {
if err := tree.ndb.DeleteVersion(version, false); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this works? You have to move every node in the merkle tree for the historical state at the prior height, to being in the live state section of node db

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, only did basic unit test in cosmos-sdk side here:cosmos/cosmos-sdk#11361, I need more understanding on internals of iavl I think.
Do you think there is an efficient way to achieve this rollback feature?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need to patch iavl at all, there's LoadVersionForOverwriting which is perfect for rollback state.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also check if it will be pruned correctly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yihuang yihuang closed this Mar 14, 2022
@yihuang yihuang deleted the delete-latest-version branch March 14, 2022 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support deletion of latest saved version
3 participants