Skip to content

Commit

Permalink
Merge pull request #15 from Solovyov1796/localdev-0glabs-v0.47.10-rel…
Browse files Browse the repository at this point in the history
…ease-x

enable and improve log for store and pruning
  • Loading branch information
Solovyov1796 authored Oct 26, 2024
2 parents 2520978 + 7d863ce commit 26ce7ac
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,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
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
7 changes: 5 additions & 2 deletions store/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,9 +608,12 @@ func (rs *Store) PruneStores(pruningHeight int64) (err error) {

rs.logger.Debug("pruning store", "height", pruningHeight)

cnt := 1
total := len(rs.stores)
for key, store := range rs.stores {
rs.logger.Debug("pruning store", "key", key) // Also log store.name (a private variable)?

rs.logger.Debug("pruning store", "key", key.Name()) // Also log store.name (a private variable)?
rs.logger.Info(fmt.Sprintf("pruning for module \"%s\" to height %d. (%d/%d)", key.Name(), pruningHeight, cnt, total))
cnt++
// If the store is wrapped with an inter-block cache, we must first unwrap
// it to get the underlying IAVL store.
if store.GetStoreType() != types.StoreTypeIAVL {
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
3 changes: 2 additions & 1 deletion x/group/internal/orm/testsupport.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

dbm "github.com/cometbft/cometbft-db"
"github.com/cometbft/cometbft/libs/log"
"github.com/cosmos/cosmos-sdk/store"
"github.com/cosmos/cosmos-sdk/store/gaskv"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
Expand All @@ -19,7 +20,7 @@ func NewMockContext() *MockContext {
db := dbm.NewMemDB()
return &MockContext{
db: dbm.NewMemDB(),
store: store.NewCommitMultiStore(db),
store: store.NewCommitMultiStore(db, log.NewNopLogger()),
}
}

Expand Down
2 changes: 1 addition & 1 deletion x/group/keeper/invariants_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,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 26ce7ac

Please sign in to comment.