diff --git a/baseapp/abci.go b/baseapp/abci.go index 8c67eddcda7f..9cc4ffed1aef 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -125,7 +125,15 @@ func (app *BaseApp) SetOption(req abci.RequestSetOption) (res abci.ResponseSetOp // Info implements the ABCI interface. func (app *BaseApp) Info(req abci.RequestInfo) abci.ResponseInfo { lastCommitID := app.cms.LastCommitID() - + // load the app version for a non zero height + if lastCommitID.Version > 0 { + ctx, err := app.createQueryContext(lastCommitID.Version, false) + if err != nil { + panic(err) + } + // get and set the app version + _ = app.AppVersion(ctx) + } return abci.ResponseInfo{ Data: app.name, Version: app.version, diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index eefb34331a6d..743caf27fa5a 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -203,7 +203,14 @@ func (app *BaseApp) Name() string { } // AppVersion returns the application's protocol version. -func (app *BaseApp) AppVersion() uint64 { +func (app *BaseApp) AppVersion(ctx sdk.Context) uint64 { + if app.appVersion == 0 && app.paramStore.Has(ctx, ParamStoreKeyVersionParams) { + var vp tmproto.VersionParams + + app.paramStore.Get(ctx, ParamStoreKeyVersionParams, &vp) + // set the app version + app.appVersion = vp.AppVersion + } return app.appVersion } diff --git a/baseapp/baseapp_test.go b/baseapp/baseapp_test.go index 99e4541b5ea3..2a1ae556bcce 100644 --- a/baseapp/baseapp_test.go +++ b/baseapp/baseapp_test.go @@ -460,7 +460,7 @@ func TestInfo(t *testing.T) { assert.Equal(t, t.Name(), res.GetData()) assert.Equal(t, int64(0), res.LastBlockHeight) require.Equal(t, []uint8(nil), res.LastBlockAppHash) - require.Equal(t, app.AppVersion(), res.AppVersion) + require.EqualValues(t, 0, res.AppVersion) // ----- test a proper response ------- // TODO }