Add fee payer to protobuf definition (#7384)

* Add fee payer to protobuf definition

* Compile new tx type

* Use FeePayer from Tx, add it to required signers

* Add unit tests on proper handling of FeePayer field

* Use string address for fee payer field

* Update logic for string feePayer
This commit is contained in:
Ethan Frey
2020-09-30 09:03:44 +00:00
committed by GitHub
parent ddaa3c5176
commit d917520092
5 changed files with 202 additions and 53 deletions
+107 -53
View File
@@ -672,6 +672,10 @@ type Fee struct {
// gas_limit is the maximum gas that can be used in transaction processing
// before an out of gas error occurs
GasLimit uint64 `protobuf:"varint,2,opt,name=gas_limit,json=gasLimit,proto3" json:"gas_limit,omitempty"`
// if unset, the first signer is responsible for paying the fees. If set, the specified account must pay the fees.
// the payer must be a tx signer (and thus have signed this field in AuthInfo).
// setting this field does *not* change the ordering of required signers for the transaction.
Payer string `protobuf:"bytes,3,opt,name=payer,proto3" json:"payer,omitempty"`
}
func (m *Fee) Reset() { *m = Fee{} }
@@ -721,6 +725,13 @@ func (m *Fee) GetGasLimit() uint64 {
return 0
}
func (m *Fee) GetPayer() string {
if m != nil {
return m.Payer
}
return ""
}
func init() {
proto.RegisterType((*Tx)(nil), "cosmos.tx.v1beta1.Tx")
proto.RegisterType((*TxRaw)(nil), "cosmos.tx.v1beta1.TxRaw")
@@ -737,59 +748,59 @@ func init() {
func init() { proto.RegisterFile("cosmos/tx/v1beta1/tx.proto", fileDescriptor_96d1575ffde80842) }
var fileDescriptor_96d1575ffde80842 = []byte{
// 821 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x4f, 0x6f, 0xdc, 0x44,
0x14, 0x5f, 0xaf, 0x37, 0x1b, 0xef, 0x4b, 0xd2, 0xd2, 0x51, 0x85, 0x36, 0x1b, 0xd5, 0x0d, 0x46,
0x85, 0xbd, 0xc4, 0x6e, 0xd3, 0x03, 0x7f, 0x84, 0x04, 0xd9, 0x42, 0x95, 0xaa, 0x14, 0xa4, 0x49,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, 0x5f, 0xf8, 0xce,
0x9b, 0x4b, 0xbf, 0xf3, 0xee, 0xd2, 0xef, 0xfc, 0x71, 0xe9, 0x77, 0x5e, 0x3e, 0x58, 0x1f, 0x28,
0x52, 0x55, 0xd2, 0x37, 0xcd, 0xf9, 0xf8, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x34, 0x02, 0x69,
0x7b, 0xcd, 0x06, 0x00, 0x00,
// 830 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x4d, 0x6f, 0xdc, 0x44,
0x18, 0x5e, 0xef, 0x57, 0xbc, 0x6f, 0x92, 0x96, 0x8e, 0x22, 0xb4, 0xd9, 0xa8, 0x6e, 0x30, 0x2a,
0xec, 0x25, 0x76, 0x9b, 0x1e, 0xf8, 0x10, 0x12, 0x64, 0x0b, 0x55, 0xaa, 0x52, 0x90, 0x26, 0x39,
0xf5, 0x62, 0x8d, 0xbd, 0x13, 0xef, 0xa8, 0xeb, 0x99, 0xc5, 0x33, 0x2e, 0xf6, 0x8f, 0x40, 0xaa,
0x90, 0x10, 0x27, 0xfe, 0x00, 0xbf, 0xa4, 0xc7, 0x1e, 0x39, 0x41, 0x95, 0xfc, 0x10, 0xd0, 0x8c,
0xc7, 0x4e, 0x04, 0xab, 0xe4, 0xc2, 0xc9, 0x33, 0xef, 0x3c, 0xef, 0xf3, 0x3e, 0x7e, 0xbf, 0x60,
0x92, 0x08, 0x99, 0x09, 0x19, 0xaa, 0x32, 0x7c, 0xf5, 0x30, 0xa6, 0x8a, 0x3c, 0x0c, 0x55, 0x19,
0xac, 0x72, 0xa1, 0x04, 0xba, 0x53, 0xbf, 0x05, 0xaa, 0x0c, 0xec, 0xdb, 0x64, 0x27, 0x15, 0xa9,
0x30, 0xaf, 0xa1, 0x3e, 0xd5, 0xc0, 0xc9, 0x81, 0x25, 0x49, 0xf2, 0x6a, 0xa5, 0x44, 0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x7f, 0x73, 0xa0, 0xf7, 0x84, 0x52, 0x94, 0xc0, 0x90, 0x64,
0x7a, 0x48, 0x6d, 0xab, 0xb5, 0x4b, 0x52, 0xaf, 0xe7, 0x2b, 0x52, 0x18, 0x9f, 0x3d, 0x78, 0xf3,
0xe7, 0xbd, 0xce, 0xef, 0x7f, 0xdd, 0x9b, 0xa6, 0x4c, 0x2d, 0x8a, 0x38, 0x48, 0x44, 0x16, 0x36,
0xab, 0xdf, 0x7c, 0x0e, 0xe4, 0xfc, 0x65, 0xa8, 0xaa, 0x15, 0x95, 0xc6, 0x41, 0x62, 0x4b, 0x8d,
0xf6, 0x60, 0x94, 0x12, 0x19, 0x2d, 0x59, 0xc6, 0x94, 0x29, 0x44, 0x1f, 0xbb, 0x29, 0x91, 0xdf,
0xea, 0x3b, 0xda, 0x81, 0xc1, 0x8a, 0x54, 0x34, 0xb7, 0x5b, 0xa5, 0xbe, 0xcc, 0xbe, 0x7c, 0x73,
0xee, 0x39, 0x6f, 0xcf, 0x3d, 0xe7, 0xdd, 0xb9, 0xe7, 0xbc, 0xbe, 0xf0, 0x3a, 0x6f, 0x2f, 0xbc,
0xce, 0x1f, 0x17, 0x5e, 0xe7, 0xc5, 0xfd, 0x9b, 0xc3, 0x87, 0xaa, 0x8c, 0x87, 0xa6, 0x65, 0x1f,
0xfd, 0x13, 0x00, 0x00, 0xff, 0xff, 0xfa, 0xdf, 0x9b, 0x65, 0xe3, 0x06, 0x00, 0x00,
}
func (m *Tx) Marshal() (dAtA []byte, err error) {
@@ -1296,6 +1307,13 @@ func (m *Fee) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if len(m.Payer) > 0 {
i -= len(m.Payer)
copy(dAtA[i:], m.Payer)
i = encodeVarintTx(dAtA, i, uint64(len(m.Payer)))
i--
dAtA[i] = 0x1a
}
if m.GasLimit != 0 {
i = encodeVarintTx(dAtA, i, uint64(m.GasLimit))
i--
@@ -1554,6 +1572,10 @@ func (m *Fee) Size() (n int) {
if m.GasLimit != 0 {
n += 1 + sovTx(uint64(m.GasLimit))
}
l = len(m.Payer)
if l > 0 {
n += 1 + l + sovTx(uint64(l))
}
return n
}
@@ -2918,6 +2940,38 @@ func (m *Fee) Unmarshal(dAtA []byte) error {
break
}
}
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Payer", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTx
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthTx
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthTx
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Payer = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipTx(dAtA[iNdEx:])
+20
View File
@@ -67,6 +67,13 @@ func (t *Tx) ValidateBasic() error {
)
}
if fee.Payer != "" {
_, err := sdk.AccAddressFromBech32(fee.Payer)
if err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid fee payer address (%s)", err)
}
}
sigs := t.Signatures
if len(sigs) == 0 {
@@ -84,6 +91,8 @@ func (t *Tx) ValidateBasic() error {
}
// GetSigners retrieves all the signers of a tx.
// This includes all unique signers of the messages (in order),
// as well as the FeePayer (if specified and not already included).
func (t *Tx) GetSigners() []sdk.AccAddress {
var signers []sdk.AccAddress
seen := map[string]bool{}
@@ -97,6 +106,17 @@ func (t *Tx) GetSigners() []sdk.AccAddress {
}
}
// ensure any specified fee payer is included in the required signers (at the end)
feePayer := t.AuthInfo.Fee.Payer
if feePayer != "" && !seen[feePayer] {
payerAddr, err := sdk.AccAddressFromBech32(feePayer)
if err != nil {
panic(err)
}
signers = append(signers, payerAddr)
seen[feePayer] = true
}
return signers
}