From f0de908f39fde64407d9c195a095b421b23f4e82 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 21 Dec 2023 12:41:57 -0700 Subject: [PATCH] attempt further fixes --- baseapp/options.go | 5 --- client/pruning/main.go | 4 +- server/util.go | 1 - store/rootmulti/store.go | 80 +++++++++++----------------------------- store/types/store.go | 3 -- 5 files changed, 24 insertions(+), 69 deletions(-) diff --git a/baseapp/options.go b/baseapp/options.go index e669495f647d..4949d73358a4 100644 --- a/baseapp/options.go +++ b/baseapp/options.go @@ -70,11 +70,6 @@ func SetIAVLDisableFastNode(disable bool) func(*BaseApp) { return func(bapp *BaseApp) { bapp.cms.SetIAVLDisableFastNode(disable) } } -// SetIAVLLazyLoading enables/disables lazy loading of the IAVL store. -func SetIAVLLazyLoading(lazyLoading bool) func(*BaseApp) { - return func(bapp *BaseApp) { bapp.cms.SetLazyLoading(lazyLoading) } -} - // SetInterBlockCache provides a BaseApp option function that sets the // inter-block cache. func SetInterBlockCache(cache sdk.MultiStorePersistentCache) func(*BaseApp) { diff --git a/client/pruning/main.go b/client/pruning/main.go index 247cd2c360c9..d6b96796da78 100644 --- a/client/pruning/main.go +++ b/client/pruning/main.go @@ -106,9 +106,11 @@ Supported app-db-backend types include 'goleveldb', 'rocksdb', 'pebbledb'.`, } cmd.Printf("pruning heights start from %v, end at %v\n", pruningHeights[0], pruningHeights[len(pruningHeights)-1]) - if err = rootMultiStore.PruneStores(false, pruningHeights); err != nil { + rootMultiStore.PruneStores(pruningHeights[len(pruningHeights)-1]) + if err != nil { return err } + fmt.Printf("successfully pruned the application root multi stores\n") cmd.Println("successfully pruned the application root multi stores") return nil diff --git a/server/util.go b/server/util.go index 9a6ae40f786e..517724129eef 100644 --- a/server/util.go +++ b/server/util.go @@ -493,7 +493,6 @@ func DefaultBaseappOptions(appOpts types.AppOptions) []func(*baseapp.BaseApp) { mempool.SenderNonceMaxTxOpt(cast.ToInt(appOpts.Get(FlagMempoolMaxTxs))), ), ), - baseapp.SetIAVLLazyLoading(cast.ToBool(appOpts.Get(FlagIAVLLazyLoading))), baseapp.SetChainID(chainID), } } diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index 42c80a9eb2b9..ae985ce97f53 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -64,15 +64,15 @@ type Store struct { storesParams map[types.StoreKey]storeParams stores map[types.StoreKey]types.CommitKVStore keysByName map[string]types.StoreKey - lazyLoading bool - initialVersion int64 - removalMap map[types.StoreKey]bool - traceWriter io.Writer - traceContext types.TraceContext - traceContextMutex sync.Mutex - interBlockCache types.MultiStorePersistentCache - listeners map[types.StoreKey][]types.WriteListener - commitHeader cmtproto.Header + + initialVersion int64 + removalMap map[types.StoreKey]bool + traceWriter io.Writer + traceContext types.TraceContext + traceContextMutex sync.Mutex + interBlockCache types.MultiStorePersistentCache + listeners map[types.StoreKey][]types.WriteListener + commitHeader cmtproto.Header } var ( @@ -125,11 +125,6 @@ func (rs *Store) SetIAVLDisableFastNode(disableFastNode bool) { rs.iavlDisableFastNode = disableFastNode } -// SetLazyLoading sets if the iavl store should be loaded lazily or not -func (rs *Store) SetLazyLoading(lazyLoading bool) { - rs.lazyLoading = lazyLoading -} - // GetStoreType implements Store. func (rs *Store) GetStoreType() types.StoreType { return types.StoreTypeMulti @@ -600,60 +595,27 @@ func (rs *Store) handlePruning(version int64) error { } rs.logger.Info("prune start", "height", version) defer rs.logger.Info("prune end", "height", version) - return rs.PruneStores(true, nil) + rs.PruneStores(version) + return nil } // PruneStores prunes the specific heights of the multi store. // If clearPruningManager is true, the pruning manager will return the pruning heights, // and they are appended to the pruningHeights to be pruned. -func (rs *Store) PruneStores(clearPruningManager bool, pruningHeights []int64) (err error) { - if clearPruningManager { - heights, err := rs.pruningManager.GetFlushAndResetPruningHeights() - if err != nil { - return err - } - - if len(heights) == 0 { - rs.logger.Debug("no heights to be pruned from pruning manager") - } - - pruningHeights = append(pruningHeights, heights...) - } - - if len(pruningHeights) == 0 { - rs.logger.Debug("no heights need to be pruned") - return nil - } - - maxHeight := int64(0) - for _, height := range pruningHeights { - if height > maxHeight { - maxHeight = height - } - } - rs.logger.Debug("pruning store", "heights", maxHeight) - +func (rs *Store) PruneStores(pruningHeight int64) { for key, store := range rs.stores { - rs.logger.Debug("pruning store", "key", key) // Also log store.name (a private variable)? - - // 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 { - continue - } - - store = rs.GetCommitKVStore(key) - - err := store.(*iavl.Store).DeleteVersionsTo(maxHeight) - if err == nil { - continue - } + if store.GetStoreType() == types.StoreTypeIAVL { + // If the store is wrapped with an inter-block cache, we must first unwrap + // it to get the underlying IAVL store. + store = rs.GetCommitKVStore(key) - if errCause := errors.Cause(err); errCause != nil && errCause != iavltree.ErrVersionDoesNotExist { - return err + if err := store.(*iavl.Store).DeleteVersionsTo(pruningHeight); err != nil { + if errCause := errors.Cause(err); errCause != nil && errCause != iavltree.ErrVersionDoesNotExist { + panic(err) + } + } } } - return nil } // getStoreByName performs a lookup of a StoreKey given a store name typically diff --git a/store/types/store.go b/store/types/store.go index 992173195661..bb0913d17f66 100644 --- a/store/types/store.go +++ b/store/types/store.go @@ -188,9 +188,6 @@ type CommitMultiStore interface { // SetIAVLDisableFastNode enables/disables fastnode feature on iavl. SetIAVLDisableFastNode(disable bool) - // SetIAVLLazyLoading enable/disable lazy loading on iavl. - SetLazyLoading(lazyLoading bool) - // RollbackToVersion rollback the db to specific version(height). RollbackToVersion(version int64) error