Skip to content

Commit

Permalink
fix: forceprune logic (backport #8978) (#8979)
Browse files Browse the repository at this point in the history
* fix: forceprune logic (#8978)

* fix: forceprune logic

* chore: add changelog

(cherry picked from commit 455d378)

# Conflicts:
#	CHANGELOG.md

* chore: fix merge conflits with CHANGELOG

---------

Co-authored-by: PaddyMc <[email protected]>
  • Loading branch information
mergify[bot] and PaddyMc authored Feb 3, 2025
1 parent 82a6353 commit d968d04
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### State Compatible

* [#8978](https://github.com/osmosis-labs/osmosis/pull/8895) fix: forceprune logic

## v28.0.3

### State Breaking

### State Compatible

* [#8968](https://github.com/osmosis-labs/osmosis/pull/8968) fix: use forked block-sdk patch
* [#8895](https://github.com/osmosis-labs/osmosis/pull/8895) (xcs) feat: support XCS final hop memos

## v28.0.2

### State Breaking
Expand Down
6 changes: 4 additions & 2 deletions cmd/osmosisd/cmd/forceprune.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ which would keep blockchain and state data of last 188000 blocks (approximately
return err
}

startHeight, currentHeight, err := pruneBlockStoreAndGetHeights(dbPath, fullHeight)
startHeight, currentHeight, err := pruneBlockStoreAndGetHeights(clientCtx.HomeDir, dbPath, fullHeight)
if err != nil {
return err
}
Expand All @@ -100,7 +100,7 @@ which would keep blockchain and state data of last 188000 blocks (approximately
}

// pruneBlockStoreAndGetHeights prunes blockstore and returns the startHeight and currentHeight.
func pruneBlockStoreAndGetHeights(dbPath string, fullHeight int64) (
func pruneBlockStoreAndGetHeights(homeDir, dbPath string, fullHeight int64) (
startHeight int64, currentHeight int64, err error,
) {
opts := opt.Options{
Expand All @@ -119,6 +119,7 @@ func pruneBlockStoreAndGetHeights(dbPath string, fullHeight int64) (
currentHeight = bs.Height()

defaultConfig := cmtcfg.DefaultConfig()
defaultConfig.SetRoot(homeDir)

stateDB, err := cmtcfg.DefaultDBProvider(&cmtcfg.DBContext{ID: "state", Config: defaultConfig})
if err != nil {
Expand All @@ -128,6 +129,7 @@ func pruneBlockStoreAndGetHeights(dbPath string, fullHeight int64) (
stateStore := sm.NewStore(stateDB, sm.StoreOptions{
DiscardABCIResponses: defaultConfig.Storage.DiscardABCIResponses,
})
defer stateStore.Close()

// Can use blank string for genesis file since state will not be empty if we are pruning, and therefore is not used.
state, err := stateStore.LoadFromDBOrGenesisFile("")
Expand Down

0 comments on commit d968d04

Please sign in to comment.