Skip to content

Commit

Permalink
fix(app): register wasm snapshot extension for state-sync (#2114)
Browse files Browse the repository at this point in the history
* fix(app): register wasm snapshot extension for state-sync

* feature gate extension registration

* move to a separate function

* rename method
  • Loading branch information
milapsheth authored Feb 28, 2024
1 parent a30eae9 commit 6f90d60
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ func NewAxelarApp(

app.SetAnteHandler(initAnteHandlers(encodingConfig, keys, keepers, appOpts))

// Register wasm snapshot extension for state-sync compatibility
// MUST be done before loading the version
app.registerWasmSnapshotExtension(keepers)

if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
tmos.Exit(err.Error())
Expand Down Expand Up @@ -453,6 +457,22 @@ func initMessageRouter(keepers *KeeperCache) nexusTypes.MessageRouter {
return messageRouter
}

func (app *AxelarApp) registerWasmSnapshotExtension(keepers *KeeperCache) {
// Register wasm snapshot extension to enable state-sync compatibility for wasm.
// MUST be done before loading the version
// Requires the snapshot store to be created and registered as a BaseAppOption
if IsWasmEnabled() {
if manager := app.SnapshotManager(); manager != nil {
err := manager.RegisterExtensions(
wasmkeeper.NewWasmSnapshotter(app.CommitMultiStore(), getKeeper[wasm.Keeper](keepers)),
)
if err != nil {
panic(fmt.Errorf("failed to register snapshot extension: %s", err))
}
}
}
}

func (app *AxelarApp) setUpgradeBehaviour(configurator module.Configurator, keepers *KeeperCache) {
app.upgradeKeeper.SetUpgradeHandler(
upgradeName(app.Version()),
Expand Down

0 comments on commit 6f90d60

Please sign in to comment.