Skip to content

Commit

Permalink
fix: allow the application to set the initial app version in the cons…
Browse files Browse the repository at this point in the history
…ensus params (#377)
  • Loading branch information
cmwaters committed Mar 13, 2024
1 parent 8b5e30b commit 9034100
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,8 @@ func (app *BaseApp) GetConsensusParams(ctx sdk.Context) *abci.ConsensusParams {

app.paramStore.Get(ctx, ParamStoreKeyVersionParams, &vp)
cp.Version = &vp
} else if app.appVersion != 0 {
cp.Version = &tmproto.VersionParams{AppVersion: app.appVersion}
}

return cp
Expand All @@ -518,12 +520,19 @@ func (app *BaseApp) StoreConsensusParams(ctx sdk.Context, cp *abci.ConsensusPara
app.paramStore.Set(ctx, ParamStoreKeyBlockParams, cp.Block)
app.paramStore.Set(ctx, ParamStoreKeyEvidenceParams, cp.Evidence)
app.paramStore.Set(ctx, ParamStoreKeyValidatorParams, cp.Validator)
// NOTE: we only persist the app version from v2 onwards
if cp.Version != nil && cp.Version.AppVersion >= 2 {
if app.paramStore.Has(ctx, ParamStoreKeyVersionParams) {
app.paramStore.Set(ctx, ParamStoreKeyVersionParams, cp.Version)
}
}

// SetInitialAppVersionInConsensusParams sets the initial app version
// in the consensus params if it has not yet been set.
func (app *BaseApp) SetInitialAppVersionInConsensusParams(ctx sdk.Context, version uint64) {
if !app.paramStore.Has(ctx, ParamStoreKeyVersionParams) {
app.paramStore.Set(ctx, ParamStoreKeyVersionParams, &tmproto.VersionParams{AppVersion: version})
}
}

// getMaximumBlockGas gets the maximum gas from the consensus params. It panics
// if maximum block gas is less than negative one and returns zero if negative
// one.
Expand Down

0 comments on commit 9034100

Please sign in to comment.