Problems with installing Relay on Google Cloud

I need to create a test GSN Relay for Polygon testnet so I dived into opengsn deployment. I’m certainly not the most experienced with VMs on GC and this all a bit of a revelation.

I’ve set up the VM and have SSH access all setup with keys. No problem (appears so…)

Downloaded rdc to my laptop ok but could not connect it to the VM . Permission denied.

Then installed rdc on the VM and will run locally. .env and config files in place. But I get the same thing:

~ $ ./rdc local config
-bash: ./rdc: Permission denied

However, after research, I saw another similar post that advised running with bash -x so

bash -x ./rdc local config

It works. So I managed to run bash -x ./rdc local up -d and I have containers running.

Now does it work? No, I get Bad Gateway 502 when accessing https://betenbloc.com/gsn1/getaddr

I see in the router log that there is an issue with the call as follows:

sherringtonian@betenbloc ~ $ wget https://betenbloc.com/gsn1/getaddr --no-check-certificate
--2021-10-17 09:46:35--  https://betenbloc.com/gsn1/getaddr
Resolving betenbloc.com... 35.204.219.18
Connecting to betenbloc.com|35.204.219.18|:443... connected.
WARNING: cannot verify betenbloc.com's certificate, issued by 'CN=(STAGING) Artificial Apricot R3,O=(STAGING) Let\'s Encrypt,C=US':
  Unable to locally verify the issuer's authority.
HTTP request sent, awaiting response... 502 Bad Gateway
2021-10-17 09:46:35 ERROR 502: Bad Gateway.

In the logs…

router          | /gsn1/ => http://gsn1/
router          | 2021/10/17 09:46:35 [error] 8#8: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.22.0.3, server: , request: "GET /gsn1/getaddr HTTP/1.0", upstream: "http://172.22.0.2:80/getaddr", host: "betenbloc.com"
router          | 172.22.0.3 - - [17/Oct/2021:09:46:35 +0000] "GET /gsn1/getaddr HTTP/1.0" 502 157 "-" "Wget/1.21.1"

It’s not the certificate. The same thing was happening when using production certificate. Had to use staging as issuer ran out of patience with me.

Any help most appreciated!

  1. the rdc script is not meant to be executed on the cloud host itself: the script requires a “mnemonic” file which is your personal wallet.
    you do need to run it locally on your machine, and yes, it requires to be executable (chmod +x rdc)
    Thank you for letting us know, so we clarify it in our documentation.

  2. I can see the certificate of your host is at “staging” state.
    please add to your .env file:
    HTTPS_STAGE=production
    This will make the certificate a “production” one.

  3. The log you submitted suggests that the actual gsn relayer didn’t start correctly.
    To show the logs of the relayer itself, please issue the log command:
    rdc logs {hostname} gsn1
    (that’s also the reason for “Bad gateway” when accessing the URL)

Thank for your response.

  1. Running the rdc script locally required configuring ssh to use the key file and that was what was causing the Public Key failure. Now ok but still need to run it with bash -x ./rdc
  2. I’m using the Staging certificate as the service issuing production certificates gets annoyed if you ask for a new certificate too many times - it does this each time the containers start. So, I suggest using staging certificates until all is working ok
  3. It seems that the 502 Bad Gateway failure is actually the response from Chainstack RPC URL. It works just fine if I use the same URL in Metamask. Switching to Infura worked after I added a Card for the Polygon POS. Now I get the following issue:
Starting GSN Relay Server process...

Parsing server config...

Using config file /app/config/gsn-relay-config.json
Initial configuration: {
  baseRelayFee: 0,
  pctRelayFee: 10,
  versionRegistryAddress: '0x4Fe8824c885D67613848c94a15dce7680897f33E',
  gasPriceFactor: 1,
  ownerAddress: '0x253dD319d6db7cE195277d5a1dfd6Ee13A408c76',
  ethereumNodeUrl: 'https://polygon-mumbai.infura.io/v3/<my key>'
}
Resolving server config ...

debug:   Created logger for ; remote logs collecting: false
debug:   _getPastEventsPaginated start, fromBlock: 1, toBlock: undefined
Returned error: eth_getLogs block range too large, range: 20366947, max: 100000

So the container constantly fails and then restarts and so on. How can I solve this?

Thank you again for your assistance.

Thanks for your response. It seems that the 502 Bad Gateway response is actually from the RPC URL which is from my account with Chainstack. The URL works perfectly fine in Metamask. So I used Infura and after adding a Card to access Polygon POS and checking URL works ok, I now get this issue:

Starting GSN Relay Server process...

Parsing server config...

Using config file /app/config/gsn-relay-config.json
Initial configuration: {
  baseRelayFee: 0,
  pctRelayFee: 10,
  versionRegistryAddress: '0x4Fe8824c885D67613848c94a15dce7680897f33E',
  gasPriceFactor: 1,
  ownerAddress: '0x253dD319d6db7cE195277d5a1dfd6Ee13A408c76',
  ethereumNodeUrl: 'https://polygon-mumbai.infura.io/<my key>
}
Resolving server config ...

debug:   Created logger for ; remote logs collecting: false
debug:   _getPastEventsPaginated start, fromBlock: 1, toBlock: undefined
Returned error: eth_getLogs block range too large, range: 20366947, max: 100000

The relay container constantly fails and restarts… How can I solve this?

Hi @iansher
This error is caused by Polygon range limits for eth_getLogs, You can add "pastEventsQueryMaxPageSize": 900 in your relay server config file to solve this error.

To optimize, since your relayer doesn’t have any on-chain events to handle yet, you can add "coldRestartLogsFromBlock": 20393789 to start scanning only from a recent block.

Hi @shahaf Thanks for the info, Ok added the two config values. Unfortunately, still an issue.

Starting GSN Relay Server process...

Parsing server config...

Using config file /app/config/gsn-relay-config.json
Initial configuration: {
  baseRelayFee: 0,
  pctRelayFee: 10,
  versionRegistryAddress: '0x4Fe8824c885D67613848c94a15dce7680897f33E',
  gasPriceFactor: 1,
  ownerAddress: '0x253dD319d6db7cE195277d5a1dfd6Ee13A408c76',
  ethereumNodeUrl: 'https://polygon-mumbai.infura.io/<my key>,
  pastEventsQueryMaxPageSize: 900,
  coldRestartLogsFromBlock: 20393789
}
Resolving server config ...

debug:   Created logger for ; remote logs collecting: false
debug:   _getPastEventsPaginated start, fromBlock: 20393789, toBlock: undefined
info:    Splitting request for 14990 blocks into 17 smaller paginated requests!
getVersion(hub) - no version found
Starting GSN Relay Server process...

And the container is restarted and so on… Is it the getVersion(hub) that is the problem?

this is the configuration we currently use for our mumbai relayer:

{
  "baseRelayFee": 0,
  "pctRelayFee": 70,
  "versionRegistryAddress": "0x4Fe8824c885D67613848c94a15dce7680897f33E",
  "ownerAddress": "<your account>",
  "registrationBlockRate": 50000,
  "pastEventsQueryMaxPageSize": 80000,
  "gasPriceFactor": 1,
  "confirmationsNeeded": 1,
  "ethereumNodeUrl": "https://matic-mumbai.chainstacklabs.com"
}

note that initial loading will take time, since it searches the entire blockchain for the initial events.

@drortirosh Thank you! That works perfectly. I will use that as a base. Do you happen to know if there is a reference to all these configuration settings?