From 9143f9374c86101008c1c67968888098374bf2f7 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 6 Feb 2023 23:54:14 -0500 Subject: [PATCH] fix: exclude mem store from commit info (backport #14931) (#14934) Co-authored-by: Aleksandr Bezobchuk Co-authored-by: marbar3778 --- CHANGELOG.md | 2 +- store/rootmulti/store.go | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ac1aa3cada8..4781eea9620c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +* (store) [#14931](https://github.com/cosmos/cosmos-sdk/pull/14931) Exclude in-memory KVStores, i.e. `StoreTypeMemory`, from CommitInfo commitments. * (cli) [#14919](https://github.com/cosmos/cosmos-sdk/pull/14919) Fix never assigned error when write validators. * (x/group) [#14923](https://github.com/cosmos/cosmos-sdk/pull/14923) Fix error while using pagination in `x/group` from CLI @@ -297,7 +298,6 @@ extension interfaces. `module.Manager.Modules` is now of type `map[string]interf ### Bug Fixes -* (x/auth) [#13838](https://github.com/cosmos/cosmos-sdk/pull/13838) Fix calling `String()` and `MarshalYAML` panics when pubkey is set on a `BaseAccount`. * (rosetta) [#13583](https://github.com/cosmos/cosmos-sdk/pull/13583) Misc fixes for cosmos-rosetta. * (x/evidence) [#13740](https://github.com/cosmos/cosmos-sdk/pull/13740) Fix evidence query API to decode the hash properly. * (bank) [#13691](https://github.com/cosmos/cosmos-sdk/issues/13691) Fix unhandled error for vesting account transfers, when total vesting amount exceeds total balance. diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index 339da432b576..670272792bd1 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -1052,10 +1052,15 @@ 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)) - for key, store := range storeMap { + storeKeys := keysForStoreKeyMap(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 @@ -1063,7 +1068,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 }