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

NEP-417: Meta transactions #417

Closed
wants to merge 4 commits into from
Closed

Conversation

e-uleyskiy
Copy link
Contributor

Summary

This is a fork of NEP-366. Main changes:

  1. The implicit account case is described according to the comments one and two
  2. DelegateAction and DelegateActionMessage formats are changed.

I will attach a diagram a little bit later.

Egor Uleyskiy added 3 commits October 19, 2022 03:14
Squashed commit of the following:

commit 06ea3bbcbf7387923d7ced70de55fadc2391be21
Author: Illia Polosukhin <ilblackdragon@gmail.com>
Date:   Fri Jun 24 06:57:01 2022 -0400

    More text fixes

commit 3901b139e1f97b94a3df95eba566476cc7a41491
Author: Illia Polosukhin <ilblackdragon@gmail.com>
Date:   Fri Jun 24 06:51:51 2022 -0400

    Move details of the DelegateAction from Actions.md to the proposal. Add the flow of data

commit cd576a5bd382957566fc2d9611a13cdcaa3c91e1
Author: Illia Polosukhin <ilblackdragon@gmail.com>
Date:   Thu Jun 23 16:01:40 2022 -0400

    Adding PR number

commit c9ee1e6f7d7ab96a12cad0a59a97855ae5c61d06
Author: Illia Polosukhin <ilblackdragon@gmail.com>
Date:   Thu Jun 23 08:38:51 2022 -0400

    Adding a lot more details for DelegateAction design

commit 9142bf9fb262927afd1ade75e5f9ffa91370b790
Author: Illia Polosukhin <ilblackdragon@gmail.com>
Date:   Tue Jun 21 17:18:51 2022 -0400

    Initial commit for meta tx standard
@e-uleyskiy e-uleyskiy requested a review from a team as a code owner October 19, 2022 00:42
Copy link
Contributor

@akhi3030 akhi3030 left a comment

Choose a reason for hiding this comment

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

Thanks @e-uleyskiy. This looks like a great start. My comments are generally minor. They should help someone less familiar with the proposal understand it better.


The main flow of the meta transaction will be as follows:
- User requests the relayer for its access key (public key) which the relayer are going to use. The user specifies this key as `relayer_pub_key` in `DelegateAction`.
- User fetches the relayer's access key `nonce`, increments it and assigns the value to `relayer_nonce` in `DelegateAction`: `relayer_nonce = nonce + 1`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Will the relayer have one nonce per user? If not, then a relayer can only work with one user at a time. This will have lower throughput and a potential attack vector where the user can request the nonce from the relayer and never send the subsequent transaction.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually the implementation of the relayer node is up to developers, I think. But if you want me to describe it in this NEP, I will do. Bellow are my thoughts:

A relayer should have one nonce per access key. And one access key per user. A relayer can import a lot of access keys to its account and schedule them between users.

the user can request the nonce from the relayer and never send the subsequent transaction

The relayer can reserve an access key for some time. When this time ends, other users can use this key.
And one important thing, the user requests access key/public key, not nonce.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that the implementation of the relayer node will be up to the developers. And I suppose a NEP is not the right place to provide best practices for developers either. However, I felt that fellow developers who are interested in building a relayer would be curious about this point. For me personally, just this conversation should suffice and I don't think we need to add more text to the NEP.

- User forms `SignedDelegateAction` with the `DelegateAction` and the `DelegateAction` signature.
- User forms `DelegateActionMessage` with the `SignedDelegateAction`.
- User sends `DelegateActionMessage` data to the relayer.
- Relayer verifies actions specified in `DelegateAction`: the total cost and whether the user included the reward for the relayer.
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Should we clarify how a user may include the reward given that the user may not have any NEAR tokens yet.
  • Is there an attack vector where the relayer can keep the reward and not finish the transaction? Will the user have any recourse there or will users generally have to trust relayers.

- Relayer forms a `Transaction` with `receiver_id` equals to `delegate_action.sender_id` and `actions: [SignedDelegateAction { ... }]`. Signs it with its key. Note that such transactions can contain other actions toward user's account (for example calling a function).
- This transaction is processed normally. A `Receipt` is created with a copy of the actions in the transaction.
- When processing a `SignedDelegateAction`, a number of checks are done (see below), mainly a check to ensure that the `signature` matches the user account's key.
- When a `Receipt` with a valid `SignedDelegateAction` in actions arrives at the user's account, it gets executed. Execution means creation of a new Receipt with `receiver_id: AccountId` and `actions: Action` matching `receiver_id` and `actions` in the `DelegateAction`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we clarify what we mean by "user's account" here? If I understand things properly, users may not have accounts yet.


## Summary

In-protocol meta transactions allowing for third-party account to initiate and pay transaction fees on behalf of the account.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I wonder if this feature should be called delegate transactions instead of meta transactions. I feel like that is a more precise name.

@fadeevab
Copy link
Contributor

@e-uleyskiy Thanks for the NEP!

The following parts should be added into the NEP:

  1. Security control: signer_id of implicit account must be equal to delegate_action.public_key.
  2. Use cases into the Overview.
  3. A sequence diagram describing the Specification chapter.
  4. Refund cases for failed transactions.

@ori-near
Copy link
Contributor

Hey @e-uleyskiy, thank you for submitting this NEP. Since this is a continuation of #366, could you please submit a pull request to change 366 and close 417? This way we can keep the content and discussion centralized in one NEP. Thank you very much.

@e-uleyskiy
Copy link
Contributor Author

@ori-near
Ok, when I fix all issues the reviewers have found, I will submit a pull request to the meta-tx branch.

@frol frol added A-NEP A NEAR Enhancement Proposal (NEP). T-runtime About NEAR Protocol Runtime (actions, Wasm, fees accounting) WG-protocol Protocol Standards Work Group should be accountable S-review/needs-author-revision A NEP in the REVIEW stage that needs an author revision. labels Oct 24, 2022
@ori-near ori-near changed the base branch from master to meta-tx October 25, 2022 17:24
@frol frol changed the base branch from meta-tx to master October 25, 2022 17:27
@frol frol changed the base branch from master to meta-tx October 25, 2022 17:27
@e-uleyskiy
Copy link
Contributor Author

Close this pull request. Need to discuss more about this approach.
#366 (comment)
#366 (comment)

@e-uleyskiy e-uleyskiy closed this Oct 27, 2022
@e-uleyskiy e-uleyskiy deleted the meta-tx branch October 27, 2022 19:44
@ori-near ori-near added S-rejected A NEP that was rejected by a working group. and removed S-review/needs-author-revision A NEP in the REVIEW stage that needs an author revision. labels Oct 27, 2022
@ori-near
Copy link
Contributor

Moved this to Rejected since this is a duplicate/continuation of #366.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-NEP A NEAR Enhancement Proposal (NEP). S-rejected A NEP that was rejected by a working group. T-runtime About NEAR Protocol Runtime (actions, Wasm, fees accounting) WG-protocol Protocol Standards Work Group should be accountable
Projects
Status: REJECTED
Development

Successfully merging this pull request may close these issues.

5 participants