Skip to content

Commit

Permalink
Cherry-pick: Problem: CacheWrapWithTrace api is not used (crypto-org-…
Browse files Browse the repository at this point in the history
…chain#207)

Reason for Cherry-pick:
- Good for maintaining (remove not used api)

Original Commit Message:

Solution:
- remove the api

changelog

Original author: yihuang <[email protected]>

-----------

Cherry-picked-by: zsystm <[email protected]>
  • Loading branch information
yihuang authored and zsystm committed May 24, 2024
1 parent 373a5be commit 87e8f49
Show file tree
Hide file tree
Showing 16 changed files with 8 additions and 75 deletions.
8 changes: 6 additions & 2 deletions store/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,20 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

* [#207](https://github.com/crypto-org-chain/cosmos-sdk/pull/207) Remove api CacheWrapWithTrace.
* [#205](https://github.com/crypto-org-chain/cosmos-sdk/pull/205) Support object store.
* [#207](https://github.com/crypto-org-chain/cosmos-sdk/pull/207) Remove unused api CacheWrapWithTrace.

## v1.1.0 (March 20, 2024)

### Improvements

* [#19770](https://github.com/cosmos/cosmos-sdk/pull/19770) Upgrade IAVL to IAVL v1.1.1.

## v1.0.2 (January 10, 2024)

### Bug Fixes

* [#18897](https://github.com/cosmos/cosmos-sdk/pull/18897) Replace panic in pruning to avoid consensus halting.
* [#18897](https://github.com/cosmos/cosmos-sdk/pull/18897) Replace panic in pruning to avoid consensus halting.

## v1.0.1 (November 28, 2023)

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

Expand Down Expand Up @@ -178,11 +176,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 @@ -662,9 +662,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
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)
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 @@ -444,7 +444,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 @@ -550,11 +550,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 @@ -168,12 +168,6 @@ func (tkv *Store) CacheWrap() types.CacheWrap {
return cachekv.NewStore(tkv)
}

// 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)
store.CacheWrap()
}

func TestTraceKVStoreCacheWrapWithTrace(t *testing.T) {
store := newEmptyTraceKVStore(nil)
require.Panics(t, func() { store.CacheWrapWithTrace(nil, nil) })
}

0 comments on commit 87e8f49

Please sign in to comment.