refactor(x/consensus): audit QA (#21151)

This commit is contained in:
Facundo Medica 2024-08-09 17:20:42 +02:00 committed by GitHub
parent bc698d8bb2
commit a9a687c7da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 48 additions and 67 deletions

View File

@ -57,7 +57,6 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
* (baseapp) [#18499](https://github.com/cosmos/cosmos-sdk/pull/18499) Add `MsgRouter` response type from message name function.
* (types) [#18768](https://github.com/cosmos/cosmos-sdk/pull/18768) Add MustValAddressFromBech32 function.
* (gRPC) [#19049](https://github.com/cosmos/cosmos-sdk/pull/19049) Add debug log prints for each gRPC request.
* (x/consensus) [#19483](https://github.com/cosmos/cosmos-sdk/pull/19483) Add consensus messages registration to consensus module.
* (types) [#19759](https://github.com/cosmos/cosmos-sdk/pull/19759) Align SignerExtractionAdapter in PriorityNonceMempool Remove.
* (client) [#19870](https://github.com/cosmos/cosmos-sdk/pull/19870) Add new query command `wait-tx`. Alias `event-query-tx-for` to `wait-tx` for backward compatibility.
* (crypto/keyring) [#20212](https://github.com/cosmos/cosmos-sdk/pull/20212) Expose the db keyring used in the keystore.
@ -144,7 +143,6 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
* The module manager now can do everything that the basic manager was doing.
* When using runtime, just inject the module manager when needed using your app config.
* All `AppModuleBasic` structs have been removed.
* (x/consensus) [#19488](https://github.com/cosmos/cosmos-sdk/pull/19488) Consensus module creation takes `appmodule.Environment` instead of individual services.
* (server) [#18303](https://github.com/cosmos/cosmos-sdk/pull/18303) `x/genutil` now handles the application export. `server.AddCommands` does not take an `AppExporter` but instead `genutilcli.Commands` does.
* (x/gov/testutil) [#17986](https://github.com/cosmos/cosmos-sdk/pull/18036) `MsgDeposit` has been removed because of AutoCLI migration.
* (x/staking/testutil) [#17986](https://github.com/cosmos/cosmos-sdk/pull/17986) `MsgRedelegateExec`, `MsgUnbondExec` has been removed because of AutoCLI migration.
@ -174,7 +172,6 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
* (x/staking) [#18257](https://github.com/cosmos/cosmos-sdk/pull/18257) Staking module was moved to its own go.mod `cosmossdk.io/x/staking`
* (x/authz) [#18265](https://github.com/cosmos/cosmos-sdk/pull/18265) Authz module was moved to its own go.mod `cosmossdk.io/x/authz`
* (x/mint) [#18283](https://github.com/cosmos/cosmos-sdk/pull/18283) Mint module was moved to its own go.mod `cosmossdk.io/x/mint`
* (x/consensus) [#18041](https://github.com/cosmos/cosmos-sdk/pull/18041) `ToProtoConsensusParams()` returns an error
* (x/slashing) [#18115](https://github.com/cosmos/cosmos-sdk/pull/18115) `NewValidatorSigningInfo` takes strings instead of `sdk.AccAddress`
* (types) [#18268](https://github.com/cosmos/cosmos-sdk/pull/18268) Remove global setting of basedenom. Use the staking module parameter instead
* (x/auth) [#18351](https://github.com/cosmos/cosmos-sdk/pull/18351) Auth module was moved to its own go.mod `cosmossdk.io/x/auth`

View File

@ -1298,8 +1298,6 @@ type MsgUpdateParams struct {
Block *v1.BlockParams `protobuf:"bytes,2,opt,name=block,proto3" json:"block,omitempty"`
Evidence *v1.EvidenceParams `protobuf:"bytes,3,opt,name=evidence,proto3" json:"evidence,omitempty"`
Validator *v1.ValidatorParams `protobuf:"bytes,4,opt,name=validator,proto3" json:"validator,omitempty"`
// Since: cosmos-sdk 0.51
//
// Deprecated: Do not use.
Abci *v1.ABCIParams `protobuf:"bytes,5,opt,name=abci,proto3" json:"abci,omitempty"`
Synchrony *v1.SynchronyParams `protobuf:"bytes,6,opt,name=synchrony,proto3" json:"synchrony,omitempty"`
@ -1444,7 +1442,7 @@ var file_cosmos_consensus_v1_tx_proto_rawDesc = []byte{
0x62, 0x66, 0x74, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x79, 0x6e,
0x63, 0x68, 0x72, 0x6f, 0x6e, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0x13, 0xda, 0xb4,
0x2d, 0x0f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x20, 0x30, 0x2e, 0x35,
0x31, 0x52, 0x09, 0x73, 0x79, 0x6e, 0x63, 0x68, 0x72, 0x6f, 0x6e, 0x79, 0x12, 0x4f, 0x0a, 0x07,
0x32, 0x52, 0x09, 0x73, 0x79, 0x6e, 0x63, 0x68, 0x72, 0x6f, 0x6e, 0x79, 0x12, 0x4f, 0x0a, 0x07,
0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e,
0x63, 0x6f, 0x6d, 0x65, 0x74, 0x62, 0x66, 0x74, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x76,
0x31, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42,

View File

@ -31,4 +31,13 @@ Ref: https://keepachangelog.com/en/1.0.0/
## [Unreleased]
### Features
* (x/consensus) [#19483](https://github.com/cosmos/cosmos-sdk/pull/19483) Add consensus messages registration to consensus module.
* [#20615](https://github.com/cosmos/cosmos-sdk/pull/20615) Add consensus messages to add cometinfo to consensus modules
### API Breaking Changes
* (x/consensus) [#19488](https://github.com/cosmos/cosmos-sdk/pull/19488) Consensus module creation takes `appmodule.Environment` instead of individual services.
* (x/consensus) [#18041](https://github.com/cosmos/cosmos-sdk/pull/18041) `ToProtoConsensusParams()` returns an error

View File

@ -19,8 +19,6 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
)
var StoreKey = "Consensus"
type Keeper struct {
appmodule.Environment

View File

@ -38,7 +38,7 @@ func getDuration(d time.Duration) *time.Duration {
}
func (s *KeeperTestSuite) SetupTest(enabledFeatures bool) {
key := storetypes.NewKVStoreKey(consensusparamkeeper.StoreKey)
key := storetypes.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test"))
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 5})
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{})

View File

@ -38,9 +38,9 @@ message MsgUpdateParams {
cometbft.types.v1.EvidenceParams evidence = 3;
cometbft.types.v1.ValidatorParams validator = 4;
// Since: cosmos-sdk 0.51
cometbft.types.v1.ABCIParams abci = 5 [deprecated = true, (cosmos_proto.field_added_in) = "cosmos-sdk 0.50"];
cometbft.types.v1.SynchronyParams synchrony = 6 [(cosmos_proto.field_added_in) = "cosmos-sdk 0.51"];
cometbft.types.v1.ABCIParams abci = 5 [deprecated = true, (cosmos_proto.field_added_in) = "cosmos-sdk 0.50"];
cometbft.types.v1.SynchronyParams synchrony = 6 [(cosmos_proto.field_added_in) = "cosmos-sdk 0.52"];
cometbft.types.v1.FeatureParams feature = 7 [(cosmos_proto.field_added_in) = "cosmos-sdk 0.52"];
}

View File

@ -31,39 +31,19 @@ func (msg MsgUpdateParams) ToProtoConsensusParams() (cmtproto.ConsensusParams, e
PubKeyTypes: msg.Validator.PubKeyTypes,
},
Version: cmttypes.DefaultConsensusParams().ToProto().Version, // Version is stored in x/upgrade
Feature: &cmtproto.FeatureParams{},
Synchrony: &cmtproto.SynchronyParams{},
Feature: msg.Feature,
Synchrony: msg.Synchrony,
}
if msg.Abci != nil {
if cp.Feature == nil {
cp.Feature = &cmtproto.FeatureParams{}
}
cp.Feature.VoteExtensionsEnableHeight = &types.Int64Value{
Value: msg.Abci.VoteExtensionsEnableHeight,
}
}
if msg.Feature != nil {
if msg.Feature.VoteExtensionsEnableHeight != nil {
cp.Feature.VoteExtensionsEnableHeight = &types.Int64Value{
Value: msg.Feature.GetVoteExtensionsEnableHeight().GetValue(),
}
}
if msg.Feature.PbtsEnableHeight != nil {
cp.Feature.PbtsEnableHeight = &types.Int64Value{
Value: msg.Feature.GetPbtsEnableHeight().GetValue(),
}
}
}
if msg.Synchrony != nil {
if msg.Synchrony.MessageDelay != nil {
delay := *msg.Synchrony.MessageDelay
cp.Synchrony.MessageDelay = &delay
}
if msg.Synchrony.Precision != nil {
precision := *msg.Synchrony.Precision
cp.Synchrony.Precision = &precision
}
}
return cp, nil
}

View File

@ -44,7 +44,6 @@ type MsgUpdateParams struct {
Block *v1.BlockParams `protobuf:"bytes,2,opt,name=block,proto3" json:"block,omitempty"`
Evidence *v1.EvidenceParams `protobuf:"bytes,3,opt,name=evidence,proto3" json:"evidence,omitempty"`
Validator *v1.ValidatorParams `protobuf:"bytes,4,opt,name=validator,proto3" json:"validator,omitempty"`
// Since: cosmos-sdk 0.51
Abci *v1.ABCIParams `protobuf:"bytes,5,opt,name=abci,proto3" json:"abci,omitempty"` // Deprecated: Do not use.
Synchrony *v1.SynchronyParams `protobuf:"bytes,6,opt,name=synchrony,proto3" json:"synchrony,omitempty"`
Feature *v1.FeatureParams `protobuf:"bytes,7,opt,name=feature,proto3" json:"feature,omitempty"`
@ -179,39 +178,39 @@ func init() {
func init() { proto.RegisterFile("cosmos/consensus/v1/tx.proto", fileDescriptor_2135c60575ab504d) }
var fileDescriptor_2135c60575ab504d = []byte{
// 507 bytes of a gzipped FileDescriptorProto
// 506 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x4f, 0x6b, 0x13, 0x41,
0x18, 0xc6, 0xb3, 0x36, 0x69, 0xcd, 0x28, 0x14, 0x27, 0x4a, 0xa7, 0xa1, 0x0e, 0x31, 0x88, 0x94,
0x60, 0x66, 0x9b, 0x58, 0xff, 0x82, 0x60, 0x23, 0x8a, 0x1e, 0x8a, 0xb2, 0xa5, 0x1e, 0xbc, 0xc8,
0x64, 0x77, 0xba, 0x5d, 0xd2, 0xdd, 0x59, 0x76, 0x26, 0x6b, 0x73, 0x13, 0xc1, 0x8b, 0x27, 0xbf,
0x88, 0x90, 0x43, 0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0x45, 0x66, 0x29, 0x0f, 0xee, 0xbf,
0x9f, 0x8d, 0x5b, 0xf9, 0x8b, 0xfb, 0x38, 0x1b, 0xb7, 0x6e, 0xe4, 0x66, 0xf3, 0xf8, 0xb7, 0x2d,
0x5e, 0xd8, 0x8d, 0xe6, 0x3a, 0x58, 0x5b, 0x78, 0x64, 0x31, 0x11, 0x26, 0xf6, 0xee, 0x07, 0x03,
0x2c, 0xed, 0x0a, 0x17, 0xbe, 0x05, 0x17, 0xcf, 0xac, 0xd3, 0x75, 0x52, 0xb0, 0xfd, 0x64, 0x21,
0xa5, 0x7e, 0xf3, 0x7f, 0x5c, 0x59, 0x57, 0xb3, 0xf6, 0x75, 0xf1, 0x7e, 0xdb, 0x77, 0xeb, 0x95,
0x77, 0xb3, 0x71, 0xcb, 0xe8, 0xdd, 0xfb, 0x32, 0xc1, 0xc6, 0xe9, 0x04, 0x1b, 0x3f, 0x27, 0xd8,
0xf8, 0x34, 0xc5, 0xa5, 0xd3, 0x29, 0x2e, 0x7d, 0x9f, 0xe2, 0xd2, 0x6b, 0xac, 0x09, 0xe1, 0x0c,
0x88, 0xc7, 0xcf, 0x5c, 0x53, 0x8d, 0xb1, 0xbf, 0xac, 0xbe, 0x89, 0x5b, 0xbf, 0x02, 0x00, 0x00,
0xff, 0xff, 0x84, 0xf1, 0x97, 0xc0, 0xcd, 0x03, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.