From a3259bb5d10805362149a2a15921514ef420930f Mon Sep 17 00:00:00 2001 From: VictorTrustyDev Date: Mon, 1 Jan 2024 00:41:55 +0700 Subject: [PATCH 1/2] add snapshot command --- cmd/evmd/root.go | 36 ++++++++++++++++++++++++++++++++++++ server/util.go | 1 + 2 files changed, 37 insertions(+) diff --git a/cmd/evmd/root.go b/cmd/evmd/root.go index c93baa488e..4c0661c684 100644 --- a/cmd/evmd/root.go +++ b/cmd/evmd/root.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "github.com/EscanBE/evermint/v12/constants" + "github.com/cosmos/cosmos-sdk/client/snapshot" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" "github.com/spf13/viper" "io" @@ -124,6 +125,41 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) { config.Cmd(), pruning.PruningCmd(a.newApp), NewConvertAddressCmd(), + func() *cobra.Command { + snapshotCmd := snapshot.Cmd(a.newApp) + snapshotCmd.Long = fmt.Sprintf(` +How to use "%s snapshot" command: + +In this context, we gonna to export snapshot for height 100000 + +1. Create state-sync snapshot on a running node with "export" +> sudo systemctl stop %s +> %s snapshots export --height 100000 +You gonna get state-sync snapshot at "%s/snapshots/" dir as usual: +> Log: Snapshot created at height 100000, format 3, chunks 10 + +2. Pack snapshot with "dump": +> %s snapshots dump 100000 3 +You gonna get "100000-3.tar.gz" at current working directory + +3. Share to another node or reset data of current node with "unsafe-reset-all" + +4. Unsafe-reset the node and unpack snapshot with "load": +> %s snapshots load 100000-3.tar.gz + +5. Then restore app state with "restore": +> %s snapshots restore 100000 3 +You gonna get "data/application.db" unpacked + +6. Now bootstrap state with "bootstrap-state": +%s tendermint bootstrap-state +`, + constants.ApplicationBinaryName, constants.ApplicationBinaryName, constants.ApplicationBinaryName, + constants.ApplicationHome, + constants.ApplicationBinaryName, constants.ApplicationBinaryName, constants.ApplicationBinaryName, constants.ApplicationBinaryName, + ) + return snapshotCmd + }(), } // End of command rename chain diff --git a/server/util.go b/server/util.go index e03428ddbd..f16092410b 100644 --- a/server/util.go +++ b/server/util.go @@ -40,6 +40,7 @@ func AddCommands( sdkserver.VersionCmd(), tmcmd.ResetAllCmd, tmcmd.ResetStateCmd, + sdkserver.BootstrapStateCmd(opts.AppCreator), ) startCmd := StartCmd(opts) From 769089f0f3da060694e23169b8def8203833ef59 Mon Sep 17 00:00:00 2001 From: VictorTrustyDev Date: Mon, 1 Jan 2024 00:42:01 +0700 Subject: [PATCH 2/2] update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 259534381f..7189e3c91e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ **From this version, CometBFT is officially used as the consensus engine.** +### Features + +- (store) [#12](https://github.com/EscanBE/evermint/pull/12) Add local `snapshots` management commands + ### Improvement - (test) [#10](https://github.com/EscanBE/evermint/pull/10) Use Testnet chain-id instead of Mainnet chain-id for tests