Skip to content

Commit

Permalink
fix(x/consensus): Add missing ABCI consensus param in MsgUpdateParams…
Browse files Browse the repository at this point in the history
… (backport #16713) (#16745)

Co-authored-by: Facundo Medica <14063057+facundomedica@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
  • Loading branch information
3 people committed Jun 28, 2023
1 parent 9b2eb52 commit 730a352
Show file tree
Hide file tree
Showing 6 changed files with 265 additions and 61 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Bug Fixes

* (x/consensus) [#16713](https://github.com/cosmos/cosmos-sdk/pull/16713) Add missing ABCI param in MsgUpdateParams.
* [#16547](https://github.com/cosmos/cosmos-sdk/pull/16547) Ensure a transaction's gas limit cannot exceed the block gas limit.
* (x/auth) [#16554](https://github.com/cosmos/cosmos-sdk/pull/16554) `ModuleAccount.Validate` now reports a nil `.BaseAccount` instead of panicking.
* (baseapp) [#16613](https://github.com/cosmos/cosmos-sdk/pull/16613) Ensure each message in a transaction has a registered handler, otherwise `CheckTx` will fail.
Expand Down
161 changes: 127 additions & 34 deletions api/cosmos/consensus/v1/tx.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions proto/cosmos/consensus/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ message MsgUpdateParams {
tendermint.types.BlockParams block = 2;
tendermint.types.EvidenceParams evidence = 3;
tendermint.types.ValidatorParams validator = 4;

// Since: cosmos-sdk 0.50
tendermint.types.ABCIParams abci = 5;
}

// MsgUpdateParamsResponse defines the response structure for executing a
Expand Down
36 changes: 36 additions & 0 deletions x/consensus/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,34 @@ func (s *KeeperTestSuite) TestGRPCQueryConsensusParams() {
},
true,
},
{
"success with abci",
types.QueryParamsRequest{},
func() {
input := &types.MsgUpdateParams{
Authority: s.consensusParamsKeeper.GetAuthority(),
Block: defaultConsensusParams.Block,
Validator: defaultConsensusParams.Validator,
Evidence: defaultConsensusParams.Evidence,
Abci: &cmtproto.ABCIParams{
VoteExtensionsEnableHeight: 1234,
},
}
s.consensusParamsKeeper.UpdateParams(s.ctx, input)
},
types.QueryParamsResponse{
Params: &cmtproto.ConsensusParams{
Block: defaultConsensusParams.Block,
Validator: defaultConsensusParams.Validator,
Evidence: defaultConsensusParams.Evidence,
Version: defaultConsensusParams.Version,
Abci: &cmtproto.ABCIParams{
VoteExtensionsEnableHeight: 1234,
},
},
},
true,
},
}

for _, tc := range testCases {
Expand Down Expand Up @@ -155,6 +183,14 @@ func (s *KeeperTestSuite) TestUpdateParams() {
s.Require().Contains(err.Error(), tc.expErrMsg)
} else {
s.Require().NoError(err)

res, err := s.consensusParamsKeeper.Params(s.ctx, &types.QueryParamsRequest{})
s.Require().NoError(err)

s.Require().Equal(tc.input.Abci, res.Params.Abci)
s.Require().Equal(tc.input.Block, res.Params.Block)
s.Require().Equal(tc.input.Evidence, res.Params.Evidence)
s.Require().Equal(tc.input.Validator, res.Params.Validator)
}
})
}
Expand Down
10 changes: 9 additions & 1 deletion x/consensus/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
var _ sdk.Msg = &MsgUpdateParams{}

func (msg MsgUpdateParams) ToProtoConsensusParams() cmtproto.ConsensusParams {
return cmtproto.ConsensusParams{
cp := cmtproto.ConsensusParams{
Block: &cmtproto.BlockParams{
MaxBytes: msg.Block.MaxBytes,
MaxGas: msg.Block.MaxGas,
Expand All @@ -25,4 +25,12 @@ func (msg MsgUpdateParams) ToProtoConsensusParams() cmtproto.ConsensusParams {
},
Version: cmttypes.DefaultConsensusParams().ToProto().Version, // Version is stored in x/upgrade
}

if msg.Abci != nil {
cp.Abci = &cmtproto.ABCIParams{
VoteExtensionsEnableHeight: msg.Abci.VoteExtensionsEnableHeight,
}
}

return cp
}
Loading

0 comments on commit 730a352

Please sign in to comment.