Skip to content

Commit

Permalink
fix: add wasm state-sync snapshot extension (#184)
Browse files Browse the repository at this point in the history
* fix: enable wasm snapshot extension

* add snapshot and pruning cmds
  • Loading branch information
harish551 authored Aug 26, 2024
1 parent 5b9b739 commit 3d80d9d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
10 changes: 10 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,16 @@ func NewOmniFlixApp(
app.SetPrecommiter(app.PreCommitter)
app.SetPrepareCheckStater(app.PrepareCheckStater)

// Register snapshot extensions to enable state-sync for wasm.
if manager := app.SnapshotManager(); manager != nil {
err := manager.RegisterExtensions(
wasmkeeper.NewWasmSnapshotter(app.CommitMultiStore(), &app.WasmKeeper),
)
if err != nil {
panic(fmt.Errorf("failed to register snapshot extension: %s", err))
}
}

if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
tmos.Exit(fmt.Sprintf("failed to load latest version: %s", err))
Expand Down
11 changes: 7 additions & 4 deletions cmd/omniflixhubd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/client/pruning"
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/client/snapshot"
runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services"
"github.com/cosmos/cosmos-sdk/server"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
Expand Down Expand Up @@ -130,6 +132,9 @@ func initCometBftConfig() *tmcfg.Config {
}

func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, tempApp *app.OmniFlixApp) {
ac := appCreator{
encCfg: encodingConfig,
}
rootCmd.AddCommand(
genutilcli.InitCmd(tempApp.ModuleBasics, app.DefaultNodeHome),
tmcli.NewCompletionCmd(rootCmd, true),
Expand All @@ -150,12 +155,10 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, t
genutilcli.ValidateGenesisCmd(tempApp.ModuleBasics),
tmcli.NewCompletionCmd(rootCmd, true),
addDebugCommands(debug.Cmd()),
pruning.Cmd(ac.newApp, app.DefaultNodeHome),
snapshot.Cmd(ac.newApp),
)

ac := appCreator{
encCfg: encodingConfig,
}

server.AddCommands(rootCmd, app.DefaultNodeHome, ac.newApp, ac.appExport, addModuleInitFlags)

// add keybase, auxiliary RPC, query, and tx child commands
Expand Down

0 comments on commit 3d80d9d

Please sign in to comment.