Merge PR #2792: Support export at specific height
This commit is contained in:
commit
d40d767bc8
|
@ -29,8 +29,10 @@ FEATURES
|
|||
* [stake][cli] [\#2027] Add CLI query command for getting all delegations to a specific validator.
|
||||
|
||||
* Gaia
|
||||
* [app] \#2791 Support export at a specific height, with `gaiad export --height=HEIGHT`.
|
||||
* [x/gov] [#2479](https://github.com/cosmos/cosmos-sdk/issues/2479) Implemented querier
|
||||
for getting governance parameters.
|
||||
* [app] \#2791 Support export at a specific height, with `gaiad export --height=HEIGHT`.
|
||||
|
||||
* SDK
|
||||
* [simulator] \#2682 MsgEditValidator now looks at the validator's max rate, thus it now succeeds a significant portion of the time
|
||||
|
|
|
@ -324,6 +324,11 @@ func (app *GaiaApp) ExportAppStateAndValidators() (appState json.RawMessage, val
|
|||
return appState, validators, nil
|
||||
}
|
||||
|
||||
// load a particular height
|
||||
func (app *GaiaApp) LoadHeight(height int64) error {
|
||||
return app.LoadVersion(height, app.keyMain)
|
||||
}
|
||||
|
||||
//______________________________________________________________________________________________
|
||||
|
||||
// Combined Staking Hooks
|
||||
|
|
|
@ -64,8 +64,14 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer) abci.Application
|
|||
}
|
||||
|
||||
func exportAppStateAndTMValidators(
|
||||
logger log.Logger, db dbm.DB, traceStore io.Writer,
|
||||
logger log.Logger, db dbm.DB, traceStore io.Writer, height int64,
|
||||
) (json.RawMessage, []tmtypes.GenesisValidator, error) {
|
||||
gApp := app.NewGaiaApp(logger, db, traceStore)
|
||||
if height != -1 {
|
||||
err := gApp.LoadHeight(height)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
}
|
||||
return gApp.ExportAppStateAndValidators()
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ func newApp(logger log.Logger, db dbm.DB, storeTracer io.Writer) abci.Applicatio
|
|||
return app.NewBasecoinApp(logger, db, baseapp.SetPruning(viper.GetString("pruning")))
|
||||
}
|
||||
|
||||
func exportAppStateAndTMValidators(logger log.Logger, db dbm.DB, storeTracer io.Writer) (
|
||||
func exportAppStateAndTMValidators(logger log.Logger, db dbm.DB, storeTracer io.Writer, _ int64) (
|
||||
json.RawMessage, []tmtypes.GenesisValidator, error) {
|
||||
bapp := app.NewBasecoinApp(logger, db)
|
||||
return bapp.ExportAppStateAndValidators()
|
||||
|
|
|
@ -133,7 +133,7 @@ func newApp(logger log.Logger, db dbm.DB, _ io.Writer) abci.Application {
|
|||
return app.NewDemocoinApp(logger, db)
|
||||
}
|
||||
|
||||
func exportAppStateAndTMValidators(logger log.Logger, db dbm.DB, _ io.Writer) (
|
||||
func exportAppStateAndTMValidators(logger log.Logger, db dbm.DB, _ io.Writer, _ int64) (
|
||||
json.RawMessage, []tmtypes.GenesisValidator, error) {
|
||||
dapp := app.NewDemocoinApp(logger, db)
|
||||
return dapp.ExportAppStateAndValidators()
|
||||
|
|
|
@ -129,6 +129,21 @@ gaiacli status
|
|||
|
||||
View the status of the network with the [Cosmos Explorer](https://explorecosmos.network). Once your full node syncs up to the current block height, you should see it appear on the [list of full nodes](https://explorecosmos.network/validators). If it doesn't show up, that's ok--the Explorer does not connect to every node.
|
||||
|
||||
## Export State
|
||||
|
||||
Gaia can dump the entire application state to a JSON file, which could be useful for manual analysis and can also be used as the genesis file of a new network.
|
||||
|
||||
Export state with:
|
||||
|
||||
```bash
|
||||
gaiad export > [filename].json
|
||||
```
|
||||
|
||||
You can also export state from a particular height (at the end of processing the block of that height):
|
||||
|
||||
```bash
|
||||
gaiad export --height=[height] > [filename].json
|
||||
```
|
||||
|
||||
## Upgrade to Validator Node
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ type (
|
|||
|
||||
// AppExporter is a function that dumps all app state to
|
||||
// JSON-serializable structure and returns the current validator set.
|
||||
AppExporter func(log.Logger, dbm.DB, io.Writer) (json.RawMessage, []tmtypes.GenesisValidator, error)
|
||||
AppExporter func(log.Logger, dbm.DB, io.Writer, int64) (json.RawMessage, []tmtypes.GenesisValidator, error)
|
||||
)
|
||||
|
||||
func openDB(rootDir string) (dbm.DB, error) {
|
||||
|
|
|
@ -13,9 +13,13 @@ import (
|
|||
"path"
|
||||
)
|
||||
|
||||
const (
|
||||
flagHeight = "height"
|
||||
)
|
||||
|
||||
// ExportCmd dumps app state to JSON.
|
||||
func ExportCmd(ctx *Context, cdc *codec.Codec, appExporter AppExporter) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
cmd := &cobra.Command{
|
||||
Use: "export",
|
||||
Short: "Export state to JSON",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
|
@ -45,7 +49,8 @@ func ExportCmd(ctx *Context, cdc *codec.Codec, appExporter AppExporter) *cobra.C
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
appState, validators, err := appExporter(ctx.Logger, db, traceWriter)
|
||||
height := viper.GetInt64(flagHeight)
|
||||
appState, validators, err := appExporter(ctx.Logger, db, traceWriter, height)
|
||||
if err != nil {
|
||||
return errors.Errorf("error exporting state: %v\n", err)
|
||||
}
|
||||
|
@ -67,6 +72,8 @@ func ExportCmd(ctx *Context, cdc *codec.Codec, appExporter AppExporter) *cobra.C
|
|||
return nil
|
||||
},
|
||||
}
|
||||
cmd.Flags().Int64(flagHeight, -1, "Export state from a particular height (-1 means latest height)")
|
||||
return cmd
|
||||
}
|
||||
|
||||
func isEmptyState(home string) (bool, error) {
|
||||
|
|
Loading…
Reference in New Issue