Skip to content

Commit

Permalink
fix export app-version
Browse files Browse the repository at this point in the history
ParamStoreKeyVersionParams key was never set in paramStore. This forces storage of app-version
  • Loading branch information
najeal committed Jul 2, 2024
1 parent 7ee7290 commit d3b3c42
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
10 changes: 0 additions & 10 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -771,13 +771,3 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino

return paramsKeeper
}

func (app *App) InitializeAppVersion(ctx sdk.Context) {
appVersion := app.GetAppVersionFromParamStore(ctx)
if appVersion == 0 {
// if the param store does not have an app version set, default to v1
app.SetAppVersion(ctx, v1)
} else {
app.SetAppVersion(ctx, appVersion)
}
}
8 changes: 7 additions & 1 deletion app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ func (app *App) ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAddrs
return servertypes.ExportedApp{}, err
}

app.InitializeAppVersion(ctx)
versionToInit := v1
if app.LastBlockHeight() >= app.upgradeHeightV2 {
versionToInit = v2
}
app.SetInitialAppVersionInConsensusParams(ctx, versionToInit)
app.SetAppVersion(ctx, versionToInit)

if !app.IsSealed() {
app.mountKeysAndInit(app.AppVersion())
}
Expand Down
2 changes: 1 addition & 1 deletion app/test/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestExportAppStateAndValidators(t *testing.T) {
require.NoError(t, err)
assert.NotNil(t, exported)
// TODO: the following assertion is commented out because the exported app does not populate consensus params.version
// assert.Equal(t, uint64(2), exported.ConsensusParams.Version.AppVersion)
assert.Equal(t, uint64(2), exported.ConsensusParams.Version.AppVersion)
})
}

Expand Down

0 comments on commit d3b3c42

Please sign in to comment.