Skip to content

Commit

Permalink
Adds OpenGSN docker setup and readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesduncombe committed Feb 14, 2024
1 parent 3d47ccd commit 63cdf65
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 0 deletions.
17 changes: 17 additions & 0 deletions gsn/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
49 changes: 49 additions & 0 deletions gsn/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 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.
55 changes: 55 additions & 0 deletions gsn/compose.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 63cdf65

Please sign in to comment.