Skip to content

Commit

Permalink
fix: prune cmd should disable async pruning (#22656)
Browse files Browse the repository at this point in the history
(cherry picked from commit eb3bf8b)

# Conflicts:
#	store/iavl/store.go
#	store/rootmulti/store.go
#	store/types/store.go
  • Loading branch information
yihuang authored and mergify[bot] committed Dec 4, 2024
1 parent 4c5632c commit 19d502a
Show file tree
Hide file tree
Showing 9 changed files with 2,274 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i

* (sims) [#21906](https://github.com/cosmos/cosmos-sdk/pull/21906) Skip sims test when running dry on validators
* (cli) [#21919](https://github.com/cosmos/cosmos-sdk/pull/21919) Query address-by-acc-num by account_id instead of id.
* (cli) [#22656](https://github.com/cosmos/cosmos-sdk/pull/22656) Prune cmd should disable async pruning.

### API Breaking Changes

Expand Down
5 changes: 5 additions & 0 deletions baseapp/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ func SetIAVLDisableFastNode(disable bool) func(*BaseApp) {
return func(bapp *BaseApp) { bapp.cms.SetIAVLDisableFastNode(disable) }
}

// SetIAVLSyncPruning set sync/async pruning in the IAVL store.
func SetIAVLSyncPruning(syncPruning bool) func(*BaseApp) {
return func(bapp *BaseApp) { bapp.cms.SetIAVLSyncPruning(syncPruning) }

Check failure on line 91 in baseapp/options.go

View workflow job for this annotation

GitHub Actions / dependency-review

bapp.cms.SetIAVLSyncPruning undefined (type "cosmossdk.io/store/types".CommitMultiStore has no field or method SetIAVLSyncPruning)

Check failure on line 91 in baseapp/options.go

View workflow job for this annotation

GitHub Actions / golangci-lint

bapp.cms.SetIAVLSyncPruning undefined (type "cosmossdk.io/store/types".CommitMultiStore has no field or method SetIAVLSyncPruning)) (typecheck)
}

// SetInterBlockCache provides a BaseApp option function that sets the
// inter-block cache.
func SetInterBlockCache(cache storetypes.MultiStorePersistentCache) func(*BaseApp) {
Expand Down
6 changes: 6 additions & 0 deletions client/pruning/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ Supported app-db-backend types include 'goleveldb', 'rocksdb', 'pebbledb'.`,
return err
}

// must disable async pruning
vp.Set(server.FlagIAVLSyncPruning, true)

// use the first argument if present to set the pruning method
if len(args) > 0 {
vp.Set(server.FlagPruning, args[0])
Expand All @@ -72,6 +75,9 @@ Supported app-db-backend types include 'goleveldb', 'rocksdb', 'pebbledb'.`,
return err
}

// in our test, it's important to close db explicitly for pebbledb to write to disk.
defer db.Close()

logger := log.NewLogger(cmd.OutOrStdout())
app := appCreator(logger, db, nil, vp)
cms := app.CommitMultiStore()
Expand Down
4 changes: 4 additions & 0 deletions server/mock/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ func (ms multiStore) SetIAVLDisableFastNode(disable bool) {
panic("not implemented")
}

func (ms multiStore) SetIAVLSyncPruning(syncPruning bool) {
panic("not implemented")
}

func (ms multiStore) SetInitialVersion(version int64) error {
panic("not implemented")
}
Expand Down
1 change: 1 addition & 0 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const (
FlagMinRetainBlocks = "min-retain-blocks"
FlagIAVLCacheSize = "iavl-cache-size"
FlagDisableIAVLFastNode = "iavl-disable-fastnode"
FlagIAVLSyncPruning = "iavl-sync-pruning"
FlagShutdownGrace = "shutdown-grace"

// state sync-related flags
Expand Down
1 change: 1 addition & 0 deletions server/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ func DefaultBaseappOptions(appOpts types.AppOptions) []func(*baseapp.BaseApp) {
baseapp.SetSnapshot(snapshotStore, snapshotOptions),
baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(FlagIAVLCacheSize))),
baseapp.SetIAVLDisableFastNode(cast.ToBool(appOpts.Get(FlagDisableIAVLFastNode))),
baseapp.SetIAVLSyncPruning(cast.ToBool(appOpts.Get(FlagIAVLSyncPruning))),
defaultMempool,
baseapp.SetChainID(chainID),
baseapp.SetQueryGasLimit(cast.ToUint64(appOpts.Get(FlagQueryGasLimit))),
Expand Down
Loading

0 comments on commit 19d502a

Please sign in to comment.