Skip to content

Instantly share code, notes, and snippets.

@spalladino
Last active November 18, 2020 15:10

Revisions

  1. spalladino revised this gist Nov 18, 2020. No changes.
  2. spalladino revised this gist Nov 18, 2020. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions setup-relayer.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    # Manual setup for a GSN relayer

    > :warning: This setup is only good for GSNv1. Head over to https://docs.opengsn.org for the latest setup for GSNv2.
    ## Install nginx and certbot
    ```
    sudo add-apt-repository universe
  3. spalladino revised this gist Aug 12, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion setup-relayer.md
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,7 @@ sudo chown -R ubuntu:ubuntu /app

    ## Download relayer bin
    ```
    curl 'https://github.com/OpenZeppelin/openzeppelin-gsn-helpers/releases/download/v0.1.4/gsn-relay-linux-amd64' -o /app/bin/RelayHttpServer
    curl 'https://github.com/OpenZeppelin/openzeppelin-gsn-helpers/releases/download/v0.1.4/gsn-relay-linux-amd64' -o /app/bin/RelayHttpServer -L -s
    chmod a+x /app/bin/RelayHttpServer
    ```

  4. spalladino revised this gist Aug 12, 2019. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions setup-relayer.md
    Original file line number Diff line number Diff line change
    @@ -15,10 +15,10 @@ sudo mkdir -p /app/data
    sudo chown -R ubuntu:ubuntu /app
    ```

    ## Upload relayer bin (from local workstation)
    ## Download relayer bin
    ```
    make build-server
    rsync build/server/bin/RelayHttpServer gsn-relay-rinkeby:/app/bin/
    curl 'https://github.com/OpenZeppelin/openzeppelin-gsn-helpers/releases/download/v0.1.4/gsn-relay-linux-amd64' -o /app/bin/RelayHttpServer
    chmod a+x /app/bin/RelayHttpServer
    ```

    ## Get certificate and cron it
  5. spalladino revised this gist Aug 6, 2019. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion setup-relayer.md
    Original file line number Diff line number Diff line change
    @@ -91,6 +91,7 @@ LOCAL_PORT=8091
    WORKDIR=/app/data
    NODE_URL=https://NETWORK.infura.io/v3/INFURATOKEN
    RELAY_HUB=RELAY_HUB_ADDRESS
    GAS_PRICE_PERCENT=0
    ```

    ## Configure service on systemd
    @@ -107,7 +108,7 @@ Group=ubuntu
    Type=simple
    WorkingDirectory=/app/
    EnvironmentFile=/app/env
    ExecStart=/app/bin/RelayHttpServer -Url ${URL} -Port ${LOCAL_PORT} -Workdir ${WORKDIR} -EthereumNodeUrl ${NODE_URL} -RelayHubAddress ${RELAY_HUB}
    ExecStart=/app/bin/RelayHttpServer -Url ${URL} -Port ${LOCAL_PORT} -Workdir ${WORKDIR} -EthereumNodeUrl ${NODE_URL} -RelayHubAddress ${RELAY_HUB} -GasPricePercent ${GAS_PRICE_PERCENT}
    StandardOutput=journal
    StandardError=journal
    Restart=on-failure
  6. spalladino revised this gist Aug 5, 2019. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion setup-relayer.md
    Original file line number Diff line number Diff line change
    @@ -77,7 +77,8 @@ server {
    ## Enable new site
    ```
    cd sites-enabled
    ln -ns ../sites-available/relayer
    sudo ln -ns ../sites-available/relayer
    sudo nginx -s reload
    ```

    ## Setup environment
  7. spalladino revised this gist Aug 5, 2019. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions setup-relayer.md
    Original file line number Diff line number Diff line change
    @@ -21,6 +21,12 @@ make build-server
    rsync build/server/bin/RelayHttpServer gsn-relay-rinkeby:/app/bin/
    ```

    ## Get certificate and cron it
    ```
    sudo certbot certonly --nginx
    sudo echo "/usr/bin/certbot renew --quiet" > /etc/cron.monthly/certbot
    ```

    ## Config nginx
    ```
    cd /etc/nginx
    @@ -74,12 +80,6 @@ cd sites-enabled
    ln -ns ../sites-available/relayer
    ```

    ## Get certificate and cron it
    ```
    sudo certbot certonly --nginx
    sudo echo "/usr/bin/certbot renew --quiet" > /etc/cron.monthly/certbot
    ```

    ## Setup environment

    ### /app/env
  8. spalladino revised this gist Aug 5, 2019. 1 changed file with 1 addition and 4 deletions.
    5 changes: 1 addition & 4 deletions setup-relayer.md
    Original file line number Diff line number Diff line change
    @@ -2,13 +2,10 @@

    ## Install nginx and certbot
    ```
    sudo apt-get install nginx
    sudo apt-get update
    sudo apt-get install software-properties-common
    sudo add-apt-repository universe
    sudo add-apt-repository ppa:certbot/certbot
    sudo apt-get update
    sudo apt-get install certbot python-certbot-nginx
    sudo apt-get install nginx software-properties-common certbot python-certbot-nginx
    ```

    ## Create app folder
  9. spalladino revised this gist Aug 1, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion setup-relayer.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # Manual setup for a GSN relayer

    ## Install nginx and cerbot
    ## Install nginx and certbot
    ```
    sudo apt-get install nginx
    sudo apt-get update
  10. spalladino revised this gist Jul 11, 2019. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion setup-relayer.md
    Original file line number Diff line number Diff line change
    @@ -98,7 +98,7 @@ RELAY_HUB=RELAY_HUB_ADDRESS
    ## Configure service on systemd

    ### /etc/sytemd/system/relayer.service

    ```
    [Unit]
    Description=GSN relayer
    StartLimitIntervalSec=300
    @@ -118,6 +118,7 @@ StartLimitBurst=5
    [Install]
    WantedBy=default.target
    ```

    ## Start service
    ```
  11. spalladino created this gist Jul 11, 2019.
    137 changes: 137 additions & 0 deletions setup-relayer.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,137 @@
    # Manual setup for a GSN relayer

    ## Install nginx and cerbot
    ```
    sudo apt-get install nginx
    sudo apt-get update
    sudo apt-get install software-properties-common
    sudo add-apt-repository universe
    sudo add-apt-repository ppa:certbot/certbot
    sudo apt-get update
    sudo apt-get install certbot python-certbot-nginx
    ```

    ## Create app folder
    ```
    sudo mkdir -p /app/bin
    sudo mkdir -p /app/data
    sudo chown -R ubuntu:ubuntu /app
    ```

    ## Upload relayer bin (from local workstation)
    ```
    make build-server
    rsync build/server/bin/RelayHttpServer gsn-relay-rinkeby:/app/bin/
    ```

    ## Config nginx
    ```
    cd /etc/nginx
    sudo rm sites-enabled/default
    ```

    ### /etc/nginx/sites-available/relayer
    ```
    log_format postdata escape=json '$remote_addr - $remote_user [$time_local] '
    '"$request" $status $bytes_sent '
    '"$http_referer" "$http_user_agent" "$request_body"';
    server {
    listen 80;
    server_name example.com;
    location ~ /.well-known {
    root /var/www/html;
    allow all;
    }
    location / {
    return 301 https://$server_name$request_uri;
    }
    }
    server {
    listen 443 ssl;
    server_name example.com;
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    location / {
    access_log /var/log/nginx/access.log postdata;
    proxy_pass http://localhost:8091;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_cache_bypass $http_upgrade;
    }
    }
    ```

    ## Enable new site
    ```
    cd sites-enabled
    ln -ns ../sites-available/relayer
    ```

    ## Get certificate and cron it
    ```
    sudo certbot certonly --nginx
    sudo echo "/usr/bin/certbot renew --quiet" > /etc/cron.monthly/certbot
    ```

    ## Setup environment

    ### /app/env

    ```
    URL=https://example.com
    LOCAL_PORT=8091
    WORKDIR=/app/data
    NODE_URL=https://NETWORK.infura.io/v3/INFURATOKEN
    RELAY_HUB=RELAY_HUB_ADDRESS
    ```

    ## Configure service on systemd

    ### /etc/sytemd/system/relayer.service

    [Unit]
    Description=GSN relayer
    StartLimitIntervalSec=300

    [Service]
    User=ubuntu
    Group=ubuntu
    Type=simple
    WorkingDirectory=/app/
    EnvironmentFile=/app/env
    ExecStart=/app/bin/RelayHttpServer -Url ${URL} -Port ${LOCAL_PORT} -Workdir ${WORKDIR} -EthereumNodeUrl ${NODE_URL} -RelayHubAddress ${RELAY_HUB}
    StandardOutput=journal
    StandardError=journal
    Restart=on-failure
    RestartSec=30
    StartLimitBurst=5

    [Install]
    WantedBy=default.target

    ## Start service
    ```
    sudo systemctl daemon-reload
    sudo systemctl enable relayer
    sudo systemctl start relayer
    ```

    ## Test it (from local workstation)
    ```
    curl 'https://example.com/getaddr'
    ```

    ## Fund it (from local workstation)
    ```
    ./scripts/fundrelay.js RELAY_HUB_ADDRESS 'https://example.com' 0 PROVIDER_URL
    ```