From 15ad5095e613214299e00e162e3cc1cc34652bad Mon Sep 17 00:00:00 2001 From: VictorTrustyDev Date: Mon, 1 Jan 2024 00:47:18 +0700 Subject: [PATCH 1/3] add snapshot command --- cmd/evmd/root.go | 29 +++++++++++++++++++++++++++++ server/util.go | 1 + 2 files changed, 30 insertions(+) diff --git a/cmd/evmd/root.go b/cmd/evmd/root.go index 28ceaf7f7f..760a11789c 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" "io" "os" "path/filepath" @@ -121,6 +122,34 @@ 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 fb454a87a8..f4b6c26abc 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 9f000ad796fe8b4621eba874334738fee8b7467e Mon Sep 17 00:00:00 2001 From: VictorTrustyDev Date: Mon, 1 Jan 2024 00:47:50 +0700 Subject: [PATCH 2/3] update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee14011162..859bf52a62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ # Unreleased +### Features + +- (store) [#13](https://github.com/EscanBE/evermint/pull/13) Add local `snapshots` management commands (backport #12) + ### Improvement - (test) [#11](https://github.com/EscanBE/evermint/pull/11) Use Testnet chain-id instead of Mainnet chain-id for tests (backport #10) From 58af09878d8db4f395df9d0aafbe4ac560b43c22 Mon Sep 17 00:00:00 2001 From: VictorTrustyDev Date: Mon, 1 Jan 2024 00:53:11 +0700 Subject: [PATCH 3/3] adjust snapshot format --- cmd/evmd/root.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/evmd/root.go b/cmd/evmd/root.go index 760a11789c..427f2d90fb 100644 --- a/cmd/evmd/root.go +++ b/cmd/evmd/root.go @@ -131,15 +131,15 @@ In this context, we gonna to export snapshot for height 100000 > 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 +> Log: Snapshot created at height 100000, format 2, chunks 10 2. Pack snapshot with "dump": -> %s snapshots dump 100000 3 -You gonna get "100000-3.tar.gz" at current working directory +> %s snapshots dump 100000 2 +You gonna get "100000-2.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 +> %s snapshots load 100000-2.tar.gz 5. Then restore app state with "restore": -> %s snapshots restore 100000 3 +> %s snapshots restore 100000 2 You gonna get "data/application.db" unpacked 6. Now bootstrap state with "bootstrap-state": %s tendermint bootstrap-state