From d4f51a2582f810fc92a50bbe8cc2ce6f1fdb2118 Mon Sep 17 00:00:00 2001 From: HuangYi Date: Fri, 18 Mar 2022 16:21:54 +0800 Subject: [PATCH 01/22] Refactor tx middleware to support pluggable feemarket module Closes: #11415 --- .../feegrant/v1beta1/feegrant.pulsar.go | 4 +- api/cosmos/feegrant/v1beta1/tx.pulsar.go | 2 +- api/cosmos/tx/v1beta1/tx.pulsar.go | 365 +++++++++++++----- proto/cosmos/tx/v1beta1/tx.proto | 5 + simapp/app.go | 1 + types/errors/errors.go | 3 + types/tx/tx.pb.go | 197 ++++++---- types/tx/types.go | 4 + x/auth/middleware/auth_ext.go | 75 ++++ x/auth/middleware/branch_store_test.go | 2 +- x/auth/middleware/fee.go | 122 ++---- x/auth/middleware/fee_test.go | 25 +- x/auth/middleware/feegrant_test.go | 1 + x/auth/middleware/middleware.go | 7 +- x/auth/middleware/middleware_test.go | 1 + x/auth/middleware/priority.go | 63 --- x/auth/middleware/priority_test.go | 38 -- x/auth/middleware/static_feemarket.go | 65 ++++ x/auth/middleware/testutil_test.go | 1 + 19 files changed, 618 insertions(+), 363 deletions(-) create mode 100644 x/auth/middleware/auth_ext.go delete mode 100644 x/auth/middleware/priority.go delete mode 100644 x/auth/middleware/priority_test.go create mode 100644 x/auth/middleware/static_feemarket.go diff --git a/api/cosmos/feegrant/v1beta1/feegrant.pulsar.go b/api/cosmos/feegrant/v1beta1/feegrant.pulsar.go index 0cc50a4b469e..4136d147cf2f 100644 --- a/api/cosmos/feegrant/v1beta1/feegrant.pulsar.go +++ b/api/cosmos/feegrant/v1beta1/feegrant.pulsar.go @@ -2730,7 +2730,7 @@ type AllowedMsgAllowance struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // allowance can be any of basic and filtered fee allowance. + // allowance can be any of basic and periodic fee allowance. Allowance *anypb.Any `protobuf:"bytes,1,opt,name=allowance,proto3" json:"allowance,omitempty"` // allowed_messages are the messages for which the grantee has the access. AllowedMessages []string `protobuf:"bytes,2,rep,name=allowed_messages,json=allowedMessages,proto3" json:"allowed_messages,omitempty"` @@ -2780,7 +2780,7 @@ type Grant struct { Granter string `protobuf:"bytes,1,opt,name=granter,proto3" json:"granter,omitempty"` // grantee is the address of the user being granted an allowance of another user's funds. Grantee string `protobuf:"bytes,2,opt,name=grantee,proto3" json:"grantee,omitempty"` - // allowance can be any of basic and filtered fee allowance. + // allowance can be any of basic, periodic, allowed fee allowance. Allowance *anypb.Any `protobuf:"bytes,3,opt,name=allowance,proto3" json:"allowance,omitempty"` } diff --git a/api/cosmos/feegrant/v1beta1/tx.pulsar.go b/api/cosmos/feegrant/v1beta1/tx.pulsar.go index 473fef545b6b..723d4319fb73 100644 --- a/api/cosmos/feegrant/v1beta1/tx.pulsar.go +++ b/api/cosmos/feegrant/v1beta1/tx.pulsar.go @@ -1800,7 +1800,7 @@ type MsgGrantAllowance struct { Granter string `protobuf:"bytes,1,opt,name=granter,proto3" json:"granter,omitempty"` // grantee is the address of the user being granted an allowance of another user's funds. Grantee string `protobuf:"bytes,2,opt,name=grantee,proto3" json:"grantee,omitempty"` - // allowance can be any of basic and filtered fee allowance. + // allowance can be any of basic, periodic, allowed fee allowance. Allowance *anypb.Any `protobuf:"bytes,3,opt,name=allowance,proto3" json:"allowance,omitempty"` } diff --git a/api/cosmos/tx/v1beta1/tx.pulsar.go b/api/cosmos/tx/v1beta1/tx.pulsar.go index d39c5e6efe46..7db7fdcf480a 100644 --- a/api/cosmos/tx/v1beta1/tx.pulsar.go +++ b/api/cosmos/tx/v1beta1/tx.pulsar.go @@ -3545,11 +3545,63 @@ func (x *_AuthInfo_1_list) IsValid() bool { return x.list != nil } +var _ protoreflect.List = (*_AuthInfo_1023_list)(nil) + +type _AuthInfo_1023_list struct { + list *[]*anypb.Any +} + +func (x *_AuthInfo_1023_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_AuthInfo_1023_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_AuthInfo_1023_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*anypb.Any) + (*x.list)[i] = concreteValue +} + +func (x *_AuthInfo_1023_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*anypb.Any) + *x.list = append(*x.list, concreteValue) +} + +func (x *_AuthInfo_1023_list) AppendMutable() protoreflect.Value { + v := new(anypb.Any) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_AuthInfo_1023_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_AuthInfo_1023_list) NewElement() protoreflect.Value { + v := new(anypb.Any) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_AuthInfo_1023_list) IsValid() bool { + return x.list != nil +} + var ( - md_AuthInfo protoreflect.MessageDescriptor - fd_AuthInfo_signer_infos protoreflect.FieldDescriptor - fd_AuthInfo_fee protoreflect.FieldDescriptor - fd_AuthInfo_tip protoreflect.FieldDescriptor + md_AuthInfo protoreflect.MessageDescriptor + fd_AuthInfo_signer_infos protoreflect.FieldDescriptor + fd_AuthInfo_fee protoreflect.FieldDescriptor + fd_AuthInfo_tip protoreflect.FieldDescriptor + fd_AuthInfo_extension_options protoreflect.FieldDescriptor ) func init() { @@ -3558,6 +3610,7 @@ func init() { fd_AuthInfo_signer_infos = md_AuthInfo.Fields().ByName("signer_infos") fd_AuthInfo_fee = md_AuthInfo.Fields().ByName("fee") fd_AuthInfo_tip = md_AuthInfo.Fields().ByName("tip") + fd_AuthInfo_extension_options = md_AuthInfo.Fields().ByName("extension_options") } var _ protoreflect.Message = (*fastReflection_AuthInfo)(nil) @@ -3643,6 +3696,12 @@ func (x *fastReflection_AuthInfo) Range(f func(protoreflect.FieldDescriptor, pro return } } + if len(x.ExtensionOptions) != 0 { + value := protoreflect.ValueOfList(&_AuthInfo_1023_list{list: &x.ExtensionOptions}) + if !f(fd_AuthInfo_extension_options, value) { + return + } + } } // Has reports whether a field is populated. @@ -3664,6 +3723,8 @@ func (x *fastReflection_AuthInfo) Has(fd protoreflect.FieldDescriptor) bool { return x.Fee != nil case "cosmos.tx.v1beta1.AuthInfo.tip": return x.Tip != nil + case "cosmos.tx.v1beta1.AuthInfo.extension_options": + return len(x.ExtensionOptions) != 0 default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.tx.v1beta1.AuthInfo")) @@ -3686,6 +3747,8 @@ func (x *fastReflection_AuthInfo) Clear(fd protoreflect.FieldDescriptor) { x.Fee = nil case "cosmos.tx.v1beta1.AuthInfo.tip": x.Tip = nil + case "cosmos.tx.v1beta1.AuthInfo.extension_options": + x.ExtensionOptions = nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.tx.v1beta1.AuthInfo")) @@ -3714,6 +3777,12 @@ func (x *fastReflection_AuthInfo) Get(descriptor protoreflect.FieldDescriptor) p case "cosmos.tx.v1beta1.AuthInfo.tip": value := x.Tip return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "cosmos.tx.v1beta1.AuthInfo.extension_options": + if len(x.ExtensionOptions) == 0 { + return protoreflect.ValueOfList(&_AuthInfo_1023_list{}) + } + listValue := &_AuthInfo_1023_list{list: &x.ExtensionOptions} + return protoreflect.ValueOfList(listValue) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.tx.v1beta1.AuthInfo")) @@ -3742,6 +3811,10 @@ func (x *fastReflection_AuthInfo) Set(fd protoreflect.FieldDescriptor, value pro x.Fee = value.Message().Interface().(*Fee) case "cosmos.tx.v1beta1.AuthInfo.tip": x.Tip = value.Message().Interface().(*Tip) + case "cosmos.tx.v1beta1.AuthInfo.extension_options": + lv := value.List() + clv := lv.(*_AuthInfo_1023_list) + x.ExtensionOptions = *clv.list default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.tx.v1beta1.AuthInfo")) @@ -3778,6 +3851,12 @@ func (x *fastReflection_AuthInfo) Mutable(fd protoreflect.FieldDescriptor) proto x.Tip = new(Tip) } return protoreflect.ValueOfMessage(x.Tip.ProtoReflect()) + case "cosmos.tx.v1beta1.AuthInfo.extension_options": + if x.ExtensionOptions == nil { + x.ExtensionOptions = []*anypb.Any{} + } + value := &_AuthInfo_1023_list{list: &x.ExtensionOptions} + return protoreflect.ValueOfList(value) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.tx.v1beta1.AuthInfo")) @@ -3800,6 +3879,9 @@ func (x *fastReflection_AuthInfo) NewField(fd protoreflect.FieldDescriptor) prot case "cosmos.tx.v1beta1.AuthInfo.tip": m := new(Tip) return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "cosmos.tx.v1beta1.AuthInfo.extension_options": + list := []*anypb.Any{} + return protoreflect.ValueOfList(&_AuthInfo_1023_list{list: &list}) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.tx.v1beta1.AuthInfo")) @@ -3883,6 +3965,12 @@ func (x *fastReflection_AuthInfo) ProtoMethods() *protoiface.Methods { l = options.Size(x.Tip) n += 1 + l + runtime.Sov(uint64(l)) } + if len(x.ExtensionOptions) > 0 { + for _, e := range x.ExtensionOptions { + l = options.Size(e) + n += 2 + l + runtime.Sov(uint64(l)) + } + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -3912,6 +4000,24 @@ func (x *fastReflection_AuthInfo) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if len(x.ExtensionOptions) > 0 { + for iNdEx := len(x.ExtensionOptions) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.ExtensionOptions[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x3f + i-- + dAtA[i] = 0xfa + } + } if x.Tip != nil { encoded, err := options.Marshal(x.Tip) if err != nil { @@ -4111,6 +4217,40 @@ func (x *fastReflection_AuthInfo) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } iNdEx = postIndex + case 1023: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ExtensionOptions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.ExtensionOptions = append(x.ExtensionOptions, &anypb.Any{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.ExtensionOptions[len(x.ExtensionOptions)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -8502,6 +8642,10 @@ type AuthInfo struct { // // Since: cosmos-sdk 0.46 Tip *Tip `protobuf:"bytes,3,opt,name=tip,proto3" json:"tip,omitempty"` + // extension_options are arbitrary options that can be added by chains + // when the default options are not sufficient. If any of these are present + // and can't be handled, the transaction will be rejected + ExtensionOptions []*anypb.Any `protobuf:"bytes,1023,rep,name=extension_options,json=extensionOptions,proto3" json:"extension_options,omitempty"` } func (x *AuthInfo) Reset() { @@ -8545,6 +8689,13 @@ func (x *AuthInfo) GetTip() *Tip { return nil } +func (x *AuthInfo) GetExtensionOptions() []*anypb.Any { + if x != nil { + return x.ExtensionOptions + } + return nil +} + // SignerInfo describes the public key and signing mode of a single top-level // signer. type SignerInfo struct { @@ -9034,7 +9185,7 @@ var file_cosmos_tx_v1beta1_tx_proto_rawDesc = []byte{ 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x1b, 0x6e, 0x6f, 0x6e, 0x43, 0x72, 0x69, 0x74, 0x69, 0x63, 0x61, 0x6c, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x22, 0xa0, 0x01, 0x0a, 0x08, 0x41, 0x75, 0x74, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x40, + 0x73, 0x22, 0xe4, 0x01, 0x0a, 0x08, 0x41, 0x75, 0x74, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x40, 0x0a, 0x0c, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x49, @@ -9044,89 +9195,94 @@ var file_cosmos_tx_v1beta1_tx_proto_rawDesc = []byte{ 0x31, 0x2e, 0x46, 0x65, 0x65, 0x52, 0x03, 0x66, 0x65, 0x65, 0x12, 0x28, 0x0a, 0x03, 0x74, 0x69, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x54, 0x69, 0x70, 0x52, - 0x03, 0x74, 0x69, 0x70, 0x22, 0x97, 0x01, 0x0a, 0x0a, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x49, - 0x6e, 0x66, 0x6f, 0x12, 0x33, 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, - 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x09, 0x70, - 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x38, 0x0a, 0x09, 0x6d, 0x6f, 0x64, 0x65, - 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, - 0x4d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x6d, 0x6f, 0x64, 0x65, 0x49, 0x6e, - 0x66, 0x6f, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x22, 0xe0, - 0x02, 0x0a, 0x08, 0x4d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x3c, 0x0a, 0x06, 0x73, - 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, - 0x4d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x48, - 0x00, 0x52, 0x06, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x12, 0x39, 0x0a, 0x05, 0x6d, 0x75, 0x6c, - 0x74, 0x69, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x6f, 0x64, - 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x48, 0x00, 0x52, 0x05, 0x6d, - 0x75, 0x6c, 0x74, 0x69, 0x1a, 0x41, 0x0a, 0x06, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x12, 0x37, - 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, - 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x4d, 0x6f, 0x64, - 0x65, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x1a, 0x90, 0x01, 0x0a, 0x05, 0x4d, 0x75, 0x6c, 0x74, - 0x69, 0x12, 0x4b, 0x0a, 0x08, 0x62, 0x69, 0x74, 0x61, 0x72, 0x72, 0x61, 0x79, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x72, 0x79, - 0x70, 0x74, 0x6f, 0x2e, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x73, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x62, - 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x63, 0x74, 0x42, 0x69, 0x74, 0x41, - 0x72, 0x72, 0x61, 0x79, 0x52, 0x08, 0x62, 0x69, 0x74, 0x61, 0x72, 0x72, 0x61, 0x79, 0x12, 0x3a, - 0x0a, 0x0a, 0x6d, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x73, 0x18, 0x02, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, - 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, - 0x09, 0x6d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x42, 0x05, 0x0a, 0x03, 0x73, 0x75, - 0x6d, 0x22, 0xeb, 0x01, 0x0a, 0x03, 0x46, 0x65, 0x65, 0x12, 0x63, 0x0a, 0x06, 0x61, 0x6d, 0x6f, - 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, - 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x30, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, - 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1b, - 0x0a, 0x09, 0x67, 0x61, 0x73, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x04, 0x52, 0x08, 0x67, 0x61, 0x73, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x2e, 0x0a, 0x05, 0x70, - 0x61, 0x79, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, - 0x72, 0x69, 0x6e, 0x67, 0x52, 0x05, 0x70, 0x61, 0x79, 0x65, 0x72, 0x12, 0x32, 0x0a, 0x07, 0x67, - 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, - 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, - 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72, 0x22, - 0x9c, 0x01, 0x0a, 0x03, 0x54, 0x69, 0x70, 0x12, 0x63, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, - 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, - 0x69, 0x6e, 0x42, 0x30, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, - 0x6f, 0x69, 0x6e, 0x73, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x30, 0x0a, 0x06, - 0x74, 0x69, 0x70, 0x70, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, - 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, - 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x06, 0x74, 0x69, 0x70, 0x70, 0x65, 0x72, 0x22, 0xce, - 0x01, 0x0a, 0x0d, 0x41, 0x75, 0x78, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, - 0x12, 0x32, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, - 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x61, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x12, 0x3e, 0x0a, 0x08, 0x73, 0x69, 0x67, 0x6e, 0x5f, 0x64, 0x6f, 0x63, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, - 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x44, - 0x6f, 0x63, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x41, 0x75, 0x78, 0x52, 0x07, 0x73, 0x69, 0x67, - 0x6e, 0x44, 0x6f, 0x63, 0x12, 0x37, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x73, - 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, - 0x69, 0x67, 0x6e, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, - 0x03, 0x73, 0x69, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x73, 0x69, 0x67, 0x42, - 0xc4, 0x01, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, - 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, - 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x74, 0x78, - 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x74, 0x78, 0x76, 0x31, 0x62, 0x65, 0x74, - 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x54, 0x58, 0xaa, 0x02, 0x11, 0x43, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x54, 0x78, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x11, 0x43, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x54, 0x78, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0xe2, 0x02, 0x1d, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x54, 0x78, 0x5c, 0x56, 0x31, 0x62, - 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0xea, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x54, 0x78, 0x3a, 0x3a, 0x56, - 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x03, 0x74, 0x69, 0x70, 0x12, 0x42, 0x0a, 0x11, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, + 0x6e, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xff, 0x07, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x10, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, + 0x6e, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x97, 0x01, 0x0a, 0x0a, 0x53, 0x69, 0x67, + 0x6e, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x33, 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, + 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, + 0x79, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x38, 0x0a, 0x09, + 0x6d, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1b, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, + 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x6d, 0x6f, + 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, + 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, + 0x63, 0x65, 0x22, 0xe0, 0x02, 0x0a, 0x08, 0x4d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, + 0x3c, 0x0a, 0x06, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x22, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, + 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x53, 0x69, 0x6e, + 0x67, 0x6c, 0x65, 0x48, 0x00, 0x52, 0x06, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x12, 0x39, 0x0a, + 0x05, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0x2e, 0x4d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x48, + 0x00, 0x52, 0x05, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x1a, 0x41, 0x0a, 0x06, 0x53, 0x69, 0x6e, 0x67, + 0x6c, 0x65, 0x12, 0x37, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x23, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x73, 0x69, 0x67, + 0x6e, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, 0x69, 0x67, + 0x6e, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x1a, 0x90, 0x01, 0x0a, 0x05, + 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x12, 0x4b, 0x0a, 0x08, 0x62, 0x69, 0x74, 0x61, 0x72, 0x72, 0x61, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2e, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x73, 0x69, 0x67, + 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x63, 0x74, + 0x42, 0x69, 0x74, 0x41, 0x72, 0x72, 0x61, 0x79, 0x52, 0x08, 0x62, 0x69, 0x74, 0x61, 0x72, 0x72, + 0x61, 0x79, 0x12, 0x3a, 0x0a, 0x0a, 0x6d, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x73, + 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x6f, 0x64, 0x65, 0x49, + 0x6e, 0x66, 0x6f, 0x52, 0x09, 0x6d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x42, 0x05, + 0x0a, 0x03, 0x73, 0x75, 0x6d, 0x22, 0xeb, 0x01, 0x0a, 0x03, 0x46, 0x65, 0x65, 0x12, 0x63, 0x0a, + 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, + 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x30, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, + 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, + 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, + 0x6e, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x67, 0x61, 0x73, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x67, 0x61, 0x73, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, + 0x2e, 0x0a, 0x05, 0x70, 0x61, 0x79, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, + 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x05, 0x70, 0x61, 0x79, 0x65, 0x72, 0x12, + 0x32, 0x0a, 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, + 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x67, 0x72, 0x61, 0x6e, + 0x74, 0x65, 0x72, 0x22, 0x9c, 0x01, 0x0a, 0x03, 0x54, 0x69, 0x70, 0x12, 0x63, 0x0a, 0x06, 0x61, + 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x30, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, + 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, + 0x12, 0x30, 0x0a, 0x06, 0x74, 0x69, 0x70, 0x70, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, + 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x06, 0x74, 0x69, 0x70, 0x70, + 0x65, 0x72, 0x22, 0xce, 0x01, 0x0a, 0x0d, 0x41, 0x75, 0x78, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, + 0x44, 0x61, 0x74, 0x61, 0x12, 0x32, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, + 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x3e, 0x0a, 0x08, 0x73, 0x69, 0x67, 0x6e, + 0x5f, 0x64, 0x6f, 0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, + 0x69, 0x67, 0x6e, 0x44, 0x6f, 0x63, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x41, 0x75, 0x78, 0x52, + 0x07, 0x73, 0x69, 0x67, 0x6e, 0x44, 0x6f, 0x63, 0x12, 0x37, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x74, 0x78, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6d, 0x6f, 0x64, + 0x65, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x69, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, + 0x73, 0x69, 0x67, 0x42, 0xc4, 0x01, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x07, 0x54, + 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2f, 0x74, 0x78, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x74, 0x78, 0x76, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x54, 0x58, 0xaa, 0x02, 0x11, 0x43, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x54, 0x78, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0xca, 0x02, 0x11, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x54, 0x78, 0x5c, 0x56, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x1d, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x54, 0x78, + 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x54, + 0x78, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -9172,22 +9328,23 @@ var file_cosmos_tx_v1beta1_tx_proto_depIdxs = []int32{ 6, // 7: cosmos.tx.v1beta1.AuthInfo.signer_infos:type_name -> cosmos.tx.v1beta1.SignerInfo 8, // 8: cosmos.tx.v1beta1.AuthInfo.fee:type_name -> cosmos.tx.v1beta1.Fee 9, // 9: cosmos.tx.v1beta1.AuthInfo.tip:type_name -> cosmos.tx.v1beta1.Tip - 13, // 10: cosmos.tx.v1beta1.SignerInfo.public_key:type_name -> google.protobuf.Any - 7, // 11: cosmos.tx.v1beta1.SignerInfo.mode_info:type_name -> cosmos.tx.v1beta1.ModeInfo - 11, // 12: cosmos.tx.v1beta1.ModeInfo.single:type_name -> cosmos.tx.v1beta1.ModeInfo.Single - 12, // 13: cosmos.tx.v1beta1.ModeInfo.multi:type_name -> cosmos.tx.v1beta1.ModeInfo.Multi - 14, // 14: cosmos.tx.v1beta1.Fee.amount:type_name -> cosmos.base.v1beta1.Coin - 14, // 15: cosmos.tx.v1beta1.Tip.amount:type_name -> cosmos.base.v1beta1.Coin - 3, // 16: cosmos.tx.v1beta1.AuxSignerData.sign_doc:type_name -> cosmos.tx.v1beta1.SignDocDirectAux - 15, // 17: cosmos.tx.v1beta1.AuxSignerData.mode:type_name -> cosmos.tx.signing.v1beta1.SignMode - 15, // 18: cosmos.tx.v1beta1.ModeInfo.Single.mode:type_name -> cosmos.tx.signing.v1beta1.SignMode - 16, // 19: cosmos.tx.v1beta1.ModeInfo.Multi.bitarray:type_name -> cosmos.crypto.multisig.v1beta1.CompactBitArray - 7, // 20: cosmos.tx.v1beta1.ModeInfo.Multi.mode_infos:type_name -> cosmos.tx.v1beta1.ModeInfo - 21, // [21:21] is the sub-list for method output_type - 21, // [21:21] is the sub-list for method input_type - 21, // [21:21] is the sub-list for extension type_name - 21, // [21:21] is the sub-list for extension extendee - 0, // [0:21] is the sub-list for field type_name + 13, // 10: cosmos.tx.v1beta1.AuthInfo.extension_options:type_name -> google.protobuf.Any + 13, // 11: cosmos.tx.v1beta1.SignerInfo.public_key:type_name -> google.protobuf.Any + 7, // 12: cosmos.tx.v1beta1.SignerInfo.mode_info:type_name -> cosmos.tx.v1beta1.ModeInfo + 11, // 13: cosmos.tx.v1beta1.ModeInfo.single:type_name -> cosmos.tx.v1beta1.ModeInfo.Single + 12, // 14: cosmos.tx.v1beta1.ModeInfo.multi:type_name -> cosmos.tx.v1beta1.ModeInfo.Multi + 14, // 15: cosmos.tx.v1beta1.Fee.amount:type_name -> cosmos.base.v1beta1.Coin + 14, // 16: cosmos.tx.v1beta1.Tip.amount:type_name -> cosmos.base.v1beta1.Coin + 3, // 17: cosmos.tx.v1beta1.AuxSignerData.sign_doc:type_name -> cosmos.tx.v1beta1.SignDocDirectAux + 15, // 18: cosmos.tx.v1beta1.AuxSignerData.mode:type_name -> cosmos.tx.signing.v1beta1.SignMode + 15, // 19: cosmos.tx.v1beta1.ModeInfo.Single.mode:type_name -> cosmos.tx.signing.v1beta1.SignMode + 16, // 20: cosmos.tx.v1beta1.ModeInfo.Multi.bitarray:type_name -> cosmos.crypto.multisig.v1beta1.CompactBitArray + 7, // 21: cosmos.tx.v1beta1.ModeInfo.Multi.mode_infos:type_name -> cosmos.tx.v1beta1.ModeInfo + 22, // [22:22] is the sub-list for method output_type + 22, // [22:22] is the sub-list for method input_type + 22, // [22:22] is the sub-list for extension type_name + 22, // [22:22] is the sub-list for extension extendee + 0, // [0:22] is the sub-list for field type_name } func init() { file_cosmos_tx_v1beta1_tx_proto_init() } diff --git a/proto/cosmos/tx/v1beta1/tx.proto b/proto/cosmos/tx/v1beta1/tx.proto index ac7b690f4661..9c04fb764aec 100644 --- a/proto/cosmos/tx/v1beta1/tx.proto +++ b/proto/cosmos/tx/v1beta1/tx.proto @@ -142,6 +142,11 @@ message AuthInfo { // // Since: cosmos-sdk 0.46 Tip tip = 3; + + // extension_options are arbitrary options that can be added by chains + // when the default options are not sufficient. If any of these are present + // and can't be handled, the transaction will be rejected + repeated google.protobuf.Any extension_options = 1023; } // SignerInfo describes the public key and signing mode of a single top-level diff --git a/simapp/app.go b/simapp/app.go index 8e9b94075df8..958d66ec474e 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -471,6 +471,7 @@ func (app *SimApp) setTxHandler(txConfig client.TxConfig, indexEventsStr []strin SignModeHandler: txConfig.SignModeHandler(), SigGasConsumer: authmiddleware.DefaultSigVerificationGasConsumer, TxDecoder: txConfig.TxDecoder(), + FeeMarket: authmiddleware.StaticFeeMarket{}, }) if err != nil { panic(err) diff --git a/types/errors/errors.go b/types/errors/errors.go index aa6bffe0616d..f2287cbae53e 100644 --- a/types/errors/errors.go +++ b/types/errors/errors.go @@ -162,6 +162,9 @@ var ( // ErrAppConfig defines an error occurred if min-gas-prices field in BaseConfig is empty. ErrAppConfig = Register(RootCodespace, 40, "error in app.toml") + // ErrUnknownAuthExtensionOptions defines an error for unknown auth_info extension options. + ErrUnknownAuthExtensionOptions = Register(RootCodespace, 41, "unknown auth_info extension options") + // ErrPanic is only set when we recover from a panic, so we know to // redact potentially sensitive system info ErrPanic = errorsmod.ErrPanic diff --git a/types/tx/tx.pb.go b/types/tx/tx.pb.go index d16c7898116b..5203dcfd6481 100644 --- a/types/tx/tx.pb.go +++ b/types/tx/tx.pb.go @@ -455,6 +455,10 @@ type AuthInfo struct { // // Since: cosmos-sdk 0.46 Tip *Tip `protobuf:"bytes,3,opt,name=tip,proto3" json:"tip,omitempty"` + // extension_options are arbitrary options that can be added by chains + // when the default options are not sufficient. If any of these are present + // and can't be handled, the transaction will be rejected + ExtensionOptions []*types.Any `protobuf:"bytes,1023,rep,name=extension_options,json=extensionOptions,proto3" json:"extension_options,omitempty"` } func (m *AuthInfo) Reset() { *m = AuthInfo{} } @@ -511,6 +515,13 @@ func (m *AuthInfo) GetTip() *Tip { return nil } +func (m *AuthInfo) GetExtensionOptions() []*types.Any { + if m != nil { + return m.ExtensionOptions + } + return nil +} + // SignerInfo describes the public key and signing mode of a single top-level // signer. type SignerInfo struct { @@ -1012,71 +1023,71 @@ func init() { func init() { proto.RegisterFile("cosmos/tx/v1beta1/tx.proto", fileDescriptor_96d1575ffde80842) } var fileDescriptor_96d1575ffde80842 = []byte{ - // 1015 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0xcf, 0x6f, 0x1b, 0x45, - 0x14, 0xf6, 0x66, 0x6d, 0xc7, 0x7e, 0x4d, 0xda, 0x74, 0x14, 0x21, 0xc7, 0x51, 0xdd, 0xe0, 0xaa, - 0xe0,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0xab, 0xd2, 0x3e, 0xa2, 0x85, 0xcb, 0xdd, 0x7f, 0xe9, 0x72, 0xb4, 0x01, 0xae, 0x64, 0x91, 0xa9, - 0xc6, 0x1a, 0xd6, 0xc3, 0xc1, 0x87, 0x4f, 0x4f, 0x3b, 0xce, 0xb3, 0xd3, 0x8e, 0xf3, 0xfc, 0xb4, - 0xe3, 0x3c, 0x39, 0xeb, 0x54, 0x9e, 0x9d, 0x75, 0x2a, 0xbf, 0x9c, 0x75, 0x2a, 0x8f, 0x6e, 0x2e, - 0xbf, 0x4e, 0x5f, 0x4d, 0x87, 0x75, 0xd3, 0x70, 0x6e, 0xff, 0x15, 0x00, 0x00, 0xff, 0xff, 0x4d, - 0x26, 0x62, 0x70, 0xd8, 0x09, 0x00, 0x00, + // 1019 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0x4d, 0x6f, 0x1b, 0x45, + 0x18, 0xf6, 0x66, 0x6d, 0xc7, 0x7e, 0x9b, 0xf4, 0x63, 0x54, 0x21, 0xc7, 0x51, 0xdd, 0xb0, 0x55, + 0xc1, 0x97, 0xec, 0xa6, 0xe9, 0x81, 0x82, 0x10, 0x60, 0x37, 0x54, 0xa9, 0x4a, 0x41, 0x9a, 0xe4, + 0xd4, 0xcb, 0x6a, 0xbc, 0x9e, 0xac, 0x47, 0xf5, 0xce, 0x2c, 0x3b, 0xb3, 0x60, 0xff, 0x08, 0xa4, + 0x0a, 0x09, 0x71, 0xe1, 0x17, 0x70, 0xe6, 0x47, 0xf4, 0x84, 0x2a, 0x4e, 0x9c, 0xa0, 0x4a, 0xb8, + 0x21, 0xf1, 0x17, 0x40, 0x33, 0x3b, 0xbb, 0x49, 0x4b, 0x6a, 0x83, 0xa8, 0x38, 0xed, 0x7c, 0x3c, + 0xef, 0x33, 0xcf, 0xbc, 0xf3, 0xec, 0xfb, 0x42, 0x37, 0x12, 0x32, 0x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a0, 0x1c, 0x0a, 0x00, 0x00, } func (m *Tx) Marshal() (dAtA []byte, err error) { @@ -1402,6 +1413,22 @@ func (m *AuthInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.ExtensionOptions) > 0 { + for iNdEx := len(m.ExtensionOptions) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ExtensionOptions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3f + i-- + dAtA[i] = 0xfa + } + } if m.Tip != nil { { size, err := m.Tip.MarshalToSizedBuffer(dAtA[:i]) @@ -1966,6 +1993,12 @@ func (m *AuthInfo) Size() (n int) { l = m.Tip.Size() n += 1 + l + sovTx(uint64(l)) } + if len(m.ExtensionOptions) > 0 { + for _, e := range m.ExtensionOptions { + l = e.Size() + n += 2 + l + sovTx(uint64(l)) + } + } return n } @@ -3168,6 +3201,40 @@ func (m *AuthInfo) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 1023: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExtensionOptions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ExtensionOptions = append(m.ExtensionOptions, &types.Any{}) + if err := m.ExtensionOptions[len(m.ExtensionOptions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/types/tx/types.go b/types/tx/types.go index 006941b35f17..73441655f500 100644 --- a/types/tx/types.go +++ b/types/tx/types.go @@ -156,6 +156,10 @@ func (t *Tx) FeeGranter() sdk.AccAddress { return nil } +func (t *Tx) AuthExtensionOptions() []*codectypes.Any { + return t.AuthInfo.ExtensionOptions +} + // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method func (t *Tx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { if t.Body != nil { diff --git a/x/auth/middleware/auth_ext.go b/x/auth/middleware/auth_ext.go new file mode 100644 index 000000000000..a6a92a75710b --- /dev/null +++ b/x/auth/middleware/auth_ext.go @@ -0,0 +1,75 @@ +package middleware + +import ( + "context" + + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/tx" +) + +// ExtensionOptionChecker is a function that returns true if the extension option is accepted. +type ExtensionOptionChecker func(*codectypes.Any) bool + +type HasAuthExtensionOptionsTx interface { + AuthExtensionOptions() []*codectypes.Any +} + +type checkAuthExtensionOptionsTxHandler struct { + next tx.Handler + checker ExtensionOptionChecker +} + +// NewAuthExtensionOptionsMiddleware creates a new checkAuthExtensionOptionsMiddleware. +// NewAuthExtensionOptionsMiddleware is a middleware that checks all auth_info extension +// options pass the checker. +func NewAuthExtensionOptionsMiddleware(checker ExtensionOptionChecker) tx.Middleware { + return func(next tx.Handler) tx.Handler { + return checkAuthExtensionOptionsTxHandler{ + next, + checker, + } + } +} + +var _ tx.Handler = checkAuthExtensionOptionsTxHandler{} + +func checkAuthExtOpts(tx sdk.Tx, checker ExtensionOptionChecker) error { + if hasExtOptsTx, ok := tx.(HasAuthExtensionOptionsTx); ok { + for _, opt := range hasExtOptsTx.AuthExtensionOptions() { + if !checker(opt) { + return sdkerrors.ErrUnknownAuthExtensionOptions + } + } + } + + return nil +} + +// CheckTx implements tx.Handler.CheckTx. +func (txh checkAuthExtensionOptionsTxHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { + if err := checkAuthExtOpts(req.Tx, txh.checker); err != nil { + return tx.Response{}, tx.ResponseCheckTx{}, err + } + + return txh.next.CheckTx(ctx, req, checkReq) +} + +// DeliverTx implements tx.Handler.DeliverTx. +func (txh checkAuthExtensionOptionsTxHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { + if err := checkAuthExtOpts(req.Tx, txh.checker); err != nil { + return tx.Response{}, err + } + + return txh.next.DeliverTx(ctx, req) +} + +// SimulateTx implements tx.Handler.SimulateTx method. +func (txh checkAuthExtensionOptionsTxHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { + if err := checkAuthExtOpts(req.Tx, txh.checker); err != nil { + return tx.Response{}, err + } + + return txh.next.SimulateTx(ctx, req) +} diff --git a/x/auth/middleware/branch_store_test.go b/x/auth/middleware/branch_store_test.go index ea675492c1b5..8927d1111f7d 100644 --- a/x/auth/middleware/branch_store_test.go +++ b/x/auth/middleware/branch_store_test.go @@ -72,7 +72,7 @@ func (s *MWTestSuite) TestBranchStore() { middleware.NewTxDecoderMiddleware(s.clientCtx.TxConfig.TxDecoder()), middleware.GasTxMiddleware, middleware.RecoveryTxMiddleware, - middleware.DeductFeeMiddleware(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper), + middleware.DeductFeeMiddleware(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, middleware.StaticFeeMarket{}), middleware.IncrementSequenceMiddleware(s.app.AccountKeeper), middleware.WithBranchedStore, middleware.ConsumeBlockGasMiddleware, diff --git a/x/auth/middleware/fee.go b/x/auth/middleware/fee.go index 718afba479d1..d1a8d0b93a4d 100644 --- a/x/auth/middleware/fee.go +++ b/x/auth/middleware/fee.go @@ -4,78 +4,21 @@ import ( "context" "fmt" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/tx" "github.com/cosmos/cosmos-sdk/x/auth/types" ) -var _ tx.Handler = mempoolFeeTxHandler{} - -type mempoolFeeTxHandler struct { - next tx.Handler -} - -// MempoolFeeMiddleware will check if the transaction's fee is at least as large -// as the local validator's minimum gasFee (defined in validator config). -// If fee is too low, middleware returns error and tx is rejected from mempool. -// Note this only applies when ctx.CheckTx = true -// If fee is high enough or not CheckTx, then call next middleware -// CONTRACT: Tx must implement FeeTx to use MempoolFeeMiddleware -func MempoolFeeMiddleware(txh tx.Handler) tx.Handler { - return mempoolFeeTxHandler{ - next: txh, - } -} - -// CheckTx implements tx.Handler.CheckTx. It is responsible for determining if a -// transaction's fees meet the required minimum of the processing node. Note, a -// node can have zero fees set as the minimum. If non-zero minimum fees are set -// and the transaction does not meet the minimum, the transaction is rejected. -// -// Recall, a transaction's fee is determined by ceil(minGasPrice * gasLimit). -func (txh mempoolFeeTxHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { - sdkCtx := sdk.UnwrapSDKContext(ctx) - - feeTx, ok := req.Tx.(sdk.FeeTx) - if !ok { - return tx.Response{}, tx.ResponseCheckTx{}, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx") - } - - feeCoins := feeTx.GetFee() - gas := feeTx.GetGas() - - // Ensure that the provided fees meet a minimum threshold for the validator, - // if this is a CheckTx. This is only for local mempool purposes, and thus - // is only ran on check tx. - minGasPrices := sdkCtx.MinGasPrices() - if !minGasPrices.IsZero() { - requiredFees := make(sdk.Coins, len(minGasPrices)) - - // Determine the required fees by multiplying each required minimum gas - // price by the gas limit, where fee = ceil(minGasPrice * gasLimit). - glDec := sdk.NewDec(int64(gas)) - for i, gp := range minGasPrices { - fee := gp.Amount.Mul(glDec) - requiredFees[i] = sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt()) - } - - if !feeCoins.IsAnyGTE(requiredFees) { - return tx.Response{}, tx.ResponseCheckTx{}, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, requiredFees) - } - } - - return txh.next.CheckTx(ctx, req, checkReq) -} - -// DeliverTx implements tx.Handler.DeliverTx. -func (txh mempoolFeeTxHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { - return txh.next.DeliverTx(ctx, req) -} - -// SimulateTx implements tx.Handler.SimulateTx. -func (txh mempoolFeeTxHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { - return txh.next.SimulateTx(ctx, req) +// FeeMarket defines the interface of feemarket system for tx middleware. +type FeeMarket interface { + // CheckAuthExtensionOption returns true for allowed auth_info extension option, + // Some feemarket module needs to extent the auth_info. + CheckAuthExtensionOption(*codectypes.Any) bool + // CheckTxFee check if the provided fee is enough and returns the effective fee and tx priority, + // the effective fee should be deducted later, and the priority should be returned in abci response. + CheckTxFee(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) } var _ tx.Handler = deductFeeTxHandler{} @@ -84,6 +27,7 @@ type deductFeeTxHandler struct { accountKeeper AccountKeeper bankKeeper types.BankKeeper feegrantKeeper FeegrantKeeper + feemarket FeeMarket next tx.Handler } @@ -91,19 +35,19 @@ type deductFeeTxHandler struct { // If the first signer does not have the funds to pay for the fees, return with InsufficientFunds error // Call next middleware if fees successfully deducted // CONTRACT: Tx must implement FeeTx interface to use deductFeeTxHandler -func DeductFeeMiddleware(ak AccountKeeper, bk types.BankKeeper, fk FeegrantKeeper) tx.Middleware { +func DeductFeeMiddleware(ak AccountKeeper, bk types.BankKeeper, fk FeegrantKeeper, fm FeeMarket) tx.Middleware { return func(txh tx.Handler) tx.Handler { return deductFeeTxHandler{ accountKeeper: ak, bankKeeper: bk, feegrantKeeper: fk, + feemarket: fm, next: txh, } } } -func (dfd deductFeeTxHandler) checkDeductFee(ctx context.Context, sdkTx sdk.Tx) error { - sdkCtx := sdk.UnwrapSDKContext(ctx) +func (dfd deductFeeTxHandler) checkDeductFee(ctx sdk.Context, sdkTx sdk.Tx, fee sdk.Coins) error { feeTx, ok := sdkTx.(sdk.FeeTx) if !ok { return sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx") @@ -113,10 +57,8 @@ func (dfd deductFeeTxHandler) checkDeductFee(ctx context.Context, sdkTx sdk.Tx) return fmt.Errorf("Fee collector module account (%s) has not been set", types.FeeCollectorName) } - fee := feeTx.GetFee() feePayer := feeTx.FeePayer() feeGranter := feeTx.FeeGranter() - deductFeesFrom := feePayer // if feegranter set deduct fee from feegranter account. @@ -125,7 +67,7 @@ func (dfd deductFeeTxHandler) checkDeductFee(ctx context.Context, sdkTx sdk.Tx) if dfd.feegrantKeeper == nil { return sdkerrors.ErrInvalidRequest.Wrap("fee grants are not enabled") } else if !feeGranter.Equals(feePayer) { - err := dfd.feegrantKeeper.UseGrantedFees(sdkCtx, feeGranter, feePayer, fee, sdkTx.GetMsgs()) + err := dfd.feegrantKeeper.UseGrantedFees(ctx, feeGranter, feePayer, fee, sdkTx.GetMsgs()) if err != nil { return sdkerrors.Wrapf(err, "%s does not not allow to pay fees for %s", feeGranter, feePayer) } @@ -134,39 +76,52 @@ func (dfd deductFeeTxHandler) checkDeductFee(ctx context.Context, sdkTx sdk.Tx) deductFeesFrom = feeGranter } - deductFeesFromAcc := dfd.accountKeeper.GetAccount(sdkCtx, deductFeesFrom) + deductFeesFromAcc := dfd.accountKeeper.GetAccount(ctx, deductFeesFrom) if deductFeesFromAcc == nil { return sdkerrors.ErrUnknownAddress.Wrapf("fee payer address: %s does not exist", deductFeesFrom) } // deduct the fees - if !feeTx.GetFee().IsZero() { - err := DeductFees(dfd.bankKeeper, sdkCtx, deductFeesFromAcc, feeTx.GetFee()) + if !fee.IsZero() { + err := DeductFees(dfd.bankKeeper, ctx, deductFeesFromAcc, fee) if err != nil { return err } } events := sdk.Events{sdk.NewEvent(sdk.EventTypeTx, - sdk.NewAttribute(sdk.AttributeKeyFee, feeTx.GetFee().String()), + sdk.NewAttribute(sdk.AttributeKeyFee, fee.String()), )} - sdkCtx.EventManager().EmitEvents(events) + ctx.EventManager().EmitEvents(events) return nil } // CheckTx implements tx.Handler.CheckTx. func (dfd deductFeeTxHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { - if err := dfd.checkDeductFee(ctx, req.Tx); err != nil { + sdkCtx := sdk.UnwrapSDKContext(ctx) + fee, priority, err := dfd.feemarket.CheckTxFee(sdkCtx, req.Tx) + if err != nil { + return tx.Response{}, tx.ResponseCheckTx{}, err + } + if err := dfd.checkDeductFee(sdkCtx, req.Tx, fee); err != nil { return tx.Response{}, tx.ResponseCheckTx{}, err } - return dfd.next.CheckTx(ctx, req, checkReq) + res, checkRes, err := dfd.next.CheckTx(ctx, req, checkReq) + checkRes.Priority = priority + + return res, checkRes, err } // DeliverTx implements tx.Handler.DeliverTx. func (dfd deductFeeTxHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := dfd.checkDeductFee(ctx, req.Tx); err != nil { + sdkCtx := sdk.UnwrapSDKContext(ctx) + fee, _, err := dfd.feemarket.CheckTxFee(sdkCtx, req.Tx) + if err != nil { + return tx.Response{}, err + } + if err := dfd.checkDeductFee(sdkCtx, req.Tx, fee); err != nil { return tx.Response{}, err } @@ -174,7 +129,12 @@ func (dfd deductFeeTxHandler) DeliverTx(ctx context.Context, req tx.Request) (tx } func (dfd deductFeeTxHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := dfd.checkDeductFee(ctx, req.Tx); err != nil { + sdkCtx := sdk.UnwrapSDKContext(ctx) + fee, _, err := dfd.feemarket.CheckTxFee(sdkCtx, req.Tx) + if err != nil { + return tx.Response{}, err + } + if err := dfd.checkDeductFee(sdkCtx, req.Tx, fee); err != nil { return tx.Response{}, err } diff --git a/x/auth/middleware/fee_test.go b/x/auth/middleware/fee_test.go index e4673f3f8dd5..ca73355f7986 100644 --- a/x/auth/middleware/fee_test.go +++ b/x/auth/middleware/fee_test.go @@ -13,14 +13,21 @@ func (s *MWTestSuite) TestEnsureMempoolFees() { ctx := s.SetupTest(true) // setup txBuilder := s.clientCtx.TxConfig.NewTxBuilder() - txHandler := middleware.ComposeMiddlewares(noopTxHandler, middleware.MempoolFeeMiddleware) + txHandler := middleware.ComposeMiddlewares(noopTxHandler, middleware.DeductFeeMiddleware( + s.app.AccountKeeper, + s.app.BankKeeper, + s.app.FeeGrantKeeper, + middleware.StaticFeeMarket{}, + )) // keys and addresses priv1, _, addr1 := testdata.KeyTestPubAddr() // msg and signatures msg := testdata.NewTestMsg(addr1) - feeAmount := testdata.NewTestFeeAmount() + atomCoin := sdk.NewCoin("atom", sdk.NewInt(150)) + apeCoin := sdk.NewInt64Coin("ape", 1500000) + feeAmount := sdk.NewCoins(apeCoin, atomCoin) gasLimit := testdata.NewTestGasLimit() s.Require().NoError(txBuilder.SetMsgs(msg)) txBuilder.SetFeeAmount(feeAmount) @@ -39,16 +46,23 @@ func (s *MWTestSuite) TestEnsureMempoolFees() { _, _, err = txHandler.CheckTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx}, tx.RequestCheckTx{}) s.Require().NotNil(err, "Middleware should have errored on too low fee for local gasPrice") - // txHandler should not error since we do not check minGasPrice in DeliverTx + // txHandler should fail since we also check minGasPrice in DeliverTx _, err = txHandler.DeliverTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx}) - s.Require().Nil(err, "MempoolFeeMiddleware returned error in DeliverTx") + s.Require().Error(err, "MempoolFeeMiddleware don't error in DeliverTx") atomPrice = sdk.NewDecCoinFromDec("atom", sdk.NewDec(0).Quo(sdk.NewDec(100000))) lowGasPrice := []sdk.DecCoin{atomPrice} ctx = ctx.WithMinGasPrices(lowGasPrice) - _, _, err = txHandler.CheckTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx}, tx.RequestCheckTx{}) + // Set account with sufficient funds + acc := s.app.AccountKeeper.NewAccountWithAddress(ctx, addr1) + s.app.AccountKeeper.SetAccount(ctx, acc) + err = testutil.FundAccount(s.app.BankKeeper, ctx, addr1, feeAmount) + s.Require().NoError(err) + + _, checkTxRes, err := txHandler.CheckTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx}, tx.RequestCheckTx{}) s.Require().Nil(err, "Middleware should not have errored on fee higher than local gasPrice") + s.Require().Equal(atomCoin.Amount.Int64(), checkTxRes.Priority, "priority should be atom amount") } func (s *MWTestSuite) TestDeductFees() { @@ -60,6 +74,7 @@ func (s *MWTestSuite) TestDeductFees() { s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, + middleware.StaticFeeMarket{}, ), ) diff --git a/x/auth/middleware/feegrant_test.go b/x/auth/middleware/feegrant_test.go index f2c36ad5efdd..fadecd8f1b65 100644 --- a/x/auth/middleware/feegrant_test.go +++ b/x/auth/middleware/feegrant_test.go @@ -36,6 +36,7 @@ func (s *MWTestSuite) TestDeductFeesNoDelegation() { s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, + middleware.StaticFeeMarket{}, ), ) diff --git a/x/auth/middleware/middleware.go b/x/auth/middleware/middleware.go index 87b1216363fb..5c62051c3eb7 100644 --- a/x/auth/middleware/middleware.go +++ b/x/auth/middleware/middleware.go @@ -48,6 +48,7 @@ type TxHandlerOptions struct { FeegrantKeeper FeegrantKeeper SignModeHandler authsigning.SignModeHandler SigGasConsumer func(meter sdk.GasMeter, sig signing.SignatureV2, params types.Params) error + FeeMarket FeeMarket } // NewDefaultTxHandler defines a TxHandler middleware stacks that should work @@ -92,7 +93,8 @@ func NewDefaultTxHandler(options TxHandlerOptions) (tx.Handler, error) { // Reject all extension options which can optionally be included in the // tx. RejectExtensionOptionsMiddleware, - MempoolFeeMiddleware, + // Reject auth_info extension options that don't pass the criteria. + NewAuthExtensionOptionsMiddleware(options.FeeMarket.CheckAuthExtensionOption), ValidateBasicMiddleware, TxTimeoutHeightMiddleware, ValidateMemoMiddleware(options.AccountKeeper), @@ -101,8 +103,7 @@ func NewDefaultTxHandler(options TxHandlerOptions) (tx.Handler, error) { // ComposeMiddlewares godoc for details. // `DeductFeeMiddleware` and `IncrementSequenceMiddleware` should be put outside of `WithBranchedStore` middleware, // so their storage writes are not discarded when tx fails. - DeductFeeMiddleware(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper), - TxPriorityMiddleware, + DeductFeeMiddleware(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.FeeMarket), SetPubKeyMiddleware(options.AccountKeeper), ValidateSigCountMiddleware(options.AccountKeeper), SigGasConsumeMiddleware(options.AccountKeeper, sigGasConsumer), diff --git a/x/auth/middleware/middleware_test.go b/x/auth/middleware/middleware_test.go index d923b84b2c3d..f1d1fb237a3a 100644 --- a/x/auth/middleware/middleware_test.go +++ b/x/auth/middleware/middleware_test.go @@ -1026,6 +1026,7 @@ func (s *MWTestSuite) TestCustomSignatureVerificationGasConsumer() { } }, TxDecoder: s.clientCtx.TxConfig.TxDecoder(), + FeeMarket: middleware.StaticFeeMarket{}, }, ) s.Require().NoError(err) diff --git a/x/auth/middleware/priority.go b/x/auth/middleware/priority.go deleted file mode 100644 index a464fddd1e7d..000000000000 --- a/x/auth/middleware/priority.go +++ /dev/null @@ -1,63 +0,0 @@ -package middleware - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/types/tx" -) - -var _ tx.Handler = txPriorityHandler{} - -type txPriorityHandler struct { - next tx.Handler -} - -// TxPriorityMiddleware implements tx handling middleware that determines a -// transaction's priority via a naive mechanism -- the total sum of fees provided. -// It sets the Priority in ResponseCheckTx only. -func TxPriorityMiddleware(txh tx.Handler) tx.Handler { - return txPriorityHandler{next: txh} -} - -// CheckTx implements tx.Handler.CheckTx. We set the Priority of the transaction -// to be ordered in the Tendermint mempool based naively on the total sum of all -// fees included. Applications that need more sophisticated mempool ordering -// should look to implement their own fee handling middleware instead of using -// TxPriorityHandler. -func (h txPriorityHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { - feeTx, ok := req.Tx.(sdk.FeeTx) - if !ok { - return tx.Response{}, tx.ResponseCheckTx{}, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx") - } - - feeCoins := feeTx.GetFee() - - res, checkRes, err := h.next.CheckTx(ctx, req, checkReq) - checkRes.Priority = GetTxPriority(feeCoins) - - return res, checkRes, err -} - -func (h txPriorityHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { - return h.next.DeliverTx(ctx, req) -} - -func (h txPriorityHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { - return h.next.SimulateTx(ctx, req) -} - -// GetTxPriority returns a naive tx priority based on the amount of the smallest denomination of the fee -// provided in a transaction. -func GetTxPriority(fee sdk.Coins) int64 { - var priority int64 - for _, c := range fee { - p := c.Amount.Int64() - if priority == 0 || p < priority { - priority = p - } - } - - return priority -} diff --git a/x/auth/middleware/priority_test.go b/x/auth/middleware/priority_test.go deleted file mode 100644 index 388418644040..000000000000 --- a/x/auth/middleware/priority_test.go +++ /dev/null @@ -1,38 +0,0 @@ -package middleware_test - -import ( - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - "github.com/cosmos/cosmos-sdk/testutil/testdata" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/cosmos/cosmos-sdk/x/auth/middleware" -) - -func (s *MWTestSuite) TestPriority() { - ctx := s.SetupTest(true) // setup - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() - - txHandler := middleware.ComposeMiddlewares(noopTxHandler, middleware.TxPriorityMiddleware) - - // keys and addresses - priv1, _, addr1 := testdata.KeyTestPubAddr() - - // msg and signatures - msg := testdata.NewTestMsg(addr1) - atomCoin := sdk.NewCoin("atom", sdk.NewInt(150)) - apeCoin := sdk.NewInt64Coin("ape", 1500000) - feeAmount := sdk.NewCoins(apeCoin, atomCoin) - gasLimit := testdata.NewTestGasLimit() - s.Require().NoError(txBuilder.SetMsgs(msg)) - txBuilder.SetFeeAmount(feeAmount) - txBuilder.SetGasLimit(gasLimit) - - privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} - testTx, _, err := s.createTestTx(txBuilder, privs, accNums, accSeqs, ctx.ChainID()) - s.Require().NoError(err) - - // txHandler errors with insufficient fees - _, checkTxRes, err := txHandler.CheckTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx}, tx.RequestCheckTx{}) - s.Require().NoError(err, "Middleware should not have errored on too low fee for local gasPrice") - s.Require().Equal(atomCoin.Amount.Int64(), checkTxRes.Priority, "priority should be atom amount") -} diff --git a/x/auth/middleware/static_feemarket.go b/x/auth/middleware/static_feemarket.go new file mode 100644 index 000000000000..c2013d32d31c --- /dev/null +++ b/x/auth/middleware/static_feemarket.go @@ -0,0 +1,65 @@ +package middleware + +import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// StaticFeeMarket implements a static feemarket. +type StaticFeeMarket struct{} + +// CheckAuthExtensionOption returns true if the auth extension option should be allowed. +func (sfm StaticFeeMarket) CheckAuthExtensionOption(*codectypes.Any) bool { + return false +} + +// CheckTxFee check if the provided fee is enough, if yes return the effective fee and priority, otherwise return +// error. +// The effective fee should be deducted later, and the priority should be set in the abci response. +func (sfm StaticFeeMarket) CheckTxFee(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) { + feeTx, ok := tx.(sdk.FeeTx) + if !ok { + return nil, 0, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx") + } + + feeCoins := feeTx.GetFee() + gas := feeTx.GetGas() + + // Ensure that the provided fees meet a minimum threshold for the validator, + // if this is a CheckTx. This is only for local mempool purposes, and thus + // is only ran on check tx. + minGasPrices := ctx.MinGasPrices() + if !minGasPrices.IsZero() { + requiredFees := make(sdk.Coins, len(minGasPrices)) + + // Determine the required fees by multiplying each required minimum gas + // price by the gas limit, where fee = ceil(minGasPrice * gasLimit). + glDec := sdk.NewDec(int64(gas)) + for i, gp := range minGasPrices { + fee := gp.Amount.Mul(glDec) + requiredFees[i] = sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt()) + } + + if !feeCoins.IsAnyGTE(requiredFees) { + return nil, 0, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, requiredFees) + } + } + + priority := GetTxPriority(feeCoins) + return feeCoins, priority, nil +} + +// GetTxPriority returns a naive tx priority based on the amount of the smallest denomination of the fee +// provided in a transaction. +func GetTxPriority(fee sdk.Coins) int64 { + var priority int64 + for _, c := range fee { + p := c.Amount.Int64() + if priority == 0 || p < priority { + priority = p + } + } + + return priority +} diff --git a/x/auth/middleware/testutil_test.go b/x/auth/middleware/testutil_test.go index f493a463fa2a..5fae7a9918fe 100644 --- a/x/auth/middleware/testutil_test.go +++ b/x/auth/middleware/testutil_test.go @@ -90,6 +90,7 @@ func (s *MWTestSuite) SetupTest(isCheckTx bool) sdk.Context { SignModeHandler: encodingConfig.TxConfig.SignModeHandler(), SigGasConsumer: middleware.DefaultSigVerificationGasConsumer, TxDecoder: s.clientCtx.TxConfig.TxDecoder(), + FeeMarket: middleware.StaticFeeMarket{}, }) s.Require().NoError(err) s.txHandler = txHandler From a6271d9d2e190a28d0890364504cf7b05c1cfb7d Mon Sep 17 00:00:00 2001 From: HuangYi Date: Sat, 19 Mar 2022 00:09:31 +0800 Subject: [PATCH 02/22] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 136af434525a..5a6b9d6c6a34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -185,6 +185,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/auth) [\#10880](https://github.com/cosmos/cosmos-sdk/pull/10880) Added a new query to the tx query service that returns a block with transactions fully decoded. * (types) [\#11200](https://github.com/cosmos/cosmos-sdk/pull/11200) Added `Min()` and `Max()` operations on sdk.Coins. * (gov) [\#11287](https://github.com/cosmos/cosmos-sdk/pull/11287) Fix error message when no flags are provided while executing `submit-legacy-proposal` transaction. +* (ante) [#11413](https://github.com/cosmos/cosmos-sdk/pull/11413) Refactor tx middleware to support pluggable feemarket module. ### Bug Fixes From 8a06c23a444a4a27fb8b50b8bb3e80c4196963c2 Mon Sep 17 00:00:00 2001 From: HuangYi Date: Sat, 19 Mar 2022 00:16:18 +0800 Subject: [PATCH 03/22] add overflow protection --- x/auth/middleware/static_feemarket.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/x/auth/middleware/static_feemarket.go b/x/auth/middleware/static_feemarket.go index c2013d32d31c..c1d6ac0f30fd 100644 --- a/x/auth/middleware/static_feemarket.go +++ b/x/auth/middleware/static_feemarket.go @@ -1,6 +1,8 @@ package middleware import ( + "math" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -55,7 +57,10 @@ func (sfm StaticFeeMarket) CheckTxFee(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, in func GetTxPriority(fee sdk.Coins) int64 { var priority int64 for _, c := range fee { - p := c.Amount.Int64() + p := int64(math.MaxInt64) + if c.Amount.IsInt64() { + p = c.Amount.Int64() + } if priority == 0 || p < priority { priority = p } From 3c0b971d203eaea70b45019b6fbe516a94551dde Mon Sep 17 00:00:00 2001 From: HuangYi Date: Mon, 21 Mar 2022 10:52:05 +0800 Subject: [PATCH 04/22] reject non-empty auth extension options in legacy amino mode --- x/auth/tx/legacy_amino_json.go | 5 +++++ x/auth/tx/legacy_amino_json_test.go | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/x/auth/tx/legacy_amino_json.go b/x/auth/tx/legacy_amino_json.go index 01274f9f6ed9..e953ebe39eb9 100644 --- a/x/auth/tx/legacy_amino_json.go +++ b/x/auth/tx/legacy_amino_json.go @@ -41,11 +41,16 @@ func (s signModeLegacyAminoJSONHandler) GetSignBytes(mode signingtypes.SignMode, } body := protoTx.tx.Body + authInfo := protoTx.tx.AuthInfo if len(body.ExtensionOptions) != 0 || len(body.NonCriticalExtensionOptions) != 0 { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "%s does not support protobuf extension options", signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON) } + if len(authInfo.ExtensionOptions) != 0 { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "%s does not support AuthInfo protobuf extension options", signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON) + } + addr := data.Address if addr == "" { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "got empty address in %s handler", signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON) diff --git a/x/auth/tx/legacy_amino_json_test.go b/x/auth/tx/legacy_amino_json_test.go index 7df42f92b13d..1cbc10f3e89a 100644 --- a/x/auth/tx/legacy_amino_json_test.go +++ b/x/auth/tx/legacy_amino_json_test.go @@ -136,6 +136,17 @@ func TestLegacyAminoJSONHandler_GetSignBytes(t *testing.T) { tx = bldr.GetTx() _, err = handler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signingData, tx) require.Error(t, err) + + // expect error with AuthInfo extension options + bldr = newBuilder(nil) + buildTx(t, bldr) + any, err = cdctypes.NewAnyWithValue(testdata.NewTestMsg()) + require.NoError(t, err) + bldr.tx.AuthInfo.ExtensionOptions = []*cdctypes.Any{any} + tx = bldr.GetTx() + _, err = handler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signingData, tx) + require.Error(t, err) + } func TestLegacyAminoJSONHandler_DefaultMode(t *testing.T) { From 62f478988f7559676f5e1d0799708072692ef6a0 Mon Sep 17 00:00:00 2001 From: HuangYi Date: Tue, 22 Mar 2022 09:23:35 +0800 Subject: [PATCH 05/22] fix review suggestions --- CHANGELOG.md | 2 +- types/tx/types.go | 2 ++ x/auth/middleware/auth_ext.go | 8 ++++++++ x/auth/middleware/fee.go | 6 +++--- x/auth/middleware/middleware.go | 2 +- x/auth/middleware/static_feemarket.go | 9 ++++++--- 6 files changed, 21 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a6b9d6c6a34..0538aa400957 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -140,6 +140,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/authz) [\#10447](https://github.com/cosmos/cosmos-sdk/pull/10447) authz `NewGrant` takes a new argument: block time, to correctly validate expire time. * [\#10961](https://github.com/cosmos/cosmos-sdk/pull/10961) Support third-party modules to add extension snapshots to state-sync. * [\#11274](https://github.com/cosmos/cosmos-sdk/pull/11274) `types/errors.New` now is an alias for `types/errors.Register` and should only be used in initialization code. +* (ante) [#11413](https://github.com/cosmos/cosmos-sdk/pull/11413) Refactor tx middleware to support pluggable feemarket module. The API breakages: a) Removed `MempoolFeeMiddleware` and `TxPriorityMiddleware`, the functionalities are moved into `DeductFeeMiddleware`, b) Added a new `FeeMarket` field to `HandlerOptions`, when set to `StaticFeeMarket{}`, it'll keep the existing middleware behavior. ### Client Breaking Changes @@ -185,7 +186,6 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/auth) [\#10880](https://github.com/cosmos/cosmos-sdk/pull/10880) Added a new query to the tx query service that returns a block with transactions fully decoded. * (types) [\#11200](https://github.com/cosmos/cosmos-sdk/pull/11200) Added `Min()` and `Max()` operations on sdk.Coins. * (gov) [\#11287](https://github.com/cosmos/cosmos-sdk/pull/11287) Fix error message when no flags are provided while executing `submit-legacy-proposal` transaction. -* (ante) [#11413](https://github.com/cosmos/cosmos-sdk/pull/11413) Refactor tx middleware to support pluggable feemarket module. ### Bug Fixes diff --git a/types/tx/types.go b/types/tx/types.go index 73441655f500..cee28a4ce17f 100644 --- a/types/tx/types.go +++ b/types/tx/types.go @@ -156,6 +156,8 @@ func (t *Tx) FeeGranter() sdk.AccAddress { return nil } +// AuthExtensionOptions returns the AuthInfo's ExtensionOptions, +// implements the interface HasAuthExtensionOptionsTx. func (t *Tx) AuthExtensionOptions() []*codectypes.Any { return t.AuthInfo.ExtensionOptions } diff --git a/x/auth/middleware/auth_ext.go b/x/auth/middleware/auth_ext.go index a6a92a75710b..e65a28e44133 100644 --- a/x/auth/middleware/auth_ext.go +++ b/x/auth/middleware/auth_ext.go @@ -12,6 +12,10 @@ import ( // ExtensionOptionChecker is a function that returns true if the extension option is accepted. type ExtensionOptionChecker func(*codectypes.Any) bool +func rejectExtensionOption(*codectypes.Any) bool { + return false +} + type HasAuthExtensionOptionsTx interface { AuthExtensionOptions() []*codectypes.Any } @@ -24,7 +28,11 @@ type checkAuthExtensionOptionsTxHandler struct { // NewAuthExtensionOptionsMiddleware creates a new checkAuthExtensionOptionsMiddleware. // NewAuthExtensionOptionsMiddleware is a middleware that checks all auth_info extension // options pass the checker. +// If checker is nil, it defaults to a function that rejects all extension options. func NewAuthExtensionOptionsMiddleware(checker ExtensionOptionChecker) tx.Middleware { + if checker == nil { + checker = rejectExtensionOption + } return func(next tx.Handler) tx.Handler { return checkAuthExtensionOptionsTxHandler{ next, diff --git a/x/auth/middleware/fee.go b/x/auth/middleware/fee.go index d1a8d0b93a4d..d6d17a93e04f 100644 --- a/x/auth/middleware/fee.go +++ b/x/auth/middleware/fee.go @@ -13,9 +13,9 @@ import ( // FeeMarket defines the interface of feemarket system for tx middleware. type FeeMarket interface { - // CheckAuthExtensionOption returns true for allowed auth_info extension option, - // Some feemarket module needs to extent the auth_info. - CheckAuthExtensionOption(*codectypes.Any) bool + // AllowAuthExtensionOption returns true for allowed auth_info extension option, + // Some feemarket modules need to extend the auth_info. + AllowAuthExtensionOption(*codectypes.Any) bool // CheckTxFee check if the provided fee is enough and returns the effective fee and tx priority, // the effective fee should be deducted later, and the priority should be returned in abci response. CheckTxFee(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) diff --git a/x/auth/middleware/middleware.go b/x/auth/middleware/middleware.go index 5c62051c3eb7..46374c11e93d 100644 --- a/x/auth/middleware/middleware.go +++ b/x/auth/middleware/middleware.go @@ -94,7 +94,7 @@ func NewDefaultTxHandler(options TxHandlerOptions) (tx.Handler, error) { // tx. RejectExtensionOptionsMiddleware, // Reject auth_info extension options that don't pass the criteria. - NewAuthExtensionOptionsMiddleware(options.FeeMarket.CheckAuthExtensionOption), + NewAuthExtensionOptionsMiddleware(options.FeeMarket.AllowAuthExtensionOption), ValidateBasicMiddleware, TxTimeoutHeightMiddleware, ValidateMemoMiddleware(options.AccountKeeper), diff --git a/x/auth/middleware/static_feemarket.go b/x/auth/middleware/static_feemarket.go index c1d6ac0f30fd..a3f52fa04e1d 100644 --- a/x/auth/middleware/static_feemarket.go +++ b/x/auth/middleware/static_feemarket.go @@ -8,11 +8,14 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -// StaticFeeMarket implements a static feemarket. +// StaticFeeMarket implements a static feemarket, where the minimum price per +// unit of gas is fixed and set by each validator. type StaticFeeMarket struct{} -// CheckAuthExtensionOption returns true if the auth extension option should be allowed. -func (sfm StaticFeeMarket) CheckAuthExtensionOption(*codectypes.Any) bool { +var _ FeeMarket = StaticFeeMarket{} + +// AllowAuthExtensionOption returns true if the auth extension option should be allowed. +func (sfm StaticFeeMarket) AllowAuthExtensionOption(*codectypes.Any) bool { return false } From aabd04b98cd38126cac9d2138dcbfd4eb632d602 Mon Sep 17 00:00:00 2001 From: HuangYi Date: Tue, 22 Mar 2022 09:33:59 +0800 Subject: [PATCH 06/22] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0538aa400957..8ff097f66d02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -140,7 +140,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/authz) [\#10447](https://github.com/cosmos/cosmos-sdk/pull/10447) authz `NewGrant` takes a new argument: block time, to correctly validate expire time. * [\#10961](https://github.com/cosmos/cosmos-sdk/pull/10961) Support third-party modules to add extension snapshots to state-sync. * [\#11274](https://github.com/cosmos/cosmos-sdk/pull/11274) `types/errors.New` now is an alias for `types/errors.Register` and should only be used in initialization code. -* (ante) [#11413](https://github.com/cosmos/cosmos-sdk/pull/11413) Refactor tx middleware to support pluggable feemarket module. The API breakages: a) Removed `MempoolFeeMiddleware` and `TxPriorityMiddleware`, the functionalities are moved into `DeductFeeMiddleware`, b) Added a new `FeeMarket` field to `HandlerOptions`, when set to `StaticFeeMarket{}`, it'll keep the existing middleware behavior. +* (ante) [#11413](https://github.com/cosmos/cosmos-sdk/pull/11413) Refactor tx middleware to support pluggable feemarket module. The API breakages: a) Removed `MempoolFeeMiddleware` and `TxPriorityMiddleware`, the functionalities are moved into `DeductFeeMiddleware`, b) Added a `FeeMarket` field to `HandlerOptions`, and a `FeeMarket` parameter to `DeductFeeMiddleware`, when set to `StaticFeeMarket{}`, it'll keep the existing behavior, c) Added an `extention_options` field to `AuthInfo` in `Tx`, d) Added a `NewAuthExtensionOptionsMiddleware` middleware to check the `extension_options` field. ### Client Breaking Changes From 5ef3bd45f10edfb912292632829513136050ec23 Mon Sep 17 00:00:00 2001 From: yihuang Date: Tue, 22 Mar 2022 16:58:40 +0800 Subject: [PATCH 07/22] Update x/auth/middleware/static_feemarket.go --- x/auth/middleware/static_feemarket.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/x/auth/middleware/static_feemarket.go b/x/auth/middleware/static_feemarket.go index a3f52fa04e1d..3586cb53bf43 100644 --- a/x/auth/middleware/static_feemarket.go +++ b/x/auth/middleware/static_feemarket.go @@ -32,8 +32,7 @@ func (sfm StaticFeeMarket) CheckTxFee(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, in gas := feeTx.GetGas() // Ensure that the provided fees meet a minimum threshold for the validator, - // if this is a CheckTx. This is only for local mempool purposes, and thus - // is only ran on check tx. + // This is only for local mempool purposes, if this is a DeliverTx, the `MinGasPrices` should be zero. minGasPrices := ctx.MinGasPrices() if !minGasPrices.IsZero() { requiredFees := make(sdk.Coins, len(minGasPrices)) From 6cd75ab5641018873548c58f8330b79eea03ecc7 Mon Sep 17 00:00:00 2001 From: HuangYi Date: Tue, 22 Mar 2022 18:01:43 +0800 Subject: [PATCH 08/22] review suggestions --- simapp/app.go | 2 +- types/errors/errors.go | 3 --- x/auth/middleware/auth_ext.go | 2 +- x/auth/middleware/branch_store_test.go | 2 +- x/auth/middleware/fee_test.go | 4 ++-- x/auth/middleware/feegrant_test.go | 2 +- x/auth/middleware/middleware_test.go | 2 +- x/auth/middleware/testutil_test.go | 2 +- .../{static_feemarket.go => validator_tx_fee.go} | 16 ++++++++-------- 9 files changed, 16 insertions(+), 19 deletions(-) rename x/auth/middleware/{static_feemarket.go => validator_tx_fee.go} (80%) diff --git a/simapp/app.go b/simapp/app.go index 958d66ec474e..c4cd700401d7 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -471,7 +471,7 @@ func (app *SimApp) setTxHandler(txConfig client.TxConfig, indexEventsStr []strin SignModeHandler: txConfig.SignModeHandler(), SigGasConsumer: authmiddleware.DefaultSigVerificationGasConsumer, TxDecoder: txConfig.TxDecoder(), - FeeMarket: authmiddleware.StaticFeeMarket{}, + FeeMarket: authmiddleware.ValidatorTxFee{}, }) if err != nil { panic(err) diff --git a/types/errors/errors.go b/types/errors/errors.go index f2287cbae53e..aa6bffe0616d 100644 --- a/types/errors/errors.go +++ b/types/errors/errors.go @@ -162,9 +162,6 @@ var ( // ErrAppConfig defines an error occurred if min-gas-prices field in BaseConfig is empty. ErrAppConfig = Register(RootCodespace, 40, "error in app.toml") - // ErrUnknownAuthExtensionOptions defines an error for unknown auth_info extension options. - ErrUnknownAuthExtensionOptions = Register(RootCodespace, 41, "unknown auth_info extension options") - // ErrPanic is only set when we recover from a panic, so we know to // redact potentially sensitive system info ErrPanic = errorsmod.ErrPanic diff --git a/x/auth/middleware/auth_ext.go b/x/auth/middleware/auth_ext.go index e65a28e44133..a42cfabb95e3 100644 --- a/x/auth/middleware/auth_ext.go +++ b/x/auth/middleware/auth_ext.go @@ -47,7 +47,7 @@ func checkAuthExtOpts(tx sdk.Tx, checker ExtensionOptionChecker) error { if hasExtOptsTx, ok := tx.(HasAuthExtensionOptionsTx); ok { for _, opt := range hasExtOptsTx.AuthExtensionOptions() { if !checker(opt) { - return sdkerrors.ErrUnknownAuthExtensionOptions + return sdkerrors.ErrInvalidRequest.Wrapf("Unknown auth extension option: %T", opt) } } } diff --git a/x/auth/middleware/branch_store_test.go b/x/auth/middleware/branch_store_test.go index 8927d1111f7d..c8b547526a3e 100644 --- a/x/auth/middleware/branch_store_test.go +++ b/x/auth/middleware/branch_store_test.go @@ -72,7 +72,7 @@ func (s *MWTestSuite) TestBranchStore() { middleware.NewTxDecoderMiddleware(s.clientCtx.TxConfig.TxDecoder()), middleware.GasTxMiddleware, middleware.RecoveryTxMiddleware, - middleware.DeductFeeMiddleware(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, middleware.StaticFeeMarket{}), + middleware.DeductFeeMiddleware(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, middleware.ValidatorTxFee{}), middleware.IncrementSequenceMiddleware(s.app.AccountKeeper), middleware.WithBranchedStore, middleware.ConsumeBlockGasMiddleware, diff --git a/x/auth/middleware/fee_test.go b/x/auth/middleware/fee_test.go index ca73355f7986..6fae0325c2cf 100644 --- a/x/auth/middleware/fee_test.go +++ b/x/auth/middleware/fee_test.go @@ -17,7 +17,7 @@ func (s *MWTestSuite) TestEnsureMempoolFees() { s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, - middleware.StaticFeeMarket{}, + middleware.ValidatorTxFee{}, )) // keys and addresses @@ -74,7 +74,7 @@ func (s *MWTestSuite) TestDeductFees() { s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, - middleware.StaticFeeMarket{}, + middleware.ValidatorTxFee{}, ), ) diff --git a/x/auth/middleware/feegrant_test.go b/x/auth/middleware/feegrant_test.go index fadecd8f1b65..cc91f80f4371 100644 --- a/x/auth/middleware/feegrant_test.go +++ b/x/auth/middleware/feegrant_test.go @@ -36,7 +36,7 @@ func (s *MWTestSuite) TestDeductFeesNoDelegation() { s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, - middleware.StaticFeeMarket{}, + middleware.ValidatorTxFee{}, ), ) diff --git a/x/auth/middleware/middleware_test.go b/x/auth/middleware/middleware_test.go index f1d1fb237a3a..058b44ea890a 100644 --- a/x/auth/middleware/middleware_test.go +++ b/x/auth/middleware/middleware_test.go @@ -1026,7 +1026,7 @@ func (s *MWTestSuite) TestCustomSignatureVerificationGasConsumer() { } }, TxDecoder: s.clientCtx.TxConfig.TxDecoder(), - FeeMarket: middleware.StaticFeeMarket{}, + FeeMarket: middleware.ValidatorTxFee{}, }, ) s.Require().NoError(err) diff --git a/x/auth/middleware/testutil_test.go b/x/auth/middleware/testutil_test.go index 5fae7a9918fe..78d49fd9dbd7 100644 --- a/x/auth/middleware/testutil_test.go +++ b/x/auth/middleware/testutil_test.go @@ -90,7 +90,7 @@ func (s *MWTestSuite) SetupTest(isCheckTx bool) sdk.Context { SignModeHandler: encodingConfig.TxConfig.SignModeHandler(), SigGasConsumer: middleware.DefaultSigVerificationGasConsumer, TxDecoder: s.clientCtx.TxConfig.TxDecoder(), - FeeMarket: middleware.StaticFeeMarket{}, + FeeMarket: middleware.ValidatorTxFee{}, }) s.Require().NoError(err) s.txHandler = txHandler diff --git a/x/auth/middleware/static_feemarket.go b/x/auth/middleware/validator_tx_fee.go similarity index 80% rename from x/auth/middleware/static_feemarket.go rename to x/auth/middleware/validator_tx_fee.go index a3f52fa04e1d..be25ae6137ba 100644 --- a/x/auth/middleware/static_feemarket.go +++ b/x/auth/middleware/validator_tx_fee.go @@ -8,21 +8,21 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -// StaticFeeMarket implements a static feemarket, where the minimum price per +// ValidatorTxFee implements a static feemarket, where the minimum price per // unit of gas is fixed and set by each validator. -type StaticFeeMarket struct{} +type ValidatorTxFee struct{} -var _ FeeMarket = StaticFeeMarket{} +var _ FeeMarket = ValidatorTxFee{} // AllowAuthExtensionOption returns true if the auth extension option should be allowed. -func (sfm StaticFeeMarket) AllowAuthExtensionOption(*codectypes.Any) bool { +func (sfm ValidatorTxFee) AllowAuthExtensionOption(*codectypes.Any) bool { return false } // CheckTxFee check if the provided fee is enough, if yes return the effective fee and priority, otherwise return // error. // The effective fee should be deducted later, and the priority should be set in the abci response. -func (sfm StaticFeeMarket) CheckTxFee(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) { +func (sfm ValidatorTxFee) CheckTxFee(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) { feeTx, ok := tx.(sdk.FeeTx) if !ok { return nil, 0, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx") @@ -51,13 +51,13 @@ func (sfm StaticFeeMarket) CheckTxFee(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, in } } - priority := GetTxPriority(feeCoins) + priority := getTxPriority(feeCoins) return feeCoins, priority, nil } -// GetTxPriority returns a naive tx priority based on the amount of the smallest denomination of the fee +// getTxPriority returns a naive tx priority based on the amount of the smallest denomination of the fee // provided in a transaction. -func GetTxPriority(fee sdk.Coins) int64 { +func getTxPriority(fee sdk.Coins) int64 { var priority int64 for _, c := range fee { p := int64(math.MaxInt64) From 6e2468fbd079467bb5c5f73acb6c228444646f15 Mon Sep 17 00:00:00 2001 From: HuangYi Date: Tue, 22 Mar 2022 18:18:24 +0800 Subject: [PATCH 09/22] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ff097f66d02..d3f7adae4b2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -140,7 +140,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/authz) [\#10447](https://github.com/cosmos/cosmos-sdk/pull/10447) authz `NewGrant` takes a new argument: block time, to correctly validate expire time. * [\#10961](https://github.com/cosmos/cosmos-sdk/pull/10961) Support third-party modules to add extension snapshots to state-sync. * [\#11274](https://github.com/cosmos/cosmos-sdk/pull/11274) `types/errors.New` now is an alias for `types/errors.Register` and should only be used in initialization code. -* (ante) [#11413](https://github.com/cosmos/cosmos-sdk/pull/11413) Refactor tx middleware to support pluggable feemarket module. The API breakages: a) Removed `MempoolFeeMiddleware` and `TxPriorityMiddleware`, the functionalities are moved into `DeductFeeMiddleware`, b) Added a `FeeMarket` field to `HandlerOptions`, and a `FeeMarket` parameter to `DeductFeeMiddleware`, when set to `StaticFeeMarket{}`, it'll keep the existing behavior, c) Added an `extention_options` field to `AuthInfo` in `Tx`, d) Added a `NewAuthExtensionOptionsMiddleware` middleware to check the `extension_options` field. +* (ante) [#11413](https://github.com/cosmos/cosmos-sdk/pull/11413) Refactor tx middleware to support pluggable feemarket module. Merged `MempoolFeeMiddleware` and `TxPriorityMiddleware` functionalities into `DeductFeeMiddleware`, so the potential feemarket module can implement these logic in one pass. Added a `FeeMarket` interface to plug-in different feemarket implementation in tx middleware, current fee logic is preserved by the default `ValidatorTxFee` implementation. Added an `extention_options` field to `AuthInfo`, so feemarket module can add extra fields to tx. ### Client Breaking Changes From a74ca398d33220ea4c7d7930b68cdcfac52e80cb Mon Sep 17 00:00:00 2001 From: HuangYi Date: Tue, 22 Mar 2022 18:42:42 +0800 Subject: [PATCH 10/22] make FeeMarket in TxHandlerOptions optional --- docs/architecture/adr-045-check-delivertx-middlewares.md | 1 + simapp/app.go | 1 - x/auth/middleware/middleware.go | 9 +++++++-- x/auth/middleware/middleware_test.go | 1 - x/auth/middleware/testutil_test.go | 1 - 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/architecture/adr-045-check-delivertx-middlewares.md b/docs/architecture/adr-045-check-delivertx-middlewares.md index bb108d401ea4..dfb03d705ebe 100644 --- a/docs/architecture/adr-045-check-delivertx-middlewares.md +++ b/docs/architecture/adr-045-check-delivertx-middlewares.md @@ -4,6 +4,7 @@ * 20.08.2021: Initial draft. * 07.12.2021: Update `tx.Handler` interface ([\#10693](https://github.com/cosmos/cosmos-sdk/pull/10693)). +* 22.03.2022: Update code snippets. ## Status diff --git a/simapp/app.go b/simapp/app.go index c4cd700401d7..8e9b94075df8 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -471,7 +471,6 @@ func (app *SimApp) setTxHandler(txConfig client.TxConfig, indexEventsStr []strin SignModeHandler: txConfig.SignModeHandler(), SigGasConsumer: authmiddleware.DefaultSigVerificationGasConsumer, TxDecoder: txConfig.TxDecoder(), - FeeMarket: authmiddleware.ValidatorTxFee{}, }) if err != nil { panic(err) diff --git a/x/auth/middleware/middleware.go b/x/auth/middleware/middleware.go index 46374c11e93d..54de03760070 100644 --- a/x/auth/middleware/middleware.go +++ b/x/auth/middleware/middleware.go @@ -75,6 +75,11 @@ func NewDefaultTxHandler(options TxHandlerOptions) (tx.Handler, error) { sigGasConsumer = DefaultSigVerificationGasConsumer } + var feeMarket = options.FeeMarket + if feeMarket == nil { + feeMarket = ValidatorTxFee{} + } + return ComposeMiddlewares( NewRunMsgsTxHandler(options.MsgServiceRouter, options.LegacyRouter), NewTxDecoderMiddleware(options.TxDecoder), @@ -94,7 +99,7 @@ func NewDefaultTxHandler(options TxHandlerOptions) (tx.Handler, error) { // tx. RejectExtensionOptionsMiddleware, // Reject auth_info extension options that don't pass the criteria. - NewAuthExtensionOptionsMiddleware(options.FeeMarket.AllowAuthExtensionOption), + NewAuthExtensionOptionsMiddleware(feeMarket.AllowAuthExtensionOption), ValidateBasicMiddleware, TxTimeoutHeightMiddleware, ValidateMemoMiddleware(options.AccountKeeper), @@ -103,7 +108,7 @@ func NewDefaultTxHandler(options TxHandlerOptions) (tx.Handler, error) { // ComposeMiddlewares godoc for details. // `DeductFeeMiddleware` and `IncrementSequenceMiddleware` should be put outside of `WithBranchedStore` middleware, // so their storage writes are not discarded when tx fails. - DeductFeeMiddleware(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.FeeMarket), + DeductFeeMiddleware(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, feeMarket), SetPubKeyMiddleware(options.AccountKeeper), ValidateSigCountMiddleware(options.AccountKeeper), SigGasConsumeMiddleware(options.AccountKeeper, sigGasConsumer), diff --git a/x/auth/middleware/middleware_test.go b/x/auth/middleware/middleware_test.go index 058b44ea890a..d923b84b2c3d 100644 --- a/x/auth/middleware/middleware_test.go +++ b/x/auth/middleware/middleware_test.go @@ -1026,7 +1026,6 @@ func (s *MWTestSuite) TestCustomSignatureVerificationGasConsumer() { } }, TxDecoder: s.clientCtx.TxConfig.TxDecoder(), - FeeMarket: middleware.ValidatorTxFee{}, }, ) s.Require().NoError(err) diff --git a/x/auth/middleware/testutil_test.go b/x/auth/middleware/testutil_test.go index 78d49fd9dbd7..f493a463fa2a 100644 --- a/x/auth/middleware/testutil_test.go +++ b/x/auth/middleware/testutil_test.go @@ -90,7 +90,6 @@ func (s *MWTestSuite) SetupTest(isCheckTx bool) sdk.Context { SignModeHandler: encodingConfig.TxConfig.SignModeHandler(), SigGasConsumer: middleware.DefaultSigVerificationGasConsumer, TxDecoder: s.clientCtx.TxConfig.TxDecoder(), - FeeMarket: middleware.ValidatorTxFee{}, }) s.Require().NoError(err) s.txHandler = txHandler From a1f5911a52cc4c967d0276de9ec07aed2ed55dbd Mon Sep 17 00:00:00 2001 From: yihuang Date: Tue, 22 Mar 2022 18:46:06 +0800 Subject: [PATCH 11/22] Apply suggestions from code review --- CHANGELOG.md | 2 +- docs/architecture/adr-045-check-delivertx-middlewares.md | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3f7adae4b2c..c46cd02f50ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -140,7 +140,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/authz) [\#10447](https://github.com/cosmos/cosmos-sdk/pull/10447) authz `NewGrant` takes a new argument: block time, to correctly validate expire time. * [\#10961](https://github.com/cosmos/cosmos-sdk/pull/10961) Support third-party modules to add extension snapshots to state-sync. * [\#11274](https://github.com/cosmos/cosmos-sdk/pull/11274) `types/errors.New` now is an alias for `types/errors.Register` and should only be used in initialization code. -* (ante) [#11413](https://github.com/cosmos/cosmos-sdk/pull/11413) Refactor tx middleware to support pluggable feemarket module. Merged `MempoolFeeMiddleware` and `TxPriorityMiddleware` functionalities into `DeductFeeMiddleware`, so the potential feemarket module can implement these logic in one pass. Added a `FeeMarket` interface to plug-in different feemarket implementation in tx middleware, current fee logic is preserved by the default `ValidatorTxFee` implementation. Added an `extention_options` field to `AuthInfo`, so feemarket module can add extra fields to tx. +* (ante) [#11413](https://github.com/cosmos/cosmos-sdk/pull/11413) Refactor tx middleware to support pluggable feemarket module. Merged `MempoolFeeMiddleware` and `TxPriorityMiddleware` functionalities into `DeductFeeMiddleware`, so the potential feemarket module can implement this logic in one pass. Added a `FeeMarket` interface to plug-in different feemarket implementation in tx middleware, the current fee logic is preserved by the default `ValidatorTxFee` implementation. Added an `extention_options` field to `AuthInfo`, so feemarket module can add extra fields to tx. ### Client Breaking Changes diff --git a/docs/architecture/adr-045-check-delivertx-middlewares.md b/docs/architecture/adr-045-check-delivertx-middlewares.md index dfb03d705ebe..bb108d401ea4 100644 --- a/docs/architecture/adr-045-check-delivertx-middlewares.md +++ b/docs/architecture/adr-045-check-delivertx-middlewares.md @@ -4,7 +4,6 @@ * 20.08.2021: Initial draft. * 07.12.2021: Update `tx.Handler` interface ([\#10693](https://github.com/cosmos/cosmos-sdk/pull/10693)). -* 22.03.2022: Update code snippets. ## Status From 93f13960cdc9fb4aaa169389f02f674c26db0dac Mon Sep 17 00:00:00 2001 From: HuangYi Date: Tue, 22 Mar 2022 20:02:09 +0800 Subject: [PATCH 12/22] remove extension options in AuthInfo --- api/cosmos/tx/v1beta1/tx.pulsar.go | 365 ++++++++------------------ proto/cosmos/tx/v1beta1/tx.proto | 5 - types/tx/tx.pb.go | 197 +++++--------- types/tx/types.go | 6 - x/auth/middleware/auth_ext.go | 83 ------ x/auth/middleware/ext.go | 45 ++-- x/auth/middleware/fee.go | 6 +- x/auth/middleware/middleware.go | 7 +- x/auth/middleware/validator_tx_fee.go | 4 +- x/auth/tx/legacy_amino_json.go | 5 - 10 files changed, 206 insertions(+), 517 deletions(-) delete mode 100644 x/auth/middleware/auth_ext.go diff --git a/api/cosmos/tx/v1beta1/tx.pulsar.go b/api/cosmos/tx/v1beta1/tx.pulsar.go index 7db7fdcf480a..d39c5e6efe46 100644 --- a/api/cosmos/tx/v1beta1/tx.pulsar.go +++ b/api/cosmos/tx/v1beta1/tx.pulsar.go @@ -3545,63 +3545,11 @@ func (x *_AuthInfo_1_list) IsValid() bool { return x.list != nil } -var _ protoreflect.List = (*_AuthInfo_1023_list)(nil) - -type _AuthInfo_1023_list struct { - list *[]*anypb.Any -} - -func (x *_AuthInfo_1023_list) Len() int { - if x.list == nil { - return 0 - } - return len(*x.list) -} - -func (x *_AuthInfo_1023_list) Get(i int) protoreflect.Value { - return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) -} - -func (x *_AuthInfo_1023_list) Set(i int, value protoreflect.Value) { - valueUnwrapped := value.Message() - concreteValue := valueUnwrapped.Interface().(*anypb.Any) - (*x.list)[i] = concreteValue -} - -func (x *_AuthInfo_1023_list) Append(value protoreflect.Value) { - valueUnwrapped := value.Message() - concreteValue := valueUnwrapped.Interface().(*anypb.Any) - *x.list = append(*x.list, concreteValue) -} - -func (x *_AuthInfo_1023_list) AppendMutable() protoreflect.Value { - v := new(anypb.Any) - *x.list = append(*x.list, v) - return protoreflect.ValueOfMessage(v.ProtoReflect()) -} - -func (x *_AuthInfo_1023_list) Truncate(n int) { - for i := n; i < len(*x.list); i++ { - (*x.list)[i] = nil - } - *x.list = (*x.list)[:n] -} - -func (x *_AuthInfo_1023_list) NewElement() protoreflect.Value { - v := new(anypb.Any) - return protoreflect.ValueOfMessage(v.ProtoReflect()) -} - -func (x *_AuthInfo_1023_list) IsValid() bool { - return x.list != nil -} - var ( - md_AuthInfo protoreflect.MessageDescriptor - fd_AuthInfo_signer_infos protoreflect.FieldDescriptor - fd_AuthInfo_fee protoreflect.FieldDescriptor - fd_AuthInfo_tip protoreflect.FieldDescriptor - fd_AuthInfo_extension_options protoreflect.FieldDescriptor + md_AuthInfo protoreflect.MessageDescriptor + fd_AuthInfo_signer_infos protoreflect.FieldDescriptor + fd_AuthInfo_fee protoreflect.FieldDescriptor + fd_AuthInfo_tip protoreflect.FieldDescriptor ) func init() { @@ -3610,7 +3558,6 @@ func init() { fd_AuthInfo_signer_infos = md_AuthInfo.Fields().ByName("signer_infos") fd_AuthInfo_fee = md_AuthInfo.Fields().ByName("fee") fd_AuthInfo_tip = md_AuthInfo.Fields().ByName("tip") - fd_AuthInfo_extension_options = md_AuthInfo.Fields().ByName("extension_options") } var _ protoreflect.Message = (*fastReflection_AuthInfo)(nil) @@ -3696,12 +3643,6 @@ func (x *fastReflection_AuthInfo) Range(f func(protoreflect.FieldDescriptor, pro return } } - if len(x.ExtensionOptions) != 0 { - value := protoreflect.ValueOfList(&_AuthInfo_1023_list{list: &x.ExtensionOptions}) - if !f(fd_AuthInfo_extension_options, value) { - return - } - } } // Has reports whether a field is populated. @@ -3723,8 +3664,6 @@ func (x *fastReflection_AuthInfo) Has(fd protoreflect.FieldDescriptor) bool { return x.Fee != nil case "cosmos.tx.v1beta1.AuthInfo.tip": return x.Tip != nil - case "cosmos.tx.v1beta1.AuthInfo.extension_options": - return len(x.ExtensionOptions) != 0 default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.tx.v1beta1.AuthInfo")) @@ -3747,8 +3686,6 @@ func (x *fastReflection_AuthInfo) Clear(fd protoreflect.FieldDescriptor) { x.Fee = nil case "cosmos.tx.v1beta1.AuthInfo.tip": x.Tip = nil - case "cosmos.tx.v1beta1.AuthInfo.extension_options": - x.ExtensionOptions = nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.tx.v1beta1.AuthInfo")) @@ -3777,12 +3714,6 @@ func (x *fastReflection_AuthInfo) Get(descriptor protoreflect.FieldDescriptor) p case "cosmos.tx.v1beta1.AuthInfo.tip": value := x.Tip return protoreflect.ValueOfMessage(value.ProtoReflect()) - case "cosmos.tx.v1beta1.AuthInfo.extension_options": - if len(x.ExtensionOptions) == 0 { - return protoreflect.ValueOfList(&_AuthInfo_1023_list{}) - } - listValue := &_AuthInfo_1023_list{list: &x.ExtensionOptions} - return protoreflect.ValueOfList(listValue) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.tx.v1beta1.AuthInfo")) @@ -3811,10 +3742,6 @@ func (x *fastReflection_AuthInfo) Set(fd protoreflect.FieldDescriptor, value pro x.Fee = value.Message().Interface().(*Fee) case "cosmos.tx.v1beta1.AuthInfo.tip": x.Tip = value.Message().Interface().(*Tip) - case "cosmos.tx.v1beta1.AuthInfo.extension_options": - lv := value.List() - clv := lv.(*_AuthInfo_1023_list) - x.ExtensionOptions = *clv.list default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.tx.v1beta1.AuthInfo")) @@ -3851,12 +3778,6 @@ func (x *fastReflection_AuthInfo) Mutable(fd protoreflect.FieldDescriptor) proto x.Tip = new(Tip) } return protoreflect.ValueOfMessage(x.Tip.ProtoReflect()) - case "cosmos.tx.v1beta1.AuthInfo.extension_options": - if x.ExtensionOptions == nil { - x.ExtensionOptions = []*anypb.Any{} - } - value := &_AuthInfo_1023_list{list: &x.ExtensionOptions} - return protoreflect.ValueOfList(value) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.tx.v1beta1.AuthInfo")) @@ -3879,9 +3800,6 @@ func (x *fastReflection_AuthInfo) NewField(fd protoreflect.FieldDescriptor) prot case "cosmos.tx.v1beta1.AuthInfo.tip": m := new(Tip) return protoreflect.ValueOfMessage(m.ProtoReflect()) - case "cosmos.tx.v1beta1.AuthInfo.extension_options": - list := []*anypb.Any{} - return protoreflect.ValueOfList(&_AuthInfo_1023_list{list: &list}) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.tx.v1beta1.AuthInfo")) @@ -3965,12 +3883,6 @@ func (x *fastReflection_AuthInfo) ProtoMethods() *protoiface.Methods { l = options.Size(x.Tip) n += 1 + l + runtime.Sov(uint64(l)) } - if len(x.ExtensionOptions) > 0 { - for _, e := range x.ExtensionOptions { - l = options.Size(e) - n += 2 + l + runtime.Sov(uint64(l)) - } - } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -4000,24 +3912,6 @@ func (x *fastReflection_AuthInfo) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if len(x.ExtensionOptions) > 0 { - for iNdEx := len(x.ExtensionOptions) - 1; iNdEx >= 0; iNdEx-- { - encoded, err := options.Marshal(x.ExtensionOptions[iNdEx]) - if err != nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) - i-- - dAtA[i] = 0x3f - i-- - dAtA[i] = 0xfa - } - } if x.Tip != nil { encoded, err := options.Marshal(x.Tip) if err != nil { @@ -4217,40 +4111,6 @@ func (x *fastReflection_AuthInfo) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } iNdEx = postIndex - case 1023: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ExtensionOptions", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if postIndex > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - x.ExtensionOptions = append(x.ExtensionOptions, &anypb.Any{}) - if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.ExtensionOptions[len(x.ExtensionOptions)-1]); err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -8642,10 +8502,6 @@ type AuthInfo struct { // // Since: cosmos-sdk 0.46 Tip *Tip `protobuf:"bytes,3,opt,name=tip,proto3" json:"tip,omitempty"` - // extension_options are arbitrary options that can be added by chains - // when the default options are not sufficient. If any of these are present - // and can't be handled, the transaction will be rejected - ExtensionOptions []*anypb.Any `protobuf:"bytes,1023,rep,name=extension_options,json=extensionOptions,proto3" json:"extension_options,omitempty"` } func (x *AuthInfo) Reset() { @@ -8689,13 +8545,6 @@ func (x *AuthInfo) GetTip() *Tip { return nil } -func (x *AuthInfo) GetExtensionOptions() []*anypb.Any { - if x != nil { - return x.ExtensionOptions - } - return nil -} - // SignerInfo describes the public key and signing mode of a single top-level // signer. type SignerInfo struct { @@ -9185,7 +9034,7 @@ var file_cosmos_tx_v1beta1_tx_proto_rawDesc = []byte{ 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x1b, 0x6e, 0x6f, 0x6e, 0x43, 0x72, 0x69, 0x74, 0x69, 0x63, 0x61, 0x6c, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x22, 0xe4, 0x01, 0x0a, 0x08, 0x41, 0x75, 0x74, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x40, + 0x73, 0x22, 0xa0, 0x01, 0x0a, 0x08, 0x41, 0x75, 0x74, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x40, 0x0a, 0x0c, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x49, @@ -9195,94 +9044,89 @@ var file_cosmos_tx_v1beta1_tx_proto_rawDesc = []byte{ 0x31, 0x2e, 0x46, 0x65, 0x65, 0x52, 0x03, 0x66, 0x65, 0x65, 0x12, 0x28, 0x0a, 0x03, 0x74, 0x69, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x54, 0x69, 0x70, 0x52, - 0x03, 0x74, 0x69, 0x70, 0x12, 0x42, 0x0a, 0x11, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, - 0x6e, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xff, 0x07, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x10, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, - 0x6e, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x97, 0x01, 0x0a, 0x0a, 0x53, 0x69, 0x67, - 0x6e, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x33, 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, - 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, - 0x79, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x38, 0x0a, 0x09, - 0x6d, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1b, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, - 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x6d, 0x6f, - 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, - 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, - 0x63, 0x65, 0x22, 0xe0, 0x02, 0x0a, 0x08, 0x4d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, - 0x3c, 0x0a, 0x06, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x22, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, - 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x53, 0x69, 0x6e, - 0x67, 0x6c, 0x65, 0x48, 0x00, 0x52, 0x06, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x12, 0x39, 0x0a, - 0x05, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0x2e, 0x4d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x48, - 0x00, 0x52, 0x05, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x1a, 0x41, 0x0a, 0x06, 0x53, 0x69, 0x6e, 0x67, - 0x6c, 0x65, 0x12, 0x37, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x23, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x73, 0x69, 0x67, - 0x6e, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, 0x69, 0x67, - 0x6e, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x1a, 0x90, 0x01, 0x0a, 0x05, - 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x12, 0x4b, 0x0a, 0x08, 0x62, 0x69, 0x74, 0x61, 0x72, 0x72, 0x61, - 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2e, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x73, 0x69, 0x67, - 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x63, 0x74, - 0x42, 0x69, 0x74, 0x41, 0x72, 0x72, 0x61, 0x79, 0x52, 0x08, 0x62, 0x69, 0x74, 0x61, 0x72, 0x72, - 0x61, 0x79, 0x12, 0x3a, 0x0a, 0x0a, 0x6d, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x73, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, - 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x6f, 0x64, 0x65, 0x49, - 0x6e, 0x66, 0x6f, 0x52, 0x09, 0x6d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x42, 0x05, - 0x0a, 0x03, 0x73, 0x75, 0x6d, 0x22, 0xeb, 0x01, 0x0a, 0x03, 0x46, 0x65, 0x65, 0x12, 0x63, 0x0a, - 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, - 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x30, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, - 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, - 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, - 0x6e, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x67, 0x61, 0x73, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x67, 0x61, 0x73, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, - 0x2e, 0x0a, 0x05, 0x70, 0x61, 0x79, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, - 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, - 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x05, 0x70, 0x61, 0x79, 0x65, 0x72, 0x12, - 0x32, 0x0a, 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, - 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x67, 0x72, 0x61, 0x6e, - 0x74, 0x65, 0x72, 0x22, 0x9c, 0x01, 0x0a, 0x03, 0x54, 0x69, 0x70, 0x12, 0x63, 0x0a, 0x06, 0x61, - 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x30, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, - 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, - 0x12, 0x30, 0x0a, 0x06, 0x74, 0x69, 0x70, 0x70, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x06, 0x74, 0x69, 0x70, 0x70, - 0x65, 0x72, 0x22, 0xce, 0x01, 0x0a, 0x0d, 0x41, 0x75, 0x78, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, - 0x44, 0x61, 0x74, 0x61, 0x12, 0x32, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, - 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x3e, 0x0a, 0x08, 0x73, 0x69, 0x67, 0x6e, - 0x5f, 0x64, 0x6f, 0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, - 0x69, 0x67, 0x6e, 0x44, 0x6f, 0x63, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x41, 0x75, 0x78, 0x52, - 0x07, 0x73, 0x69, 0x67, 0x6e, 0x44, 0x6f, 0x63, 0x12, 0x37, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, - 0x74, 0x78, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, - 0x61, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6d, 0x6f, 0x64, - 0x65, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x69, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, - 0x73, 0x69, 0x67, 0x42, 0xc4, 0x01, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x07, 0x54, - 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2f, 0x74, 0x78, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x74, 0x78, 0x76, - 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x54, 0x58, 0xaa, 0x02, 0x11, 0x43, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x54, 0x78, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0xca, 0x02, 0x11, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x54, 0x78, 0x5c, 0x56, 0x31, 0x62, - 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x1d, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x54, 0x78, - 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, - 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x54, - 0x78, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x03, 0x74, 0x69, 0x70, 0x22, 0x97, 0x01, 0x0a, 0x0a, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x49, + 0x6e, 0x66, 0x6f, 0x12, 0x33, 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x09, 0x70, + 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x38, 0x0a, 0x09, 0x6d, 0x6f, 0x64, 0x65, + 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, + 0x4d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x6d, 0x6f, 0x64, 0x65, 0x49, 0x6e, + 0x66, 0x6f, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x22, 0xe0, + 0x02, 0x0a, 0x08, 0x4d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x3c, 0x0a, 0x06, 0x73, + 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, + 0x4d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x48, + 0x00, 0x52, 0x06, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x12, 0x39, 0x0a, 0x05, 0x6d, 0x75, 0x6c, + 0x74, 0x69, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x6f, 0x64, + 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x48, 0x00, 0x52, 0x05, 0x6d, + 0x75, 0x6c, 0x74, 0x69, 0x1a, 0x41, 0x0a, 0x06, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x12, 0x37, + 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, + 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x4d, 0x6f, 0x64, + 0x65, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x1a, 0x90, 0x01, 0x0a, 0x05, 0x4d, 0x75, 0x6c, 0x74, + 0x69, 0x12, 0x4b, 0x0a, 0x08, 0x62, 0x69, 0x74, 0x61, 0x72, 0x72, 0x61, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x72, 0x79, + 0x70, 0x74, 0x6f, 0x2e, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x73, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x63, 0x74, 0x42, 0x69, 0x74, 0x41, + 0x72, 0x72, 0x61, 0x79, 0x52, 0x08, 0x62, 0x69, 0x74, 0x61, 0x72, 0x72, 0x61, 0x79, 0x12, 0x3a, + 0x0a, 0x0a, 0x6d, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x73, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, + 0x09, 0x6d, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x42, 0x05, 0x0a, 0x03, 0x73, 0x75, + 0x6d, 0x22, 0xeb, 0x01, 0x0a, 0x03, 0x46, 0x65, 0x65, 0x12, 0x63, 0x0a, 0x06, 0x61, 0x6d, 0x6f, + 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, + 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x30, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, + 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1b, + 0x0a, 0x09, 0x67, 0x61, 0x73, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x08, 0x67, 0x61, 0x73, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x2e, 0x0a, 0x05, 0x70, + 0x61, 0x79, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, + 0x72, 0x69, 0x6e, 0x67, 0x52, 0x05, 0x70, 0x61, 0x79, 0x65, 0x72, 0x12, 0x32, 0x0a, 0x07, 0x67, + 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, + 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, + 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72, 0x22, + 0x9c, 0x01, 0x0a, 0x03, 0x54, 0x69, 0x70, 0x12, 0x63, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, + 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, + 0x69, 0x6e, 0x42, 0x30, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, + 0x6f, 0x69, 0x6e, 0x73, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x30, 0x0a, 0x06, + 0x74, 0x69, 0x70, 0x70, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, + 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, + 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x06, 0x74, 0x69, 0x70, 0x70, 0x65, 0x72, 0x22, 0xce, + 0x01, 0x0a, 0x0d, 0x41, 0x75, 0x78, 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, + 0x12, 0x32, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x61, 0x64, 0x64, + 0x72, 0x65, 0x73, 0x73, 0x12, 0x3e, 0x0a, 0x08, 0x73, 0x69, 0x67, 0x6e, 0x5f, 0x64, 0x6f, 0x63, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x44, + 0x6f, 0x63, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x41, 0x75, 0x78, 0x52, 0x07, 0x73, 0x69, 0x67, + 0x6e, 0x44, 0x6f, 0x63, 0x12, 0x37, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x73, + 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, + 0x69, 0x67, 0x6e, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, + 0x03, 0x73, 0x69, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x73, 0x69, 0x67, 0x42, + 0xc4, 0x01, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, + 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, + 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, + 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x74, 0x78, + 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x74, 0x78, 0x76, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x54, 0x58, 0xaa, 0x02, 0x11, 0x43, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x54, 0x78, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x11, 0x43, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x54, 0x78, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0xe2, 0x02, 0x1d, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x54, 0x78, 0x5c, 0x56, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0xea, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x54, 0x78, 0x3a, 0x3a, 0x56, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -9328,23 +9172,22 @@ var file_cosmos_tx_v1beta1_tx_proto_depIdxs = []int32{ 6, // 7: cosmos.tx.v1beta1.AuthInfo.signer_infos:type_name -> cosmos.tx.v1beta1.SignerInfo 8, // 8: cosmos.tx.v1beta1.AuthInfo.fee:type_name -> cosmos.tx.v1beta1.Fee 9, // 9: cosmos.tx.v1beta1.AuthInfo.tip:type_name -> cosmos.tx.v1beta1.Tip - 13, // 10: cosmos.tx.v1beta1.AuthInfo.extension_options:type_name -> google.protobuf.Any - 13, // 11: cosmos.tx.v1beta1.SignerInfo.public_key:type_name -> google.protobuf.Any - 7, // 12: cosmos.tx.v1beta1.SignerInfo.mode_info:type_name -> cosmos.tx.v1beta1.ModeInfo - 11, // 13: cosmos.tx.v1beta1.ModeInfo.single:type_name -> cosmos.tx.v1beta1.ModeInfo.Single - 12, // 14: cosmos.tx.v1beta1.ModeInfo.multi:type_name -> cosmos.tx.v1beta1.ModeInfo.Multi - 14, // 15: cosmos.tx.v1beta1.Fee.amount:type_name -> cosmos.base.v1beta1.Coin - 14, // 16: cosmos.tx.v1beta1.Tip.amount:type_name -> cosmos.base.v1beta1.Coin - 3, // 17: cosmos.tx.v1beta1.AuxSignerData.sign_doc:type_name -> cosmos.tx.v1beta1.SignDocDirectAux - 15, // 18: cosmos.tx.v1beta1.AuxSignerData.mode:type_name -> cosmos.tx.signing.v1beta1.SignMode - 15, // 19: cosmos.tx.v1beta1.ModeInfo.Single.mode:type_name -> cosmos.tx.signing.v1beta1.SignMode - 16, // 20: cosmos.tx.v1beta1.ModeInfo.Multi.bitarray:type_name -> cosmos.crypto.multisig.v1beta1.CompactBitArray - 7, // 21: cosmos.tx.v1beta1.ModeInfo.Multi.mode_infos:type_name -> cosmos.tx.v1beta1.ModeInfo - 22, // [22:22] is the sub-list for method output_type - 22, // [22:22] is the sub-list for method input_type - 22, // [22:22] is the sub-list for extension type_name - 22, // [22:22] is the sub-list for extension extendee - 0, // [0:22] is the sub-list for field type_name + 13, // 10: cosmos.tx.v1beta1.SignerInfo.public_key:type_name -> google.protobuf.Any + 7, // 11: cosmos.tx.v1beta1.SignerInfo.mode_info:type_name -> cosmos.tx.v1beta1.ModeInfo + 11, // 12: cosmos.tx.v1beta1.ModeInfo.single:type_name -> cosmos.tx.v1beta1.ModeInfo.Single + 12, // 13: cosmos.tx.v1beta1.ModeInfo.multi:type_name -> cosmos.tx.v1beta1.ModeInfo.Multi + 14, // 14: cosmos.tx.v1beta1.Fee.amount:type_name -> cosmos.base.v1beta1.Coin + 14, // 15: cosmos.tx.v1beta1.Tip.amount:type_name -> cosmos.base.v1beta1.Coin + 3, // 16: cosmos.tx.v1beta1.AuxSignerData.sign_doc:type_name -> cosmos.tx.v1beta1.SignDocDirectAux + 15, // 17: cosmos.tx.v1beta1.AuxSignerData.mode:type_name -> cosmos.tx.signing.v1beta1.SignMode + 15, // 18: cosmos.tx.v1beta1.ModeInfo.Single.mode:type_name -> cosmos.tx.signing.v1beta1.SignMode + 16, // 19: cosmos.tx.v1beta1.ModeInfo.Multi.bitarray:type_name -> cosmos.crypto.multisig.v1beta1.CompactBitArray + 7, // 20: cosmos.tx.v1beta1.ModeInfo.Multi.mode_infos:type_name -> cosmos.tx.v1beta1.ModeInfo + 21, // [21:21] is the sub-list for method output_type + 21, // [21:21] is the sub-list for method input_type + 21, // [21:21] is the sub-list for extension type_name + 21, // [21:21] is the sub-list for extension extendee + 0, // [0:21] is the sub-list for field type_name } func init() { file_cosmos_tx_v1beta1_tx_proto_init() } diff --git a/proto/cosmos/tx/v1beta1/tx.proto b/proto/cosmos/tx/v1beta1/tx.proto index 9c04fb764aec..ac7b690f4661 100644 --- a/proto/cosmos/tx/v1beta1/tx.proto +++ b/proto/cosmos/tx/v1beta1/tx.proto @@ -142,11 +142,6 @@ message AuthInfo { // // Since: cosmos-sdk 0.46 Tip tip = 3; - - // extension_options are arbitrary options that can be added by chains - // when the default options are not sufficient. If any of these are present - // and can't be handled, the transaction will be rejected - repeated google.protobuf.Any extension_options = 1023; } // SignerInfo describes the public key and signing mode of a single top-level diff --git a/types/tx/tx.pb.go b/types/tx/tx.pb.go index 5203dcfd6481..d16c7898116b 100644 --- a/types/tx/tx.pb.go +++ b/types/tx/tx.pb.go @@ -455,10 +455,6 @@ type AuthInfo struct { // // Since: cosmos-sdk 0.46 Tip *Tip `protobuf:"bytes,3,opt,name=tip,proto3" json:"tip,omitempty"` - // extension_options are arbitrary options that can be added by chains - // when the default options are not sufficient. If any of these are present - // and can't be handled, the transaction will be rejected - ExtensionOptions []*types.Any `protobuf:"bytes,1023,rep,name=extension_options,json=extensionOptions,proto3" json:"extension_options,omitempty"` } func (m *AuthInfo) Reset() { *m = AuthInfo{} } @@ -515,13 +511,6 @@ func (m *AuthInfo) GetTip() *Tip { return nil } -func (m *AuthInfo) GetExtensionOptions() []*types.Any { - if m != nil { - return m.ExtensionOptions - } - return nil -} - // SignerInfo describes the public key and signing mode of a single top-level // signer. type SignerInfo struct { @@ -1023,71 +1012,71 @@ func init() { func init() { proto.RegisterFile("cosmos/tx/v1beta1/tx.proto", fileDescriptor_96d1575ffde80842) } var fileDescriptor_96d1575ffde80842 = []byte{ - // 1019 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0x4d, 0x6f, 0x1b, 0x45, - 0x18, 0xf6, 0x66, 0x6d, 0xc7, 0x7e, 0x9b, 0xf4, 0x63, 0x54, 0x21, 0xc7, 0x51, 0xdd, 0xb0, 0x55, - 0xc1, 0x97, 0xec, 0xa6, 0xe9, 0x81, 0x82, 0x10, 0x60, 0x37, 0x54, 0xa9, 0x4a, 0x41, 0x9a, 0xe4, - 0xd4, 0xcb, 0x6a, 0xbc, 0x9e, 0xac, 0x47, 0xf5, 0xce, 0x2c, 0x3b, 0xb3, 0x60, 0xff, 0x08, 0xa4, - 0x0a, 0x09, 0x71, 0xe1, 0x17, 0x70, 0xe6, 0x47, 0xf4, 0x84, 0x2a, 0x4e, 0x9c, 0xa0, 0x4a, 0xb8, - 0x21, 0xf1, 0x17, 0x40, 0x33, 0x3b, 0xbb, 0x49, 0x4b, 0x6a, 0x83, 0xa8, 0x38, 0xed, 0x7c, 0x3c, - 0xef, 0x33, 0xcf, 0xbc, 0xf3, 0xec, 0xfb, 0x42, 0x37, 0x12, 0x32, 0x11, 0x32, 0x50, 0xb3, 0xe0, - 0x8b, 0x5b, 0x23, 0xaa, 0xc8, 0xad, 0x40, 0xcd, 0xfc, 0x34, 0x13, 0x4a, 0xa0, 0x2b, 0xc5, 0x9e, - 0xaf, 0x66, 0xbe, 0xdd, 0xeb, 0x5e, 0x8d, 0x45, 0x2c, 0xcc, 0x6e, 0xa0, 0x47, 0x05, 0xb0, 0xbb, - 0x6d, 0x49, 0xa2, 0x6c, 0x9e, 0x2a, 0x11, 0x24, 0xf9, 0x54, 0x31, 0xc9, 0xe2, 0x8a, 0xb1, 0x5c, - 0xb0, 0xf0, 0x9e, 0x85, 0x8f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, 0x6d, 0x77, - 0xa0, 0xa9, 0x58, 0x9a, 0xd2, 0xac, 0xa8, 0x8d, 0x0b, 0xf4, 0x59, 0x9c, 0xf7, 0xa3, 0x03, 0xeb, - 0x83, 0x7c, 0x56, 0xfc, 0x8c, 0x7b, 0x44, 0x11, 0x7d, 0x49, 0x52, 0x40, 0x8d, 0x5b, 0x16, 0x5e, - 0xd2, 0x02, 0xd1, 0x07, 0xd0, 0xd2, 0x76, 0x0c, 0xc7, 0x22, 0xb2, 0x6e, 0xbf, 0xf1, 0x8a, 0x2a, - 0x75, 0xb6, 0xc3, 0xe1, 0x55, 0x69, 0x1b, 0x71, 0xe9, 0x72, 0xf7, 0x5f, 0xba, 0x1c, 0x5d, 0x06, - 0x57, 0xb2, 0xd8, 0xbc, 0xc6, 0x1a, 0xd6, 0xc3, 0xe1, 0x87, 0x4f, 0x8f, 0x7b, 0xce, 0xb3, 0xe3, - 0x9e, 0xf3, 0xfc, 0xb8, 0xe7, 0x3c, 0x39, 0xe9, 0xd5, 0x9e, 0x9d, 0xf4, 0x6a, 0x3f, 0x9f, 0xf4, - 0x6a, 0x8f, 0x6e, 0x2e, 0x4f, 0x67, 0xa0, 0x66, 0xa3, 0xa6, 0x29, 0x38, 0xb7, 0xff, 0x0a, 0x00, - 0x00, 0xff, 0xff, 0x54, 0xd9, 0xd3, 0xa0, 0x1c, 0x0a, 0x00, 0x00, + // 1015 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xf6, 0x66, 0x6d, 0xc7, 0x7e, 0x4d, 0xda, 0x74, 0x14, 0x21, 0xc7, 0x51, 0xdd, 0xe0, 0xaa, + 0xe0, 0x4b, 0x76, 0xd3, 0xf4, 0x40, 0x41, 0x08, 0xb0, 0x1b, 0xaa, 0x54, 0xa5, 0x20, 0x4d, 0x72, + 0xea, 0x65, 0x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x1a, 0xd6, 0xc3, 0xc1, 0x87, 0x4f, 0x4f, 0x3b, 0xce, 0xb3, 0xd3, 0x8e, 0xf3, 0xfc, 0xb4, + 0xe3, 0x3c, 0x39, 0xeb, 0x54, 0x9e, 0x9d, 0x75, 0x2a, 0xbf, 0x9c, 0x75, 0x2a, 0x8f, 0x6e, 0x2e, + 0xbf, 0x4e, 0x5f, 0x4d, 0x87, 0x75, 0xd3, 0x70, 0x6e, 0xff, 0x15, 0x00, 0x00, 0xff, 0xff, 0x4d, + 0x26, 0x62, 0x70, 0xd8, 0x09, 0x00, 0x00, } func (m *Tx) Marshal() (dAtA []byte, err error) { @@ -1413,22 +1402,6 @@ func (m *AuthInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.ExtensionOptions) > 0 { - for iNdEx := len(m.ExtensionOptions) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ExtensionOptions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3f - i-- - dAtA[i] = 0xfa - } - } if m.Tip != nil { { size, err := m.Tip.MarshalToSizedBuffer(dAtA[:i]) @@ -1993,12 +1966,6 @@ func (m *AuthInfo) Size() (n int) { l = m.Tip.Size() n += 1 + l + sovTx(uint64(l)) } - if len(m.ExtensionOptions) > 0 { - for _, e := range m.ExtensionOptions { - l = e.Size() - n += 2 + l + sovTx(uint64(l)) - } - } return n } @@ -3201,40 +3168,6 @@ func (m *AuthInfo) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 1023: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExtensionOptions", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ExtensionOptions = append(m.ExtensionOptions, &types.Any{}) - if err := m.ExtensionOptions[len(m.ExtensionOptions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/types/tx/types.go b/types/tx/types.go index cee28a4ce17f..006941b35f17 100644 --- a/types/tx/types.go +++ b/types/tx/types.go @@ -156,12 +156,6 @@ func (t *Tx) FeeGranter() sdk.AccAddress { return nil } -// AuthExtensionOptions returns the AuthInfo's ExtensionOptions, -// implements the interface HasAuthExtensionOptionsTx. -func (t *Tx) AuthExtensionOptions() []*codectypes.Any { - return t.AuthInfo.ExtensionOptions -} - // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method func (t *Tx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { if t.Body != nil { diff --git a/x/auth/middleware/auth_ext.go b/x/auth/middleware/auth_ext.go deleted file mode 100644 index a42cfabb95e3..000000000000 --- a/x/auth/middleware/auth_ext.go +++ /dev/null @@ -1,83 +0,0 @@ -package middleware - -import ( - "context" - - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/types/tx" -) - -// ExtensionOptionChecker is a function that returns true if the extension option is accepted. -type ExtensionOptionChecker func(*codectypes.Any) bool - -func rejectExtensionOption(*codectypes.Any) bool { - return false -} - -type HasAuthExtensionOptionsTx interface { - AuthExtensionOptions() []*codectypes.Any -} - -type checkAuthExtensionOptionsTxHandler struct { - next tx.Handler - checker ExtensionOptionChecker -} - -// NewAuthExtensionOptionsMiddleware creates a new checkAuthExtensionOptionsMiddleware. -// NewAuthExtensionOptionsMiddleware is a middleware that checks all auth_info extension -// options pass the checker. -// If checker is nil, it defaults to a function that rejects all extension options. -func NewAuthExtensionOptionsMiddleware(checker ExtensionOptionChecker) tx.Middleware { - if checker == nil { - checker = rejectExtensionOption - } - return func(next tx.Handler) tx.Handler { - return checkAuthExtensionOptionsTxHandler{ - next, - checker, - } - } -} - -var _ tx.Handler = checkAuthExtensionOptionsTxHandler{} - -func checkAuthExtOpts(tx sdk.Tx, checker ExtensionOptionChecker) error { - if hasExtOptsTx, ok := tx.(HasAuthExtensionOptionsTx); ok { - for _, opt := range hasExtOptsTx.AuthExtensionOptions() { - if !checker(opt) { - return sdkerrors.ErrInvalidRequest.Wrapf("Unknown auth extension option: %T", opt) - } - } - } - - return nil -} - -// CheckTx implements tx.Handler.CheckTx. -func (txh checkAuthExtensionOptionsTxHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { - if err := checkAuthExtOpts(req.Tx, txh.checker); err != nil { - return tx.Response{}, tx.ResponseCheckTx{}, err - } - - return txh.next.CheckTx(ctx, req, checkReq) -} - -// DeliverTx implements tx.Handler.DeliverTx. -func (txh checkAuthExtensionOptionsTxHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := checkAuthExtOpts(req.Tx, txh.checker); err != nil { - return tx.Response{}, err - } - - return txh.next.DeliverTx(ctx, req) -} - -// SimulateTx implements tx.Handler.SimulateTx method. -func (txh checkAuthExtensionOptionsTxHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := checkAuthExtOpts(req.Tx, txh.checker); err != nil { - return tx.Response{}, err - } - - return txh.next.SimulateTx(ctx, req) -} diff --git a/x/auth/middleware/ext.go b/x/auth/middleware/ext.go index 783c3bbc476b..0966a3da2c34 100644 --- a/x/auth/middleware/ext.go +++ b/x/auth/middleware/ext.go @@ -14,27 +14,42 @@ type HasExtensionOptionsTx interface { GetNonCriticalExtensionOptions() []*codectypes.Any } +// ExtensionOptionChecker is a function that returns true if the extension option is accepted. +type ExtensionOptionChecker func(*codectypes.Any) bool + +func rejectExtensionOption(*codectypes.Any) bool { + return false +} + type rejectExtensionOptionsTxHandler struct { - next tx.Handler + next tx.Handler + checker ExtensionOptionChecker } -// RejectExtensionOptionsMiddleware creates a new rejectExtensionOptionsMiddleware. -// rejectExtensionOptionsMiddleware is a middleware that rejects all extension -// options which can optionally be included in protobuf transactions. Users that -// need extension options should create a custom middleware chain that handles -// needed extension options properly and rejects unknown ones. -func RejectExtensionOptionsMiddleware(txh tx.Handler) tx.Handler { - return rejectExtensionOptionsTxHandler{ - next: txh, +// NewExtensionOptionsMiddleware creates a new middleware that rejects all extension +// options which can optionally be included in protobuf transactions that don't pass the checker. +// Users that need extension options should pass a custom checker that returns true for the +// needed extension options. +func NewExtensionOptionsMiddleware(checker ExtensionOptionChecker) tx.Middleware { + if checker == nil { + checker = rejectExtensionOption + } + return func(txh tx.Handler) tx.Handler { + return rejectExtensionOptionsTxHandler{ + next: txh, + checker: checker, + } } } var _ tx.Handler = rejectExtensionOptionsTxHandler{} -func checkExtOpts(tx sdk.Tx) error { +func checkExtOpts(tx sdk.Tx, checker ExtensionOptionChecker) error { if hasExtOptsTx, ok := tx.(HasExtensionOptionsTx); ok { - if len(hasExtOptsTx.GetExtensionOptions()) != 0 { - return sdkerrors.ErrUnknownExtensionOptions + for _, opt := range hasExtOptsTx.GetExtensionOptions() { + if !checker(opt) { + return sdkerrors.ErrUnknownExtensionOptions + } } } @@ -43,7 +58,7 @@ func checkExtOpts(tx sdk.Tx) error { // CheckTx implements tx.Handler.CheckTx. func (txh rejectExtensionOptionsTxHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { - if err := checkExtOpts(req.Tx); err != nil { + if err := checkExtOpts(req.Tx, txh.checker); err != nil { return tx.Response{}, tx.ResponseCheckTx{}, err } @@ -52,7 +67,7 @@ func (txh rejectExtensionOptionsTxHandler) CheckTx(ctx context.Context, req tx.R // DeliverTx implements tx.Handler.DeliverTx. func (txh rejectExtensionOptionsTxHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := checkExtOpts(req.Tx); err != nil { + if err := checkExtOpts(req.Tx, txh.checker); err != nil { return tx.Response{}, err } @@ -61,7 +76,7 @@ func (txh rejectExtensionOptionsTxHandler) DeliverTx(ctx context.Context, req tx // SimulateTx implements tx.Handler.SimulateTx method. func (txh rejectExtensionOptionsTxHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := checkExtOpts(req.Tx); err != nil { + if err := checkExtOpts(req.Tx, txh.checker); err != nil { return tx.Response{}, err } diff --git a/x/auth/middleware/fee.go b/x/auth/middleware/fee.go index d6d17a93e04f..ce21ef0b5bb3 100644 --- a/x/auth/middleware/fee.go +++ b/x/auth/middleware/fee.go @@ -13,9 +13,9 @@ import ( // FeeMarket defines the interface of feemarket system for tx middleware. type FeeMarket interface { - // AllowAuthExtensionOption returns true for allowed auth_info extension option, - // Some feemarket modules need to extend the auth_info. - AllowAuthExtensionOption(*codectypes.Any) bool + // AllowExtensionOption returns true for allowed extension option, + // Some feemarket modules need to extend the tx. + AllowExtensionOption(*codectypes.Any) bool // CheckTxFee check if the provided fee is enough and returns the effective fee and tx priority, // the effective fee should be deducted later, and the priority should be returned in abci response. CheckTxFee(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) diff --git a/x/auth/middleware/middleware.go b/x/auth/middleware/middleware.go index 54de03760070..23e061c369b0 100644 --- a/x/auth/middleware/middleware.go +++ b/x/auth/middleware/middleware.go @@ -95,11 +95,8 @@ func NewDefaultTxHandler(options TxHandlerOptions) (tx.Handler, error) { // Choose which events to index in Tendermint. Make sure no events are // emitted outside of this middleware. NewIndexEventsTxMiddleware(options.IndexEvents), - // Reject all extension options which can optionally be included in the - // tx. - RejectExtensionOptionsMiddleware, - // Reject auth_info extension options that don't pass the criteria. - NewAuthExtensionOptionsMiddleware(feeMarket.AllowAuthExtensionOption), + // Reject all extension options other than the ones needed by the feemarket. + NewExtensionOptionsMiddleware(feeMarket.AllowExtensionOption), ValidateBasicMiddleware, TxTimeoutHeightMiddleware, ValidateMemoMiddleware(options.AccountKeeper), diff --git a/x/auth/middleware/validator_tx_fee.go b/x/auth/middleware/validator_tx_fee.go index ac23456618b6..58ef78867d4e 100644 --- a/x/auth/middleware/validator_tx_fee.go +++ b/x/auth/middleware/validator_tx_fee.go @@ -14,8 +14,8 @@ type ValidatorTxFee struct{} var _ FeeMarket = ValidatorTxFee{} -// AllowAuthExtensionOption returns true if the auth extension option should be allowed. -func (sfm ValidatorTxFee) AllowAuthExtensionOption(*codectypes.Any) bool { +// AllowExtensionOption returns true if the auth extension option should be allowed. +func (sfm ValidatorTxFee) AllowExtensionOption(*codectypes.Any) bool { return false } diff --git a/x/auth/tx/legacy_amino_json.go b/x/auth/tx/legacy_amino_json.go index e953ebe39eb9..01274f9f6ed9 100644 --- a/x/auth/tx/legacy_amino_json.go +++ b/x/auth/tx/legacy_amino_json.go @@ -41,16 +41,11 @@ func (s signModeLegacyAminoJSONHandler) GetSignBytes(mode signingtypes.SignMode, } body := protoTx.tx.Body - authInfo := protoTx.tx.AuthInfo if len(body.ExtensionOptions) != 0 || len(body.NonCriticalExtensionOptions) != 0 { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "%s does not support protobuf extension options", signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON) } - if len(authInfo.ExtensionOptions) != 0 { - return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "%s does not support AuthInfo protobuf extension options", signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON) - } - addr := data.Address if addr == "" { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "got empty address in %s handler", signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON) From 12b95d23d858b78ec118ea3fd49681786d0b6d55 Mon Sep 17 00:00:00 2001 From: HuangYi Date: Tue, 22 Mar 2022 20:04:06 +0800 Subject: [PATCH 13/22] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3f7adae4b2c..4ec8bba64622 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -140,7 +140,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/authz) [\#10447](https://github.com/cosmos/cosmos-sdk/pull/10447) authz `NewGrant` takes a new argument: block time, to correctly validate expire time. * [\#10961](https://github.com/cosmos/cosmos-sdk/pull/10961) Support third-party modules to add extension snapshots to state-sync. * [\#11274](https://github.com/cosmos/cosmos-sdk/pull/11274) `types/errors.New` now is an alias for `types/errors.Register` and should only be used in initialization code. -* (ante) [#11413](https://github.com/cosmos/cosmos-sdk/pull/11413) Refactor tx middleware to support pluggable feemarket module. Merged `MempoolFeeMiddleware` and `TxPriorityMiddleware` functionalities into `DeductFeeMiddleware`, so the potential feemarket module can implement these logic in one pass. Added a `FeeMarket` interface to plug-in different feemarket implementation in tx middleware, current fee logic is preserved by the default `ValidatorTxFee` implementation. Added an `extention_options` field to `AuthInfo`, so feemarket module can add extra fields to tx. +* (ante) [#11413](https://github.com/cosmos/cosmos-sdk/pull/11413) Refactor tx middleware to support pluggable feemarket module. Merged `MempoolFeeMiddleware` and `TxPriorityMiddleware` functionalities into `DeductFeeMiddleware`, so the potential feemarket module can implement these logic in one pass. Added a `FeeMarket` interface to plug-in different feemarket implementation in tx middleware, current fee logic is preserved by the default `ValidatorTxFee` implementation. Change `RejectExtensionOptionsMiddleware` to `NewExtensionOptionsMiddleware` to allow extension options needed by feemarket. ### Client Breaking Changes From 75ae1ee237152650938db15bbc71f5423ef52798 Mon Sep 17 00:00:00 2001 From: HuangYi Date: Tue, 22 Mar 2022 20:23:04 +0800 Subject: [PATCH 14/22] fix extension option middleware unit tests --- x/auth/middleware/ext_test.go | 58 +++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/x/auth/middleware/ext_test.go b/x/auth/middleware/ext_test.go index ec57f722c893..8304c8345850 100644 --- a/x/auth/middleware/ext_test.go +++ b/x/auth/middleware/ext_test.go @@ -2,6 +2,7 @@ package middleware_test import ( "github.com/cosmos/cosmos-sdk/codec/types" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" typestx "github.com/cosmos/cosmos-sdk/types/tx" @@ -9,28 +10,45 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/tx" ) -func (s *MWTestSuite) TestRejectExtensionOptionsMiddleware() { - ctx := s.SetupTest(true) // setup - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() +func (s *MWTestSuite) TestExtensionOptionsMiddleware() { + testCases := []struct { + msg string + allow bool + }{ + {"reject extension", true}, + {"allow extension", false}, + } + for _, tc := range testCases { + s.Run(tc.msg, func() { + ctx := s.SetupTest(true) // setup + txBuilder := s.clientCtx.TxConfig.NewTxBuilder() - txHandler := middleware.ComposeMiddlewares(noopTxHandler, middleware.RejectExtensionOptionsMiddleware) + txHandler := middleware.ComposeMiddlewares(noopTxHandler, middleware.NewExtensionOptionsMiddleware(func(_ *codectypes.Any) bool { + return tc.allow + })) - // no extension options should not trigger an error - theTx := txBuilder.GetTx() - _, _, err := txHandler.CheckTx(sdk.WrapSDKContext(ctx), typestx.Request{Tx: theTx}, typestx.RequestCheckTx{}) - s.Require().NoError(err) + // no extension options should not trigger an error + theTx := txBuilder.GetTx() + _, _, err := txHandler.CheckTx(sdk.WrapSDKContext(ctx), typestx.Request{Tx: theTx}, typestx.RequestCheckTx{}) + s.Require().NoError(err) - extOptsTxBldr, ok := txBuilder.(tx.ExtensionOptionsTxBuilder) - if !ok { - // if we can't set extension options, this middleware doesn't apply and we're done - return - } + extOptsTxBldr, ok := txBuilder.(tx.ExtensionOptionsTxBuilder) + if !ok { + // if we can't set extension options, this middleware doesn't apply and we're done + return + } - // setting any extension option should cause an error - any, err := types.NewAnyWithValue(testdata.NewTestMsg()) - s.Require().NoError(err) - extOptsTxBldr.SetExtensionOptions(any) - theTx = txBuilder.GetTx() - _, _, err = txHandler.CheckTx(sdk.WrapSDKContext(ctx), typestx.Request{Tx: theTx}, typestx.RequestCheckTx{}) - s.Require().EqualError(err, "unknown extension options") + // setting any extension option should cause an error + any, err := types.NewAnyWithValue(testdata.NewTestMsg()) + s.Require().NoError(err) + extOptsTxBldr.SetExtensionOptions(any) + theTx = txBuilder.GetTx() + _, _, err = txHandler.CheckTx(sdk.WrapSDKContext(ctx), typestx.Request{Tx: theTx}, typestx.RequestCheckTx{}) + if tc.allow { + s.Require().NoError(err) + } else { + s.Require().EqualError(err, "unknown extension options") + } + }) + } } From 1c66c622c0874d5704bbb0e389dc7ff0b8dc82a2 Mon Sep 17 00:00:00 2001 From: yihuang Date: Wed, 23 Mar 2022 09:09:42 +0800 Subject: [PATCH 15/22] update comments --- x/auth/middleware/ext_test.go | 6 +++--- x/auth/middleware/validator_tx_fee.go | 6 +++--- x/auth/tx/legacy_amino_json_test.go | 11 ----------- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/x/auth/middleware/ext_test.go b/x/auth/middleware/ext_test.go index 8304c8345850..27c294794cfb 100644 --- a/x/auth/middleware/ext_test.go +++ b/x/auth/middleware/ext_test.go @@ -15,8 +15,8 @@ func (s *MWTestSuite) TestExtensionOptionsMiddleware() { msg string allow bool }{ - {"reject extension", true}, - {"allow extension", false}, + {"allow extension", true}, + {"reject extension", false}, } for _, tc := range testCases { s.Run(tc.msg, func() { @@ -38,7 +38,7 @@ func (s *MWTestSuite) TestExtensionOptionsMiddleware() { return } - // setting any extension option should cause an error + // set an extension option and check any, err := types.NewAnyWithValue(testdata.NewTestMsg()) s.Require().NoError(err) extOptsTxBldr.SetExtensionOptions(any) diff --git a/x/auth/middleware/validator_tx_fee.go b/x/auth/middleware/validator_tx_fee.go index 58ef78867d4e..5ba4c3550675 100644 --- a/x/auth/middleware/validator_tx_fee.go +++ b/x/auth/middleware/validator_tx_fee.go @@ -8,13 +8,13 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -// ValidatorTxFee implements a static feemarket, where the minimum price per -// unit of gas is fixed and set by each validator. +// ValidatorTxFee implements the default fee logic, where the minimum price per +// unit of gas is fixed and set by each validator, can the tx priority is computed from the gas price. type ValidatorTxFee struct{} var _ FeeMarket = ValidatorTxFee{} -// AllowExtensionOption returns true if the auth extension option should be allowed. +// AllowExtensionOption should return true if the auth extension option should be allowed. func (sfm ValidatorTxFee) AllowExtensionOption(*codectypes.Any) bool { return false } diff --git a/x/auth/tx/legacy_amino_json_test.go b/x/auth/tx/legacy_amino_json_test.go index 1cbc10f3e89a..7df42f92b13d 100644 --- a/x/auth/tx/legacy_amino_json_test.go +++ b/x/auth/tx/legacy_amino_json_test.go @@ -136,17 +136,6 @@ func TestLegacyAminoJSONHandler_GetSignBytes(t *testing.T) { tx = bldr.GetTx() _, err = handler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signingData, tx) require.Error(t, err) - - // expect error with AuthInfo extension options - bldr = newBuilder(nil) - buildTx(t, bldr) - any, err = cdctypes.NewAnyWithValue(testdata.NewTestMsg()) - require.NoError(t, err) - bldr.tx.AuthInfo.ExtensionOptions = []*cdctypes.Any{any} - tx = bldr.GetTx() - _, err = handler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signingData, tx) - require.Error(t, err) - } func TestLegacyAminoJSONHandler_DefaultMode(t *testing.T) { From 2585d4550654b06eae788c3a66deddfc5072e526 Mon Sep 17 00:00:00 2001 From: yihuang Date: Fri, 25 Mar 2022 18:26:23 +0800 Subject: [PATCH 16/22] Update x/auth/middleware/ext.go Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com> --- x/auth/middleware/ext.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x/auth/middleware/ext.go b/x/auth/middleware/ext.go index 0966a3da2c34..5159e3c5f1f8 100644 --- a/x/auth/middleware/ext.go +++ b/x/auth/middleware/ext.go @@ -17,6 +17,8 @@ type HasExtensionOptionsTx interface { // ExtensionOptionChecker is a function that returns true if the extension option is accepted. type ExtensionOptionChecker func(*codectypes.Any) bool +// rejectExtensionOption is the default extension check that reject all tx +// extensions. func rejectExtensionOption(*codectypes.Any) bool { return false } From 78817e2431ff646b02b5ea73b6f48b0950273892 Mon Sep 17 00:00:00 2001 From: yihuang Date: Tue, 29 Mar 2022 16:06:45 +0800 Subject: [PATCH 17/22] Update CHANGELOG.md Co-authored-by: Aaron Craelius --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b1eeaf233a4..dfac92ca9e0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -145,7 +145,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [\#10961](https://github.com/cosmos/cosmos-sdk/pull/10961) Support third-party modules to add extension snapshots to state-sync. * [\#11274](https://github.com/cosmos/cosmos-sdk/pull/11274) `types/errors.New` now is an alias for `types/errors.Register` and should only be used in initialization code. * (authz)[\#11060](https://github.com/cosmos/cosmos-sdk/pull/11060) `authz.NewMsgGrant` `expiration` is now a pointer. When `nil` is used then no expiration will be set (grant won't expire). -* (ante) [#11413](https://github.com/cosmos/cosmos-sdk/pull/11413) Refactor tx middleware to support pluggable feemarket module. Merged `MempoolFeeMiddleware` and `TxPriorityMiddleware` functionalities into `DeductFeeMiddleware`, so the potential feemarket module can implement these logics in one pass. Added a `FeeMarket` interface to plugin custom feemarket implementation in tx middleware, the current fee logic is preserved by the default `ValidatorTxFee` implementation. Change `RejectExtensionOptionsMiddleware` to `NewExtensionOptionsMiddleware` to allow extension options needed by feemarket. +* (x/auth/middleware) [#11413](https://github.com/cosmos/cosmos-sdk/pull/11413) Refactor tx middleware to support pluggable feemarket module. Merged `MempoolFeeMiddleware` and `TxPriorityMiddleware` functionalities into `DeductFeeMiddleware`, so the potential feemarket module can implement these logics in one pass. Added a `FeeMarket` interface to plugin custom feemarket implementation in tx middleware, the current fee logic is preserved by the default `ValidatorTxFee` implementation. Change `RejectExtensionOptionsMiddleware` to `NewExtensionOptionsMiddleware` to allow extension options needed by feemarket. ### Client Breaking Changes From 5b79cc8bef38b60655f9428a6a603497755f4909 Mon Sep 17 00:00:00 2001 From: HuangYi Date: Tue, 29 Mar 2022 16:21:24 +0800 Subject: [PATCH 18/22] remove FeeMarket interface --- x/auth/middleware/branch_store_test.go | 2 +- x/auth/middleware/fee.go | 19 +++++++++++------ x/auth/middleware/fee_test.go | 4 ++-- x/auth/middleware/feegrant_test.go | 2 +- x/auth/middleware/middleware.go | 28 ++++++++++++++++---------- x/auth/middleware/validator_tx_fee.go | 19 +++-------------- 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/x/auth/middleware/branch_store_test.go b/x/auth/middleware/branch_store_test.go index c8b547526a3e..80e116fb2a82 100644 --- a/x/auth/middleware/branch_store_test.go +++ b/x/auth/middleware/branch_store_test.go @@ -72,7 +72,7 @@ func (s *MWTestSuite) TestBranchStore() { middleware.NewTxDecoderMiddleware(s.clientCtx.TxConfig.TxDecoder()), middleware.GasTxMiddleware, middleware.RecoveryTxMiddleware, - middleware.DeductFeeMiddleware(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, middleware.ValidatorTxFee{}), + middleware.DeductFeeMiddleware(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, nil), middleware.IncrementSequenceMiddleware(s.app.AccountKeeper), middleware.WithBranchedStore, middleware.ConsumeBlockGasMiddleware, diff --git a/x/auth/middleware/fee.go b/x/auth/middleware/fee.go index ce21ef0b5bb3..e21d8d790090 100644 --- a/x/auth/middleware/fee.go +++ b/x/auth/middleware/fee.go @@ -21,13 +21,17 @@ type FeeMarket interface { CheckTxFee(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) } +// TxFeeChecker check if the provided fee is enough and returns the effective fee and tx priority, +// the effective fee should be deducted later, and the priority should be returned in abci response. +type TxFeeChecker func(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) + var _ tx.Handler = deductFeeTxHandler{} type deductFeeTxHandler struct { accountKeeper AccountKeeper bankKeeper types.BankKeeper feegrantKeeper FeegrantKeeper - feemarket FeeMarket + txFeeChecker TxFeeChecker next tx.Handler } @@ -35,13 +39,16 @@ type deductFeeTxHandler struct { // If the first signer does not have the funds to pay for the fees, return with InsufficientFunds error // Call next middleware if fees successfully deducted // CONTRACT: Tx must implement FeeTx interface to use deductFeeTxHandler -func DeductFeeMiddleware(ak AccountKeeper, bk types.BankKeeper, fk FeegrantKeeper, fm FeeMarket) tx.Middleware { +func DeductFeeMiddleware(ak AccountKeeper, bk types.BankKeeper, fk FeegrantKeeper, tfc TxFeeChecker) tx.Middleware { + if tfc == nil { + tfc = checkTxFeeWithValidatorMinGasPrices + } return func(txh tx.Handler) tx.Handler { return deductFeeTxHandler{ accountKeeper: ak, bankKeeper: bk, feegrantKeeper: fk, - feemarket: fm, + txFeeChecker: tfc, next: txh, } } @@ -100,7 +107,7 @@ func (dfd deductFeeTxHandler) checkDeductFee(ctx sdk.Context, sdkTx sdk.Tx, fee // CheckTx implements tx.Handler.CheckTx. func (dfd deductFeeTxHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) - fee, priority, err := dfd.feemarket.CheckTxFee(sdkCtx, req.Tx) + fee, priority, err := dfd.txFeeChecker(sdkCtx, req.Tx) if err != nil { return tx.Response{}, tx.ResponseCheckTx{}, err } @@ -117,7 +124,7 @@ func (dfd deductFeeTxHandler) CheckTx(ctx context.Context, req tx.Request, check // DeliverTx implements tx.Handler.DeliverTx. func (dfd deductFeeTxHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) - fee, _, err := dfd.feemarket.CheckTxFee(sdkCtx, req.Tx) + fee, _, err := dfd.txFeeChecker(sdkCtx, req.Tx) if err != nil { return tx.Response{}, err } @@ -130,7 +137,7 @@ func (dfd deductFeeTxHandler) DeliverTx(ctx context.Context, req tx.Request) (tx func (dfd deductFeeTxHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) - fee, _, err := dfd.feemarket.CheckTxFee(sdkCtx, req.Tx) + fee, _, err := dfd.txFeeChecker(sdkCtx, req.Tx) if err != nil { return tx.Response{}, err } diff --git a/x/auth/middleware/fee_test.go b/x/auth/middleware/fee_test.go index 6fae0325c2cf..7c1f54463fff 100644 --- a/x/auth/middleware/fee_test.go +++ b/x/auth/middleware/fee_test.go @@ -17,7 +17,7 @@ func (s *MWTestSuite) TestEnsureMempoolFees() { s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, - middleware.ValidatorTxFee{}, + nil, )) // keys and addresses @@ -74,7 +74,7 @@ func (s *MWTestSuite) TestDeductFees() { s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, - middleware.ValidatorTxFee{}, + nil, ), ) diff --git a/x/auth/middleware/feegrant_test.go b/x/auth/middleware/feegrant_test.go index cc91f80f4371..547f57a589d1 100644 --- a/x/auth/middleware/feegrant_test.go +++ b/x/auth/middleware/feegrant_test.go @@ -36,7 +36,7 @@ func (s *MWTestSuite) TestDeductFeesNoDelegation() { s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, - middleware.ValidatorTxFee{}, + nil, ), ) diff --git a/x/auth/middleware/middleware.go b/x/auth/middleware/middleware.go index 23e061c369b0..a3fb30b0d6ae 100644 --- a/x/auth/middleware/middleware.go +++ b/x/auth/middleware/middleware.go @@ -43,12 +43,13 @@ type TxHandlerOptions struct { LegacyRouter sdk.Router MsgServiceRouter *MsgServiceRouter - AccountKeeper AccountKeeper - BankKeeper types.BankKeeper - FeegrantKeeper FeegrantKeeper - SignModeHandler authsigning.SignModeHandler - SigGasConsumer func(meter sdk.GasMeter, sig signing.SignatureV2, params types.Params) error - FeeMarket FeeMarket + AccountKeeper AccountKeeper + BankKeeper types.BankKeeper + FeegrantKeeper FeegrantKeeper + SignModeHandler authsigning.SignModeHandler + SigGasConsumer func(meter sdk.GasMeter, sig signing.SignatureV2, params types.Params) error + ExtensionOptionChecker ExtensionOptionChecker + TxFeeChecker TxFeeChecker } // NewDefaultTxHandler defines a TxHandler middleware stacks that should work @@ -75,9 +76,14 @@ func NewDefaultTxHandler(options TxHandlerOptions) (tx.Handler, error) { sigGasConsumer = DefaultSigVerificationGasConsumer } - var feeMarket = options.FeeMarket - if feeMarket == nil { - feeMarket = ValidatorTxFee{} + var extensionOptionChecker = options.ExtensionOptionChecker + if extensionOptionChecker == nil { + extensionOptionChecker = rejectExtensionOption + } + + var txFeeChecker = options.TxFeeChecker + if txFeeChecker == nil { + txFeeChecker = checkTxFeeWithValidatorMinGasPrices } return ComposeMiddlewares( @@ -96,7 +102,7 @@ func NewDefaultTxHandler(options TxHandlerOptions) (tx.Handler, error) { // emitted outside of this middleware. NewIndexEventsTxMiddleware(options.IndexEvents), // Reject all extension options other than the ones needed by the feemarket. - NewExtensionOptionsMiddleware(feeMarket.AllowExtensionOption), + NewExtensionOptionsMiddleware(extensionOptionChecker), ValidateBasicMiddleware, TxTimeoutHeightMiddleware, ValidateMemoMiddleware(options.AccountKeeper), @@ -105,7 +111,7 @@ func NewDefaultTxHandler(options TxHandlerOptions) (tx.Handler, error) { // ComposeMiddlewares godoc for details. // `DeductFeeMiddleware` and `IncrementSequenceMiddleware` should be put outside of `WithBranchedStore` middleware, // so their storage writes are not discarded when tx fails. - DeductFeeMiddleware(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, feeMarket), + DeductFeeMiddleware(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, txFeeChecker), SetPubKeyMiddleware(options.AccountKeeper), ValidateSigCountMiddleware(options.AccountKeeper), SigGasConsumeMiddleware(options.AccountKeeper, sigGasConsumer), diff --git a/x/auth/middleware/validator_tx_fee.go b/x/auth/middleware/validator_tx_fee.go index 58ef78867d4e..d0711f265ae2 100644 --- a/x/auth/middleware/validator_tx_fee.go +++ b/x/auth/middleware/validator_tx_fee.go @@ -3,26 +3,13 @@ package middleware import ( "math" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -// ValidatorTxFee implements a static feemarket, where the minimum price per -// unit of gas is fixed and set by each validator. -type ValidatorTxFee struct{} - -var _ FeeMarket = ValidatorTxFee{} - -// AllowExtensionOption returns true if the auth extension option should be allowed. -func (sfm ValidatorTxFee) AllowExtensionOption(*codectypes.Any) bool { - return false -} - -// CheckTxFee check if the provided fee is enough, if yes return the effective fee and priority, otherwise return -// error. -// The effective fee should be deducted later, and the priority should be set in the abci response. -func (sfm ValidatorTxFee) CheckTxFee(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) { +// checkTxFeeWithValidatorMinGasPrices check if the provided fee against the min-gas-prices configured by validator, +// if enough return the specified fee as effective fee, and convert the price amount to tx priority. +func checkTxFeeWithValidatorMinGasPrices(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) { feeTx, ok := tx.(sdk.FeeTx) if !ok { return nil, 0, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx") From 9a2bbedebff61c2940c4fb98860dbd674a354c7a Mon Sep 17 00:00:00 2001 From: yihuang Date: Tue, 29 Mar 2022 16:31:17 +0800 Subject: [PATCH 19/22] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf2af4714267..025003012202 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -148,7 +148,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [\#11274](https://github.com/cosmos/cosmos-sdk/pull/11274) `types/errors.New` now is an alias for `types/errors.Register` and should only be used in initialization code. * (authz)[\#11060](https://github.com/cosmos/cosmos-sdk/pull/11060) `authz.NewMsgGrant` `expiration` is now a pointer. When `nil` is used then no expiration will be set (grant won't expire). * (x/distribution)[\#11457](https://github.com/cosmos/cosmos-sdk/pull/11457) Add amount field to `distr.MsgWithdrawDelegatorRewardResponse` and `distr.MsgWithdrawValidatorCommissionResponse`. -* (x/auth/middleware) [#11413](https://github.com/cosmos/cosmos-sdk/pull/11413) Refactor tx middleware to be extensible on tx fee logic. Merged `MempoolFeeMiddleware` and `TxPriorityMiddleware` functionalities into `DeductFeeMiddleware`, make the logic extensible using the `TxFeeChecker` option, the current fee logic is preserved by the default `checkTxFeeWithValidatorMinGasPrices` implementation. Change `RejectExtensionOptionsMiddleware` to `NewExtensionOptionsMiddleware` which is extension with the `ExtensionOptionChecker` option. +* (x/auth/middleware) [#11413](https://github.com/cosmos/cosmos-sdk/pull/11413) Refactor tx middleware to be extensible on tx fee logic. Merged `MempoolFeeMiddleware` and `TxPriorityMiddleware` functionalities into `DeductFeeMiddleware`, make the logic extensible using the `TxFeeChecker` option, the current fee logic is preserved by the default `checkTxFeeWithValidatorMinGasPrices` implementation. Change `RejectExtensionOptionsMiddleware` to `NewExtensionOptionsMiddleware` which is extensible with the `ExtensionOptionChecker` option. ### Client Breaking Changes From 14ce986a647dfd1a1292b9673ef2dd9d5ccc188b Mon Sep 17 00:00:00 2001 From: HuangYi Date: Tue, 29 Mar 2022 16:31:26 +0800 Subject: [PATCH 20/22] remove FeeMarket interface --- x/auth/middleware/fee.go | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/x/auth/middleware/fee.go b/x/auth/middleware/fee.go index e21d8d790090..2ae83c37269e 100644 --- a/x/auth/middleware/fee.go +++ b/x/auth/middleware/fee.go @@ -4,23 +4,12 @@ import ( "context" "fmt" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/tx" "github.com/cosmos/cosmos-sdk/x/auth/types" ) -// FeeMarket defines the interface of feemarket system for tx middleware. -type FeeMarket interface { - // AllowExtensionOption returns true for allowed extension option, - // Some feemarket modules need to extend the tx. - AllowExtensionOption(*codectypes.Any) bool - // CheckTxFee check if the provided fee is enough and returns the effective fee and tx priority, - // the effective fee should be deducted later, and the priority should be returned in abci response. - CheckTxFee(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) -} - // TxFeeChecker check if the provided fee is enough and returns the effective fee and tx priority, // the effective fee should be deducted later, and the priority should be returned in abci response. type TxFeeChecker func(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) From 0b939140b3abaf617d2e617b85986cc7b7da0788 Mon Sep 17 00:00:00 2001 From: HuangYi Date: Tue, 29 Mar 2022 18:32:55 +0800 Subject: [PATCH 21/22] unpack extension options Any's --- CHANGELOG.md | 2 +- types/tx/ext.go | 21 +++++++++++++++++++++ types/tx/types.go | 16 +++++++++++++++- 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 types/tx/ext.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 025003012202..530968a4afcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -148,7 +148,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [\#11274](https://github.com/cosmos/cosmos-sdk/pull/11274) `types/errors.New` now is an alias for `types/errors.Register` and should only be used in initialization code. * (authz)[\#11060](https://github.com/cosmos/cosmos-sdk/pull/11060) `authz.NewMsgGrant` `expiration` is now a pointer. When `nil` is used then no expiration will be set (grant won't expire). * (x/distribution)[\#11457](https://github.com/cosmos/cosmos-sdk/pull/11457) Add amount field to `distr.MsgWithdrawDelegatorRewardResponse` and `distr.MsgWithdrawValidatorCommissionResponse`. -* (x/auth/middleware) [#11413](https://github.com/cosmos/cosmos-sdk/pull/11413) Refactor tx middleware to be extensible on tx fee logic. Merged `MempoolFeeMiddleware` and `TxPriorityMiddleware` functionalities into `DeductFeeMiddleware`, make the logic extensible using the `TxFeeChecker` option, the current fee logic is preserved by the default `checkTxFeeWithValidatorMinGasPrices` implementation. Change `RejectExtensionOptionsMiddleware` to `NewExtensionOptionsMiddleware` which is extensible with the `ExtensionOptionChecker` option. +* (x/auth/middleware) [#11413](https://github.com/cosmos/cosmos-sdk/pull/11413) Refactor tx middleware to be extensible on tx fee logic. Merged `MempoolFeeMiddleware` and `TxPriorityMiddleware` functionalities into `DeductFeeMiddleware`, make the logic extensible using the `TxFeeChecker` option, the current fee logic is preserved by the default `checkTxFeeWithValidatorMinGasPrices` implementation. Change `RejectExtensionOptionsMiddleware` to `NewExtensionOptionsMiddleware` which is extensible with the `ExtensionOptionChecker` option. Unpack the tx extension options `Any`s to interface `TxExtensionOptionI`. ### Client Breaking Changes diff --git a/types/tx/ext.go b/types/tx/ext.go new file mode 100644 index 000000000000..28c1358649d8 --- /dev/null +++ b/types/tx/ext.go @@ -0,0 +1,21 @@ +package tx + +import ( + "github.com/cosmos/cosmos-sdk/codec/types" +) + +// TxExtensionOptionI defines the interface for tx extension options +type TxExtensionOptionI interface{} + +// UnpackExtensionOptionsI unpacks Any's to TxExtensionOptionI's. +func UnpackTxExtensionOptionsI(unpacker types.AnyUnpacker, anys []*types.Any) error { + for _, any := range anys { + var opt TxExtensionOptionI + err := unpacker.UnpackAny(any, &opt) + if err != nil { + return err + } + } + + return nil +} diff --git a/types/tx/types.go b/types/tx/types.go index 006941b35f17..227f9977bfef 100644 --- a/types/tx/types.go +++ b/types/tx/types.go @@ -173,7 +173,19 @@ func (t *Tx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method func (m *TxBody) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { - return UnpackInterfaces(unpacker, m.Messages) + if err := UnpackInterfaces(unpacker, m.Messages); err != nil { + return err + } + + if err := UnpackTxExtensionOptionsI(unpacker, m.ExtensionOptions); err != nil { + return err + } + + if err := UnpackTxExtensionOptionsI(unpacker, m.NonCriticalExtensionOptions); err != nil { + return err + } + + return nil } // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method @@ -200,4 +212,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterInterface("cosmos.tx.v1beta1.Tx", (*sdk.Tx)(nil)) registry.RegisterImplementations((*sdk.Tx)(nil), &Tx{}) + + registry.RegisterInterface("cosmos.tx.v1beta1.TxExtensionOptionI", (*TxExtensionOptionI)(nil)) } From 1b36270ba0d9b3d45da28dc51186a2e7c9120085 Mon Sep 17 00:00:00 2001 From: HuangYi Date: Tue, 29 Mar 2022 21:32:10 +0800 Subject: [PATCH 22/22] fix unit test --- testutil/testdata/codec.go | 5 +++++ types/tx/ext.go | 4 ++-- types/tx/types.go | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/testutil/testdata/codec.go b/testutil/testdata/codec.go index d5c6e8abd2f2..5124f506d0d5 100644 --- a/testutil/testdata/codec.go +++ b/testutil/testdata/codec.go @@ -6,6 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + tx "github.com/cosmos/cosmos-sdk/types/tx" ) func NewTestInterfaceRegistry() types.InterfaceRegistry { @@ -31,6 +32,10 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { (*HasHasAnimalI)(nil), &HasHasAnimal{}, ) + registry.RegisterImplementations( + (*tx.TxExtensionOptionI)(nil), + &Cat{}, + ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/types/tx/ext.go b/types/tx/ext.go index 28c1358649d8..fb2e1ed448bc 100644 --- a/types/tx/ext.go +++ b/types/tx/ext.go @@ -7,8 +7,8 @@ import ( // TxExtensionOptionI defines the interface for tx extension options type TxExtensionOptionI interface{} -// UnpackExtensionOptionsI unpacks Any's to TxExtensionOptionI's. -func UnpackTxExtensionOptionsI(unpacker types.AnyUnpacker, anys []*types.Any) error { +// unpackTxExtensionOptionsI unpacks Any's to TxExtensionOptionI's. +func unpackTxExtensionOptionsI(unpacker types.AnyUnpacker, anys []*types.Any) error { for _, any := range anys { var opt TxExtensionOptionI err := unpacker.UnpackAny(any, &opt) diff --git a/types/tx/types.go b/types/tx/types.go index 227f9977bfef..cbdb50a43ca4 100644 --- a/types/tx/types.go +++ b/types/tx/types.go @@ -177,11 +177,11 @@ func (m *TxBody) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { return err } - if err := UnpackTxExtensionOptionsI(unpacker, m.ExtensionOptions); err != nil { + if err := unpackTxExtensionOptionsI(unpacker, m.ExtensionOptions); err != nil { return err } - if err := UnpackTxExtensionOptionsI(unpacker, m.NonCriticalExtensionOptions); err != nil { + if err := unpackTxExtensionOptionsI(unpacker, m.NonCriticalExtensionOptions); err != nil { return err }