From cdeb3e35d2aa2bb5a32fe2b8395c8f94b51fc469 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Wed, 20 Dec 2023 17:48:22 +0400 Subject: [PATCH] feat: `snapshots` command (#1411) * feat: add the snapshots command * make generate * make generate * changelog --------- Co-authored-by: Lucas Bertrand --- changelog.md | 1 + cmd/zetacored/root.go | 10 ++++-- docs/cli/zetacored/zetacored.md | 1 + docs/cli/zetacored/zetacored_snapshots.md | 29 +++++++++++++++++ .../zetacored/zetacored_snapshots_delete.md | 27 ++++++++++++++++ .../cli/zetacored/zetacored_snapshots_dump.md | 28 +++++++++++++++++ .../zetacored/zetacored_snapshots_export.md | 28 +++++++++++++++++ .../cli/zetacored/zetacored_snapshots_list.md | 27 ++++++++++++++++ .../cli/zetacored/zetacored_snapshots_load.md | 27 ++++++++++++++++ .../zetacored/zetacored_snapshots_restore.md | 31 +++++++++++++++++++ 10 files changed, 206 insertions(+), 3 deletions(-) create mode 100644 docs/cli/zetacored/zetacored_snapshots.md create mode 100644 docs/cli/zetacored/zetacored_snapshots_delete.md create mode 100644 docs/cli/zetacored/zetacored_snapshots_dump.md create mode 100644 docs/cli/zetacored/zetacored_snapshots_export.md create mode 100644 docs/cli/zetacored/zetacored_snapshots_list.md create mode 100644 docs/cli/zetacored/zetacored_snapshots_load.md create mode 100644 docs/cli/zetacored/zetacored_snapshots_restore.md diff --git a/changelog.md b/changelog.md index d83253c00b..a1706d308e 100644 --- a/changelog.md +++ b/changelog.md @@ -10,6 +10,7 @@ ### Features * [1395](https://github.com/zeta-chain/node/pull/1395) - Add state variable to track aborted zeta amount * [1387](https://github.com/zeta-chain/node/pull/1387) - Add HSM capability for zetaclient hot key +* [1410](https://github.com/zeta-chain/node/pull/1410) - `snapshots` commands * enable zetaclients to use dynamic gas price on zetachain - enables >0 min_gas_price in feemarket module * add static chain data for Sepolia testnet * added metrics to track the burn rate of the hotkey in the telemetry server as well as prometheus diff --git a/cmd/zetacored/root.go b/cmd/zetacored/root.go index 6abf556bc6..9f1835c9bb 100644 --- a/cmd/zetacored/root.go +++ b/cmd/zetacored/root.go @@ -7,6 +7,8 @@ import ( "os" "path/filepath" + "github.com/cosmos/cosmos-sdk/client/snapshot" + appparams "github.com/cosmos/cosmos-sdk/simapp/params" snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" "github.com/evmos/ethermint/crypto/hd" @@ -119,6 +121,10 @@ func initTmConfig() *tmcfg.Config { } func initRootCmd(rootCmd *cobra.Command, encodingConfig appparams.EncodingConfig) { + ac := appCreator{ + encCfg: encodingConfig, + } + rootCmd.AddCommand( ethermintclient.ValidateChainID( genutilcli.InitCmd(app.ModuleBasics, app.DefaultNodeHome), @@ -136,11 +142,9 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig appparams.EncodingConfig debug.Cmd(), config.Cmd(), + snapshot.Cmd(ac.newApp), ) - ac := appCreator{ - encCfg: encodingConfig, - } zevmserver.AddCommands(rootCmd, zevmserver.NewDefaultStartOptions(ac.newApp, app.DefaultNodeHome), ac.appExport, addModuleInitFlags) // the ethermintserver one supercedes the sdk one diff --git a/docs/cli/zetacored/zetacored.md b/docs/cli/zetacored/zetacored.md index 72e3c72a76..4b5f360d55 100644 --- a/docs/cli/zetacored/zetacored.md +++ b/docs/cli/zetacored/zetacored.md @@ -32,6 +32,7 @@ Zetacore Daemon (server) * [zetacored query](zetacored_query.md) - Querying subcommands * [zetacored rollback](zetacored_rollback.md) - rollback cosmos-sdk and tendermint state by one height * [zetacored rosetta](zetacored_rosetta.md) - spin up a rosetta server +* [zetacored snapshots](zetacored_snapshots.md) - Manage local snapshots * [zetacored start](zetacored_start.md) - Run the full node * [zetacored status](zetacored_status.md) - Query remote node for status * [zetacored tendermint](zetacored_tendermint.md) - Tendermint subcommands diff --git a/docs/cli/zetacored/zetacored_snapshots.md b/docs/cli/zetacored/zetacored_snapshots.md new file mode 100644 index 0000000000..e75ca720d8 --- /dev/null +++ b/docs/cli/zetacored/zetacored_snapshots.md @@ -0,0 +1,29 @@ +# snapshots + +Manage local snapshots + +### Options + +``` + -h, --help help for snapshots +``` + +### Options inherited from parent commands + +``` + --home string directory for config and data + --log_format string The logging format (json|plain) + --log_level string The logging level (trace|debug|info|warn|error|fatal|panic) + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored](zetacored.md) - Zetacore Daemon (server) +* [zetacored snapshots delete](zetacored_snapshots_delete.md) - Delete a local snapshot +* [zetacored snapshots dump](zetacored_snapshots_dump.md) - Dump the snapshot as portable archive format +* [zetacored snapshots export](zetacored_snapshots_export.md) - Export app state to snapshot store +* [zetacored snapshots list](zetacored_snapshots_list.md) - List local snapshots +* [zetacored snapshots load](zetacored_snapshots_load.md) - Load a snapshot archive file (.tar.gz) into snapshot store +* [zetacored snapshots restore](zetacored_snapshots_restore.md) - Restore app state from local snapshot + diff --git a/docs/cli/zetacored/zetacored_snapshots_delete.md b/docs/cli/zetacored/zetacored_snapshots_delete.md new file mode 100644 index 0000000000..1fdd8cc105 --- /dev/null +++ b/docs/cli/zetacored/zetacored_snapshots_delete.md @@ -0,0 +1,27 @@ +# snapshots delete + +Delete a local snapshot + +``` +zetacored snapshots delete [height] [format] [flags] +``` + +### Options + +``` + -h, --help help for delete +``` + +### Options inherited from parent commands + +``` + --home string directory for config and data + --log_format string The logging format (json|plain) + --log_level string The logging level (trace|debug|info|warn|error|fatal|panic) + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored snapshots](zetacored_snapshots.md) - Manage local snapshots + diff --git a/docs/cli/zetacored/zetacored_snapshots_dump.md b/docs/cli/zetacored/zetacored_snapshots_dump.md new file mode 100644 index 0000000000..8cca605a1d --- /dev/null +++ b/docs/cli/zetacored/zetacored_snapshots_dump.md @@ -0,0 +1,28 @@ +# snapshots dump + +Dump the snapshot as portable archive format + +``` +zetacored snapshots dump [height] [format] [flags] +``` + +### Options + +``` + -h, --help help for dump + -o, --output string output file +``` + +### Options inherited from parent commands + +``` + --home string directory for config and data + --log_format string The logging format (json|plain) + --log_level string The logging level (trace|debug|info|warn|error|fatal|panic) + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored snapshots](zetacored_snapshots.md) - Manage local snapshots + diff --git a/docs/cli/zetacored/zetacored_snapshots_export.md b/docs/cli/zetacored/zetacored_snapshots_export.md new file mode 100644 index 0000000000..e331f1c90f --- /dev/null +++ b/docs/cli/zetacored/zetacored_snapshots_export.md @@ -0,0 +1,28 @@ +# snapshots export + +Export app state to snapshot store + +``` +zetacored snapshots export [flags] +``` + +### Options + +``` + --height int Height to export, default to latest state height + -h, --help help for export +``` + +### Options inherited from parent commands + +``` + --home string directory for config and data + --log_format string The logging format (json|plain) + --log_level string The logging level (trace|debug|info|warn|error|fatal|panic) + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored snapshots](zetacored_snapshots.md) - Manage local snapshots + diff --git a/docs/cli/zetacored/zetacored_snapshots_list.md b/docs/cli/zetacored/zetacored_snapshots_list.md new file mode 100644 index 0000000000..dceabbe0a8 --- /dev/null +++ b/docs/cli/zetacored/zetacored_snapshots_list.md @@ -0,0 +1,27 @@ +# snapshots list + +List local snapshots + +``` +zetacored snapshots list [flags] +``` + +### Options + +``` + -h, --help help for list +``` + +### Options inherited from parent commands + +``` + --home string directory for config and data + --log_format string The logging format (json|plain) + --log_level string The logging level (trace|debug|info|warn|error|fatal|panic) + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored snapshots](zetacored_snapshots.md) - Manage local snapshots + diff --git a/docs/cli/zetacored/zetacored_snapshots_load.md b/docs/cli/zetacored/zetacored_snapshots_load.md new file mode 100644 index 0000000000..c1dd66e5c7 --- /dev/null +++ b/docs/cli/zetacored/zetacored_snapshots_load.md @@ -0,0 +1,27 @@ +# snapshots load + +Load a snapshot archive file (.tar.gz) into snapshot store + +``` +zetacored snapshots load [archive-file] [flags] +``` + +### Options + +``` + -h, --help help for load +``` + +### Options inherited from parent commands + +``` + --home string directory for config and data + --log_format string The logging format (json|plain) + --log_level string The logging level (trace|debug|info|warn|error|fatal|panic) + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored snapshots](zetacored_snapshots.md) - Manage local snapshots + diff --git a/docs/cli/zetacored/zetacored_snapshots_restore.md b/docs/cli/zetacored/zetacored_snapshots_restore.md new file mode 100644 index 0000000000..03502fe8e6 --- /dev/null +++ b/docs/cli/zetacored/zetacored_snapshots_restore.md @@ -0,0 +1,31 @@ +# snapshots restore + +Restore app state from local snapshot + +### Synopsis + +Restore app state from local snapshot + +``` +zetacored snapshots restore [height] [format] [flags] +``` + +### Options + +``` + -h, --help help for restore +``` + +### Options inherited from parent commands + +``` + --home string directory for config and data + --log_format string The logging format (json|plain) + --log_level string The logging level (trace|debug|info|warn|error|fatal|panic) + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored snapshots](zetacored_snapshots.md) - Manage local snapshots +