Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: CacheWrapWithTrace api is not used #207

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions store/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions store/cachekv/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cachekv

import (
"bytes"
"io"
"sort"
"sync"

Expand All @@ -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"
)

Expand Down Expand Up @@ -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

Expand Down
5 changes: 0 additions & 5 deletions store/cachemulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 0 additions & 8 deletions store/dbadapter/store.go
Original file line number Diff line number Diff line change
@@ -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"
)

Expand Down Expand Up @@ -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{}
3 changes: 0 additions & 3 deletions store/dbadapter/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
7 changes: 0 additions & 7 deletions store/gaskv/store.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package gaskv

import (
"io"

"cosmossdk.io/store/types"
)

Expand Down Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion store/gaskv/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
7 changes: 0 additions & 7 deletions store/iavl/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package iavl
import (
"errors"
"fmt"
"io"

cmtprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto"
dbm "github.com/cosmos/cosmos-db"
Expand All @@ -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"
)
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions store/iavl/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 0 additions & 8 deletions store/listenkv/store.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package listenkv

import (
"io"

"cosmossdk.io/store/types"
)

Expand Down Expand Up @@ -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")
}
5 changes: 0 additions & 5 deletions store/listenkv/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) })
}
3 changes: 0 additions & 3 deletions store/mem/mem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 0 additions & 8 deletions store/mem/store.go
Original file line number Diff line number Diff line change
@@ -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"
)

Expand Down Expand Up @@ -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 }

Expand Down
7 changes: 0 additions & 7 deletions store/prefix/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ package prefix
import (
"bytes"
"errors"
"io"

"cosmossdk.io/store/cachekv"
"cosmossdk.io/store/tracekv"
"cosmossdk.io/store/types"
)

Expand Down Expand Up @@ -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))
Expand Down
3 changes: 0 additions & 3 deletions store/prefix/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
5 changes: 0 additions & 5 deletions store/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 2 additions & 4 deletions store/rootmulti/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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) {
Expand All @@ -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)

Expand Down
6 changes: 0 additions & 6 deletions store/tracekv/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 0 additions & 5 deletions store/tracekv/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) })
}
6 changes: 0 additions & 6 deletions store/types/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading