Skip to content

Commit

Permalink
Allow state exporting from any directory (#3608)
Browse files Browse the repository at this point in the history
* Allow exporting from any directory

* Changelog

(cherry picked from commit da4f503)

# Conflicts:
#	CHANGELOG.md
#	app/export.go
  • Loading branch information
ValarDragon authored and mergify[bot] committed Dec 4, 2022
1 parent 1da5605 commit c275610
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## v12.3.0

<<<<<<< HEAD
* [#3325](https://github.com/osmosis-labs/osmosis/pull/3325) Use mainline iavl v0.19.4 instead of our iavl fork
=======
### Features

* [#2788](https://github.com/osmosis-labs/osmosis/pull/2788) Add logarithm base 2 implementation.

### Bug fixes

* [#3608](https://github.com/osmosis-labs/osmosis/pull/3608) Make it possible to state export from any directory.

### Misc Improvements


## v13.0.0

This release includes stableswap, and expands the IBC safety & composability functionality of Osmosis. The primary features are:
>>>>>>> da4f5038 (Allow state exporting from any directory (#3608))
## v12.2.1

Expand Down
12 changes: 7 additions & 5 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ package app

import (
"encoding/json"
"log"
"fmt"

tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)

// ExportAppStateAndValidators exports the state of the application for a genesis
Expand All @@ -25,8 +23,7 @@ func (app *OsmosisApp) ExportAppStateAndValidators(
// Tendermint will start InitChain.
height := app.LastBlockHeight() + 1
if forZeroHeight {
height = 0
app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs)
return servertypes.ExportedApp{}, fmt.Errorf("forZeroHeight not supported")
}

genState := app.mm.ExportGenesis(ctx, app.AppCodec(), modulesToExport)
Expand All @@ -44,6 +41,7 @@ func (app *OsmosisApp) ExportAppStateAndValidators(
}, err
}

<<<<<<< HEAD
// prepare for fresh start at zero height
// NOTE zero height genesis is a temporary feature which will be deprecated
//
Expand Down Expand Up @@ -194,4 +192,8 @@ func (app *OsmosisApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
return false
},
)
=======
func (app *OsmosisApp) ExportState(ctx sdk.Context) map[string]json.RawMessage {
return app.mm.ExportGenesis(ctx, app.AppCodec())
>>>>>>> da4f5038 (Allow state exporting from any directory (#3608))
}
9 changes: 4 additions & 5 deletions cmd/osmosisd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,14 @@ func createOsmosisAppAndExport(
) (servertypes.ExportedApp, error) {
encCfg := osmosis.MakeEncodingConfig() // Ideally, we would reuse the one created by NewRootCmd.
encCfg.Marshaler = codec.NewProtoCodec(encCfg.InterfaceRegistry)
var app *osmosis.OsmosisApp
if height != -1 {
app = osmosis.NewOsmosisApp(logger, db, traceStore, false, map[int64]bool{}, "", uint(1), appOpts, osmosis.GetWasmEnabledProposals(), osmosis.EmptyWasmOpts)
loadLatest := height == -1
homeDir := cast.ToString(appOpts.Get(flags.FlagHome))
app := osmosis.NewOsmosisApp(logger, db, traceStore, loadLatest, map[int64]bool{}, homeDir, 0, appOpts, osmosis.GetWasmEnabledProposals(), osmosis.EmptyWasmOpts)

if !loadLatest {
if err := app.LoadHeight(height); err != nil {
return servertypes.ExportedApp{}, err
}
} else {
app = osmosis.NewOsmosisApp(logger, db, traceStore, true, map[int64]bool{}, "", uint(1), appOpts, osmosis.GetWasmEnabledProposals(), osmosis.EmptyWasmOpts)
}

return app.ExportAppStateAndValidators(forZeroHeight, jailWhiteList, modulesToExport)
Expand Down

0 comments on commit c275610

Please sign in to comment.