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

GSNv2 support #2258

Closed
spalladino opened this issue Jun 1, 2020 · 3 comments · Fixed by #2508
Closed

GSNv2 support #2258

spalladino opened this issue Jun 1, 2020 · 3 comments · Fixed by #2508

Comments

@spalladino
Copy link
Contributor

🧐 Motivation
GSNv2 is under development by the OpenGSN team, and it's very similar to GSNv1 regarding recipient contract implementation. We could add support for both v2 and v1 with some minor changes.

📝 Details
GSNv2 moves the responsibility of deciding whether to pay for a meta-tx (ie acceptRelayedCall, along with pre/post) out of the Recipient into a Paymaster contract. The Recipient now only needs to implement the base _msgSender and _msgData helpers, which should use the injected address at the end of the CALLDATA (instead of msg.sender) if the call comes from a TrustedForwarder.

The TrustedForwarder has the responsibilities of validating the user signature, managing its nonce, appending the signer address to the CALLDATA, and forwarding the call. As with the RelayHub in GSNv1, the Recipient should assume they are receiving a meta-tx if it's sent by the TrustedForwarder. And as with the RelayHub, the TrustedForwarder can be a singleton, since it has no app-specific logic.

This approach is described in detail in this ERC to be published. Note that getHubAddr was changed to isTrustedForwarder in the Recipient internal interface.

To sum up, we need to:

  • Refactor the _msgSender and _msgData methods out of GSNRecipient into a MetaTransactionRecipient (preferrably including the ERC number once published).
  • Add a TrustedForwarder implementation to Contracts so devs can easily set up a local meta-tx setup, and optionally include addresses to the singleton deployments.
  • Clarify that GSNRecipient is only valid for GSNv1, since the Paymaster interface has changed in v2.
@nventuro
Copy link
Contributor

nventuro commented Jun 1, 2020

Great, thanks for the summary! It looks like we'll be able to leave our Context contract untouched, and therefore not modify any non-GSN code. The 'issue' introduced by diamond inheritance that requires doing a manual override of Context's methods will remain though.

We may also want to update our docs to guide users to the OpenGSN docs, removing the references we have (which are anyway replicated there).

@frangio
Copy link
Contributor

frangio commented Oct 7, 2020

@naszam For testing please open an issue in OpenZeppelin/openzeppelin-test-environment.

@naszam
Copy link

naszam commented Oct 9, 2020

@frangio Ok, Thanks! I've removed my post

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants