Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fee payer to protobuf definition #7384

Merged
merged 8 commits into from
Sep 30, 2020

Conversation

ethanfrey
Copy link
Contributor

@ethanfrey ethanfrey commented Sep 24, 2020

Description

closes: #7341

  • Adds a new field: Tx.AuthInfo.Fee.Payer
  • Update Tx.FeePayer() to use this field if set, otherwise default to first signer if unset (current status)
  • Update Tx.GetSigners() to ensure the fee payer is included - appended at the end if not in any messages

This allows us to specify the non-first signer to pay the fee in a multi-sig transaction. It also allows us to provide something like Ethereum's "meta-transactions". I can sign a transaction I wish and name a third-party as the fee payer. They can parse the transaction and then sign on to pay the fee for me. Incentivation schemes are out of scope, but we give stargate the infrastructure to let people experiment.


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@codecov
Copy link

codecov bot commented Sep 25, 2020

Codecov Report

Merging #7384 into master will increase coverage by 0.00%.
The diff coverage is 60.00%.

@@           Coverage Diff           @@
##           master    #7384   +/-   ##
=======================================
  Coverage   54.81%   54.81%           
=======================================
  Files         587      587           
  Lines       36502    36512   +10     
=======================================
+ Hits        20008    20014    +6     
- Misses      14404    14406    +2     
- Partials     2090     2092    +2     

@ethanfrey ethanfrey marked this pull request as ready for review September 25, 2020 15:33
@ethanfrey ethanfrey changed the title WIP: Add fee payer to protobuf definition Add fee payer to protobuf definition Sep 25, 2020
@ethanfrey
Copy link
Contributor Author

ethanfrey commented Sep 25, 2020

This was working on make test. Then I rebased from 7ea6b2c5e to 0ddb2bd74 (one day of master commits) and some integration tests fail. It has the same behavior when fee payer is unset, so I am confused.

And just 2 of the 4 test runs...

@ethanfrey ethanfrey force-pushed the ethanfrey/7341-add-fee-payer-to-tx branch from 2008df8 to ebe2351 Compare September 25, 2020 15:45
proto/cosmos/tx/v1beta1/tx.proto Outdated Show resolved Hide resolved
@ethanfrey ethanfrey force-pushed the ethanfrey/7341-add-fee-payer-to-tx branch from ebe2351 to 2932b45 Compare September 25, 2020 20:58
@@ -97,6 +106,17 @@ func (t *Tx) GetSigners() []sdk.AccAddress {
}
}

// ensure any specified fee payer is included in the required signers (at the end)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will we do here when we have fee grants working?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think fee grants will be enough of a project that we do some more refactoring then.

My first idea was "Refactor this code and make changes to the various ante handlers.". However, on reflection, the current functionality is actually quite useful with no more and should not be removed. Maybe fee grants could add a separate field to specify a grant. eg.

message Fee {
  repeated cosmos.base.v1beta1.Coin amount = 1;
  uint64 gas_limit = 2;
  string payer = 3;
  string granter = 4;
}
  • payer and granter unset is as now (paid from first signer)
  • payer set and granter unset is like my PR (paid from specified payer, who is added to signers)
  • payer set and granter set means the payer (who signed) will attempt to pay the fees via a fee grant from granter's account.
  • payer unset and granter set is either invalid or says the first signer attempts to pay from the granter's account

This is just my first reflection. We could add this granter field by 0.40 if you wish, but I would make that a separate PR, and not worry about implementing that until the fee grant module (which may be 0.40.x if you add the field now, or maybe 0.41)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that could work. It does add the overhead of another field, but it does seem clearer and allow the additional third use case you've specified.

@ethanfrey
Copy link
Contributor Author

@anilcse if I have satisfactorily addressed your change request, can you please leave another review? I'd prefer to remove the red flag now that I have fixed it

Copy link
Collaborator

@anilcse anilcse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ethanfrey
Copy link
Contributor Author

Thanks

@alessio
Copy link
Contributor

alessio commented Sep 27, 2020

@ethanfrey please merge master in

Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ethanfrey
Copy link
Contributor Author

What is blocking this PR? Besides the merge conflict? There is rapid bit rot in the SDK as other PRs merge in, so it would be nice to see this moving forward.

When I auto-gen proto files, they do look a bit different than the checked in ones. And this is showing a diff in the auto-gen file, I wonder if I can do this merge properly...

@aaronc aaronc added A:automerge Automatically merge PR once all prerequisites pass. C:x/auth labels Sep 29, 2020
@aaronc
Copy link
Member

aaronc commented Sep 29, 2020

I've added automerge. Just fix the conflicts and it should merge.

@mergify mergify bot merged commit d917520 into cosmos:master Sep 30, 2020
@ethanfrey ethanfrey deleted the ethanfrey/7341-add-fee-payer-to-tx branch September 30, 2020 09:06
@aaronc aaronc mentioned this pull request Oct 2, 2020
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. C:x/auth
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Fee Payer field to Tx.AuthInfo.Fee
5 participants