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

fix: pass initial version at immutable tree creation #880

Merged
merged 3 commits into from
Feb 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mutable_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func NewMutableTree(db dbm.DB, cacheSize int, skipFastStorageUpgrade bool, lg lo
}

ndb := newNodeDB(db, cacheSize, opts, lg)
head := &ImmutableTree{ndb: ndb, skipFastStorageUpgrade: skipFastStorageUpgrade}
head := &ImmutableTree{ndb: ndb, skipFastStorageUpgrade: skipFastStorageUpgrade, version: int64(opts.InitialVersion)}
Copy link
Collaborator

@cool-develope cool-develope Feb 8, 2024

Choose a reason for hiding this comment

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

I know the result is same.
The happy case is to load the current version while constructing the tree in LoadVersion, so we don't need to set the InitialVersion option. The InitialVersion is just optional considering the above case like new module.
But if we force set the version here, it can be misleading the meaning of InitialVersion.

Copy link
Contributor Author

@beer-1 beer-1 Feb 8, 2024

Choose a reason for hiding this comment

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

I don't have strong opinion on this, so happy to follow your way.

Is the above solution (in comment) is good? or should we make other changes on LoadVersion function?
I have tested, and the above solution is also working.

Copy link
Collaborator

Choose a reason for hiding this comment

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

no, we should move this part to the LoadVersion, your commit will be not working when set the initial version by SetInitialVersion without opts.

Copy link
Contributor Author

@beer-1 beer-1 Feb 8, 2024

Choose a reason for hiding this comment

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

okay, I moved the fix to LoadVersion and tested it. It's also working well :)
@cool-develope


return &MutableTree{
logger: lg,
Expand Down
Loading