Issue getting valid relay provider

Hi I am currently following along with the ethers implementation of GSN in this example:

I am able to get to line 37 where we instantiate a GSN relay provider. I am getting the following warning message:

WARNING: beta ignore version compatibility Error: Provided Hub version(1.0) is not supported by the current interactor(2.0.1)

I understand from a different post on this forum that this warning should not interfere with the normal functionality of the relay provider. I am however not able to run .init() on it. I commented it out and am able to create the ether provider regardless which I then use to create a gsnWallet instance. I then use this gsnWallet when connecting to a deployed simple storage contract on Rinkeby. When calling the “set” function on the contract I get an error message indicating insufficient gas funds which I understand means the GSN transaction was unsuccessful. Any ideas on where I may have set up my code incorrectly. I have all of my configuration code listed below:

const provider = Ethers.getDefaultProvider('rinkeby')
const web3Provider = new Web3HttpProvider(`https://rinkeby.infura.io/v3/${process.env.GATSBY_INFURA}`)
const wallet = new Ethers.Wallet(`0x${privateKey}`, provider)
const paymasterAddress = PaymasterContract.networks['4'].address
const config = await resolveConfigurationGSN(web3Provider, { forwarderAddress: 
process.env.GATSBY_FORWARDER_RINKEBY, paymasterAddress })

const gsnProvider = new RelayProvider(web3Provider, config)

gsnProvider.addAccount({address: '<arbitrary public address>', privateKey: Buffer.from(privateKey, 'hex') })

// await gsnProvider.init()
const etherProvider= new Ethers.providers.Web3Provider(gsnProvider)
setEtherProvider(etherProvider)
const gsnWallet = new Ethers.Wallet(`0x${privateKey}`, etherProvider)
const instance = new Ethers.Contract(address, SimpleStorageContract.abi, gsnWallet)
instance.connect(etherProvider.getSigner(<arbitrary public address>))

I appreciate the help!

Update: I have since figured out the previously listed issue.

Currently I am able to run a GSN transaction although it is failing with the following error:

Relaying errors (2):
https://relayer-rinkeby.riseworks.io => paymaster rejected in local view call to 'relayCall()' : Forwarder is not trustedhttps://rk2.relays.opengsn.org/gsn1 => paymaster rejected in local view call to 'relayCall()' : Forwarder is not trusted
    at RelayProvider.js:103

I am using the Rinkeby forwarder that is listed in the OpenGSN documentation. Could this be the result of a misconfigured relay provider?

Not sure if you’re still using the config options in original post. But the config resolver is smart enough to figure out the correct forwarder. Here’s mine…

  const config = await resolveConfigurationGSN(web3.currentProvider, {
    verbose: true,
    chainId: (await web3.eth.getChainId()).toString(),
    paymasterAddress: process.env.MY_PAYMASTER_ADDR,
  });

Also, make sure you’re using the right OpenGSN version from NPM

1 Like

Hi amaurer,

Thank you for your input. We were not using the current version of GSN which may be why we are getting the error I specified above. The reason we are not using the current version is because when using version 2.0.3 we are getting the following error:

Can't resolve 'fs' in ./node_modules/winston/dist/winston'

If you're trying to use a package make sure that 'fs' is installed. If you're trying to use a local file make sure that the path is correct.

File: node_modules/winston/dist/winston/tail-file.js

We have not been able to find away around this and I am curious if you have encountered the same error. Appreciate your input

This ‘fs’ issue seems critical. Thanks for reporting .
Strangely, we didn’t see this error, neither when working on command line tests, nor when running react apps (e.g github.com/opengsn/ctf-react)

The “forwarder but trusted” means your recipient is not configured with the same forwarder the paymaster is using.
Check that recipient.trustedForwarder() and paymaster. trustedForwarder () are the same.

1 Like

Hi drortirosh,

We missed setting the forwarder for the paymaster in the migration. Everything works now! Glad we could shed light on a sneaky bug. We will continue using version 2.0.1 until 2.0.3 is patched. Thanks so much for the help!

Can you please elaborate under what condition did you hit that fs issue?
I need to reproduce it before I can find a cause…
We do have tests that work with react/webpack and with browserify, and none of them hit such a problem with any version of gsn

We are using a React framework called Gatsby.js. I’m not sure if you have used it or not but when you want to run the site on your local machine you run the command “gatsby develop”. The fs error is occurring towards the end of the command execution and prevents the site from being fully deployed. Hope this sheds a little more light on the issue

A little digging into winston (which is used internally by GSN) and gatsby configuration shows that this can solve your problem:

Create a file named gatsby-node.js at the root of your project, containing:

exports.onCreateWebpackConfig = ({
  stage,
  rules,
  loaders,
  plugins,
  actions,
}) => {
  actions.setWebpackConfig({
        node: {
          fs: 'empty'
        }
  })
}

(plain-vanilla react app works with GSN, so I’m not sure why gatsby had modified these defaults)

Please let me know if it helps, so that you can use the latest GSN with it.

That did indeed fix the fs error so many thanks for that. Now we are facing this error:

Error: Provided Hub version(1.0) is not supported by the current interactor(2.0.3)
    at ContractInteractor._validateVersion (ContractInteractor.js:114)
    at GSNConfigurator.js:78
    at async Promise.all (:8000/index 3)
    at resolveConfigurationGSN (GSNConfigurator.js:72)

We are using the Rinkeby hub “0x53C88539C65E0350408a2294C4A85eB3d8ce8789” which is listed in the 2.0.1 release so I’m not sure why it is saying the hub is the 1.0 version. Am I misunderstanding this message?

Edit: That error is being thrown from this line:
const config = await resolveConfigurationGSN(web3Provider, { paymasterAddress })

The message is misleading: it checks the version of the paymaster.
Did you write your own paymaster? The current protocol version is 2.0, so you need to put that.
We usually add the component “vendor”, name and interface (though the version checking doesn’t check any of that)
E.g our RelayHub version is 2.0.0+opengsn.hub.irelayhub

We used the NaivePaymaster given in the tutorial. We must have used an earlier variant of the tutorial because sure enough the version was 1.0. I changed it to 2.0 but the error did not go away. It now shows:

Error: Provided Hub version(2.0) is not supported by the current interactor(2.0.3)

this should be a warning only, and you can ignore it (client interactor 2.0.3 fully supports contracts version 2.0)

Hmmmm ok… not sure why but in my case it is an error and is preventing me from connecting to the contract instance with ethers. Here is full error message:

Error: Provided Hub version(2.0) is not supported by the current interactor(2.0.3)
    at ContractInteractor._validateVersion
(./node_modules/@opengsn/gsn/dist/src/relayclient/ContractInteractor.js:114)
    at ./node_modules/@opengsn/gsn/dist/src/relayclient/GSNConfigurator.js:78
    at async Promise.all (:8000/index 3)
    at resolveConfigurationGSN (./node_modules/@opengsn/gsn/dist/src/relayclient/GSNConfigurator.js:72)

Am going to see if setting up config differently for RelayProvider will help

I think the error is that your paymaster version is incorrect. try mark your paymaster as “2.0.0” instead of “2.0”

1 Like

Hmm I had thought of that but assured myself that was too simple to be it… sure enough it was the problem. Many thanks for the help! Things are working perfectly on 2.0.3 now

don’t blame yourself too much… it is surely a bug of ours to give you a very elaborate explanation - which points you to the wrong direction…