Skip to content

Commit

Permalink
refactor: pass logger to store (#14438)
Browse files Browse the repository at this point in the history
  • Loading branch information
tac0turtle authored Dec 28, 2022
1 parent 741f4ae commit 7d2ba36
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/gov) [#14390](https://github.com/cosmos/cosmos-sdk/pull/14390) Add title, proposer and summary to proposal struct
* (baseapp) [#14417](https://github.com/cosmos/cosmos-sdk/pull/14417) `SetStreamingService` accepts appOptions, AppCodec and Storekeys needed to set streamers.
* Store pacakge no longer has a dependency on baseapp.
* (store) [#14438](https://github.com/cosmos/cosmos-sdk/pull/14438) Pass logger from baseapp to store.

### State Machine Breaking

Expand Down
2 changes: 1 addition & 1 deletion baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func NewBaseApp(
logger: logger,
name: name,
db: db,
cms: store.NewCommitMultiStore(db),
cms: store.NewCommitMultiStore(db, logger),
storeLoader: DefaultStoreLoader,
grpcQueryRouter: NewGRPCQueryRouter(),
msgServiceRouter: NewMsgServiceRouter(),
Expand Down
1 change: 1 addition & 0 deletions server/mock/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

func TestStore(t *testing.T) {
db := dbm.NewMemDB()

cms := NewCommitMultiStore()

key := sdk.NewKVStoreKey("test")
Expand Down
2 changes: 1 addition & 1 deletion store/cachekv/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func DoBenchmarkDeepContextStack(b *testing.B, depth int) {
key := storetypes.NewKVStoreKey("test")

db := dbm.NewMemDB()
cms := store.NewCommitMultiStore(db)
cms := store.NewCommitMultiStore(db, log.NewNopLogger())
cms.MountStoreWithDB(key, storetypes.StoreTypeIAVL, db)
cms.LoadLatestVersion()
ctx := sdk.NewContext(cms, tmproto.Header{}, false, log.NewNopLogger())
Expand Down
4 changes: 2 additions & 2 deletions store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/cosmos/cosmos-sdk/store/types"
)

func NewCommitMultiStore(db dbm.DB) types.CommitMultiStore {
return rootmulti.NewStore(db, log.NewNopLogger())
func NewCommitMultiStore(db dbm.DB, logger log.Logger) types.CommitMultiStore {
return rootmulti.NewStore(db, logger)
}

func NewCommitKVStoreCacheManager() types.MultiStorePersistentCache {
Expand Down
4 changes: 2 additions & 2 deletions testutil/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
// DefaultContext creates a sdk.Context with a fresh MemDB that can be used in tests.
func DefaultContext(key storetypes.StoreKey, tkey storetypes.StoreKey) sdk.Context {
db := dbm.NewMemDB()
cms := store.NewCommitMultiStore(db)
cms := store.NewCommitMultiStore(db, log.NewNopLogger())
cms.MountStoreWithDB(key, storetypes.StoreTypeIAVL, db)
cms.MountStoreWithDB(tkey, storetypes.StoreTypeTransient, db)
err := cms.LoadLatestVersion()
Expand All @@ -36,7 +36,7 @@ type TestContext struct {

func DefaultContextWithDB(t *testing.T, key storetypes.StoreKey, tkey storetypes.StoreKey) TestContext {
db := dbm.NewMemDB()
cms := store.NewCommitMultiStore(db)
cms := store.NewCommitMultiStore(db, log.NewNopLogger())
cms.MountStoreWithDB(key, storetypes.StoreTypeIAVL, db)
cms.MountStoreWithDB(tkey, storetypes.StoreTypeTransient, db)
err := cms.LoadLatestVersion()
Expand Down
6 changes: 4 additions & 2 deletions x/group/internal/orm/testsupport.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package orm
import (
"fmt"

"github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"

"github.com/cosmos/cosmos-sdk/store"
"github.com/cosmos/cosmos-sdk/store/gaskv"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
dbm "github.com/tendermint/tm-db"
)

type MockContext struct {
Expand All @@ -19,7 +21,7 @@ func NewMockContext() *MockContext {
db := dbm.NewMemDB()
return &MockContext{
db: dbm.NewMemDB(),
store: store.NewCommitMultiStore(db),
store: store.NewCommitMultiStore(db, log.NewNopLogger()),
}
}

Expand Down
3 changes: 1 addition & 2 deletions x/group/keeper/invariants_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/stretchr/testify/suite"
"github.com/tendermint/tendermint/libs/log"

tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

Expand Down Expand Up @@ -39,7 +38,7 @@ func (s *invariantTestSuite) SetupSuite() {
cdc := codec.NewProtoCodec(interfaceRegistry)
key := sdk.NewKVStoreKey(group.ModuleName)
db := dbm.NewMemDB()
cms := store.NewCommitMultiStore(db)
cms := store.NewCommitMultiStore(db, log.NewNopLogger())
cms.MountStoreWithDB(key, storetypes.StoreTypeIAVL, db)
_ = cms.LoadLatestVersion()
sdkCtx := sdk.NewContext(cms, tmproto.Header{}, false, log.NewNopLogger())
Expand Down
2 changes: 1 addition & 1 deletion x/params/types/subspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type SubspaceTestSuite struct {
func (suite *SubspaceTestSuite) SetupTest() {
db := dbm.NewMemDB()

ms := store.NewCommitMultiStore(db)
ms := store.NewCommitMultiStore(db, log.NewNopLogger())
ms.MountStoreWithDB(key, storetypes.StoreTypeIAVL, db)
ms.MountStoreWithDB(tkey, storetypes.StoreTypeTransient, db)
suite.NoError(ms.LoadLatestVersion())
Expand Down

0 comments on commit 7d2ba36

Please sign in to comment.