From d5d0f6243422a3484eac5e59145d5e4b2e6e00d0 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) (cherry picked from commit 1344ff137dc7df3869972b24b36f91746386e38d) # Conflicts: # CHANGELOG.md # store/rootmulti/store.go --- CHANGELOG.md | 13 +++++++++++++ store/rootmulti/store.go | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ac1aa3cada8..570b84cd0d60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -297,7 +297,20 @@ extension interfaces. `module.Manager.Modules` is now of type `map[string]interf ### Bug Fixes +<<<<<<< HEAD * (x/auth) [#13838](https://github.com/cosmos/cosmos-sdk/pull/13838) Fix calling `String()` and `MarshalYAML` panics when pubkey is set on a `BaseAccount`. +======= +* (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 +* (x/bank) [#14538](https://github.com/cosmos/cosmos-sdk/pull/14538) Validate denom in bank balances GRPC queries. +* (baseapp) [#14505](https://github.com/cosmos/cosmos-sdk/pull/14505) PrepareProposal and ProcessProposal now use deliverState for the first block in order to access changes made in InitChain. +* (server) [#14441](https://github.com/cosmos/cosmos-sdk/pull/14441) Fix `--log_format` flag not working. +* (x/upgrade) [#13936](https://github.com/cosmos/cosmos-sdk/pull/13936) Make downgrade verification work again +* (x/group) [#13742](https://github.com/cosmos/cosmos-sdk/pull/13742) Fix `validate-genesis` when group policy accounts exist. +* (x/auth) [#13838](https://github.com/cosmos/cosmos-sdk/pull/13838) Fix calling `String()` when pubkey is set on a `BaseAccount`. +>>>>>>> 1344ff137 (fix: exclude mem store from commit info (#14931)) * (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..dc407edf6c5a 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -1051,11 +1051,20 @@ func GetLatestVersion(db dbm.DB) int64 { // Commits each store and returns a new commitInfo. func commitStores(version int64, storeMap map[types.StoreKey]types.CommitKVStore, removalMap map[types.StoreKey]bool) *types.CommitInfo { storeInfos := make([]types.StoreInfo, 0, len(storeMap)) +<<<<<<< HEAD for key, store := range storeMap { +======= + storeKeys := keysFromStoreKeyMap(storeMap) + + for _, key := range storeKeys { + store := storeMap[key] +>>>>>>> 1344ff137 (fix: exclude mem store from commit info (#14931)) 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 +1072,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 }