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

CacheMultiStoreWithVersion -> store.(*iavl.Store).GetImmutable(version) error: "version does not exist" #939

Open
quaisx opened this issue May 2, 2024 · 0 comments

Comments

@quaisx
Copy link

quaisx commented May 2, 2024

I am running into a situation when the call is placed into CacheMultiStoreWithVersion during gRPC call. When hitting this line:

func (rs *Store) CacheMultiStoreWithVersion(version int64) (types.CacheMultiStore, error) {
	...
			cacheStore, err = store.(*iavl.Store).GetImmutable(version)
			// if we got error from loading a module store
			// we fetch commit info of this version
			// we use commit info to check if the store existed at this version or not
			if err != nil {

the returned error is "version does not exist".

When debugging the calls to "commit":

func (tree *MutableTree) saveFastNodeAdditions(batchCommmit bool) error {
	keysToSort := make([]string, 0)
	tree.unsavedFastNodeAdditions.Range(func(k, v interface{}) bool {
		keysToSort = append(keysToSort, k.(string))
		return true
	})
	sort.Strings(keysToSort)

	for _, key := range keysToSort {
		val, _ := tree.unsavedFastNodeAdditions.Load(key)
		if err := tree.ndb.SaveFastNode(val.(*fastnode.Node)); err != nil {
			return err
		}
		if batchCommmit {
			if err := tree.ndb.resetBatch(); err != nil {
				return err
			}
		}
	}
	return nil
}

tree.root does not get populated for empty tree.unsavedFastNodeAdditions. As a result the code below goes into this condition:

func (tree *MutableTree) SaveVersion() ([]byte, int64, error) {
	...
	if tree.root == nil {
		if err := tree.ndb.SaveEmptyRoot(version); err != nil {
			return nil, 0, err
		}
	} else {

ane tree.root remains nil. Obviously, when later calling *store.(iavl.Store).GetImmutable(version) an error message in returned.
This behaviour manifests with some modules but not with others.
When I query the bank balance it fails "someapp q bank balances <alias|address>".

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

No branches or pull requests

1 participant