diff --git a/CHANGELOG.md b/CHANGELOG.md index f5773401ccc7..6a2e8f9177d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## Unreleased +### Improvements + +* [PR 565](https://github.com/provenance-io/cosmos-sdk/pull/565) Removes locks around state listening. There's no concurrency risk. + ### Bug Fixes * [PR 564](https://github.com/provenance-io/cosmos-sdk/pull/564) Fix protobufjs parse error by using object form vs. array for `additional_bindings` rpc tag. diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index 52f5c94d6915..aaed905767ac 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -61,8 +61,6 @@ type Store struct { interBlockCache types.MultiStorePersistentCache listeners map[types.StoreKey]*types.MemoryListener - - listenersMx sync.Mutex } var ( @@ -382,8 +380,6 @@ func (rs *Store) TracingEnabled() bool { // AddListeners adds a listener for the KVStore belonging to the provided StoreKey func (rs *Store) AddListeners(keys []types.StoreKey) { - rs.listenersMx.Lock() - defer rs.listenersMx.Unlock() for i := range keys { listener := rs.listeners[keys[i]] if listener == nil { @@ -405,8 +401,6 @@ func (rs *Store) ListeningEnabled(key types.StoreKey) bool { // not the state in the store itself. This is a mutating and destructive operation. // This method has been synchronized. func (rs *Store) PopStateCache() []*types.StoreKVPair { - rs.listenersMx.Lock() - defer rs.listenersMx.Unlock() var cache []*types.StoreKVPair for key := range rs.listeners { ls := rs.listeners[key] @@ -490,8 +484,6 @@ func (rs *Store) CacheWrapWithTrace(_ io.Writer, _ types.TraceContext) types.Cac // CacheMultiStore creates ephemeral branch of the multi-store and returns a CacheMultiStore. // It implements the MultiStore interface. func (rs *Store) CacheMultiStore() types.CacheMultiStore { - rs.listenersMx.Lock() - defer rs.listenersMx.Unlock() stores := make(map[types.StoreKey]types.CacheWrapper) for k, v := range rs.stores { store := types.KVStore(v) @@ -510,8 +502,6 @@ func (rs *Store) CacheMultiStore() types.CacheMultiStore { // any store cannot be loaded. This should only be used for querying and // iterating at past heights. func (rs *Store) CacheMultiStoreWithVersion(version int64) (types.CacheMultiStore, error) { - rs.listenersMx.Lock() - defer rs.listenersMx.Unlock() cachedStores := make(map[types.StoreKey]types.CacheWrapper) for key, store := range rs.stores { var cacheStore types.KVStore @@ -566,8 +556,6 @@ func (rs *Store) GetStore(key types.StoreKey) types.Store { // NOTE: The returned KVStore may be wrapped in an inter-block cache if it is // set on the root store. func (rs *Store) GetKVStore(key types.StoreKey) types.KVStore { - rs.listenersMx.Lock() - defer rs.listenersMx.Unlock() s := rs.stores[key] if s == nil { panic(fmt.Sprintf("store does not exist for key: %s", key.Name()))