Send Consensus Params during EndBlock (#7107)

* add cp to endblock

* fix build

* add test: TestBaseApp_EndBlock

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
Alexander Bezobchuk 2020-08-20 07:28:40 -04:00 committed by GitHub
parent 16435a0f4d
commit 049731bb3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 1 deletions

View File

@ -163,7 +163,11 @@ func (app *BaseApp) EndBlock(req abci.RequestEndBlock) (res abci.ResponseEndBloc
res = app.endBlocker(app.deliverState.ctx, req)
}
return
if cp := app.GetConsensusParams(app.deliverState.ctx); cp != nil {
res.ConsensusParamUpdates = cp
}
return res
}
// CheckTx implements the ABCI interface and executes a tx in CheckTx mode. In

View File

@ -1678,3 +1678,35 @@ func TestWithRouter(t *testing.T) {
app.Commit()
}
}
func TestBaseApp_EndBlock(t *testing.T) {
db := dbm.NewMemDB()
name := t.Name()
logger := defaultLogger()
cp := &abci.ConsensusParams{
Block: &abci.BlockParams{
MaxGas: 5000000,
},
}
app := NewBaseApp(name, logger, db, nil)
app.SetParamStore(&paramStore{db: dbm.NewMemDB()})
app.InitChain(abci.RequestInitChain{
ConsensusParams: cp,
})
app.SetEndBlocker(func(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
return abci.ResponseEndBlock{
ValidatorUpdates: []abci.ValidatorUpdate{
{Power: 100},
},
}
})
app.Seal()
res := app.EndBlock(abci.RequestEndBlock{})
require.Len(t, res.GetValidatorUpdates(), 1)
require.Equal(t, int64(100), res.GetValidatorUpdates()[0].Power)
require.Equal(t, cp.Block.MaxGas, res.ConsensusParamUpdates.Block.MaxGas)
}