Skip to content

Commit

Permalink
resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Dec 12, 2024
1 parent f069df1 commit 38fc4cc
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 7 deletions.
5 changes: 5 additions & 0 deletions runtime/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package runtime

import (
"context"
"io"

"cosmossdk.io/core/store"
storetypes "cosmossdk.io/store/types"
Expand Down Expand Up @@ -109,6 +110,10 @@ func (kvStoreAdapter) CacheWrap() storetypes.CacheWrap {
panic("unimplemented")
}

func (kvStoreAdapter) CacheWrapWithTrace(w io.Writer, tc storetypes.TraceContext) storetypes.CacheWrap {
panic("unimplemented")
}

func (kvStoreAdapter) GetStoreType() storetypes.StoreType {
panic("unimplemented")
}
Expand Down
8 changes: 8 additions & 0 deletions server/mock/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ func (ms multiStore) CacheWrap() storetypes.CacheWrap {
panic("not implemented")
}

func (ms multiStore) CacheWrapWithTrace(w io.Writer, tc storetypes.TraceContext) storetypes.CacheWrap {
panic("unimplemented")
}

func (ms multiStore) TracingEnabled() bool {
panic("not implemented")
}
Expand Down Expand Up @@ -178,6 +182,10 @@ func (kv kvStore) CacheWrap() storetypes.CacheWrap {
panic("not implemented")
}

func (kv kvStore) CacheWrapWithTrace(w io.Writer, tc storetypes.TraceContext) storetypes.CacheWrap {
panic("unimplemented")
}

func (kv kvStore) GetStoreType() storetypes.StoreType {
panic("not implemented")
}
Expand Down
1 change: 1 addition & 0 deletions store/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [#243](https://github.com/crypto-org-chain/cosmos-sdk/pull/243) Support `RunAtomic` API to use new CoW cache store.
* [#244](https://github.com/crypto-org-chain/cosmos-sdk/pull/244) Add `Discard` method to CacheWrap to discard the write buffer.
* [#258](https://github.com/crypto-org-chain/cosmos-sdk/pull/258) Add `NewFromParent` API to cachemulti store to create a new store from block-stm multiversion data structure.
* [#1043](https://github.com/crypto-org-chain/cosmos-sdk/pull/1043) Add back CacheWrapWithTrace api.

## [Unreleased]

Expand Down
7 changes: 5 additions & 2 deletions store/cachekv/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,11 @@ func (store *GStore[V]) CacheWrap() types.CacheWrap {
}

// CacheWrapWithTrace implements the CacheWrapper interface.
func (store *Store) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.CacheWrap {
return NewStore(tracekv.NewStore(store, w, tc))
func (store *GStore[V]) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.CacheWrap {
if store, ok := any(store).(*GStore[[]byte]); ok {
return NewStore(tracekv.NewStore(store, w, tc))
}
return store.CacheWrap()
}

//----------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion store/gaskv/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (gs *GStore[V]) CacheWrap() types.CacheWrap {
}

// CacheWrapWithTrace implements the KVStore interface.
func (gs *Store) CacheWrapWithTrace(_ io.Writer, _ types.TraceContext) types.CacheWrap {
func (gs *GStore[V]) CacheWrapWithTrace(_ io.Writer, _ types.TraceContext) types.CacheWrap {
panic("cannot CacheWrapWithTrace a GasKVStore")
}

Expand Down
7 changes: 7 additions & 0 deletions store/internal/btreeadaptor.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package internal

import (
"io"

"cosmossdk.io/store/cachekv"
"cosmossdk.io/store/internal/btree"
"cosmossdk.io/store/types"
Expand Down Expand Up @@ -59,3 +61,8 @@ func (ts *BTreeStore[V]) GetStoreType() types.StoreType {
func (ts *BTreeStore[V]) CacheWrap() types.CacheWrap {
return cachekv.NewGStore(ts, ts.isZero, ts.valueLen)
}

// CacheWrapWithTrace branches the underlying store.
func (ts *BTreeStore[V]) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.CacheWrap {
return cachekv.NewGStore(ts, ts.isZero, ts.valueLen)
}
7 changes: 5 additions & 2 deletions store/prefix/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ func (s GStore[V]) CacheWrap() types.CacheWrap {
}

// 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))
func (s GStore[V]) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.CacheWrap {
if store, ok := any(s).(*GStore[[]byte]); ok {
return cachekv.NewGStore(tracekv.NewStore(store, w, tc), store.isZero, store.valueLen)
}
return s.CacheWrap()
}

// Implements KVStore
Expand Down
3 changes: 1 addition & 2 deletions store/tracekv/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io"

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

Expand Down Expand Up @@ -165,7 +164,7 @@ func (tkv *Store) GetStoreType() types.StoreType {
// CacheWrap implements the KVStore interface. It panics because a Store
// cannot be branched.
func (tkv *Store) CacheWrap() types.CacheWrap {
return cachekv.NewStore(tkv)
return tkv.parent.CacheWrap()
}

// CacheWrapWithTrace implements the KVStore interface. It panics as a
Expand Down
3 changes: 3 additions & 0 deletions store/types/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ type CacheWrap interface {

// Discard the write set
Discard()

// CacheWrapWithTrace branches a store with tracing enabled.
CacheWrapWithTrace(w io.Writer, tc TraceContext) CacheWrap
}

type CacheWrapper interface {
Expand Down

0 comments on commit 38fc4cc

Please sign in to comment.