diff --git a/store/CHANGELOG.md b/store/CHANGELOG.md index cdd7bb1c59fa..95a55120ae45 100644 --- a/store/CHANGELOG.md +++ b/store/CHANGELOG.md @@ -23,6 +23,12 @@ Ref: https://keepachangelog.com/en/1.0.0/ # Changelog +## [Unreleased] + +### Improvements + +* [#207](https://github.com/crypto-org-chain/cosmos-sdk/pull/207) Remove api CacheWrapWithTrace. + ## v1.1.0 (March 20, 2024) ### Improvements diff --git a/store/cachekv/store.go b/store/cachekv/store.go index 08cfc2b325f6..9c062c8ce619 100644 --- a/store/cachekv/store.go +++ b/store/cachekv/store.go @@ -2,7 +2,6 @@ package cachekv import ( "bytes" - "io" "sort" "sync" @@ -12,7 +11,6 @@ import ( "cosmossdk.io/store/cachekv/internal" "cosmossdk.io/store/internal/conv" "cosmossdk.io/store/internal/kv" - "cosmossdk.io/store/tracekv" "cosmossdk.io/store/types" ) @@ -166,11 +164,6 @@ func (store *Store) CacheWrap() types.CacheWrap { return NewStore(store) } -// CacheWrapWithTrace implements the CacheWrapper interface. -func (store *Store) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.CacheWrap { - return NewStore(tracekv.NewStore(store, w, tc)) -} - //---------------------------------------- // Iteration diff --git a/store/cachemulti/store.go b/store/cachemulti/store.go index 696911370c5d..37fadb7790f2 100644 --- a/store/cachemulti/store.go +++ b/store/cachemulti/store.go @@ -132,11 +132,6 @@ func (cms Store) CacheWrap() types.CacheWrap { return cms.CacheMultiStore().(types.CacheWrap) } -// CacheWrapWithTrace implements the CacheWrapper interface. -func (cms Store) CacheWrapWithTrace(_ io.Writer, _ types.TraceContext) types.CacheWrap { - return cms.CacheWrap() -} - // Implements MultiStore. func (cms Store) CacheMultiStore() types.CacheMultiStore { return newCacheMultiStoreFromCMS(cms) diff --git a/store/dbadapter/store.go b/store/dbadapter/store.go index 013e26df2030..804ed4d38d8b 100644 --- a/store/dbadapter/store.go +++ b/store/dbadapter/store.go @@ -1,12 +1,9 @@ package dbadapter import ( - "io" - dbm "github.com/cosmos/cosmos-db" "cosmossdk.io/store/cachekv" - "cosmossdk.io/store/tracekv" "cosmossdk.io/store/types" ) @@ -81,10 +78,5 @@ func (dsa Store) CacheWrap() types.CacheWrap { return cachekv.NewStore(dsa) } -// CacheWrapWithTrace implements KVStore. -func (dsa Store) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.CacheWrap { - return cachekv.NewStore(tracekv.NewStore(dsa, w, tc)) -} - // dbm.DB implements KVStore so we can CacheKVStore it. var _ types.KVStore = Store{} diff --git a/store/dbadapter/store_test.go b/store/dbadapter/store_test.go index 9685887f9126..515fd38c2bab 100644 --- a/store/dbadapter/store_test.go +++ b/store/dbadapter/store_test.go @@ -80,7 +80,4 @@ func TestCacheWraps(t *testing.T) { cacheWrapper := store.CacheWrap() require.IsType(t, &cachekv.Store{}, cacheWrapper) - - cacheWrappedWithTrace := store.CacheWrapWithTrace(nil, nil) - require.IsType(t, &cachekv.Store{}, cacheWrappedWithTrace) } diff --git a/store/gaskv/store.go b/store/gaskv/store.go index e0f96af7151e..59247d80008a 100644 --- a/store/gaskv/store.go +++ b/store/gaskv/store.go @@ -1,8 +1,6 @@ package gaskv import ( - "io" - "cosmossdk.io/store/types" ) @@ -87,11 +85,6 @@ func (gs *Store) CacheWrap() types.CacheWrap { panic("cannot CacheWrap a GasKVStore") } -// CacheWrapWithTrace implements the KVStore interface. -func (gs *Store) CacheWrapWithTrace(_ io.Writer, _ types.TraceContext) types.CacheWrap { - panic("cannot CacheWrapWithTrace a GasKVStore") -} - func (gs *Store) iterator(start, end []byte, ascending bool) types.Iterator { var parent types.Iterator if ascending { diff --git a/store/gaskv/store_test.go b/store/gaskv/store_test.go index 354832d17c40..d4fd70778cd9 100644 --- a/store/gaskv/store_test.go +++ b/store/gaskv/store_test.go @@ -24,7 +24,6 @@ func TestGasKVStoreBasic(t *testing.T) { require.Equal(t, types.StoreTypeDB, st.GetStoreType()) require.Panics(t, func() { st.CacheWrap() }) - require.Panics(t, func() { st.CacheWrapWithTrace(nil, nil) }) require.Panics(t, func() { st.Set(nil, []byte("value")) }, "setting a nil key should panic") require.Panics(t, func() { st.Set([]byte(""), []byte("value")) }, "setting an empty key should panic") diff --git a/store/iavl/store.go b/store/iavl/store.go index 7bdcb1df9177..e73dcd6c1fdd 100644 --- a/store/iavl/store.go +++ b/store/iavl/store.go @@ -3,7 +3,6 @@ package iavl import ( "errors" "fmt" - "io" cmtprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" dbm "github.com/cosmos/cosmos-db" @@ -16,7 +15,6 @@ import ( "cosmossdk.io/store/internal/kv" "cosmossdk.io/store/metrics" pruningtypes "cosmossdk.io/store/pruning/types" - "cosmossdk.io/store/tracekv" "cosmossdk.io/store/types" "cosmossdk.io/store/wrapper" ) @@ -179,11 +177,6 @@ func (st *Store) CacheWrap() types.CacheWrap { return cachekv.NewStore(st) } -// CacheWrapWithTrace implements the Store interface. -func (st *Store) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.CacheWrap { - return cachekv.NewStore(tracekv.NewStore(st, w, tc)) -} - // Implements types.KVStore. func (st *Store) Set(key, value []byte) { types.AssertValidKey(key) diff --git a/store/iavl/store_test.go b/store/iavl/store_test.go index 7ad24d7fe33d..46d9fa62371c 100644 --- a/store/iavl/store_test.go +++ b/store/iavl/store_test.go @@ -663,9 +663,6 @@ func TestCacheWraps(t *testing.T) { cacheWrapper := store.CacheWrap() require.IsType(t, &cachekv.Store{}, cacheWrapper) - - cacheWrappedWithTrace := store.CacheWrapWithTrace(nil, nil) - require.IsType(t, &cachekv.Store{}, cacheWrappedWithTrace) } func TestChangeSets(t *testing.T) { diff --git a/store/listenkv/store.go b/store/listenkv/store.go index b08a6e395071..343be611b9f0 100644 --- a/store/listenkv/store.go +++ b/store/listenkv/store.go @@ -1,8 +1,6 @@ package listenkv import ( - "io" - "cosmossdk.io/store/types" ) @@ -134,9 +132,3 @@ func (s *Store) GetStoreType() types.StoreType { func (s *Store) CacheWrap() types.CacheWrap { panic("cannot CacheWrap a ListenKVStore") } - -// CacheWrapWithTrace implements the KVStore interface. It panics as a -// Store cannot be cache wrapped. -func (s *Store) CacheWrapWithTrace(_ io.Writer, _ types.TraceContext) types.CacheWrap { - panic("cannot CacheWrapWithTrace a ListenKVStore") -} diff --git a/store/listenkv/store_test.go b/store/listenkv/store_test.go index 51b88912c2e1..1f9ca4b2942e 100644 --- a/store/listenkv/store_test.go +++ b/store/listenkv/store_test.go @@ -274,8 +274,3 @@ func TestListenKVStoreCacheWrap(t *testing.T) { store := newEmptyListenKVStore(nil) require.Panics(t, func() { store.CacheWrap() }) } - -func TestListenKVStoreCacheWrapWithTrace(t *testing.T) { - store := newEmptyListenKVStore(nil) - require.Panics(t, func() { store.CacheWrapWithTrace(nil, nil) }) -} diff --git a/store/mem/mem_test.go b/store/mem/mem_test.go index 6595b45dce17..23eb731fe648 100644 --- a/store/mem/mem_test.go +++ b/store/mem/mem_test.go @@ -30,9 +30,6 @@ func TestStore(t *testing.T) { cacheWrapper := db.CacheWrap() require.IsType(t, &cachekv.Store{}, cacheWrapper) - - cacheWrappedWithTrace := db.CacheWrapWithTrace(nil, nil) - require.IsType(t, &cachekv.Store{}, cacheWrappedWithTrace) } func TestCommit(t *testing.T) { diff --git a/store/mem/store.go b/store/mem/store.go index b819d7536302..2b2bc228ddcd 100644 --- a/store/mem/store.go +++ b/store/mem/store.go @@ -1,14 +1,11 @@ package mem import ( - "io" - dbm "github.com/cosmos/cosmos-db" "cosmossdk.io/store/cachekv" "cosmossdk.io/store/dbadapter" pruningtypes "cosmossdk.io/store/pruning/types" - "cosmossdk.io/store/tracekv" "cosmossdk.io/store/types" ) @@ -41,11 +38,6 @@ func (s Store) CacheWrap() types.CacheWrap { return cachekv.NewStore(s) } -// CacheWrapWithTrace implements KVStore. -func (s Store) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.CacheWrap { - return cachekv.NewStore(tracekv.NewStore(s, w, tc)) -} - // Commit performs a no-op as entries are persistent between commitments. func (s *Store) Commit() (id types.CommitID) { return } diff --git a/store/prefix/store.go b/store/prefix/store.go index 32b9e8247e2c..10f50b3ea795 100644 --- a/store/prefix/store.go +++ b/store/prefix/store.go @@ -3,10 +3,8 @@ package prefix import ( "bytes" "errors" - "io" "cosmossdk.io/store/cachekv" - "cosmossdk.io/store/tracekv" "cosmossdk.io/store/types" ) @@ -52,11 +50,6 @@ func (s Store) CacheWrap() types.CacheWrap { return cachekv.NewStore(s) } -// CacheWrapWithTrace implements the KVStore interface. -func (s Store) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.CacheWrap { - return cachekv.NewStore(tracekv.NewStore(s, w, tc)) -} - // Implements KVStore func (s Store) Get(key []byte) []byte { res := s.parent.Get(s.key(key)) diff --git a/store/prefix/store_test.go b/store/prefix/store_test.go index 738835770425..818733033e09 100644 --- a/store/prefix/store_test.go +++ b/store/prefix/store_test.go @@ -445,7 +445,4 @@ func TestCacheWraps(t *testing.T) { cacheWrapper := store.CacheWrap() require.IsType(t, &cachekv.Store{}, cacheWrapper) - - cacheWrappedWithTrace := store.CacheWrapWithTrace(nil, nil) - require.IsType(t, &cachekv.Store{}, cacheWrappedWithTrace) } diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index 94336bc5faa8..39b6d35e5f43 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -544,11 +544,6 @@ func (rs *Store) CacheWrap() types.CacheWrap { return rs.CacheMultiStore().(types.CacheWrap) } -// CacheWrapWithTrace implements the CacheWrapper interface. -func (rs *Store) CacheWrapWithTrace(_ io.Writer, _ types.TraceContext) types.CacheWrap { - return rs.CacheWrap() -} - // CacheMultiStore creates ephemeral branch of the multi-store and returns a CacheMultiStore. // It implements the MultiStore interface. func (rs *Store) CacheMultiStore() types.CacheMultiStore { diff --git a/store/rootmulti/store_test.go b/store/rootmulti/store_test.go index 2702f3e08623..983fc411f3da 100644 --- a/store/rootmulti/store_test.go +++ b/store/rootmulti/store_test.go @@ -17,6 +17,7 @@ import ( sdkmaps "cosmossdk.io/store/internal/maps" "cosmossdk.io/store/metrics" pruningtypes "cosmossdk.io/store/pruning/types" + "cosmossdk.io/store/tracekv" "cosmossdk.io/store/types" ) @@ -690,9 +691,6 @@ func TestCacheWraps(t *testing.T) { cacheWrapper := multi.CacheWrap() require.IsType(t, cachemulti.Store{}, cacheWrapper) - - cacheWrappedWithTrace := multi.CacheWrapWithTrace(nil, nil) - require.IsType(t, cachemulti.Store{}, cacheWrappedWithTrace) } func TestTraceConcurrency(t *testing.T) { @@ -710,7 +708,7 @@ func TestTraceConcurrency(t *testing.T) { cms := multi.CacheMultiStore() store1 := cms.GetKVStore(key) - cw := store1.CacheWrapWithTrace(b, tc) + cw := tracekv.NewStore(store1.CacheWrap().(types.KVStore), b, tc) _ = cw require.NotNil(t, store1) diff --git a/store/tracekv/store.go b/store/tracekv/store.go index ba6df431da16..7df8b0f97ba7 100644 --- a/store/tracekv/store.go +++ b/store/tracekv/store.go @@ -167,12 +167,6 @@ func (tkv *Store) CacheWrap() types.CacheWrap { panic("cannot CacheWrap a TraceKVStore") } -// CacheWrapWithTrace implements the KVStore interface. It panics as a -// Store cannot be branched. -func (tkv *Store) CacheWrapWithTrace(_ io.Writer, _ types.TraceContext) types.CacheWrap { - panic("cannot CacheWrapWithTrace a TraceKVStore") -} - // writeOperation writes a KVStore operation to the underlying io.Writer as // JSON-encoded data where the key/value pair is base64 encoded. func writeOperation(w io.Writer, op operation, tc types.TraceContext, key, value []byte) { diff --git a/store/tracekv/store_test.go b/store/tracekv/store_test.go index 2c42734baefd..d276accd530a 100644 --- a/store/tracekv/store_test.go +++ b/store/tracekv/store_test.go @@ -285,8 +285,3 @@ func TestTraceKVStoreCacheWrap(t *testing.T) { store := newEmptyTraceKVStore(nil) require.Panics(t, func() { store.CacheWrap() }) } - -func TestTraceKVStoreCacheWrapWithTrace(t *testing.T) { - store := newEmptyTraceKVStore(nil) - require.Panics(t, func() { store.CacheWrapWithTrace(nil, nil) }) -} diff --git a/store/types/store.go b/store/types/store.go index 8980179950e2..f37e9860baaa 100644 --- a/store/types/store.go +++ b/store/types/store.go @@ -297,17 +297,11 @@ type CacheWrap interface { // CacheWrap recursively wraps again. CacheWrap() CacheWrap - - // CacheWrapWithTrace recursively wraps again with tracing enabled. - CacheWrapWithTrace(w io.Writer, tc TraceContext) CacheWrap } type CacheWrapper interface { // CacheWrap branches a store. CacheWrap() CacheWrap - - // CacheWrapWithTrace branches a store with tracing enabled. - CacheWrapWithTrace(w io.Writer, tc TraceContext) CacheWrap } func (cid CommitID) IsZero() bool {