From 7fdab2fb7d82d7f02b3e09f92f463c10622a25d5 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Wed, 24 Aug 2022 15:38:53 -0600 Subject: [PATCH 1/3] remove lint error for accountkeeper and bankkeeper cant be nil --- x/auth/ante/ante.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x/auth/ante/ante.go b/x/auth/ante/ante.go index a562e67ee39c..44a6184c18af 100644 --- a/x/auth/ante/ante.go +++ b/x/auth/ante/ante.go @@ -6,6 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/tx/signing" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" "github.com/cosmos/cosmos-sdk/x/auth/types" + "reflect" ) // HandlerOptions are the options required for constructing a default SDK AnteHandler. @@ -23,11 +24,11 @@ type HandlerOptions struct { // numbers, checks signatures & account numbers, and deducts fees from the first // signer. func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { - if options.AccountKeeper == nil { + if reflect.ValueOf(options.AccountKeeper).IsNil() || reflect.ValueOf(options.AccountKeeper).IsZero() { return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for ante builder") } - if options.BankKeeper == nil { + if reflect.ValueOf(options.BankKeeper).IsNil() || reflect.ValueOf(options.BankKeeper).IsZero() { return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for ante builder") } From 61435b46a14314bd669de76744f311979c7ae556 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Wed, 24 Aug 2022 18:08:28 -0600 Subject: [PATCH 2/3] regenerated protos with removing some unused imports --- api/cosmos/consensus_param/v1/query.pulsar.go | 78 +++++++++---------- baseapp/grpcrouter.go | 5 +- client/grpc/reflection/reflection.pb.go | 7 +- client/grpc/tmservice/query.pb.go | 7 +- proto/cosmos/consensus_param/v1/query.proto | 2 - x/consensus_param/types/query.pb.go | 51 ++++++------ x/consensus_param/types/tx.pb.go | 7 +- 7 files changed, 73 insertions(+), 84 deletions(-) diff --git a/api/cosmos/consensus_param/v1/query.pulsar.go b/api/cosmos/consensus_param/v1/query.pulsar.go index a3025a6b2bb1..7e7c6cf7b53c 100644 --- a/api/cosmos/consensus_param/v1/query.pulsar.go +++ b/api/cosmos/consensus_param/v1/query.pulsar.go @@ -2,11 +2,9 @@ package consensus_paramv1 import ( - _ "cosmossdk.io/api/cosmos/base/query/v1beta1" types "cosmossdk.io/api/tendermint/types" fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" - _ "github.com/gogo/protobuf/gogoproto" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -890,46 +888,42 @@ var file_cosmos_consensus_param_v1_query_proto_rawDesc = []byte{ 0x75, 0x73, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x2f, 0x76, 0x31, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x19, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x2e, - 0x76, 0x31, 0x1a, 0x2a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, - 0x71, 0x75, 0x65, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x70, 0x61, - 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, - 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, - 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x1a, 0x1d, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x74, - 0x79, 0x70, 0x65, 0x73, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x22, 0x14, 0x0a, 0x12, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x50, 0x0a, 0x13, 0x51, 0x75, 0x65, 0x72, 0x79, - 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x39, - 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, - 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x79, 0x70, 0x65, - 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, - 0x73, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x32, 0x96, 0x01, 0x0a, 0x05, 0x51, 0x75, - 0x65, 0x72, 0x79, 0x12, 0x8c, 0x01, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x2d, - 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, - 0x73, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, - 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, - 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, - 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x23, 0x82, - 0xd3, 0xe4, 0x93, 0x02, 0x1d, 0x12, 0x1b, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, - 0x61, 0x6e, 0x6b, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x70, 0x61, 0x72, 0x61, - 0x6d, 0x73, 0x42, 0xeb, 0x01, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x5f, 0x70, 0x61, 0x72, 0x61, - 0x6d, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x50, 0x01, 0x5a, 0x3c, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, - 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x6e, 0x73, - 0x65, 0x6e, 0x73, 0x75, 0x73, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x2f, 0x76, 0x31, 0x3b, 0x63, - 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x76, 0x31, - 0xa2, 0x02, 0x03, 0x43, 0x43, 0x58, 0xaa, 0x02, 0x18, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, - 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x2e, 0x56, - 0x31, 0xca, 0x02, 0x18, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x43, 0x6f, 0x6e, 0x73, 0x65, - 0x6e, 0x73, 0x75, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x24, 0x43, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x50, - 0x61, 0x72, 0x61, 0x6d, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0xea, 0x02, 0x1a, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x43, 0x6f, - 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x3a, 0x3a, 0x56, 0x31, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x76, 0x31, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, + 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x1a, 0x1d, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x74, 0x79, 0x70, + 0x65, 0x73, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0x14, 0x0a, 0x12, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x50, 0x0a, 0x13, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, + 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x39, 0x0a, 0x06, + 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x74, + 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, + 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, + 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x32, 0x96, 0x01, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, + 0x79, 0x12, 0x8c, 0x01, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x2d, 0x2e, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x5f, + 0x70, 0x61, 0x72, 0x61, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, + 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x5f, 0x70, + 0x61, 0x72, 0x61, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, + 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x23, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x1d, 0x12, 0x1b, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x6e, + 0x6b, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, + 0x42, 0xeb, 0x01, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x2e, + 0x76, 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, + 0x5a, 0x3c, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, + 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, + 0x73, 0x75, 0x73, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x6e, + 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x76, 0x31, 0xa2, 0x02, + 0x03, 0x43, 0x43, 0x58, 0xaa, 0x02, 0x18, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x43, 0x6f, + 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x2e, 0x56, 0x31, 0xca, + 0x02, 0x18, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, + 0x75, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x24, 0x43, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x5c, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x50, 0x61, 0x72, + 0x61, 0x6d, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0xea, 0x02, 0x1a, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x43, 0x6f, 0x6e, 0x73, + 0x65, 0x6e, 0x73, 0x75, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/baseapp/grpcrouter.go b/baseapp/grpcrouter.go index 3e3e54691a7f..72ec5320206d 100644 --- a/baseapp/grpcrouter.go +++ b/baseapp/grpcrouter.go @@ -114,8 +114,5 @@ func (qrt *GRPCQueryRouter) SetInterfaceRegistry(interfaceRegistry codectypes.In qrt.cdc = codec.NewProtoCodec(interfaceRegistry).GRPCCodec() // Once we have an interface registry, we can register the interface // registry reflection gRPC service. - reflection.RegisterReflectionServiceServer( - qrt, - reflection.NewReflectionServiceServer(interfaceRegistry), - ) + reflection.RegisterReflectionServiceServer(qrt, reflection.NewReflectionServiceServer(interfaceRegistry)) } diff --git a/client/grpc/reflection/reflection.pb.go b/client/grpc/reflection/reflection.pb.go index 271b71fe9295..66dbef0c7105 100644 --- a/client/grpc/reflection/reflection.pb.go +++ b/client/grpc/reflection/reflection.pb.go @@ -6,6 +6,7 @@ package reflection import ( context "context" fmt "fmt" + grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" @@ -264,10 +265,10 @@ type ReflectionServiceClient interface { } type reflectionServiceClient struct { - cc *grpc.ClientConn + cc grpc1.ClientConn } -func NewReflectionServiceClient(cc *grpc.ClientConn) ReflectionServiceClient { +func NewReflectionServiceClient(cc grpc1.ClientConn) ReflectionServiceClient { return &reflectionServiceClient{cc} } @@ -310,7 +311,7 @@ func (*UnimplementedReflectionServiceServer) ListImplementations(ctx context.Con return nil, status.Errorf(codes.Unimplemented, "method ListImplementations not implemented") } -func RegisterReflectionServiceServer(s *grpc.Server, srv ReflectionServiceServer) { +func RegisterReflectionServiceServer(s grpc1.Server, srv ReflectionServiceServer) { s.RegisterService(&_ReflectionService_serviceDesc, srv) } diff --git a/client/grpc/tmservice/query.pb.go b/client/grpc/tmservice/query.pb.go index 15c3cd42f39f..1ce38e1c5430 100644 --- a/client/grpc/tmservice/query.pb.go +++ b/client/grpc/tmservice/query.pb.go @@ -10,6 +10,7 @@ import ( types "github.com/cosmos/cosmos-sdk/codec/types" query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" p2p "github.com/tendermint/tendermint/proto/tendermint/p2p" types1 "github.com/tendermint/tendermint/proto/tendermint/types" @@ -1314,10 +1315,10 @@ type ServiceClient interface { } type serviceClient struct { - cc *grpc.ClientConn + cc grpc1.ClientConn } -func NewServiceClient(cc *grpc.ClientConn) ServiceClient { +func NewServiceClient(cc grpc1.ClientConn) ServiceClient { return &serviceClient{cc} } @@ -1432,7 +1433,7 @@ func (*UnimplementedServiceServer) ABCIQuery(ctx context.Context, req *ABCIQuery return nil, status.Errorf(codes.Unimplemented, "method ABCIQuery not implemented") } -func RegisterServiceServer(s *grpc.Server, srv ServiceServer) { +func RegisterServiceServer(s grpc1.Server, srv ServiceServer) { s.RegisterService(&_Service_serviceDesc, srv) } diff --git a/proto/cosmos/consensus_param/v1/query.proto b/proto/cosmos/consensus_param/v1/query.proto index 83f16631fae7..ff3b4cfb800a 100644 --- a/proto/cosmos/consensus_param/v1/query.proto +++ b/proto/cosmos/consensus_param/v1/query.proto @@ -1,8 +1,6 @@ syntax = "proto3"; package cosmos.consensus_param.v1; -import "cosmos/base/query/v1beta1/pagination.proto"; -import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "tendermint/types/params.proto"; diff --git a/x/consensus_param/types/query.pb.go b/x/consensus_param/types/query.pb.go index 48bcf42011b7..7cea8c6a2562 100644 --- a/x/consensus_param/types/query.pb.go +++ b/x/consensus_param/types/query.pb.go @@ -6,8 +6,7 @@ package types import ( context "context" fmt "fmt" - _ "github.com/cosmos/cosmos-sdk/types/query" - _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" types "github.com/tendermint/tendermint/proto/tendermint/types" _ "google.golang.org/genproto/googleapis/api/annotations" @@ -122,28 +121,26 @@ func init() { } var fileDescriptor_3d2ae9668ec06671 = []byte{ - // 323 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x51, 0x3f, 0x4b, 0x3b, 0x41, - 0x10, 0xcd, 0xfe, 0xe0, 0x97, 0xe2, 0xec, 0xce, 0x14, 0x1a, 0xcd, 0xa2, 0x11, 0x41, 0x84, 0xec, - 0x70, 0xd1, 0xc6, 0x56, 0x7b, 0x89, 0x96, 0x36, 0xb2, 0x97, 0x2c, 0xeb, 0x11, 0x6f, 0x67, 0x73, - 0xbb, 0x17, 0x4c, 0x6b, 0x6d, 0x21, 0x08, 0x7e, 0x26, 0xcb, 0x80, 0x8d, 0xa5, 0x24, 0x7e, 0x10, - 0xb9, 0xdd, 0x35, 0xfe, 0x09, 0x82, 0xd5, 0x0e, 0x33, 0xef, 0xbd, 0x79, 0xfb, 0x26, 0xda, 0xed, - 0xa3, 0xc9, 0xd1, 0x40, 0x1f, 0x95, 0x11, 0xca, 0x94, 0xe6, 0x52, 0xf3, 0x82, 0xe7, 0x30, 0x4e, - 0x60, 0x54, 0x8a, 0x62, 0xc2, 0x74, 0x81, 0x16, 0xe3, 0x75, 0x0f, 0x63, 0x3f, 0x60, 0x6c, 0x9c, - 0x34, 0xf7, 0x83, 0x42, 0xca, 0x8d, 0xf0, 0x1c, 0x18, 0x27, 0xa9, 0xb0, 0x3c, 0x01, 0xcd, 0x65, - 0xa6, 0xb8, 0xcd, 0x50, 0x79, 0x99, 0x66, 0x43, 0xa2, 0x44, 0x57, 0x42, 0x55, 0x85, 0xee, 0xa6, - 0x44, 0x94, 0xd7, 0x02, 0xb8, 0xce, 0x80, 0x2b, 0x85, 0xd6, 0x51, 0x4c, 0x98, 0xb6, 0xac, 0x50, - 0x03, 0x51, 0xe4, 0x99, 0xb2, 0x60, 0x27, 0x5a, 0x18, 0x70, 0xab, 0xc3, 0xb8, 0xdd, 0x88, 0xe2, - 0xb3, 0x6a, 0x69, 0xcf, 0x35, 0xcf, 0xc5, 0xa8, 0x14, 0xc6, 0xb6, 0x7b, 0xd1, 0xea, 0xb7, 0xae, - 0xd1, 0x95, 0xf1, 0xf8, 0x28, 0xaa, 0x7b, 0xf2, 0x1a, 0xd9, 0x22, 0x7b, 0x2b, 0xdd, 0x6d, 0xf6, - 0x29, 0xce, 0x9c, 0x38, 0x3b, 0xf9, 0xf8, 0x61, 0xa0, 0x06, 0x42, 0xf7, 0x91, 0x44, 0xff, 0x9d, - 0x64, 0x7c, 0x47, 0xa2, 0xba, 0x1f, 0xc6, 0x1d, 0xf6, 0x6b, 0x2e, 0x6c, 0xd9, 0x55, 0x93, 0xfd, - 0x15, 0xee, 0xed, 0xb6, 0x77, 0x6e, 0x9f, 0xdf, 0x1e, 0xfe, 0xb5, 0xe2, 0x0d, 0x58, 0x64, 0xac, - 0x86, 0x5f, 0xd2, 0xad, 0xc0, 0xc7, 0xa7, 0x4f, 0x33, 0x4a, 0xa6, 0x33, 0x4a, 0x5e, 0x67, 0x94, - 0xdc, 0xcf, 0x69, 0x6d, 0x3a, 0xa7, 0xb5, 0x97, 0x39, 0xad, 0x5d, 0x1c, 0xca, 0xcc, 0x5e, 0x95, - 0x29, 0xeb, 0x63, 0x0e, 0x8b, 0x33, 0x57, 0x4f, 0xc7, 0x0c, 0x86, 0x70, 0xb3, 0x74, 0x73, 0x17, - 0x40, 0x5a, 0x77, 0xb9, 0x1e, 0xbc, 0x07, 0x00, 0x00, 0xff, 0xff, 0x4c, 0xfa, 0x35, 0x91, 0x1a, - 0x02, 0x00, 0x00, + // 296 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4d, 0xce, 0x2f, 0xce, + 0xcd, 0x2f, 0xd6, 0x4f, 0xce, 0xcf, 0x2b, 0x4e, 0xcd, 0x2b, 0x2e, 0x2d, 0x8e, 0x2f, 0x48, 0x2c, + 0x4a, 0xcc, 0xd5, 0x2f, 0x33, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, + 0xc9, 0x17, 0x92, 0x84, 0x28, 0xd3, 0x43, 0x53, 0xa6, 0x57, 0x66, 0x28, 0x25, 0x93, 0x9e, 0x9f, + 0x9f, 0x9e, 0x93, 0xaa, 0x9f, 0x58, 0x90, 0xa9, 0x9f, 0x98, 0x97, 0x97, 0x5f, 0x92, 0x58, 0x92, + 0x99, 0x9f, 0x57, 0x0c, 0xd1, 0x28, 0x25, 0x5b, 0x92, 0x9a, 0x97, 0x92, 0x5a, 0x94, 0x9b, 0x99, + 0x57, 0xa2, 0x5f, 0x52, 0x59, 0x90, 0x5a, 0xac, 0x0f, 0xd6, 0x08, 0x95, 0x56, 0x12, 0xe1, 0x12, + 0x0a, 0x04, 0x59, 0x13, 0x00, 0x16, 0x0c, 0x4a, 0x2d, 0x2c, 0x4d, 0x2d, 0x2e, 0x51, 0x0a, 0xe0, + 0x12, 0x46, 0x11, 0x2d, 0x2e, 0x00, 0x59, 0x2b, 0x64, 0xc9, 0xc5, 0x06, 0xd1, 0x2c, 0xc1, 0xa8, + 0xc0, 0xa8, 0xc1, 0x6d, 0xa4, 0xa8, 0x87, 0x30, 0x5c, 0x0f, 0x6c, 0xb8, 0x9e, 0x33, 0xcc, 0x7d, + 0x50, 0xad, 0x50, 0x0d, 0x46, 0xd3, 0x18, 0xb9, 0x58, 0xc1, 0x46, 0x0a, 0xf5, 0x30, 0x72, 0xb1, + 0x41, 0x24, 0x85, 0x74, 0xf5, 0x70, 0xfa, 0x4a, 0x0f, 0xd3, 0x55, 0x52, 0x7a, 0xc4, 0x2a, 0x87, + 0x38, 0x57, 0x49, 0xb9, 0xe9, 0xf2, 0x93, 0xc9, 0x4c, 0xb2, 0x42, 0xd2, 0xfa, 0xd0, 0x30, 0x4e, + 0x4a, 0xcc, 0xcb, 0xd6, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0x84, 0x06, 0x83, 0x93, 0xdf, + 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, + 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x99, 0xa4, 0x67, 0x96, 0x64, 0x94, + 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0xc3, 0x23, 0x09, 0x44, 0xe9, 0x16, 0xa7, 0x64, 0xeb, 0x57, + 0x60, 0xc4, 0x18, 0x38, 0x00, 0x92, 0xd8, 0xc0, 0xe1, 0x6a, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, + 0x2a, 0x1e, 0x98, 0xab, 0xd8, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -163,10 +160,10 @@ type QueryClient interface { } type queryClient struct { - cc *grpc.ClientConn + cc grpc1.ClientConn } -func NewQueryClient(cc *grpc.ClientConn) QueryClient { +func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } @@ -193,7 +190,7 @@ func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsReq return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } -func RegisterQueryServer(s *grpc.Server, srv QueryServer) { +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } diff --git a/x/consensus_param/types/tx.pb.go b/x/consensus_param/types/tx.pb.go index d08f4d6a5234..325ad78b3044 100644 --- a/x/consensus_param/types/tx.pb.go +++ b/x/consensus_param/types/tx.pb.go @@ -9,6 +9,7 @@ import ( _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/types/msgservice" _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" types "github.com/tendermint/tendermint/proto/tendermint/types" grpc "google.golang.org/grpc" @@ -183,10 +184,10 @@ type MsgClient interface { } type msgClient struct { - cc *grpc.ClientConn + cc grpc1.ClientConn } -func NewMsgClient(cc *grpc.ClientConn) MsgClient { +func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } @@ -216,7 +217,7 @@ func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateP return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") } -func RegisterMsgServer(s *grpc.Server, srv MsgServer) { +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } From 6d03157fbdbc886fe560ef7af4e574274b722358 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Wed, 24 Aug 2022 19:39:18 -0600 Subject: [PATCH 3/3] add legacy exported + keeper and module dep inject functions --- x/consensus_param/exported/exported.go | 24 +++++++--- x/consensus_param/keeper/grpc_query.go | 4 +- x/consensus_param/keeper/keeper.go | 4 +- x/consensus_param/module.go | 62 +++++++++++++++++++++++--- 4 files changed, 78 insertions(+), 16 deletions(-) diff --git a/x/consensus_param/exported/exported.go b/x/consensus_param/exported/exported.go index 7d17fc4f057c..a76e5b101cfd 100644 --- a/x/consensus_param/exported/exported.go +++ b/x/consensus_param/exported/exported.go @@ -5,10 +5,20 @@ import ( tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) -// ProtocolVersionSetter defines the interface fulfilled by BaseApp -// which allows setting it's appVersion field. -type ConsensusParamSetter interface { - Get(ctx sdk.Context) (*tmproto.ConsensusParams, error) - Has(ctx sdk.Context) bool - Set(ctx sdk.Context, cp *tmproto.ConsensusParams) -} +type ( + // Subspace defines an interface that implements the legacy x/params Subspace + // type. + // + // NOTE: This is used solely for migration of x/params managed parameters. + Subspace interface { + Get(ctx sdk.Context) (*tmproto.ConsensusParams, error) + } + + // ConsensusParamSetter ProtocolVersionSetter defines the interface fulfilled by BaseApp + // which allows setting its appVersion field. + ConsensusParamSetter interface { + Get(ctx sdk.Context) (*tmproto.ConsensusParams, error) + Has(ctx sdk.Context) bool + Set(ctx sdk.Context, cp *tmproto.ConsensusParams) + } +) diff --git a/x/consensus_param/keeper/grpc_query.go b/x/consensus_param/keeper/grpc_query.go index ebd03e95117a..966512b03402 100644 --- a/x/consensus_param/keeper/grpc_query.go +++ b/x/consensus_param/keeper/grpc_query.go @@ -12,15 +12,17 @@ import ( var _ types.QueryServer = Querier{} +// Querier is used as Keeper will have duplicate methods if used directly, and gRPC names take precedence over keeper type Querier struct { Keeper } +// NewQuerier constructor for the Querier struct func NewQuerier(keeper Keeper) Querier { return Querier{Keeper: keeper} } -// Balance implements the Query/Balance gRPC method +// Params Balance implements the Query/Balance gRPC method func (k Querier) Params(ctx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) diff --git a/x/consensus_param/keeper/keeper.go b/x/consensus_param/keeper/keeper.go index dcf7b7c8c8cf..9f1b89ee6ba8 100644 --- a/x/consensus_param/keeper/keeper.go +++ b/x/consensus_param/keeper/keeper.go @@ -31,6 +31,7 @@ func (k *Keeper) GetAuthority() string { return k.authority } +// Get gets the consensus parameters func (k *Keeper) Get(ctx sdk.Context) (*tmproto.ConsensusParams, error) { store := ctx.KVStore(k.storeKey) @@ -50,8 +51,9 @@ func (k *Keeper) Has(ctx sdk.Context) bool { return store.Has(types.ParamStoreKeyConsensusParams) } +// Set sets the consensus parameters func (k *Keeper) Set(ctx sdk.Context, cp *tmproto.ConsensusParams) { - store := ctx.KVStore(k.storeKey) + store := ctx.KVStore(k.storeKey) store.Set(types.ParamStoreKeyConsensusParams, k.cdc.MustMarshal(cp)) } diff --git a/x/consensus_param/module.go b/x/consensus_param/module.go index 81f634cac803..1fa24c015c94 100644 --- a/x/consensus_param/module.go +++ b/x/consensus_param/module.go @@ -2,8 +2,13 @@ package bank import ( "context" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/depinject" "encoding/json" - + "github.com/cosmos/cosmos-sdk/runtime" + store "github.com/cosmos/cosmos-sdk/store/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -16,6 +21,8 @@ import ( "github.com/cosmos/cosmos-sdk/x/consensus_param/exported" "github.com/cosmos/cosmos-sdk/x/consensus_param/keeper" "github.com/cosmos/cosmos-sdk/x/consensus_param/types" + + modulev1 "cosmossdk.io/api/cosmos/consensus_param/module/v1" ) // ConsensusVersion defines the current x/bank module consensus version. @@ -26,18 +33,18 @@ var ( _ module.AppModuleBasic = AppModuleBasic{} ) -// AppModuleBasic defines the basic application module used by the bank module. +// AppModuleBasic defines the basic application module used by the consensus_param module. type AppModuleBasic struct { cdc codec.Codec } -// Name returns the bank module's name. +// Name returns the consensus_param module's name. func (AppModuleBasic) Name() string { return types.ModuleName } -// RegisterLegacyAminoCodec registers the bank module's types on the LegacyAmino codec. +// RegisterLegacyAminoCodec registers the consensus_param module's types on the LegacyAmino codec. func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} -// DefaultGenesis returns default genesis state as raw bytes for the bank +// DefaultGenesis returns default genesis state as raw bytes for the consensus_param // module. func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { return nil @@ -96,10 +103,10 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ss exported.Subspace) A } } -// Name returns the bank module's name. +// Name returns the consensus_param module's name. func (AppModule) Name() string { return types.ModuleName } -// InitGenesis is handled by for init genesis of consensus params +// 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 { return nil } @@ -112,3 +119,44 @@ func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } // RegisterInvariants does nothing, there are no invariants to enforce func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {} + +func init() { + appmodule.Register( + &modulev1.Module{}, + appmodule.Provide(provideModuleBasic, provideModule), + ) +} + +func provideModuleBasic() runtime.AppModuleBasicWrapper { + return runtime.WrapAppModuleBasic(AppModuleBasic{}) +} + +type consensusParamInputs struct { + depinject.In + + Cdc codec.Codec + Key *store.KVStoreKey + ModuleKey depinject.OwnModuleKey + Authority map[string]sdk.AccAddress `optional:"true"` + + // LegacySubspace is used solely for migration of x/params managed parameters + LegacySubspace exported.Subspace +} + +type consensusParamOutputs struct { + depinject.Out + + consensusParamKeeper keeper.Keeper + Module runtime.AppModuleWrapper +} + +func provideModule(in consensusParamInputs) consensusParamOutputs { + authority, ok := in.Authority[depinject.ModuleKey(in.ModuleKey).Name()] + if !ok { + // default to governance authority if not provided + authority = authtypes.NewModuleAddress(govtypes.ModuleName) + } + k := keeper.NewKeeper(in.Cdc, in.Key, authority.String()) + m := NewAppModule(in.Cdc, k, in.LegacySubspace) + return consensusParamOutputs{consensusParamKeeper: k, Module: runtime.WrapAppModule(m)} +}