Skip to content

Commit

Permalink
chore(consensus): Add grpc proto comments and cleanups (cosmos#14156)
Browse files Browse the repository at this point in the history
* chore(consensus): Add grpc proto comments

* refactor: x/consensus audit changes (cosmos#14110)

* refactor: x/consensus audit changes

Co-authored-by: Jeancarlo Barrios <[email protected]>
  • Loading branch information
amaury1093 and JeancarloBarrios authored Dec 6, 2022
1 parent a31c4ac commit a1dc6d9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
7 changes: 5 additions & 2 deletions proto/cosmos/consensus/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ service Query {
}
}

// QueryParamsRequest defines the request type for querying x/consensus_param parameters.
// QueryParamsRequest defines the request type for querying x/consensus parameters.
message QueryParamsRequest {}

// QueryParamsResponse defines the response type for querying x/consensus_param parameters.
// QueryParamsResponse defines the response type for querying x/consensus parameters.
message QueryParamsResponse {
// params are the tendermint consensus params stored in the consensus module.
// Please note that `params.version` is not populated in this response, it is
// tracked separately in the x/upgrade module.
tendermint.types.ConsensusParams params = 1;
}
2 changes: 1 addition & 1 deletion proto/cosmos/consensus/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ message MsgUpdateParams {
// authority is the address of the governance account.
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];

// params defines the x/consensus_params parameters to update.
// params defines the x/consensus parameters to update.
// VersionsParams is not included in this Msg because it is tracked
// separarately in x/upgrade.
//
Expand Down
4 changes: 2 additions & 2 deletions x/consensus/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ func NewQuerier(keeper Keeper) Querier {
return Querier{Keeper: keeper}
}

// Params Balance implements the Query/Balance gRPC method
func (k Querier) Params(ctx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
// Params queries params of consensus module
func (k Querier) Params(ctx context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
sdkCtx := sdk.UnwrapSDKContext(ctx)

params, err := k.Keeper.Get(sdkCtx)
Expand Down
14 changes: 7 additions & 7 deletions x/consensus/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule {
func (AppModule) Name() string { return types.ModuleName }

// InitGenesis is handled by for init genesis of consensus_param
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
func (am AppModule) InitGenesis(sdk.Context, codec.JSONCodec, json.RawMessage) []abci.ValidatorUpdate {
// nil is returned since initgenesis of consensus params is handled by tendermint
return nil
}

// ExportGenesis is handled by tendermint export of genesis
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
func (am AppModule) ExportGenesis(sdk.Context, codec.JSONCodec) json.RawMessage {
// nil is returned since ExportGenesis of consensus params is handled by tendermint and baseapp
return nil
}
Expand All @@ -128,7 +128,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }

// RegisterInvariants does nothing, there are no invariants to enforce
func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {}
func (am AppModule) RegisterInvariants(sdk.InvariantRegistry) {}

func init() {
appmodule.Register(
Expand All @@ -137,23 +137,23 @@ func init() {
)
}

type ConsensusParamInputs struct {
type ConsensusInputs struct {
depinject.In

Config *modulev1.Module
Cdc codec.Codec
Key *store.KVStoreKey
}

type ConsensusParamOutputs struct {
type ConsensusOutputs struct {
depinject.Out

Keeper keeper.Keeper
Module appmodule.AppModule
BaseAppOption runtime.BaseAppOption
}

func ProvideModule(in ConsensusParamInputs) ConsensusParamOutputs {
func ProvideModule(in ConsensusInputs) ConsensusOutputs {
// default to governance authority if not provided
authority := authtypes.NewModuleAddress(govtypes.ModuleName)
if in.Config.Authority != "" {
Expand All @@ -166,7 +166,7 @@ func ProvideModule(in ConsensusParamInputs) ConsensusParamOutputs {
app.SetParamStore(&k)
}

return ConsensusParamOutputs{
return ConsensusOutputs{
Keeper: k,
Module: m,
BaseAppOption: baseappOpt,
Expand Down
1 change: 0 additions & 1 deletion x/consensus/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
)

// bank message types
const (
TypeMsgUpdateParams = "update_params"
)
Expand Down

0 comments on commit a1dc6d9

Please sign in to comment.