Add an option to pass env file to deploy command (#304)

* Add an option to pass env file to deploy command

* Use env variable mapping in fixturenet-optimism stack

* Use default values from checked in env files

* Use env variable mapping in mobymask-v2 stack

* Update instructions

* Add extra hosts in app compose files and update instructions

* Add CERC prefix to env variables in fixturenet-optimism stack

* Add CERC prefix to env variables in mobymask-v2 stack

Former-commit-id: 6b62247ef7a32e20e55c529afa0b80fadb6873a1
This commit is contained in:
prathamesh0
2023-04-11 16:21:03 +05:30
committed by GitHub
parent ffc24c0be8
commit c2a3ffe0dd
24 changed files with 276 additions and 120 deletions
@@ -10,6 +10,8 @@ Clone required repositories:
```bash
laconic-so --stack fixturenet-optimism setup-repositories
# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the repositories mentioned below and re-run the command
```
Checkout to the required versions and branches in repos:
@@ -109,7 +111,7 @@ docker volume rm $(docker volume ls -q --filter "name=.*fixturenet_geth_accounts
docker volume rm $(docker volume ls -q --filter name=l2_geth_data)
```
* Reuse the deployment command used in [Deploy](#deploy) to restart the stopped containers
* Re-run the deployment command used in [Deploy](#deploy) to restart the stopped containers
## Known Issues
+22 -7
View File
@@ -10,6 +10,8 @@ Clone required repositories:
```bash
laconic-so --stack fixturenet-optimism setup-repositories --exclude cerc-io/go-ethereum
# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the repositories mentioned below and re-run the command
```
Checkout to the required versions and branches in repos:
@@ -35,16 +37,29 @@ This should create the required docker images in the local image registry:
## Deploy
Update the [l1-params.env](../../config/fixturenet-optimism/l1-params.env) file with L1 endpoint (`L1_RPC`, `L1_HOST` and `L1_PORT`) and other params
Create and update an env file to be used in the next step ([defaults](../../config/fixturenet-optimism/l1-params.env)):
* NOTE:
* Stack Orchestrator needs to be run in [`dev`](/docs/CONTRIBUTING.md#install-developer-mode) mode to be able to edit the env file
* If L1 is running on the host machine, use `host.docker.internal` as the hostname to access the host port
```bash
# External L1 endpoint
CERC_L1_CHAIN_ID=
CERC_L1_RPC=
CERC_L1_HOST=
CERC_L1_PORT=
# Credentials for accounts on L1 to send balance to Optimism Proxy contract from
# (enables them to do transactions on L2)
CERC_L1_ADDRESS=
CERC_L1_PRIV_KEY=
CERC_L1_ADDRESS_2=
CERC_L1_PRIV_KEY_2=
```
* NOTE: If L1 is running on the host machine, use `host.docker.internal` as the hostname to access the host port
Deploy the stack:
```bash
laconic-so --stack fixturenet-optimism deploy up --include fixturenet-optimism
laconic-so --stack fixturenet-optimism deploy --include fixturenet-optimism --env-file <PATH_TO_ENV_FILE> up
```
The `fixturenet-optimism-contracts` service may take a while (`~15 mins`) to complete running as it:
@@ -69,7 +84,7 @@ docker logs -f <CONTAINER_ID>
Stop all services running in the background:
```bash
laconic-so --stack fixturenet-optimism deploy down --include fixturenet-optimism
laconic-so --stack fixturenet-optimism deploy --include fixturenet-optimism down
```
Clear volumes created by this stack:
@@ -84,4 +99,4 @@ docker volume rm $(docker volume ls -q --filter "name=.*fixturenet_geth_accounts
## Troubleshooting
See [Troubleshooting](./README.md#troubleshooting)
See [Troubleshooting](./README.md#troubleshooting)
+3 -1
View File
@@ -1,10 +1,12 @@
# MobyMask v2 watcher
Instructions to setup and deploy an end-to-end MobyMask v2 stack ([L1](../fixturenet-eth/) + [L2](../fixturenet-optimism/) chains + watcher) using [laconic-stack-orchestrator](/README.md#install)
Instructions to setup and deploy an end-to-end MobyMask v2 stack ([L1](../fixturenet-eth/) + [L2](../fixturenet-optimism/) chains + watcher + web-app(s)) using [laconic-stack-orchestrator](/README.md#install)
We support running just the watcher part of stack, given an external L2 Optimism endpoint.
Follow [mobymask-only](./mobymask-only.md) for the same.
We also support running just the web-app(s), given external watcher GQL (for mobymask-app) and relay node endpoints. Follow [web-apps.md](./web-apps.md) for the same.
## Setup
Clone required repositories:
+42 -9
View File
@@ -10,6 +10,8 @@ Clone required repositories:
```bash
laconic-so --stack mobymask-v2 setup-repositories --include cerc-io/MobyMask,cerc-io/watcher-ts
# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the repositories mentioned below and re-run the command
```
Checkout to the required versions and branches in repos:
@@ -36,19 +38,38 @@ This should create the required docker images in the local image registry
### Configuration
* In [mobymask-params.env](../../config/watcher-mobymask-v2/mobymask-params.env) file set `DEPLOYED_CONTRACT` to existing deployed mobymask contract address
* Setting `DEPLOYED_CONTRACT` will skip contract deployment when running stack
* `ENABLE_PEER_L2_TXS` is used to enable/disable sending txs to L2 chain from watcher peer.
* Update the [optimism-params.env](../../config/watcher-mobymask-v2/optimism-params.env) file with Optimism endpoints and other params for the Optimism running separately
* `PRIVATE_KEY_PEER` is used by watcher peer to send txs to L2 chain
* NOTE:
* Stack Orchestrator needs to be run in [`dev`](/docs/CONTRIBUTING.md#install-developer-mode) mode to be able to edit the env file
* If Optimism is running on the host machine, use `host.docker.internal` as the hostname to access the host port
Create and update an env file to be used in the next step ([defaults](../../config/watcher-mobymask-v2/)):
```bash
# External L2 endpoints
CERC_L2_GETH_RPC=
CERC_L2_GETH_HOST=
CERC_L2_GETH_PORT=
CERC_L2_NODE_HOST=
CERC_L2_NODE_PORT=
# Credentials for accounts to perform txs on L2
CERC_PRIVATE_KEY_DEPLOYER=
CERC_PRIVATE_KEY_PEER=
# Base URI for mobymask-app
# (used for generating a root invite link after deploying the contract)
CERC_MOBYMASK_APP_BASE_URI="http://127.0.0.1:3002/#"
# Set to false for disabling watcher peer to send txs to L2
CERC_ENABLE_PEER_L2_TXS=true
# (Optional) Set already deployed MobyMask contract address to avoid deploying contract in the stack
CERC_DEPLOYED_CONTRACT=
```
* NOTE: If Optimism is running on the host machine, use `host.docker.internal` as the hostname to access the host port
### Deploy the stack
```bash
laconic-so --stack mobymask-v2 deploy --include watcher-mobymask-v2 up
laconic-so --stack mobymask-v2 deploy --include watcher-mobymask-v2 --env-file <PATH_TO_ENV_FILE> up
```
To list down and monitor the running containers:
@@ -63,10 +84,22 @@ docker ps
docker logs -f <CONTAINER_ID>
```
The watcher endpoint is exposed on host port `3001` and the relay node endpoint is exposed on host port `9090`
Check the logs of the deployment container to get the deployed contract's address and generated root invite link:
```bash
docker logs -f $(docker ps -aq --filter name="mobymask-1")
```
## Tests
See [Tests](./README.md#tests)
## Web Apps
For deploying the web-app(s) separately after deploying the watcher, follow [web-apps.md](./web-apps.md)
## Clean up
Stop all services running in the background:
+37 -10
View File
@@ -10,6 +10,8 @@ Clone required repositories:
```bash
laconic-so --stack mobymask-v2 setup-repositories --include cerc-io/react-peer,cerc-io/mobymask-ui
# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the repositories mentioned below and re-run the command
```
Checkout to the required versions and branches in repos:
@@ -36,36 +38,61 @@ This should create the required docker images in the local image registry
### Configuration
* Update the [mobymask-params.env](../../config/watcher-mobymask-v2/mobymask-params.env) file with watcher endpoints and other params required by the web-apps
* `WATCHER_HOST` and `WATCHER_PORT` is used to check if watcher is up before building and deploying mobymask-app
* `APP_WATCHER_URL` is used by mobymask-app to make GQL queries
* `DEPLOYED_CONTRACT` and `CHAIN_ID` is used by mobymask-app in app config when creating messgaes for L2 txs
* `RELAY_NODES` is used by the web-apps to connect to the relay nodes (run in watcher)
* NOTE:
* Stack Orchestrator needs to be run in [`dev`](/docs/CONTRIBUTING.md#install-developer-mode) mode to be able to edit the env file
* If watcher is running on the host machine, use `host.docker.internal` as the hostname to access the host port
Create and update an env file to be used in the next step ([defaults](../../config/watcher-mobymask-v2/mobymask-params.env)):
```bash
# Set relay nodes to be used by the web-app
CERC_RELAY_NODES=["/ip4/127.0.0.1/tcp/9090/ws/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t"]
# Also add if running MobyMask app:
# External watcher endpoint (to check if watcher is up)
CERC_WATCHER_HOST=
CERC_WATCHER_PORT=
# Watcher endpoint used by the app for GQL queries
CERC_APP_WATCHER_URL="http://127.0.0.1:3001"
# Set deployed MobyMask contract address to be used in MobyMask app's config
CERC_DEPLOYED_CONTRACT=
# L2 Chain ID used by mobymask web-app for L2 txs
CERC_CHAIN_ID=42069
```
* NOTE: If watcher is running on the host machine, use `host.docker.internal` as the hostname to access the host port
### Deploy the stack
For running mobymask-app
```bash
laconic-so --stack mobymask-v2 deploy --include mobymask-app up
laconic-so --stack mobymask-v2 deploy --include mobymask-app --env-file <PATH_TO_ENV_FILE> up
# Runs on host port 3002
```
For running peer-test-app
```bash
laconic-so --stack mobymask-v2 deploy --include peer-test-app up
laconic-so --stack mobymask-v2 deploy --include peer-test-app --env-file <PATH_TO_ENV_FILE> up
# Runs on host port 3003
```
To list down and monitor the running containers:
```bash
laconic-so --stack mobymask-v2 deploy --include [mobymask-app | peer-test-app] ps
docker ps
# Check logs for a container
docker logs -f <CONTAINER_ID>
```
## Demo
Follow the [demo](./demo.md) to try out the MobyMask app with L2 chain
## Clean up
Stop all services running in the background: