By adding a optional "fee payer" field, we can get a lot more flexibility and prepare a smooth upgrade to support the planned fee delegation functionality (which should be in 0.41 at the latest).
I would propose including this in the 0.40 release. And can prepare a PR for it if that is requested.
Fee is hardcoded as first signer. Many times this may not be the desire, and you would have to readjust the messages to make it work, even if you might want them in another order:
https://github.com/cosmos/cosmos-sdk/blob/master/proto/cosmos/tx/v1beta1/tx.proto#L94-L98
A lot of work has gone into making the entire Tx very general, including multiple coins as fees
https://github.com/cosmos/cosmos-sdk/blob/master/proto/cosmos/tx/v1beta1/tx.proto#L148-L159
And even a framework for extension options:
https://github.com/cosmos/cosmos-sdk/blob/master/proto/cosmos/tx/v1beta1/tx.proto#L76-L84
Given the fact the Tx has been defined very flexibly, and the fact that one very rigid assumption is being made, I would propose to update Tx to allow clearly specifying which signer should pay the fee.
message Fee {
// amount is the amount of coins to be paid as a fee
repeated cosmos.base.v1beta1.Coin amount = 1
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
// gas_limit is the maximum gas that can be used in transaction processing
// before an out of gas error occurs
uint64 gas_limit = 2;
// 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.
bytes payer = 3 [
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress",
(gogoproto.moretags) = "yaml:\"payer\""
];
}
Smooth migration: This requires one more check in the fee ante decorators, but no other changes to client or parsing code if they don't use this field. Clients can optionally add support if they wish to have better multisig support.
Bonus: This may allow for fee delegation to be released as a non-breaking cosmos-sdk 0.40.1 change (although enabling it on a chain will be a hard fork for the chain, the feature could be released without waiting for 0.41)
Yes, great to get this in there. I think we could even do something simpler where if the field is set (for now) it must match the first signer. But allowing it to be any one of the signers wouldn't be too hard. Either way, it would be good to get the very minimum viable version of this into stargate. I consider it more of an oversight on my part than anything else that it didn't when we first designed Tx.
Are you planning to open a PR for this @ethanfrey ?
I will this week. I wasn't quite clear from your last comment, but happy to do so.
Most helpful comment
I will this week. I wasn't quite clear from your last comment, but happy to do so.