From 1344ff137dc7df3869972b24b36f91746386e38d Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 6 Feb 2023 23:09:21 -0500 Subject: [PATCH] fix: exclude mem store from commit info (#14931) --- CHANGELOG.md | 1 + store/rootmulti/store.go | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e17c954e11c..5202f8bb998 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -265,6 +265,7 @@ extension interfaces. `module.Manager.Modules` is now of type `map[string]interf ### Bug Fixes +* (store) [#14931](https://github.com/cosmos/cosmos-sdk/pull/14931) Exclude in-memory KVStores, i.e. `StoreTypeMemory`, from CommitInfo commitments. * (types/coin) [#14715](https://github.com/cosmos/cosmos-sdk/pull/14715) `sdk.Coins.Add` now returns an empty set of coins `sdk.Coins{}` if both coins set are empty. * This is a behavior change, as previously `sdk.Coins.Add` would return `nil` in this case. * (types/coin) [#14739](https://github.com/cosmos/cosmos-sdk/pull/14739) Deprecate the method `Coin.IsEqual` in favour of `Coin.Equal`. The difference between the two methods is that the first one results in a panic when denoms are not equal. This panic lead to unexpected behaviour diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index a1ee5619b6c..45fbb4b25d1 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -1071,11 +1071,14 @@ func GetLatestVersion(db dbm.DB) int64 { func commitStores(version int64, storeMap map[types.StoreKey]types.CommitKVStore, removalMap map[types.StoreKey]bool) *types.CommitInfo { storeInfos := make([]types.StoreInfo, 0, len(storeMap)) storeKeys := keysFromStoreKeyMap(storeMap) + for _, key := range storeKeys { store := storeMap[key] last := store.LastCommitID() - // If a commit event execution is interrupted, a new iavl store's version will be larger than the rootmulti's metadata, when the block is replayed, we should avoid committing that iavl store again. + // If a commit event execution is interrupted, a new iavl store's version + // will be larger than the RMS's metadata, when the block is replayed, we + // should avoid committing that iavl store again. var commitID types.CommitID if last.Version >= version { last.Version = version @@ -1083,7 +1086,9 @@ func commitStores(version int64, storeMap map[types.StoreKey]types.CommitKVStore } else { commitID = store.Commit() } - if store.GetStoreType() == types.StoreTypeTransient { + + storeType := store.GetStoreType() + if storeType == types.StoreTypeTransient || storeType == types.StoreTypeMemory { continue }