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?

@drortirosh I tried to install Relay on Google Cloud this past few days. I followed all the forum posts I could find and at the end it seems to work (i.e. by going to https:///gsn1/getaddr , I can see ready: true in the JSON file).

However, when I use ‘./rdc logs gsn1’ I see the following:

> gsn1_1          | info:    Transaction 2548f2bb244bd8d39c7b0add921ec4a5fa96630209ee47fbd567feca7d3b9392 is valid
> gsn1_1          | debug:   view call to penalizeRepeatedNonce reverted with error message Returned error: execution reverted: Legal relay transaction.
> gsn1_1          | Tx not penalizable.

Does it mean my relay is working or is there still issues with my installation?

I also tried Unstake a GSN Relay but it fails with error as follows:

Thanks a lot!!!

“Tx not penalizable.” can be ignored…
clients try to verify relayer request, by sending to another relayer to check it.
this other relayer says the TX is OK, and log it as “error”.

Hi @drortirosh. Thanks for your help last time. I resumed installation of the relay on Google Cloud and had a few more issues. However, eventually I found this configuration worked ok for Polygon Mumbai.

{
  "baseRelayFee": 0,
  "pctRelayFee": 70,
  "ownerAddress": "0x253dD319d6db7cE195277d5a1dfd6Ee13A408c76",
  "registrationBlockRate": 1000,
  "pastEventsQueryMaxPageSize": 900,
  "coldRestartLogsFromBlock": 25784109,
  "gasPriceFactor": 1,
  "confirmationsNeeded": 1,
  "ethereumNodeUrl": "https://matic-mumbai.chainstacklabs.com",
  "relayHubAddress": "0x6646cD15d33cE3a6933e36de38990121e8ba2806"
}

Note that along the way, I had issues with the server failing to contact the RPC on the ethereumNodeURL - gsn1 just kept on restarting until I replaced versionRegistryAddress with a relayHubAddress for mumbai. Then all sprang to life.

However, when i try to register, i get a failure. I am using this:

docker run --rm -ti -v $PWD:$PWD \
    opengsn/cli:2.2.6 relayer-register \
    --network https://matic-mumbai.chainstacklabs.com \
    --gasPrice 35 \
    --relayUrl https://betenbloc.com/gsn1 \
    -m `pwd`/pass12

Which returned this:

Status: Downloaded newer image for opengsn/cli:2.2.6
Using mnemonic from file /home/ian/register/pass12
debug:   interactor init start
info:    Contract interactor cannot resolve a full deployment from the following input: {}
Found funded account 0x37772859970eEDC507E7bc3c8e44C894B3C3f5Bf
Registering GSN relayer at https://betenbloc.com/gsn1
info:    pingResponse: {"relayWorkerAddress":"0xc68d2d4d042164f449ef7224fbdb93af935ef141","relayManagerAddress":"0x6da884ed2780f861b0027f765d2afb4a7183c3bf","relayHubAddress":"0x6646cD15d33cE3a6933e36de38990121e8ba2806","ownerAddress":"0x253dD319d6db7cE195277d5a1dfd6Ee13A408c76","minGasPrice":"1500000012","maxAcceptanceBudget":"285252","chainId":"80001","networkId":"80001","ready":false,"version":"2.2.5"}
current stake= 0
Funding relayer
Waiting 10000ms 0/5 for relayer to set 0x37772859970eEDC507E7bc3c8e44C894B3C3f5Bf as owner
Waiting 10000ms 1/5 for relayer to set 0x37772859970eEDC507E7bc3c8e44C894B3C3f5Bf as owner
Waiting 10000ms 2/5 for relayer to set 0x37772859970eEDC507E7bc3c8e44C894B3C3f5Bf as owner
Waiting 10000ms 3/5 for relayer to set 0x37772859970eEDC507E7bc3c8e44C894B3C3f5Bf as owner
Waiting 10000ms 4/5 for relayer to set 0x37772859970eEDC507E7bc3c8e44C894B3C3f5Bf as owner
Waiting 10000ms 5/5 for relayer to set 0x37772859970eEDC507E7bc3c8e44C894B3C3f5Bf as owner
Failed to register relay: RelayServer failed to set its owner on the StakeManager

So yes it funded the relayer 2.0 MATIC as shown here Polygon Transaction Hash (Txhash) Details | PolygonScan
But my relayer is not registered according to the ready false state.
So I think I can unstake this but that fails because there is no unstake possibility on Polygon networks right now according to this:

So, how can I complete the registration and / or get the stake back? Any help most appreciated!

  1. please try to re-run the relayer-register tool. sometimes, the 1 minute waiting for the relayer is not enough, and just re-running continues the relayer deployment.
  2. you can check the relayer log (docker logs default_gsn1_1) and paste it here so we can see why it didn’t finish set its owner and continue the registration.
  3. If you don’t want to continue installing the relayer, and just want to withdraw the funds: You don’t need to unstake your relayer, since it isn’t staked at . It is “funded”, though, and you can withdraw those funds using:
    docker run --rm -v $PWD:$PWD -ti opengsn/cli:2.2.5-withdraw relayer-withdraw

Hi @drortirosh . Many thanks for your response. I’m still having issues…

  1. Tried to rerun the relayer-registration took but has insufficent funds .
root@Ian-HP:/home/ian/register# ls
issue.txt  pass12  register.txt
root@Ian-HP:/home/ian/register# nano register.txt
root@Ian-HP:/home/ian/register# root@Ian-HP:/home/ian/register# docker run --rm -ti -v $PWD:$PWD \
cli rela>     opengsn/cli relayer-register \
>     --network https://matic-mumbai.chainstacklabs.com \
>     --gasPrice 35 \
>     --relayUrl https://betenbloc.com/gsn1 \
>     -m `pwd`/pass12
Using mnemonic from file /home/ian/register/pass12
debug:   interactor init start
info:    Contract interactor cannot resolve a full deployment from the following input: {}
Error: could not find unlocked account with sufficient balance; all accounts:
 - 0x37772859970eEDC507E7bc3c8e44C894B3C3f5Bf
 - 0x989E5eA7f48A65A1532bfAc1B49301c930360509
 - 0x262A77A1A106bE9A6639C246490e094E8ad0bc61
 - 0xd4082C6cd4DF6aCb8f496BE08bb9C7BeD9B47321
 - 0x56c4FFDd4007183107bcCEc774CB24B0e226BFB2
 - 0xF7Df79cFa4915053F20D943Dd0e67bD435487372
 - 0xC8453C9c00E6EE6646Cdc1DB461Ba88CfA23362F
 - 0xD561c376aa649c781CeD246f5dcA4C58D549C3B0
 - 0x8A91D1d84e05c7D17cA8EE97f42c0a63C6Ee001F
 - 0xfeD9addf46F217fc4fbCF369116e95BDE4381f03
    at CommandsLogic.findWealthyAccount (webpack:////Users/dror/IdeaProjects/gsn223/packages/cli/dist/CommandsLogic.js?:71:15)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at eval (webpack:////Users/dror/IdeaProjects/gsn223/packages/cli/dist/commands/gsn-relayer-register.js?:25:70)
root@Ian-HP:/home/ian/register# docker run --rm -ti -v $PWD:$PWD     opengsn/cli relayer-register     --network https://matic-mumbai.chainstacklabs.com     --gasPrice 35     --relayUrl https://betenbloc.com/gsn1     -m `pwd`/pass12
  1. Here is what the logs are showing me:
gsn1_1          | debug:   queried node for last active server event, found in block undefined
gsn1_1          | debug:   _shouldRegisterAgain activityExpired=false currentBlock=25808906 latestTxBlockNumber=-1 activityBlockRate=0
gsn1_1          | debug:   will attempt registration: isRegistrationPending=false isRegistrationCorrect=false forceRegistration=true
gsn1_1          | debug:   will not actually attempt registration - prerequisites not satisfied
gsn1_1          | debug:   Not registered yet
gsn1_1          | info:    Splitting request for 24800 blocks into 28 smaller paginated requests!
gsn1_1          | warn:    Different worker is not finished yet, skipping this block
gsn1_1          | debug:   queried node for last active server event, found in block undefined
gsn1_1          | debug:   _shouldRegisterAgain activityExpired=false currentBlock=25808908 latestTxBlockNumber=-1 activityBlockRate=0
gsn1_1          | debug:   will attempt registration: isRegistrationPending=false isRegistrationCorrect=false forceRegistration=true
gsn1_1          | debug:   will not actually attempt registration - prerequisites not satisfied
gsn1_1          | debug:   Not registered yet
gsn1_1          | info:    Splitting request for 24804 blocks into 28 smaller paginated requests!

These log entries are being repeated over and over…

  1. To get back the MATIC into the 0x37772859970eEDC507E7bc3c8e44C894B3C3f5Bf account I ran the withdraw as suggested - I presumed on the same client as the relayer deployment and I received this:
root@Ian-HP:/home/ian/register# docker run --rm -v $PWD:$PWD -ti opengsn/cli:2.2.5-withdraw relayer-withdraw
Unable to find image 'opengsn/cli:2.2.5-withdraw' locally
2.2.5-withdraw: Pulling from opengsn/cli
afb6ec6fdc1c: Already exists
028320f35da4: Already exists
99eddfd3b998: Already exists
683bd47a2467: Already exists
dcaf18717d9f: Already exists
cb26e333a01b: Already exists
f8b4fc822ff0: Pull complete
Digest: sha256:d4c736f79fb1292cfb249c84917327b71fc5d336594bbc04561910ab7424c2b4
Status: Downloaded newer image for opengsn/cli:2.2.5-withdraw
Error: configFilename //config/gsn-relay-config.json must be a file
    at Object.getServerConfig (webpack:////Users/dror/IdeaProjects/gsn-224/packages/cli/dist/utils.js?:80:15)
    at eval (webpack:////Users/dror/IdeaProjects/gsn-224/packages/cli/dist/commands/gsn-relayer-withdraw.js?:18:28)
    at eval (webpack:////Users/dror/IdeaProjects/gsn-224/packages/cli/dist/commands/gsn-relayer-withdraw.js?:56:3)
    at Object.../../packages/cli/dist/commands/gsn-relayer-withdraw.js (/app/gsn-relayer-withdraw.js:15384:1)
    at __webpack_require__ (/app/gsn-relayer-withdraw.js:20:30)
    at /app/gsn-relayer-withdraw.js:84:18
    at Object.<anonymous> (/app/gsn-relayer-withdraw.js:87:10)
    at Module._compile (internal/modules/cjs/loader.js:1118:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
    at Module.load (internal/modules/cjs/loader.js:982:32)
    at Function.Module._load (internal/modules/cjs/loader.js:875:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47

The /config/gsn-relay-config.json file is for sure on the relay server. I tried running the command on the relay server itself but got the same result.

Thanks, Ian

Hey, if you’re trying to rerun the relayer-register command again you have to specify --funds 0 or else it will try and fund the relay manager again with the default amount. The same goes for the stake, if you don’t want to stake then --stake 0 is another option you’ll want.

The error with the withdraw command seems to be due to some kind of config file issue. I’ve encountered this issue before and it was happening because I incorrectly exited a vim session where I was editing the contents. I would try opening the file with vim or nano to see the result. Hopefully that helps!

@digglehopper Thanks for your input! But I still have issues… m

–funds 0 seems to have been ignored…

root@Ian-HP:/home/ian/register# docker run --rm -ti -v $PWD:$PWD     opengsn/cli relayer-register     --network https://matic-mumbai.chainstacklabs.com     --gasPrice 35     --relayUrl https://betenbloc.com/gsn1  --funds 0 --stake 0   -m `p
wd`/pass12
Using mnemonic from file /home/ian/register/pass12
debug:   interactor init start
info:    Contract interactor cannot resolve a full deployment from the following input: {}
Error: could not find unlocked account with sufficient balance; all accounts:
 - 0x37772859970eEDC507E7bc3c8e44C894B3C3f5Bf
 - 0x989E5eA7f48A65A1532bfAc1B49301c930360509
 - 0x262A77A1A106bE9A6639C246490e094E8ad0bc61
 - 0xd4082C6cd4DF6aCb8f496BE08bb9C7BeD9B47321
 - 0x56c4FFDd4007183107bcCEc774CB24B0e226BFB2
 - 0xF7Df79cFa4915053F20D943Dd0e67bD435487372
 - 0xC8453C9c00E6EE6646Cdc1DB461Ba88CfA23362F
 - 0xD561c376aa649c781CeD246f5dcA4C58D549C3B0
 - 0x8A91D1d84e05c7D17cA8EE97f42c0a63C6Ee001F
 - 0xfeD9addf46F217fc4fbCF369116e95BDE4381f03
    at CommandsLogic.findWealthyAccount (webpack:////Users/dror/IdeaProjects/gsn223/packages/cli/dist/CommandsLogic.js?:71:15)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at eval (webpack:////Users/dror/IdeaProjects/gsn223/packages/cli/dist/commands/gsn-relayer-register.js?:25:70)

So I gave in and funded the account. Then tried the command again and I get this

root@Ian-HP:/home/ian/register# docker run --rm -ti -v $PWD:$PWD     opengsn/cli relayer-register     --network https://matic-mumbai.chainstacklabs.com     --gasPrice 35     --relayUrl https://betenbloc.com/gsn1  --funds 0 --stake 0   -m `pwd`/pass12
Using mnemonic from file /home/ian/register/pass12
debug:   interactor init start
info:    Contract interactor cannot resolve a full deployment from the following input: {}
Found funded account 0x37772859970eEDC507E7bc3c8e44C894B3C3f5Bf
Registering GSN relayer at https://betenbloc.com/gsn1
info:    pingResponse: {"relayWorkerAddress":"0xc68d2d4d042164f449ef7224fbdb93af935ef141","relayManagerAddress":"0x6da884ed2780f861b0027f765d2afb4a7183c3bf","relayHubAddress":"0x6646cD15d33cE3a6933e36de38990121e8ba2806","ownerAddress":"0x253dD319d6db7cE195277d5a1dfd6Ee13A408c76","minGasPrice":"2213232043","maxAcceptanceBudget":"285252","chainId":"80001","networkId":"80001","ready":false,"version":"2.2.5"}
current stake= 0
Failed to register relay: Already owned by 0x253dD319d6db7cE195277d5a1dfd6Ee13A408c76, our account=0x37772859970eEDC507E7bc3c8e44C894B3C3f5Bf

And the same thing happens without the --funds 0 and --stake 0 parameters.

Sorry that didn’t work. If it can’t resolve a full deployment then I think there might be an issue with your gsn-relay-config.json file. Since the withdraw command fails with an error regarding this file, I think it’s possible. Using the cat and vim commands on the config file could help surface some clues.

Hi! I’m having trouble getting getaddr to load a json. I want the relayer to be on Polygon Mainnet, but otherwise I’m trying to follow through the relayer tutorial in the docs. I’ve got a duckdns domain but I don’t think that’s the issue … host in .env is the duckdns domain, and I’m able to seemingly connect up everything, but for some reason the relayer just won’t load. My config which I’ve got in both computer and my google e-micro:
{
“baseRelayFee”: 0,
“pctRelayFee”: 70,
“relayHubAddress”: “0x6C28AfC105e65782D9Ea6F2cA68df84C9e7d750d”,
“ownerAddress”: ownerAddress,
“gasPriceFactor”: 1,
“confirmationsNeeded”: 1,
“ethereumNodeUrl”: “https://polygon-mainnet.g.alchemy.com/v2/my api”,
“coldRestartLogsFromBlock”: 22051314,
“registrationBlockRate”: 1000,
“pastEventsQueryMaxPageSize”: 900,
“maxGasPrice”: 1e12,
“workerMinBalance”: 0.5e18,
“workerTargetBalance”: 0.5e18
}

The error I get when I try to run the multiline command to register the relayer is “Failed to register relay: could contact not relayer, is it running?”

The getaddr page also shows an error 502.

Please help! I really want to get this working :slight_smile:

Edit: I think I must have made some kind of mistake before because now after deleting and doing up a new vm (and getting the same issues again, fixing config, resetting rdc, and possibly also waiting two hours - not sure but it might have to do with how google handles resource-sharing for vms) I do get the json. Have to complete the tute when I get home. I love the work everyone @ openGSN this project is simply fantastic.

Regards,
rajasmasala

Oops haha now I have a new error when trying to register relay:

Failed to register relay: RelayServer failed to set its owner on the StakeManager.

Edit: managed to get past that. But now:

Failed to register relay: Relay not ready after 60s

Edit: an hour later my relay is registered. Great! Starting to get the hang of this interface a bit.