From 950cfa26a815b52691b9b236a8903f5d29e7a385 Mon Sep 17 00:00:00 2001 From: James Duncombe Date: Wed, 14 Feb 2024 11:25:52 +0000 Subject: [PATCH] Adds OpenGSN docker setup and readme. --- gsn/Dockerfile | 17 +++++++++++++++ gsn/README.md | 43 ++++++++++++++++++++++++++++++++++++++ gsn/compose.yml | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 gsn/Dockerfile create mode 100644 gsn/README.md create mode 100644 gsn/compose.yml diff --git a/gsn/Dockerfile b/gsn/Dockerfile new file mode 100644 index 00000000..f704ce5f --- /dev/null +++ b/gsn/Dockerfile @@ -0,0 +1,17 @@ +# Building from the CI image (Circle CI) +FROM cimg/node:16.20.1 + +WORKDIR /app + +RUN git clone --depth 1 --branch v3.0.0-beta.10 \ + https://github.com/opengsn/gsn.git \ + /app + +# Build the deps, compile the contracts etc. +RUN yarn create-all-deps && \ + yarn && \ + yarn preprocess + +# Build the relay server. +RUN cd packages/relay && \ + yarn diff --git a/gsn/README.md b/gsn/README.md new file mode 100644 index 00000000..80fe378b --- /dev/null +++ b/gsn/README.md @@ -0,0 +1,43 @@ +# OpenGSN v3 setup ⛽️ + +The `/gsn` folder within the tt-white-contracts repo contains: + +- `deploy` +- `relay` + +It also contains a `Dockerfile` and `compose.yml` file. + +Read on for the description... + +## Docker files + +`Dockerfile` contains the minimal setup to pull and build the OpenGSN repo. More specifically it: + +- Pulls all the deps +- Compiles the contracts +- Compiles the relay server typescript into the js file ready to run + +`compose.yml` is the `docker compose` main file. + +Running `docker compose up` will bring up **just** the relay server - see "Replay" section below. + +Running `docker run gsn_deploy` will deploy the OpenGSN contracts - see "Deploy" section below. + +## Deploy - dev only + +`deploy/config` holds the config for the deployment of the OpenGSN contracts - specifically: +- `RelayHub` +- `StakeManager` +- `Forwarder` +- `Penalizer` +- `RelayRegistrar` + +Note: This should only be needed on a local chain... we _should_ be using the deployed contracts that exist on chain already. + +See: +- Mainnet network: https://docs.opengsn.org/networks/polygon/polygon.html +- Mumbai network: https://docs.opengsn.org/networks/polygon/mumbai.html + +## Relay + +`relay` holds the relay server's config / data. diff --git a/gsn/compose.yml b/gsn/compose.yml new file mode 100644 index 00000000..936c19ab --- /dev/null +++ b/gsn/compose.yml @@ -0,0 +1,55 @@ +version: "3.8" + +services: + gsn_deploy: + image: ts-opengsn + profiles: ["deploy"] + build: + context: ./ + working_dir: /app/packages/deployer + command: ["yarn", "deploy", "--network", "dev"] + networks: + - eth_network + volumes: + - type: bind + source: ./deploy/config/deploy.ts + target: /app/packages/deployer/deploy/deploy.ts + - type: bind + source: ./deploy/config/hardhat.config.ts + target: /app/packages/deployer/hardhat.config.ts + - type: bind + source: ./deploy/config/deployment-config.ts + target: /app/packages/deployer/deployments/deployment-config.ts + # Deployments held in memory. + - type: tmpfs + target: /app/packages/deployer/deployments/networks + + gsn_relay: + image: ts-opengsn + build: + context: ./ + working_dir: /app/packages/relay + stop_grace_period: 3s + command: [ + "node", + "./dist/runServer.js", + "--config", + "/app/packages/relay/gsn-relay-config.json" + ] + networks: + - eth_network + ports: + - "8090:8090" + volumes: + - type: bind + source: ./relay/config/gsn-relay-config.json + target: /app/packages/relay/gsn-relay-config.json + # Relay data held in memory. + - type: bind + source: ./relay/data + target: /gsn-data + +networks: + eth_network: + name: eth_network + external: true