Skip to content

GSNv2 support #2258

@spalladino

Description

@spalladino

🧐 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions