From 08ab095da31e8ef65966c3e17fd43537d80c1a95 Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Thu, 31 Mar 2022 01:36:53 +0000 Subject: [PATCH 01/18] refactor: update protos --- proto/lbm/consortium/v1/consortium.proto | 10 ++-- proto/lbm/consortium/v1/event.proto | 2 +- proto/lbm/consortium/v1/genesis.proto | 6 +-- proto/lbm/consortium/v1/query.proto | 2 +- x/consortium/{types => }/consortium.pb.go | 62 ++++++++++----------- x/consortium/{types => }/event.pb.go | 14 ++--- x/consortium/{types => }/genesis.pb.go | 32 ++++++----- x/consortium/{types => }/query.pb.go | 65 +++++++++++------------ x/consortium/{types => }/query.pb.gw.go | 4 +- 9 files changed, 95 insertions(+), 102 deletions(-) rename x/consortium/{types => }/consortium.pb.go (90%) rename x/consortium/{types => }/event.pb.go (97%) rename x/consortium/{types => }/genesis.pb.go (87%) rename x/consortium/{types => }/query.pb.go (92%) rename x/consortium/{types => }/query.pb.gw.go (99%) diff --git a/proto/lbm/consortium/v1/consortium.proto b/proto/lbm/consortium/v1/consortium.proto index c8c961c919..5ed6ad57c2 100644 --- a/proto/lbm/consortium/v1/consortium.proto +++ b/proto/lbm/consortium/v1/consortium.proto @@ -1,20 +1,20 @@ syntax = "proto3"; package lbm.consortium.v1; -option go_package = "github.com/line/lbm-sdk/x/consortium/types"; +option go_package = "github.com/line/lbm-sdk/x/consortium"; option (gogoproto.equal_all) = true; import "gogoproto/gogo.proto"; // Params defines the parameters for the consortium module. message Params { - bool enabled = 1 [(gogoproto.moretags) = "yaml:\"enabled\""]; + bool enabled = 1; } // ValidatorAuth defines authorization info of a validator. message ValidatorAuth { - string operator_address = 1 [(gogoproto.moretags) = "yaml:\"operator_address\""]; - bool creation_allowed = 2 [(gogoproto.moretags) = "yaml:\"creation_allowed\""]; + string operator_address = 1; + bool creation_allowed = 2; } // UpdateConsortiumParamsProposal details a proposal to update params of cosortium module. @@ -36,5 +36,5 @@ message UpdateValidatorAuthsProposal { string title = 1; string description = 2; - repeated ValidatorAuth auths = 3 [(gogoproto.moretags) = "yaml:\"auths\""]; + repeated ValidatorAuth auths = 3; } diff --git a/proto/lbm/consortium/v1/event.proto b/proto/lbm/consortium/v1/event.proto index 00ce02ff4f..02e0e2ffe7 100644 --- a/proto/lbm/consortium/v1/event.proto +++ b/proto/lbm/consortium/v1/event.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package lbm.consortium.v1; -option go_package = "github.com/line/lbm-sdk/x/consortium/types"; +option go_package = "github.com/line/lbm-sdk/x/consortium"; import "lbm/consortium/v1/consortium.proto"; diff --git a/proto/lbm/consortium/v1/genesis.proto b/proto/lbm/consortium/v1/genesis.proto index ca3a27337e..ce1c5398bb 100644 --- a/proto/lbm/consortium/v1/genesis.proto +++ b/proto/lbm/consortium/v1/genesis.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package lbm.consortium.v1; -option go_package = "github.com/line/lbm-sdk/x/consortium/types"; +option go_package = "github.com/line/lbm-sdk/x/consortium"; option (gogoproto.equal_all) = true; import "gogoproto/gogo.proto"; @@ -13,9 +13,9 @@ message GenesisState { option (gogoproto.goproto_getters) = false; // params defines the module parameters at genesis. - Params params = 1 [(gogoproto.moretags) = "yaml:\"params\""]; + Params params = 1; // allowed_validators defines the allowed validator addresses at genesis. // provided empty, the module gathers information from staking module. - repeated ValidatorAuth validator_auths = 2 [(gogoproto.moretags) = "yaml:\"validator_auths\""]; + repeated ValidatorAuth validator_auths = 2; } diff --git a/proto/lbm/consortium/v1/query.proto b/proto/lbm/consortium/v1/query.proto index 1e693cc0ff..7376f7f2ae 100644 --- a/proto/lbm/consortium/v1/query.proto +++ b/proto/lbm/consortium/v1/query.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package lbm.consortium.v1; -option go_package = "github.com/line/lbm-sdk/x/consortium/types"; +option go_package = "github.com/line/lbm-sdk/x/consortium"; import "lbm/base/query/v1/pagination.proto"; import "google/api/annotations.proto"; diff --git a/x/consortium/types/consortium.pb.go b/x/consortium/consortium.pb.go similarity index 90% rename from x/consortium/types/consortium.pb.go rename to x/consortium/consortium.pb.go index 47c5358663..29912ed757 100644 --- a/x/consortium/types/consortium.pb.go +++ b/x/consortium/consortium.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. // source: lbm/consortium/v1/consortium.proto -package types +package consortium import ( fmt "fmt" @@ -25,7 +25,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the consortium module. type Params struct { - Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty" yaml:"enabled"` + Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -70,8 +70,8 @@ func (m *Params) GetEnabled() bool { // ValidatorAuth defines authorization info of a validator. type ValidatorAuth struct { - OperatorAddress string `protobuf:"bytes,1,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty" yaml:"operator_address"` - CreationAllowed bool `protobuf:"varint,2,opt,name=creation_allowed,json=creationAllowed,proto3" json:"creation_allowed,omitempty" yaml:"creation_allowed"` + OperatorAddress string `protobuf:"bytes,1,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty"` + CreationAllowed bool `protobuf:"varint,2,opt,name=creation_allowed,json=creationAllowed,proto3" json:"creation_allowed,omitempty"` } func (m *ValidatorAuth) Reset() { *m = ValidatorAuth{} } @@ -164,7 +164,7 @@ var xxx_messageInfo_UpdateConsortiumParamsProposal proto.InternalMessageInfo type UpdateValidatorAuthsProposal struct { Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` - Auths []*ValidatorAuth `protobuf:"bytes,3,rep,name=auths,proto3" json:"auths,omitempty" yaml:"auths"` + Auths []*ValidatorAuth `protobuf:"bytes,3,rep,name=auths,proto3" json:"auths,omitempty"` } func (m *UpdateValidatorAuthsProposal) Reset() { *m = UpdateValidatorAuthsProposal{} } @@ -211,34 +211,30 @@ func init() { } var fileDescriptor_ff3cd9d46ac10ef2 = []byte{ - // 420 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x92, 0xbf, 0xae, 0xd3, 0x30, - 0x18, 0xc5, 0x63, 0xaa, 0x5b, 0xb8, 0xee, 0x85, 0x7b, 0x89, 0xae, 0x44, 0xf8, 0x23, 0x27, 0xf2, - 0x54, 0x21, 0x48, 0xd4, 0x22, 0x31, 0x74, 0x6b, 0x90, 0x50, 0xc7, 0x2a, 0x12, 0x0c, 0x2c, 0x95, - 0x13, 0x5b, 0x6d, 0x84, 0x13, 0x47, 0xb6, 0x5b, 0xe8, 0x1b, 0x30, 0x32, 0xc2, 0x44, 0x47, 0x26, - 0x9e, 0x83, 0xb1, 0x23, 0x53, 0x85, 0xd2, 0x85, 0xb9, 0x4f, 0x80, 0x12, 0xb7, 0x28, 0x2d, 0x6c, - 0x6c, 0xf9, 0x8e, 0x4f, 0x7e, 0xdf, 0xf1, 0x91, 0x21, 0xe6, 0x71, 0x16, 0x24, 0x22, 0x57, 0x42, - 0xea, 0x74, 0x9e, 0x05, 0x8b, 0x5e, 0x63, 0xf2, 0x0b, 0x29, 0xb4, 0xb0, 0xef, 0xf2, 0x38, 0xf3, - 0x1b, 0xea, 0xa2, 0xf7, 0xe0, 0x7a, 0x2a, 0xa6, 0xa2, 0x3e, 0x0d, 0xaa, 0x2f, 0x63, 0xc4, 0xcf, - 0x61, 0x7b, 0x4c, 0x24, 0xc9, 0x94, 0xfd, 0x04, 0xde, 0x64, 0x39, 0x89, 0x39, 0xa3, 0x0e, 0xf0, - 0x40, 0xf7, 0x56, 0x68, 0xef, 0x36, 0xee, 0x9d, 0x25, 0xc9, 0xf8, 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 0xc6, 0xbd, 0x30, 0x9d, 0xd6, 0x3f, 0xe2, 0xc8, 0x00, 0x8e, 0x03, 0x87, 0xa3, 0xaf, - 0x25, 0x02, 0xdf, 0x4b, 0x04, 0xd6, 0x25, 0x02, 0x3f, 0x4b, 0x04, 0x3e, 0x6e, 0x91, 0xb5, 0xde, - 0x22, 0xeb, 0xc7, 0x16, 0x59, 0x6f, 0x1e, 0x4f, 0x53, 0x3d, 0x9b, 0xc7, 0x7e, 0x22, 0xb2, 0x80, - 0xa7, 0x39, 0x0b, 0x78, 0x9c, 0x3d, 0x55, 0xf4, 0x6d, 0xf0, 0xbe, 0xf9, 0x4e, 0xf5, 0xb2, 0x60, - 0x2a, 0x6e, 0xd7, 0xef, 0xee, 0xd9, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x90, 0xf5, 0xd5, 0xf4, - 0xc6, 0x02, 0x00, 0x00, + // 367 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x92, 0xb1, 0x4e, 0xc2, 0x40, + 0x1c, 0xc6, 0x7b, 0x12, 0x50, 0x0e, 0x0d, 0xda, 0x30, 0x54, 0x63, 0x8e, 0xa6, 0x71, 0xc0, 0xc1, + 0x36, 0x60, 0xe2, 0xe0, 0x06, 0xbe, 0x00, 0x69, 0xa2, 0x83, 0x0b, 0xb9, 0xf6, 0x2e, 0xd0, 0x78, + 0xed, 0x35, 0x77, 0x07, 0xfa, 0x08, 0x8e, 0x8e, 0x9a, 0x38, 0x30, 0xfa, 0x28, 0x8e, 0x8c, 0x8e, + 0xa6, 0x2c, 0x3e, 0x86, 0x69, 0x0f, 0x4c, 0x89, 0x6e, 0x6e, 0xfd, 0xbe, 0x7e, 0xf7, 0xfd, 0x7f, + 0xf9, 0xe7, 0x0f, 0x1d, 0x16, 0xc4, 0x5e, 0xc8, 0x13, 0xc9, 0x85, 0x8a, 0xa6, 0xb1, 0x37, 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, 0x6c, 0x1b, 0x9b, 0xf8, 0x3f, 0xd9, 0x05, 0xac, 0xe2, 0xbc, 0xc8, 0xaa, + 0xd8, 0x95, 0x4e, 0xa3, 0x67, 0xff, 0x01, 0xb6, 0x31, 0xd1, 0xd7, 0xf1, 0x4d, 0xbc, 0xc1, 0xe0, + 0x2d, 0x43, 0xe0, 0x3d, 0x43, 0x60, 0x91, 0x21, 0xf0, 0x99, 0x21, 0xf0, 0xb4, 0x44, 0xc6, 0x62, + 0x89, 0x8c, 0x8f, 0x25, 0x32, 0x6e, 0x4f, 0xc6, 0x91, 0x9a, 0x4c, 0x03, 0x37, 0xe4, 0xb1, 0xc7, + 0xa2, 0x84, 0x7a, 0x2c, 0x88, 0xcf, 0x24, 0xb9, 0xf3, 0x1e, 0x4a, 0x87, 0x13, 0xd4, 0x8a, 0x83, + 0x38, 0xff, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x48, 0x61, 0xd9, 0xce, 0x5f, 0x02, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { diff --git a/x/consortium/types/event.pb.go b/x/consortium/event.pb.go similarity index 97% rename from x/consortium/types/event.pb.go rename to x/consortium/event.pb.go index b6732e086b..d95ed17768 100644 --- a/x/consortium/types/event.pb.go +++ b/x/consortium/event.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. // source: lbm/consortium/v1/event.proto -package types +package consortium import ( fmt "fmt" @@ -120,7 +120,7 @@ func init() { func init() { proto.RegisterFile("lbm/consortium/v1/event.proto", fileDescriptor_c233a6a29d2bc95c) } var fileDescriptor_c233a6a29d2bc95c = []byte{ - // 230 bytes of a gzipped FileDescriptorProto + // 225 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcd, 0x49, 0xca, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0xce, 0x2f, 0x2a, 0xc9, 0x2c, 0xcd, 0xd5, 0x2f, 0x33, 0xd4, 0x4f, 0x2d, 0x4b, 0xcd, 0x2b, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0xcc, 0x49, 0xca, 0xd5, 0x43, @@ -130,12 +130,12 @@ var fileDescriptor_c233a6a29d2bc95c = []byte{ 0x49, 0xea, 0x61, 0x58, 0xa3, 0x07, 0x51, 0x1a, 0x04, 0x55, 0xa8, 0x14, 0xcc, 0x25, 0x89, 0x64, 0x62, 0x58, 0x62, 0x4e, 0x66, 0x4a, 0x62, 0x49, 0x7e, 0x91, 0x63, 0x69, 0x49, 0x46, 0xb1, 0x90, 0x19, 0x17, 0x6b, 0x22, 0x88, 0x21, 0xc1, 0xa8, 0xc0, 0xac, 0xc1, 0x6d, 0xa4, 0x80, 0xc5, 0x38, - 0x14, 0x1d, 0x41, 0x10, 0xe5, 0x4e, 0x2e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, + 0x14, 0x1d, 0x41, 0x10, 0xe5, 0x4e, 0x76, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, - 0x10, 0xa5, 0x95, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x9f, 0x93, 0x99, - 0x97, 0xaa, 0x9f, 0x93, 0x94, 0xab, 0x5b, 0x9c, 0x92, 0xad, 0x5f, 0x81, 0xec, 0xf5, 0x92, 0xca, - 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x9f, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x8a, 0x35, - 0x13, 0xf5, 0x4b, 0x01, 0x00, 0x00, + 0x10, 0xa5, 0x92, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x9f, 0x93, 0x99, + 0x97, 0xaa, 0x9f, 0x93, 0x94, 0xab, 0x5b, 0x9c, 0x92, 0xad, 0x5f, 0x81, 0xe4, 0xd9, 0x24, 0x36, + 0xb0, 0x6f, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x0c, 0xc1, 0x45, 0x53, 0x45, 0x01, 0x00, + 0x00, } func (m *EventUpdateConsortiumParams) Marshal() (dAtA []byte, err error) { diff --git a/x/consortium/types/genesis.pb.go b/x/consortium/genesis.pb.go similarity index 87% rename from x/consortium/types/genesis.pb.go rename to x/consortium/genesis.pb.go index 57ece09acf..53fde78b0f 100644 --- a/x/consortium/types/genesis.pb.go +++ b/x/consortium/genesis.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. // source: lbm/consortium/v1/genesis.proto -package types +package consortium import ( fmt "fmt" @@ -26,10 +26,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the consortium module's genesis state. type GenesisState struct { // params defines the module parameters at genesis. - Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty" yaml:"params"` + Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` // allowed_validators defines the allowed validator addresses at genesis. // provided empty, the module gathers information from staking module. - ValidatorAuths []*ValidatorAuth `protobuf:"bytes,2,rep,name=validator_auths,json=validatorAuths,proto3" json:"validator_auths,omitempty" yaml:"validator_auths"` + ValidatorAuths []*ValidatorAuth `protobuf:"bytes,2,rep,name=validator_auths,json=validatorAuths,proto3" json:"validator_auths,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -72,25 +72,23 @@ func init() { func init() { proto.RegisterFile("lbm/consortium/v1/genesis.proto", fileDescriptor_f0783d21a1f8be8d) } var fileDescriptor_f0783d21a1f8be8d = []byte{ - // 282 bytes of a gzipped FileDescriptorProto + // 249 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcf, 0x49, 0xca, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0xce, 0x2f, 0x2a, 0xc9, 0x2c, 0xcd, 0xd5, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0xcc, 0x49, 0xca, 0xd5, 0x43, 0x28, 0xd0, 0x2b, 0x33, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xea, 0x83, - 0x58, 0x10, 0x85, 0x52, 0x4a, 0x98, 0x26, 0x21, 0x69, 0x03, 0xab, 0x51, 0x3a, 0xca, 0xc8, 0xc5, - 0xe3, 0x0e, 0x31, 0x3e, 0xb8, 0x24, 0xb1, 0x24, 0x55, 0xc8, 0x85, 0x8b, 0xad, 0x20, 0xb1, 0x28, + 0x58, 0x10, 0x85, 0x52, 0x4a, 0x98, 0x26, 0x21, 0x69, 0x03, 0xab, 0x51, 0x9a, 0xc6, 0xc8, 0xc5, + 0xe3, 0x0e, 0x31, 0x3e, 0xb8, 0x24, 0xb1, 0x24, 0x55, 0xc8, 0x90, 0x8b, 0xad, 0x20, 0xb1, 0x28, 0x31, 0xb7, 0x58, 0x82, 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x52, 0x0f, 0xc3, 0x3a, 0xbd, 0x00, - 0xb0, 0x02, 0x27, 0xc1, 0x4f, 0xf7, 0xe4, 0x79, 0x2b, 0x13, 0x73, 0x73, 0xac, 0x94, 0x20, 0x5a, - 0x94, 0x82, 0xa0, 0x7a, 0x85, 0x52, 0xb9, 0xf8, 0xcb, 0x12, 0x73, 0x32, 0x53, 0x12, 0x4b, 0xf2, - 0x8b, 0xe2, 0x13, 0x4b, 0x4b, 0x32, 0x8a, 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, 0x5e, 0x2c, 0x90, 0x67, 0x70, 0x72, 0x5a, 0xf1, 0x48, 0x8e, 0xf1, + 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, + 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x54, 0xd2, 0x33, 0x4b, 0x32, 0x4a, + 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x73, 0x32, 0xf3, 0x52, 0xf5, 0x73, 0x92, 0x72, 0x75, 0x8b, + 0x53, 0xb2, 0xf5, 0x2b, 0x90, 0xbc, 0x98, 0xc4, 0x06, 0xf6, 0xa3, 0x31, 0x20, 0x00, 0x00, 0xff, + 0xff, 0x0d, 0x35, 0x21, 0x6d, 0x53, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/consortium/types/query.pb.go b/x/consortium/query.pb.go similarity index 92% rename from x/consortium/types/query.pb.go rename to x/consortium/query.pb.go index ddb24c4028..24f8317069 100644 --- a/x/consortium/types/query.pb.go +++ b/x/consortium/query.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. // source: lbm/consortium/v1/query.proto -package types +package consortium import ( context "context" @@ -318,38 +318,37 @@ func init() { func init() { proto.RegisterFile("lbm/consortium/v1/query.proto", fileDescriptor_e916717a75144447) } var fileDescriptor_e916717a75144447 = []byte{ - // 483 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0x41, 0x6b, 0xd4, 0x40, - 0x14, 0xc7, 0x77, 0x5a, 0xbb, 0xe0, 0x13, 0xc5, 0x8e, 0x1e, 0xdc, 0xd4, 0xa6, 0x75, 0xa0, 0x22, - 0x6a, 0x67, 0xd8, 0x56, 0x04, 0x2f, 0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cf, 0x46, 0xbb, 0xca, 0x1d, 0xec, 0x96, 0x81, 0xdd, 0xc0, 0xeb, 0xff, 0x85, 0x7d, - 0xfe, 0xe2, 0xe7, 0xcc, 0x47, 0x27, 0x33, 0x1f, 0xfd, 0x99, 0xf9, 0xe8, 0xeb, 0xdc, 0xef, 0x9d, - 0xcc, 0xfd, 0xde, 0xef, 0xb9, 0xdf, 0x7b, 0x73, 0x3f, 0x8c, 0xf4, 0xa4, 0x08, 0xe8, 0x81, 0x4c, - 0x58, 0x1c, 0xa5, 0xa2, 0xf4, 0xd9, 0x56, 0xe3, 0xf7, 0xec, 0x43, 0xd5, 0x4d, 0x1f, 0x65, 0x42, - 0x05, 0x7d, 0xf3, 0x2b, 0xd8, 0xfd, 0x17, 0x00, 0x00, 0xff, 0xff, 0x95, 0x93, 0xc7, 0xd0, 0xa4, - 0x04, 0x00, 0x00, + // 480 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0x4f, 0x6b, 0xd4, 0x40, + 0x18, 0xc6, 0x77, 0x5a, 0xbb, 0xe0, 0x2b, 0x8a, 0x1d, 0x3d, 0xb8, 0xa9, 0x4d, 0xeb, 0x60, 0x45, + 0xd0, 0xce, 0xb0, 0xad, 0x08, 0x5e, 0x2a, 0xf5, 0xd4, 0xa3, 0xee, 0xc1, 0x83, 0x08, 0x32, 0xe9, + 0x0e, 0xd9, 0x60, 0x92, 0x49, 0x33, 0x93, 0xc5, 0x3f, 0x78, 0xf1, 0x13, 0x08, 0x42, 0xbf, 0x82, + 0xdf, 0x44, 0x3c, 0x16, 0xbc, 0x78, 0x94, 0x5d, 0x3f, 0x88, 0x64, 0x66, 0xba, 0x4d, 0x48, 0x56, + 0x73, 0x7d, 0xdf, 0xe7, 0x7d, 0x9e, 0x5f, 0xe6, 0x7d, 0x09, 0x6c, 0xc6, 0x41, 0xc2, 0x8e, 0x65, + 0xaa, 0x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, 0xe8, 0x9b, 0x9f, + 0xc0, 0xfe, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc9, 0x69, 0x58, 0x8c, 0x9e, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/consortium/types/query.pb.gw.go b/x/consortium/query.pb.gw.go similarity index 99% rename from x/consortium/types/query.pb.gw.go rename to x/consortium/query.pb.gw.go index b797a072fa..85c9137ba8 100644 --- a/x/consortium/types/query.pb.gw.go +++ b/x/consortium/query.pb.gw.go @@ -2,11 +2,11 @@ // source: lbm/consortium/v1/query.proto /* -Package types is a reverse proxy. +Package consortium is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ -package types +package consortium import ( "context" From fb4d5b898b2a9a64e1eb6335b88576bd5a40f1d0 Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Thu, 31 Mar 2022 01:46:30 +0000 Subject: [PATCH 02/18] refactor: move expected_keepers.go --- x/consortium/{types => }/expected_keepers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename x/consortium/{types => }/expected_keepers.go (95%) diff --git a/x/consortium/types/expected_keepers.go b/x/consortium/expected_keepers.go similarity index 95% rename from x/consortium/types/expected_keepers.go rename to x/consortium/expected_keepers.go index 89a41ef8c3..5a4cc8b3df 100644 --- a/x/consortium/types/expected_keepers.go +++ b/x/consortium/expected_keepers.go @@ -1,4 +1,4 @@ -package types +package consortium import ( sdk "github.com/line/lbm-sdk/types" From f7087fcc10dbc281d0a85bfb3e1e96be037f9e66 Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Thu, 31 Mar 2022 01:57:39 +0000 Subject: [PATCH 03/18] refactor: move keys.go --- x/consortium/keeper/keys.go | 29 +++++++++++++++++++++++++++ x/consortium/keys.go | 12 +++++++++++ x/consortium/types/keys.go | 40 ------------------------------------- 3 files changed, 41 insertions(+), 40 deletions(-) create mode 100644 x/consortium/keeper/keys.go create mode 100644 x/consortium/keys.go delete mode 100644 x/consortium/types/keys.go diff --git a/x/consortium/keeper/keys.go b/x/consortium/keeper/keys.go new file mode 100644 index 0000000000..4137bef378 --- /dev/null +++ b/x/consortium/keeper/keys.go @@ -0,0 +1,29 @@ +package keeper + +import ( + sdk "github.com/line/lbm-sdk/types" +) + +// Keys for consortium store +// Items are stored with the following key: values +// +// - 0x00: Params +// +// - 0x01: bool +var ( + paramsKey = []byte{0x00} + validatorAuthKeyPrefix = []byte{0x01} +) + +// validatorAuthKey key for a specific validator from the store +func validatorAuthKey(valAddr sdk.ValAddress) []byte { + key := make([]byte, len(validatorAuthKeyPrefix)+len(valAddr)) + copy(key, validatorAuthKeyPrefix) + copy(key[len(validatorAuthKeyPrefix):], valAddr) + return key +} + +// splitValidatorAuthKey splits the validator auth key and returns validator +func splitValidatorAuthKey(key []byte) sdk.ValAddress { + return sdk.ValAddress(key[1:]) // remove prefix +} diff --git a/x/consortium/keys.go b/x/consortium/keys.go new file mode 100644 index 0000000000..5f64bf1482 --- /dev/null +++ b/x/consortium/keys.go @@ -0,0 +1,12 @@ +package consortium + +const ( + // ModuleName is the module name constant used in many places + ModuleName = "consortium" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey defines the module's message routing key + RouterKey = ModuleName +) diff --git a/x/consortium/types/keys.go b/x/consortium/types/keys.go deleted file mode 100644 index ed49b55020..0000000000 --- a/x/consortium/types/keys.go +++ /dev/null @@ -1,40 +0,0 @@ -package types - -import ( - sdk "github.com/line/lbm-sdk/types" -) - -const ( - // ModuleName is the name of the module - ModuleName = "consortium" - - // StoreKey is the store key string for consortium - StoreKey = ModuleName - - // RouterKey is the message route for consortium - RouterKey = ModuleName - - // QuerierKey is used to handle abci_query requests - QuerierKey = ModuleName -) - -// Keys for consortium store -// Items are stored with the following key: values -// -// - 0x00: Params -// -// - 0x01: bool -var ( - ParamsKey = []byte{0x00} - ValidatorAuthKeyPrefix = []byte{0x01} -) - -// ValidatorAuthKey key for a specific validator from the store -func ValidatorAuthKey(valAddr sdk.ValAddress) []byte { - return append(ValidatorAuthKeyPrefix, valAddr.Bytes()...) -} - -// SplitValidatorAuthKey splits the validator auth key and returns validator -func SplitValidatorAuthKey(key []byte) sdk.ValAddress { - return sdk.ValAddress(key[1:]) // remove prefix -} From 2536b65818eb53009c986dbba1b5b0b0265596c8 Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Thu, 31 Mar 2022 02:02:46 +0000 Subject: [PATCH 04/18] refactor: move module.go --- x/consortium/{ => module}/module.go | 38 ++++++++++++++--------------- 1 file changed, 19 insertions(+), 19 deletions(-) rename x/consortium/{ => module}/module.go (88%) diff --git a/x/consortium/module.go b/x/consortium/module/module.go similarity index 88% rename from x/consortium/module.go rename to x/consortium/module/module.go index c502f40e70..4621b2c19a 100644 --- a/x/consortium/module.go +++ b/x/consortium/module/module.go @@ -1,4 +1,4 @@ -package consortium +package module import ( "context" @@ -15,9 +15,9 @@ import ( codectypes "github.com/line/lbm-sdk/codec/types" sdk "github.com/line/lbm-sdk/types" "github.com/line/lbm-sdk/types/module" + "github.com/line/lbm-sdk/x/consortium" "github.com/line/lbm-sdk/x/consortium/client/cli" "github.com/line/lbm-sdk/x/consortium/keeper" - "github.com/line/lbm-sdk/x/consortium/types" ) var ( @@ -37,28 +37,26 @@ func NewAppModuleBasic() AppModuleBasic { // Name returns the ModuleName func (AppModuleBasic) Name() string { - return types.ModuleName + return consortium.ModuleName } // RegisterLegacyAminoCodec registers the consortium types on the LegacyAmino codec -func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - types.RegisterLegacyAminoCodec(cdc) -} +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} // DefaultGenesis returns default genesis state as raw bytes for the consortium // module. func (AppModuleBasic) DefaultGenesis(cdc codec.JSONMarshaler) json.RawMessage { - return cdc.MustMarshalJSON(types.DefaultGenesisState()) + return cdc.MustMarshalJSON(consortium.DefaultGenesisState()) } // ValidateGenesis performs genesis state validation for the consortium module. func (AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, config client.TxEncodingConfig, bz json.RawMessage) error { - var data types.GenesisState + var data consortium.GenesisState if err := cdc.UnmarshalJSON(bz, &data); err != nil { - return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + return fmt.Errorf("failed to unmarshal %s genesis state: %w", consortium.ModuleName, err) } - return types.ValidateGenesis(data) + return consortium.ValidateGenesis(data) } // RegisterRESTRoutes registers all REST query handlers @@ -66,7 +64,9 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, r *mux.Router // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the consortium module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + if err := consortium.RegisterQueryHandlerClient(context.Background(), mux, consortium.NewQueryClient(clientCtx)); err != nil { + panic(err) + } } // GetQueryCmd returns the cli query commands for this module @@ -80,7 +80,7 @@ func (AppModuleBasic) GetTxCmd() *cobra.Command { } func (b AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { - types.RegisterInterfaces(registry) + consortium.RegisterInterfaces(registry) } //____________________________________________________________________________ @@ -90,11 +90,11 @@ type AppModule struct { AppModuleBasic keeper keeper.Keeper - stakingKeeper types.StakingKeeper + stakingKeeper consortium.StakingKeeper } // NewAppModule creates a new AppModule object -func NewAppModule(cdc codec.Marshaler, keeper keeper.Keeper, stk types.StakingKeeper) AppModule { +func NewAppModule(cdc codec.Marshaler, keeper keeper.Keeper, stk consortium.StakingKeeper) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{cdc: cdc}, keeper: keeper, @@ -109,20 +109,20 @@ func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} func (AppModule) Route() sdk.Route { return sdk.Route{} } // QuerierRoute returns the route we respond to for abci queries -func (AppModule) QuerierRoute() string { return types.QuerierKey } +func (AppModule) QuerierRoute() string { return "" } // LegacyQuerierHandler registers a query handler to respond to the module-specific queries func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return keeper.NewQuerier(am.keeper, legacyQuerierCdc) + return nil } // RegisterServices registers a GRPC query service to respond to the // module-specific GRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { - types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + consortium.RegisterQueryServer(cfg.QueryServer(), am.keeper) /* m := keeper.NewMigrator(am.keeper) - if err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2); err != nil { + if err := cfg.RegisterMigration(consortium.ModuleName, 1, m.Migrate1to2); err != nil { panic(fmt.Sprintf("failed to migrate x/consortium from version 1 to 2: %v", err)) } */ } @@ -130,7 +130,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { // InitGenesis performs genesis initialization for the consortium module. It returns // no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, data json.RawMessage) []abci.ValidatorUpdate { - var genesisState types.GenesisState + var genesisState consortium.GenesisState cdc.MustUnmarshalJSON(data, &genesisState) InitGenesis(ctx, am.keeper, am.stakingKeeper, &genesisState) return []abci.ValidatorUpdate{} From be749db0c6c676d128244fda9d843cdeaa28248a Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Thu, 31 Mar 2022 02:06:58 +0000 Subject: [PATCH 05/18] refactor: move genesis.go --- x/consortium/genesis.go | 52 ++++++++++++++++------------------ x/consortium/keeper/genesis.go | 43 ++++++++++++++++++++++++++++ x/consortium/module/module.go | 4 +-- x/consortium/types/genesis.go | 39 ------------------------- 4 files changed, 69 insertions(+), 69 deletions(-) create mode 100644 x/consortium/keeper/genesis.go delete mode 100644 x/consortium/types/genesis.go diff --git a/x/consortium/genesis.go b/x/consortium/genesis.go index c40d132585..adbfea4b67 100644 --- a/x/consortium/genesis.go +++ b/x/consortium/genesis.go @@ -2,42 +2,38 @@ package consortium import ( sdk "github.com/line/lbm-sdk/types" - "github.com/line/lbm-sdk/x/consortium/keeper" - "github.com/line/lbm-sdk/x/consortium/types" - - stakingtypes "github.com/line/lbm-sdk/x/staking/types" + sdkerrors "github.com/line/lbm-sdk/types/errors" ) -func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, sk types.StakingKeeper, data *types.GenesisState) error { - keeper.SetParams(ctx, data.Params) +// NewGenesisState creates a new GenesisState object +func NewGenesisState(params *Params, validatorAuths []*ValidatorAuth) *GenesisState { + return &GenesisState{ + Params: params, + ValidatorAuths: validatorAuths, + } +} - validatorAuths := data.ValidatorAuths - if keeper.GetEnabled(ctx) && len(validatorAuths) == 0 { - // Allowed validators must exist if the module is enabled, - // so it should be the very first block of the chain. - // We gather the information from staking module. - sk.IterateValidators(ctx, func(_ int64, addr stakingtypes.ValidatorI) (stop bool) { - auth := &types.ValidatorAuth{ - OperatorAddress: addr.GetOperator().String(), - CreationAllowed: true, - } - validatorAuths = append(validatorAuths, auth) - return false - }) +// DefaultGenesisState creates a default GenesisState object +func DefaultGenesisState() *GenesisState { + return &GenesisState{ + Params: &Params{Enabled: false}, + ValidatorAuths: []*ValidatorAuth{}, } +} - for _, auth := range validatorAuths { - if err := keeper.SetValidatorAuth(ctx, auth); err != nil { +// ValidateGenesis validates the provided genesis state to ensure the +// expected invariants holds. +func ValidateGenesis(data GenesisState) error { + // validator auths are redundant where consortium is off + if !data.Params.Enabled && len(data.ValidatorAuths) != 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "redundant validator auths for disabled consortium") + } + + for _, auth := range data.ValidatorAuths { + if err := sdk.ValidateValAddress(auth.OperatorAddress); err != nil { return err } } return nil } - -func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState { - return &types.GenesisState{ - Params: keeper.GetParams(ctx), - ValidatorAuths: keeper.GetValidatorAuths(ctx), - } -} diff --git a/x/consortium/keeper/genesis.go b/x/consortium/keeper/genesis.go new file mode 100644 index 0000000000..38e7d1b4b8 --- /dev/null +++ b/x/consortium/keeper/genesis.go @@ -0,0 +1,43 @@ +package keeper + +import ( + sdk "github.com/line/lbm-sdk/types" + + "github.com/line/lbm-sdk/x/consortium" + + stakingtypes "github.com/line/lbm-sdk/x/staking/types" +) + +func (k Keeper) InitGenesis(ctx sdk.Context, sk consortium.StakingKeeper, data *consortium.GenesisState) error { + k.SetParams(ctx, data.Params) + + validatorAuths := data.ValidatorAuths + if k.GetEnabled(ctx) && len(validatorAuths) == 0 { + // Allowed validators must exist if the module is enabled, + // so it should be the very first block of the chain. + // We gather the information from staking module. + sk.IterateValidators(ctx, func(_ int64, addr stakingtypes.ValidatorI) (stop bool) { + auth := &consortium.ValidatorAuth{ + OperatorAddress: addr.GetOperator().String(), + CreationAllowed: true, + } + validatorAuths = append(validatorAuths, auth) + return false + }) + } + + for _, auth := range validatorAuths { + if err := k.SetValidatorAuth(ctx, auth); err != nil { + return err + } + } + + return nil +} + +func (k Keeper) ExportGenesis(ctx sdk.Context) *consortium.GenesisState { + return &consortium.GenesisState{ + Params: k.GetParams(ctx), + ValidatorAuths: k.GetValidatorAuths(ctx), + } +} diff --git a/x/consortium/module/module.go b/x/consortium/module/module.go index 4621b2c19a..fcaf155365 100644 --- a/x/consortium/module/module.go +++ b/x/consortium/module/module.go @@ -132,14 +132,14 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, data json.RawMessage) []abci.ValidatorUpdate { var genesisState consortium.GenesisState cdc.MustUnmarshalJSON(data, &genesisState) - InitGenesis(ctx, am.keeper, am.stakingKeeper, &genesisState) + am.keeper.InitGenesis(ctx, am.stakingKeeper, &genesisState) return []abci.ValidatorUpdate{} } // ExportGenesis returns the exported genesis state as raw bytes for the consortium // module. func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONMarshaler) json.RawMessage { - gs := ExportGenesis(ctx, am.keeper) + gs := am.keeper.ExportGenesis(ctx) return cdc.MustMarshalJSON(gs) } diff --git a/x/consortium/types/genesis.go b/x/consortium/types/genesis.go deleted file mode 100644 index 077890c8f6..0000000000 --- a/x/consortium/types/genesis.go +++ /dev/null @@ -1,39 +0,0 @@ -package types - -import ( - sdk "github.com/line/lbm-sdk/types" - sdkerrors "github.com/line/lbm-sdk/types/errors" -) - -// NewGenesisState creates a new GenesisState object -func NewGenesisState(params *Params, validatorAuths []*ValidatorAuth) *GenesisState { - return &GenesisState{ - Params: params, - ValidatorAuths: validatorAuths, - } -} - -// DefaultGenesisState creates a default GenesisState object -func DefaultGenesisState() *GenesisState { - return &GenesisState{ - Params: &Params{Enabled: false}, - ValidatorAuths: []*ValidatorAuth{}, - } -} - -// ValidateGenesis validates the provided genesis state to ensure the -// expected invariants holds. -func ValidateGenesis(data GenesisState) error { - // validator auths are redundant where consortium is off - if !data.Params.Enabled && len(data.ValidatorAuths) != 0 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "redundant validator auths for disabled consortium") - } - - for _, auth := range data.ValidatorAuths { - if err := sdk.ValidateValAddress(auth.OperatorAddress); err != nil { - return err - } - } - - return nil -} From 22448b604236cac3b4a69db07a7355e24bfaa566 Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Thu, 31 Mar 2022 02:16:07 +0000 Subject: [PATCH 06/18] refactor: move codec.go --- x/consortium/codec.go | 14 ++++++++++++++ x/consortium/types/codec.go | 21 --------------------- 2 files changed, 14 insertions(+), 21 deletions(-) create mode 100644 x/consortium/codec.go delete mode 100644 x/consortium/types/codec.go diff --git a/x/consortium/codec.go b/x/consortium/codec.go new file mode 100644 index 0000000000..0015aa57b3 --- /dev/null +++ b/x/consortium/codec.go @@ -0,0 +1,14 @@ +package consortium + +import ( + "github.com/line/lbm-sdk/codec/types" + govtypes "github.com/line/lbm-sdk/x/gov/types" +) + +func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations( + (*govtypes.Content)(nil), + &UpdateConsortiumParamsProposal{}, + &UpdateValidatorAuthsProposal{}, + ) +} diff --git a/x/consortium/types/codec.go b/x/consortium/types/codec.go deleted file mode 100644 index b2a429c1fd..0000000000 --- a/x/consortium/types/codec.go +++ /dev/null @@ -1,21 +0,0 @@ -package types - -import ( - "github.com/line/lbm-sdk/codec" - "github.com/line/lbm-sdk/codec/types" - govtypes "github.com/line/lbm-sdk/x/gov/types" -) - -// RegisterLegacyAminoCodec registers concrete types on the LegacyAmino codec -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&UpdateConsortiumParamsProposal{}, "lbm-sdk/UpdateConsortiumParamsProposal", nil) - cdc.RegisterConcrete(&UpdateValidatorAuthsProposal{}, "lbm-sdk/UpdateValidatorAuthsProposal", nil) -} - -func RegisterInterfaces(registry types.InterfaceRegistry) { - registry.RegisterImplementations( - (*govtypes.Content)(nil), - &UpdateConsortiumParamsProposal{}, - &UpdateValidatorAuthsProposal{}, - ) -} From 5f8becce6a0faeb2997e3dea19dea021c8dae413 Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Thu, 31 Mar 2022 02:25:54 +0000 Subject: [PATCH 07/18] refactor: move proposal.go --- x/consortium/{types => }/proposal.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) rename x/consortium/{types => }/proposal.go (89%) diff --git a/x/consortium/types/proposal.go b/x/consortium/proposal.go similarity index 89% rename from x/consortium/types/proposal.go rename to x/consortium/proposal.go index 6015491545..995a65165e 100644 --- a/x/consortium/types/proposal.go +++ b/x/consortium/proposal.go @@ -1,4 +1,4 @@ -package types +package consortium import ( "fmt" @@ -20,13 +20,11 @@ func NewUpdateConsortiumParamsProposal(title, description string, params *Params } // Assert proposals implements govtypes.Content at compile-time -var _ govtypes.Content = &UpdateConsortiumParamsProposal{} +var _ govtypes.Content = (*UpdateConsortiumParamsProposal)(nil) func init() { govtypes.RegisterProposalType(ProposalTypeUpdateConsortiumParams) - govtypes.RegisterProposalTypeCodec(&UpdateConsortiumParamsProposal{}, "lbm-sdk/UpdateConsortiumParamsProposal") govtypes.RegisterProposalType(ProposalTypeUpdateValidatorAuths) - govtypes.RegisterProposalTypeCodec(&UpdateValidatorAuthsProposal{}, "lbm-sdk/UpdateValidatorAuths") } func (p *UpdateConsortiumParamsProposal) GetTitle() string { return p.Title } @@ -57,7 +55,7 @@ func NewUpdateValidatorAuthsProposal(title, description string, return &UpdateValidatorAuthsProposal{title, description, auths} } -var _ govtypes.Content = &UpdateValidatorAuthsProposal{} +var _ govtypes.Content = (*UpdateValidatorAuthsProposal)(nil) func (p *UpdateValidatorAuthsProposal) GetTitle() string { return p.Title } func (p *UpdateValidatorAuthsProposal) GetDescription() string { return p.Description } From d177bcc978f352c2a2828aaa39fe74a14fc8929e Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Thu, 31 Mar 2022 02:26:13 +0000 Subject: [PATCH 08/18] refactor: remove folder `types` --- x/consortium/types/querier.go | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 x/consortium/types/querier.go diff --git a/x/consortium/types/querier.go b/x/consortium/types/querier.go deleted file mode 100644 index b45297202a..0000000000 --- a/x/consortium/types/querier.go +++ /dev/null @@ -1,8 +0,0 @@ -package types - -// query endpoints supported by the consortium Querier -const ( - QueryParams = "params" - QueryValidatorAuths = "validator_auths" - QueryValidatorAuth = "validator_auth" -) From 13b43790dd6ae7c26d158a80742c110671962ee6 Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Thu, 31 Mar 2022 02:44:07 +0000 Subject: [PATCH 09/18] refactor: move proposal.go --- x/consortium/{ => keeper}/handler.go | 11 +++-- x/consortium/keeper/proposal.go | 33 ++++++++++++++ .../proposal_test.go} | 43 ++++++++----------- x/consortium/proposal_handler.go | 34 --------------- 4 files changed, 56 insertions(+), 65 deletions(-) rename x/consortium/{ => keeper}/handler.go (67%) create mode 100644 x/consortium/keeper/proposal.go rename x/consortium/{proposal_handler_test.go => keeper/proposal_test.go} (55%) delete mode 100644 x/consortium/proposal_handler.go diff --git a/x/consortium/handler.go b/x/consortium/keeper/handler.go similarity index 67% rename from x/consortium/handler.go rename to x/consortium/keeper/handler.go index 7f9411d8c6..f69ee5da03 100644 --- a/x/consortium/handler.go +++ b/x/consortium/keeper/handler.go @@ -1,23 +1,22 @@ -package consortium +package keeper import ( sdk "github.com/line/lbm-sdk/types" sdkerrors "github.com/line/lbm-sdk/types/errors" - "github.com/line/lbm-sdk/x/consortium/keeper" - "github.com/line/lbm-sdk/x/consortium/types" + "github.com/line/lbm-sdk/x/consortium" govtypes "github.com/line/lbm-sdk/x/gov/types" ) -func NewProposalHandler(k keeper.Keeper) govtypes.Handler { +func NewProposalHandler(k Keeper) govtypes.Handler { return func(ctx sdk.Context, content govtypes.Content) error { if !k.GetEnabled(ctx) { return nil } switch c := content.(type) { - case *types.UpdateConsortiumParamsProposal: + case *consortium.UpdateConsortiumParamsProposal: return handleUpdateConsortiumParamsProposal(ctx, k, c) - case *types.UpdateValidatorAuthsProposal: + case *consortium.UpdateValidatorAuthsProposal: return handleUpdateValidatorAuthsProposal(ctx, k, c) default: return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized consortium proposal content type: %T", c) diff --git a/x/consortium/keeper/proposal.go b/x/consortium/keeper/proposal.go new file mode 100644 index 0000000000..c4cd495b23 --- /dev/null +++ b/x/consortium/keeper/proposal.go @@ -0,0 +1,33 @@ +package keeper + +import ( + sdk "github.com/line/lbm-sdk/types" + "github.com/line/lbm-sdk/x/consortium" +) + +// handleUpdateConsortiumParamsProposal is a handler for update consortium params proposal +func handleUpdateConsortiumParamsProposal(ctx sdk.Context, k Keeper, p *consortium.UpdateConsortiumParamsProposal) error { + params := p.Params + k.SetParams(ctx, params) + + if !params.Enabled { + k.Cleanup(ctx) + } + + return ctx.EventManager().EmitTypedEvent(&consortium.EventUpdateConsortiumParams{ + Params: params, + }) +} + +// handleUpdateValidatorAuthsProposal is a handler for update validator auths proposal +func handleUpdateValidatorAuthsProposal(ctx sdk.Context, k Keeper, p *consortium.UpdateValidatorAuthsProposal) error { + for _, auth := range p.Auths { + if err := k.SetValidatorAuth(ctx, auth); err != nil { + return err + } + } + + return ctx.EventManager().EmitTypedEvent(&consortium.EventUpdateValidatorAuths{ + Auths: p.Auths, + }) +} diff --git a/x/consortium/proposal_handler_test.go b/x/consortium/keeper/proposal_test.go similarity index 55% rename from x/consortium/proposal_handler_test.go rename to x/consortium/keeper/proposal_test.go index 278d33195c..d07f57ec22 100644 --- a/x/consortium/proposal_handler_test.go +++ b/x/consortium/keeper/proposal_test.go @@ -1,4 +1,4 @@ -package consortium_test +package keeper_test import ( "testing" @@ -6,32 +6,25 @@ import ( ocproto "github.com/line/ostracon/proto/ostracon/types" "github.com/stretchr/testify/require" - "github.com/line/lbm-sdk/crypto/keys/ed25519" "github.com/line/lbm-sdk/simapp" sdk "github.com/line/lbm-sdk/types" "github.com/line/lbm-sdk/x/consortium" - "github.com/line/lbm-sdk/x/consortium/types" + "github.com/line/lbm-sdk/x/consortium/keeper" govtypes "github.com/line/lbm-sdk/x/gov/types" ) -var ( - delPk = ed25519.GenPrivKey().PubKey() - delAddr = sdk.BytesToAccAddress(delPk.Address()) - valAddr = delAddr.ToValAddress() -) - -func newParams(enabled bool) *types.Params { - return &types.Params{Enabled: enabled} +func newParams(enabled bool) *consortium.Params { + return &consortium.Params{Enabled: enabled} } -func newUpdateConsortiumParamsProposal(params *types.Params) govtypes.Content { - return types.NewUpdateConsortiumParamsProposal("Test", "description", params) +func newUpdateConsortiumParamsProposal(params *consortium.Params) govtypes.Content { + return consortium.NewUpdateConsortiumParamsProposal("Test", "description", params) } -func newValidatorAuths(addrs []sdk.ValAddress, allow bool) []*types.ValidatorAuth { - auths := []*types.ValidatorAuth{} +func newValidatorAuths(addrs []sdk.ValAddress, allow bool) []*consortium.ValidatorAuth { + auths := []*consortium.ValidatorAuth{} for _, addr := range addrs { - auth := &types.ValidatorAuth{ + auth := &consortium.ValidatorAuth{ OperatorAddress: addr.String(), CreationAllowed: allow, } @@ -41,8 +34,8 @@ func newValidatorAuths(addrs []sdk.ValAddress, allow bool) []*types.ValidatorAut return auths } -func newUpdateValidatorAuthsProposal(auths []*types.ValidatorAuth) govtypes.Content { - return types.NewUpdateValidatorAuthsProposal("Test", "description", auths) +func newUpdateValidatorAuthsProposal(auths []*consortium.ValidatorAuth) govtypes.Content { + return consortium.NewUpdateValidatorAuthsProposal("Test", "description", auths) } func TestProposalHandler(t *testing.T) { @@ -50,33 +43,33 @@ func TestProposalHandler(t *testing.T) { ctx := app.BaseApp.NewContext(false, ocproto.Header{}) // turn on the module - keeper := app.ConsortiumKeeper + k := app.ConsortiumKeeper params_on := newParams(true) - keeper.SetParams(ctx, params_on) + k.SetParams(ctx, params_on) - handler := consortium.NewProposalHandler(keeper) + handler := keeper.NewProposalHandler(k) // test adding creation allowed validators adding := newValidatorAuths([]sdk.ValAddress{valAddr}, true) ap := newUpdateValidatorAuthsProposal(adding) require.NoError(t, ap.ValidateBasic()) require.NoError(t, handler(ctx, ap)) - require.Equal(t, adding, keeper.GetValidatorAuths(ctx)) + require.Equal(t, adding, k.GetValidatorAuths(ctx)) // test deleting creation allowed validators deleting := newValidatorAuths([]sdk.ValAddress{valAddr}, false) dp := newUpdateValidatorAuthsProposal(deleting) require.NoError(t, dp.ValidateBasic()) require.NoError(t, handler(ctx, dp)) - require.Equal(t, deleting, keeper.GetValidatorAuths(ctx)) + require.Equal(t, deleting, k.GetValidatorAuths(ctx)) // disable consortium params_off := newParams(false) pp := newUpdateConsortiumParamsProposal(params_off) require.NoError(t, pp.ValidateBasic()) require.NoError(t, handler(ctx, pp)) - require.Equal(t, []*types.ValidatorAuth{}, keeper.GetValidatorAuths(ctx)) - require.Equal(t, params_off, keeper.GetParams(ctx)) + require.Equal(t, []*consortium.ValidatorAuth{}, k.GetValidatorAuths(ctx)) + require.Equal(t, params_off, k.GetParams(ctx)) // attempt to enable consortium, which fails pp = newUpdateConsortiumParamsProposal(params_on) diff --git a/x/consortium/proposal_handler.go b/x/consortium/proposal_handler.go deleted file mode 100644 index aa615f1b33..0000000000 --- a/x/consortium/proposal_handler.go +++ /dev/null @@ -1,34 +0,0 @@ -package consortium - -import ( - sdk "github.com/line/lbm-sdk/types" - "github.com/line/lbm-sdk/x/consortium/keeper" - "github.com/line/lbm-sdk/x/consortium/types" -) - -// handleUpdateConsortiumParamsProposal is a handler for update consortium params proposal -func handleUpdateConsortiumParamsProposal(ctx sdk.Context, k keeper.Keeper, p *types.UpdateConsortiumParamsProposal) error { - params := p.Params - k.SetParams(ctx, params) - - if !params.Enabled { - k.Cleanup(ctx) - } - - return ctx.EventManager().EmitTypedEvent(&types.EventUpdateConsortiumParams{ - Params: params, - }) -} - -// handleUpdateValidatorAuthsProposal is a handler for update validator auths proposal -func handleUpdateValidatorAuthsProposal(ctx sdk.Context, k keeper.Keeper, p *types.UpdateValidatorAuthsProposal) error { - for _, auth := range p.Auths { - if err := k.SetValidatorAuth(ctx, auth); err != nil { - return err - } - } - - return ctx.EventManager().EmitTypedEvent(&types.EventUpdateValidatorAuths{ - Auths: p.Auths, - }) -} From dc597900d958ee26783cd35024a1166d126dc2cd Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Thu, 31 Mar 2022 03:05:48 +0000 Subject: [PATCH 10/18] refactor: update grpc_query.go --- x/consortium/keeper/grpc_query.go | 38 ++++++++++++++--------- x/consortium/keeper/grpc_query_test.go | 43 +++++++++++++------------- x/consortium/module/module.go | 2 +- 3 files changed, 47 insertions(+), 36 deletions(-) diff --git a/x/consortium/keeper/grpc_query.go b/x/consortium/keeper/grpc_query.go index 533394b24b..092b2ad6ed 100644 --- a/x/consortium/keeper/grpc_query.go +++ b/x/consortium/keeper/grpc_query.go @@ -9,22 +9,32 @@ import ( "github.com/line/lbm-sdk/store/prefix" sdk "github.com/line/lbm-sdk/types" "github.com/line/lbm-sdk/types/query" - "github.com/line/lbm-sdk/x/consortium/types" + "github.com/line/lbm-sdk/x/consortium" ) -var _ types.QueryServer = Keeper{} +type queryServer struct { + keeper Keeper +} + +func NewQueryServer(keeper Keeper) consortium.QueryServer { + return &queryServer{ + keeper: keeper, + } +} + +var _ consortium.QueryServer = (*queryServer)(nil) -func (q Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { +func (s queryServer) Params(c context.Context, req *consortium.QueryParamsRequest) (*consortium.QueryParamsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } ctx := sdk.UnwrapSDKContext(c) - return &types.QueryParamsResponse{Params: q.GetParams(ctx)}, nil + return &consortium.QueryParamsResponse{Params: s.keeper.GetParams(ctx)}, nil } -func (q Keeper) ValidatorAuth(c context.Context, req *types.QueryValidatorAuthRequest) (*types.QueryValidatorAuthResponse, error) { +func (s queryServer) ValidatorAuth(c context.Context, req *consortium.QueryValidatorAuthRequest) (*consortium.QueryValidatorAuthResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } @@ -36,26 +46,26 @@ func (q Keeper) ValidatorAuth(c context.Context, req *types.QueryValidatorAuthRe ctx := sdk.UnwrapSDKContext(c) addr := sdk.ValAddress(req.ValidatorAddress) - auth, err := q.GetValidatorAuth(ctx, addr) + auth, err := s.keeper.GetValidatorAuth(ctx, addr) if err != nil { return nil, err } - return &types.QueryValidatorAuthResponse{Auth: auth}, nil + return &consortium.QueryValidatorAuthResponse{Auth: auth}, nil } -func (q Keeper) ValidatorAuths(c context.Context, req *types.QueryValidatorAuthsRequest) (*types.QueryValidatorAuthsResponse, error) { +func (s queryServer) ValidatorAuths(c context.Context, req *consortium.QueryValidatorAuthsRequest) (*consortium.QueryValidatorAuthsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } - var auths []*types.ValidatorAuth + var auths []*consortium.ValidatorAuth ctx := sdk.UnwrapSDKContext(c) - store := ctx.KVStore(q.storeKey) - validatorStore := prefix.NewStore(store, types.ValidatorAuthKeyPrefix) + store := ctx.KVStore(s.keeper.storeKey) + validatorStore := prefix.NewStore(store, validatorAuthKeyPrefix) pageRes, err := query.Paginate(validatorStore, req.Pagination, func(key []byte, value []byte) error { - var auth types.ValidatorAuth - q.cdc.MustUnmarshalBinaryBare(value, &auth) + var auth consortium.ValidatorAuth + s.keeper.cdc.MustUnmarshalBinaryBare(value, &auth) auths = append(auths, &auth) return nil }) @@ -63,5 +73,5 @@ func (q Keeper) ValidatorAuths(c context.Context, req *types.QueryValidatorAuths return nil, err } - return &types.QueryValidatorAuthsResponse{Auths: auths, Pagination: pageRes}, nil + return &consortium.QueryValidatorAuthsResponse{Auths: auths, Pagination: pageRes}, nil } diff --git a/x/consortium/keeper/grpc_query_test.go b/x/consortium/keeper/grpc_query_test.go index 7f00d704e6..817497951f 100644 --- a/x/consortium/keeper/grpc_query_test.go +++ b/x/consortium/keeper/grpc_query_test.go @@ -12,7 +12,8 @@ import ( "github.com/line/lbm-sdk/simapp" sdk "github.com/line/lbm-sdk/types" "github.com/line/lbm-sdk/types/query" - "github.com/line/lbm-sdk/x/consortium/types" + "github.com/line/lbm-sdk/x/consortium" + "github.com/line/lbm-sdk/x/consortium/keeper" ) type ConsortiumTestSuite struct { @@ -20,7 +21,7 @@ type ConsortiumTestSuite struct { app *simapp.SimApp ctx sdk.Context - queryClient types.QueryClient + queryClient consortium.QueryClient } func (suite *ConsortiumTestSuite) SetupTest() { @@ -28,14 +29,14 @@ func (suite *ConsortiumTestSuite) SetupTest() { suite.ctx = suite.app.BaseApp.NewContext(false, ocproto.Header{}) queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.app.InterfaceRegistry()) - types.RegisterQueryServer(queryHelper, suite.app.ConsortiumKeeper) - suite.queryClient = types.NewQueryClient(queryHelper) + consortium.RegisterQueryServer(queryHelper, keeper.NewQueryServer(suite.app.ConsortiumKeeper)) + suite.queryClient = consortium.NewQueryClient(queryHelper) } func (suite *ConsortiumTestSuite) TestQueryParams() { var ( - req *types.QueryParamsRequest - expResponse types.QueryParamsResponse + req *consortium.QueryParamsRequest + expResponse consortium.QueryParamsResponse ) testCases := []struct { @@ -46,11 +47,11 @@ func (suite *ConsortiumTestSuite) TestQueryParams() { { "with enabled", func() { - params := &types.Params{Enabled: true} + params := &consortium.Params{Enabled: true} suite.app.ConsortiumKeeper.SetParams(suite.ctx, params) - req = &types.QueryParamsRequest{} - expResponse = types.QueryParamsResponse{Params: params} + req = &consortium.QueryParamsRequest{} + expResponse = consortium.QueryParamsResponse{Params: params} }, true, }, @@ -77,8 +78,8 @@ func (suite *ConsortiumTestSuite) TestQueryParams() { func (suite *ConsortiumTestSuite) TestQueryValidatorAuth() { var ( - req *types.QueryValidatorAuthRequest - expResponse types.QueryValidatorAuthResponse + req *consortium.QueryValidatorAuthRequest + expResponse consortium.QueryValidatorAuthResponse ) testCases := []struct { @@ -89,22 +90,22 @@ func (suite *ConsortiumTestSuite) TestQueryValidatorAuth() { { "with non-existent auth", func() { - req = &types.QueryValidatorAuthRequest{ValidatorAddress: valAddr.String()} - expResponse = types.QueryValidatorAuthResponse{} + req = &consortium.QueryValidatorAuthRequest{ValidatorAddress: valAddr.String()} + expResponse = consortium.QueryValidatorAuthResponse{} }, false, }, { "with existing auth", func() { - auth := &types.ValidatorAuth{ + auth := &consortium.ValidatorAuth{ OperatorAddress: valAddr.String(), CreationAllowed: true, } suite.app.ConsortiumKeeper.SetValidatorAuth(suite.ctx, auth) - req = &types.QueryValidatorAuthRequest{ValidatorAddress: valAddr.String()} - expResponse = types.QueryValidatorAuthResponse{Auth: auth} + req = &consortium.QueryValidatorAuthRequest{ValidatorAddress: valAddr.String()} + expResponse = consortium.QueryValidatorAuthResponse{Auth: auth} }, true, }, @@ -130,7 +131,7 @@ func (suite *ConsortiumTestSuite) TestQueryValidatorAuth() { } func (suite *ConsortiumTestSuite) TestQueryValidatorAuths() { - var req *types.QueryValidatorAuthsRequest + var req *consortium.QueryValidatorAuthsRequest testCases := []struct { msg string malleate func() @@ -141,7 +142,7 @@ func (suite *ConsortiumTestSuite) TestQueryValidatorAuths() { { "empty request", func() { - req = &types.QueryValidatorAuthsRequest{} + req = &consortium.QueryValidatorAuthsRequest{} }, true, 0, @@ -150,7 +151,7 @@ func (suite *ConsortiumTestSuite) TestQueryValidatorAuths() { { "with empty auths", func() { - req = &types.QueryValidatorAuthsRequest{ + req = &consortium.QueryValidatorAuthsRequest{ Pagination: &query.PageRequest{Limit: 1, CountTotal: true}, } }, @@ -161,13 +162,13 @@ func (suite *ConsortiumTestSuite) TestQueryValidatorAuths() { { "with non-empty auths", func() { - auth := &types.ValidatorAuth{ + auth := &consortium.ValidatorAuth{ OperatorAddress: valAddr.String(), CreationAllowed: true, } suite.app.ConsortiumKeeper.SetValidatorAuth(suite.ctx, auth) - req = &types.QueryValidatorAuthsRequest{ + req = &consortium.QueryValidatorAuthsRequest{ Pagination: &query.PageRequest{Limit: 1, CountTotal: true}, } }, diff --git a/x/consortium/module/module.go b/x/consortium/module/module.go index fcaf155365..dd4d3b491f 100644 --- a/x/consortium/module/module.go +++ b/x/consortium/module/module.go @@ -119,7 +119,7 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd // RegisterServices registers a GRPC query service to respond to the // module-specific GRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { - consortium.RegisterQueryServer(cfg.QueryServer(), am.keeper) + consortium.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServer(am.keeper)) /* m := keeper.NewMigrator(am.keeper) if err := cfg.RegisterMigration(consortium.ModuleName, 1, m.Migrate1to2); err != nil { From 43924b61c47306df877f986a99e1347aced7169b Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Thu, 31 Mar 2022 03:16:48 +0000 Subject: [PATCH 11/18] refactor: remove legacy querier.go --- x/consortium/keeper/querier.go | 86 ---------------------------------- 1 file changed, 86 deletions(-) delete mode 100644 x/consortium/keeper/querier.go diff --git a/x/consortium/keeper/querier.go b/x/consortium/keeper/querier.go deleted file mode 100644 index c81cd9d15e..0000000000 --- a/x/consortium/keeper/querier.go +++ /dev/null @@ -1,86 +0,0 @@ -package keeper - -import ( - abci "github.com/line/ostracon/abci/types" - - "github.com/line/lbm-sdk/client" - "github.com/line/lbm-sdk/codec" - sdk "github.com/line/lbm-sdk/types" - sdkerrors "github.com/line/lbm-sdk/types/errors" - "github.com/line/lbm-sdk/x/consortium/types" -) - -// NewQuerier creates a new consortium Querier instance -func NewQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) { - switch path[0] { - case types.QueryParams: - return queryEnabled(ctx, req, keeper, legacyQuerierCdc) - - case types.QueryValidatorAuth: - return queryValidatorAuth(ctx, path[1:], req, keeper, legacyQuerierCdc) - - case types.QueryValidatorAuths: - return queryValidatorAuths(ctx, path[1:], req, keeper, legacyQuerierCdc) - - default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown query path: %s", path[0]) - } - } -} - -func queryEnabled(ctx sdk.Context, _ abci.RequestQuery, keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - enabled := keeper.GetEnabled(ctx) - - res, err := legacyQuerierCdc.MarshalJSON(&enabled) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func queryValidatorAuth(ctx sdk.Context, path []string, _ abci.RequestQuery, keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - addr := path[0] - if err := sdk.ValidateValAddress(addr); err != nil { - return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid validator address (%s)", err) - } - valAddr := sdk.ValAddress(addr) - - auth, err := keeper.GetValidatorAuth(ctx, valAddr) - if err != nil { - return nil, err - } - - res, err := legacyQuerierCdc.MarshalJSON(&auth) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func queryValidatorAuths(ctx sdk.Context, _ []string, req abci.RequestQuery, keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryValidatorAuthsRequest - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - addrs := keeper.GetValidatorAuths(ctx) - if len(addrs) != 0 { - start, end := client.Paginate(len(addrs), int(params.Pagination.Offset), int(params.Pagination.Limit), 100) - if start < 0 || end < 0 { - addrs = []*types.ValidatorAuth{} - } else { - addrs = addrs[start:end] - } - } - - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, addrs) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} From 41f3d436b8efaba296d20afeefd8f0b0175f7b90 Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Thu, 31 Mar 2022 03:17:07 +0000 Subject: [PATCH 12/18] refactor: apply package rename on x/consortium --- x/consortium/client/cli/query.go | 16 ++++++++-------- x/consortium/client/cli/tx.go | 16 ++++++++-------- x/consortium/client/testutil/grpc.go | 12 ++++++------ x/consortium/client/testutil/suite.go | 10 +++++----- x/consortium/keeper/keeper.go | 12 ++++++------ x/consortium/keeper/keeper_test.go | 6 +++--- x/consortium/keeper/params.go | 12 ++++++------ x/consortium/keeper/params_test.go | 4 ++-- x/consortium/keeper/validator.go | 24 ++++++++++++------------ x/consortium/keeper/validator_test.go | 6 +++--- 10 files changed, 59 insertions(+), 59 deletions(-) diff --git a/x/consortium/client/cli/query.go b/x/consortium/client/cli/query.go index a472e563b1..eb3e9c95c3 100644 --- a/x/consortium/client/cli/query.go +++ b/x/consortium/client/cli/query.go @@ -8,13 +8,13 @@ import ( "github.com/line/lbm-sdk/client" "github.com/line/lbm-sdk/client/flags" sdk "github.com/line/lbm-sdk/types" - "github.com/line/lbm-sdk/x/consortium/types" + "github.com/line/lbm-sdk/x/consortium" ) // NewQueryCmd returns the parent command for all x/consortium CLi query commands. func NewQueryCmd() *cobra.Command { cmd := &cobra.Command{ - Use: types.ModuleName, + Use: consortium.ModuleName, Short: "Querying commands for the consortium module", } @@ -39,9 +39,9 @@ func NewQueryCmdParams() *cobra.Command { if err != nil { return err } - queryClient := types.NewQueryClient(clientCtx) + queryClient := consortium.NewQueryClient(clientCtx) - params := types.QueryParamsRequest{} + params := consortium.QueryParamsRequest{} res, err := queryClient.Params(context.Background(), ¶ms) if err != nil { return err @@ -68,14 +68,14 @@ func NewQueryCmdValidatorAuth() *cobra.Command { if err != nil { return err } - queryClient := types.NewQueryClient(clientCtx) + queryClient := consortium.NewQueryClient(clientCtx) valAddr := args[0] if err = sdk.ValidateValAddress(valAddr); err != nil { return err } - params := types.QueryValidatorAuthRequest{ValidatorAddress: valAddr} + params := consortium.QueryValidatorAuthRequest{ValidatorAddress: valAddr} res, err := queryClient.ValidatorAuth(context.Background(), ¶ms) if err != nil { return err @@ -102,14 +102,14 @@ func NewQueryCmdValidatorAuths() *cobra.Command { if err != nil { return err } - queryClient := types.NewQueryClient(clientCtx) + queryClient := consortium.NewQueryClient(clientCtx) pageReq, err := client.ReadPageRequest(cmd.Flags()) if err != nil { return err } - params := types.QueryValidatorAuthsRequest{Pagination: pageReq} + params := consortium.QueryValidatorAuthsRequest{Pagination: pageReq} res, err := queryClient.ValidatorAuths(context.Background(), ¶ms) if err != nil { return err diff --git a/x/consortium/client/cli/tx.go b/x/consortium/client/cli/tx.go index 4ed5bc5a7f..c52eb67b1f 100644 --- a/x/consortium/client/cli/tx.go +++ b/x/consortium/client/cli/tx.go @@ -10,7 +10,7 @@ import ( "github.com/line/lbm-sdk/client/tx" sdk "github.com/line/lbm-sdk/types" "github.com/line/lbm-sdk/version" - "github.com/line/lbm-sdk/x/consortium/types" + "github.com/line/lbm-sdk/x/consortium" "github.com/line/lbm-sdk/x/gov/client/cli" govtypes "github.com/line/lbm-sdk/x/gov/types" ) @@ -64,10 +64,10 @@ $ %s tx gov submit-proposal update-consortium-params [flags] return err } - params := &types.Params{ + params := &consortium.Params{ Enabled: false, } - content := types.NewUpdateConsortiumParamsProposal(title, description, params) + content := consortium.NewUpdateConsortiumParamsProposal(title, description, params) msg, err := govtypes.NewMsgSubmitProposal(content, deposit, from) if err != nil { return err @@ -149,17 +149,17 @@ $ %s tx gov submit-proposal update-validator-auths [flags] } deletingValidators := parseCommaSeparated(deletingValidatorsStr) - createAuths := func(addings, deletings []string) []*types.ValidatorAuth { - var auths []*types.ValidatorAuth + createAuths := func(addings, deletings []string) []*consortium.ValidatorAuth { + var auths []*consortium.ValidatorAuth for _, addr := range addings { - auth := &types.ValidatorAuth{ + auth := &consortium.ValidatorAuth{ OperatorAddress: addr, CreationAllowed: true, } auths = append(auths, auth) } for _, addr := range deletings { - auth := &types.ValidatorAuth{ + auth := &consortium.ValidatorAuth{ OperatorAddress: addr, CreationAllowed: false, } @@ -170,7 +170,7 @@ $ %s tx gov submit-proposal update-validator-auths [flags] } auths := createAuths(addingValidators, deletingValidators) - content := types.NewUpdateValidatorAuthsProposal(title, description, auths) + content := consortium.NewUpdateValidatorAuthsProposal(title, description, auths) msg, err := govtypes.NewMsgSubmitProposal(content, deposit, from) if err != nil { return err diff --git a/x/consortium/client/testutil/grpc.go b/x/consortium/client/testutil/grpc.go index 2cab6362e6..4414c01c81 100644 --- a/x/consortium/client/testutil/grpc.go +++ b/x/consortium/client/testutil/grpc.go @@ -7,7 +7,7 @@ import ( "github.com/line/lbm-sdk/testutil" "github.com/line/lbm-sdk/testutil/rest" - "github.com/line/lbm-sdk/x/consortium/types" + "github.com/line/lbm-sdk/x/consortium" ) func (s *IntegrationTestSuite) TestGRPCParams() { @@ -24,9 +24,9 @@ func (s *IntegrationTestSuite) TestGRPCParams() { "valid request", fmt.Sprintf("%s/lbm/consortium/v1/params", val.APIAddress), false, - &types.QueryParamsResponse{}, - &types.QueryParamsResponse{ - Params: &types.Params{ + &consortium.QueryParamsResponse{}, + &consortium.QueryParamsResponse{ + Params: &consortium.Params{ Enabled: true, }, }, @@ -83,7 +83,7 @@ func (s *IntegrationTestSuite) TestGRPCValidatorAuth() { resp, err := rest.GetRequest(tc.url) s.Require().NoError(err) - var auth types.QueryValidatorAuthResponse + var auth consortium.QueryValidatorAuthResponse err = s.cfg.Codec.UnmarshalJSON(resp, &auth) if tc.expErr { @@ -121,7 +121,7 @@ func (s *IntegrationTestSuite) TestGRPCValidatorAuths() { resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers) s.Require().NoError(err) - var auths types.QueryValidatorAuthsResponse + var auths consortium.QueryValidatorAuthsResponse err = s.cfg.Codec.UnmarshalJSON(resp, &auths) if tc.expErr { diff --git a/x/consortium/client/testutil/suite.go b/x/consortium/client/testutil/suite.go index bde3b0a925..3f2ab96d26 100644 --- a/x/consortium/client/testutil/suite.go +++ b/x/consortium/client/testutil/suite.go @@ -4,7 +4,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/line/lbm-sdk/testutil/network" - "github.com/line/lbm-sdk/x/consortium/types" + "github.com/line/lbm-sdk/x/consortium" ) type IntegrationTestSuite struct { @@ -23,18 +23,18 @@ func (s *IntegrationTestSuite) SetupSuite() { genesisState := s.cfg.GenesisState - var consortiumData types.GenesisState - s.Require().NoError(s.cfg.Codec.UnmarshalJSON(genesisState[types.ModuleName], &consortiumData)) + var consortiumData consortium.GenesisState + s.Require().NoError(s.cfg.Codec.UnmarshalJSON(genesisState[consortium.ModuleName], &consortiumData)) // enable consortium - params := &types.Params{ + params := &consortium.Params{ Enabled: true, } consortiumData.Params = params consortiumDataBz, err := s.cfg.Codec.MarshalJSON(&consortiumData) s.Require().NoError(err) - genesisState[types.ModuleName] = consortiumDataBz + genesisState[consortium.ModuleName] = consortiumDataBz s.cfg.GenesisState = genesisState s.network = network.New(s.T(), s.cfg) diff --git a/x/consortium/keeper/keeper.go b/x/consortium/keeper/keeper.go index d7a81b9da6..7b7ff287d2 100644 --- a/x/consortium/keeper/keeper.go +++ b/x/consortium/keeper/keeper.go @@ -5,12 +5,12 @@ import ( "github.com/line/lbm-sdk/codec" sdk "github.com/line/lbm-sdk/types" - "github.com/line/lbm-sdk/x/consortium/types" + "github.com/line/lbm-sdk/x/consortium" ) // Keeper defines the consortium module Keeper type Keeper struct { - stakingKeeper types.StakingKeeper + stakingKeeper consortium.StakingKeeper // The (unexposed) keys used to access the stores from the Context. storeKey sdk.StoreKey @@ -26,7 +26,7 @@ type Keeper struct { func NewKeeper( cdc codec.BinaryMarshaler, key sdk.StoreKey, - stakingKeeper types.StakingKeeper, + stakingKeeper consortium.StakingKeeper, ) Keeper { return Keeper{ storeKey: key, @@ -37,13 +37,13 @@ func NewKeeper( // Logger returns a module-specific logger. func (k Keeper) Logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", "x/"+types.ModuleName) + return ctx.Logger().With("module", "x/"+consortium.ModuleName) } // Cleaning up the states func (k Keeper) Cleanup(ctx sdk.Context) { valAddrs := []sdk.ValAddress{} - k.IterateValidatorAuths(ctx, func(auth types.ValidatorAuth) (stop bool) { + k.IterateValidatorAuths(ctx, func(auth consortium.ValidatorAuth) (stop bool) { addr := sdk.ValAddress(auth.OperatorAddress) valAddrs = append(valAddrs, addr) return false @@ -51,7 +51,7 @@ func (k Keeper) Cleanup(ctx sdk.Context) { store := ctx.KVStore(k.storeKey) for _, addr := range valAddrs { - key := types.ValidatorAuthKey(addr) + key := validatorAuthKey(addr) store.Delete(key) } } diff --git a/x/consortium/keeper/keeper_test.go b/x/consortium/keeper/keeper_test.go index b64bf34b57..41d534c897 100644 --- a/x/consortium/keeper/keeper_test.go +++ b/x/consortium/keeper/keeper_test.go @@ -9,7 +9,7 @@ import ( "github.com/line/lbm-sdk/crypto/keys/ed25519" "github.com/line/lbm-sdk/simapp" sdk "github.com/line/lbm-sdk/types" - "github.com/line/lbm-sdk/x/consortium/types" + "github.com/line/lbm-sdk/x/consortium" ) var ( @@ -25,7 +25,7 @@ func TestCleanup(t *testing.T) { k := app.ConsortiumKeeper // add auths - auth := &types.ValidatorAuth{ + auth := &consortium.ValidatorAuth{ OperatorAddress: valAddr.String(), CreationAllowed: true, } @@ -33,5 +33,5 @@ func TestCleanup(t *testing.T) { // cleanup k.Cleanup(ctx) - require.Equal(t, []*types.ValidatorAuth{}, k.GetValidatorAuths(ctx)) + require.Equal(t, []*consortium.ValidatorAuth{}, k.GetValidatorAuths(ctx)) } diff --git a/x/consortium/keeper/params.go b/x/consortium/keeper/params.go index 541a6308ba..4e1570fee6 100644 --- a/x/consortium/keeper/params.go +++ b/x/consortium/keeper/params.go @@ -2,25 +2,25 @@ package keeper import ( sdk "github.com/line/lbm-sdk/types" - "github.com/line/lbm-sdk/x/consortium/types" + "github.com/line/lbm-sdk/x/consortium" ) -func (k Keeper) GetParams(ctx sdk.Context) *types.Params { +func (k Keeper) GetParams(ctx sdk.Context) *consortium.Params { store := ctx.KVStore(k.storeKey) - key := types.ParamsKey + key := paramsKey bz := store.Get(key) - var params types.Params + var params consortium.Params k.cdc.MustUnmarshalBinaryBare(bz, ¶ms) return ¶ms } -func (k Keeper) SetParams(ctx sdk.Context, params *types.Params) { +func (k Keeper) SetParams(ctx sdk.Context, params *consortium.Params) { bz := k.cdc.MustMarshalBinaryBare(params) store := ctx.KVStore(k.storeKey) - key := types.ParamsKey + key := paramsKey store.Set(key, bz) } diff --git a/x/consortium/keeper/params_test.go b/x/consortium/keeper/params_test.go index 8edd652794..4727bd3db1 100644 --- a/x/consortium/keeper/params_test.go +++ b/x/consortium/keeper/params_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" "github.com/line/lbm-sdk/simapp" - "github.com/line/lbm-sdk/x/consortium/types" + "github.com/line/lbm-sdk/x/consortium" ) func TestGetSetParams(t *testing.T) { @@ -16,7 +16,7 @@ func TestGetSetParams(t *testing.T) { k := app.ConsortiumKeeper - params := &types.Params{ + params := &consortium.Params{ Enabled: true, } k.SetParams(ctx, params) diff --git a/x/consortium/keeper/validator.go b/x/consortium/keeper/validator.go index c854398f81..52efb8b03b 100644 --- a/x/consortium/keeper/validator.go +++ b/x/consortium/keeper/validator.go @@ -3,18 +3,18 @@ package keeper import ( sdk "github.com/line/lbm-sdk/types" sdkerrors "github.com/line/lbm-sdk/types/errors" - "github.com/line/lbm-sdk/x/consortium/types" + "github.com/line/lbm-sdk/x/consortium" ) -func (k Keeper) GetValidatorAuth(ctx sdk.Context, valAddr sdk.ValAddress) (*types.ValidatorAuth, error) { +func (k Keeper) GetValidatorAuth(ctx sdk.Context, valAddr sdk.ValAddress) (*consortium.ValidatorAuth, error) { store := ctx.KVStore(k.storeKey) - key := types.ValidatorAuthKey(valAddr) + key := validatorAuthKey(valAddr) bz := store.Get(key) if len(bz) == 0 { return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "no validator auth found for: %s", valAddr) } - var auth types.ValidatorAuth + var auth consortium.ValidatorAuth if err := k.cdc.UnmarshalBinaryBare(bz, &auth); err != nil { return nil, err } @@ -22,9 +22,9 @@ func (k Keeper) GetValidatorAuth(ctx sdk.Context, valAddr sdk.ValAddress) (*type return &auth, nil } -func (k Keeper) SetValidatorAuth(ctx sdk.Context, auth *types.ValidatorAuth) error { +func (k Keeper) SetValidatorAuth(ctx sdk.Context, auth *consortium.ValidatorAuth) error { store := ctx.KVStore(k.storeKey) - key := types.ValidatorAuthKey(sdk.ValAddress(auth.OperatorAddress)) + key := validatorAuthKey(sdk.ValAddress(auth.OperatorAddress)) bz, err := k.cdc.MarshalBinaryBare(auth) if err != nil { @@ -39,13 +39,13 @@ func (k Keeper) SetValidatorAuth(ctx sdk.Context, auth *types.ValidatorAuth) err // IterateValidatorAuths iterates over the validator auths // and performs a callback function -func (k Keeper) IterateValidatorAuths(ctx sdk.Context, cb func(auth types.ValidatorAuth) (stop bool)) { +func (k Keeper) IterateValidatorAuths(ctx sdk.Context, cb func(auth consortium.ValidatorAuth) (stop bool)) { store := ctx.KVStore(k.storeKey) - iter := sdk.KVStorePrefixIterator(store, types.ValidatorAuthKeyPrefix) + iter := sdk.KVStorePrefixIterator(store, validatorAuthKeyPrefix) defer iter.Close() for ; iter.Valid(); iter.Next() { - var auth types.ValidatorAuth + var auth consortium.ValidatorAuth k.cdc.MustUnmarshalBinaryBare(iter.Value(), &auth) if cb(auth) { break @@ -54,9 +54,9 @@ func (k Keeper) IterateValidatorAuths(ctx sdk.Context, cb func(auth types.Valida } // utility functions -func (k Keeper) GetValidatorAuths(ctx sdk.Context) []*types.ValidatorAuth { - auths := []*types.ValidatorAuth{} - k.IterateValidatorAuths(ctx, func(auth types.ValidatorAuth) (stop bool) { +func (k Keeper) GetValidatorAuths(ctx sdk.Context) []*consortium.ValidatorAuth { + auths := []*consortium.ValidatorAuth{} + k.IterateValidatorAuths(ctx, func(auth consortium.ValidatorAuth) (stop bool) { auths = append(auths, &auth) return false }) diff --git a/x/consortium/keeper/validator_test.go b/x/consortium/keeper/validator_test.go index 83d7e7a422..446ee9c2b4 100644 --- a/x/consortium/keeper/validator_test.go +++ b/x/consortium/keeper/validator_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" "github.com/line/lbm-sdk/simapp" - "github.com/line/lbm-sdk/x/consortium/types" + "github.com/line/lbm-sdk/x/consortium" ) func TestGetSetValidatorAuth(t *testing.T) { @@ -21,7 +21,7 @@ func TestGetSetValidatorAuth(t *testing.T) { require.Error(t, err) // test adding creation allowed validators - expected := &types.ValidatorAuth{ + expected := &consortium.ValidatorAuth{ OperatorAddress: valAddr.String(), CreationAllowed: true, } @@ -29,5 +29,5 @@ func TestGetSetValidatorAuth(t *testing.T) { actual, err := k.GetValidatorAuth(ctx, valAddr) require.Equal(t, expected, actual) - require.Equal(t, []*types.ValidatorAuth{expected}, k.GetValidatorAuths(ctx)) + require.Equal(t, []*consortium.ValidatorAuth{expected}, k.GetValidatorAuths(ctx)) } From ad5db958065717f7cdb91068a377bd4806fe74b8 Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Thu, 31 Mar 2022 03:17:49 +0000 Subject: [PATCH 13/18] refactor: apply package rename on x/stakingplus --- x/stakingplus/types/expected_keepers.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/stakingplus/types/expected_keepers.go b/x/stakingplus/types/expected_keepers.go index a82e2a826e..00c15d19dd 100644 --- a/x/stakingplus/types/expected_keepers.go +++ b/x/stakingplus/types/expected_keepers.go @@ -3,11 +3,11 @@ package types import ( sdk "github.com/line/lbm-sdk/types" - consortiumtypes "github.com/line/lbm-sdk/x/consortium/types" + "github.com/line/lbm-sdk/x/consortium" ) // ConsortiumKeeper defines the expected consortium keeper type ConsortiumKeeper interface { GetEnabled(ctx sdk.Context) bool - GetValidatorAuth(ctx sdk.Context, valAddr sdk.ValAddress) (*consortiumtypes.ValidatorAuth, error) + GetValidatorAuth(ctx sdk.Context, valAddr sdk.ValAddress) (*consortium.ValidatorAuth, error) } From c8c42ca16d34336a9af2ca2ad1173f56d31f7855 Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Thu, 31 Mar 2022 03:18:02 +0000 Subject: [PATCH 14/18] refactor: apply package rename on app --- simapp/app.go | 14 +++++++------- simapp/app_test.go | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index c11f9df2ac..5f81307107 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -53,7 +53,7 @@ import ( "github.com/line/lbm-sdk/x/consortium" consortiumclient "github.com/line/lbm-sdk/x/consortium/client" consortiumkeeper "github.com/line/lbm-sdk/x/consortium/keeper" - consortiumtypes "github.com/line/lbm-sdk/x/consortium/types" + consortiummodule "github.com/line/lbm-sdk/x/consortium/module" "github.com/line/lbm-sdk/x/crisis" crisiskeeper "github.com/line/lbm-sdk/x/crisis/keeper" crisistypes "github.com/line/lbm-sdk/x/crisis/types" @@ -124,7 +124,7 @@ var ( staking.AppModuleBasic{}, mint.AppModuleBasic{}, distr.AppModuleBasic{}, - consortium.AppModuleBasic{}, + consortiummodule.AppModuleBasic{}, gov.NewAppModuleBasic( consortiumclient.UpdateConsortiumParamsProposalHandler, consortiumclient.UpdateValidatorAuthsProposalHandler, @@ -257,7 +257,7 @@ func NewSimApp( ibctransfertypes.StoreKey, capabilitytypes.StoreKey, feegranttypes.StoreKey, - consortiumtypes.StoreKey, + consortium.StoreKey, class.StoreKey, token.StoreKey, ) @@ -312,7 +312,7 @@ func NewSimApp( app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegranttypes.StoreKey], app.AccountKeeper) app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath) - app.ConsortiumKeeper = consortiumkeeper.NewKeeper(appCodec, keys[consortiumtypes.StoreKey], stakingKeeper) + app.ConsortiumKeeper = consortiumkeeper.NewKeeper(appCodec, keys[consortium.StoreKey], stakingKeeper) classKeeper := classkeeper.NewKeeper(appCodec, keys[class.StoreKey]) app.TokenKeeper = tokenkeeper.NewKeeper(appCodec, keys[token.StoreKey], app.AccountKeeper, classKeeper) @@ -335,7 +335,7 @@ func NewSimApp( AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)). AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)). AddRoute(ibchost.RouterKey, ibcclient.NewClientUpdateProposalHandler(app.IBCKeeper.ClientKeeper)). - AddRoute(consortiumtypes.RouterKey, consortium.NewProposalHandler(app.ConsortiumKeeper)) + AddRoute(consortium.RouterKey, consortiumkeeper.NewProposalHandler(app.ConsortiumKeeper)) app.GovKeeper = govkeeper.NewKeeper( appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper, &stakingKeeper, govRouter, @@ -385,7 +385,7 @@ func NewSimApp( capability.NewAppModule(appCodec, *app.CapabilityKeeper), crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants), feegrant.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), - consortium.NewAppModule(appCodec, app.ConsortiumKeeper, app.StakingKeeper), + consortiummodule.NewAppModule(appCodec, app.ConsortiumKeeper, app.StakingKeeper), gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), @@ -429,7 +429,7 @@ func NewSimApp( evidencetypes.ModuleName, ibctransfertypes.ModuleName, feegranttypes.ModuleName, - consortiumtypes.ModuleName, + consortium.ModuleName, token.ModuleName, ) diff --git a/simapp/app_test.go b/simapp/app_test.go index 1b05cb12ae..c060e09ff9 100644 --- a/simapp/app_test.go +++ b/simapp/app_test.go @@ -22,7 +22,7 @@ import ( "github.com/line/lbm-sdk/x/auth/vesting" banktypes "github.com/line/lbm-sdk/x/bank/types" "github.com/line/lbm-sdk/x/capability" - "github.com/line/lbm-sdk/x/consortium" + consortiummodule "github.com/line/lbm-sdk/x/consortium/module" "github.com/line/lbm-sdk/x/crisis" "github.com/line/lbm-sdk/x/distribution" "github.com/line/lbm-sdk/x/evidence" @@ -184,7 +184,7 @@ func TestRunMigrations(t *testing.T) { "crisis": crisis.AppModule{}.ConsensusVersion(), "genutil": genutil.AppModule{}.ConsensusVersion(), "capability": capability.AppModule{}.ConsensusVersion(), - "consortium": consortium.AppModule{}.ConsensusVersion(), + "consortium": consortiummodule.AppModule{}.ConsensusVersion(), }, ) if tc.expRunErr { @@ -237,7 +237,7 @@ func TestInitGenesisOnMigration(t *testing.T) { "crisis": crisis.AppModule{}.ConsensusVersion(), "genutil": genutil.AppModule{}.ConsensusVersion(), "capability": capability.AppModule{}.ConsensusVersion(), - "consortium": consortium.AppModule{}.ConsensusVersion(), + "consortium": consortiummodule.AppModule{}.ConsensusVersion(), }, ) From ee0b39e7b2262add1b468068b8f323292ac7faa5 Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Thu, 31 Mar 2022 03:28:23 +0000 Subject: [PATCH 15/18] docs: update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b5ad3db45..363e255045 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements +* (refactor) [\#493](https://github.com/line/lbm-sdk/pull/493) restructure x/consortium + ### Bug Fixes * (x/wasm) [\#453](https://github.com/line/lbm-sdk/pull/453) modify wasm grpc query api path * (client) [\#476](https://github.com/line/lbm-sdk/pull/476) change the default value of the client output format in the config From 003ba2575ba7d496ca61e81f6f5e939b1d0d42b1 Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Thu, 31 Mar 2022 03:34:34 +0000 Subject: [PATCH 16/18] fix: remove unused function --- x/consortium/keeper/keys.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/x/consortium/keeper/keys.go b/x/consortium/keeper/keys.go index 4137bef378..f27fc82400 100644 --- a/x/consortium/keeper/keys.go +++ b/x/consortium/keeper/keys.go @@ -22,8 +22,3 @@ func validatorAuthKey(valAddr sdk.ValAddress) []byte { copy(key[len(validatorAuthKeyPrefix):], valAddr) return key } - -// splitValidatorAuthKey splits the validator auth key and returns validator -func splitValidatorAuthKey(key []byte) sdk.ValAddress { - return sdk.ValAddress(key[1:]) // remove prefix -} From fb253eac5b5ea179ec4bf8b90e9a42379186714c Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Thu, 31 Mar 2022 03:36:38 +0000 Subject: [PATCH 17/18] refactor: refactor handler --- x/consortium/keeper/handler.go | 4 ++-- x/consortium/keeper/proposal.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/x/consortium/keeper/handler.go b/x/consortium/keeper/handler.go index f69ee5da03..74e0fa3a89 100644 --- a/x/consortium/keeper/handler.go +++ b/x/consortium/keeper/handler.go @@ -15,9 +15,9 @@ func NewProposalHandler(k Keeper) govtypes.Handler { switch c := content.(type) { case *consortium.UpdateConsortiumParamsProposal: - return handleUpdateConsortiumParamsProposal(ctx, k, c) + return k.handleUpdateConsortiumParamsProposal(ctx, c) case *consortium.UpdateValidatorAuthsProposal: - return handleUpdateValidatorAuthsProposal(ctx, k, c) + return k.handleUpdateValidatorAuthsProposal(ctx, c) default: return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized consortium proposal content type: %T", c) } diff --git a/x/consortium/keeper/proposal.go b/x/consortium/keeper/proposal.go index c4cd495b23..b280b66713 100644 --- a/x/consortium/keeper/proposal.go +++ b/x/consortium/keeper/proposal.go @@ -6,7 +6,7 @@ import ( ) // handleUpdateConsortiumParamsProposal is a handler for update consortium params proposal -func handleUpdateConsortiumParamsProposal(ctx sdk.Context, k Keeper, p *consortium.UpdateConsortiumParamsProposal) error { +func (k Keeper) handleUpdateConsortiumParamsProposal(ctx sdk.Context, p *consortium.UpdateConsortiumParamsProposal) error { params := p.Params k.SetParams(ctx, params) @@ -20,7 +20,7 @@ func handleUpdateConsortiumParamsProposal(ctx sdk.Context, k Keeper, p *consorti } // handleUpdateValidatorAuthsProposal is a handler for update validator auths proposal -func handleUpdateValidatorAuthsProposal(ctx sdk.Context, k Keeper, p *consortium.UpdateValidatorAuthsProposal) error { +func (k Keeper) handleUpdateValidatorAuthsProposal(ctx sdk.Context, p *consortium.UpdateValidatorAuthsProposal) error { for _, auth := range p.Auths { if err := k.SetValidatorAuth(ctx, auth); err != nil { return err From a4872a1c7cbd93873a9b9a33a958bd89d289994f Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Mon, 4 Apr 2022 05:30:33 +0000 Subject: [PATCH 18/18] refactor: remove unused function --- x/consortium/genesis.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/x/consortium/genesis.go b/x/consortium/genesis.go index adbfea4b67..201ed28a4e 100644 --- a/x/consortium/genesis.go +++ b/x/consortium/genesis.go @@ -5,14 +5,6 @@ import ( sdkerrors "github.com/line/lbm-sdk/types/errors" ) -// NewGenesisState creates a new GenesisState object -func NewGenesisState(params *Params, validatorAuths []*ValidatorAuth) *GenesisState { - return &GenesisState{ - Params: params, - ValidatorAuths: validatorAuths, - } -} - // DefaultGenesisState creates a default GenesisState object func DefaultGenesisState() *GenesisState { return &GenesisState{