Skip to content

Commit

Permalink
Info queries the param store
Browse files Browse the repository at this point in the history
  • Loading branch information
cmwaters committed Nov 20, 2023
1 parent 0dae054 commit af6d671
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
10 changes: 9 additions & 1 deletion baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Check failure on line 136 in baseapp/abci.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofumpt`-ed (gofumpt)
return abci.ResponseInfo{
Data: app.name,
Version: app.version,
Expand Down
9 changes: 8 additions & 1 deletion baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit af6d671

Please sign in to comment.