From 7a20fb056faa3e2a3bc07ecc6b517815065a2ee0 Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Mon, 3 Apr 2023 15:52:09 +0200 Subject: [PATCH 01/47] feat: update proto files --- proto/gaia/globalfee/v1beta1/genesis.proto | 4 + proto/gaia/globalfee/v1beta1/query.proto | 13 +- x/globalfee/types/genesis.pb.go | 141 +++++++++-- x/globalfee/types/query.pb.go | 266 ++++++++++++++------- x/globalfee/types/query.pb.gw.go | 28 +-- 5 files changed, 326 insertions(+), 126 deletions(-) diff --git a/proto/gaia/globalfee/v1beta1/genesis.proto b/proto/gaia/globalfee/v1beta1/genesis.proto index 39493b0c637..c986306cfb4 100644 --- a/proto/gaia/globalfee/v1beta1/genesis.proto +++ b/proto/gaia/globalfee/v1beta1/genesis.proto @@ -28,4 +28,8 @@ message Params { (gogoproto.moretags) = "yaml:\"minimum_gas_prices\"", (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins" ]; + + // bypass_min_fee_msg_types are setup for tx msgs free of fee charge + repeated string bypass_min_fee_msg_types = 2 [(gogoproto.moretags) = "yaml:\"bypass_min_fee_msg_types\""]; + uint64 max_total_bypass_minFee_msg_gas_usage = 3; } diff --git a/proto/gaia/globalfee/v1beta1/query.proto b/proto/gaia/globalfee/v1beta1/query.proto index 81f587c5bd5..98fb75be00d 100644 --- a/proto/gaia/globalfee/v1beta1/query.proto +++ b/proto/gaia/globalfee/v1beta1/query.proto @@ -9,24 +9,27 @@ option go_package = "github.com/cosmos/gaia/x/globalfee/types"; // Query defines the gRPC querier service. service Query { - rpc MinimumGasPrices(QueryMinimumGasPricesRequest) - returns (QueryMinimumGasPricesResponse) { + rpc Params(QueryParamsRequest) + returns (QueryParamsResponse) { option (google.api.http).get = - "/gaia/globalfee/v1beta1/minimum_gas_prices"; + "/gaia/globalfee/v1beta1/params"; } } // QueryMinimumGasPricesRequest is the request type for the // Query/MinimumGasPrices RPC method. -message QueryMinimumGasPricesRequest {} +message QueryParamsRequest {} // QueryMinimumGasPricesResponse is the response type for the // Query/MinimumGasPrices RPC method. -message QueryMinimumGasPricesResponse { +message QueryParamsResponse { repeated cosmos.base.v1beta1.DecCoin minimum_gas_prices = 1 [ (gogoproto.nullable) = false, (gogoproto.jsontag) = "minimum_gas_prices,omitempty", (gogoproto.moretags) = "yaml:\"minimum_gas_prices\"", (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins" ]; + + repeated string bypass_min_fee_msg_types = 2 [(gogoproto.moretags) = "yaml:\"bypass_min_fee_msg_types\""]; + uint64 max_total_bypass_minFee_msg_gas_usage = 3; } diff --git a/x/globalfee/types/genesis.pb.go b/x/globalfee/types/genesis.pb.go index bde069af626..8ea40614a80 100644 --- a/x/globalfee/types/genesis.pb.go +++ b/x/globalfee/types/genesis.pb.go @@ -79,6 +79,9 @@ type Params struct { // values allowed. For more information see // https://docs.cosmos.network/main/modules/auth#concepts MinimumGasPrices github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=minimum_gas_prices,json=minimumGasPrices,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"minimum_gas_prices,omitempty" yaml:"minimum_gas_prices"` + // bypass_min_fee_msg_types are setup for tx msgs free of fee charge + BypassMinFeeMsgTypes []string `protobuf:"bytes,2,rep,name=bypass_min_fee_msg_types,json=bypassMinFeeMsgTypes,proto3" json:"bypass_min_fee_msg_types,omitempty" yaml:"bypass_min_fee_msg_types"` + MaxTotalBypassMinFeeMsgGasUsage uint64 `protobuf:"varint,3,opt,name=max_total_bypass_minFee_msg_gas_usage,json=maxTotalBypassMinFeeMsgGasUsage,proto3" json:"max_total_bypass_minFee_msg_gas_usage,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -121,6 +124,20 @@ func (m *Params) GetMinimumGasPrices() github_com_cosmos_cosmos_sdk_types.DecCoi return nil } +func (m *Params) GetBypassMinFeeMsgTypes() []string { + if m != nil { + return m.BypassMinFeeMsgTypes + } + return nil +} + +func (m *Params) GetMaxTotalBypassMinFeeMsgGasUsage() uint64 { + if m != nil { + return m.MaxTotalBypassMinFeeMsgGasUsage + } + return 0 +} + func init() { proto.RegisterType((*GenesisState)(nil), "gaia.globalfee.v1beta1.GenesisState") proto.RegisterType((*Params)(nil), "gaia.globalfee.v1beta1.Params") @@ -131,28 +148,34 @@ func init() { } var fileDescriptor_015b3e8b7a7c65c5 = []byte{ - // 325 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0x31, 0x4b, 0x03, 0x31, - 0x14, 0xc7, 0x2f, 0x08, 0x1d, 0xae, 0x0e, 0xe5, 0x10, 0xa9, 0xa5, 0xe4, 0xe4, 0x70, 0x28, 0xa8, - 0x09, 0xad, 0x9b, 0xe3, 0x29, 0x74, 0x2d, 0x75, 0x73, 0xa9, 0xb9, 0x33, 0xc6, 0x60, 0x73, 0x09, - 0x4d, 0x2a, 0xf6, 0x5b, 0xf8, 0x39, 0xfc, 0x0c, 0xee, 0x76, 0xec, 0xe8, 0x54, 0xe5, 0x6e, 0x73, - 0xf4, 0x13, 0xc8, 0x25, 0x67, 0x2b, 0x9c, 0x53, 0x02, 0xef, 0xf7, 0x7e, 0xff, 0xc7, 0x7b, 0xfe, - 0x11, 0x23, 0x9c, 0x60, 0x36, 0x95, 0x09, 0x99, 0xde, 0x51, 0x8a, 0x1f, 0xfb, 0x09, 0x35, 0xa4, - 0x8f, 0x19, 0xcd, 0xa8, 0xe6, 0x1a, 0xa9, 0x99, 0x34, 0x32, 0xd8, 0x2f, 0x29, 0xb4, 0xa1, 0x50, - 0x45, 0x75, 0xf6, 0x98, 0x64, 0xd2, 0x22, 0xb8, 0xfc, 0x39, 0xba, 0x03, 0x53, 0xa9, 0x85, 0xd4, - 0x38, 0x21, 0x7a, 0x2b, 0x4c, 0x25, 0xcf, 0x5c, 0x3d, 0xba, 0xf1, 0x77, 0x87, 0x4e, 0x7f, 0x65, - 0x88, 0xa1, 0xc1, 0xc8, 0x6f, 0x28, 0x32, 0x23, 0x42, 0xb7, 0xc1, 0x21, 0xe8, 0x35, 0x07, 0x10, - 0xfd, 0x1f, 0x87, 0x46, 0x96, 0x8a, 0xdb, 0xcb, 0x75, 0xe8, 0x7d, 0xad, 0xc3, 0x96, 0xeb, 0x3a, - 0x91, 0x82, 0x1b, 0x2a, 0x94, 0x59, 0x8c, 0x2b, 0x4f, 0xf4, 0x06, 0xfc, 0x86, 0x83, 0x83, 0x57, - 0xe0, 0x07, 0x82, 0x67, 0x5c, 0xcc, 0xc5, 0x84, 0x11, 0x3d, 0x51, 0x33, 0x9e, 0xd2, 0x32, 0x69, - 0xa7, 0xd7, 0x1c, 0x74, 0x91, 0x1b, 0x15, 0x95, 0xa3, 0x6e, 0x62, 0x2e, 0x69, 0x7a, 0x21, 0x79, - 0x16, 0xab, 0x2a, 0xa7, 0x5b, 0xef, 0xdf, 0x66, 0x7e, 0xaf, 0xc3, 0x83, 0x05, 0x11, 0xd3, 0xf3, - 0xa8, 0x4e, 0x45, 0x2f, 0x1f, 0xe1, 0x31, 0xe3, 0xe6, 0x7e, 0x9e, 0xa0, 0x54, 0x0a, 0x5c, 0xed, - 0xc5, 0x3d, 0xa7, 0xfa, 0xf6, 0x01, 0x9b, 0x85, 0xa2, 0xfa, 0x37, 0x50, 0x8f, 0x5b, 0x95, 0x63, - 0x48, 0xf4, 0xc8, 0x1a, 0xe2, 0x78, 0x99, 0x43, 0xb0, 0xca, 0x21, 0xf8, 0xcc, 0x21, 0x78, 0x2e, - 0xa0, 0xb7, 0x2a, 0xa0, 0xf7, 0x5e, 0x40, 0xef, 0xba, 0x57, 0x17, 0xdb, 0x5b, 0x3e, 0xfd, 0xb9, - 0xa6, 0xd5, 0x27, 0x0d, 0xbb, 0xf6, 0xb3, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x48, 0x6d, 0x01, - 0xcd, 0xec, 0x01, 0x00, 0x00, + // 422 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0x4d, 0x6e, 0xd3, 0x40, + 0x14, 0xc7, 0xe3, 0x06, 0x45, 0xc2, 0x65, 0x51, 0x59, 0x15, 0x32, 0x55, 0x35, 0x8e, 0x0c, 0x48, + 0x96, 0x80, 0xb1, 0x5a, 0x76, 0x2c, 0x0d, 0x6a, 0x56, 0x45, 0x51, 0x28, 0x1b, 0x58, 0x0c, 0xcf, + 0x66, 0x3a, 0x8c, 0xf0, 0x78, 0xac, 0xbc, 0x09, 0x8a, 0x6f, 0xc1, 0x39, 0x38, 0x03, 0x07, 0xe8, + 0xb2, 0x4b, 0x56, 0x06, 0x25, 0x3b, 0x96, 0x15, 0x07, 0x40, 0xe3, 0x31, 0x0d, 0x28, 0x74, 0x65, + 0xcb, 0xef, 0xf7, 0xff, 0xf0, 0xd3, 0xf3, 0x1f, 0x08, 0x90, 0x90, 0x8a, 0x52, 0xe7, 0x50, 0x9e, + 0x73, 0x9e, 0x7e, 0x3a, 0xca, 0xb9, 0x81, 0xa3, 0x54, 0xf0, 0x8a, 0xa3, 0x44, 0x5a, 0xcf, 0xb5, + 0xd1, 0xc1, 0x5d, 0x4b, 0xd1, 0x6b, 0x8a, 0xf6, 0xd4, 0xc1, 0xbe, 0xd0, 0x42, 0x77, 0x48, 0x6a, + 0xdf, 0x1c, 0x7d, 0x40, 0x0a, 0x8d, 0x4a, 0x63, 0x9a, 0x03, 0x6e, 0x0c, 0x0b, 0x2d, 0x2b, 0x37, + 0x8f, 0xdf, 0xf9, 0x77, 0x26, 0xce, 0xfe, 0x95, 0x01, 0xc3, 0x83, 0xa9, 0x3f, 0xaa, 0x61, 0x0e, + 0x0a, 0x43, 0x6f, 0xec, 0x25, 0xbb, 0xc7, 0x84, 0xfe, 0x3f, 0x8e, 0x4e, 0x3b, 0x2a, 0x0b, 0x2f, + 0xda, 0x68, 0xf0, 0xb3, 0x8d, 0xf6, 0x9c, 0xea, 0xb1, 0x56, 0xd2, 0x70, 0x55, 0x9b, 0x66, 0xd6, + 0xfb, 0xc4, 0xbf, 0x76, 0xfc, 0x91, 0x83, 0x83, 0xaf, 0x9e, 0x1f, 0x28, 0x59, 0x49, 0xb5, 0x50, + 0x4c, 0x00, 0xb2, 0x7a, 0x2e, 0x0b, 0x6e, 0x93, 0x86, 0xc9, 0xee, 0xf1, 0x21, 0x75, 0x55, 0xa9, + 0xad, 0x7a, 0x1d, 0xf3, 0x82, 0x17, 0xcf, 0xb5, 0xac, 0xb2, 0xba, 0xcf, 0x39, 0xdc, 0xd6, 0x6f, + 0x32, 0xaf, 0xda, 0xe8, 0x5e, 0x03, 0xaa, 0x7c, 0x16, 0x6f, 0x53, 0xf1, 0x97, 0xef, 0xd1, 0x23, + 0x21, 0xcd, 0x87, 0x45, 0x4e, 0x0b, 0xad, 0xd2, 0x7e, 0x2f, 0xee, 0xf1, 0x04, 0xdf, 0x7f, 0x4c, + 0x4d, 0x53, 0x73, 0xfc, 0x13, 0x88, 0xb3, 0xbd, 0xde, 0x63, 0x02, 0x38, 0xed, 0x1c, 0x82, 0xb7, + 0x7e, 0x98, 0x37, 0x35, 0x20, 0x32, 0x25, 0x2b, 0x76, 0xce, 0x39, 0x53, 0x28, 0x58, 0x27, 0x0b, + 0x77, 0xc6, 0xc3, 0xe4, 0x76, 0x76, 0xff, 0xaa, 0x8d, 0x22, 0xd7, 0xe0, 0x26, 0x32, 0x9e, 0xed, + 0xbb, 0xd1, 0xa9, 0xac, 0x4e, 0x38, 0x3f, 0x45, 0x71, 0x66, 0x3f, 0x07, 0x2f, 0xfd, 0x87, 0x0a, + 0x96, 0xcc, 0x68, 0x03, 0x25, 0xdb, 0x88, 0x4f, 0x7a, 0xad, 0xfd, 0x91, 0x05, 0x82, 0xe0, 0xe1, + 0x70, 0xec, 0x25, 0xb7, 0x66, 0x91, 0x82, 0xe5, 0x99, 0x65, 0xb3, 0x7f, 0xcd, 0x26, 0x80, 0xaf, + 0x2d, 0x96, 0x65, 0x17, 0x2b, 0xe2, 0x5d, 0xae, 0x88, 0xf7, 0x63, 0x45, 0xbc, 0xcf, 0x6b, 0x32, + 0xb8, 0x5c, 0x93, 0xc1, 0xb7, 0x35, 0x19, 0xbc, 0x49, 0xb6, 0xb7, 0xd0, 0x1d, 0xde, 0xf2, 0xaf, + 0xd3, 0xeb, 0xaa, 0xe6, 0xa3, 0xee, 0x46, 0x9e, 0xfe, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x30, 0x6f, + 0x78, 0xaa, 0x99, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -208,6 +231,20 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.MaxTotalBypassMinFeeMsgGasUsage != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.MaxTotalBypassMinFeeMsgGasUsage)) + i-- + dAtA[i] = 0x18 + } + if len(m.BypassMinFeeMsgTypes) > 0 { + for iNdEx := len(m.BypassMinFeeMsgTypes) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.BypassMinFeeMsgTypes[iNdEx]) + copy(dAtA[i:], m.BypassMinFeeMsgTypes[iNdEx]) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.BypassMinFeeMsgTypes[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } if len(m.MinimumGasPrices) > 0 { for iNdEx := len(m.MinimumGasPrices) - 1; iNdEx >= 0; iNdEx-- { { @@ -259,6 +296,15 @@ func (m *Params) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.BypassMinFeeMsgTypes) > 0 { + for _, s := range m.BypassMinFeeMsgTypes { + l = len(s) + n += 1 + l + sovGenesis(uint64(l)) + } + } + if m.MaxTotalBypassMinFeeMsgGasUsage != 0 { + n += 1 + sovGenesis(uint64(m.MaxTotalBypassMinFeeMsgGasUsage)) + } return n } @@ -414,6 +460,57 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BypassMinFeeMsgTypes", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BypassMinFeeMsgTypes = append(m.BypassMinFeeMsgTypes, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxTotalBypassMinFeeMsgGasUsage", wireType) + } + m.MaxTotalBypassMinFeeMsgGasUsage = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxTotalBypassMinFeeMsgGasUsage |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/globalfee/types/query.pb.go b/x/globalfee/types/query.pb.go index 569b6975be4..2060acd3a87 100644 --- a/x/globalfee/types/query.pb.go +++ b/x/globalfee/types/query.pb.go @@ -33,21 +33,21 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // QueryMinimumGasPricesRequest is the request type for the // Query/MinimumGasPrices RPC method. -type QueryMinimumGasPricesRequest struct { +type QueryParamsRequest struct { } -func (m *QueryMinimumGasPricesRequest) Reset() { *m = QueryMinimumGasPricesRequest{} } -func (m *QueryMinimumGasPricesRequest) String() string { return proto.CompactTextString(m) } -func (*QueryMinimumGasPricesRequest) ProtoMessage() {} -func (*QueryMinimumGasPricesRequest) Descriptor() ([]byte, []int) { +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_12a736cede25d10a, []int{0} } -func (m *QueryMinimumGasPricesRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryMinimumGasPricesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryMinimumGasPricesRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -57,36 +57,38 @@ func (m *QueryMinimumGasPricesRequest) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *QueryMinimumGasPricesRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryMinimumGasPricesRequest.Merge(m, src) +func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) } -func (m *QueryMinimumGasPricesRequest) XXX_Size() int { +func (m *QueryParamsRequest) XXX_Size() int { return m.Size() } -func (m *QueryMinimumGasPricesRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryMinimumGasPricesRequest.DiscardUnknown(m) +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryMinimumGasPricesRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo // QueryMinimumGasPricesResponse is the response type for the // Query/MinimumGasPrices RPC method. -type QueryMinimumGasPricesResponse struct { - MinimumGasPrices github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=minimum_gas_prices,json=minimumGasPrices,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"minimum_gas_prices,omitempty" yaml:"minimum_gas_prices"` +type QueryParamsResponse struct { + MinimumGasPrices github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=minimum_gas_prices,json=minimumGasPrices,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"minimum_gas_prices,omitempty" yaml:"minimum_gas_prices"` + BypassMinFeeMsgTypes []string `protobuf:"bytes,2,rep,name=bypass_min_fee_msg_types,json=bypassMinFeeMsgTypes,proto3" json:"bypass_min_fee_msg_types,omitempty" yaml:"bypass_min_fee_msg_types"` + MaxTotalBypassMinFeeMsgGasUsage uint64 `protobuf:"varint,3,opt,name=max_total_bypass_minFee_msg_gas_usage,json=maxTotalBypassMinFeeMsgGasUsage,proto3" json:"max_total_bypass_minFee_msg_gas_usage,omitempty"` } -func (m *QueryMinimumGasPricesResponse) Reset() { *m = QueryMinimumGasPricesResponse{} } -func (m *QueryMinimumGasPricesResponse) String() string { return proto.CompactTextString(m) } -func (*QueryMinimumGasPricesResponse) ProtoMessage() {} -func (*QueryMinimumGasPricesResponse) Descriptor() ([]byte, []int) { +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_12a736cede25d10a, []int{1} } -func (m *QueryMinimumGasPricesResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryMinimumGasPricesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryMinimumGasPricesResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -96,28 +98,42 @@ func (m *QueryMinimumGasPricesResponse) XXX_Marshal(b []byte, deterministic bool return b[:n], nil } } -func (m *QueryMinimumGasPricesResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryMinimumGasPricesResponse.Merge(m, src) +func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) } -func (m *QueryMinimumGasPricesResponse) XXX_Size() int { +func (m *QueryParamsResponse) XXX_Size() int { return m.Size() } -func (m *QueryMinimumGasPricesResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryMinimumGasPricesResponse.DiscardUnknown(m) +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryMinimumGasPricesResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo -func (m *QueryMinimumGasPricesResponse) GetMinimumGasPrices() github_com_cosmos_cosmos_sdk_types.DecCoins { +func (m *QueryParamsResponse) GetMinimumGasPrices() github_com_cosmos_cosmos_sdk_types.DecCoins { if m != nil { return m.MinimumGasPrices } return nil } +func (m *QueryParamsResponse) GetBypassMinFeeMsgTypes() []string { + if m != nil { + return m.BypassMinFeeMsgTypes + } + return nil +} + +func (m *QueryParamsResponse) GetMaxTotalBypassMinFeeMsgGasUsage() uint64 { + if m != nil { + return m.MaxTotalBypassMinFeeMsgGasUsage + } + return 0 +} + func init() { - proto.RegisterType((*QueryMinimumGasPricesRequest)(nil), "gaia.globalfee.v1beta1.QueryMinimumGasPricesRequest") - proto.RegisterType((*QueryMinimumGasPricesResponse)(nil), "gaia.globalfee.v1beta1.QueryMinimumGasPricesResponse") + proto.RegisterType((*QueryParamsRequest)(nil), "gaia.globalfee.v1beta1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "gaia.globalfee.v1beta1.QueryParamsResponse") } func init() { @@ -125,31 +141,37 @@ func init() { } var fileDescriptor_12a736cede25d10a = []byte{ - // 377 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xb1, 0x4f, 0xdb, 0x40, - 0x14, 0xc6, 0x7d, 0xad, 0xda, 0xc1, 0x5d, 0x22, 0xab, 0xaa, 0xda, 0xc8, 0x3d, 0x57, 0x9e, 0xa2, - 0x36, 0xbd, 0x53, 0xd2, 0x76, 0xe9, 0x98, 0x56, 0x62, 0x42, 0x82, 0x8c, 0x2c, 0xd1, 0xd9, 0x1c, - 0xc7, 0x09, 0x9f, 0x9f, 0x93, 0x3b, 0x23, 0xbc, 0xf2, 0x17, 0x20, 0xf1, 0x5f, 0xb0, 0xb2, 0xc2, - 0x9e, 0x31, 0x12, 0x0b, 0x93, 0x41, 0x09, 0x13, 0x23, 0x7f, 0x01, 0xb2, 0x9d, 0x00, 0x8a, 0x09, - 0x12, 0x93, 0x2d, 0x7d, 0xbf, 0xf7, 0x3e, 0x7d, 0xdf, 0x3d, 0xdb, 0x17, 0x4c, 0x32, 0x2a, 0x22, - 0x08, 0x58, 0xb4, 0xc3, 0x39, 0xdd, 0xef, 0x04, 0xdc, 0xb0, 0x0e, 0x1d, 0xa6, 0x7c, 0x94, 0x91, - 0x64, 0x04, 0x06, 0x9c, 0x4f, 0x05, 0x43, 0x1e, 0x18, 0x32, 0x67, 0x9a, 0x1f, 0x05, 0x08, 0x28, - 0x11, 0x5a, 0xfc, 0x55, 0x74, 0xd3, 0x15, 0x00, 0x22, 0xe2, 0x94, 0x25, 0x92, 0xb2, 0x38, 0x06, - 0xc3, 0x8c, 0x84, 0x58, 0xcf, 0x55, 0x1c, 0x82, 0x56, 0xa0, 0x69, 0xc0, 0xf4, 0xa3, 0x59, 0x08, - 0x32, 0xae, 0x74, 0x1f, 0xdb, 0xee, 0x66, 0x61, 0xbd, 0x2e, 0x63, 0xa9, 0x52, 0xb5, 0xc6, 0xf4, - 0xc6, 0x48, 0x86, 0x5c, 0xf7, 0xf9, 0x30, 0xe5, 0xda, 0xf8, 0x39, 0xb2, 0xbf, 0xae, 0x00, 0x74, - 0x02, 0xb1, 0xe6, 0xce, 0x19, 0xb2, 0x1d, 0x55, 0x89, 0x03, 0xc1, 0xf4, 0x20, 0x29, 0xe5, 0xcf, - 0xe8, 0xdb, 0xdb, 0xd6, 0x87, 0xae, 0x4b, 0x2a, 0x7f, 0x52, 0xf8, 0x2f, 0x82, 0x90, 0xff, 0x3c, - 0xfc, 0x07, 0x32, 0xee, 0x25, 0xe3, 0xdc, 0xb3, 0x6e, 0x73, 0xcf, 0xad, 0xcf, 0xb7, 0x41, 0x49, - 0xc3, 0x55, 0x62, 0xb2, 0xbb, 0xdc, 0xfb, 0x92, 0x31, 0x15, 0xfd, 0xf5, 0xeb, 0x94, 0x7f, 0x72, - 0xe5, 0xfd, 0x10, 0xd2, 0xec, 0xa6, 0x01, 0x09, 0x41, 0xd1, 0x79, 0xd8, 0xea, 0xf3, 0x53, 0x6f, - 0xef, 0x51, 0x93, 0x25, 0x5c, 0x2f, 0x0c, 0x75, 0xbf, 0xa1, 0x96, 0x62, 0x74, 0xcf, 0x91, 0xfd, - 0xae, 0x0c, 0xe8, 0x9c, 0x22, 0xbb, 0xb1, 0x9c, 0xd2, 0xf9, 0x4d, 0x9e, 0x7f, 0x0c, 0xf2, 0x52, - 0x6b, 0xcd, 0x3f, 0xaf, 0x9c, 0xaa, 0xaa, 0xf4, 0xbb, 0x87, 0x17, 0x37, 0xc7, 0x6f, 0xda, 0xce, - 0x77, 0xba, 0xe2, 0x4a, 0xea, 0x0d, 0xf4, 0x7a, 0xe3, 0x29, 0x46, 0x93, 0x29, 0x46, 0xd7, 0x53, - 0x8c, 0x8e, 0x66, 0xd8, 0x9a, 0xcc, 0xb0, 0x75, 0x39, 0xc3, 0xd6, 0x56, 0xab, 0x5e, 0x4c, 0xb9, - 0xf6, 0xe0, 0xc9, 0xe2, 0xb2, 0x9e, 0xe0, 0x7d, 0x79, 0x0b, 0xbf, 0xee, 0x03, 0x00, 0x00, 0xff, - 0xff, 0x73, 0x0d, 0xf8, 0x43, 0x9d, 0x02, 0x00, 0x00, + // 468 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xbf, 0x6e, 0x13, 0x41, + 0x10, 0xc6, 0x7d, 0x31, 0x44, 0xe2, 0x68, 0xd0, 0x62, 0x21, 0x63, 0x59, 0x77, 0xd6, 0x21, 0x90, + 0x45, 0x60, 0x57, 0x09, 0x1d, 0xe5, 0x81, 0x92, 0x2a, 0x28, 0x58, 0xa1, 0x81, 0xe2, 0x34, 0x77, + 0x6c, 0x96, 0x15, 0xb7, 0x7f, 0xe2, 0xd9, 0x43, 0xbe, 0x12, 0x3a, 0x3a, 0xa4, 0xbc, 0x05, 0xcf, + 0xc0, 0x03, 0xa4, 0x8c, 0x44, 0x43, 0x65, 0x90, 0x4d, 0x45, 0x99, 0x27, 0x40, 0xf7, 0x27, 0x84, + 0xc8, 0x44, 0xa2, 0xba, 0xd3, 0xce, 0x6f, 0xbe, 0x6f, 0x67, 0xbf, 0xf1, 0x23, 0x01, 0x12, 0x98, + 0xc8, 0x4d, 0x0a, 0xf9, 0x01, 0xe7, 0xec, 0xdd, 0x66, 0xca, 0x1d, 0x6c, 0xb2, 0xc3, 0x82, 0x4f, + 0x4b, 0x6a, 0xa7, 0xc6, 0x19, 0x72, 0xab, 0x62, 0xe8, 0x1f, 0x86, 0xb6, 0xcc, 0xa0, 0x27, 0x8c, + 0x30, 0x35, 0xc2, 0xaa, 0xbf, 0x86, 0x1e, 0x0c, 0x85, 0x31, 0x22, 0xe7, 0x0c, 0xac, 0x64, 0xa0, + 0xb5, 0x71, 0xe0, 0xa4, 0xd1, 0xd8, 0x56, 0x83, 0xcc, 0xa0, 0x32, 0xc8, 0x52, 0xc0, 0x73, 0xb3, + 0xcc, 0x48, 0xdd, 0xd4, 0xa3, 0x9e, 0x4f, 0x9e, 0x57, 0xd6, 0x7b, 0x30, 0x05, 0x85, 0x13, 0x7e, + 0x58, 0x70, 0x74, 0xd1, 0xfb, 0xae, 0x7f, 0xf3, 0xc2, 0x31, 0x5a, 0xa3, 0x91, 0x93, 0x2f, 0x9e, + 0x4f, 0x94, 0xd4, 0x52, 0x15, 0x2a, 0x11, 0x80, 0x89, 0x9d, 0xca, 0x8c, 0x63, 0xdf, 0x1b, 0x75, + 0xc7, 0xd7, 0xb7, 0x86, 0xb4, 0xf1, 0xa2, 0x95, 0xd7, 0xd9, 0xa5, 0xe9, 0x53, 0x9e, 0x3d, 0x31, + 0x52, 0xc7, 0xf6, 0x78, 0x1e, 0x76, 0x7e, 0xcd, 0xc3, 0xe1, 0x6a, 0xff, 0x03, 0xa3, 0xa4, 0xe3, + 0xca, 0xba, 0xf2, 0x74, 0x1e, 0xde, 0x2e, 0x41, 0xe5, 0x8f, 0xa3, 0x55, 0x2a, 0xfa, 0xfc, 0x3d, + 0xdc, 0x10, 0xd2, 0xbd, 0x29, 0x52, 0x9a, 0x19, 0xc5, 0xda, 0xc1, 0x9a, 0xcf, 0x43, 0x7c, 0xfd, + 0x96, 0xb9, 0xd2, 0x72, 0x3c, 0x33, 0xc4, 0xc9, 0x8d, 0x56, 0x63, 0x07, 0x70, 0xaf, 0x56, 0x20, + 0xaf, 0xfc, 0x7e, 0x5a, 0x5a, 0x40, 0x4c, 0x94, 0xd4, 0xc9, 0x01, 0xe7, 0x89, 0x42, 0x91, 0xd4, + 0x6d, 0xfd, 0xb5, 0x51, 0x77, 0x7c, 0x2d, 0xbe, 0x73, 0x3a, 0x0f, 0xc3, 0xe6, 0x06, 0x97, 0x91, + 0xd1, 0xa4, 0xd7, 0x94, 0x76, 0xa5, 0xde, 0xe6, 0x7c, 0x17, 0xc5, 0x7e, 0x75, 0x4c, 0x9e, 0xf9, + 0x77, 0x15, 0xcc, 0x12, 0x67, 0x1c, 0xe4, 0xc9, 0x79, 0xf3, 0x76, 0xdb, 0x5b, 0x0d, 0x52, 0x20, + 0x08, 0xde, 0xef, 0x8e, 0xbc, 0xf1, 0x95, 0x49, 0xa8, 0x60, 0xb6, 0x5f, 0xb1, 0xf1, 0x45, 0xb1, + 0x1d, 0xc0, 0x17, 0x15, 0xb6, 0x75, 0xe4, 0xf9, 0x57, 0xeb, 0x0c, 0xc8, 0x47, 0xcf, 0x5f, 0x6f, + 0x82, 0x20, 0xf7, 0xe9, 0xbf, 0x77, 0x83, 0xae, 0x86, 0x38, 0xd8, 0xf8, 0x2f, 0xb6, 0x49, 0x36, + 0xba, 0xf7, 0xe1, 0xeb, 0xcf, 0xa3, 0xb5, 0x11, 0x09, 0xd8, 0x25, 0x0b, 0x6a, 0x6b, 0x3e, 0x8e, + 0x8f, 0x17, 0x81, 0x77, 0xb2, 0x08, 0xbc, 0x1f, 0x8b, 0xc0, 0xfb, 0xb4, 0x0c, 0x3a, 0x27, 0xcb, + 0xa0, 0xf3, 0x6d, 0x19, 0x74, 0x5e, 0x8e, 0x57, 0xb3, 0xa9, 0xa5, 0x66, 0x7f, 0x89, 0xd5, 0x0f, + 0x98, 0xae, 0xd7, 0xab, 0xf7, 0xe8, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6f, 0x37, 0x8f, 0x3d, + 0x0c, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -164,7 +186,7 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { - MinimumGasPrices(ctx context.Context, in *QueryMinimumGasPricesRequest, opts ...grpc.CallOption) (*QueryMinimumGasPricesResponse, error) + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) } type queryClient struct { @@ -175,9 +197,9 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } -func (c *queryClient) MinimumGasPrices(ctx context.Context, in *QueryMinimumGasPricesRequest, opts ...grpc.CallOption) (*QueryMinimumGasPricesResponse, error) { - out := new(QueryMinimumGasPricesResponse) - err := c.cc.Invoke(ctx, "/gaia.globalfee.v1beta1.Query/MinimumGasPrices", in, out, opts...) +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/gaia.globalfee.v1beta1.Query/Params", in, out, opts...) if err != nil { return nil, err } @@ -186,35 +208,35 @@ func (c *queryClient) MinimumGasPrices(ctx context.Context, in *QueryMinimumGasP // QueryServer is the server API for Query service. type QueryServer interface { - MinimumGasPrices(context.Context, *QueryMinimumGasPricesRequest) (*QueryMinimumGasPricesResponse, error) + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. type UnimplementedQueryServer struct { } -func (*UnimplementedQueryServer) MinimumGasPrices(ctx context.Context, req *QueryMinimumGasPricesRequest) (*QueryMinimumGasPricesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method MinimumGasPrices not implemented") +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } -func _Query_MinimumGasPrices_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryMinimumGasPricesRequest) +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).MinimumGasPrices(ctx, in) + return srv.(QueryServer).Params(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/gaia.globalfee.v1beta1.Query/MinimumGasPrices", + FullMethod: "/gaia.globalfee.v1beta1.Query/Params", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).MinimumGasPrices(ctx, req.(*QueryMinimumGasPricesRequest)) + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) } return interceptor(ctx, in, info, handler) } @@ -224,15 +246,15 @@ var _Query_serviceDesc = grpc.ServiceDesc{ HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "MinimumGasPrices", - Handler: _Query_MinimumGasPrices_Handler, + MethodName: "Params", + Handler: _Query_Params_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "gaia/globalfee/v1beta1/query.proto", } -func (m *QueryMinimumGasPricesRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -242,12 +264,12 @@ func (m *QueryMinimumGasPricesRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryMinimumGasPricesRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryMinimumGasPricesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -255,7 +277,7 @@ func (m *QueryMinimumGasPricesRequest) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } -func (m *QueryMinimumGasPricesResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -265,16 +287,30 @@ func (m *QueryMinimumGasPricesResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryMinimumGasPricesResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryMinimumGasPricesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l + if m.MaxTotalBypassMinFeeMsgGasUsage != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.MaxTotalBypassMinFeeMsgGasUsage)) + i-- + dAtA[i] = 0x18 + } + if len(m.BypassMinFeeMsgTypes) > 0 { + for iNdEx := len(m.BypassMinFeeMsgTypes) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.BypassMinFeeMsgTypes[iNdEx]) + copy(dAtA[i:], m.BypassMinFeeMsgTypes[iNdEx]) + i = encodeVarintQuery(dAtA, i, uint64(len(m.BypassMinFeeMsgTypes[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } if len(m.MinimumGasPrices) > 0 { for iNdEx := len(m.MinimumGasPrices) - 1; iNdEx >= 0; iNdEx-- { { @@ -303,7 +339,7 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *QueryMinimumGasPricesRequest) Size() (n int) { +func (m *QueryParamsRequest) Size() (n int) { if m == nil { return 0 } @@ -312,7 +348,7 @@ func (m *QueryMinimumGasPricesRequest) Size() (n int) { return n } -func (m *QueryMinimumGasPricesResponse) Size() (n int) { +func (m *QueryParamsResponse) Size() (n int) { if m == nil { return 0 } @@ -324,6 +360,15 @@ func (m *QueryMinimumGasPricesResponse) Size() (n int) { n += 1 + l + sovQuery(uint64(l)) } } + if len(m.BypassMinFeeMsgTypes) > 0 { + for _, s := range m.BypassMinFeeMsgTypes { + l = len(s) + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.MaxTotalBypassMinFeeMsgGasUsage != 0 { + n += 1 + sovQuery(uint64(m.MaxTotalBypassMinFeeMsgGasUsage)) + } return n } @@ -333,7 +378,7 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *QueryMinimumGasPricesRequest) Unmarshal(dAtA []byte) error { +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -356,10 +401,10 @@ func (m *QueryMinimumGasPricesRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryMinimumGasPricesRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryMinimumGasPricesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -383,7 +428,7 @@ func (m *QueryMinimumGasPricesRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryMinimumGasPricesResponse) Unmarshal(dAtA []byte) error { +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -406,10 +451,10 @@ func (m *QueryMinimumGasPricesResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryMinimumGasPricesResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryMinimumGasPricesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -446,6 +491,57 @@ func (m *QueryMinimumGasPricesResponse) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BypassMinFeeMsgTypes", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BypassMinFeeMsgTypes = append(m.BypassMinFeeMsgTypes, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxTotalBypassMinFeeMsgGasUsage", wireType) + } + m.MaxTotalBypassMinFeeMsgGasUsage = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxTotalBypassMinFeeMsgGasUsage |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/globalfee/types/query.pb.gw.go b/x/globalfee/types/query.pb.gw.go index 0e33d9df1a5..5a24a95a0ca 100644 --- a/x/globalfee/types/query.pb.gw.go +++ b/x/globalfee/types/query.pb.gw.go @@ -33,20 +33,20 @@ var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage var _ = metadata.Join -func request_Query_MinimumGasPrices_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryMinimumGasPricesRequest +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest var metadata runtime.ServerMetadata - msg, err := client.MinimumGasPrices(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_MinimumGasPrices_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryMinimumGasPricesRequest +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest var metadata runtime.ServerMetadata - msg, err := server.MinimumGasPrices(ctx, &protoReq) + msg, err := server.Params(ctx, &protoReq) return msg, metadata, err } @@ -57,7 +57,7 @@ func local_request_Query_MinimumGasPrices_0(ctx context.Context, marshaler runti // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - mux.Handle("GET", pattern_Query_MinimumGasPrices_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -68,7 +68,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_MinimumGasPrices_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -76,7 +76,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_MinimumGasPrices_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -121,7 +121,7 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - mux.Handle("GET", pattern_Query_MinimumGasPrices_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -130,14 +130,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_MinimumGasPrices_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_MinimumGasPrices_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -145,9 +145,9 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_MinimumGasPrices_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"gaia", "globalfee", "v1beta1", "minimum_gas_prices"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"gaia", "globalfee", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( - forward_Query_MinimumGasPrices_0 = runtime.ForwardResponseMessage + forward_Query_Params_0 = runtime.ForwardResponseMessage ) From 92eb6f1b1bbbe45547fa11192cb011922adf730b Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Mon, 3 Apr 2023 15:52:54 +0200 Subject: [PATCH 02/47] feat: update proto-docs --- docs/proto/proto-docs.md | 61 ++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 15 deletions(-) diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index 42172f01b1e..4333ca9a308 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -1,44 +1,57 @@ # Protobuf Documentation - ## Table of Contents - [gaia/globalfee/v1beta1/query.proto](#gaia/globalfee/v1beta1/query.proto) - - [QueryMinimumGasPricesRequest](#gaia.globalfee.v1beta1.QueryMinimumGasPricesRequest) - - [QueryMinimumGasPricesResponse](#gaia.globalfee.v1beta1.QueryMinimumGasPricesResponse) + - [QueryParamsRequest](#gaia.globalfee.v1beta1.QueryParamsRequest) + - [QueryParamsResponse](#gaia.globalfee.v1beta1.QueryParamsResponse) - - [Query](#gaia.globalfee.v1beta1.Query) + - [Query](#gaia.globalfee.v1beta1.Query) - [gaia/globalfee/v1beta1/genesis.proto](#gaia/globalfee/v1beta1/genesis.proto) - - [GenesisState](#gaia.globalfee.v1beta1.GenesisState) - - [Params](#gaia.globalfee.v1beta1.Params) + - [GenesisState](#gaia.globalfee.v1beta1.GenesisState) + - [Params](#gaia.globalfee.v1beta1.Params) - [Scalar Value Types](#scalar-value-types) + +

Top

## gaia/globalfee/v1beta1/query.proto - -### QueryMinimumGasPricesRequest + + +### QueryParamsRequest QueryMinimumGasPricesRequest is the request type for the Query/MinimumGasPrices RPC method. - -### QueryMinimumGasPricesResponse + + + + + +### QueryParamsResponse QueryMinimumGasPricesResponse is the response type for the Query/MinimumGasPrices RPC method. + | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `minimum_gas_prices` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | | +| `bypass_min_fee_msg_types` | [string](#string) | repeated | | +| `max_total_bypass_minFee_msg_gas_usage` | [uint64](#uint64) | | | + + + + @@ -46,42 +59,57 @@ Query/MinimumGasPrices RPC method. + ### Query - Query defines the gRPC querier service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `MinimumGasPrices` | [QueryMinimumGasPricesRequest](#gaia.globalfee.v1beta1.QueryMinimumGasPricesRequest) | [QueryMinimumGasPricesResponse](#gaia.globalfee.v1beta1.QueryMinimumGasPricesResponse) | | GET|/gaia/globalfee/v1beta1/minimum_gas_prices| +| `Params` | [QueryParamsRequest](#gaia.globalfee.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#gaia.globalfee.v1beta1.QueryParamsResponse) | | GET|/gaia/globalfee/v1beta1/params| + +

Top

## gaia/globalfee/v1beta1/genesis.proto + + ### GenesisState - GenesisState - initial state of module + | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `params` | [Params](#gaia.globalfee.v1beta1.Params) | | Params of this module | + + + + + ### Params - Params defines the set of module parameters. + | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `minimum_gas_prices` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | Minimum stores the minimum gas price(s) for all TX on the chain. When multiple coins are defined then they are accepted alternatively. The list must be sorted by denoms asc. No duplicate denoms or zero amount values allowed. For more information see | +| `minimum_gas_prices` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | Minimum stores the minimum gas price(s) for all TX on the chain. When multiple coins are defined then they are accepted alternatively. The list must be sorted by denoms asc. No duplicate denoms or zero amount values allowed. For more information see https://docs.cosmos.network/main/modules/auth#concepts | +| `bypass_min_fee_msg_types` | [string](#string) | repeated | bypass_min_fee_msg_types are setup for tx msgs free of fee charge | +| `max_total_bypass_minFee_msg_gas_usage` | [uint64](#uint64) | | | + + + + @@ -91,6 +119,8 @@ Params defines the set of module parameters. + + ## Scalar Value Types | .proto Type | Notes | C++ | Java | Python | Go | C# | PHP | Ruby | @@ -110,3 +140,4 @@ Params defines the set of module parameters. | bool | | bool | boolean | boolean | bool | bool | boolean | TrueClass/FalseClass | | string | A string must always contain UTF-8 encoded or 7-bit ASCII text. | string | String | str/unicode | string | string | string | String (UTF-8) | | bytes | May contain any arbitrary sequence of bytes. | string | ByteString | str | []byte | ByteString | string | String (ASCII-8BIT) | + From 94906dfa0b20caa0f9f59db6f9ac5159216f94a7 Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Mon, 3 Apr 2023 16:05:21 +0200 Subject: [PATCH 03/47] refactor: update query request and response --- tests/e2e/query.go | 2 +- x/globalfee/client/cli/query.go | 13 +++++++------ x/globalfee/querier.go | 18 +++++++++++++++--- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/tests/e2e/query.go b/tests/e2e/query.go index e2b7816814d..e6f513a7ced 100644 --- a/tests/e2e/query.go +++ b/tests/e2e/query.go @@ -80,7 +80,7 @@ func queryGlobalFees(endpoint string) (amt sdk.DecCoins, err error) { return nil, fmt.Errorf("failed to execute HTTP request: %w", err) } - var fees globalfee.QueryMinimumGasPricesResponse + var fees globalfee.QueryParamsResponse if err := cdc.UnmarshalJSON(body, &fees); err != nil { return sdk.DecCoins{}, err } diff --git a/x/globalfee/client/cli/query.go b/x/globalfee/client/cli/query.go index be6894a9d5c..3a247320301 100644 --- a/x/globalfee/client/cli/query.go +++ b/x/globalfee/client/cli/query.go @@ -24,11 +24,12 @@ func GetQueryCmd() *cobra.Command { func GetCmdShowMinimumGasPrices() *cobra.Command { cmd := &cobra.Command{ - Use: "minimum-gas-prices", - Short: "Show minimum gas prices", - Long: "Show all minimum gas prices", - Aliases: []string{"min"}, - Args: cobra.ExactArgs(0), + Use: "params", + Short: "Show globalfee params", + // todo check here + Long: "Show globalfee requirement: minimum_gas_prices, bypass_min_fee_msg_types, max_total_bypass_minFee_msg_gas_usage", + // Aliases: []string{"min"}, + Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { @@ -36,7 +37,7 @@ func GetCmdShowMinimumGasPrices() *cobra.Command { } queryClient := types.NewQueryClient(clientCtx) - res, err := queryClient.MinimumGasPrices(cmd.Context(), &types.QueryMinimumGasPricesRequest{}) + res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{}) if err != nil { return err } diff --git a/x/globalfee/querier.go b/x/globalfee/querier.go index 23a06c28600..7187239c679 100644 --- a/x/globalfee/querier.go +++ b/x/globalfee/querier.go @@ -25,13 +25,25 @@ func NewGrpcQuerier(paramSource ParamSource) GrpcQuerier { } // MinimumGasPrices return minimum gas prices -func (g GrpcQuerier) MinimumGasPrices(stdCtx context.Context, _ *types.QueryMinimumGasPricesRequest) (*types.QueryMinimumGasPricesResponse, error) { +func (g GrpcQuerier) Params(stdCtx context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { var minGasPrices sdk.DecCoins + var bypassMinFeeMsgTypes []string + var maxTotalBypassMinFeeMsgGasUsage uint64 ctx := sdk.UnwrapSDKContext(stdCtx) + // todo: if return err if not exist? if g.paramSource.Has(ctx, types.ParamStoreKeyMinGasPrices) { g.paramSource.Get(ctx, types.ParamStoreKeyMinGasPrices, &minGasPrices) } - return &types.QueryMinimumGasPricesResponse{ - MinimumGasPrices: minGasPrices, + if g.paramSource.Has(ctx, types.ParamStoreKeyBypassMinFeeMsgTypes) { + g.paramSource.Get(ctx, types.ParamStoreKeyBypassMinFeeMsgTypes, &bypassMinFeeMsgTypes) + } + if g.paramSource.Has(ctx, types.ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage) { + g.paramSource.Get(ctx, types.ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage, &maxTotalBypassMinFeeMsgGasUsage) + } + + return &types.QueryParamsResponse{ + MinimumGasPrices: minGasPrices, + BypassMinFeeMsgTypes: bypassMinFeeMsgTypes, + MaxTotalBypassMinFeeMsgGasUsage: maxTotalBypassMinFeeMsgGasUsage, }, nil } From 15e0bc8561c6646aa06a2011003c9027fb638c87 Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Mon, 3 Apr 2023 16:08:33 +0200 Subject: [PATCH 04/47] refactor: add bypass-min-fee-msg-types and max_total_bypass_minFee_msg_gas_usage to globalfee params --- ante/ante.go | 20 ++++------- app/app.go | 25 +++++-------- x/globalfee/ante/fee.go | 55 +++++++++++++++++++++------- x/globalfee/types/params.go | 71 ++++++++++++++++++++++++++++++++++--- 4 files changed, 125 insertions(+), 46 deletions(-) diff --git a/ante/ante.go b/ante/ante.go index f2b06bd8ee0..0940106daea 100644 --- a/ante/ante.go +++ b/ante/ante.go @@ -17,12 +17,11 @@ import ( // channel keeper. type HandlerOptions struct { ante.HandlerOptions - Codec codec.BinaryCodec - GovKeeper *govkeeper.Keeper - IBCkeeper *ibckeeper.Keeper - BypassMinFeeMsgTypes []string - GlobalFeeSubspace paramtypes.Subspace - StakingSubspace paramtypes.Subspace + Codec codec.BinaryCodec + GovKeeper *govkeeper.Keeper + IBCkeeper *ibckeeper.Keeper + GlobalFeeSubspace paramtypes.Subspace + StakingSubspace paramtypes.Subspace } func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) { @@ -53,13 +52,6 @@ func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) { sigGasConsumer = ante.DefaultSigVerificationGasConsumer } - // maxTotalBypassMinFeeMsgGasUsage is the allowed maximum gas usage - // for all the bypass msgs in a transactions. - // A transaction that contains only bypass message types and the gas usage does not - // exceed maxTotalBypassMinFeeMsgGasUsage can be accepted with a zero fee. - // For details, see gaiafeeante.NewFeeDecorator() - var maxTotalBypassMinFeeMsgGasUsage uint64 = 1_000_000 - anteDecorators := []sdk.AnteDecorator{ ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first ante.NewRejectExtensionOptionsDecorator(), @@ -68,7 +60,7 @@ func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) { ante.NewValidateMemoDecorator(opts.AccountKeeper), ante.NewConsumeGasForTxSizeDecorator(opts.AccountKeeper), NewGovPreventSpamDecorator(opts.Codec, opts.GovKeeper), - gaiafeeante.NewFeeDecorator(opts.BypassMinFeeMsgTypes, opts.GlobalFeeSubspace, opts.StakingSubspace, maxTotalBypassMinFeeMsgGasUsage), + gaiafeeante.NewFeeDecorator(opts.GlobalFeeSubspace, opts.StakingSubspace), ante.NewDeductFeeDecorator(opts.AccountKeeper, opts.BankKeeper, opts.FeegrantKeeper), ante.NewSetPubKeyDecorator(opts.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators diff --git a/app/app.go b/app/app.go index a24db610e5a..4e068e7980c 100644 --- a/app/app.go +++ b/app/app.go @@ -7,6 +7,8 @@ import ( "os" "path/filepath" + "github.com/cosmos/gaia/v9/x/globalfee" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" @@ -28,8 +30,6 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" - ibcchanneltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types" ibctesting "github.com/cosmos/interchain-security/legacy_ibc_testing/testing" "github.com/gorilla/mux" "github.com/rakyll/statik/fs" @@ -45,7 +45,7 @@ import ( gaiaappparams "github.com/cosmos/gaia/v9/app/params" "github.com/cosmos/gaia/v9/app/upgrades" v9 "github.com/cosmos/gaia/v9/app/upgrades/v9" - "github.com/cosmos/gaia/v9/x/globalfee" + globalfeetypes "github.com/cosmos/gaia/v9/x/globalfee/types" // unnamed import of statik for swagger UI support _ "github.com/cosmos/cosmos-sdk/client/docs/statik" @@ -212,12 +212,11 @@ func NewGaiaApp( SignModeHandler: encodingConfig.TxConfig.SignModeHandler(), SigGasConsumer: ante.DefaultSigVerificationGasConsumer, }, - Codec: appCodec, - IBCkeeper: app.IBCKeeper, - GovKeeper: &app.GovKeeper, - BypassMinFeeMsgTypes: bypassMinFeeMsgTypes, - GlobalFeeSubspace: app.GetSubspace(globalfee.ModuleName), - StakingSubspace: app.GetSubspace(stakingtypes.ModuleName), + Codec: appCodec, + IBCkeeper: app.IBCKeeper, + GovKeeper: &app.GovKeeper, + GlobalFeeSubspace: app.GetSubspace(globalfee.ModuleName), + StakingSubspace: app.GetSubspace(stakingtypes.ModuleName), }, ) if err != nil { @@ -242,13 +241,7 @@ func NewGaiaApp( } func GetDefaultBypassFeeMessages() []string { - return []string{ - sdk.MsgTypeURL(&ibcchanneltypes.MsgRecvPacket{}), - sdk.MsgTypeURL(&ibcchanneltypes.MsgAcknowledgement{}), - sdk.MsgTypeURL(&ibcclienttypes.MsgUpdateClient{}), - sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeout{}), - sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeoutOnClose{}), - } + return globalfeetypes.DefaultBypassMinFeeMsgTypes } // ValidateBypassFeeMsgTypes checks that a proto message type exists for all MsgTypes in bypassMinFeeMsgTypes diff --git a/x/globalfee/ante/fee.go b/x/globalfee/ante/fee.go index e818e7d398b..8e68a32f2db 100644 --- a/x/globalfee/ante/fee.go +++ b/x/globalfee/ante/fee.go @@ -7,9 +7,10 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/cosmos/gaia/v9/x/globalfee/types" + tmstrings "github.com/tendermint/tendermint/libs/strings" "github.com/cosmos/gaia/v9/x/globalfee" + "github.com/cosmos/gaia/v9/x/globalfee/types" ) // FeeWithBypassDecorator will check if the transaction's fee is at least as large @@ -26,13 +27,11 @@ import ( var _ sdk.AnteDecorator = FeeDecorator{} type FeeDecorator struct { - BypassMinFeeMsgTypes []string - GlobalMinFee globalfee.ParamSource - StakingSubspace paramtypes.Subspace - MaxTotalBypassMinFeeMsgGasUsage uint64 + GlobalMinFee globalfee.ParamSource + StakingSubspace paramtypes.Subspace } -func NewFeeDecorator(bypassMsgTypes []string, globalfeeSubspace, stakingSubspace paramtypes.Subspace, maxTotalBypassMinFeeMsgGasUsage uint64) FeeDecorator { +func NewFeeDecorator(globalfeeSubspace, stakingSubspace paramtypes.Subspace) FeeDecorator { if !globalfeeSubspace.HasKeyTable() { panic("global fee paramspace was not set up via module") } @@ -42,10 +41,8 @@ func NewFeeDecorator(bypassMsgTypes []string, globalfeeSubspace, stakingSubspace } return FeeDecorator{ - BypassMinFeeMsgTypes: bypassMsgTypes, - GlobalMinFee: globalfeeSubspace, - StakingSubspace: stakingSubspace, - MaxTotalBypassMinFeeMsgGasUsage: maxTotalBypassMinFeeMsgGasUsage, + GlobalMinFee: globalfeeSubspace, + StakingSubspace: stakingSubspace, } } @@ -65,8 +62,10 @@ func (mfd FeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, ne // - the total gas limit per message does not exceed MaxTotalBypassMinFeeMsgGasUsage, // i.e., totalGas <= MaxTotalBypassMinFeeMsgGasUsage // Otherwise, minimum fees and global fees are checked to prevent spam. - doesNotExceedMaxGasUsage := gas <= mfd.MaxTotalBypassMinFeeMsgGasUsage - allowedToBypassMinFee := mfd.containsOnlyBypassMinFeeMsgs(msgs) && doesNotExceedMaxGasUsage + + maxTotalBypassMinFeeMsgGasUsage := mfd.getMaxTotalBypassMinFeeMsgGasUsage(ctx) + doesNotExceedMaxGasUsage := gas <= maxTotalBypassMinFeeMsgGasUsage + allowedToBypassMinFee := mfd.containsOnlyBypassMinFeeMsgs(ctx, msgs) && doesNotExceedMaxGasUsage var allFees sdk.Coins requiredGlobalFees, err := mfd.getGlobalFee(ctx, feeTx) @@ -158,3 +157,35 @@ func (mfd FeeDecorator) getBondDenom(ctx sdk.Context) string { return bondDenom } + +func (mfd FeeDecorator) containsOnlyBypassMinFeeMsgs(ctx sdk.Context, msgs []sdk.Msg) bool { + bypassMsgTypes := mfd.getBypassMsgTypes(ctx) + for _, msg := range msgs { + if tmstrings.StringInSlice(sdk.MsgTypeURL(msg), bypassMsgTypes) { + continue + } + return false + } + + return true +} + +func (mfd FeeDecorator) getBypassMsgTypes(ctx sdk.Context) []string { + bypassMsgs := []string{} + if mfd.GlobalMinFee.Has(ctx, types.ParamStoreKeyBypassMinFeeMsgTypes) { + mfd.GlobalMinFee.Get(ctx, types.ParamStoreKeyBypassMinFeeMsgTypes, &bypassMsgs) + } + + // todo if check err: ParamStoreKeyBypassMinFeeMsgTypes does not exist + return bypassMsgs +} + +func (mfd FeeDecorator) getMaxTotalBypassMinFeeMsgGasUsage(ctx sdk.Context) uint64 { + var maxTotalBypassMinFeeMsgGasUsage uint64 + if mfd.GlobalMinFee.Has(ctx, types.ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage) { + mfd.GlobalMinFee.Get(ctx, types.ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage, &maxTotalBypassMinFeeMsgGasUsage) + } + + // todo if check err: maxTotalBypassMinFeeMsgGasUsage does not exist + return maxTotalBypassMinFeeMsgGasUsage +} diff --git a/x/globalfee/types/params.go b/x/globalfee/types/params.go index 59aa38cc568..cf2922fee8b 100644 --- a/x/globalfee/types/params.go +++ b/x/globalfee/types/params.go @@ -3,17 +3,44 @@ package types import ( "fmt" + ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" + ibcchanneltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) -// ParamStoreKeyMinGasPrices store key -var ParamStoreKeyMinGasPrices = []byte("MinimumGasPricesParam") +var ( + // ParamStoreKeyMinGasPrices store key + ParamStoreKeyMinGasPrices = []byte("MinimumGasPricesParam") + ParamStoreKeyBypassMinFeeMsgTypes = []byte("BypassMinFeeMsgTypes") + ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage = []byte("MaxTotalBypassMinFeeMsgGasUsage") + + DefaultMinGasPrices = sdk.DecCoins{} + DefaultBypassMinFeeMsgTypes = []string{ + sdk.MsgTypeURL(&ibcchanneltypes.MsgRecvPacket{}), + sdk.MsgTypeURL(&ibcchanneltypes.MsgAcknowledgement{}), + sdk.MsgTypeURL(&ibcclienttypes.MsgUpdateClient{}), + sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeout{}), + sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeoutOnClose{}), + } + + // maxTotalBypassMinFeeMsgGasUsage is the allowed maximum gas usage + // for all the bypass msgs in a transactions. + // A transaction that contains only bypass message types and the gas usage does not + // exceed maxTotalBypassMinFeeMsgGasUsage can be accepted with a zero fee. + // For details, see gaiafeeante.NewFeeDecorator() + DefaultmaxTotalBypassMinFeeMsgGasUsage uint64 = 1_000_000 +) // DefaultParams returns default parameters func DefaultParams() Params { - return Params{MinimumGasPrices: sdk.DecCoins{}} + return Params{ + MinimumGasPrices: DefaultMinGasPrices, + BypassMinFeeMsgTypes: DefaultBypassMinFeeMsgTypes, + MaxTotalBypassMinFeeMsgGasUsage: DefaultmaxTotalBypassMinFeeMsgGasUsage, + } } func ParamKeyTable() paramtypes.KeyTable { @@ -22,7 +49,19 @@ func ParamKeyTable() paramtypes.KeyTable { // ValidateBasic performs basic validation. func (p Params) ValidateBasic() error { - return validateMinimumGasPrices(p.MinimumGasPrices) + if err := validateMinimumGasPrices(p.MinimumGasPrices); err != nil { + return err + } + + if err := validateBypassMinFeeMsgTypes(p.BypassMinFeeMsgTypes); err != nil { + return err + } + + if err := validateMaxTotalBypassMinFeeMsgGasUsage(p.MaxTotalBypassMinFeeMsgGasUsage); err != nil { + return err + } + + return nil } // ParamSetPairs returns the parameter set pairs. @@ -31,6 +70,12 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair( ParamStoreKeyMinGasPrices, &p.MinimumGasPrices, validateMinimumGasPrices, ), + paramtypes.NewParamSetPair( + ParamStoreKeyBypassMinFeeMsgTypes, &p.BypassMinFeeMsgTypes, validateBypassMinFeeMsgTypes, + ), + paramtypes.NewParamSetPair( + ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage, &p.MaxTotalBypassMinFeeMsgGasUsage, validateMaxTotalBypassMinFeeMsgGasUsage, + ), } } @@ -45,6 +90,24 @@ func validateMinimumGasPrices(i interface{}) error { return dec.Validate() } +// todo check if args string +func validateBypassMinFeeMsgTypes(i interface{}) error { + return nil +} + +func validateMaxTotalBypassMinFeeMsgGasUsage(i interface{}) error { + v, ok := i.(uint64) + if !ok { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "type: %T, expected uint64", i) + } + + if v < 0 { + return fmt.Errorf("gas usage %s is negtive", v) + } + + return nil +} + // Validate checks that the DecCoins are sorted, have nonnegtive amount, with a valid and unique // denomination (i.e no duplicates). Otherwise, it returns an error. type DecCoins sdk.DecCoins From 4e7478e4650651843a6b0bc82cc6b78cfd5fc899 Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Mon, 3 Apr 2023 16:11:18 +0200 Subject: [PATCH 05/47] test: update test --- x/globalfee/ante/antetest/fee_test.go | 635 +++++++++++++------------- x/globalfee/ante/fee_utils.go | 12 - 2 files changed, 316 insertions(+), 331 deletions(-) diff --git a/x/globalfee/ante/antetest/fee_test.go b/x/globalfee/ante/antetest/fee_test.go index 2cb1aeffdca..d2b68e4af94 100644 --- a/x/globalfee/ante/antetest/fee_test.go +++ b/x/globalfee/ante/antetest/fee_test.go @@ -11,7 +11,6 @@ import ( ibcchanneltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types" "github.com/stretchr/testify/suite" - gaiaapp "github.com/cosmos/gaia/v9/app" gaiafeeante "github.com/cosmos/gaia/v9/x/globalfee/ante" globfeetypes "github.com/cosmos/gaia/v9/x/globalfee/types" ) @@ -31,7 +30,7 @@ func (s *IntegrationTestSuite) TestGetDefaultGlobalFees() { stakingSubspace := s.SetupTestStakingSubspace(stakingParam) // setup antehandler - mfd := gaiafeeante.NewFeeDecorator(gaiaapp.GetDefaultBypassFeeMessages(), globalfeeSubspace, stakingSubspace, newTestGasLimit()) + mfd := gaiafeeante.NewFeeDecorator(globalfeeSubspace, stakingSubspace) defaultGlobalFees, err := mfd.DefaultZeroGlobalFee(s.ctx) s.Require().NoError(err) @@ -61,55 +60,50 @@ func (s *IntegrationTestSuite) TestGlobalFeeMinimumGasFeeAnteHandler() { medFeeAmt := sdk.NewInt(med.MulInt64(int64(2) * denominator).RoundInt64()) lowFeeAmt := sdk.NewInt(low.MulInt64(int64(2) * denominator).RoundInt64()) - globalfeeParamsEmpty := &globfeetypes.Params{MinimumGasPrices: []sdk.DecCoin{}} + globalfeeParamsEmpty := []sdk.DecCoin{} minGasPriceEmpty := []sdk.DecCoin{} - globalfeeParams0 := &globfeetypes.Params{MinimumGasPrices: []sdk.DecCoin{ + globalfeeParams0 := []sdk.DecCoin{ sdk.NewDecCoinFromDec("photon", sdk.NewDec(0)), sdk.NewDecCoinFromDec("uatom", sdk.NewDec(0)), - }} - globalfeeParamsContain0 := &globfeetypes.Params{MinimumGasPrices: []sdk.DecCoin{ + } + globalfeeParamsContain0 := []sdk.DecCoin{ sdk.NewDecCoinFromDec("photon", med), sdk.NewDecCoinFromDec("uatom", sdk.NewDec(0)), - }} + } minGasPrice0 := []sdk.DecCoin{ sdk.NewDecCoinFromDec("stake", sdk.NewDec(0)), sdk.NewDecCoinFromDec("uatom", sdk.NewDec(0)), } - globalfeeParamsHigh := &globfeetypes.Params{ - MinimumGasPrices: []sdk.DecCoin{ - sdk.NewDecCoinFromDec("uatom", high), - }, + globalfeeParamsHigh := []sdk.DecCoin{ + sdk.NewDecCoinFromDec("uatom", high), } minGasPrice := []sdk.DecCoin{ sdk.NewDecCoinFromDec("uatom", med), sdk.NewDecCoinFromDec("stake", med), } - globalfeeParamsLow := &globfeetypes.Params{ - MinimumGasPrices: []sdk.DecCoin{ - sdk.NewDecCoinFromDec("uatom", low), - }, + globalfeeParamsLow := []sdk.DecCoin{ + sdk.NewDecCoinFromDec("uatom", low), } // global fee must be sorted in denom - globalfeeParamsNewDenom := &globfeetypes.Params{ - MinimumGasPrices: []sdk.DecCoin{ - sdk.NewDecCoinFromDec("photon", high), - sdk.NewDecCoinFromDec("quark", high), - }, + globalfeeParamsNewDenom := []sdk.DecCoin{ + sdk.NewDecCoinFromDec("photon", high), + sdk.NewDecCoinFromDec("quark", high), } + testCases := map[string]struct { - minGasPrice []sdk.DecCoin - globalFeeParams *globfeetypes.Params - gasPrice sdk.Coins - gasLimit sdk.Gas - txMsg sdk.Msg - txCheck bool - expErr bool + minGasPrice []sdk.DecCoin + globalFee []sdk.DecCoin + gasPrice sdk.Coins + gasLimit sdk.Gas + txMsg sdk.Msg + txCheck bool + expErr bool }{ // test fees // empty min_gas_price or empty global fee "empty min_gas_price, nonempty global fee, fee higher/equal than global_fee": { - minGasPrice: minGasPriceEmpty, - globalFeeParams: globalfeeParamsHigh, + minGasPrice: minGasPriceEmpty, + globalFee: globalfeeParamsHigh, // sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()) gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", highFeeAmt)), gasLimit: testdata.NewTestGasLimit(), @@ -118,73 +112,73 @@ func (s *IntegrationTestSuite) TestGlobalFeeMinimumGasFeeAnteHandler() { expErr: false, }, "empty min_gas_price, nonempty global fee, fee lower than global_fee": { - minGasPrice: minGasPriceEmpty, - globalFeeParams: globalfeeParamsHigh, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), - gasLimit: testdata.NewTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPriceEmpty, + globalFee: globalfeeParamsHigh, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), + gasLimit: testdata.NewTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, "nonempty min_gas_price with defaultGlobalFee denom, empty global fee, fee higher/equal than min_gas_price": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsEmpty, // default 0uatom - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", medFeeAmt)), - gasLimit: testdata.NewTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsEmpty, // default 0uatom + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", medFeeAmt)), + gasLimit: testdata.NewTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "nonempty min_gas_price with defaultGlobalFee denom, empty global fee, fee lower than min_gas_price": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsEmpty, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), - gasLimit: testdata.NewTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsEmpty, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), + gasLimit: testdata.NewTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, "empty min_gas_price, empty global fee, empty fee": { - minGasPrice: minGasPriceEmpty, - globalFeeParams: globalfeeParamsEmpty, - gasPrice: sdk.Coins{}, - gasLimit: testdata.NewTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPriceEmpty, + globalFee: globalfeeParamsEmpty, + gasPrice: sdk.Coins{}, + gasLimit: testdata.NewTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, // zero min_gas_price or zero global fee "zero min_gas_price, zero global fee, zero fee in global fee denom": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParams0, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt()), sdk.NewCoin("photon", sdk.ZeroInt())), - gasLimit: testdata.NewTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice0, + globalFee: globalfeeParams0, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt()), sdk.NewCoin("photon", sdk.ZeroInt())), + gasLimit: testdata.NewTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "zero min_gas_price, zero global fee, empty fee": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParams0, - gasPrice: sdk.Coins{}, - gasLimit: testdata.NewTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice0, + globalFee: globalfeeParams0, + gasPrice: sdk.Coins{}, + gasLimit: testdata.NewTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, // zero global fee "zero min_gas_price, zero global fee, zero fee not in globalfee denom": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParams0, - gasPrice: sdk.NewCoins(sdk.NewCoin("stake", sdk.ZeroInt())), - gasLimit: testdata.NewTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice0, + globalFee: globalfeeParams0, + gasPrice: sdk.NewCoins(sdk.NewCoin("stake", sdk.ZeroInt())), + gasLimit: testdata.NewTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "zero min_gas_price, zero global fee, zero fees one in, one not in globalfee denom": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParams0, + minGasPrice: minGasPrice0, + globalFee: globalfeeParams0, gasPrice: sdk.NewCoins( sdk.NewCoin("stake", sdk.ZeroInt()), sdk.NewCoin("uatom", sdk.ZeroInt())), @@ -195,119 +189,119 @@ func (s *IntegrationTestSuite) TestGlobalFeeMinimumGasFeeAnteHandler() { }, // zero min_gas_price and empty global fee "zero min_gas_price, empty global fee, zero fee in min_gas_price_denom": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParamsEmpty, - gasPrice: sdk.NewCoins(sdk.NewCoin("stake", sdk.ZeroInt())), - gasLimit: testdata.NewTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice0, + globalFee: globalfeeParamsEmpty, + gasPrice: sdk.NewCoins(sdk.NewCoin("stake", sdk.ZeroInt())), + gasLimit: testdata.NewTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "zero min_gas_price, empty global fee, zero fee not in min_gas_price denom, not in defaultZeroGlobalFee denom": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParamsEmpty, - gasPrice: sdk.NewCoins(sdk.NewCoin("quark", sdk.ZeroInt())), - gasLimit: testdata.NewTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice0, + globalFee: globalfeeParamsEmpty, + gasPrice: sdk.NewCoins(sdk.NewCoin("quark", sdk.ZeroInt())), + gasLimit: testdata.NewTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "zero min_gas_price, empty global fee, zero fee in defaultZeroGlobalFee denom": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParamsEmpty, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), - gasLimit: newTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice0, + globalFee: globalfeeParamsEmpty, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), + gasLimit: newTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "zero min_gas_price, empty global fee, nonzero fee in defaultZeroGlobalFee denom": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParamsEmpty, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), - gasLimit: newTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice0, + globalFee: globalfeeParamsEmpty, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), + gasLimit: newTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "zero min_gas_price, empty global fee, nonzero fee not in defaultZeroGlobalFee denom": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParamsEmpty, - gasPrice: sdk.NewCoins(sdk.NewCoin("quark", highFeeAmt)), - gasLimit: newTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPrice0, + globalFee: globalfeeParamsEmpty, + gasPrice: sdk.NewCoins(sdk.NewCoin("quark", highFeeAmt)), + gasLimit: newTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, // empty min_gas_price, zero global fee "empty min_gas_price, zero global fee, zero fee in global fee denom": { - minGasPrice: minGasPriceEmpty, - globalFeeParams: globalfeeParams0, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), - gasLimit: newTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPriceEmpty, + globalFee: globalfeeParams0, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), + gasLimit: newTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "empty min_gas_price, zero global fee, zero fee not in global fee denom": { - minGasPrice: minGasPriceEmpty, - globalFeeParams: globalfeeParams0, - gasPrice: sdk.NewCoins(sdk.NewCoin("stake", sdk.ZeroInt())), - gasLimit: newTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPriceEmpty, + globalFee: globalfeeParams0, + gasPrice: sdk.NewCoins(sdk.NewCoin("stake", sdk.ZeroInt())), + gasLimit: newTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "empty min_gas_price, zero global fee, nonzero fee in global fee denom": { - minGasPrice: minGasPriceEmpty, - globalFeeParams: globalfeeParams0, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), - gasLimit: newTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPriceEmpty, + globalFee: globalfeeParams0, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), + gasLimit: newTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "empty min_gas_price, zero global fee, nonzero fee not in global fee denom": { - minGasPrice: minGasPriceEmpty, - globalFeeParams: globalfeeParams0, - gasPrice: sdk.NewCoins(sdk.NewCoin("stake", highFeeAmt)), - gasLimit: newTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPriceEmpty, + globalFee: globalfeeParams0, + gasPrice: sdk.NewCoins(sdk.NewCoin("stake", highFeeAmt)), + gasLimit: newTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, // zero min_gas_price, nonzero global fee "zero min_gas_price, nonzero global fee, fee is higher than global fee": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), - gasLimit: newTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice0, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), + gasLimit: newTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, // nonzero min_gas_price, nonzero global fee "fee higher/equal than globalfee and min_gas_price": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsHigh, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", highFeeAmt)), - gasLimit: newTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsHigh, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", highFeeAmt)), + gasLimit: newTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "fee lower than globalfee and min_gas_price": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsHigh, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), - gasLimit: newTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsHigh, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), + gasLimit: newTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, "fee with one denom higher/equal, one denom lower than globalfee and min_gas_price": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsNewDenom, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsNewDenom, gasPrice: sdk.NewCoins( sdk.NewCoin("photon", lowFeeAmt), sdk.NewCoin("quark", highFeeAmt)), @@ -317,73 +311,73 @@ func (s *IntegrationTestSuite) TestGlobalFeeMinimumGasFeeAnteHandler() { expErr: false, }, "globalfee > min_gas_price, fee higher/equal than min_gas_price, lower than globalfee": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsHigh, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", medFeeAmt)), - gasLimit: newTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsHigh, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", medFeeAmt)), + gasLimit: newTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, "globalfee < min_gas_price, fee higher/equal than globalfee and lower than min_gas_price": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), - gasLimit: newTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), + gasLimit: newTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, // nonzero min_gas_price, zero global fee "nonzero min_gas_price, zero global fee, fee is in global fee denom and lower than min_gas_price": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParams0, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), - gasLimit: newTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPrice, + globalFee: globalfeeParams0, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), + gasLimit: newTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, "nonzero min_gas_price, zero global fee, fee is in global fee denom and higher/equal than min_gas_price": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParams0, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", medFeeAmt)), - gasLimit: newTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice, + globalFee: globalfeeParams0, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", medFeeAmt)), + gasLimit: newTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "nonzero min_gas_price, zero global fee, fee is in min_gas_price denom which is not in global fee default, but higher/equal than min_gas_price": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParams0, - gasPrice: sdk.NewCoins(sdk.NewCoin("stake", highFeeAmt)), - gasLimit: newTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPrice, + globalFee: globalfeeParams0, + gasPrice: sdk.NewCoins(sdk.NewCoin("stake", highFeeAmt)), + gasLimit: newTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, // fee denom tests "min_gas_price denom is not subset of global fee denom , fee paying in global fee denom": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsNewDenom, - gasPrice: sdk.NewCoins(sdk.NewCoin("photon", highFeeAmt)), - gasLimit: newTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsNewDenom, + gasPrice: sdk.NewCoins(sdk.NewCoin("photon", highFeeAmt)), + gasLimit: newTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "min_gas_price denom is not subset of global fee denom, fee paying in min_gas_price denom": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsNewDenom, - gasPrice: sdk.NewCoins(sdk.NewCoin("stake", highFeeAmt)), - gasLimit: newTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsNewDenom, + gasPrice: sdk.NewCoins(sdk.NewCoin("stake", highFeeAmt)), + gasLimit: newTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, "fees contain denom not in globalfee": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, gasPrice: sdk.NewCoins( sdk.NewCoin("uatom", highFeeAmt), sdk.NewCoin("quark", highFeeAmt)), @@ -393,8 +387,8 @@ func (s *IntegrationTestSuite) TestGlobalFeeMinimumGasFeeAnteHandler() { expErr: true, }, "fees contain denom not in globalfee with zero amount": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", highFeeAmt), sdk.NewCoin("quark", sdk.ZeroInt())), gasLimit: newTestGasLimit(), @@ -408,17 +402,17 @@ func (s *IntegrationTestSuite) TestGlobalFeeMinimumGasFeeAnteHandler() { // if the user includes any fee at all in the non-zero denom, it must be higher than that non-zero fee // unlikely we will ever see zero and non-zero together but technically possible "globalfee contains zero coin and non-zero coin, fee is lower than the nonzero coin": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParamsContain0, - gasPrice: sdk.NewCoins(sdk.NewCoin("photon", lowFeeAmt)), - gasLimit: newTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPrice0, + globalFee: globalfeeParamsContain0, + gasPrice: sdk.NewCoins(sdk.NewCoin("photon", lowFeeAmt)), + gasLimit: newTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, "globalfee contains zero coin, fee contains zero coins of the same denom and a lower fee of the other denom in global fee": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParamsContain0, + minGasPrice: minGasPrice0, + globalFee: globalfeeParamsContain0, gasPrice: sdk.NewCoins( sdk.NewCoin("photon", lowFeeAmt), sdk.NewCoin("uatom", sdk.ZeroInt())), @@ -428,17 +422,17 @@ func (s *IntegrationTestSuite) TestGlobalFeeMinimumGasFeeAnteHandler() { expErr: true, }, "globalfee contains zero coin, fee is empty": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParamsContain0, - gasPrice: sdk.Coins{}, - gasLimit: newTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice0, + globalFee: globalfeeParamsContain0, + gasPrice: sdk.Coins{}, + gasLimit: newTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "globalfee contains zero coin, fee contains lower fee of zero coins's denom, globalfee also contains nonzero coin,fee contains higher fee of nonzero coins's denom, ": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParamsContain0, + minGasPrice: minGasPrice0, + globalFee: globalfeeParamsContain0, gasPrice: sdk.NewCoins( sdk.NewCoin("photon", lowFeeAmt), sdk.NewCoin("uatom", highFeeAmt)), @@ -448,8 +442,8 @@ func (s *IntegrationTestSuite) TestGlobalFeeMinimumGasFeeAnteHandler() { expErr: false, }, "globalfee contains zero coin, fee is all zero coins but in global fee's denom": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParamsContain0, + minGasPrice: minGasPrice0, + globalFee: globalfeeParamsContain0, gasPrice: sdk.NewCoins( sdk.NewCoin("photon", sdk.ZeroInt()), sdk.NewCoin("uatom", sdk.ZeroInt()), @@ -460,159 +454,162 @@ func (s *IntegrationTestSuite) TestGlobalFeeMinimumGasFeeAnteHandler() { expErr: false, }, "globalfee contains zero coin, fee is higher than the nonzero coin": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParamsContain0, - gasPrice: sdk.NewCoins(sdk.NewCoin("photon", highFeeAmt)), - gasLimit: newTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice0, + globalFee: globalfeeParamsContain0, + gasPrice: sdk.NewCoins(sdk.NewCoin("photon", highFeeAmt)), + gasLimit: newTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "bypass msg type: ibc.core.channel.v1.MsgRecvPacket": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), - gasLimit: newTestGasLimit(), + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), + gasLimit: newTestGasLimit(), txMsg: ibcchanneltypes.NewMsgRecvPacket( ibcchanneltypes.Packet{}, nil, ibcclienttypes.Height{}, ""), txCheck: true, expErr: false, }, "bypass msg type: ibc.core.channel.v1.MsgTimeout": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), - gasLimit: newTestGasLimit(), + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), + gasLimit: newTestGasLimit(), txMsg: ibcchanneltypes.NewMsgTimeout( + // todo check here ibcchanneltypes.Packet{}, 1, nil, ibcclienttypes.Height{}, ""), txCheck: true, expErr: false, }, "bypass msg type: ibc.core.channel.v1.MsgTimeoutOnClose": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), - gasLimit: newTestGasLimit(), + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), + gasLimit: newTestGasLimit(), txMsg: ibcchanneltypes.NewMsgTimeout( ibcchanneltypes.Packet{}, 2, nil, ibcclienttypes.Height{}, ""), txCheck: true, expErr: false, }, "bypass msg gas usage exceeds maxTotalBypassMinFeeMsgGasUsage": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), - gasLimit: 2 * newTestMaxTotalBypassMinFeeMsgGasUsage(), + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), + gasLimit: 2 * newTestMaxTotalBypassMinFeeMsgGasUsage(), txMsg: ibcchanneltypes.NewMsgTimeout( ibcchanneltypes.Packet{}, 2, nil, ibcclienttypes.Height{}, ""), txCheck: true, expErr: true, }, "bypass msg gas usage equals to maxTotalBypassMinFeeMsgGasUsage": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), - gasLimit: newTestMaxTotalBypassMinFeeMsgGasUsage(), + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), + gasLimit: newTestMaxTotalBypassMinFeeMsgGasUsage(), txMsg: ibcchanneltypes.NewMsgTimeout( ibcchanneltypes.Packet{}, 3, nil, ibcclienttypes.Height{}, ""), txCheck: true, expErr: false, }, "msg type ibc, zero fee not in globalfee denom": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("photon", sdk.ZeroInt())), - gasLimit: newTestGasLimit(), + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("photon", sdk.ZeroInt())), + gasLimit: newTestGasLimit(), txMsg: ibcchanneltypes.NewMsgRecvPacket( ibcchanneltypes.Packet{}, nil, ibcclienttypes.Height{}, ""), txCheck: true, expErr: false, }, "msg type ibc, nonzero fee in globalfee denom": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", highFeeAmt)), - gasLimit: newTestGasLimit(), + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", highFeeAmt)), + gasLimit: newTestGasLimit(), txMsg: ibcchanneltypes.NewMsgRecvPacket( ibcchanneltypes.Packet{}, nil, ibcclienttypes.Height{}, ""), txCheck: true, expErr: false, }, "msg type ibc, nonzero fee not in globalfee denom": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("photon", highFeeAmt)), - gasLimit: newTestGasLimit(), + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("photon", highFeeAmt)), + gasLimit: newTestGasLimit(), txMsg: ibcchanneltypes.NewMsgRecvPacket( ibcchanneltypes.Packet{}, nil, ibcclienttypes.Height{}, ""), txCheck: true, expErr: true, }, "msg type ibc, empty fee": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.Coins{}, - gasLimit: newTestGasLimit(), + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.Coins{}, + gasLimit: newTestGasLimit(), txMsg: ibcchanneltypes.NewMsgRecvPacket( ibcchanneltypes.Packet{}, nil, ibcclienttypes.Height{}, ""), txCheck: true, expErr: false, }, "msg type non-ibc, nonzero fee in globalfee denom": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", highFeeAmt)), - gasLimit: newTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", highFeeAmt)), + gasLimit: newTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "msg type non-ibc, empty fee": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.Coins{}, - gasLimit: newTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.Coins{}, + gasLimit: newTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, "msg type non-ibc, nonzero fee not in globalfee denom": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("photon", highFeeAmt)), - gasLimit: newTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("photon", highFeeAmt)), + gasLimit: newTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, "disable checkTx: no fee check. min_gas_price is low, global fee is low, tx fee is zero": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), - gasLimit: newTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: false, - expErr: false, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), + gasLimit: newTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: false, + expErr: false, }, "disable checkTx: no fee check. min_gas_price is low, global fee is low, tx fee's denom is not in global fees denoms set": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("quark", sdk.ZeroInt())), - gasLimit: newTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: false, - expErr: false, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("quark", sdk.ZeroInt())), + gasLimit: newTestGasLimit(), + txMsg: testdata.NewTestMsg(addr1), + txCheck: false, + expErr: false, }, } for name, testCase := range testCases { s.Run(name, func() { // set globalfees and min gas price - globalfeeSubspace := s.SetupTestGlobalFeeStoreAndMinGasPrice(testCase.minGasPrice, testCase.globalFeeParams) + globalFeeparams := globfeetypes.DefaultParams() + globalFeeparams.MinimumGasPrices = testCase.globalFee + globalfeeSubspace := s.SetupTestGlobalFeeStoreAndMinGasPrice(testCase.minGasPrice, &globalFeeparams) stakingParam := stakingtypes.DefaultParams() stakingParam.BondDenom = "uatom" stakingSubspace := s.SetupTestStakingSubspace(stakingParam) // setup antehandler - mfd := gaiafeeante.NewFeeDecorator(gaiaapp.GetDefaultBypassFeeMessages(), globalfeeSubspace, stakingSubspace, newTestMaxTotalBypassMinFeeMsgGasUsage()) + mfd := gaiafeeante.NewFeeDecorator(globalfeeSubspace, stakingSubspace) antehandler := sdk.ChainAnteDecorators(mfd) s.Require().NoError(s.txBuilder.SetMsgs(testCase.txMsg)) s.txBuilder.SetFeeAmount(testCase.gasPrice) diff --git a/x/globalfee/ante/fee_utils.go b/x/globalfee/ante/fee_utils.go index 9fa48b01e99..80c7a9dbffe 100644 --- a/x/globalfee/ante/fee_utils.go +++ b/x/globalfee/ante/fee_utils.go @@ -4,7 +4,6 @@ import ( "math" sdk "github.com/cosmos/cosmos-sdk/types" - tmstrings "github.com/tendermint/tendermint/libs/strings" ) // getMinGasPrice will also return sorted coins @@ -27,17 +26,6 @@ func getMinGasPrice(ctx sdk.Context, feeTx sdk.FeeTx) sdk.Coins { return requiredFees.Sort() } -func (mfd FeeDecorator) containsOnlyBypassMinFeeMsgs(msgs []sdk.Msg) bool { - for _, msg := range msgs { - if tmstrings.StringInSlice(sdk.MsgTypeURL(msg), mfd.BypassMinFeeMsgTypes) { - continue - } - return false - } - - return true -} - // DenomsSubsetOfIncludingZero and IsAnyGTEIncludingZero are similar to DenomsSubsetOf and IsAnyGTE in sdk. Since we allow zero coins in global fee(zero coins means the chain does not want to set a global fee but still want to define the fee's denom) // // overwrite DenomsSubsetOfIncludingZero from sdk, to allow zero amt coins in superset. e.g. 1stake is DenomsSubsetOfIncludingZero 0stake. [] is the DenomsSubsetOfIncludingZero of [0stake] but not [1stake]. From a244a85fc8aee018f885848c8b140a0c2ed2c7fe Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Mon, 3 Apr 2023 16:13:53 +0200 Subject: [PATCH 06/47] feat: add migration --- app/upgrades/v10/constants.go | 15 ++++++++++ app/upgrades/v10/upgrades.go | 26 +++++++++++++++++ x/globalfee/keeper/migrations.go | 22 +++++++++++++++ x/globalfee/migrations/v2/store.go | 37 +++++++++++++++++++++++++ x/globalfee/migrations/v2/store_test.go | 1 + x/globalfee/module.go | 9 +++++- 6 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 app/upgrades/v10/constants.go create mode 100644 app/upgrades/v10/upgrades.go create mode 100644 x/globalfee/keeper/migrations.go create mode 100644 x/globalfee/migrations/v2/store.go create mode 100644 x/globalfee/migrations/v2/store_test.go diff --git a/app/upgrades/v10/constants.go b/app/upgrades/v10/constants.go new file mode 100644 index 00000000000..b45786a90af --- /dev/null +++ b/app/upgrades/v10/constants.go @@ -0,0 +1,15 @@ +package v10 + +import ( + "github.com/cosmos/gaia/v9/app/upgrades" +) + +const ( + // UpgradeName defines the on-chain upgrade name. + UpgradeName = "v10" +) + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, +} diff --git a/app/upgrades/v10/upgrades.go b/app/upgrades/v10/upgrades.go new file mode 100644 index 00000000000..01bb520c829 --- /dev/null +++ b/app/upgrades/v10/upgrades.go @@ -0,0 +1,26 @@ +package v10 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + "github.com/cosmos/gaia/v9/app/keepers" +) + +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + keepers *keepers.AppKeepers, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + ctx.Logger().Info("Starting module migrations...") + + vm, err := mm.RunMigrations(ctx, configurator, vm) + if err != nil { + return vm, err + } + + ctx.Logger().Info("Upgrade complete") + return vm, err + } +} diff --git a/x/globalfee/keeper/migrations.go b/x/globalfee/keeper/migrations.go new file mode 100644 index 00000000000..8ee92ce8257 --- /dev/null +++ b/x/globalfee/keeper/migrations.go @@ -0,0 +1,22 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + v2 "github.com/cosmos/gaia/v9/x/globalfee/migrations/v2" +) + +// Migrator is a struct for handling in-place store migrations. +type Migrator struct { + globalfeeSubspace paramtypes.Subspace +} + +// NewMigrator returns a new Migrator. +func NewMigrator(globalfeeSubspace paramtypes.Subspace) Migrator { + return Migrator{globalfeeSubspace: globalfeeSubspace} +} + +// Migrate1to2 migrates from version 1 to 2. +func (m Migrator) Migrate1to2(ctx sdk.Context) error { + return v2.MigrateStore(ctx, m.globalfeeSubspace) +} diff --git a/x/globalfee/migrations/v2/store.go b/x/globalfee/migrations/v2/store.go new file mode 100644 index 00000000000..cfe4f1b4e4a --- /dev/null +++ b/x/globalfee/migrations/v2/store.go @@ -0,0 +1,37 @@ +package v2 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/cosmos/gaia/v9/x/globalfee/types" +) + +// MigrateStore performs in-place store migrations. +// The migration includes: +// Add bypass-min-fee-msg-types params that are set +// ["/ibc.core.channel.v1.MsgRecvPacket", +// "/ibc.core.channel.v1.MsgAcknowledgement", +// "/ibc.core.client.v1.MsgUpdateClient", +// "/ibc.core.channel.v1.MsgTimeout", +// "/ibc.core.channel.v1.MsgTimeoutOnClose"] asd default. +func MigrateStore(ctx sdk.Context, globalfeeSubspace paramtypes.Subspace) error { + var globalMinGasPrices sdk.DecCoins + + if globalfeeSubspace.Has(ctx, types.ParamStoreKeyMinGasPrices) { + globalfeeSubspace.Get(ctx, types.ParamStoreKeyMinGasPrices, &globalMinGasPrices) + } else { + // todo return err + return nil + } + + var params types.Params + + defaultParams := types.DefaultParams() + params.MinimumGasPrices = globalMinGasPrices + params.BypassMinFeeMsgTypes = defaultParams.BypassMinFeeMsgTypes + params.MaxTotalBypassMinFeeMsgGasUsage = defaultParams.MaxTotalBypassMinFeeMsgGasUsage + + globalfeeSubspace.SetParamSet(ctx, ¶ms) + + return nil +} diff --git a/x/globalfee/migrations/v2/store_test.go b/x/globalfee/migrations/v2/store_test.go new file mode 100644 index 00000000000..5ec3cc8e833 --- /dev/null +++ b/x/globalfee/migrations/v2/store_test.go @@ -0,0 +1 @@ +package v2 diff --git a/x/globalfee/module.go b/x/globalfee/module.go index 484bb7778ec..eb58053c496 100644 --- a/x/globalfee/module.go +++ b/x/globalfee/module.go @@ -3,6 +3,7 @@ package globalfee import ( "context" "encoding/json" + "fmt" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -17,6 +18,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" "github.com/cosmos/gaia/v9/x/globalfee/client/cli" + "github.com/cosmos/gaia/v9/x/globalfee/keeper" "github.com/cosmos/gaia/v9/x/globalfee/types" ) @@ -116,6 +118,11 @@ func (a AppModule) LegacyQuerierHandler(amino *codec.LegacyAmino) sdk.Querier { func (a AppModule) RegisterServices(cfg module.Configurator) { types.RegisterQueryServer(cfg.QueryServer(), NewGrpcQuerier(a.paramSpace)) + + m := keeper.NewMigrator(a.paramSpace) + if err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2); err != nil { + panic(fmt.Sprintf("failed to migrate x/globalfee from version 1 to 2: %v", err)) + } } func (a AppModule) BeginBlock(context sdk.Context, block abci.RequestBeginBlock) { @@ -130,5 +137,5 @@ func (a AppModule) EndBlock(context sdk.Context, block abci.RequestEndBlock) []a // introduced by the module. To avoid wrong/empty versions, the initial version // should be set to 1. func (a AppModule) ConsensusVersion() uint64 { - return 1 + return 2 } From edd0e510b9e90cde33326a0ab8bd6c7d3bbdb137 Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Mon, 3 Apr 2023 16:14:13 +0200 Subject: [PATCH 07/47] docs: update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19a74affce4..1f8934b0325 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ # Changelog ## [Unreleased] +* Add `bypass-min-fee-msg-types` and `maxTotalBypassMinFeeMsgGagUsage` to globalfee params (state breaking and API breaking!!!). ## [v9.0.2-rc0] - 2023-03-27 * (feat) Bump [Interchain-Security](https://github.com/cosmos/interchain-security) [v1.1.0](https://github.com/cosmos/interchain-security/releases/tag/v1.1.0) provider module. See the [release notes](https://github.com/cosmos/interchain-security/releases/tag/v1.1.0) for details. From c9b9b98e2f000bb8221f18a1212f067359783bc5 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Mon, 3 Apr 2023 16:45:22 +0200 Subject: [PATCH 08/47] add BypassMinFeeMsgTypes param to store --- Makefile | 2 +- proto/gaia/globalfee/v1beta1/genesis.proto | 8 +- x/globalfee/types/genesis.pb.go | 107 ++++++++++++++++----- x/globalfee/types/params.go | 56 ++++++++++- x/globalfee/types/params_test.go | 38 +++++++- 5 files changed, 182 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index 09748e5908a..3e19f6b97ee 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ BUILDDIR ?= $(CURDIR)/build TEST_DOCKER_REPO=cosmos/contrib-gaiatest GO_SYSTEM_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1-2) -REQUIRE_GO_VERSION = 1.18 +REQUIRE_GO_VERSION = 1.19 export GO111MODULE = on diff --git a/proto/gaia/globalfee/v1beta1/genesis.proto b/proto/gaia/globalfee/v1beta1/genesis.proto index 39493b0c637..7740e2206b0 100644 --- a/proto/gaia/globalfee/v1beta1/genesis.proto +++ b/proto/gaia/globalfee/v1beta1/genesis.proto @@ -17,7 +17,7 @@ message GenesisState { // Params defines the set of module parameters. message Params { - // Minimum stores the minimum gas price(s) for all TX on the chain. + // minimum_gas_prices stores the minimum gas price(s) for all TX on the chain. // When multiple coins are defined then they are accepted alternatively. // The list must be sorted by denoms asc. No duplicate denoms or zero amount // values allowed. For more information see @@ -28,4 +28,10 @@ message Params { (gogoproto.moretags) = "yaml:\"minimum_gas_prices\"", (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins" ]; + // bypass_min_fee_msg_types defines the exhaustive list of IBC message url types + // that can bypass the minimum fee + repeated string bypass_min_fee_msg_types = 2 [ + (gogoproto.jsontag) = "bypass_min_fee_msg_types,omitempty", + (gogoproto.moretags) = "yaml:\"bypass_min_fee_msg_types\"" + ]; } diff --git a/x/globalfee/types/genesis.pb.go b/x/globalfee/types/genesis.pb.go index bde069af626..d61637b14be 100644 --- a/x/globalfee/types/genesis.pb.go +++ b/x/globalfee/types/genesis.pb.go @@ -73,12 +73,15 @@ func (m *GenesisState) GetParams() Params { // Params defines the set of module parameters. type Params struct { - // Minimum stores the minimum gas price(s) for all TX on the chain. + // minimum_gas_prices stores the minimum gas price(s) for all TX on the chain. // When multiple coins are defined then they are accepted alternatively. // The list must be sorted by denoms asc. No duplicate denoms or zero amount // values allowed. For more information see // https://docs.cosmos.network/main/modules/auth#concepts MinimumGasPrices github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=minimum_gas_prices,json=minimumGasPrices,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"minimum_gas_prices,omitempty" yaml:"minimum_gas_prices"` + // bypass_min_fee_msg_types defines the exhaustive list of IBC message url types + // that can bypass the minimum fee + BypassMinFeeMsgTypes []string `protobuf:"bytes,2,rep,name=bypass_min_fee_msg_types,json=bypassMinFeeMsgTypes,proto3" json:"bypass_min_fee_msg_types,omitempty" yaml:"bypass_min_fee_msg_types"` } func (m *Params) Reset() { *m = Params{} } @@ -121,6 +124,13 @@ func (m *Params) GetMinimumGasPrices() github_com_cosmos_cosmos_sdk_types.DecCoi return nil } +func (m *Params) GetBypassMinFeeMsgTypes() []string { + if m != nil { + return m.BypassMinFeeMsgTypes + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "gaia.globalfee.v1beta1.GenesisState") proto.RegisterType((*Params)(nil), "gaia.globalfee.v1beta1.Params") @@ -131,28 +141,32 @@ func init() { } var fileDescriptor_015b3e8b7a7c65c5 = []byte{ - // 325 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0x31, 0x4b, 0x03, 0x31, - 0x14, 0xc7, 0x2f, 0x08, 0x1d, 0xae, 0x0e, 0xe5, 0x10, 0xa9, 0xa5, 0xe4, 0xe4, 0x70, 0x28, 0xa8, - 0x09, 0xad, 0x9b, 0xe3, 0x29, 0x74, 0x2d, 0x75, 0x73, 0xa9, 0xb9, 0x33, 0xc6, 0x60, 0x73, 0x09, - 0x4d, 0x2a, 0xf6, 0x5b, 0xf8, 0x39, 0xfc, 0x0c, 0xee, 0x76, 0xec, 0xe8, 0x54, 0xe5, 0x6e, 0x73, - 0xf4, 0x13, 0xc8, 0x25, 0x67, 0x2b, 0x9c, 0x53, 0x02, 0xef, 0xf7, 0x7e, 0xff, 0xc7, 0x7b, 0xfe, - 0x11, 0x23, 0x9c, 0x60, 0x36, 0x95, 0x09, 0x99, 0xde, 0x51, 0x8a, 0x1f, 0xfb, 0x09, 0x35, 0xa4, - 0x8f, 0x19, 0xcd, 0xa8, 0xe6, 0x1a, 0xa9, 0x99, 0x34, 0x32, 0xd8, 0x2f, 0x29, 0xb4, 0xa1, 0x50, - 0x45, 0x75, 0xf6, 0x98, 0x64, 0xd2, 0x22, 0xb8, 0xfc, 0x39, 0xba, 0x03, 0x53, 0xa9, 0x85, 0xd4, - 0x38, 0x21, 0x7a, 0x2b, 0x4c, 0x25, 0xcf, 0x5c, 0x3d, 0xba, 0xf1, 0x77, 0x87, 0x4e, 0x7f, 0x65, - 0x88, 0xa1, 0xc1, 0xc8, 0x6f, 0x28, 0x32, 0x23, 0x42, 0xb7, 0xc1, 0x21, 0xe8, 0x35, 0x07, 0x10, - 0xfd, 0x1f, 0x87, 0x46, 0x96, 0x8a, 0xdb, 0xcb, 0x75, 0xe8, 0x7d, 0xad, 0xc3, 0x96, 0xeb, 0x3a, - 0x91, 0x82, 0x1b, 0x2a, 0x94, 0x59, 0x8c, 0x2b, 0x4f, 0xf4, 0x06, 0xfc, 0x86, 0x83, 0x83, 0x57, - 0xe0, 0x07, 0x82, 0x67, 0x5c, 0xcc, 0xc5, 0x84, 0x11, 0x3d, 0x51, 0x33, 0x9e, 0xd2, 0x32, 0x69, - 0xa7, 0xd7, 0x1c, 0x74, 0x91, 0x1b, 0x15, 0x95, 0xa3, 0x6e, 0x62, 0x2e, 0x69, 0x7a, 0x21, 0x79, - 0x16, 0xab, 0x2a, 0xa7, 0x5b, 0xef, 0xdf, 0x66, 0x7e, 0xaf, 0xc3, 0x83, 0x05, 0x11, 0xd3, 0xf3, - 0xa8, 0x4e, 0x45, 0x2f, 0x1f, 0xe1, 0x31, 0xe3, 0xe6, 0x7e, 0x9e, 0xa0, 0x54, 0x0a, 0x5c, 0xed, - 0xc5, 0x3d, 0xa7, 0xfa, 0xf6, 0x01, 0x9b, 0x85, 0xa2, 0xfa, 0x37, 0x50, 0x8f, 0x5b, 0x95, 0x63, - 0x48, 0xf4, 0xc8, 0x1a, 0xe2, 0x78, 0x99, 0x43, 0xb0, 0xca, 0x21, 0xf8, 0xcc, 0x21, 0x78, 0x2e, - 0xa0, 0xb7, 0x2a, 0xa0, 0xf7, 0x5e, 0x40, 0xef, 0xba, 0x57, 0x17, 0xdb, 0x5b, 0x3e, 0xfd, 0xb9, - 0xa6, 0xd5, 0x27, 0x0d, 0xbb, 0xf6, 0xb3, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x48, 0x6d, 0x01, - 0xcd, 0xec, 0x01, 0x00, 0x00, + // 390 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xb1, 0x6a, 0xe3, 0x30, + 0x18, 0xc7, 0xed, 0x04, 0x02, 0xe7, 0xdc, 0x10, 0x4c, 0x38, 0x7c, 0x21, 0xc8, 0xc1, 0xdc, 0x60, + 0xb8, 0x3b, 0x99, 0xe4, 0xb6, 0x1b, 0xdd, 0xd2, 0xd0, 0x21, 0x10, 0xd2, 0x4e, 0x5d, 0x5c, 0xd9, + 0x55, 0x54, 0xd1, 0xc8, 0x32, 0x91, 0x52, 0xea, 0xb1, 0x6f, 0xd0, 0xe7, 0xe8, 0x33, 0xf4, 0x01, + 0x02, 0x5d, 0x32, 0x76, 0x72, 0x4b, 0xb2, 0x65, 0xec, 0x13, 0x14, 0x5b, 0x6e, 0xd2, 0x92, 0x66, + 0x92, 0xd0, 0xf7, 0xfb, 0xfe, 0xff, 0xbf, 0xa4, 0xcf, 0xf8, 0x45, 0x10, 0x45, 0x1e, 0x99, 0xf0, + 0x10, 0x4d, 0xc6, 0x18, 0x7b, 0xd7, 0xdd, 0x10, 0x4b, 0xd4, 0xf5, 0x08, 0x8e, 0xb1, 0xa0, 0x02, + 0x26, 0x53, 0x2e, 0xb9, 0xf9, 0x23, 0xa7, 0xe0, 0x86, 0x82, 0x25, 0xd5, 0x6a, 0x12, 0x4e, 0x78, + 0x81, 0x78, 0xf9, 0x4e, 0xd1, 0x2d, 0x10, 0x71, 0xc1, 0xb8, 0xf0, 0x42, 0x24, 0xb6, 0x82, 0x11, + 0xa7, 0xb1, 0xaa, 0x3b, 0xe7, 0xc6, 0xf7, 0xbe, 0x92, 0x3f, 0x91, 0x48, 0x62, 0x73, 0x68, 0xd4, + 0x12, 0x34, 0x45, 0x4c, 0x58, 0x7a, 0x47, 0x77, 0xeb, 0x3d, 0x00, 0xbf, 0xb6, 0x83, 0xc3, 0x82, + 0xf2, 0xad, 0x79, 0x66, 0x6b, 0xeb, 0xcc, 0x6e, 0xa8, 0xae, 0x3f, 0x9c, 0x51, 0x89, 0x59, 0x22, + 0xd3, 0x51, 0xa9, 0xe3, 0x3c, 0x56, 0x8c, 0x9a, 0x82, 0xcd, 0x07, 0xdd, 0x30, 0x19, 0x8d, 0x29, + 0x9b, 0xb1, 0x80, 0x20, 0x11, 0x24, 0x53, 0x1a, 0xe1, 0xdc, 0xa9, 0xea, 0xd6, 0x7b, 0x6d, 0xa8, + 0xa2, 0xc2, 0x3c, 0xea, 0xc6, 0xe6, 0x10, 0x47, 0x07, 0x9c, 0xc6, 0x7e, 0x52, 0xfa, 0xb4, 0x77, + 0xfb, 0xb7, 0x9e, 0xaf, 0x99, 0xfd, 0x33, 0x45, 0x6c, 0xf2, 0xdf, 0xd9, 0xa5, 0x9c, 0xfb, 0x67, + 0xfb, 0x37, 0xa1, 0xf2, 0x72, 0x16, 0xc2, 0x88, 0x33, 0xaf, 0x7c, 0x17, 0xb5, 0xfc, 0x15, 0x17, + 0x57, 0x9e, 0x4c, 0x13, 0x2c, 0xde, 0x0d, 0xc5, 0xa8, 0x51, 0x6a, 0xf4, 0x91, 0x18, 0x16, 0x0a, + 0xe6, 0xad, 0x6e, 0x58, 0x61, 0x9a, 0x20, 0x21, 0x02, 0x46, 0xe3, 0x60, 0x8c, 0x71, 0xc0, 0x04, + 0x09, 0x8a, 0x3e, 0xab, 0xd2, 0xa9, 0xba, 0xdf, 0xfc, 0xe3, 0x75, 0x66, 0x3b, 0xfb, 0x98, 0x4f, + 0x41, 0x6d, 0x15, 0x74, 0x1f, 0xeb, 0x8c, 0x9a, 0xaa, 0x34, 0xa0, 0xf1, 0x11, 0xc6, 0x03, 0x41, + 0x4e, 0xf3, 0x63, 0xdf, 0x9f, 0x2f, 0x81, 0xbe, 0x58, 0x02, 0xfd, 0x65, 0x09, 0xf4, 0xbb, 0x15, + 0xd0, 0x16, 0x2b, 0xa0, 0x3d, 0xad, 0x80, 0x76, 0xe6, 0xee, 0x5e, 0xae, 0x98, 0xa7, 0x9b, 0x0f, + 0x13, 0x55, 0x48, 0x87, 0xb5, 0xe2, 0xeb, 0xff, 0xbd, 0x05, 0x00, 0x00, 0xff, 0xff, 0x05, 0x8f, + 0x3e, 0xdc, 0x70, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -208,6 +222,15 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.BypassMinFeeMsgTypes) > 0 { + for iNdEx := len(m.BypassMinFeeMsgTypes) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.BypassMinFeeMsgTypes[iNdEx]) + copy(dAtA[i:], m.BypassMinFeeMsgTypes[iNdEx]) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.BypassMinFeeMsgTypes[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } if len(m.MinimumGasPrices) > 0 { for iNdEx := len(m.MinimumGasPrices) - 1; iNdEx >= 0; iNdEx-- { { @@ -259,6 +282,12 @@ func (m *Params) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.BypassMinFeeMsgTypes) > 0 { + for _, s := range m.BypassMinFeeMsgTypes { + l = len(s) + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -414,6 +443,38 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BypassMinFeeMsgTypes", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BypassMinFeeMsgTypes = append(m.BypassMinFeeMsgTypes, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/globalfee/types/params.go b/x/globalfee/types/params.go index 7161b2c3e6f..2e7c9295578 100644 --- a/x/globalfee/types/params.go +++ b/x/globalfee/types/params.go @@ -6,14 +6,34 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" + ibcchanneltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types" ) +// DefaultBypassMinFeeMsgTypes defines the list of IBC message types +// which bypass the global min fee +func DefaultBypassMinFeeMsgTypes() []string { + return []string{ + sdk.MsgTypeURL(&ibcchanneltypes.MsgRecvPacket{}), + sdk.MsgTypeURL(&ibcchanneltypes.MsgAcknowledgement{}), + sdk.MsgTypeURL(&ibcclienttypes.MsgUpdateClient{}), + sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeout{}), + sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeoutOnClose{}), + } +} + // ParamStoreKeyMinGasPrices store key -var ParamStoreKeyMinGasPrices = []byte("MinimumGasPricesParam") +var ( + ParamStoreKeyMinGasPrices = []byte("MinimumGasPricesParam") + ParamStoreKeyBypassMinFeeMsgTypes = []byte("BypassMinFeeMsgTypesParam") +) // DefaultParams returns default parameters func DefaultParams() Params { - return Params{MinimumGasPrices: sdk.DecCoins{}} + return Params{ + MinimumGasPrices: sdk.DecCoins{}, + BypassMinFeeMsgTypes: DefaultBypassMinFeeMsgTypes(), + } } func ParamKeyTable() paramtypes.KeyTable { @@ -22,7 +42,15 @@ func ParamKeyTable() paramtypes.KeyTable { // ValidateBasic performs basic validation. func (p Params) ValidateBasic() error { - return validateMinimumGasPrices(p.MinimumGasPrices) + if err := validateMinimumGasPrices(p.MinimumGasPrices); err != nil { + return err + } + + if err := validateBypassMinFeeMsgTypes(p.BypassMinFeeMsgTypes); err != nil { + return err + } + + return nil } // ParamSetPairs returns the parameter set pairs. @@ -31,6 +59,9 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair( ParamStoreKeyMinGasPrices, &p.MinimumGasPrices, validateMinimumGasPrices, ), + paramtypes.NewParamSetPair( + ParamStoreKeyBypassMinFeeMsgTypes, &p.BypassMinFeeMsgTypes, validateBypassMinFeeMsgTypes, + ), } } @@ -45,6 +76,25 @@ func validateMinimumGasPrices(i interface{}) error { return dec.Validate() } +type BypassMinFeeMsgTypes []string + +// TODO: add more conditions to verify the message type name +// +// validateBypassMinFeeMsgTypes checks that bypass msg types aren't empty +func validateBypassMinFeeMsgTypes(i interface{}) error { + bypassMinFeeMsgTypes, ok := i.([]string) + if !ok { + return fmt.Errorf("invalid bypass msg type: %T", bypassMinFeeMsgTypes) + } + + for _, msgType := range bypassMinFeeMsgTypes { + if msgType == "" { + return fmt.Errorf("invalid empty bypass msg type") + } + } + return nil +} + type DecCoins sdk.DecCoins // Validate checks that the DecCoins are sorted, have nonnegtive amount, with a valid and unique diff --git a/x/globalfee/types/params_test.go b/x/globalfee/types/params_test.go index ba53a7f1f7f..b506b3d71e2 100644 --- a/x/globalfee/types/params_test.go +++ b/x/globalfee/types/params_test.go @@ -10,9 +10,10 @@ import ( func TestDefaultParams(t *testing.T) { p := DefaultParams() require.EqualValues(t, p.MinimumGasPrices, sdk.DecCoins{}) + require.EqualValues(t, p.BypassMinFeeMsgTypes, DefaultBypassMinFeeMsgTypes) } -func Test_validateParams(t *testing.T) { +func Test_validateMinGasPrices(t *testing.T) { tests := map[string]struct { coins interface{} // not sdk.DeCoins, but Decoins defined in glboalfee expectErr bool @@ -71,3 +72,38 @@ func Test_validateParams(t *testing.T) { }) } } + +func Test_validateBypassMinFeeMsgTypes(t *testing.T) { + tests := map[string]struct { + msgTypes interface{} // not sdk.DeCoins, but Decoins defined in global fee + expectErr bool + }{ + "DefaultParams, pass": { + DefaultParams().BypassMinFeeMsgTypes, + false, + }, + "wrong msg type should make conversion fail, fail": { + []int{0, 1, 2, 3}, + true, + }, + "empty msg types, pass": { + []string{}, + false, + }, + "empty msg type, fail": { + []string{""}, + true, + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + err := validateBypassMinFeeMsgTypes(test.msgTypes) + if test.expectErr { + require.Error(t, err) + return + } + require.NoError(t, err) + }) + } +} From e7b49a5b3ecb3ddaa9abd4edb640978d03c05331 Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Tue, 4 Apr 2023 12:27:43 +0200 Subject: [PATCH 09/47] feat: add validateBypassMinFeeMsgTypes --- x/globalfee/types/params.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/x/globalfee/types/params.go b/x/globalfee/types/params.go index cf2922fee8b..ef8cfe38a4c 100644 --- a/x/globalfee/types/params.go +++ b/x/globalfee/types/params.go @@ -90,8 +90,13 @@ func validateMinimumGasPrices(i interface{}) error { return dec.Validate() } -// todo check if args string +// todo check if correct? func validateBypassMinFeeMsgTypes(i interface{}) error { + _, ok := i.([]sdk.Msg) + if !ok { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "type: %T, expected []sdk.Msg", i) + } + return nil } From c57f7e9422f2987adeb468260fbf418c6e72aa7f Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Tue, 4 Apr 2023 15:25:59 +0200 Subject: [PATCH 10/47] update fee decorator and global fee genesis --- ante/ante.go | 2 +- x/globalfee/ante/antetest/fee_test.go | 13 ++++-- x/globalfee/ante/antetest/fee_test_setup.go | 2 +- x/globalfee/ante/fee.go | 20 ++++++--- x/globalfee/genesis_test.go | 47 ++++++++++++++++----- x/globalfee/types/params_test.go | 2 +- 6 files changed, 64 insertions(+), 22 deletions(-) diff --git a/ante/ante.go b/ante/ante.go index 16c82eb6dd4..c68d538f1bb 100644 --- a/ante/ante.go +++ b/ante/ante.go @@ -68,7 +68,7 @@ func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) { ante.NewValidateMemoDecorator(opts.AccountKeeper), ante.NewConsumeGasForTxSizeDecorator(opts.AccountKeeper), NewGovPreventSpamDecorator(opts.Codec, opts.GovKeeper), - gaiafeeante.NewFeeDecorator(opts.BypassMinFeeMsgTypes, opts.GlobalFeeSubspace, opts.StakingSubspace, maxTotalBypassMinFeeMsgGasUsage), + gaiafeeante.NewFeeDecorator(opts.GlobalFeeSubspace, opts.StakingSubspace, maxTotalBypassMinFeeMsgGasUsage), ante.NewDeductFeeDecorator(opts.AccountKeeper, opts.BankKeeper, opts.FeegrantKeeper), ante.NewSetPubKeyDecorator(opts.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators ante.NewValidateSigCountDecorator(opts.AccountKeeper), diff --git a/x/globalfee/ante/antetest/fee_test.go b/x/globalfee/ante/antetest/fee_test.go index cf144b1f616..78e98a04b70 100644 --- a/x/globalfee/ante/antetest/fee_test.go +++ b/x/globalfee/ante/antetest/fee_test.go @@ -596,7 +596,13 @@ func (s *IntegrationTestSuite) TestGlobalFeeMinimumGasFeeAnteHandler() { for name, tc := range testCases { s.Run(name, func() { // set globalfees and min gas price - _, antehandler := s.SetupTestGlobalFeeStoreAndMinGasPrice(tc.minGasPrice, tc.globalFeeParams) + _, antehandler := s.SetupTestGlobalFeeStoreAndMinGasPrice( + tc.minGasPrice, + &globfeetypes.Params{ + MinimumGasPrices: tc.globalFeeParams.MinimumGasPrices, + BypassMinFeeMsgTypes: globfeetypes.DefaultBypassMinFeeMsgTypes(), + }, + ) // set fee decorator to ante handler @@ -694,7 +700,8 @@ func (s *IntegrationTestSuite) TestGetMinGasPrice() { func (s *IntegrationTestSuite) TestContainsOnlyBypassMinFeeMsgs() { // set globalfees and min gas price - feeDecorator, _ := s.SetupTestGlobalFeeStoreAndMinGasPrice([]sdk.DecCoin{}, &globfeetypes.Params{}) + feeDecorator, _ := s.SetupTestGlobalFeeStoreAndMinGasPrice([]sdk.DecCoin{}, &globfeetypes.Params{BypassMinFeeMsgTypes: globfeetypes.DefaultBypassMinFeeMsgTypes()}) + feeDecorator.ContainsOnlyBypassMinFeeMsgs(s.ctx, []sdk.Msg{ibcchanneltypes.NewMsgRecvPacket(ibcchanneltypes.Packet{}, nil, ibcclienttypes.Height{}, "")}) testCases := []struct { name string @@ -741,7 +748,7 @@ func (s *IntegrationTestSuite) TestContainsOnlyBypassMinFeeMsgs() { for _, tc := range testCases { s.Run(tc.name, func() { - res := feeDecorator.ContainsOnlyBypassMinFeeMsgs(tc.msgs) + res := feeDecorator.ContainsOnlyBypassMinFeeMsgs(s.ctx, tc.msgs) s.Require().True(tc.expPass == res) }) } diff --git a/x/globalfee/ante/antetest/fee_test_setup.go b/x/globalfee/ante/antetest/fee_test_setup.go index c1508126a63..a029ffd8a98 100644 --- a/x/globalfee/ante/antetest/fee_test_setup.go +++ b/x/globalfee/ante/antetest/fee_test_setup.go @@ -65,7 +65,7 @@ func (s *IntegrationTestSuite) SetupTestGlobalFeeStoreAndMinGasPrice(minGasPrice stakingSubspace := s.SetupTestStakingSubspace(stakingParam) // build fee decorator - feeDecorator := gaiafeeante.NewFeeDecorator(gaiaapp.GetDefaultBypassFeeMessages(), subspace, stakingSubspace, uint64(1_000_000)) + feeDecorator := gaiafeeante.NewFeeDecorator(subspace, stakingSubspace, uint64(1_000_000)) // chain fee decorator to antehandler antehandler := sdk.ChainAnteDecorators(feeDecorator) diff --git a/x/globalfee/ante/fee.go b/x/globalfee/ante/fee.go index da869608f9e..f8d94f4aa0f 100644 --- a/x/globalfee/ante/fee.go +++ b/x/globalfee/ante/fee.go @@ -29,13 +29,12 @@ import ( var _ sdk.AnteDecorator = FeeDecorator{} type FeeDecorator struct { - BypassMinFeeMsgTypes []string GlobalMinFee globalfee.ParamSource StakingSubspace paramtypes.Subspace MaxTotalBypassMinFeeMsgGasUsage uint64 } -func NewFeeDecorator(bypassMsgTypes []string, globalfeeSubspace, stakingSubspace paramtypes.Subspace, maxTotalBypassMinFeeMsgGasUsage uint64) FeeDecorator { +func NewFeeDecorator(globalfeeSubspace, stakingSubspace paramtypes.Subspace, maxTotalBypassMinFeeMsgGasUsage uint64) FeeDecorator { if !globalfeeSubspace.HasKeyTable() { panic("global fee paramspace was not set up via module") } @@ -45,7 +44,6 @@ func NewFeeDecorator(bypassMsgTypes []string, globalfeeSubspace, stakingSubspace } return FeeDecorator{ - BypassMinFeeMsgTypes: bypassMsgTypes, GlobalMinFee: globalfeeSubspace, StakingSubspace: stakingSubspace, MaxTotalBypassMinFeeMsgGasUsage: maxTotalBypassMinFeeMsgGasUsage, @@ -86,7 +84,7 @@ func (mfd FeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, ne // // Otherwise, minimum fees and global fees are checked to prevent spam. doesNotExceedMaxGasUsage := gas <= mfd.MaxTotalBypassMinFeeMsgGasUsage - allowedToBypassMinFee := mfd.ContainsOnlyBypassMinFeeMsgs(msgs) && doesNotExceedMaxGasUsage + allowedToBypassMinFee := mfd.ContainsOnlyBypassMinFeeMsgs(ctx, msgs) && doesNotExceedMaxGasUsage if allowedToBypassMinFee { // Transactions with zero fees are accepted @@ -172,11 +170,21 @@ func (mfd FeeDecorator) getBondDenom(ctx sdk.Context) string { return bondDenom } +func (mfd FeeDecorator) getBypassMsgTypes(ctx sdk.Context) []string { + var bypassMinFeeMsgTypes []string + + if mfd.GlobalMinFee.Has(ctx, types.ParamStoreKeyBypassMinFeeMsgTypes) { + mfd.GlobalMinFee.Get(ctx, types.ParamStoreKeyBypassMinFeeMsgTypes, &bypassMinFeeMsgTypes) + } + + return bypassMinFeeMsgTypes +} + // ContainsOnlyBypassMinFeeMsgs returns true if all the given msgs type are listed // in the BypassMinFeeMsgTypes of the FeeDecorator. -func (mfd FeeDecorator) ContainsOnlyBypassMinFeeMsgs(msgs []sdk.Msg) bool { +func (mfd FeeDecorator) ContainsOnlyBypassMinFeeMsgs(ctx sdk.Context, msgs []sdk.Msg) bool { for _, msg := range msgs { - if tmstrings.StringInSlice(sdk.MsgTypeURL(msg), mfd.BypassMinFeeMsgTypes) { + if tmstrings.StringInSlice(sdk.MsgTypeURL(msg), mfd.getBypassMsgTypes(ctx)) { continue } return false diff --git a/x/globalfee/genesis_test.go b/x/globalfee/genesis_test.go index bde6e109753..2844fa355c8 100644 --- a/x/globalfee/genesis_test.go +++ b/x/globalfee/genesis_test.go @@ -23,7 +23,9 @@ import ( func TestDefaultGenesis(t *testing.T) { encCfg := simapp.MakeTestEncodingConfig() gotJSON := AppModuleBasic{}.DefaultGenesis(encCfg.Marshaler) - assert.JSONEq(t, `{"params":{"minimum_gas_prices":[]}}`, string(gotJSON), string(gotJSON)) + assert.JSONEq(t, + `{"params":{"minimum_gas_prices":[],"bypass_min_fee_msg_types":["/ibc.core.channel.v1.MsgRecvPacket","/ibc.core.channel.v1.MsgAcknowledgement","/ibc.core.client.v1.MsgUpdateClient","/ibc.core.channel.v1.MsgTimeout","/ibc.core.channel.v1.MsgTimeoutOnClose"]}}`, + string(gotJSON), string(gotJSON)) } func TestValidateGenesis(t *testing.T) { @@ -33,14 +35,20 @@ func TestValidateGenesis(t *testing.T) { expErr bool }{ "all good": { - src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"1"}]}}`, + src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"1"}], "bypass_min_fee_msg_types":["/ibc.core.channel.v1.MsgRecvPacket"]}}`, }, "empty minimum": { - src: `{"params":{"minimum_gas_prices":[]}}`, + src: `{"params":{"minimum_gas_prices":[], "bypass_min_fee_msg_types":[]}}`, }, - "minimum not set": { + "minimum and bypass not set": { src: `{"params":{}}`, }, + "minimum not set": { + src: `{"params":{"bypass_min_fee_msg_types":[]}}`, + }, + "bypass not set": { + src: `{"params":{"minimum_gas_prices":[]}}`, + }, "zero amount allowed": { src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"0"}]}}`, expErr: false, @@ -57,6 +65,10 @@ func TestValidateGenesis(t *testing.T) { src: `{"params":{"minimum_gas_prices":[{"denom":"ZLX", "amount":"1"},{"denom":"ALX", "amount":"2"}]}}`, expErr: true, }, + "empty bypass msg types not allowed": { + src: `{"params":{"bypass_min_fee_msg_types":[""]}}`, + expErr: true, + }, "sorted denoms is allowed": { src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"1"},{"denom":"ZLX", "amount":"2"}]}}`, expErr: false, @@ -80,17 +92,32 @@ func TestInitExportGenesis(t *testing.T) { exp types.GenesisState }{ "single fee": { - src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"1"}]}}`, - exp: types.GenesisState{Params: types.Params{MinimumGasPrices: sdk.NewDecCoins(sdk.NewDecCoin("ALX", sdk.NewInt(1)))}}, + src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"1"}], "bypass_min_fee_msg_types":["/ibc.core.channel.v1.MsgRecvPacket"]}}`, + exp: types.GenesisState{ + Params: types.Params{ + MinimumGasPrices: sdk.NewDecCoins(sdk.NewDecCoin("ALX", sdk.NewInt(1))), + BypassMinFeeMsgTypes: []string{"/ibc.core.channel.v1.MsgRecvPacket"}, + }, + }, }, "multiple fee options": { - src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"1"}, {"denom":"BLX", "amount":"0.001"}]}}`, - exp: types.GenesisState{Params: types.Params{MinimumGasPrices: sdk.NewDecCoins(sdk.NewDecCoin("ALX", sdk.NewInt(1)), - sdk.NewDecCoinFromDec("BLX", sdk.NewDecWithPrec(1, 3)))}}, + src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"1"}, {"denom":"BLX", "amount":"0.001"}], "bypass_min_fee_msg_types":["/ibc.core.channel.v1.MsgRecvPacket","/ibc.core.channel.v1.MsgTimeoutOnClose"]}}`, + exp: types.GenesisState{ + Params: types.Params{ + MinimumGasPrices: sdk.NewDecCoins(sdk.NewDecCoin("ALX", sdk.NewInt(1)), + sdk.NewDecCoinFromDec("BLX", sdk.NewDecWithPrec(1, 3))), + BypassMinFeeMsgTypes: []string{"/ibc.core.channel.v1.MsgRecvPacket", "/ibc.core.channel.v1.MsgTimeoutOnClose"}, + }, + }, }, "no fee set": { src: `{"params":{}}`, - exp: types.GenesisState{Params: types.Params{MinimumGasPrices: sdk.DecCoins{}}}, + exp: types.GenesisState{ + Params: types.Params{ + MinimumGasPrices: sdk.DecCoins{}, + BypassMinFeeMsgTypes: []string{}, + }, + }, }, } for name, spec := range specs { diff --git a/x/globalfee/types/params_test.go b/x/globalfee/types/params_test.go index b506b3d71e2..d6a5bd0a789 100644 --- a/x/globalfee/types/params_test.go +++ b/x/globalfee/types/params_test.go @@ -10,7 +10,7 @@ import ( func TestDefaultParams(t *testing.T) { p := DefaultParams() require.EqualValues(t, p.MinimumGasPrices, sdk.DecCoins{}) - require.EqualValues(t, p.BypassMinFeeMsgTypes, DefaultBypassMinFeeMsgTypes) + require.EqualValues(t, p.BypassMinFeeMsgTypes, DefaultBypassMinFeeMsgTypes()) } func Test_validateMinGasPrices(t *testing.T) { From 671cf7650b31e761c6f5b068982dfbb29cbc67c0 Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Tue, 4 Apr 2023 16:13:58 +0200 Subject: [PATCH 11/47] merge main --- app/app.go | 3 +- x/globalfee/types/params.go | 60 ++++++++++++++----------------------- 2 files changed, 23 insertions(+), 40 deletions(-) diff --git a/app/app.go b/app/app.go index 4e068e7980c..97fa2778725 100644 --- a/app/app.go +++ b/app/app.go @@ -7,8 +7,6 @@ import ( "os" "path/filepath" - "github.com/cosmos/gaia/v9/x/globalfee" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" @@ -45,6 +43,7 @@ import ( gaiaappparams "github.com/cosmos/gaia/v9/app/params" "github.com/cosmos/gaia/v9/app/upgrades" v9 "github.com/cosmos/gaia/v9/app/upgrades/v9" + "github.com/cosmos/gaia/v9/x/globalfee" globalfeetypes "github.com/cosmos/gaia/v9/x/globalfee/types" // unnamed import of statik for swagger UI support diff --git a/x/globalfee/types/params.go b/x/globalfee/types/params.go index 76603148c4f..e83ad718de3 100644 --- a/x/globalfee/types/params.go +++ b/x/globalfee/types/params.go @@ -113,53 +113,37 @@ func validateMaxTotalBypassMinFeeMsgGasUsage(i interface{}) error { return nil } -// Validate checks that the DecCoins are sorted, have nonnegtive amount, with a valid and unique -// denomination (i.e no duplicates). Otherwise, it returns an error. type DecCoins sdk.DecCoins +// Validate checks that the DecCoins are sorted, have nonnegtive amount, with a valid and unique +// denomination (i.e no duplicates). Otherwise, it returns an error. func (coins DecCoins) Validate() error { - switch len(coins) { - case 0: + if len(coins) == 0 { return nil + } - case 1: - // match the denom reg expr - if err := sdk.ValidateDenom(coins[0].Denom); err != nil { - return err - } - if coins[0].IsNegative() { - return fmt.Errorf("coin %s amount is negtive", coins[0]) + lowDenom := "" + seenDenoms := make(map[string]bool) + + for i, coin := range coins { + if seenDenoms[coin.Denom] { + return fmt.Errorf("duplicate denomination %s", coin.Denom) } - return nil - default: - // check single coin case - if err := (DecCoins{coins[0]}).Validate(); err != nil { + if err := sdk.ValidateDenom(coin.Denom); err != nil { return err } - - lowDenom := coins[0].Denom - seenDenoms := make(map[string]bool) - seenDenoms[lowDenom] = true - - for _, coin := range coins[1:] { - if seenDenoms[coin.Denom] { - return fmt.Errorf("duplicate denomination %s", coin.Denom) - } - if err := sdk.ValidateDenom(coin.Denom); err != nil { - return err - } - if coin.Denom <= lowDenom { - return fmt.Errorf("denomination %s is not sorted", coin.Denom) - } - if coin.IsNegative() { - return fmt.Errorf("coin %s amount is negtive", coin.Denom) - } - - // we compare each coin against the last denom - lowDenom = coin.Denom - seenDenoms[coin.Denom] = true + // skip the denom order check for the first denom in the coins list + if i != 0 && coin.Denom <= lowDenom { + return fmt.Errorf("denomination %s is not sorted", coin.Denom) + } + if coin.IsNegative() { + return fmt.Errorf("coin %s amount is negative", coin.Amount) } - return nil + // we compare each coin against the last denom + lowDenom = coin.Denom + seenDenoms[coin.Denom] = true } + + return nil } From 97b7e7bf2ebc9bff7774885101a9980553b3f7ce Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Tue, 4 Apr 2023 17:15:34 +0200 Subject: [PATCH 12/47] test: fix e2e test --- tests/e2e/query.go | 8 +++---- .../migrations/v2/{store.go => migration.go} | 8 +++++-- x/globalfee/migrations/v2/migration_test.go | 24 +++++++++++++++++++ x/globalfee/migrations/v2/store_test.go | 1 - 4 files changed, 34 insertions(+), 7 deletions(-) rename x/globalfee/migrations/v2/{store.go => migration.go} (75%) create mode 100644 x/globalfee/migrations/v2/migration_test.go delete mode 100644 x/globalfee/migrations/v2/store_test.go diff --git a/tests/e2e/query.go b/tests/e2e/query.go index e6f513a7ced..b8a7d711f5e 100644 --- a/tests/e2e/query.go +++ b/tests/e2e/query.go @@ -75,17 +75,17 @@ func queryGaiaAllBalances(endpoint, addr string) (sdk.Coins, error) { } func queryGlobalFees(endpoint string) (amt sdk.DecCoins, err error) { - body, err := httpGet(fmt.Sprintf("%s/gaia/globalfee/v1beta1/minimum_gas_prices", endpoint)) + body, err := httpGet(fmt.Sprintf("%s/gaia/globalfee/v1beta1/params", endpoint)) if err != nil { return nil, fmt.Errorf("failed to execute HTTP request: %w", err) } - var fees globalfee.QueryParamsResponse - if err := cdc.UnmarshalJSON(body, &fees); err != nil { + var params globalfee.QueryParamsResponse + if err := cdc.UnmarshalJSON(body, ¶ms); err != nil { return sdk.DecCoins{}, err } - return fees.MinimumGasPrices, nil + return params.MinimumGasPrices, nil } func queryDelegation(endpoint string, validatorAddr string, delegatorAddr string) (stakingtypes.QueryDelegationResponse, error) { diff --git a/x/globalfee/migrations/v2/store.go b/x/globalfee/migrations/v2/migration.go similarity index 75% rename from x/globalfee/migrations/v2/store.go rename to x/globalfee/migrations/v2/migration.go index cfe4f1b4e4a..6fb7a225c11 100644 --- a/x/globalfee/migrations/v2/store.go +++ b/x/globalfee/migrations/v2/migration.go @@ -6,14 +6,18 @@ import ( "github.com/cosmos/gaia/v9/x/globalfee/types" ) -// MigrateStore performs in-place store migrations. +// MigrateStore performs in-place params migrations of +// BypassMinFeeMsgTypes and MaxTotalBypassMinFeeMsgGasUsage +// from app.toml to globalfee params. // The migration includes: // Add bypass-min-fee-msg-types params that are set // ["/ibc.core.channel.v1.MsgRecvPacket", // "/ibc.core.channel.v1.MsgAcknowledgement", // "/ibc.core.client.v1.MsgUpdateClient", // "/ibc.core.channel.v1.MsgTimeout", -// "/ibc.core.channel.v1.MsgTimeoutOnClose"] asd default. +// "/ibc.core.channel.v1.MsgTimeoutOnClose"] as default and +// add MaxTotalBypassMinFeeMsgGasUsage that is set 1_000_000 as default. +// todo check name, migrateStore or migrateParams? func MigrateStore(ctx sdk.Context, globalfeeSubspace paramtypes.Subspace) error { var globalMinGasPrices sdk.DecCoins diff --git a/x/globalfee/migrations/v2/migration_test.go b/x/globalfee/migrations/v2/migration_test.go new file mode 100644 index 00000000000..689965f43cf --- /dev/null +++ b/x/globalfee/migrations/v2/migration_test.go @@ -0,0 +1,24 @@ +package v2 + +import ( + gaia "github.com/cosmos/gaia/v9/app" + "github.com/stretchr/testify/require" + + "testing" +) + +func TestMigrateStore(t *testing.T) { + cdc := gaia.MakeTestEncodingConfig().Codec + + // Run migrations. + err := MigrateStore(ctx, globalfeeSubspace) + require.NoError(t, err) + + // Check params + g + require.NoError(t, cdc.Unmarshal(bz, ¶ms)) + require.NotNil(t, params) + require.Equal(t, v1.DefaultParams().ExpeditedMinDeposit, params.ExpeditedMinDeposit) + require.Equal(t, v1.DefaultParams().ExpeditedThreshold, params.ExpeditedThreshold) + require.Equal(t, v1.DefaultParams().ExpeditedVotingPeriod, params.ExpeditedVotingPeriod) +} diff --git a/x/globalfee/migrations/v2/store_test.go b/x/globalfee/migrations/v2/store_test.go deleted file mode 100644 index 5ec3cc8e833..00000000000 --- a/x/globalfee/migrations/v2/store_test.go +++ /dev/null @@ -1 +0,0 @@ -package v2 From 1be66afafe8a95d888fa9754d2372788832b12cb Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Tue, 4 Apr 2023 17:17:38 +0200 Subject: [PATCH 13/47] test: add migration_test --- x/globalfee/migrations/v2/migration_test.go | 68 ++++++++++++++++----- 1 file changed, 54 insertions(+), 14 deletions(-) diff --git a/x/globalfee/migrations/v2/migration_test.go b/x/globalfee/migrations/v2/migration_test.go index 689965f43cf..9a3701e50b9 100644 --- a/x/globalfee/migrations/v2/migration_test.go +++ b/x/globalfee/migrations/v2/migration_test.go @@ -1,24 +1,64 @@ -package v2 +package v2_test import ( - gaia "github.com/cosmos/gaia/v9/app" - "github.com/stretchr/testify/require" - + "fmt" + v2 "github.com/cosmos/gaia/v9/x/globalfee/migrations/v2" "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdktypes "github.com/cosmos/cosmos-sdk/x/params/types" + gaiahelpers "github.com/cosmos/gaia/v9/app/helpers" // todo this is v9 when other packages gose to v10 + "github.com/cosmos/gaia/v9/x/globalfee" + globalfeetypes "github.com/cosmos/gaia/v9/x/globalfee/types" + "github.com/stretchr/testify/require" + tmrand "github.com/tendermint/tendermint/libs/rand" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) func TestMigrateStore(t *testing.T) { - cdc := gaia.MakeTestEncodingConfig().Codec + appV9 := gaiahelpers.Setup(t) + ctx := appV9.BaseApp.NewContext(false, tmproto.Header{ + ChainID: fmt.Sprintf("test-chain-%s", tmrand.Str(4)), + Height: 1, + }) - // Run migrations. - err := MigrateStore(ctx, globalfeeSubspace) + globalfeeSubspace := appV9.GetSubspace(globalfee.ModuleName) + + // todo: add this check back when the module is v10 + //_, ok := getBypassMsgTypes(globalfeeSubspace, ctx) + //require.Equal(t, ok, false) + //_, ok = getMaxTotalBypassMinFeeMsgGasUsage(globalfeeSubspace, ctx) + //require.Equal(t, ok, false) + + err := v2.MigrateStore(ctx, globalfeeSubspace) require.NoError(t, err) - // Check params - g - require.NoError(t, cdc.Unmarshal(bz, ¶ms)) - require.NotNil(t, params) - require.Equal(t, v1.DefaultParams().ExpeditedMinDeposit, params.ExpeditedMinDeposit) - require.Equal(t, v1.DefaultParams().ExpeditedThreshold, params.ExpeditedThreshold) - require.Equal(t, v1.DefaultParams().ExpeditedVotingPeriod, params.ExpeditedVotingPeriod) + bypassMsgTypes, _ := getBypassMsgTypes(globalfeeSubspace, ctx) + maxGas, _ := getMaxTotalBypassMinFeeMsgGasUsage(globalfeeSubspace, ctx) + + require.Equal(t, bypassMsgTypes, globalfeetypes.DefaultBypassMinFeeMsgTypes) + require.Equal(t, maxGas, globalfeetypes.DefaultmaxTotalBypassMinFeeMsgGasUsage) + require.Equal(t, sdk.DecCoins{}, globalfeetypes.DefaultMinGasPrices) +} + +func getBypassMsgTypes(globalfeeSubspace sdktypes.Subspace, ctx sdk.Context) ([]string, bool) { + bypassMsgs := []string{} + if globalfeeSubspace.Has(ctx, globalfeetypes.ParamStoreKeyBypassMinFeeMsgTypes) { + globalfeeSubspace.Get(ctx, globalfeetypes.ParamStoreKeyBypassMinFeeMsgTypes, &bypassMsgs) + } else { + return bypassMsgs, false + } + + return bypassMsgs, true +} + +func getMaxTotalBypassMinFeeMsgGasUsage(globalfeeSubspace sdktypes.Subspace, ctx sdk.Context) (uint64, bool) { + var maxTotalBypassMinFeeMsgGasUsage uint64 + if globalfeeSubspace.Has(ctx, globalfeetypes.ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage) { + globalfeeSubspace.Get(ctx, globalfeetypes.ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage, &maxTotalBypassMinFeeMsgGasUsage) + } else { + return maxTotalBypassMinFeeMsgGasUsage, false + } + + return maxTotalBypassMinFeeMsgGasUsage, true } From 1a427137a1f9708086bcd8d67955f63c6baba503 Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Tue, 4 Apr 2023 18:12:30 +0200 Subject: [PATCH 14/47] chore: add comments --- tests/e2e/e2e_bypassminfee_test.go | 1 + tests/e2e/e2e_setup_test.go | 1 + x/globalfee/types/params_test.go | 1 + 3 files changed, 3 insertions(+) diff --git a/tests/e2e/e2e_bypassminfee_test.go b/tests/e2e/e2e_bypassminfee_test.go index ecc16c25c30..2f83ce77287 100644 --- a/tests/e2e/e2e_bypassminfee_test.go +++ b/tests/e2e/e2e_bypassminfee_test.go @@ -5,6 +5,7 @@ import ( ) func (s *IntegrationTestSuite) testByPassMinFeeWithdrawReward() { + // todo gov propose withdraw to be bypass-msg first paidFeeAmt := math.LegacyMustNewDecFromStr(minGasPrice).Mul(math.LegacyNewDec(gas)).String() payee := s.chainA.validators[0].keyInfo.GetAddress() // pass diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 83e35e83c0d..ea92d8528a1 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -514,6 +514,7 @@ func (s *IntegrationTestSuite) initValidatorConfigs(c *chain) { }, } + // todo remove customAppTemplate := ` ############################################################################### ### Custom Gaia Configuration ### diff --git a/x/globalfee/types/params_test.go b/x/globalfee/types/params_test.go index ba53a7f1f7f..05db13d9964 100644 --- a/x/globalfee/types/params_test.go +++ b/x/globalfee/types/params_test.go @@ -12,6 +12,7 @@ func TestDefaultParams(t *testing.T) { require.EqualValues(t, p.MinimumGasPrices, sdk.DecCoins{}) } +// todo: add test for bypass and maxGas validation func Test_validateParams(t *testing.T) { tests := map[string]struct { coins interface{} // not sdk.DeCoins, but Decoins defined in glboalfee From 784dce92d1e9786842146fa64823d3280204a304 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Tue, 4 Apr 2023 18:33:18 +0200 Subject: [PATCH 15/47] remove bypass from config --- ante/ante.go | 11 ++++---- app/app.go | 49 ++++----------------------------- app/params/config.go | 55 ------------------------------------- cmd/gaiad/cmd/root.go | 5 +--- cmd/gaiad/cmd/testnet.go | 7 +---- tests/e2e/e2e_setup_test.go | 30 ++------------------ x/globalfee/module.go | 19 +++++++++++++ 7 files changed, 33 insertions(+), 143 deletions(-) delete mode 100644 app/params/config.go diff --git a/ante/ante.go b/ante/ante.go index c68d538f1bb..d020d66cadd 100644 --- a/ante/ante.go +++ b/ante/ante.go @@ -24,12 +24,11 @@ var maxTotalBypassMinFeeMsgGasUsage uint64 = 1_000_000 // channel keeper. type HandlerOptions struct { ante.HandlerOptions - Codec codec.BinaryCodec - GovKeeper *govkeeper.Keeper - IBCkeeper *ibckeeper.Keeper - BypassMinFeeMsgTypes []string - GlobalFeeSubspace paramtypes.Subspace - StakingSubspace paramtypes.Subspace + Codec codec.BinaryCodec + GovKeeper *govkeeper.Keeper + IBCkeeper *ibckeeper.Keeper + GlobalFeeSubspace paramtypes.Subspace + StakingSubspace paramtypes.Subspace } func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) { diff --git a/app/app.go b/app/app.go index a24db610e5a..d0eb273665b 100644 --- a/app/app.go +++ b/app/app.go @@ -28,8 +28,6 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" - ibcchanneltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types" ibctesting "github.com/cosmos/interchain-security/legacy_ibc_testing/testing" "github.com/gorilla/mux" "github.com/rakyll/statik/fs" @@ -188,21 +186,6 @@ func NewGaiaApp( app.MountTransientStores(app.GetTransientStoreKey()) app.MountMemoryStores(app.GetMemoryStoreKey()) - var bypassMinFeeMsgTypes []string - bypassMinFeeMsgTypesOptions := appOpts.Get(gaiaappparams.BypassMinFeeMsgTypesKey) - if bypassMinFeeMsgTypesOptions == nil { - bypassMinFeeMsgTypes = GetDefaultBypassFeeMessages() - } else { - bypassMinFeeMsgTypes = cast.ToStringSlice(bypassMinFeeMsgTypesOptions) - } - - if err := app.ValidateBypassFeeMsgTypes(bypassMinFeeMsgTypes); err != nil { - app.Logger().Error("invalid 'bypass-min-fee-msg-types' config option", "error", err) - panic(fmt.Sprintf("invalid 'bypass-min-fee-msg-types' config option: %s", err)) - } - - app.Logger().Info("min fee bypass activated for message types", "types", bypassMinFeeMsgTypes) - anteHandler, err := gaiaante.NewAnteHandler( gaiaante.HandlerOptions{ HandlerOptions: ante.HandlerOptions{ @@ -212,12 +195,11 @@ func NewGaiaApp( SignModeHandler: encodingConfig.TxConfig.SignModeHandler(), SigGasConsumer: ante.DefaultSigVerificationGasConsumer, }, - Codec: appCodec, - IBCkeeper: app.IBCKeeper, - GovKeeper: &app.GovKeeper, - BypassMinFeeMsgTypes: bypassMinFeeMsgTypes, - GlobalFeeSubspace: app.GetSubspace(globalfee.ModuleName), - StakingSubspace: app.GetSubspace(stakingtypes.ModuleName), + Codec: appCodec, + IBCkeeper: app.IBCKeeper, + GovKeeper: &app.GovKeeper, + GlobalFeeSubspace: app.GetSubspace(globalfee.ModuleName), + StakingSubspace: app.GetSubspace(stakingtypes.ModuleName), }, ) if err != nil { @@ -241,27 +223,6 @@ func NewGaiaApp( return app } -func GetDefaultBypassFeeMessages() []string { - return []string{ - sdk.MsgTypeURL(&ibcchanneltypes.MsgRecvPacket{}), - sdk.MsgTypeURL(&ibcchanneltypes.MsgAcknowledgement{}), - sdk.MsgTypeURL(&ibcclienttypes.MsgUpdateClient{}), - sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeout{}), - sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeoutOnClose{}), - } -} - -// ValidateBypassFeeMsgTypes checks that a proto message type exists for all MsgTypes in bypassMinFeeMsgTypes -// An error is returned for the first msgType that cannot be resolved -func (app *GaiaApp) ValidateBypassFeeMsgTypes(bypassMinFeeMsgTypes []string) error { - for _, msgType := range bypassMinFeeMsgTypes { - if _, err := app.interfaceRegistry.Resolve(msgType); err != nil { - return err - } - } - return nil -} - // Name returns the name of the App func (app *GaiaApp) Name() string { return app.BaseApp.Name() } diff --git a/app/params/config.go b/app/params/config.go deleted file mode 100644 index 883330c37c3..00000000000 --- a/app/params/config.go +++ /dev/null @@ -1,55 +0,0 @@ -package params - -import ( - "strings" - - serverconfig "github.com/cosmos/cosmos-sdk/server/config" -) - -var ( - // BypassMinFeeMsgTypesKey defines the configuration key for the - // BypassMinFeeMsgTypes value. - //nolint: gosec - BypassMinFeeMsgTypesKey = "bypass-min-fee-msg-types" - - // customGaiaConfigTemplate defines Gaia's custom application configuration TOML template. - customGaiaConfigTemplate = ` -############################################################################### -### Custom Gaia Configuration ### -############################################################################### -# bypass-min-fee-msg-types defines custom message types the operator may set that -# will bypass minimum fee checks during CheckTx. -# NOTE: -# bypass-min-fee-msg-types = [] will deactivate the bypass - no messages will be allowed to bypass the minimum fee check -# bypass-min-fee-msg-types = [...] will allow messages of specified type to bypass the minimum fee check -# removing bypass-min-fee-msg-types from the config file will apply the default values: -# ["/ibc.core.channel.v1.MsgRecvPacket", "/ibc.core.channel.v1.MsgAcknowledgement", "/ibc.core.client.v1.MsgUpdateClient"] -# -# Example: -# bypass-min-fee-msg-types = ["/ibc.core.channel.v1.MsgRecvPacket", "/ibc.core.channel.v1.MsgAcknowledgement", "/ibc.core.client.v1.MsgUpdateClient"] -bypass-min-fee-msg-types = [{{ range .BypassMinFeeMsgTypes }}{{ printf "%q, " . }}{{end}}] -` -) - -// CustomConfigTemplate defines Gaia's custom application configuration TOML -// template. It extends the core SDK template. -func CustomConfigTemplate() string { - config := serverconfig.DefaultConfigTemplate - lines := strings.Split(config, "\n") - // add the Gaia config at the second line of the file - lines[2] += customGaiaConfigTemplate - return strings.Join(lines, "\n") -} - -// CustomAppConfig defines Gaia's custom application configuration. -type CustomAppConfig struct { - serverconfig.Config - - // BypassMinFeeMsgTypes defines custom message types the operator may set that - // will bypass minimum fee checks during CheckTx. - // NOTE: - // bypass-min-fee-msg-types = [] will deactivate the bypass - no messages will be allowed to bypass the minimum fee check - // bypass-min-fee-msg-types = [] will allow messages of specified type to bypass the minimum fee check - // omitting bypass-min-fee-msg-types from the config file will use the default values: ["/ibc.core.channel.v1.MsgRecvPacket", "/ibc.core.channel.v1.MsgAcknowledgement", "/ibc.core.client.v1.MsgUpdateClient"] - BypassMinFeeMsgTypes []string `mapstructure:"bypass-min-fee-msg-types"` -} diff --git a/cmd/gaiad/cmd/root.go b/cmd/gaiad/cmd/root.go index 2183e7fac6c..75611a45ad2 100644 --- a/cmd/gaiad/cmd/root.go +++ b/cmd/gaiad/cmd/root.go @@ -81,10 +81,7 @@ func initAppConfig() (string, interface{}) { srvCfg.StateSync.SnapshotInterval = 1000 srvCfg.StateSync.SnapshotKeepRecent = 10 - return params.CustomConfigTemplate(), params.CustomAppConfig{ - Config: *srvCfg, - BypassMinFeeMsgTypes: gaia.GetDefaultBypassFeeMessages(), - } + return serverconfig.DefaultConfigTemplate, *srvCfg } func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { diff --git a/cmd/gaiad/cmd/testnet.go b/cmd/gaiad/cmd/testnet.go index 10210d103ec..997ebfed7fc 100644 --- a/cmd/gaiad/cmd/testnet.go +++ b/cmd/gaiad/cmd/testnet.go @@ -30,11 +30,8 @@ import ( tmrand "github.com/tendermint/tendermint/libs/rand" "github.com/tendermint/tendermint/types" tmtime "github.com/tendermint/tendermint/types/time" - // ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" // ibcchanneltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types" - - "github.com/cosmos/gaia/v9/app/params" ) var ( @@ -149,9 +146,7 @@ func InitTestnet( nodeIDs := make([]string, numValidators) valPubKeys := make([]cryptotypes.PubKey, numValidators) - simappConfig := params.CustomAppConfig{ - Config: *srvconfig.DefaultConfig(), - } + simappConfig := *srvconfig.DefaultConfig() simappConfig.MinGasPrices = minGasPrices simappConfig.API.Enable = true simappConfig.Telemetry.Enabled = true diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 83e35e83c0d..01733ca0fc7 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -29,7 +29,6 @@ import ( genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" - ibcchanneltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types" "github.com/ory/dockertest/v3" "github.com/ory/dockertest/v3/docker" "github.com/spf13/viper" @@ -38,8 +37,6 @@ import ( tmjson "github.com/tendermint/tendermint/libs/json" "github.com/tendermint/tendermint/libs/rand" rpchttp "github.com/tendermint/tendermint/rpc/client/http" - - "github.com/cosmos/gaia/v9/app/params" ) const ( @@ -502,31 +499,8 @@ func (s *IntegrationTestSuite) initValidatorConfigs(c *chain) { appConfig.API.Enable = true appConfig.MinGasPrices = fmt.Sprintf("%s%s", minGasPrice, uatomDenom) - // srvconfig.WriteConfigFile(appCfgPath, appConfig) - appCustomConfig := params.CustomAppConfig{ - Config: *appConfig, - BypassMinFeeMsgTypes: []string{ - // todo: use ibc as example ? - sdk.MsgTypeURL(&ibcchanneltypes.MsgRecvPacket{}), - sdk.MsgTypeURL(&ibcchanneltypes.MsgAcknowledgement{}), - sdk.MsgTypeURL(&ibcclienttypes.MsgUpdateClient{}), - "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", - }, - } - - customAppTemplate := ` -############################################################################### -### Custom Gaia Configuration ### -############################################################################### -# bypass-min-fee-msg-types defines custom message types the operator may set that -# will bypass minimum fee checks during CheckTx. -# -# Example: -# ["/ibc.core.channel.v1.MsgRecvPacket", "/ibc.core.channel.v1.MsgAcknowledgement", ...] -bypass-min-fee-msg-types = ["/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward","/ibc.applications.transfer.v1.MsgTransfer"] -` + srvconfig.DefaultConfigTemplate - srvconfig.SetConfigTemplate(customAppTemplate) - srvconfig.WriteConfigFile(appCfgPath, appCustomConfig) + srvconfig.SetConfigTemplate(srvconfig.DefaultConfigTemplate) + srvconfig.WriteConfigFile(appCfgPath, appConfig) } } diff --git a/x/globalfee/module.go b/x/globalfee/module.go index 2549e8403ce..61cdd8fd645 100644 --- a/x/globalfee/module.go +++ b/x/globalfee/module.go @@ -93,10 +93,29 @@ func NewAppModule(paramSpace paramstypes.Subspace) *AppModule { func (a AppModule) InitGenesis(ctx sdk.Context, marshaler codec.JSONCodec, message json.RawMessage) []abci.ValidatorUpdate { var genesisState types.GenesisState marshaler.MustUnmarshalJSON(message, &genesisState) + + // if err := a.ValidateBypassFeeMsgTypes(genesisState.Params.BypassMinFeeMsgTypes); err != nil { + // a.Logger().Error("invalid 'bypass-min-fee-msg-types' config option", "error", err) + // panic(fmt.Sprintf("invalid 'bypass-min-fee-msg-types' config option: %s", err)) + // } + + // a.Logger().Info("min fee bypass activated for message types", "types", bypassMinFeeMsgTypes) + a.paramSpace.SetParamSet(ctx, &genesisState.Params) return nil } +// ValidateBypassFeeMsgTypes checks that a proto message type exists for all MsgTypes in bypassMinFeeMsgTypes +// An error is returned for the first msgType that cannot be resolved +// func (a AppModule) ValidateBypassFeeMsgTypes(bypassMinFeeMsgTypes []string) error { +// for _, msgType := range bypassMinFeeMsgTypes { +// if _, err := a.Get.interfaceRegistry.Resolve(msgType); err != nil { +// return err +// } +// } +// return nil +// } + func (a AppModule) ExportGenesis(ctx sdk.Context, marshaler codec.JSONCodec) json.RawMessage { var genState types.GenesisState a.paramSpace.GetParamSet(ctx, &genState.Params) From e5b3b0198015ab9f1b546ccb28ce03052d28b38d Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Wed, 5 Apr 2023 10:34:23 +0200 Subject: [PATCH 16/47] fix: proto typo --- docs/proto/proto-docs.md | 4 +- proto/gaia/globalfee/v1beta1/genesis.proto | 2 +- proto/gaia/globalfee/v1beta1/query.proto | 2 +- x/globalfee/types/genesis.pb.go | 58 ++++++++++---------- x/globalfee/types/query.pb.go | 64 +++++++++++----------- 5 files changed, 65 insertions(+), 65 deletions(-) diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index 4333ca9a308..32482949bd1 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -47,7 +47,7 @@ Query/MinimumGasPrices RPC method. | ----- | ---- | ----- | ----------- | | `minimum_gas_prices` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | | | `bypass_min_fee_msg_types` | [string](#string) | repeated | | -| `max_total_bypass_minFee_msg_gas_usage` | [uint64](#uint64) | | | +| `max_total_bypass_min_fee_msg_gas_usage` | [uint64](#uint64) | | | @@ -105,7 +105,7 @@ Params defines the set of module parameters. | ----- | ---- | ----- | ----------- | | `minimum_gas_prices` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | Minimum stores the minimum gas price(s) for all TX on the chain. When multiple coins are defined then they are accepted alternatively. The list must be sorted by denoms asc. No duplicate denoms or zero amount values allowed. For more information see https://docs.cosmos.network/main/modules/auth#concepts | | `bypass_min_fee_msg_types` | [string](#string) | repeated | bypass_min_fee_msg_types are setup for tx msgs free of fee charge | -| `max_total_bypass_minFee_msg_gas_usage` | [uint64](#uint64) | | | +| `max_total_bypass_min_fee_msg_gas_usage` | [uint64](#uint64) | | | diff --git a/proto/gaia/globalfee/v1beta1/genesis.proto b/proto/gaia/globalfee/v1beta1/genesis.proto index c986306cfb4..c88d6b2eb34 100644 --- a/proto/gaia/globalfee/v1beta1/genesis.proto +++ b/proto/gaia/globalfee/v1beta1/genesis.proto @@ -31,5 +31,5 @@ message Params { // bypass_min_fee_msg_types are setup for tx msgs free of fee charge repeated string bypass_min_fee_msg_types = 2 [(gogoproto.moretags) = "yaml:\"bypass_min_fee_msg_types\""]; - uint64 max_total_bypass_minFee_msg_gas_usage = 3; + uint64 max_total_bypass_min_fee_msg_gas_usage = 3; } diff --git a/proto/gaia/globalfee/v1beta1/query.proto b/proto/gaia/globalfee/v1beta1/query.proto index 98fb75be00d..43598286976 100644 --- a/proto/gaia/globalfee/v1beta1/query.proto +++ b/proto/gaia/globalfee/v1beta1/query.proto @@ -31,5 +31,5 @@ message QueryParamsResponse { ]; repeated string bypass_min_fee_msg_types = 2 [(gogoproto.moretags) = "yaml:\"bypass_min_fee_msg_types\""]; - uint64 max_total_bypass_minFee_msg_gas_usage = 3; + uint64 max_total_bypass_min_fee_msg_gas_usage = 3; } diff --git a/x/globalfee/types/genesis.pb.go b/x/globalfee/types/genesis.pb.go index 8ea40614a80..feb41bae714 100644 --- a/x/globalfee/types/genesis.pb.go +++ b/x/globalfee/types/genesis.pb.go @@ -81,7 +81,7 @@ type Params struct { MinimumGasPrices github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=minimum_gas_prices,json=minimumGasPrices,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"minimum_gas_prices,omitempty" yaml:"minimum_gas_prices"` // bypass_min_fee_msg_types are setup for tx msgs free of fee charge BypassMinFeeMsgTypes []string `protobuf:"bytes,2,rep,name=bypass_min_fee_msg_types,json=bypassMinFeeMsgTypes,proto3" json:"bypass_min_fee_msg_types,omitempty" yaml:"bypass_min_fee_msg_types"` - MaxTotalBypassMinFeeMsgGasUsage uint64 `protobuf:"varint,3,opt,name=max_total_bypass_minFee_msg_gas_usage,json=maxTotalBypassMinFeeMsgGasUsage,proto3" json:"max_total_bypass_minFee_msg_gas_usage,omitempty"` + MaxTotalBypassMinFeeMsgGasUsage uint64 `protobuf:"varint,3,opt,name=max_total_bypass_min_fee_msg_gas_usage,json=maxTotalBypassMinFeeMsgGasUsage,proto3" json:"max_total_bypass_min_fee_msg_gas_usage,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -148,34 +148,34 @@ func init() { } var fileDescriptor_015b3e8b7a7c65c5 = []byte{ - // 422 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0x4d, 0x6e, 0xd3, 0x40, - 0x14, 0xc7, 0xe3, 0x06, 0x45, 0xc2, 0x65, 0x51, 0x59, 0x15, 0x32, 0x55, 0x35, 0x8e, 0x0c, 0x48, - 0x96, 0x80, 0xb1, 0x5a, 0x76, 0x2c, 0x0d, 0x6a, 0x56, 0x45, 0x51, 0x28, 0x1b, 0x58, 0x0c, 0xcf, - 0x66, 0x3a, 0x8c, 0xf0, 0x78, 0xac, 0xbc, 0x09, 0x8a, 0x6f, 0xc1, 0x39, 0x38, 0x03, 0x07, 0xe8, - 0xb2, 0x4b, 0x56, 0x06, 0x25, 0x3b, 0x96, 0x15, 0x07, 0x40, 0xe3, 0x31, 0x0d, 0x28, 0x74, 0x65, - 0xcb, 0xef, 0xf7, 0xff, 0xf0, 0xd3, 0xf3, 0x1f, 0x08, 0x90, 0x90, 0x8a, 0x52, 0xe7, 0x50, 0x9e, - 0x73, 0x9e, 0x7e, 0x3a, 0xca, 0xb9, 0x81, 0xa3, 0x54, 0xf0, 0x8a, 0xa3, 0x44, 0x5a, 0xcf, 0xb5, - 0xd1, 0xc1, 0x5d, 0x4b, 0xd1, 0x6b, 0x8a, 0xf6, 0xd4, 0xc1, 0xbe, 0xd0, 0x42, 0x77, 0x48, 0x6a, - 0xdf, 0x1c, 0x7d, 0x40, 0x0a, 0x8d, 0x4a, 0x63, 0x9a, 0x03, 0x6e, 0x0c, 0x0b, 0x2d, 0x2b, 0x37, - 0x8f, 0xdf, 0xf9, 0x77, 0x26, 0xce, 0xfe, 0x95, 0x01, 0xc3, 0x83, 0xa9, 0x3f, 0xaa, 0x61, 0x0e, - 0x0a, 0x43, 0x6f, 0xec, 0x25, 0xbb, 0xc7, 0x84, 0xfe, 0x3f, 0x8e, 0x4e, 0x3b, 0x2a, 0x0b, 0x2f, - 0xda, 0x68, 0xf0, 0xb3, 0x8d, 0xf6, 0x9c, 0xea, 0xb1, 0x56, 0xd2, 0x70, 0x55, 0x9b, 0x66, 0xd6, - 0xfb, 0xc4, 0xbf, 0x76, 0xfc, 0x91, 0x83, 0x83, 0xaf, 0x9e, 0x1f, 0x28, 0x59, 0x49, 0xb5, 0x50, - 0x4c, 0x00, 0xb2, 0x7a, 0x2e, 0x0b, 0x6e, 0x93, 0x86, 0xc9, 0xee, 0xf1, 0x21, 0x75, 0x55, 0xa9, - 0xad, 0x7a, 0x1d, 0xf3, 0x82, 0x17, 0xcf, 0xb5, 0xac, 0xb2, 0xba, 0xcf, 0x39, 0xdc, 0xd6, 0x6f, - 0x32, 0xaf, 0xda, 0xe8, 0x5e, 0x03, 0xaa, 0x7c, 0x16, 0x6f, 0x53, 0xf1, 0x97, 0xef, 0xd1, 0x23, - 0x21, 0xcd, 0x87, 0x45, 0x4e, 0x0b, 0xad, 0xd2, 0x7e, 0x2f, 0xee, 0xf1, 0x04, 0xdf, 0x7f, 0x4c, - 0x4d, 0x53, 0x73, 0xfc, 0x13, 0x88, 0xb3, 0xbd, 0xde, 0x63, 0x02, 0x38, 0xed, 0x1c, 0x82, 0xb7, - 0x7e, 0x98, 0x37, 0x35, 0x20, 0x32, 0x25, 0x2b, 0x76, 0xce, 0x39, 0x53, 0x28, 0x58, 0x27, 0x0b, - 0x77, 0xc6, 0xc3, 0xe4, 0x76, 0x76, 0xff, 0xaa, 0x8d, 0x22, 0xd7, 0xe0, 0x26, 0x32, 0x9e, 0xed, - 0xbb, 0xd1, 0xa9, 0xac, 0x4e, 0x38, 0x3f, 0x45, 0x71, 0x66, 0x3f, 0x07, 0x2f, 0xfd, 0x87, 0x0a, - 0x96, 0xcc, 0x68, 0x03, 0x25, 0xdb, 0x88, 0x4f, 0x7a, 0xad, 0xfd, 0x91, 0x05, 0x82, 0xe0, 0xe1, - 0x70, 0xec, 0x25, 0xb7, 0x66, 0x91, 0x82, 0xe5, 0x99, 0x65, 0xb3, 0x7f, 0xcd, 0x26, 0x80, 0xaf, - 0x2d, 0x96, 0x65, 0x17, 0x2b, 0xe2, 0x5d, 0xae, 0x88, 0xf7, 0x63, 0x45, 0xbc, 0xcf, 0x6b, 0x32, - 0xb8, 0x5c, 0x93, 0xc1, 0xb7, 0x35, 0x19, 0xbc, 0x49, 0xb6, 0xb7, 0xd0, 0x1d, 0xde, 0xf2, 0xaf, - 0xd3, 0xeb, 0xaa, 0xe6, 0xa3, 0xee, 0x46, 0x9e, 0xfe, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x30, 0x6f, - 0x78, 0xaa, 0x99, 0x02, 0x00, 0x00, + // 420 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xcf, 0x6b, 0xd4, 0x40, + 0x14, 0xc7, 0x37, 0x5d, 0x59, 0x30, 0xf5, 0x50, 0x42, 0x91, 0x58, 0xca, 0x64, 0x89, 0x22, 0x01, + 0x75, 0x42, 0xeb, 0xcd, 0x63, 0x14, 0xf7, 0x54, 0x5c, 0xd6, 0x7a, 0xd1, 0xc3, 0xf8, 0x12, 0xa7, + 0xe3, 0x60, 0x26, 0x13, 0xf6, 0xcd, 0xca, 0xe6, 0xbf, 0xf0, 0xef, 0xf0, 0x6f, 0xf0, 0x0f, 0xe8, + 0xb1, 0x47, 0x4f, 0x51, 0x76, 0x6f, 0x1e, 0x0b, 0xde, 0x65, 0x32, 0xb1, 0x55, 0x76, 0x7b, 0x4a, + 0xc8, 0xfb, 0x7c, 0x7f, 0xe4, 0xf1, 0xfc, 0x07, 0x02, 0x24, 0xa4, 0xa2, 0xd4, 0x39, 0x94, 0x67, + 0x9c, 0xa7, 0x9f, 0x8f, 0x72, 0x6e, 0xe0, 0x28, 0x15, 0xbc, 0xe2, 0x28, 0x91, 0xd6, 0x73, 0x6d, + 0x74, 0x70, 0xd7, 0x52, 0xf4, 0x8a, 0xa2, 0x3d, 0x75, 0xb0, 0x2f, 0xb4, 0xd0, 0x1d, 0x92, 0xda, + 0x37, 0x47, 0x1f, 0x90, 0x42, 0xa3, 0xd2, 0x98, 0xe6, 0x80, 0xd7, 0x86, 0x85, 0x96, 0x95, 0x9b, + 0xc7, 0xef, 0xfd, 0x3b, 0x13, 0x67, 0xff, 0xda, 0x80, 0xe1, 0xc1, 0xd4, 0x1f, 0xd5, 0x30, 0x07, + 0x85, 0xa1, 0x37, 0xf6, 0x92, 0xdd, 0x63, 0x42, 0xb7, 0xc7, 0xd1, 0x69, 0x47, 0x65, 0xe1, 0x79, + 0x1b, 0x0d, 0x7e, 0xb5, 0xd1, 0x9e, 0x53, 0x3d, 0xd6, 0x4a, 0x1a, 0xae, 0x6a, 0xd3, 0xcc, 0x7a, + 0x9f, 0xf8, 0xf7, 0x8e, 0x3f, 0x72, 0x70, 0xf0, 0xcd, 0xf3, 0x03, 0x25, 0x2b, 0xa9, 0x16, 0x8a, + 0x09, 0x40, 0x56, 0xcf, 0x65, 0xc1, 0x6d, 0xd2, 0x30, 0xd9, 0x3d, 0x3e, 0xa4, 0xae, 0x2a, 0xb5, + 0x55, 0xaf, 0x62, 0x5e, 0xf0, 0xe2, 0xb9, 0x96, 0x55, 0x56, 0xf7, 0x39, 0x87, 0x9b, 0xfa, 0xeb, + 0xcc, 0xcb, 0x36, 0xba, 0xd7, 0x80, 0x2a, 0x9f, 0xc5, 0x9b, 0x54, 0xfc, 0xf5, 0x47, 0xf4, 0x48, + 0x48, 0xf3, 0x71, 0x91, 0xd3, 0x42, 0xab, 0xb4, 0xdf, 0x8b, 0x7b, 0x3c, 0xc1, 0x0f, 0x9f, 0x52, + 0xd3, 0xd4, 0x1c, 0xff, 0x06, 0xe2, 0x6c, 0xaf, 0xf7, 0x98, 0x00, 0x4e, 0x3b, 0x87, 0xe0, 0x9d, + 0x1f, 0xe6, 0x4d, 0x0d, 0x88, 0x4c, 0xc9, 0x8a, 0x9d, 0x71, 0xce, 0x14, 0x0a, 0xd6, 0xc9, 0xc2, + 0x9d, 0xf1, 0x30, 0xb9, 0x9d, 0xdd, 0xbf, 0x6c, 0xa3, 0xc8, 0x35, 0xb8, 0x89, 0x8c, 0x67, 0xfb, + 0x6e, 0x74, 0x22, 0xab, 0x97, 0x9c, 0x9f, 0xa0, 0x38, 0xb5, 0x9f, 0x83, 0x57, 0xfe, 0x43, 0x05, + 0x4b, 0x66, 0xb4, 0x81, 0x92, 0x6d, 0x11, 0xdb, 0x3f, 0x59, 0x20, 0x08, 0x1e, 0x0e, 0xc7, 0x5e, + 0x72, 0x6b, 0x16, 0x29, 0x58, 0x9e, 0x5a, 0x38, 0xfb, 0xdf, 0x6d, 0x02, 0xf8, 0xc6, 0x62, 0x59, + 0x76, 0xbe, 0x22, 0xde, 0xc5, 0x8a, 0x78, 0x3f, 0x57, 0xc4, 0xfb, 0xb2, 0x26, 0x83, 0x8b, 0x35, + 0x19, 0x7c, 0x5f, 0x93, 0xc1, 0xdb, 0x64, 0x73, 0x0d, 0xdd, 0xe5, 0x2d, 0xff, 0xb9, 0xbd, 0xae, + 0x6b, 0x3e, 0xea, 0x8e, 0xe4, 0xe9, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4b, 0x0b, 0x25, 0x2c, + 0x9a, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/globalfee/types/query.pb.go b/x/globalfee/types/query.pb.go index 2060acd3a87..054f0c41b4b 100644 --- a/x/globalfee/types/query.pb.go +++ b/x/globalfee/types/query.pb.go @@ -74,7 +74,7 @@ var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo type QueryParamsResponse struct { MinimumGasPrices github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=minimum_gas_prices,json=minimumGasPrices,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"minimum_gas_prices,omitempty" yaml:"minimum_gas_prices"` BypassMinFeeMsgTypes []string `protobuf:"bytes,2,rep,name=bypass_min_fee_msg_types,json=bypassMinFeeMsgTypes,proto3" json:"bypass_min_fee_msg_types,omitempty" yaml:"bypass_min_fee_msg_types"` - MaxTotalBypassMinFeeMsgGasUsage uint64 `protobuf:"varint,3,opt,name=max_total_bypass_minFee_msg_gas_usage,json=maxTotalBypassMinFeeMsgGasUsage,proto3" json:"max_total_bypass_minFee_msg_gas_usage,omitempty"` + MaxTotalBypassMinFeeMsgGasUsage uint64 `protobuf:"varint,3,opt,name=max_total_bypass_min_fee_msg_gas_usage,json=maxTotalBypassMinFeeMsgGasUsage,proto3" json:"max_total_bypass_min_fee_msg_gas_usage,omitempty"` } func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } @@ -141,37 +141,37 @@ func init() { } var fileDescriptor_12a736cede25d10a = []byte{ - // 468 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xbf, 0x6e, 0x13, 0x41, - 0x10, 0xc6, 0x7d, 0x31, 0x44, 0xe2, 0x68, 0xd0, 0x62, 0x21, 0x63, 0x59, 0x77, 0xd6, 0x21, 0x90, - 0x45, 0x60, 0x57, 0x09, 0x1d, 0xe5, 0x81, 0x92, 0x2a, 0x28, 0x58, 0xa1, 0x81, 0xe2, 0x34, 0x77, - 0x6c, 0x96, 0x15, 0xb7, 0x7f, 0xe2, 0xd9, 0x43, 0xbe, 0x12, 0x3a, 0x3a, 0xa4, 0xbc, 0x05, 0xcf, - 0xc0, 0x03, 0xa4, 0x8c, 0x44, 0x43, 0x65, 0x90, 0x4d, 0x45, 0x99, 0x27, 0x40, 0xf7, 0x27, 0x84, - 0xc8, 0x44, 0xa2, 0xba, 0xd3, 0xce, 0x6f, 0xbe, 0x6f, 0x67, 0xbf, 0xf1, 0x23, 0x01, 0x12, 0x98, - 0xc8, 0x4d, 0x0a, 0xf9, 0x01, 0xe7, 0xec, 0xdd, 0x66, 0xca, 0x1d, 0x6c, 0xb2, 0xc3, 0x82, 0x4f, - 0x4b, 0x6a, 0xa7, 0xc6, 0x19, 0x72, 0xab, 0x62, 0xe8, 0x1f, 0x86, 0xb6, 0xcc, 0xa0, 0x27, 0x8c, - 0x30, 0x35, 0xc2, 0xaa, 0xbf, 0x86, 0x1e, 0x0c, 0x85, 0x31, 0x22, 0xe7, 0x0c, 0xac, 0x64, 0xa0, - 0xb5, 0x71, 0xe0, 0xa4, 0xd1, 0xd8, 0x56, 0x83, 0xcc, 0xa0, 0x32, 0xc8, 0x52, 0xc0, 0x73, 0xb3, - 0xcc, 0x48, 0xdd, 0xd4, 0xa3, 0x9e, 0x4f, 0x9e, 0x57, 0xd6, 0x7b, 0x30, 0x05, 0x85, 0x13, 0x7e, - 0x58, 0x70, 0x74, 0xd1, 0xfb, 0xae, 0x7f, 0xf3, 0xc2, 0x31, 0x5a, 0xa3, 0x91, 0x93, 0x2f, 0x9e, - 0x4f, 0x94, 0xd4, 0x52, 0x15, 0x2a, 0x11, 0x80, 0x89, 0x9d, 0xca, 0x8c, 0x63, 0xdf, 0x1b, 0x75, - 0xc7, 0xd7, 0xb7, 0x86, 0xb4, 0xf1, 0xa2, 0x95, 0xd7, 0xd9, 0xa5, 0xe9, 0x53, 0x9e, 0x3d, 0x31, - 0x52, 0xc7, 0xf6, 0x78, 0x1e, 0x76, 0x7e, 0xcd, 0xc3, 0xe1, 0x6a, 0xff, 0x03, 0xa3, 0xa4, 0xe3, - 0xca, 0xba, 0xf2, 0x74, 0x1e, 0xde, 0x2e, 0x41, 0xe5, 0x8f, 0xa3, 0x55, 0x2a, 0xfa, 0xfc, 0x3d, - 0xdc, 0x10, 0xd2, 0xbd, 0x29, 0x52, 0x9a, 0x19, 0xc5, 0xda, 0xc1, 0x9a, 0xcf, 0x43, 0x7c, 0xfd, - 0x96, 0xb9, 0xd2, 0x72, 0x3c, 0x33, 0xc4, 0xc9, 0x8d, 0x56, 0x63, 0x07, 0x70, 0xaf, 0x56, 0x20, - 0xaf, 0xfc, 0x7e, 0x5a, 0x5a, 0x40, 0x4c, 0x94, 0xd4, 0xc9, 0x01, 0xe7, 0x89, 0x42, 0x91, 0xd4, - 0x6d, 0xfd, 0xb5, 0x51, 0x77, 0x7c, 0x2d, 0xbe, 0x73, 0x3a, 0x0f, 0xc3, 0xe6, 0x06, 0x97, 0x91, - 0xd1, 0xa4, 0xd7, 0x94, 0x76, 0xa5, 0xde, 0xe6, 0x7c, 0x17, 0xc5, 0x7e, 0x75, 0x4c, 0x9e, 0xf9, - 0x77, 0x15, 0xcc, 0x12, 0x67, 0x1c, 0xe4, 0xc9, 0x79, 0xf3, 0x76, 0xdb, 0x5b, 0x0d, 0x52, 0x20, - 0x08, 0xde, 0xef, 0x8e, 0xbc, 0xf1, 0x95, 0x49, 0xa8, 0x60, 0xb6, 0x5f, 0xb1, 0xf1, 0x45, 0xb1, - 0x1d, 0xc0, 0x17, 0x15, 0xb6, 0x75, 0xe4, 0xf9, 0x57, 0xeb, 0x0c, 0xc8, 0x47, 0xcf, 0x5f, 0x6f, - 0x82, 0x20, 0xf7, 0xe9, 0xbf, 0x77, 0x83, 0xae, 0x86, 0x38, 0xd8, 0xf8, 0x2f, 0xb6, 0x49, 0x36, - 0xba, 0xf7, 0xe1, 0xeb, 0xcf, 0xa3, 0xb5, 0x11, 0x09, 0xd8, 0x25, 0x0b, 0x6a, 0x6b, 0x3e, 0x8e, - 0x8f, 0x17, 0x81, 0x77, 0xb2, 0x08, 0xbc, 0x1f, 0x8b, 0xc0, 0xfb, 0xb4, 0x0c, 0x3a, 0x27, 0xcb, - 0xa0, 0xf3, 0x6d, 0x19, 0x74, 0x5e, 0x8e, 0x57, 0xb3, 0xa9, 0xa5, 0x66, 0x7f, 0x89, 0xd5, 0x0f, - 0x98, 0xae, 0xd7, 0xab, 0xf7, 0xe8, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6f, 0x37, 0x8f, 0x3d, - 0x0c, 0x03, 0x00, 0x00, + // 465 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xbf, 0x6e, 0xd4, 0x40, + 0x10, 0xc6, 0xcf, 0x39, 0x88, 0x84, 0x69, 0xd0, 0x72, 0x42, 0xc7, 0xe9, 0x64, 0x9f, 0x8c, 0x14, + 0x9d, 0x08, 0xec, 0x2a, 0xa1, 0xa3, 0x34, 0x88, 0x54, 0x11, 0xe1, 0x14, 0x1a, 0x28, 0xac, 0xb1, + 0xd9, 0x2c, 0x2b, 0xbc, 0x7f, 0x72, 0xb3, 0x46, 0xe7, 0x36, 0x1d, 0x1d, 0x52, 0xde, 0x82, 0x67, + 0xe0, 0x01, 0x52, 0x46, 0xa2, 0xa1, 0x3a, 0xd0, 0x1d, 0x15, 0x65, 0x9e, 0x00, 0xd9, 0xbe, 0x00, + 0x91, 0x13, 0x29, 0x95, 0xad, 0x9d, 0xdf, 0x7c, 0xdf, 0xce, 0x7e, 0xe3, 0x47, 0x02, 0x24, 0x30, + 0x91, 0x9b, 0x14, 0xf2, 0x03, 0xce, 0xd9, 0xc7, 0xad, 0x94, 0x3b, 0xd8, 0x62, 0x87, 0x05, 0x9f, + 0x96, 0xd4, 0x4e, 0x8d, 0x33, 0xe4, 0x5e, 0xc5, 0xd0, 0xbf, 0x0c, 0x5d, 0x31, 0x83, 0x9e, 0x30, + 0xc2, 0xd4, 0x08, 0xab, 0xfe, 0x1a, 0x7a, 0x30, 0x14, 0xc6, 0x88, 0x9c, 0x33, 0xb0, 0x92, 0x81, + 0xd6, 0xc6, 0x81, 0x93, 0x46, 0xe3, 0xaa, 0x1a, 0x64, 0x06, 0x95, 0x41, 0x96, 0x02, 0xfe, 0x33, + 0xcb, 0x8c, 0xd4, 0x4d, 0x3d, 0xea, 0xf9, 0xe4, 0x55, 0x65, 0xbd, 0x07, 0x53, 0x50, 0x38, 0xe1, + 0x87, 0x05, 0x47, 0x17, 0x1d, 0x75, 0xfd, 0xbb, 0x17, 0x8e, 0xd1, 0x1a, 0x8d, 0x9c, 0x7c, 0xf5, + 0x7c, 0xa2, 0xa4, 0x96, 0xaa, 0x50, 0x89, 0x00, 0x4c, 0xec, 0x54, 0x66, 0x1c, 0xfb, 0xde, 0xa8, + 0x3b, 0xbe, 0xbd, 0x3d, 0xa4, 0x8d, 0x17, 0xad, 0xbc, 0xce, 0x2f, 0x4d, 0x9f, 0xf3, 0xec, 0x99, + 0x91, 0x3a, 0xb6, 0x27, 0xf3, 0xb0, 0xf3, 0x7b, 0x1e, 0x0e, 0xdb, 0xfd, 0x8f, 0x8c, 0x92, 0x8e, + 0x2b, 0xeb, 0xca, 0xb3, 0x79, 0x78, 0xbf, 0x04, 0x95, 0x3f, 0x8d, 0xda, 0x54, 0xf4, 0xe5, 0x47, + 0xb8, 0x29, 0xa4, 0x7b, 0x5f, 0xa4, 0x34, 0x33, 0x8a, 0xad, 0x06, 0x6b, 0x3e, 0x8f, 0xf1, 0xdd, + 0x07, 0xe6, 0x4a, 0xcb, 0xf1, 0xdc, 0x10, 0x27, 0x77, 0x56, 0x1a, 0x3b, 0x80, 0x7b, 0xb5, 0x02, + 0x79, 0xeb, 0xf7, 0xd3, 0xd2, 0x02, 0x62, 0xa2, 0xa4, 0x4e, 0x0e, 0x38, 0x4f, 0x14, 0x8a, 0xa4, + 0x6e, 0xeb, 0xaf, 0x8d, 0xba, 0xe3, 0x5b, 0xf1, 0x83, 0xb3, 0x79, 0x18, 0x36, 0x37, 0xb8, 0x8a, + 0x8c, 0x26, 0xbd, 0xa6, 0xb4, 0x2b, 0xf5, 0x0b, 0xce, 0x77, 0x51, 0xec, 0x57, 0xc7, 0xe4, 0xa5, + 0xbf, 0xa1, 0x60, 0x96, 0x38, 0xe3, 0x20, 0x4f, 0x2e, 0x69, 0xae, 0x26, 0x29, 0x10, 0x04, 0xef, + 0x77, 0x47, 0xde, 0xf8, 0xc6, 0x24, 0x54, 0x30, 0xdb, 0xaf, 0xe0, 0xf8, 0xa2, 0xda, 0x0e, 0xe0, + 0xeb, 0x0a, 0xdb, 0x3e, 0xf6, 0xfc, 0x9b, 0x75, 0x08, 0xe4, 0x93, 0xe7, 0xaf, 0x37, 0x49, 0x90, + 0x87, 0xf4, 0xf2, 0xe5, 0xa0, 0xed, 0x14, 0x07, 0x9b, 0xd7, 0x62, 0x9b, 0x68, 0xa3, 0x8d, 0xa3, + 0x6f, 0xbf, 0x8e, 0xd7, 0x46, 0x24, 0x60, 0x57, 0x6c, 0xa8, 0xad, 0xf9, 0x38, 0x3e, 0x59, 0x04, + 0xde, 0xe9, 0x22, 0xf0, 0x7e, 0x2e, 0x02, 0xef, 0xf3, 0x32, 0xe8, 0x9c, 0x2e, 0x83, 0xce, 0xf7, + 0x65, 0xd0, 0x79, 0x33, 0x6e, 0x87, 0x53, 0x4b, 0xcd, 0xfe, 0x13, 0xab, 0x5f, 0x30, 0x5d, 0xaf, + 0x77, 0xef, 0xc9, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xcc, 0x5c, 0xb6, 0x1a, 0x0d, 0x03, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. From 3fbdbfe53238e7a9273fe33dc092b6b79de0e7e2 Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Wed, 5 Apr 2023 14:53:30 +0200 Subject: [PATCH 17/47] skip bypass test --- tests/e2e/e2e_bypassminfee_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/e2e/e2e_bypassminfee_test.go b/tests/e2e/e2e_bypassminfee_test.go index 2f83ce77287..6d731844d76 100644 --- a/tests/e2e/e2e_bypassminfee_test.go +++ b/tests/e2e/e2e_bypassminfee_test.go @@ -6,6 +6,7 @@ import ( func (s *IntegrationTestSuite) testByPassMinFeeWithdrawReward() { // todo gov propose withdraw to be bypass-msg first + s.T().Skip() paidFeeAmt := math.LegacyMustNewDecFromStr(minGasPrice).Mul(math.LegacyNewDec(gas)).String() payee := s.chainA.validators[0].keyInfo.GetAddress() // pass From 6f33945dd82949faa2ecedb10234c09b226a9283 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Wed, 5 Apr 2023 15:49:11 +0200 Subject: [PATCH 18/47] save --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3e19f6b97ee..b0b0b1d98ae 100644 --- a/Makefile +++ b/Makefile @@ -8,13 +8,13 @@ ifeq (,$(VERSION)) VERSION := $(shell git describe --exact-match 2>/dev/null) # if VERSION is empty, then populate it with branch's name and raw commit hash ifeq (,$(VERSION)) - VERSION := $(BRANCH)-$(COMMIT) + VERSION := $(BRANCH)-$(COMMIT)< endif endif PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation') LEDGER_ENABLED ?= true -SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g') +SDK_PACK := $(shell go list -m github.com/s/cosmos-sdk | sed 's/ /\@/g') TM_VERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::') # grab everything after the space in "github.com/tendermint/tendermint v0.34.7" DOCKER := $(shell which docker) BUILDDIR ?= $(CURDIR)/build From be046e3e887799861fadc2f676e4e9f7e689a9ac Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Wed, 5 Apr 2023 18:19:27 +0200 Subject: [PATCH 19/47] update ditrosless image url in Dockerfiles --- Dockerfile | 2 +- e2e.Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index b97fbfc34ab..5caba870955 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ RUN apk add --no-cache $PACKAGES RUN CGO_ENABLED=0 make install # Add to a distroless container -FROM distroless.dev/static:$IMG_TAG +FROM cgr.dev/chainguard/static:$IMG_TAG ARG IMG_TAG COPY --from=gaiad-builder /go/bin/gaiad /usr/local/bin/ EXPOSE 26656 26657 1317 9090 diff --git a/e2e.Dockerfile b/e2e.Dockerfile index b941c2628dd..c0a8c80a4e1 100644 --- a/e2e.Dockerfile +++ b/e2e.Dockerfile @@ -11,7 +11,7 @@ RUN apk add --no-cache $PACKAGES RUN CGO_ENABLED=0 make install # Add to a distroless container -FROM distroless.dev/static:$IMG_TAG +FROM cgr.dev/chainguard/static:$IMG_TAG ARG IMG_TAG COPY --from=gaiad-builder /go/bin/gaiad /usr/local/bin/ EXPOSE 26656 26657 1317 9090 From ee64b8a0fa2e82e626bd40d54ff07a5561bc5413 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Thu, 6 Apr 2023 14:23:56 +0200 Subject: [PATCH 20/47] fix typo in makefil --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b0b0b1d98ae..3e19f6b97ee 100644 --- a/Makefile +++ b/Makefile @@ -8,13 +8,13 @@ ifeq (,$(VERSION)) VERSION := $(shell git describe --exact-match 2>/dev/null) # if VERSION is empty, then populate it with branch's name and raw commit hash ifeq (,$(VERSION)) - VERSION := $(BRANCH)-$(COMMIT)< + VERSION := $(BRANCH)-$(COMMIT) endif endif PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation') LEDGER_ENABLED ?= true -SDK_PACK := $(shell go list -m github.com/s/cosmos-sdk | sed 's/ /\@/g') +SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g') TM_VERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::') # grab everything after the space in "github.com/tendermint/tendermint v0.34.7" DOCKER := $(shell which docker) BUILDDIR ?= $(CURDIR)/build From 3383e3720fb971177b161cb6b99cb0f899d85afb Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Thu, 6 Apr 2023 16:10:28 +0200 Subject: [PATCH 21/47] save --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3e19f6b97ee..09748e5908a 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ BUILDDIR ?= $(CURDIR)/build TEST_DOCKER_REPO=cosmos/contrib-gaiatest GO_SYSTEM_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1-2) -REQUIRE_GO_VERSION = 1.19 +REQUIRE_GO_VERSION = 1.18 export GO111MODULE = on From 942725bc022cd571017fff70ddc3cbbaa1b74945 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Wed, 12 Apr 2023 08:51:04 +0200 Subject: [PATCH 22/47] update doc --- docs/proto/proto-docs.md | 6 +++--- go.mod | 10 +++++----- go.sum | 12 ++++++++---- proto/scripts/protoc-doc-gen.sh | 0 4 files changed, 16 insertions(+), 12 deletions(-) mode change 100644 => 100755 proto/scripts/protoc-doc-gen.sh diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index 32482949bd1..83c20fd683b 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -103,9 +103,9 @@ Params defines the set of module parameters. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `minimum_gas_prices` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | Minimum stores the minimum gas price(s) for all TX on the chain. When multiple coins are defined then they are accepted alternatively. The list must be sorted by denoms asc. No duplicate denoms or zero amount values allowed. For more information see https://docs.cosmos.network/main/modules/auth#concepts | -| `bypass_min_fee_msg_types` | [string](#string) | repeated | bypass_min_fee_msg_types are setup for tx msgs free of fee charge | -| `max_total_bypass_min_fee_msg_gas_usage` | [uint64](#uint64) | | | +| `minimum_gas_prices` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | minimum_gas_prices stores the minimum gas price(s) for all TX on the chain. When multiple coins are defined then they are accepted alternatively. The list must be sorted by denoms asc. No duplicate denoms or zero amount values allowed. For more information see https://docs.cosmos.network/main/modules/auth#concepts | +| `bypass_min_fee_msg_types` | [string](#string) | repeated | bypass_min_fee_msg_types defines a list of IBC message type urls that are free of fee charge | +| `max_total_bypass_min_fee_msg_gas_usage` | [uint64](#uint64) | | max_total_bypass_min_fee_msg_gas_usage defines the total maximum gas usage allowed to bypass fee charge | diff --git a/go.mod b/go.mod index 08d47ec4706..69aca8e8bf7 100644 --- a/go.mod +++ b/go.mod @@ -23,8 +23,8 @@ require ( github.com/stretchr/testify v1.8.2 github.com/tendermint/tendermint v0.34.27 github.com/tendermint/tm-db v0.6.7 - google.golang.org/genproto v0.0.0-20230125152338-dcaf20b6aeaa - google.golang.org/grpc v1.52.3 + google.golang.org/genproto v0.0.0-20230403163135-c38d8f061ccd + google.golang.org/grpc v1.54.0 ) require ( @@ -168,7 +168,7 @@ require ( github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 // indirect github.com/hexops/gotextdiff v1.0.3 // indirect github.com/iancoleman/orderedmap v0.2.0 // indirect - github.com/imdario/mergo v0.3.13 // indirect + github.com/imdario/mergo v0.3.15 // indirect github.com/improbable-eng/grpc-web v0.15.0 // indirect github.com/inconshreveable/mousetrap v1.0.1 // indirect github.com/jgautheron/goconst v1.5.1 // indirect @@ -284,7 +284,7 @@ require ( go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.8.0 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/crypto v0.5.0 // indirect + golang.org/x/crypto v0.7.0 // indirect golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect golang.org/x/exp/typeparams v0.0.0-20230224173230-c95f2b4c22f2 // indirect golang.org/x/mod v0.9.0 // indirect @@ -294,7 +294,7 @@ require ( golang.org/x/term v0.6.0 // indirect golang.org/x/text v0.8.0 // indirect golang.org/x/tools v0.7.0 // indirect - google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 // indirect + google.golang.org/protobuf v1.30.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index e6da31c8ff0..092d2faf50b 100644 --- a/go.sum +++ b/go.sum @@ -1773,8 +1773,9 @@ github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJ github.com/imdario/mergo v0.3.10/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= -github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= +github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM= +github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA= github.com/improbable-eng/grpc-web v0.14.1/go.mod h1:zEjGHa8DAlkoOXmswrNvhUGEYQA9UI7DhrGeHR1DMGU= github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ= @@ -3083,8 +3084,9 @@ golang.org/x/crypto v0.0.0-20220926161630-eccd6366d1be/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.2.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= +golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -3908,8 +3910,9 @@ google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1/go.mod h1:rZS5c/ZV google.golang.org/genproto v0.0.0-20221117204609-8f9c96812029/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= google.golang.org/genproto v0.0.0-20221201164419-0e50fba7f41c/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= -google.golang.org/genproto v0.0.0-20230125152338-dcaf20b6aeaa h1:qQPhfbPO23fwm/9lQr91L1u62Zo6cm+zI+slZT+uf+o= google.golang.org/genproto v0.0.0-20230125152338-dcaf20b6aeaa/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= +google.golang.org/genproto v0.0.0-20230403163135-c38d8f061ccd h1:sLpv7bNL1AsX3fdnWh9WVh7ejIzXdOc1RRHGeAmeStU= +google.golang.org/genproto v0.0.0-20230403163135-c38d8f061ccd/go.mod h1:UUQDJDOlWu4KYeJZffbWgBkS1YFobzKbLVfK69pe0Ak= google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= @@ -3928,8 +3931,9 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 h1:KR8+MyP7/qOlV+8Af01LtjL04bu7on42eVsxT4EyBQk= google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/proto/scripts/protoc-doc-gen.sh b/proto/scripts/protoc-doc-gen.sh old mode 100644 new mode 100755 From 82002d84b84aeecd1688bb6c6ca23f85f4b5f01b Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Fri, 14 Apr 2023 17:03:07 +0200 Subject: [PATCH 23/47] update params --- x/globalfee/ante/fee.go | 32 ++++++-------------- x/globalfee/types/params.go | 8 +++-- x/globalfee/types/params_test.go | 50 ++++++++++++++++++++++++++++++-- 3 files changed, 62 insertions(+), 28 deletions(-) diff --git a/x/globalfee/ante/fee.go b/x/globalfee/ante/fee.go index 1c251264d62..56112af594c 100644 --- a/x/globalfee/ante/fee.go +++ b/x/globalfee/ante/fee.go @@ -158,13 +158,9 @@ func (mfd FeeDecorator) DefaultZeroGlobalFee(ctx sdk.Context) ([]sdk.DecCoin, er return []sdk.DecCoin{sdk.NewDecCoinFromDec(bondDenom, sdk.NewDec(0))}, nil } -func (mfd FeeDecorator) getBondDenom(ctx sdk.Context) string { - var bondDenom string - if mfd.StakingSubspace.Has(ctx, stakingtypes.KeyBondDenom) { - mfd.StakingSubspace.Get(ctx, stakingtypes.KeyBondDenom, &bondDenom) - } - - return bondDenom +func (mfd FeeDecorator) getBondDenom(ctx sdk.Context) (res string) { + mfd.StakingSubspace.Get(ctx, stakingtypes.KeyBondDenom, &res) + return } func (mfd FeeDecorator) ContainsOnlyBypassMinFeeMsgs(ctx sdk.Context, msgs []sdk.Msg) bool { @@ -179,24 +175,14 @@ func (mfd FeeDecorator) ContainsOnlyBypassMinFeeMsgs(ctx sdk.Context, msgs []sdk return true } -func (mfd FeeDecorator) GetBypassMsgTypes(ctx sdk.Context) []string { - bypassMsgs := []string{} - if mfd.GlobalMinFee.Has(ctx, types.ParamStoreKeyBypassMinFeeMsgTypes) { - mfd.GlobalMinFee.Get(ctx, types.ParamStoreKeyBypassMinFeeMsgTypes, &bypassMsgs) - } - - // todo if check err: ParamStoreKeyBypassMinFeeMsgTypes does not exist - return bypassMsgs +func (mfd FeeDecorator) GetBypassMsgTypes(ctx sdk.Context) (res []string) { + mfd.GlobalMinFee.Get(ctx, types.ParamStoreKeyBypassMinFeeMsgTypes, &res) + return } -func (mfd FeeDecorator) GetMaxTotalBypassMinFeeMsgGasUsage(ctx sdk.Context) uint64 { - var maxTotalBypassMinFeeMsgGasUsage uint64 - if mfd.GlobalMinFee.Has(ctx, types.ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage) { - mfd.GlobalMinFee.Get(ctx, types.ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage, &maxTotalBypassMinFeeMsgGasUsage) - } - - // todo if check err: maxTotalBypassMinFeeMsgGasUsage does not exist - return maxTotalBypassMinFeeMsgGasUsage +func (mfd FeeDecorator) GetMaxTotalBypassMinFeeMsgGasUsage(ctx sdk.Context) (res uint64) { + mfd.GlobalMinFee.Get(ctx, types.ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage, &res) + return } // GetMinGasPrice returns a nodes's local minimum gas prices diff --git a/x/globalfee/types/params.go b/x/globalfee/types/params.go index c829626f77b..44c424c92af 100644 --- a/x/globalfee/types/params.go +++ b/x/globalfee/types/params.go @@ -2,6 +2,7 @@ package types import ( "fmt" + "strings" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -78,7 +79,6 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { } } -// this requires the fee non-negative func validateMinimumGasPrices(i interface{}) error { v, ok := i.(sdk.DecCoins) if !ok { @@ -91,8 +91,6 @@ func validateMinimumGasPrices(i interface{}) error { type BypassMinFeeMsgTypes []string -// TODO: add more conditions to verify the message type name -// // validateBypassMinFeeMsgTypes checks that bypass msg types aren't empty func validateBypassMinFeeMsgTypes(i interface{}) error { bypassMinFeeMsgTypes, ok := i.([]string) @@ -104,6 +102,10 @@ func validateBypassMinFeeMsgTypes(i interface{}) error { if msgType == "" { return fmt.Errorf("invalid empty bypass msg type") } + + if !strings.HasPrefix(msgType, sdk.MsgTypeURL(nil)) { + return fmt.Errorf("invalid bypass msg type name %s", msgType) + } } return nil diff --git a/x/globalfee/types/params_test.go b/x/globalfee/types/params_test.go index d5db949bb4c..b2c2931674a 100644 --- a/x/globalfee/types/params_test.go +++ b/x/globalfee/types/params_test.go @@ -16,7 +16,7 @@ func TestDefaultParams(t *testing.T) { func Test_validateMinGasPrices(t *testing.T) { tests := map[string]struct { - coins interface{} // not sdk.DeCoins, but Decoins defined in glboalfee + coins interface{} expectErr bool }{ "DefaultParams, pass": { @@ -76,7 +76,7 @@ func Test_validateMinGasPrices(t *testing.T) { func Test_validateBypassMinFeeMsgTypes(t *testing.T) { tests := map[string]struct { - msgTypes interface{} // not sdk.DeCoins, but Decoins defined in global fee + msgTypes interface{} expectErr bool }{ "DefaultParams, pass": { @@ -95,6 +95,17 @@ func Test_validateBypassMinFeeMsgTypes(t *testing.T) { []string{""}, true, }, + "invalid msg type name, fail": { + []string{"ibc.core.channel.v1.MsgRecvPacket"}, + true, + }, + "mixed valid and invalid msgs, fail": { + []string{ + "/ibc.core.channel.v1.MsgRecvPacket", + "", + }, + true, + }, } for name, test := range tests { @@ -108,3 +119,38 @@ func Test_validateBypassMinFeeMsgTypes(t *testing.T) { }) } } + +func Test_validateMaxTotalBypassMinFeeMsgGasUsage(t *testing.T) { + tests := map[string]struct { + msgTypes interface{} + expectErr bool + }{ + "DefaultParams, pass": { + DefaultParams().MaxTotalBypassMinFeeMsgGasUsage, + false, + }, + "zero value, pass": { + uint64(0), + false, + }, + "negative value, fail": { + -1, + true, + }, + "invalid type, fail": { + "5", + true, + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + err := validateMaxTotalBypassMinFeeMsgGasUsage(test.msgTypes) + if test.expectErr { + require.Error(t, err) + return + } + require.NoError(t, err) + }) + } +} From a36a56174aa52c6d497c0a8add7be865d01f2bad Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Mon, 17 Apr 2023 09:41:05 +0200 Subject: [PATCH 24/47] fix e2e bypass msg test --- tests/e2e/e2e_bypassminfee_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/e2e/e2e_bypassminfee_test.go b/tests/e2e/e2e_bypassminfee_test.go index 1d6e7d11b4f..e918be07ef2 100644 --- a/tests/e2e/e2e_bypassminfee_test.go +++ b/tests/e2e/e2e_bypassminfee_test.go @@ -1,12 +1,31 @@ package e2e import ( + "fmt" + "time" + "cosmossdk.io/math" ) func (s *IntegrationTestSuite) testByPassMinFeeWithdrawReward() { // todo gov propose withdraw to be bypass-msg first // s.T().Skip() + chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) + + s.Require().Eventually( + func() bool { + globalFees, err := queryGlobalFees(chainAAPIEndpoint) + s.T().Logf("After gov new global fee proposal: %s", globalFees.String()) + s.Require().NoError(err) + return true + + // attention: if global fee is empty, when query globalfee, it shows empty rather than default ante.DefaultZeroGlobalFee() = 0uatom. + }, + 15*time.Second, + 5*time.Second, + ) + + // GlobalFee == minGasPrice+uatomDenom paidFeeAmt := math.LegacyMustNewDecFromStr(minGasPrice).Mul(math.LegacyNewDec(gas)).String() payee := s.chainA.validators[0].keyInfo.GetAddress() // pass From a2113e449de335da53852962c630615f3994bb7c Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Mon, 17 Apr 2023 16:58:50 +0200 Subject: [PATCH 25/47] save --- tests/e2e/e2e_bypassminfee_test.go | 10 +++++-- tests/e2e/e2e_globalfee_proposal_test.go | 38 ++++++++++++++++++++++++ tests/e2e/e2e_setup_test.go | 32 ++++++++++++++++++++ tests/e2e/e2e_test.go | 2 +- tests/e2e/query.go | 17 ++++++++++- 5 files changed, 95 insertions(+), 4 deletions(-) diff --git a/tests/e2e/e2e_bypassminfee_test.go b/tests/e2e/e2e_bypassminfee_test.go index e918be07ef2..0e24150fbdf 100644 --- a/tests/e2e/e2e_bypassminfee_test.go +++ b/tests/e2e/e2e_bypassminfee_test.go @@ -5,10 +5,11 @@ import ( "time" "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" ) -func (s *IntegrationTestSuite) testByPassMinFeeWithdrawReward() { - // todo gov propose withdraw to be bypass-msg first +func (s *IntegrationTestSuite) testBypassMinFeeWithdrawReward() { // s.T().Skip() chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) @@ -25,6 +26,11 @@ func (s *IntegrationTestSuite) testByPassMinFeeWithdrawReward() { 5*time.Second, ) + // gov propose withdraw to be bypass-msg first + submitterAddr := s.chainA.validators[0].keyInfo.GetAddress() + submitter := submitterAddr.String() + s.govProposeNewBypassMsgs([]string{sdk.MsgTypeURL(&distributiontypes.MsgWithdrawDelegatorReward{})}, proposalCounter, submitter, standardFees.String()) + // GlobalFee == minGasPrice+uatomDenom paidFeeAmt := math.LegacyMustNewDecFromStr(minGasPrice).Mul(math.LegacyNewDec(gas)).String() payee := s.chainA.validators[0].keyInfo.GetAddress() diff --git a/tests/e2e/e2e_globalfee_proposal_test.go b/tests/e2e/e2e_globalfee_proposal_test.go index 3f48007af6d..1f130666f13 100644 --- a/tests/e2e/e2e_globalfee_proposal_test.go +++ b/tests/e2e/e2e_globalfee_proposal_test.go @@ -46,3 +46,41 @@ func (s *IntegrationTestSuite) govProposeNewGlobalfee(newGlobalfee sdk.DecCoins, 5*time.Second, ) } + +func (s *IntegrationTestSuite) govProposeNewBypassMsgs(newBypassMsgs []string, proposalCounter int, submitter string, fees string) { //nolint:unparam + s.writeGovParamChangeProposalBypassMsgs(s.chainA, newBypassMsgs) + chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) + submitGovFlags := []string{"param-change", configFile(proposalBypassMsgFilename)} + depositGovFlags := []string{strconv.Itoa(proposalCounter), depositAmount.String()} + voteGovFlags := []string{strconv.Itoa(proposalCounter), "yes"} + + // gov proposing new fees + s.T().Logf("Proposal number: %d", proposalCounter) + s.T().Logf("Submitting, deposit and vote legacy Gov Proposal: change bypass min fee msg types to %s", newBypassMsgs) + s.runGovProcess(chainAAPIEndpoint, submitter, proposalCounter, paramtypes.ProposalTypeChange, submitGovFlags, depositGovFlags, voteGovFlags, "vote", false) + + // query the proposal status and new fee + s.Require().Eventually( + func() bool { + proposal, err := queryGovProposal(chainAAPIEndpoint, proposalCounter) + s.Require().NoError(err) + return proposal.GetProposal().Status == gov.StatusPassed + }, + 15*time.Second, + 5*time.Second, + ) + + s.Require().Eventually( + func() bool { + bypassMsgs, err := queryBypassMsgs(chainAAPIEndpoint) + s.T().Logf("After gov new global fee proposal: %s", newBypassMsgs) + s.Require().NoError(err) + + // attention: if global fee is empty, when query globalfee, it shows empty rather than default ante.DefaultZeroGlobalFee() = 0uatom. + s.Require().Equal(newBypassMsgs, bypassMsgs) + return true + }, + 15*time.Second, + 5*time.Second, + ) +} diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 01733ca0fc7..cdd647f84a6 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -61,6 +61,7 @@ const ( slashingShares int64 = 10000 proposalGlobalFeeFilename = "proposal_globalfee.json" + proposalBypassMsgFilename = "proposal_bypass_msg.json" proposalCommunitySpendFilename = "proposal_community_spend.json" proposalAddConsumerChainFilename = "proposal_add_consumer.json" proposalRemoveConsumerChainFilename = "proposal_remove_consumer.json" @@ -609,6 +610,37 @@ func (s *IntegrationTestSuite) writeGovParamChangeProposalGlobalFees(c *chain, c s.Require().NoError(err) } +func (s *IntegrationTestSuite) writeGovParamChangeProposalBypassMsgs(c *chain, msgs []string) { + type ParamInfo struct { + Subspace string `json:"subspace"` + Key string `json:"key"` + Value []string `json:"value"` + } + + type ParamChangeMessage struct { + Title string `json:"title"` + Description string `json:"description"` + Changes []ParamInfo `json:"changes"` + Deposit string `json:"deposit"` + } + paramChangeProposalBody, err := json.MarshalIndent(ParamChangeMessage{ + Title: "global fee test", + Description: "global fee change", + Changes: []ParamInfo{ + { + Subspace: "globalfee", + Key: "BypassMinFeeMsgTypes", + Value: msgs, + }, + }, + Deposit: "1000uatom", + }, "", " ") + s.Require().NoError(err) + + err = writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalBypassMsgFilename), paramChangeProposalBody) + s.Require().NoError(err) +} + func (s *IntegrationTestSuite) writeGovCommunitySpendProposal(c *chain, amount string, recipient string) { proposalCommSpend := &distrtypes.CommunityPoolSpendProposalWithDeposit{ Title: "Community Pool Spend", diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 10fbe61b0a2..508cfe79d80 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -37,7 +37,7 @@ func (s *IntegrationTestSuite) TestByPassMinFee() { if !runBypassMinFeeTest { s.T().Skip() } - s.testByPassMinFeeWithdrawReward() + s.testBypassMinFeeWithdrawReward() } func (s *IntegrationTestSuite) TestEncode() { diff --git a/tests/e2e/query.go b/tests/e2e/query.go index b8a7d711f5e..8312e575f63 100644 --- a/tests/e2e/query.go +++ b/tests/e2e/query.go @@ -74,7 +74,7 @@ func queryGaiaAllBalances(endpoint, addr string) (sdk.Coins, error) { return balancesResp.Balances, nil } -func queryGlobalFees(endpoint string) (amt sdk.DecCoins, err error) { +func queryGlobalFees(endpoint string) (sdk.DecCoins, error) { body, err := httpGet(fmt.Sprintf("%s/gaia/globalfee/v1beta1/params", endpoint)) if err != nil { return nil, fmt.Errorf("failed to execute HTTP request: %w", err) @@ -88,6 +88,20 @@ func queryGlobalFees(endpoint string) (amt sdk.DecCoins, err error) { return params.MinimumGasPrices, nil } +func queryBypassMsgs(endpoint string) ([]string, error) { + body, err := httpGet(fmt.Sprintf("%s/gaia/globalfee/v1beta1/params", endpoint)) + if err != nil { + return nil, fmt.Errorf("failed to execute HTTP request: %w", err) + } + + var params globalfee.QueryParamsResponse + if err := cdc.UnmarshalJSON(body, ¶ms); err != nil { + return []string{}, err + } + + return params.BypassMinFeeMsgTypes, nil +} + func queryDelegation(endpoint string, validatorAddr string, delegatorAddr string) (stakingtypes.QueryDelegationResponse, error) { var res stakingtypes.QueryDelegationResponse @@ -126,6 +140,7 @@ func queryGovProposal(endpoint string, proposalID int) (govtypes.QueryProposalRe return govProposalResp, fmt.Errorf("failed to execute HTTP request: %w", err) } if err := cdc.UnmarshalJSON(body, &govProposalResp); err != nil { + // panic(string(body)) return govProposalResp, err } From 751aee490ac6d396df80c8ff84afcd6376a71ab6 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Tue, 18 Apr 2023 14:02:56 +0200 Subject: [PATCH 26/47] save --- contrib/single-node.sh | 12 ++++++++---- tests/e2e/e2e_setup_test.go | 6 ++++-- tests/e2e/query.go | 1 + 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/contrib/single-node.sh b/contrib/single-node.sh index 9570b1a15fb..93428cf8f7a 100755 --- a/contrib/single-node.sh +++ b/contrib/single-node.sh @@ -15,6 +15,8 @@ if [ -z "$2" ]; then exit 1 fi +rm -rf /Users/simon/.gaia + # Build genesis file incl account for passed address coins="10000000000stake,100000000000samoleans" gaiad init --chain-id $CHAINID $CHAINID @@ -25,10 +27,12 @@ gaiad gentx validator 5000000000stake --keyring-backend="test" --chain-id $CHAIN gaiad collect-gentxs # Set proper defaults and change ports -sed -i 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:26657"#g' ~/.gaia/config/config.toml -sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/g' ~/.gaia/config/config.toml -sed -i 's/timeout_propose = "3s"/timeout_propose = "1s"/g' ~/.gaia/config/config.toml -sed -i 's/index_all_keys = false/index_all_keys = true/g' ~/.gaia/config/config.toml +echo 1 +sed -i '' 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:26657"#g' ~/.gaia/config/config.toml +echo 2 +sed -i '' 's/timeout_commit = "5s"/timeout_commit = "1s"/g' ~/.gaia/config/config.toml +sed -i '' 's/timeout_propose = "3s"/timeout_propose = "1s"/g' ~/.gaia/config/config.toml +sed -i '' 's/index_all_keys = false/index_all_keys = true/g' ~/.gaia/config/config.toml # Start the gaia gaiad start --pruning=nothing diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index cdd647f84a6..2138786d7bb 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -144,8 +144,10 @@ func (s *IntegrationTestSuite) SetupSuite() { s.initValidatorConfigs(s.chainB) s.runValidators(s.chainB, 10) - time.Sleep(10 * time.Second) - s.runIBCRelayer() + if runIBCTest { + time.Sleep(10 * time.Second) + s.runIBCRelayer() + } } func (s *IntegrationTestSuite) TearDownSuite() { diff --git a/tests/e2e/query.go b/tests/e2e/query.go index 8312e575f63..0c152f0affd 100644 --- a/tests/e2e/query.go +++ b/tests/e2e/query.go @@ -96,6 +96,7 @@ func queryBypassMsgs(endpoint string) ([]string, error) { var params globalfee.QueryParamsResponse if err := cdc.UnmarshalJSON(body, ¶ms); err != nil { + panic(string(body)) return []string{}, err } From daf07751c0c553110d130f345846f0dcdd1f71e6 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Wed, 19 Apr 2023 10:34:26 +0200 Subject: [PATCH 27/47] update e2e bypass min fee test --- tests/e2e/e2e_bypassminfee_test.go | 31 ++++++------- tests/e2e/e2e_globalfee_proposal_test.go | 49 +++++++++++++++++++++ tests/e2e/e2e_setup_test.go | 55 +++++++++++++++++++----- tests/e2e/query.go | 15 ++++++- 4 files changed, 122 insertions(+), 28 deletions(-) diff --git a/tests/e2e/e2e_bypassminfee_test.go b/tests/e2e/e2e_bypassminfee_test.go index 0e24150fbdf..8a76300c315 100644 --- a/tests/e2e/e2e_bypassminfee_test.go +++ b/tests/e2e/e2e_bypassminfee_test.go @@ -1,9 +1,6 @@ package e2e import ( - "fmt" - "time" - "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" @@ -11,29 +8,17 @@ import ( func (s *IntegrationTestSuite) testBypassMinFeeWithdrawReward() { // s.T().Skip() - chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) - - s.Require().Eventually( - func() bool { - globalFees, err := queryGlobalFees(chainAAPIEndpoint) - s.T().Logf("After gov new global fee proposal: %s", globalFees.String()) - s.Require().NoError(err) - return true - - // attention: if global fee is empty, when query globalfee, it shows empty rather than default ante.DefaultZeroGlobalFee() = 0uatom. - }, - 15*time.Second, - 5*time.Second, - ) // gov propose withdraw to be bypass-msg first submitterAddr := s.chainA.validators[0].keyInfo.GetAddress() submitter := submitterAddr.String() + proposalCounter++ s.govProposeNewBypassMsgs([]string{sdk.MsgTypeURL(&distributiontypes.MsgWithdrawDelegatorReward{})}, proposalCounter, submitter, standardFees.String()) // GlobalFee == minGasPrice+uatomDenom paidFeeAmt := math.LegacyMustNewDecFromStr(minGasPrice).Mul(math.LegacyNewDec(gas)).String() payee := s.chainA.validators[0].keyInfo.GetAddress() + // pass s.T().Logf("bypass-msg with fee in the denom of global fee, pass") s.execWithdrawAllRewards(s.chainA, 0, payee.String(), paidFeeAmt+uatomDenom, false) @@ -46,4 +31,16 @@ func (s *IntegrationTestSuite) testBypassMinFeeWithdrawReward() { // fail s.T().Logf("bypass-msg with non-zero coin not in the denom of global fee, fail") s.execWithdrawAllRewards(s.chainA, 0, payee.String(), paidFeeAmt+photonDenom, true) + + proposalCounter++ + // change MaxTotalBypassMinFeeMsgGasUsage through governance proposal from 1_000_0000 to 1 + s.govProposeNewMaxTotalBypassMinFeeMsgGasUsage(1, proposalCounter, submitter) + + // fail + s.T().Logf("bypass-msg has zero coin and maxTotalBypassMinFeeMsgGasUsage set to 1, fail") + s.execWithdrawAllRewards(s.chainA, 0, payee.String(), "0"+uatomDenom, true) + + // pass + s.T().Logf("bypass-msg has non zero coin and maxTotalBypassMinFeeMsgGasUsage set to 1, pass") + s.execWithdrawAllRewards(s.chainA, 0, payee.String(), paidFeeAmt+uatomDenom, false) } diff --git a/tests/e2e/e2e_globalfee_proposal_test.go b/tests/e2e/e2e_globalfee_proposal_test.go index 1f130666f13..d38d833589c 100644 --- a/tests/e2e/e2e_globalfee_proposal_test.go +++ b/tests/e2e/e2e_globalfee_proposal_test.go @@ -84,3 +84,52 @@ func (s *IntegrationTestSuite) govProposeNewBypassMsgs(newBypassMsgs []string, p 5*time.Second, ) } + +func (s *IntegrationTestSuite) govProposeNewMaxTotalBypassMinFeeMsgGasUsage(newGas uint64, proposalCounter int, submitter string) { //nolint:unparam + s.writeGovParamChangeProposalMaxTotalBypass(s.chainA, newGas) + chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) + submitGovFlags := []string{"param-change", configFile(proposalMaxTotalBypassFilename)} + depositGovFlags := []string{strconv.Itoa(proposalCounter), depositAmount.String()} + voteGovFlags := []string{strconv.Itoa(proposalCounter), "yes"} + + s.Require().Eventually( + func() bool { + gas, err := queryMaxTotalBypass(chainAAPIEndpoint) + s.T().Logf("Before gov new global fee proposal: %d", gas) + s.Require().NoError(err) + + return true + }, + 15*time.Second, + 5*time.Second, + ) + + // gov proposing new fees + s.T().Logf("Proposal number: %d", proposalCounter) + s.T().Logf("Submitting, deposit and vote legacy Gov Proposal: change maxTotalBypassMinFeeMsgGasUsage to %d", newGas) + s.runGovProcess(chainAAPIEndpoint, submitter, proposalCounter, paramtypes.ProposalTypeChange, submitGovFlags, depositGovFlags, voteGovFlags, "vote", false) + + // query the proposal status and new fee + s.Require().Eventually( + func() bool { + proposal, err := queryGovProposal(chainAAPIEndpoint, proposalCounter) + s.Require().NoError(err) + return proposal.GetProposal().Status == gov.StatusPassed + }, + 15*time.Second, + 5*time.Second, + ) + + s.Require().Eventually( + func() bool { + gas, err := queryMaxTotalBypass(chainAAPIEndpoint) + s.T().Logf("After gov new global fee proposal: %d", gas) + s.Require().NoError(err) + + s.Require().Equal(newGas, gas) + return true + }, + 15*time.Second, + 5*time.Second, + ) +} diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 2138786d7bb..bd344416275 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -51,17 +51,19 @@ const ( minGasPrice = "0.00001" // the test globalfee in genesis is the same as minGasPrice // global fee lower/higher than min_gas_price - initialGlobalFeeAmt = "0.00001" - lowGlobalFeesAmt = "0.000001" - highGlobalFeeAmt = "0.0001" - gas = 200000 - govProposalBlockBuffer = 35 - relayerAccountIndex = 0 - numberOfEvidences = 10 - slashingShares int64 = 10000 + initialGlobalFeeAmt = "0.00001" + lowGlobalFeesAmt = "0.000001" + highGlobalFeeAmt = "0.0001" + maxTotalBypassMinFeeMsgGasUsage = "1" + gas = 200000 + govProposalBlockBuffer = 35 + relayerAccountIndex = 0 + numberOfEvidences = 10 + slashingShares int64 = 10000 proposalGlobalFeeFilename = "proposal_globalfee.json" proposalBypassMsgFilename = "proposal_bypass_msg.json" + proposalMaxTotalBypassFilename = "proposal_max_total_bypass.json" proposalCommunitySpendFilename = "proposal_community_spend.json" proposalAddConsumerChainFilename = "proposal_add_consumer.json" proposalRemoveConsumerChainFilename = "proposal_remove_consumer.json" @@ -162,7 +164,9 @@ func (s *IntegrationTestSuite) TearDownSuite() { s.T().Log("tearing down e2e integration test suite...") - s.Require().NoError(s.dkrPool.Purge(s.hermesResource)) + if runIBCTest { + s.Require().NoError(s.dkrPool.Purge(s.hermesResource)) + } for _, vr := range s.valResources { for _, r := range vr { @@ -626,7 +630,7 @@ func (s *IntegrationTestSuite) writeGovParamChangeProposalBypassMsgs(c *chain, m Deposit string `json:"deposit"` } paramChangeProposalBody, err := json.MarshalIndent(ParamChangeMessage{ - Title: "global fee test", + Title: "ChangeProposalBypassMsgs", Description: "global fee change", Changes: []ParamInfo{ { @@ -643,6 +647,37 @@ func (s *IntegrationTestSuite) writeGovParamChangeProposalBypassMsgs(c *chain, m s.Require().NoError(err) } +func (s *IntegrationTestSuite) writeGovParamChangeProposalMaxTotalBypass(c *chain, gas uint64) { + type ParamInfo struct { + Subspace string `json:"subspace"` + Key string `json:"key"` + Value string `json:"value"` + } + + type ParamChangeMessage struct { + Title string `json:"title"` + Description string `json:"description"` + Changes []ParamInfo `json:"changes"` + Deposit string `json:"deposit"` + } + paramChangeProposalBody, err := json.MarshalIndent(ParamChangeMessage{ + Title: "ChangeProposalMaxTotalBypass", + Description: "global fee change", + Changes: []ParamInfo{ + { + Subspace: "globalfee", + Key: "MaxTotalBypassMinFeeMsgGasUsage", + Value: strconv.FormatInt(int64(gas), 10), + }, + }, + Deposit: "1000uatom", + }, "", " ") + s.Require().NoError(err) + + err = writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalMaxTotalBypassFilename), paramChangeProposalBody) + s.Require().NoError(err) +} + func (s *IntegrationTestSuite) writeGovCommunitySpendProposal(c *chain, amount string, recipient string) { proposalCommSpend := &distrtypes.CommunityPoolSpendProposalWithDeposit{ Title: "Community Pool Spend", diff --git a/tests/e2e/query.go b/tests/e2e/query.go index 0c152f0affd..3265cb29154 100644 --- a/tests/e2e/query.go +++ b/tests/e2e/query.go @@ -96,13 +96,26 @@ func queryBypassMsgs(endpoint string) ([]string, error) { var params globalfee.QueryParamsResponse if err := cdc.UnmarshalJSON(body, ¶ms); err != nil { - panic(string(body)) return []string{}, err } return params.BypassMinFeeMsgTypes, nil } +func queryMaxTotalBypass(endpoint string) (uint64, error) { + body, err := httpGet(fmt.Sprintf("%s/gaia/globalfee/v1beta1/params", endpoint)) + if err != nil { + return 0, fmt.Errorf("failed to execute HTTP request: %w", err) + } + + var params globalfee.QueryParamsResponse + if err := cdc.UnmarshalJSON(body, ¶ms); err != nil { + return 0, err + } + + return params.MaxTotalBypassMinFeeMsgGasUsage, nil +} + func queryDelegation(endpoint string, validatorAddr string, delegatorAddr string) (stakingtypes.QueryDelegationResponse, error) { var res stakingtypes.QueryDelegationResponse From 2f1873d9c52535eb9c06ac551abda2f3b965abaf Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Wed, 19 Apr 2023 13:16:08 +0200 Subject: [PATCH 28/47] remove print --- tests/e2e/e2e_globalfee_proposal_test.go | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/tests/e2e/e2e_globalfee_proposal_test.go b/tests/e2e/e2e_globalfee_proposal_test.go index d38d833589c..e865f06e859 100644 --- a/tests/e2e/e2e_globalfee_proposal_test.go +++ b/tests/e2e/e2e_globalfee_proposal_test.go @@ -92,18 +92,6 @@ func (s *IntegrationTestSuite) govProposeNewMaxTotalBypassMinFeeMsgGasUsage(newG depositGovFlags := []string{strconv.Itoa(proposalCounter), depositAmount.String()} voteGovFlags := []string{strconv.Itoa(proposalCounter), "yes"} - s.Require().Eventually( - func() bool { - gas, err := queryMaxTotalBypass(chainAAPIEndpoint) - s.T().Logf("Before gov new global fee proposal: %d", gas) - s.Require().NoError(err) - - return true - }, - 15*time.Second, - 5*time.Second, - ) - // gov proposing new fees s.T().Logf("Proposal number: %d", proposalCounter) s.T().Logf("Submitting, deposit and vote legacy Gov Proposal: change maxTotalBypassMinFeeMsgGasUsage to %d", newGas) From f14e64d5e0c343ee2fdcf6f55d25ef74b862eff3 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Thu, 20 Apr 2023 10:50:28 +0200 Subject: [PATCH 29/47] remove migration tests; revert 97b7e7b --- tests/e2e/query.go | 6 +- x/globalfee/migrations/v2/migration.go | 42 ------------- x/globalfee/migrations/v2/migration_test.go | 66 --------------------- x/globalfee/migrations/v2/store_test.go | 1 + 4 files changed, 4 insertions(+), 111 deletions(-) delete mode 100644 x/globalfee/migrations/v2/migration.go delete mode 100644 x/globalfee/migrations/v2/migration_test.go create mode 100644 x/globalfee/migrations/v2/store_test.go diff --git a/tests/e2e/query.go b/tests/e2e/query.go index 3265cb29154..4eec7f43667 100644 --- a/tests/e2e/query.go +++ b/tests/e2e/query.go @@ -80,12 +80,12 @@ func queryGlobalFees(endpoint string) (sdk.DecCoins, error) { return nil, fmt.Errorf("failed to execute HTTP request: %w", err) } - var params globalfee.QueryParamsResponse - if err := cdc.UnmarshalJSON(body, ¶ms); err != nil { + var fees globalfee.QueryParamsResponse + if err := cdc.UnmarshalJSON(body, &fees); err != nil { return sdk.DecCoins{}, err } - return params.MinimumGasPrices, nil + return fees.MinimumGasPrices, nil } func queryBypassMsgs(endpoint string) ([]string, error) { diff --git a/x/globalfee/migrations/v2/migration.go b/x/globalfee/migrations/v2/migration.go deleted file mode 100644 index b81a20520d2..00000000000 --- a/x/globalfee/migrations/v2/migration.go +++ /dev/null @@ -1,42 +0,0 @@ -package v2 - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - - "github.com/cosmos/gaia/v9/x/globalfee/types" -) - -// MigrateStore performs in-place params migrations of -// BypassMinFeeMsgTypes and MaxTotalBypassMinFeeMsgGasUsage -// from app.toml to globalfee params. -// The migration includes: -// Add bypass-min-fee-msg-types params that are set -// ["/ibc.core.channel.v1.MsgRecvPacket", -// "/ibc.core.channel.v1.MsgAcknowledgement", -// "/ibc.core.client.v1.MsgUpdateClient", -// "/ibc.core.channel.v1.MsgTimeout", -// "/ibc.core.channel.v1.MsgTimeoutOnClose"] as default and -// add MaxTotalBypassMinFeeMsgGasUsage that is set 1_000_000 as default. -// todo check name, migrateStore or migrateParams? -func MigrateStore(ctx sdk.Context, globalfeeSubspace paramtypes.Subspace) error { - var globalMinGasPrices sdk.DecCoins - - if globalfeeSubspace.Has(ctx, types.ParamStoreKeyMinGasPrices) { - globalfeeSubspace.Get(ctx, types.ParamStoreKeyMinGasPrices, &globalMinGasPrices) - } else { - // todo return err - return nil - } - - var params types.Params - - defaultParams := types.DefaultParams() - params.MinimumGasPrices = globalMinGasPrices - params.BypassMinFeeMsgTypes = defaultParams.BypassMinFeeMsgTypes - params.MaxTotalBypassMinFeeMsgGasUsage = defaultParams.MaxTotalBypassMinFeeMsgGasUsage - - globalfeeSubspace.SetParamSet(ctx, ¶ms) - - return nil -} diff --git a/x/globalfee/migrations/v2/migration_test.go b/x/globalfee/migrations/v2/migration_test.go deleted file mode 100644 index 27f178aef35..00000000000 --- a/x/globalfee/migrations/v2/migration_test.go +++ /dev/null @@ -1,66 +0,0 @@ -package v2_test - -import ( - "fmt" - "testing" - - v2 "github.com/cosmos/gaia/v9/x/globalfee/migrations/v2" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdktypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/stretchr/testify/require" - tmrand "github.com/tendermint/tendermint/libs/rand" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - - gaiahelpers "github.com/cosmos/gaia/v9/app/helpers" // todo this is v9 when other packages gose to v10 - "github.com/cosmos/gaia/v9/x/globalfee" - globalfeetypes "github.com/cosmos/gaia/v9/x/globalfee/types" -) - -func TestMigrateStore(t *testing.T) { - appV9 := gaiahelpers.Setup(t) - ctx := appV9.BaseApp.NewContext(false, tmproto.Header{ - ChainID: fmt.Sprintf("test-chain-%s", tmrand.Str(4)), - Height: 1, - }) - - globalfeeSubspace := appV9.GetSubspace(globalfee.ModuleName) - - // todo: add this check back when the module is v10 - //_, ok := getBypassMsgTypes(globalfeeSubspace, ctx) - //require.Equal(t, ok, false) - //_, ok = getMaxTotalBypassMinFeeMsgGasUsage(globalfeeSubspace, ctx) - //require.Equal(t, ok, false) - - err := v2.MigrateStore(ctx, globalfeeSubspace) - require.NoError(t, err) - - bypassMsgTypes, _ := getBypassMsgTypes(globalfeeSubspace, ctx) - maxGas, _ := getMaxTotalBypassMinFeeMsgGasUsage(globalfeeSubspace, ctx) - - require.Equal(t, bypassMsgTypes, globalfeetypes.DefaultBypassMinFeeMsgTypes) - require.Equal(t, maxGas, globalfeetypes.DefaultmaxTotalBypassMinFeeMsgGasUsage) - require.Equal(t, sdk.DecCoins{}, globalfeetypes.DefaultMinGasPrices) -} - -func getBypassMsgTypes(globalfeeSubspace sdktypes.Subspace, ctx sdk.Context) ([]string, bool) { - bypassMsgs := []string{} - if globalfeeSubspace.Has(ctx, globalfeetypes.ParamStoreKeyBypassMinFeeMsgTypes) { - globalfeeSubspace.Get(ctx, globalfeetypes.ParamStoreKeyBypassMinFeeMsgTypes, &bypassMsgs) - } else { - return bypassMsgs, false - } - - return bypassMsgs, true -} - -func getMaxTotalBypassMinFeeMsgGasUsage(globalfeeSubspace sdktypes.Subspace, ctx sdk.Context) (uint64, bool) { - var maxTotalBypassMinFeeMsgGasUsage uint64 - if globalfeeSubspace.Has(ctx, globalfeetypes.ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage) { - globalfeeSubspace.Get(ctx, globalfeetypes.ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage, &maxTotalBypassMinFeeMsgGasUsage) - } else { - return maxTotalBypassMinFeeMsgGasUsage, false - } - - return maxTotalBypassMinFeeMsgGasUsage, true -} diff --git a/x/globalfee/migrations/v2/store_test.go b/x/globalfee/migrations/v2/store_test.go new file mode 100644 index 00000000000..5ec3cc8e833 --- /dev/null +++ b/x/globalfee/migrations/v2/store_test.go @@ -0,0 +1 @@ +package v2 From bbeb3ebc86532579956ffb52d525655d59f2bfe1 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Thu, 20 Apr 2023 10:56:49 +0200 Subject: [PATCH 30/47] remove migration ; revert a244a85f --- app/upgrades/v10/constants.go | 15 -------------- app/upgrades/v10/upgrades.go | 27 ------------------------- x/globalfee/keeper/migrations.go | 23 --------------------- x/globalfee/migrations/v2/store_test.go | 1 - x/globalfee/module.go | 9 +-------- 5 files changed, 1 insertion(+), 74 deletions(-) delete mode 100644 app/upgrades/v10/constants.go delete mode 100644 app/upgrades/v10/upgrades.go delete mode 100644 x/globalfee/keeper/migrations.go delete mode 100644 x/globalfee/migrations/v2/store_test.go diff --git a/app/upgrades/v10/constants.go b/app/upgrades/v10/constants.go deleted file mode 100644 index b45786a90af..00000000000 --- a/app/upgrades/v10/constants.go +++ /dev/null @@ -1,15 +0,0 @@ -package v10 - -import ( - "github.com/cosmos/gaia/v9/app/upgrades" -) - -const ( - // UpgradeName defines the on-chain upgrade name. - UpgradeName = "v10" -) - -var Upgrade = upgrades.Upgrade{ - UpgradeName: UpgradeName, - CreateUpgradeHandler: CreateUpgradeHandler, -} diff --git a/app/upgrades/v10/upgrades.go b/app/upgrades/v10/upgrades.go deleted file mode 100644 index 37a19404054..00000000000 --- a/app/upgrades/v10/upgrades.go +++ /dev/null @@ -1,27 +0,0 @@ -package v10 - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - - "github.com/cosmos/gaia/v9/app/keepers" -) - -func CreateUpgradeHandler( - mm *module.Manager, - configurator module.Configurator, - keepers *keepers.AppKeepers, -) upgradetypes.UpgradeHandler { - return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { - ctx.Logger().Info("Starting module migrations...") - - vm, err := mm.RunMigrations(ctx, configurator, vm) - if err != nil { - return vm, err - } - - ctx.Logger().Info("Upgrade complete") - return vm, err - } -} diff --git a/x/globalfee/keeper/migrations.go b/x/globalfee/keeper/migrations.go deleted file mode 100644 index e93fd4b703d..00000000000 --- a/x/globalfee/keeper/migrations.go +++ /dev/null @@ -1,23 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - - v2 "github.com/cosmos/gaia/v9/x/globalfee/migrations/v2" -) - -// Migrator is a struct for handling in-place store migrations. -type Migrator struct { - globalfeeSubspace paramtypes.Subspace -} - -// NewMigrator returns a new Migrator. -func NewMigrator(globalfeeSubspace paramtypes.Subspace) Migrator { - return Migrator{globalfeeSubspace: globalfeeSubspace} -} - -// Migrate1to2 migrates from version 1 to 2. -func (m Migrator) Migrate1to2(ctx sdk.Context) error { - return v2.MigrateStore(ctx, m.globalfeeSubspace) -} diff --git a/x/globalfee/migrations/v2/store_test.go b/x/globalfee/migrations/v2/store_test.go deleted file mode 100644 index 5ec3cc8e833..00000000000 --- a/x/globalfee/migrations/v2/store_test.go +++ /dev/null @@ -1 +0,0 @@ -package v2 diff --git a/x/globalfee/module.go b/x/globalfee/module.go index dd190071e40..61cdd8fd645 100644 --- a/x/globalfee/module.go +++ b/x/globalfee/module.go @@ -3,7 +3,6 @@ package globalfee import ( "context" "encoding/json" - "fmt" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -18,7 +17,6 @@ import ( abci "github.com/tendermint/tendermint/abci/types" "github.com/cosmos/gaia/v9/x/globalfee/client/cli" - "github.com/cosmos/gaia/v9/x/globalfee/keeper" "github.com/cosmos/gaia/v9/x/globalfee/types" ) @@ -141,11 +139,6 @@ func (a AppModule) LegacyQuerierHandler(amino *codec.LegacyAmino) sdk.Querier { func (a AppModule) RegisterServices(cfg module.Configurator) { types.RegisterQueryServer(cfg.QueryServer(), NewGrpcQuerier(a.paramSpace)) - - m := keeper.NewMigrator(a.paramSpace) - if err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2); err != nil { - panic(fmt.Sprintf("failed to migrate x/globalfee from version 1 to 2: %v", err)) - } } func (a AppModule) BeginBlock(context sdk.Context, block abci.RequestBeginBlock) { @@ -160,5 +153,5 @@ func (a AppModule) EndBlock(context sdk.Context, block abci.RequestEndBlock) []a // introduced by the module. To avoid wrong/empty versions, the initial version // should be set to 1. func (a AppModule) ConsensusVersion() uint64 { - return 2 + return 1 } From d999e1e2484019bfe14db205e0c8aef3f035a70a Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Thu, 20 Apr 2023 10:57:35 +0200 Subject: [PATCH 31/47] Revert "remove bypass from config" This reverts commit 784dce92d1e9786842146fa64823d3280204a304. --- ante/ante.go | 11 ++++---- app/app.go | 49 +++++++++++++++++++++++++++++---- app/params/config.go | 55 +++++++++++++++++++++++++++++++++++++ cmd/gaiad/cmd/root.go | 5 +++- cmd/gaiad/cmd/testnet.go | 7 ++++- tests/e2e/e2e_setup_test.go | 30 ++++++++++++++++++-- x/globalfee/module.go | 19 ------------- 7 files changed, 143 insertions(+), 33 deletions(-) create mode 100644 app/params/config.go diff --git a/ante/ante.go b/ante/ante.go index 13ab14181c4..3adc9605fdb 100644 --- a/ante/ante.go +++ b/ante/ante.go @@ -17,11 +17,12 @@ import ( // channel keeper. type HandlerOptions struct { ante.HandlerOptions - Codec codec.BinaryCodec - GovKeeper *govkeeper.Keeper - IBCkeeper *ibckeeper.Keeper - GlobalFeeSubspace paramtypes.Subspace - StakingSubspace paramtypes.Subspace + Codec codec.BinaryCodec + GovKeeper *govkeeper.Keeper + IBCkeeper *ibckeeper.Keeper + BypassMinFeeMsgTypes []string + GlobalFeeSubspace paramtypes.Subspace + StakingSubspace paramtypes.Subspace } func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) { diff --git a/app/app.go b/app/app.go index d0eb273665b..a24db610e5a 100644 --- a/app/app.go +++ b/app/app.go @@ -28,6 +28,8 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" + ibcchanneltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types" ibctesting "github.com/cosmos/interchain-security/legacy_ibc_testing/testing" "github.com/gorilla/mux" "github.com/rakyll/statik/fs" @@ -186,6 +188,21 @@ func NewGaiaApp( app.MountTransientStores(app.GetTransientStoreKey()) app.MountMemoryStores(app.GetMemoryStoreKey()) + var bypassMinFeeMsgTypes []string + bypassMinFeeMsgTypesOptions := appOpts.Get(gaiaappparams.BypassMinFeeMsgTypesKey) + if bypassMinFeeMsgTypesOptions == nil { + bypassMinFeeMsgTypes = GetDefaultBypassFeeMessages() + } else { + bypassMinFeeMsgTypes = cast.ToStringSlice(bypassMinFeeMsgTypesOptions) + } + + if err := app.ValidateBypassFeeMsgTypes(bypassMinFeeMsgTypes); err != nil { + app.Logger().Error("invalid 'bypass-min-fee-msg-types' config option", "error", err) + panic(fmt.Sprintf("invalid 'bypass-min-fee-msg-types' config option: %s", err)) + } + + app.Logger().Info("min fee bypass activated for message types", "types", bypassMinFeeMsgTypes) + anteHandler, err := gaiaante.NewAnteHandler( gaiaante.HandlerOptions{ HandlerOptions: ante.HandlerOptions{ @@ -195,11 +212,12 @@ func NewGaiaApp( SignModeHandler: encodingConfig.TxConfig.SignModeHandler(), SigGasConsumer: ante.DefaultSigVerificationGasConsumer, }, - Codec: appCodec, - IBCkeeper: app.IBCKeeper, - GovKeeper: &app.GovKeeper, - GlobalFeeSubspace: app.GetSubspace(globalfee.ModuleName), - StakingSubspace: app.GetSubspace(stakingtypes.ModuleName), + Codec: appCodec, + IBCkeeper: app.IBCKeeper, + GovKeeper: &app.GovKeeper, + BypassMinFeeMsgTypes: bypassMinFeeMsgTypes, + GlobalFeeSubspace: app.GetSubspace(globalfee.ModuleName), + StakingSubspace: app.GetSubspace(stakingtypes.ModuleName), }, ) if err != nil { @@ -223,6 +241,27 @@ func NewGaiaApp( return app } +func GetDefaultBypassFeeMessages() []string { + return []string{ + sdk.MsgTypeURL(&ibcchanneltypes.MsgRecvPacket{}), + sdk.MsgTypeURL(&ibcchanneltypes.MsgAcknowledgement{}), + sdk.MsgTypeURL(&ibcclienttypes.MsgUpdateClient{}), + sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeout{}), + sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeoutOnClose{}), + } +} + +// ValidateBypassFeeMsgTypes checks that a proto message type exists for all MsgTypes in bypassMinFeeMsgTypes +// An error is returned for the first msgType that cannot be resolved +func (app *GaiaApp) ValidateBypassFeeMsgTypes(bypassMinFeeMsgTypes []string) error { + for _, msgType := range bypassMinFeeMsgTypes { + if _, err := app.interfaceRegistry.Resolve(msgType); err != nil { + return err + } + } + return nil +} + // Name returns the name of the App func (app *GaiaApp) Name() string { return app.BaseApp.Name() } diff --git a/app/params/config.go b/app/params/config.go new file mode 100644 index 00000000000..883330c37c3 --- /dev/null +++ b/app/params/config.go @@ -0,0 +1,55 @@ +package params + +import ( + "strings" + + serverconfig "github.com/cosmos/cosmos-sdk/server/config" +) + +var ( + // BypassMinFeeMsgTypesKey defines the configuration key for the + // BypassMinFeeMsgTypes value. + //nolint: gosec + BypassMinFeeMsgTypesKey = "bypass-min-fee-msg-types" + + // customGaiaConfigTemplate defines Gaia's custom application configuration TOML template. + customGaiaConfigTemplate = ` +############################################################################### +### Custom Gaia Configuration ### +############################################################################### +# bypass-min-fee-msg-types defines custom message types the operator may set that +# will bypass minimum fee checks during CheckTx. +# NOTE: +# bypass-min-fee-msg-types = [] will deactivate the bypass - no messages will be allowed to bypass the minimum fee check +# bypass-min-fee-msg-types = [...] will allow messages of specified type to bypass the minimum fee check +# removing bypass-min-fee-msg-types from the config file will apply the default values: +# ["/ibc.core.channel.v1.MsgRecvPacket", "/ibc.core.channel.v1.MsgAcknowledgement", "/ibc.core.client.v1.MsgUpdateClient"] +# +# Example: +# bypass-min-fee-msg-types = ["/ibc.core.channel.v1.MsgRecvPacket", "/ibc.core.channel.v1.MsgAcknowledgement", "/ibc.core.client.v1.MsgUpdateClient"] +bypass-min-fee-msg-types = [{{ range .BypassMinFeeMsgTypes }}{{ printf "%q, " . }}{{end}}] +` +) + +// CustomConfigTemplate defines Gaia's custom application configuration TOML +// template. It extends the core SDK template. +func CustomConfigTemplate() string { + config := serverconfig.DefaultConfigTemplate + lines := strings.Split(config, "\n") + // add the Gaia config at the second line of the file + lines[2] += customGaiaConfigTemplate + return strings.Join(lines, "\n") +} + +// CustomAppConfig defines Gaia's custom application configuration. +type CustomAppConfig struct { + serverconfig.Config + + // BypassMinFeeMsgTypes defines custom message types the operator may set that + // will bypass minimum fee checks during CheckTx. + // NOTE: + // bypass-min-fee-msg-types = [] will deactivate the bypass - no messages will be allowed to bypass the minimum fee check + // bypass-min-fee-msg-types = [] will allow messages of specified type to bypass the minimum fee check + // omitting bypass-min-fee-msg-types from the config file will use the default values: ["/ibc.core.channel.v1.MsgRecvPacket", "/ibc.core.channel.v1.MsgAcknowledgement", "/ibc.core.client.v1.MsgUpdateClient"] + BypassMinFeeMsgTypes []string `mapstructure:"bypass-min-fee-msg-types"` +} diff --git a/cmd/gaiad/cmd/root.go b/cmd/gaiad/cmd/root.go index 75611a45ad2..2183e7fac6c 100644 --- a/cmd/gaiad/cmd/root.go +++ b/cmd/gaiad/cmd/root.go @@ -81,7 +81,10 @@ func initAppConfig() (string, interface{}) { srvCfg.StateSync.SnapshotInterval = 1000 srvCfg.StateSync.SnapshotKeepRecent = 10 - return serverconfig.DefaultConfigTemplate, *srvCfg + return params.CustomConfigTemplate(), params.CustomAppConfig{ + Config: *srvCfg, + BypassMinFeeMsgTypes: gaia.GetDefaultBypassFeeMessages(), + } } func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { diff --git a/cmd/gaiad/cmd/testnet.go b/cmd/gaiad/cmd/testnet.go index 997ebfed7fc..10210d103ec 100644 --- a/cmd/gaiad/cmd/testnet.go +++ b/cmd/gaiad/cmd/testnet.go @@ -30,8 +30,11 @@ import ( tmrand "github.com/tendermint/tendermint/libs/rand" "github.com/tendermint/tendermint/types" tmtime "github.com/tendermint/tendermint/types/time" + // ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" // ibcchanneltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types" + + "github.com/cosmos/gaia/v9/app/params" ) var ( @@ -146,7 +149,9 @@ func InitTestnet( nodeIDs := make([]string, numValidators) valPubKeys := make([]cryptotypes.PubKey, numValidators) - simappConfig := *srvconfig.DefaultConfig() + simappConfig := params.CustomAppConfig{ + Config: *srvconfig.DefaultConfig(), + } simappConfig.MinGasPrices = minGasPrices simappConfig.API.Enable = true simappConfig.Telemetry.Enabled = true diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index bd344416275..d56292877ed 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -29,6 +29,7 @@ import ( genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" + ibcchanneltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types" "github.com/ory/dockertest/v3" "github.com/ory/dockertest/v3/docker" "github.com/spf13/viper" @@ -37,6 +38,8 @@ import ( tmjson "github.com/tendermint/tendermint/libs/json" "github.com/tendermint/tendermint/libs/rand" rpchttp "github.com/tendermint/tendermint/rpc/client/http" + + "github.com/cosmos/gaia/v9/app/params" ) const ( @@ -506,8 +509,31 @@ func (s *IntegrationTestSuite) initValidatorConfigs(c *chain) { appConfig.API.Enable = true appConfig.MinGasPrices = fmt.Sprintf("%s%s", minGasPrice, uatomDenom) - srvconfig.SetConfigTemplate(srvconfig.DefaultConfigTemplate) - srvconfig.WriteConfigFile(appCfgPath, appConfig) + // srvconfig.WriteConfigFile(appCfgPath, appConfig) + appCustomConfig := params.CustomAppConfig{ + Config: *appConfig, + BypassMinFeeMsgTypes: []string{ + // todo: use ibc as example ? + sdk.MsgTypeURL(&ibcchanneltypes.MsgRecvPacket{}), + sdk.MsgTypeURL(&ibcchanneltypes.MsgAcknowledgement{}), + sdk.MsgTypeURL(&ibcclienttypes.MsgUpdateClient{}), + "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", + }, + } + + customAppTemplate := ` +############################################################################### +### Custom Gaia Configuration ### +############################################################################### +# bypass-min-fee-msg-types defines custom message types the operator may set that +# will bypass minimum fee checks during CheckTx. +# +# Example: +# ["/ibc.core.channel.v1.MsgRecvPacket", "/ibc.core.channel.v1.MsgAcknowledgement", ...] +bypass-min-fee-msg-types = ["/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward","/ibc.applications.transfer.v1.MsgTransfer"] +` + srvconfig.DefaultConfigTemplate + srvconfig.SetConfigTemplate(customAppTemplate) + srvconfig.WriteConfigFile(appCfgPath, appCustomConfig) } } diff --git a/x/globalfee/module.go b/x/globalfee/module.go index 61cdd8fd645..2549e8403ce 100644 --- a/x/globalfee/module.go +++ b/x/globalfee/module.go @@ -93,29 +93,10 @@ func NewAppModule(paramSpace paramstypes.Subspace) *AppModule { func (a AppModule) InitGenesis(ctx sdk.Context, marshaler codec.JSONCodec, message json.RawMessage) []abci.ValidatorUpdate { var genesisState types.GenesisState marshaler.MustUnmarshalJSON(message, &genesisState) - - // if err := a.ValidateBypassFeeMsgTypes(genesisState.Params.BypassMinFeeMsgTypes); err != nil { - // a.Logger().Error("invalid 'bypass-min-fee-msg-types' config option", "error", err) - // panic(fmt.Sprintf("invalid 'bypass-min-fee-msg-types' config option: %s", err)) - // } - - // a.Logger().Info("min fee bypass activated for message types", "types", bypassMinFeeMsgTypes) - a.paramSpace.SetParamSet(ctx, &genesisState.Params) return nil } -// ValidateBypassFeeMsgTypes checks that a proto message type exists for all MsgTypes in bypassMinFeeMsgTypes -// An error is returned for the first msgType that cannot be resolved -// func (a AppModule) ValidateBypassFeeMsgTypes(bypassMinFeeMsgTypes []string) error { -// for _, msgType := range bypassMinFeeMsgTypes { -// if _, err := a.Get.interfaceRegistry.Resolve(msgType); err != nil { -// return err -// } -// } -// return nil -// } - func (a AppModule) ExportGenesis(ctx sdk.Context, marshaler codec.JSONCodec) json.RawMessage { var genState types.GenesisState a.paramSpace.GetParamSet(ctx, &genState.Params) From 2d56919b7fba4e98e129eb081d6e4aea819e1a06 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Thu, 20 Apr 2023 12:14:56 +0200 Subject: [PATCH 32/47] update changelog --- CHANGELOG.md | 2 +- tests/e2e/e2e_bypassminfee_test.go | 5 ++--- tests/e2e/e2e_test.go | 22 +++++++++++----------- tests/e2e/query.go | 1 - x/globalfee/types/params.go | 2 +- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19180b3b5b0..cdc251849d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,7 +35,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ # Changelog ## [Unreleased] -* Add `bypass-min-fee-msg-types` and `maxTotalBypassMinFeeMsgGagUsage` to globalfee params (state breaking and API breaking!!!). +* (feat!) [#2424] Add `bypass-min-fee-msg-types` and `maxTotalBypassMinFeeMsgGagUsage` to globalfee params (state breaking and API breaking!!!). ## [v9.0.3] - 2023-04-19 * (fix) [#2092](https://github.com/cosmos/gaia/pull/2092) change bypass-min-fee-types parsing; change defaults diff --git a/tests/e2e/e2e_bypassminfee_test.go b/tests/e2e/e2e_bypassminfee_test.go index 8a76300c315..b742e228c0b 100644 --- a/tests/e2e/e2e_bypassminfee_test.go +++ b/tests/e2e/e2e_bypassminfee_test.go @@ -7,15 +7,14 @@ import ( ) func (s *IntegrationTestSuite) testBypassMinFeeWithdrawReward() { - // s.T().Skip() - // gov propose withdraw to be bypass-msg first + // submit gov prop to change bypass-msg param to MsgWithdrawDelegatorReward submitterAddr := s.chainA.validators[0].keyInfo.GetAddress() submitter := submitterAddr.String() proposalCounter++ s.govProposeNewBypassMsgs([]string{sdk.MsgTypeURL(&distributiontypes.MsgWithdrawDelegatorReward{})}, proposalCounter, submitter, standardFees.String()) - // GlobalFee == minGasPrice+uatomDenom + // Note that the global fee min gas prices is equal to minGasPrice+uatomDenom paidFeeAmt := math.LegacyMustNewDecFromStr(minGasPrice).Mul(math.LegacyNewDec(gas)).String() payee := s.chainA.validators[0].keyInfo.GetAddress() diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 508cfe79d80..513e0074155 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -5,18 +5,18 @@ import ( ) var ( - runBankTest = false + runBankTest = true runBypassMinFeeTest = true - runEncodeTest = false - runEvidenceTest = false - runFeeGrantTest = false - runGlobalFeesTest = false - runGovTest = false - runIBCTest = false - runSlashingTest = false - runStakingAndDistributionTest = false - runVestingTest = false - runRestInterfacesTest = false + runEncodeTest = true + runEvidenceTest = true + runFeeGrantTest = true + runGlobalFeesTest = true + runGovTest = true + runIBCTest = true + runSlashingTest = true + runStakingAndDistributionTest = true + runVestingTest = true + runRestInterfacesTest = true ) func (s *IntegrationTestSuite) TestRestInterfaces() { diff --git a/tests/e2e/query.go b/tests/e2e/query.go index 4eec7f43667..75e298ea0a9 100644 --- a/tests/e2e/query.go +++ b/tests/e2e/query.go @@ -154,7 +154,6 @@ func queryGovProposal(endpoint string, proposalID int) (govtypes.QueryProposalRe return govProposalResp, fmt.Errorf("failed to execute HTTP request: %w", err) } if err := cdc.UnmarshalJSON(body, &govProposalResp); err != nil { - // panic(string(body)) return govProposalResp, err } diff --git a/x/globalfee/types/params.go b/x/globalfee/types/params.go index 44c424c92af..8a9d25a5eb1 100644 --- a/x/globalfee/types/params.go +++ b/x/globalfee/types/params.go @@ -57,7 +57,7 @@ func (p Params) ValidateBasic() error { return err } - if err := validateMaxTotalBypassMinFeeMsgGasUsage(p.MaxTotalBypassMinFeeMsgGasUsage); err != nil { + if err := validateMaxTotalBypassMinFeeMsgGasUsage(p.MaxTotalBypassMinFeeMsgGasUsage); err != nil { //nolint:revive return err } From d372c4babe4ef3e8b2f1b93a80ffdaa3ebd6c8de Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Wed, 26 Apr 2023 15:46:34 +0200 Subject: [PATCH 33/47] Update CHANGELOG.md Co-authored-by: Marius Poke --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdc251849d5..17ceec5c2d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,7 +35,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ # Changelog ## [Unreleased] -* (feat!) [#2424] Add `bypass-min-fee-msg-types` and `maxTotalBypassMinFeeMsgGagUsage` to globalfee params (state breaking and API breaking!!!). +* (feat!) [#2424] Add `bypass-min-fee-msg-types` and `maxTotalBypassMinFeeMsgGagUsage` to globalfee params. Note that this change is both state breaking and API breaking. ## [v9.0.3] - 2023-04-19 * (fix) [#2092](https://github.com/cosmos/gaia/pull/2092) change bypass-min-fee-types parsing; change defaults From b63f2192ce81915f422740d2b018029d244f52ad Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Mon, 1 May 2023 15:11:10 +0200 Subject: [PATCH 34/47] update nits --- docs/proto/proto-docs.md | 4 ++-- go.mod | 4 ++-- go.sum | 3 +-- proto/gaia/globalfee/v1beta1/genesis.proto | 7 ++++--- x/globalfee/types/genesis.pb.go | 7 ++++--- x/globalfee/types/params.go | 2 ++ 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index 83c20fd683b..e2f17b2f6b5 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -104,8 +104,8 @@ Params defines the set of module parameters. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `minimum_gas_prices` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | minimum_gas_prices stores the minimum gas price(s) for all TX on the chain. When multiple coins are defined then they are accepted alternatively. The list must be sorted by denoms asc. No duplicate denoms or zero amount values allowed. For more information see https://docs.cosmos.network/main/modules/auth#concepts | -| `bypass_min_fee_msg_types` | [string](#string) | repeated | bypass_min_fee_msg_types defines a list of IBC message type urls that are free of fee charge | -| `max_total_bypass_min_fee_msg_gas_usage` | [uint64](#uint64) | | max_total_bypass_min_fee_msg_gas_usage defines the total maximum gas usage allowed to bypass fee charge | +| `bypass_min_fee_msg_types` | [string](#string) | repeated | bypass_min_fee_msg_types defines a list of message type urls that are free of fee charge. | +| `max_total_bypass_min_fee_msg_gas_usage` | [uint64](#uint64) | | max_total_bypass_min_fee_msg_gas_usage defines the total maximum gas usage allowed for a transaction containing only messages of types in bypass_min_fee_msg_types to bypass fee charge. | diff --git a/go.mod b/go.mod index 4e215df39c7..861d1bf6ba5 100644 --- a/go.mod +++ b/go.mod @@ -23,8 +23,8 @@ require ( github.com/stretchr/testify v1.8.2 github.com/tendermint/tendermint v0.34.27 github.com/tendermint/tm-db v0.6.7 - google.golang.org/genproto v0.0.0-20230403163135-c38d8f061ccd - google.golang.org/grpc v1.54.0 + google.golang.org/genproto v0.0.0-20230125152338-dcaf20b6aeaa + google.golang.org/grpc v1.52.3 ) require ( diff --git a/go.sum b/go.sum index 7f0e688e6d7..6e559f6a20f 100644 --- a/go.sum +++ b/go.sum @@ -3913,9 +3913,8 @@ google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1/go.mod h1:rZS5c/ZV google.golang.org/genproto v0.0.0-20221117204609-8f9c96812029/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= google.golang.org/genproto v0.0.0-20221201164419-0e50fba7f41c/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= +google.golang.org/genproto v0.0.0-20230125152338-dcaf20b6aeaa h1:qQPhfbPO23fwm/9lQr91L1u62Zo6cm+zI+slZT+uf+o= google.golang.org/genproto v0.0.0-20230125152338-dcaf20b6aeaa/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/genproto v0.0.0-20230403163135-c38d8f061ccd h1:sLpv7bNL1AsX3fdnWh9WVh7ejIzXdOc1RRHGeAmeStU= -google.golang.org/genproto v0.0.0-20230403163135-c38d8f061ccd/go.mod h1:UUQDJDOlWu4KYeJZffbWgBkS1YFobzKbLVfK69pe0Ak= google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= diff --git a/proto/gaia/globalfee/v1beta1/genesis.proto b/proto/gaia/globalfee/v1beta1/genesis.proto index 2029cbc7d63..d83815a060a 100644 --- a/proto/gaia/globalfee/v1beta1/genesis.proto +++ b/proto/gaia/globalfee/v1beta1/genesis.proto @@ -28,14 +28,15 @@ message Params { (gogoproto.moretags) = "yaml:\"minimum_gas_prices\"", (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins" ]; - // bypass_min_fee_msg_types defines a list of IBC message type urls - // that are free of fee charge + // bypass_min_fee_msg_types defines a list of message type urls + // that are free of fee charge. repeated string bypass_min_fee_msg_types = 2 [ (gogoproto.jsontag) = "bypass_min_fee_msg_types,omitempty", (gogoproto.moretags) = "yaml:\"bypass_min_fee_msg_types\"" ]; // max_total_bypass_min_fee_msg_gas_usage defines the total maximum gas usage - // allowed to bypass fee charge + // allowed for a transaction containing only messages of types in bypass_min_fee_msg_types + // to bypass fee charge. uint64 max_total_bypass_min_fee_msg_gas_usage = 3; } diff --git a/x/globalfee/types/genesis.pb.go b/x/globalfee/types/genesis.pb.go index 14515cc3bed..1e9188ad464 100644 --- a/x/globalfee/types/genesis.pb.go +++ b/x/globalfee/types/genesis.pb.go @@ -79,11 +79,12 @@ type Params struct { // values allowed. For more information see // https://docs.cosmos.network/main/modules/auth#concepts MinimumGasPrices github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=minimum_gas_prices,json=minimumGasPrices,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"minimum_gas_prices,omitempty" yaml:"minimum_gas_prices"` - // bypass_min_fee_msg_types defines a list of IBC message type urls - // that are free of fee charge + // bypass_min_fee_msg_types defines a list of message type urls + // that are free of fee charge. BypassMinFeeMsgTypes []string `protobuf:"bytes,2,rep,name=bypass_min_fee_msg_types,json=bypassMinFeeMsgTypes,proto3" json:"bypass_min_fee_msg_types,omitempty" yaml:"bypass_min_fee_msg_types"` // max_total_bypass_min_fee_msg_gas_usage defines the total maximum gas usage - // allowed to bypass fee charge + // allowed for a transaction containing only messages of types in bypass_min_fee_msg_types + // to bypass fee charge. MaxTotalBypassMinFeeMsgGasUsage uint64 `protobuf:"varint,3,opt,name=max_total_bypass_min_fee_msg_gas_usage,json=maxTotalBypassMinFeeMsgGasUsage,proto3" json:"max_total_bypass_min_fee_msg_gas_usage,omitempty"` } diff --git a/x/globalfee/types/params.go b/x/globalfee/types/params.go index 8a9d25a5eb1..1ecb2b6d504 100644 --- a/x/globalfee/types/params.go +++ b/x/globalfee/types/params.go @@ -17,6 +17,8 @@ var ( ParamStoreKeyBypassMinFeeMsgTypes = []byte("BypassMinFeeMsgTypes") ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage = []byte("MaxTotalBypassMinFeeMsgGasUsage") + // DefaultMinGasPrices is set at runtime to the staking token with zero amount i.e. "0uatom" + // see DefaultZeroGlobalFee method in gaia/x/globalfee/ante/fee.go. DefaultMinGasPrices = sdk.DecCoins{} DefaultBypassMinFeeMsgTypes = []string{ sdk.MsgTypeURL(&ibcchanneltypes.MsgRecvPacket{}), From 664ed2661336338ed3d719c2446715fc24aebc1f Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Tue, 2 May 2023 10:42:47 +0200 Subject: [PATCH 35/47] clean up script --- contrib/single-node.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/contrib/single-node.sh b/contrib/single-node.sh index 93428cf8f7a..9570b1a15fb 100755 --- a/contrib/single-node.sh +++ b/contrib/single-node.sh @@ -15,8 +15,6 @@ if [ -z "$2" ]; then exit 1 fi -rm -rf /Users/simon/.gaia - # Build genesis file incl account for passed address coins="10000000000stake,100000000000samoleans" gaiad init --chain-id $CHAINID $CHAINID @@ -27,12 +25,10 @@ gaiad gentx validator 5000000000stake --keyring-backend="test" --chain-id $CHAIN gaiad collect-gentxs # Set proper defaults and change ports -echo 1 -sed -i '' 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:26657"#g' ~/.gaia/config/config.toml -echo 2 -sed -i '' 's/timeout_commit = "5s"/timeout_commit = "1s"/g' ~/.gaia/config/config.toml -sed -i '' 's/timeout_propose = "3s"/timeout_propose = "1s"/g' ~/.gaia/config/config.toml -sed -i '' 's/index_all_keys = false/index_all_keys = true/g' ~/.gaia/config/config.toml +sed -i 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:26657"#g' ~/.gaia/config/config.toml +sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/g' ~/.gaia/config/config.toml +sed -i 's/timeout_propose = "3s"/timeout_propose = "1s"/g' ~/.gaia/config/config.toml +sed -i 's/index_all_keys = false/index_all_keys = true/g' ~/.gaia/config/config.toml # Start the gaia gaiad start --pruning=nothing From 537e0f136981fd3eab50361793bbb60692af8f6a Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Tue, 2 May 2023 10:43:43 +0200 Subject: [PATCH 36/47] fix changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f45917b4d4..64c19f67da2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,12 +35,12 @@ Ref: https://keepachangelog.com/en/1.0.0/ # Changelog ## [Unreleased] -* (feat!) [#2424] Add `bypass-min-fee-msg-types` and `maxTotalBypassMinFeeMsgGagUsage` to globalfee params. Note that this change is both state breaking and API breaking. ### Improvements * (test) [#2440](https://github.com/cosmos/gaia/pull/2440) Add vulncheck to nightly builds ### State Machine Breaking +* (feat!) [#2424] Add `bypass-min-fee-msg-types` and `maxTotalBypassMinFeeMsgGagUsage` to globalfee params. Note that this change is both state breaking and API breaking. * (gaia) Bump Golang prerequisite from 1.18 to 1.20 see (https://go.dev/blog/go1.20) for details. From 7cc206fc0eb8c6275e09c69a55fa17020b71f1df Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Tue, 2 May 2023 10:58:32 +0200 Subject: [PATCH 37/47] fix linter --- tests/e2e/e2e_bypassminfee_test.go | 1 - tests/e2e/e2e_globalfee_proposal_test.go | 6 +++--- x/globalfee/types/params.go | 6 +----- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/tests/e2e/e2e_bypassminfee_test.go b/tests/e2e/e2e_bypassminfee_test.go index b742e228c0b..dda4dd20313 100644 --- a/tests/e2e/e2e_bypassminfee_test.go +++ b/tests/e2e/e2e_bypassminfee_test.go @@ -7,7 +7,6 @@ import ( ) func (s *IntegrationTestSuite) testBypassMinFeeWithdrawReward() { - // submit gov prop to change bypass-msg param to MsgWithdrawDelegatorReward submitterAddr := s.chainA.validators[0].keyInfo.GetAddress() submitter := submitterAddr.String() diff --git a/tests/e2e/e2e_globalfee_proposal_test.go b/tests/e2e/e2e_globalfee_proposal_test.go index 07df22daf2e..52b8626c1fa 100644 --- a/tests/e2e/e2e_globalfee_proposal_test.go +++ b/tests/e2e/e2e_globalfee_proposal_test.go @@ -85,19 +85,19 @@ func (s *IntegrationTestSuite) govProposeNewBypassMsgs(newBypassMsgs []string, p ) } -func (s *IntegrationTestSuite) govProposeNewMaxTotalBypassMinFeeMsgGasUsage(newGas uint64, proposalCounter int, submitter string) { //nolint:unparam +func (s *IntegrationTestSuite) govProposeNewMaxTotalBypassMinFeeMsgGasUsage(newGas uint64, proposalCounter int, submitter string) { s.writeGovParamChangeProposalMaxTotalBypass(s.chainA, newGas) chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) submitGovFlags := []string{"param-change", configFile(proposalMaxTotalBypassFilename)} depositGovFlags := []string{strconv.Itoa(proposalCounter), depositAmount.String()} voteGovFlags := []string{strconv.Itoa(proposalCounter), "yes"} - // gov proposing new fees + // gov proposing new max gas usage for bypass msgs s.T().Logf("Proposal number: %d", proposalCounter) s.T().Logf("Submitting, deposit and vote legacy Gov Proposal: change maxTotalBypassMinFeeMsgGasUsage to %d", newGas) s.runGovProcess(chainAAPIEndpoint, submitter, proposalCounter, paramtypes.ProposalTypeChange, submitGovFlags, depositGovFlags, voteGovFlags, "vote", false) - // query the proposal status and new fee + // query the proposal status and max gas usage for bypass msgs s.Require().Eventually( func() bool { proposal, err := queryGovProposal(chainAAPIEndpoint, proposalCounter) diff --git a/x/globalfee/types/params.go b/x/globalfee/types/params.go index 1ecb2b6d504..07e67a983fc 100644 --- a/x/globalfee/types/params.go +++ b/x/globalfee/types/params.go @@ -59,11 +59,7 @@ func (p Params) ValidateBasic() error { return err } - if err := validateMaxTotalBypassMinFeeMsgGasUsage(p.MaxTotalBypassMinFeeMsgGasUsage); err != nil { //nolint:revive - return err - } - - return nil + return validateMaxTotalBypassMinFeeMsgGasUsage(p.MaxTotalBypassMinFeeMsgGasUsage) } // ParamSetPairs returns the parameter set pairs. From 973ef4d01864b96d7bc1bf42eb8993dc9ff78234 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Fri, 5 May 2023 09:10:11 +0200 Subject: [PATCH 38/47] nits --- go.sum | 7 ---- tests/e2e/e2e_globalfee_proposal_test.go | 2 +- tests/e2e/e2e_setup_test.go | 6 ++-- tests/e2e/query.go | 46 ++++++++++-------------- x/globalfee/genesis_test.go | 15 +++++--- 5 files changed, 31 insertions(+), 45 deletions(-) diff --git a/go.sum b/go.sum index f2719af6d40..69de1126a4b 100644 --- a/go.sum +++ b/go.sum @@ -722,8 +722,6 @@ github.com/iancoleman/orderedmap v0.2.0 h1:sq1N/TFpYH++aViPcaKjys3bDClUEU7s5B+z6 github.com/iancoleman/orderedmap v0.2.0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= -github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM= github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA= @@ -1025,8 +1023,6 @@ github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJ github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= -github.com/ory/dockertest/v3 v3.9.1 h1:v4dkG+dlu76goxMiTT2j8zV7s4oPPEppKT8K8p2f1kY= -github.com/ory/dockertest/v3 v3.9.1/go.mod h1:42Ir9hmvaAPm0Mgibk6mBPi7SFvTXxEcnztDYOJ//uM= github.com/ory/dockertest/v3 v3.10.0 h1:4K3z2VMe8Woe++invjaTB7VRyQXQy5UY+loujO4aNE4= github.com/ory/dockertest/v3 v3.10.0/go.mod h1:nr57ZbRWMqfsdGdFNLHz5jjNdDb7VVFnzAeW1n5N1Lg= github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= @@ -1411,8 +1407,6 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= -golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1919,7 +1913,6 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= diff --git a/tests/e2e/e2e_globalfee_proposal_test.go b/tests/e2e/e2e_globalfee_proposal_test.go index 52b8626c1fa..232868cedca 100644 --- a/tests/e2e/e2e_globalfee_proposal_test.go +++ b/tests/e2e/e2e_globalfee_proposal_test.go @@ -110,7 +110,7 @@ func (s *IntegrationTestSuite) govProposeNewMaxTotalBypassMinFeeMsgGasUsage(newG s.Require().Eventually( func() bool { - gas, err := queryMaxTotalBypass(chainAAPIEndpoint) + gas, err := queryMaxTotalBypassMinFeeMsgGasUsage(chainAAPIEndpoint) s.T().Logf("After gov new global fee proposal: %d", gas) s.Require().NoError(err) diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index d56292877ed..4ba210fa04a 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -149,10 +149,8 @@ func (s *IntegrationTestSuite) SetupSuite() { s.initValidatorConfigs(s.chainB) s.runValidators(s.chainB, 10) - if runIBCTest { - time.Sleep(10 * time.Second) - s.runIBCRelayer() - } + time.Sleep(10 * time.Second) + s.runIBCRelayer() } func (s *IntegrationTestSuite) TearDownSuite() { diff --git a/tests/e2e/query.go b/tests/e2e/query.go index 75e298ea0a9..8324a9c7cea 100644 --- a/tests/e2e/query.go +++ b/tests/e2e/query.go @@ -17,7 +17,7 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - globalfee "github.com/cosmos/gaia/v9/x/globalfee/types" + "github.com/cosmos/gaia/v9/x/globalfee/types" ) func queryGaiaTx(endpoint, txHash string) error { @@ -74,46 +74,36 @@ func queryGaiaAllBalances(endpoint, addr string) (sdk.Coins, error) { return balancesResp.Balances, nil } -func queryGlobalFees(endpoint string) (sdk.DecCoins, error) { +func queryGlobalFeeParams(endpoint string) (types.Params, error) { body, err := httpGet(fmt.Sprintf("%s/gaia/globalfee/v1beta1/params", endpoint)) if err != nil { - return nil, fmt.Errorf("failed to execute HTTP request: %w", err) + return types.Params{}, fmt.Errorf("failed to execute HTTP request: %w", err) } - var fees globalfee.QueryParamsResponse - if err := cdc.UnmarshalJSON(body, &fees); err != nil { - return sdk.DecCoins{}, err + var params types.Params + if err := cdc.UnmarshalJSON(body, ¶ms); err != nil { + return types.Params{}, err } - return fees.MinimumGasPrices, nil + return params, nil } -func queryBypassMsgs(endpoint string) ([]string, error) { - body, err := httpGet(fmt.Sprintf("%s/gaia/globalfee/v1beta1/params", endpoint)) - if err != nil { - return nil, fmt.Errorf("failed to execute HTTP request: %w", err) - } - - var params globalfee.QueryParamsResponse - if err := cdc.UnmarshalJSON(body, ¶ms); err != nil { - return []string{}, err - } +func queryGlobalFees(endpoint string) (sdk.DecCoins, error) { + p, err := queryGlobalFeeParams(endpoint) - return params.BypassMinFeeMsgTypes, nil + return p.MinimumGasPrices, err } -func queryMaxTotalBypass(endpoint string) (uint64, error) { - body, err := httpGet(fmt.Sprintf("%s/gaia/globalfee/v1beta1/params", endpoint)) - if err != nil { - return 0, fmt.Errorf("failed to execute HTTP request: %w", err) - } +func queryBypassMsgs(endpoint string) ([]string, error) { + p, err := queryGlobalFeeParams(endpoint) - var params globalfee.QueryParamsResponse - if err := cdc.UnmarshalJSON(body, ¶ms); err != nil { - return 0, err - } + return p.BypassMinFeeMsgTypes, err +} + +func queryMaxTotalBypassMinFeeMsgGasUsage(endpoint string) (uint64, error) { + p, err := queryGlobalFeeParams(endpoint) - return params.MaxTotalBypassMinFeeMsgGasUsage, nil + return p.MaxTotalBypassMinFeeMsgGasUsage, err } func queryDelegation(endpoint string, validatorAddr string, delegatorAddr string) (stakingtypes.QueryDelegationResponse, error) { diff --git a/x/globalfee/genesis_test.go b/x/globalfee/genesis_test.go index 5e1477436be..b27f207f60e 100644 --- a/x/globalfee/genesis_test.go +++ b/x/globalfee/genesis_test.go @@ -35,19 +35,24 @@ func TestValidateGenesis(t *testing.T) { expErr bool }{ "all good": { - src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"1"}], "bypass_min_fee_msg_types":["/ibc.core.channel.v1.MsgRecvPacket"]}}`, + src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"1"}], "bypass_min_fee_msg_types":["/ibc.core.channel.v1.MsgRecvPacket"]}}`, + expErr: false, }, "empty minimum": { - src: `{"params":{"minimum_gas_prices":[], "bypass_min_fee_msg_types":[]}}`, + src: `{"params":{"minimum_gas_prices":[], "bypass_min_fee_msg_types":[]}}`, + expErr: false, }, "minimum and bypass not set": { - src: `{"params":{}}`, + src: `{"params":{}}`, + expErr: false, }, "minimum not set": { - src: `{"params":{"bypass_min_fee_msg_types":[]}}`, + src: `{"params":{"bypass_min_fee_msg_types":[]}}`, + expErr: false, }, "bypass not set": { - src: `{"params":{"minimum_gas_prices":[]}}`, + src: `{"params":{"minimum_gas_prices":[]}}`, + expErr: false, }, "zero amount allowed": { src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"0"}]}}`, From ad85e58db0c1d9457e1aebd9adf49f32b0f9ce0e Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Fri, 5 May 2023 16:12:22 +0200 Subject: [PATCH 39/47] improve comments --- tests/e2e/e2e_bypassminfee_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/e2e/e2e_bypassminfee_test.go b/tests/e2e/e2e_bypassminfee_test.go index dda4dd20313..497e4587c1b 100644 --- a/tests/e2e/e2e_bypassminfee_test.go +++ b/tests/e2e/e2e_bypassminfee_test.go @@ -35,10 +35,10 @@ func (s *IntegrationTestSuite) testBypassMinFeeWithdrawReward() { s.govProposeNewMaxTotalBypassMinFeeMsgGasUsage(1, proposalCounter, submitter) // fail - s.T().Logf("bypass-msg has zero coin and maxTotalBypassMinFeeMsgGasUsage set to 1, fail") + s.T().Logf("bypass-msg with zero coin in the denom of global fee and maxTotalBypassMinFeeMsgGasUsage set to 1, fail") s.execWithdrawAllRewards(s.chainA, 0, payee.String(), "0"+uatomDenom, true) // pass - s.T().Logf("bypass-msg has non zero coin and maxTotalBypassMinFeeMsgGasUsage set to 1, pass") + s.T().Logf("bypass-msg with non zero coin in the denom of global fee and maxTotalBypassMinFeeMsgGasUsage set to 1, pass") s.execWithdrawAllRewards(s.chainA, 0, payee.String(), paidFeeAmt+uatomDenom, false) } From 261f40892c5f0d0693090a4f15dc4cdeda8e76d2 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Mon, 8 May 2023 10:41:09 +0200 Subject: [PATCH 40/47] Change global fee query name --- x/globalfee/ante/fee_utils.go | 2 +- x/globalfee/client/cli/query.go | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/x/globalfee/ante/fee_utils.go b/x/globalfee/ante/fee_utils.go index b3d5e2c8e80..00e41238e4f 100644 --- a/x/globalfee/ante/fee_utils.go +++ b/x/globalfee/ante/fee_utils.go @@ -76,7 +76,7 @@ func Find(coins sdk.Coins, denom string) (bool, sdk.Coin) { } // splitCoinsByDenoms returns the given coins split in two whether -// their demon is or isn't found in the given denom map. +// their denom is or isn't found in the given denom map. func splitCoinsByDenoms(feeCoins sdk.Coins, denomMap map[string]bool) (sdk.Coins, sdk.Coins) { feeCoinsNonZeroDenom, feeCoinsZeroDenom := sdk.Coins{}, sdk.Coins{} diff --git a/x/globalfee/client/cli/query.go b/x/globalfee/client/cli/query.go index 3a247320301..4215d2ccfdb 100644 --- a/x/globalfee/client/cli/query.go +++ b/x/globalfee/client/cli/query.go @@ -17,19 +17,17 @@ func GetQueryCmd() *cobra.Command { RunE: client.ValidateCmd, } queryCmd.AddCommand( - GetCmdShowMinimumGasPrices(), + GetCmdShowGlobalFeeParams(), ) return queryCmd } -func GetCmdShowMinimumGasPrices() *cobra.Command { +func GetCmdShowGlobalFeeParams() *cobra.Command { cmd := &cobra.Command{ Use: "params", Short: "Show globalfee params", - // todo check here - Long: "Show globalfee requirement: minimum_gas_prices, bypass_min_fee_msg_types, max_total_bypass_minFee_msg_gas_usage", - // Aliases: []string{"min"}, - Args: cobra.ExactArgs(0), + Long: "Show globalfee requirement: minimum_gas_prices, bypass_min_fee_msg_types, max_total_bypass_minFee_msg_gas_usage", + Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { From c3af86fa138d3a6e64a55964eec6a52b12178bc4 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Mon, 8 May 2023 14:48:10 +0200 Subject: [PATCH 41/47] update e2e bypass test --- go.sum | 2 - tests/e2e/e2e_bypassminfee_test.go | 74 ++++++++++++++++++++++++------ tests/e2e/e2e_setup_test.go | 5 +- tests/e2e/e2e_test.go | 5 +- tests/e2e/query.go | 15 ++++++ 5 files changed, 82 insertions(+), 19 deletions(-) diff --git a/go.sum b/go.sum index fe68e505bba..47938240eba 100644 --- a/go.sum +++ b/go.sum @@ -1023,8 +1023,6 @@ github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJ github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= -github.com/ory/dockertest/v3 v3.9.1 h1:v4dkG+dlu76goxMiTT2j8zV7s4oPPEppKT8K8p2f1kY= -github.com/ory/dockertest/v3 v3.9.1/go.mod h1:42Ir9hmvaAPm0Mgibk6mBPi7SFvTXxEcnztDYOJ//uM= github.com/ory/dockertest/v3 v3.10.0 h1:4K3z2VMe8Woe++invjaTB7VRyQXQy5UY+loujO4aNE4= github.com/ory/dockertest/v3 v3.10.0/go.mod h1:nr57ZbRWMqfsdGdFNLHz5jjNdDb7VVFnzAeW1n5N1Lg= github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= diff --git a/tests/e2e/e2e_bypassminfee_test.go b/tests/e2e/e2e_bypassminfee_test.go index ecc16c25c30..2151069ecad 100644 --- a/tests/e2e/e2e_bypassminfee_test.go +++ b/tests/e2e/e2e_bypassminfee_test.go @@ -1,22 +1,70 @@ package e2e import ( + "fmt" + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" ) -func (s *IntegrationTestSuite) testByPassMinFeeWithdrawReward() { +func (s *IntegrationTestSuite) testByPassMinFeeWithdrawReward(endpoint string) { paidFeeAmt := math.LegacyMustNewDecFromStr(minGasPrice).Mul(math.LegacyNewDec(gas)).String() payee := s.chainA.validators[0].keyInfo.GetAddress() - // pass - s.T().Logf("bypass-msg with fee in the denom of global fee, pass") - s.execWithdrawAllRewards(s.chainA, 0, payee.String(), paidFeeAmt+uatomDenom, false) - // pass - s.T().Logf("bypass-msg with zero coin in the denom of global fee, pass") - s.execWithdrawAllRewards(s.chainA, 0, payee.String(), "0"+uatomDenom, false) - // pass - s.T().Logf("bypass-msg with zero coin not in the denom of global fee, pass") - s.execWithdrawAllRewards(s.chainA, 0, payee.String(), "0"+photonDenom, false) - // fail - s.T().Logf("bypass-msg with non-zero coin not in the denom of global fee, fail") - s.execWithdrawAllRewards(s.chainA, 0, payee.String(), paidFeeAmt+photonDenom, true) + + testCases := []struct { + name string + fee string + expErr bool + }{ + { + "bypass-msg with fee in the denom of global fee, pass", + paidFeeAmt + uatomDenom, + false, + }, + { + "bypass-msg with zero coin in the denom of global fee, pass", + "0" + uatomDenom, + false, + }, + { + "bypass-msg with zero coin not in the denom of global fee, pass", + "0" + photonDenom, + false, + }, + { + "bypass-msg with non-zero coin not in the denom of global fee, fail", + paidFeeAmt + photonDenom, + true, + }, + } + + for _, tc := range testCases { + + // get delegator rewards + rewards, err := queryDelegatorTotalRewards(endpoint, payee.String()) + s.Require().NoError(err) + + // get delegator stake balance + stakeBalance, err := getSpecificBalance(endpoint, payee.String(), stakeDenom) + s.Require().NoError(err) + fmt.Println(stakeBalance) + + // withdraw rewards + s.Run(tc.name, func() { + s.execWithdrawAllRewards(s.chainA, 0, payee.String(), tc.fee, tc.expErr) + }) + + // get updated balance + newStakeBalance, err := getSpecificBalance(endpoint, payee.String(), stakeDenom) + s.Require().NoError(err) + + // check that the update balance was increased by at least the amount of stake tokens in the reward + total := rewards.GetTotal().Add(sdk.NewDecCoinFromCoin(stakeBalance)).Sort() + fmt.Println("total", total.String()) + fmt.Println("rewards", rewards.String()) + s.Require().Equal(total[0].Denom, stakeDenom) + + fmt.Println(sdk.NewDecCoinFromCoin(newStakeBalance).String(), total[0].String()) + s.Require().True(sdk.NewDecCoinFromCoin(newStakeBalance).IsGTE(total[0])) + } } diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 83e35e83c0d..eed6b4c879d 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -50,6 +50,7 @@ const ( gaiaHomePath = "/home/nonroot/.gaia" photonDenom = "photon" uatomDenom = "uatom" + stakeDenom = "stake" initBalanceStr = "110000000000stake,100000000000000000photon,100000000000000000uatom" minGasPrice = "0.00001" // the test globalfee in genesis is the same as minGasPrice @@ -146,8 +147,8 @@ func (s *IntegrationTestSuite) SetupSuite() { s.initValidatorConfigs(s.chainB) s.runValidators(s.chainB, 10) - time.Sleep(10 * time.Second) - s.runIBCRelayer() + // time.Sleep(10 * time.Second) + // s.runIBCRelayer() } func (s *IntegrationTestSuite) TearDownSuite() { diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index f272d72434c..c0305c67b86 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -5,7 +5,7 @@ import ( ) var ( - runBankTest = true + runBankTest = false runBypassMinFeeTest = true runEncodeTest = true runEvidenceTest = true @@ -37,7 +37,8 @@ func (s *IntegrationTestSuite) TestByPassMinFee() { if !runBypassMinFeeTest { s.T().Skip() } - s.testByPassMinFeeWithdrawReward() + chainAPI := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) + s.testByPassMinFeeWithdrawReward(chainAPI) } func (s *IntegrationTestSuite) TestEncode() { diff --git a/tests/e2e/query.go b/tests/e2e/query.go index e2b7816814d..095929d36f7 100644 --- a/tests/e2e/query.go +++ b/tests/e2e/query.go @@ -116,6 +116,21 @@ func queryDelegatorWithdrawalAddress(endpoint string, delegatorAddr string) (dis return res, nil } +func queryDelegatorTotalRewards(endpoint, delegatorAddr string) (disttypes.QueryDelegationTotalRewardsResponse, error) { + var res disttypes.QueryDelegationTotalRewardsResponse + + body, err := httpGet(fmt.Sprintf("%s/cosmos/distribution/v1beta1/delegators/%s/rewards", endpoint, delegatorAddr)) + if err != nil { + return res, err + } + + if err = cdc.UnmarshalJSON(body, &res); err != nil { + return res, err + } + + return res, nil +} + func queryGovProposal(endpoint string, proposalID int) (govtypes.QueryProposalResponse, error) { var govProposalResp govtypes.QueryProposalResponse From e779b34ea4661d412835f5a6d846639ee45b7370 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Mon, 8 May 2023 16:13:12 +0200 Subject: [PATCH 42/47] bump link checker --- .github/workflows/linkchecker.yml | 2 +- tests/e2e/e2e_bypassminfee_test.go | 27 ++++++++++++--------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/.github/workflows/linkchecker.yml b/.github/workflows/linkchecker.yml index eccadbd5601..1cf8d28642d 100644 --- a/.github/workflows/linkchecker.yml +++ b/.github/workflows/linkchecker.yml @@ -5,6 +5,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3.5.2 - - uses: gaurav-nelson/github-action-markdown-link-check@1.0.13 + - uses: gaurav-nelson/github-action-markdown-link-check@1.0.15 with: folder-path: "docs" diff --git a/tests/e2e/e2e_bypassminfee_test.go b/tests/e2e/e2e_bypassminfee_test.go index 2151069ecad..80377a76262 100644 --- a/tests/e2e/e2e_bypassminfee_test.go +++ b/tests/e2e/e2e_bypassminfee_test.go @@ -1,8 +1,6 @@ package e2e import ( - "fmt" - "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -44,27 +42,26 @@ func (s *IntegrationTestSuite) testByPassMinFeeWithdrawReward(endpoint string) { rewards, err := queryDelegatorTotalRewards(endpoint, payee.String()) s.Require().NoError(err) - // get delegator stake balance - stakeBalance, err := getSpecificBalance(endpoint, payee.String(), stakeDenom) + // get current delegator stake balance + oldBalance, err := getSpecificBalance(endpoint, payee.String(), stakeDenom) s.Require().NoError(err) - fmt.Println(stakeBalance) // withdraw rewards s.Run(tc.name, func() { s.execWithdrawAllRewards(s.chainA, 0, payee.String(), tc.fee, tc.expErr) }) - // get updated balance - newStakeBalance, err := getSpecificBalance(endpoint, payee.String(), stakeDenom) - s.Require().NoError(err) + if !tc.expErr { + // get updated balance + balance, err := getSpecificBalance(endpoint, payee.String(), stakeDenom) + s.Require().NoError(err) - // check that the update balance was increased by at least the amount of stake tokens in the reward - total := rewards.GetTotal().Add(sdk.NewDecCoinFromCoin(stakeBalance)).Sort() - fmt.Println("total", total.String()) - fmt.Println("rewards", rewards.String()) - s.Require().Equal(total[0].Denom, stakeDenom) + // compute sum of old balance and rewards + oldBalancePlusRewards := rewards.GetTotal().Add(sdk.NewDecCoinFromCoin(oldBalance)) + s.Require().Equal(oldBalancePlusRewards[0].Denom, stakeDenom) - fmt.Println(sdk.NewDecCoinFromCoin(newStakeBalance).String(), total[0].String()) - s.Require().True(sdk.NewDecCoinFromCoin(newStakeBalance).IsGTE(total[0])) + // check that the updated balance is GTE than the sum of old balance and rewards + s.Require().True(sdk.NewDecCoinFromCoin(balance).IsGTE(oldBalancePlusRewards[0])) + } } } From 39c15ab9804e37e174631b7b817b95615bbcf542 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Mon, 8 May 2023 16:26:39 +0200 Subject: [PATCH 43/47] Revert "bump link checker" This reverts commit e779b34ea4661d412835f5a6d846639ee45b7370. --- .github/workflows/linkchecker.yml | 2 +- tests/e2e/e2e_bypassminfee_test.go | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/workflows/linkchecker.yml b/.github/workflows/linkchecker.yml index 1cf8d28642d..eccadbd5601 100644 --- a/.github/workflows/linkchecker.yml +++ b/.github/workflows/linkchecker.yml @@ -5,6 +5,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3.5.2 - - uses: gaurav-nelson/github-action-markdown-link-check@1.0.15 + - uses: gaurav-nelson/github-action-markdown-link-check@1.0.13 with: folder-path: "docs" diff --git a/tests/e2e/e2e_bypassminfee_test.go b/tests/e2e/e2e_bypassminfee_test.go index 80377a76262..2151069ecad 100644 --- a/tests/e2e/e2e_bypassminfee_test.go +++ b/tests/e2e/e2e_bypassminfee_test.go @@ -1,6 +1,8 @@ package e2e import ( + "fmt" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -42,26 +44,27 @@ func (s *IntegrationTestSuite) testByPassMinFeeWithdrawReward(endpoint string) { rewards, err := queryDelegatorTotalRewards(endpoint, payee.String()) s.Require().NoError(err) - // get current delegator stake balance - oldBalance, err := getSpecificBalance(endpoint, payee.String(), stakeDenom) + // get delegator stake balance + stakeBalance, err := getSpecificBalance(endpoint, payee.String(), stakeDenom) s.Require().NoError(err) + fmt.Println(stakeBalance) // withdraw rewards s.Run(tc.name, func() { s.execWithdrawAllRewards(s.chainA, 0, payee.String(), tc.fee, tc.expErr) }) - if !tc.expErr { - // get updated balance - balance, err := getSpecificBalance(endpoint, payee.String(), stakeDenom) - s.Require().NoError(err) + // get updated balance + newStakeBalance, err := getSpecificBalance(endpoint, payee.String(), stakeDenom) + s.Require().NoError(err) - // compute sum of old balance and rewards - oldBalancePlusRewards := rewards.GetTotal().Add(sdk.NewDecCoinFromCoin(oldBalance)) - s.Require().Equal(oldBalancePlusRewards[0].Denom, stakeDenom) + // check that the update balance was increased by at least the amount of stake tokens in the reward + total := rewards.GetTotal().Add(sdk.NewDecCoinFromCoin(stakeBalance)).Sort() + fmt.Println("total", total.String()) + fmt.Println("rewards", rewards.String()) + s.Require().Equal(total[0].Denom, stakeDenom) - // check that the updated balance is GTE than the sum of old balance and rewards - s.Require().True(sdk.NewDecCoinFromCoin(balance).IsGTE(oldBalancePlusRewards[0])) - } + fmt.Println(sdk.NewDecCoinFromCoin(newStakeBalance).String(), total[0].String()) + s.Require().True(sdk.NewDecCoinFromCoin(newStakeBalance).IsGTE(total[0])) } } From 98a7052a6734d7064301d122ecec729eaba06790 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Thu, 11 May 2023 18:40:06 +0200 Subject: [PATCH 44/47] Add condition to return zero GlobalFee parameters when Genutil InitGenesis call collect-gentx --- tests/e2e/e2e_exec_test.go | 1 + x/globalfee/ante/fee.go | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/e2e/e2e_exec_test.go b/tests/e2e/e2e_exec_test.go index bd86636bfc1..6b007ef7c0b 100644 --- a/tests/e2e/e2e_exec_test.go +++ b/tests/e2e/e2e_exec_test.go @@ -367,6 +367,7 @@ func (s *IntegrationTestSuite) runGovExec(c *chain, valIdx int, submitterAddr, g generalFlags := []string{ fmt.Sprintf("--%s=%s", flags.FlagFrom, submitterAddr), + fmt.Sprintf("--%s=%s", flags.FlagGas, "300000"), // default 200000 isn't enough fmt.Sprintf("--%s=%s", flags.FlagGasPrices, fees), fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id), "--keyring-backend=test", diff --git a/x/globalfee/ante/fee.go b/x/globalfee/ante/fee.go index c3daff98715..071cc0eee78 100644 --- a/x/globalfee/ante/fee.go +++ b/x/globalfee/ante/fee.go @@ -218,14 +218,12 @@ func (mfd FeeDecorator) DefaultZeroGlobalFee(ctx sdk.Context) ([]sdk.DecCoin, er return []sdk.DecCoin{sdk.NewDecCoinFromDec(bondDenom, sdk.NewDec(0))}, nil } -func (mfd FeeDecorator) getBondDenom(ctx sdk.Context) string { - var bondDenom string - +func (mfd FeeDecorator) getBondDenom(ctx sdk.Context) (bondDenom string) { if mfd.StakingSubspace.Has(ctx, stakingtypes.KeyBondDenom) { mfd.StakingSubspace.Get(ctx, stakingtypes.KeyBondDenom, &bondDenom) } - return bondDenom + return } func (mfd FeeDecorator) ContainsOnlyBypassMinFeeMsgs(ctx sdk.Context, msgs []sdk.Msg) bool { @@ -241,12 +239,17 @@ func (mfd FeeDecorator) ContainsOnlyBypassMinFeeMsgs(ctx sdk.Context, msgs []sdk } func (mfd FeeDecorator) GetBypassMsgTypes(ctx sdk.Context) (res []string) { - mfd.GlobalMinFee.Get(ctx, types.ParamStoreKeyBypassMinFeeMsgTypes, &res) + if mfd.GlobalMinFee.Has(ctx, types.ParamStoreKeyBypassMinFeeMsgTypes) { + mfd.GlobalMinFee.Get(ctx, types.ParamStoreKeyBypassMinFeeMsgTypes, &res) + } return } func (mfd FeeDecorator) GetMaxTotalBypassMinFeeMsgGasUsage(ctx sdk.Context) (res uint64) { - mfd.GlobalMinFee.Get(ctx, types.ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage, &res) + if mfd.GlobalMinFee.Has(ctx, types.ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage) { + mfd.GlobalMinFee.Get(ctx, types.ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage, &res) + } + return } From 922615f5f67908956fbee1c5bb04714f41317d00 Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Fri, 12 May 2023 13:21:42 +0200 Subject: [PATCH 45/47] fix: panics --- app/modules.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/modules.go b/app/modules.go index a8d24548aaa..e6531d61582 100644 --- a/app/modules.go +++ b/app/modules.go @@ -272,6 +272,11 @@ func orderInitBlockers() []string { slashingtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName, + // globalfee module need to be inited before genutil + // when calling DeliverGenTxs, deliverTx is called + // globalfee module does checks in deliverTx so that + // it has to be inited earlier than genutil so that the params are set + globalfee.ModuleName, genutiltypes.ModuleName, ibctransfertypes.ModuleName, ibchost.ModuleName, @@ -284,7 +289,6 @@ func orderInitBlockers() []string { paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, - globalfee.ModuleName, providertypes.ModuleName, } } From 78964da74c3ac39740f5b72018f0aa448f8127e5 Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Fri, 12 May 2023 14:03:37 +0200 Subject: [PATCH 46/47] fix: revert back --- app/modules.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/app/modules.go b/app/modules.go index e6531d61582..977e3e2652f 100644 --- a/app/modules.go +++ b/app/modules.go @@ -109,9 +109,9 @@ var ModuleBasics = module.NewBasicManager( ) func appModules( - app *GaiaApp, - encodingConfig gaiaappparams.EncodingConfig, - skipGenesisInvariants bool, + app *GaiaApp, + encodingConfig gaiaappparams.EncodingConfig, + skipGenesisInvariants bool, ) []module.AppModule { appCodec := encodingConfig.Codec @@ -150,9 +150,9 @@ func appModules( // simulationModules returns modules for simulation manager // define the order of the modules for deterministic simulations func simulationModules( - app *GaiaApp, - encodingConfig gaiaappparams.EncodingConfig, - _ bool, + app *GaiaApp, + encodingConfig gaiaappparams.EncodingConfig, + _ bool, ) []module.AppModuleSimulation { appCodec := encodingConfig.Codec @@ -272,11 +272,6 @@ func orderInitBlockers() []string { slashingtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName, - // globalfee module need to be inited before genutil - // when calling DeliverGenTxs, deliverTx is called - // globalfee module does checks in deliverTx so that - // it has to be inited earlier than genutil so that the params are set - globalfee.ModuleName, genutiltypes.ModuleName, ibctransfertypes.ModuleName, ibchost.ModuleName, @@ -289,6 +284,7 @@ func orderInitBlockers() []string { paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, + globalfee.ModuleName, providertypes.ModuleName, } } From 83f72958736a63af32ae42728645af71cc7317dc Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Fri, 12 May 2023 14:31:13 +0200 Subject: [PATCH 47/47] fix: lint --- app/modules.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/modules.go b/app/modules.go index 977e3e2652f..a8d24548aaa 100644 --- a/app/modules.go +++ b/app/modules.go @@ -109,9 +109,9 @@ var ModuleBasics = module.NewBasicManager( ) func appModules( - app *GaiaApp, - encodingConfig gaiaappparams.EncodingConfig, - skipGenesisInvariants bool, + app *GaiaApp, + encodingConfig gaiaappparams.EncodingConfig, + skipGenesisInvariants bool, ) []module.AppModule { appCodec := encodingConfig.Codec @@ -150,9 +150,9 @@ func appModules( // simulationModules returns modules for simulation manager // define the order of the modules for deterministic simulations func simulationModules( - app *GaiaApp, - encodingConfig gaiaappparams.EncodingConfig, - _ bool, + app *GaiaApp, + encodingConfig gaiaappparams.EncodingConfig, + _ bool, ) []module.AppModuleSimulation { appCodec := encodingConfig.Codec