Add ability to run Optimism fixturenet with external L1 endpoint (#273)

* Remove unnecessary todos

* Set option to log commands in shell scripts

* Replace fixturenet-eth dependency with wait on endpoint

* Skip lighthouse node dependency check

* Update all services in the stack

* Use debug flag to enable shell commands logging

* Add bash in op-batcher container

* Update mobymask-v2 instructions

* Update fixturenet-optimism instructions

* Add descriptions for services

* Move ts files to container-build

* Take L1 RPC endpoint from the env file

* Add dev mode restriction for editing env file
This commit is contained in:
prathamesh0
2023-04-04 14:53:28 +05:30
committed by GitHub
parent 4da69ebf4c
commit 2515878eeb
19 changed files with 349 additions and 99 deletions
+33 -9
View File
@@ -8,12 +8,15 @@ Clone required repositories:
```bash
laconic-so --stack fixturenet-optimism setup-repositories
# Exclude cerc-io/go-ethereum repository if running L1 separately
laconic-so --stack fixturenet-optimism setup-repositories --exclude cerc-io/go-ethereum
```
Checkout to the required versions and branches in repos:
```bash
# optimism
# Optimism
cd ~/cerc/optimism
git checkout @eth-optimism/sdk@0.0.0-20230329025055
```
@@ -22,6 +25,9 @@ Build the container images:
```bash
laconic-so --stack fixturenet-optimism build-containers
# Only build containers required for L2 if running L1 separately
laconic-so --stack fixturenet-optimism build-containers --include cerc/foundry,cerc/optimism-contracts,cerc/optimism-op-node,cerc/optimism-l2geth,cerc/optimism-op-batcher
```
This should create the required docker images in the local image registry:
@@ -37,19 +43,36 @@ This should create the required docker images in the local image registry:
## Deploy
(Optional) 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 if running L1 separately
* 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
Deploy the stack:
```bash
laconic-so --stack fixturenet-optimism deploy up
# Only start fixturenet-optimism pod (L2) if running L1 separately
laconic-so --stack fixturenet-optimism deploy up --include fixturenet-optimism
```
To list down the running containers:
The `fixturenet-optimism-contracts` service may take a while (`~15 mins`) to complete running as it:
1. waits for the 'Merge' to happen on L1
2. waits for a finalized block to exist on L1 (so that it can be taken as a starting block for roll ups)
3. deploys the L1 contracts
To list down and monitor the running containers:
```bash
laconic-so --stack fixturenet-optimism deploy ps
# With status
docker ps
# Check logs for a container
docker logs -f <CONTAINER_ID>
```
## Clean up
@@ -58,23 +81,24 @@ Stop all services running in the background:
```bash
laconic-so --stack fixturenet-optimism deploy down
# If only ran fixturenet-optimism pod (L2)
laconic-so --stack fixturenet-optimism deploy down --include fixturenet-optimism
```
Remove volumes created by this stack:
Clear volumes created by this stack:
```bash
docker volume ls
# List all relevant volumes
docker volume ls -q --filter name=laconic*
docker volume rm laconic-d527651bba3cb61886b36a7400bd2a38_fixturenet-geth-accounts
docker volume rm laconic-d527651bba3cb61886b36a7400bd2a38_l1-deployment
docker volume rm laconic-d527651bba3cb61886b36a7400bd2a38_l2-accounts
docker volume rm laconic-d527651bba3cb61886b36a7400bd2a38_op_node_data
# Remove all the listed volumes
docker volume rm $(docker volume ls -q --filter name=laconic*)
```
## Known Issues
* Currently not supported:
* Stopping and restarting the stack from where it left off; currently starts fresh on a restart
* Pointing Optimism (L2) to external L1 endpoint to allow running only L2 services
* Resource requirements (memory + time) for building `cerc/foundry` image are on the higher side
* `cerc/optimism-contracts` image is currently based on `cerc/foundry` (Optimism requires foundry installation)
@@ -13,9 +13,9 @@ containers:
- cerc/fixturenet-eth-lighthouse
- cerc/foundry
- cerc/optimism-contracts
- cerc/optimism-op-node
- cerc/optimism-l2geth
- cerc/optimism-op-batcher
- cerc/optimism-op-node
pods:
- fixturenet-eth
- fixturenet-optimism
+23 -18
View File
@@ -31,6 +31,10 @@ git checkout laconic
# MobyMask
cd ~/cerc/MobyMask
git checkout v0.1.1
# Optimism
cd ~/cerc/optimism
git checkout @eth-optimism/sdk@0.0.0-20230329025055
```
Build the container images:
@@ -43,29 +47,33 @@ This should create the required docker images in the local image registry.
Deploy the stack:
* Deploy the containers
* Deploy the containers:
```bash
laconic-so --stack mobymask-v2 deploy-system up
```
* Check that all containers are healthy using `docker ps`
* List and check the health status of all the containers using `docker ps` and wait for them to be `healthy`
NOTE: The `mobymask-ui` container might not start. If mobymask-app is not running at http://localhost:3002, run command again to start the container
NOTE: The `mobymask-app` container might not start; if the app is not running at http://localhost:3002, restart the container using it's id:
```bash
laconic-so --stack mobymask-v2 deploy-system up
docker ps -a | grep "mobymask-app"
docker restart <CONTAINER_ID>
```
## Tests
Find the watcher container's id:
Find the watcher container's id and export it for later use:
```bash
laconic-so --stack mobymask-v2 deploy-system ps | grep "mobymask-watcher-server"
export CONTAINER_ID=<CONTAINER_ID>
```
Example output
Example output:
```
id: 5d3aae4b22039fcd1c9b18feeb91318ede1100581e75bb5ac54f9e436066b02c, name: laconic-bfb01caf98b1b8f7c8db4d33f11b905a-mobymask-watcher-server-1, ports: 0.0.0.0:3001->3001/tcp, 0.0.0.0:9001->9001/tcp, 0.0.0.0:9090->9090/tcp
@@ -73,12 +81,6 @@ id: 5d3aae4b22039fcd1c9b18feeb91318ede1100581e75bb5ac54f9e436066b02c, name: laco
In above output the container ID is `5d3aae4b22039fcd1c9b18feeb91318ede1100581e75bb5ac54f9e436066b02c`
Export it for later use:
```bash
export CONTAINER_ID=<CONTAINER_ID>
```
Run the peer tests:
```bash
@@ -87,7 +89,11 @@ docker exec -w /app/packages/peer $CONTAINER_ID yarn test
## Web Apps
Check that the status for web-app containers are healthy by using `docker ps`
Check that the web-app containers are healthy:
```bash
docker ps | grep -E 'mobymask-app|peer-test-app'
```
### mobymask-app
@@ -119,15 +125,14 @@ laconic-so --stack mobymask-v2 deploy-system down
Clear volumes:
* List all volumes
* List all relevant volumes:
```bash
docker volume ls
docker volume ls -q --filter name=laconic*
```
* Remove volumes created by this stack
* Remove all the listed volumes:
Example:
```bash
docker volume rm laconic-bfb01caf98b1b8f7c8db4d33f11b905a_moby_data_server
docker volume rm $(docker volume ls -q --filter name=laconic*)
```
+18 -18
View File
@@ -1,22 +1,22 @@
# Demo
* Get the root invite link URL for mobymask-app
* Get the root invite link URL for mobymask-app:
```
```bash
laconic-so --stack mobymask-v2 deploy-system logs mobymask
```
The invite link is seen at the end of the logs
Example:
```
The invite link is seen at the end of the logs. Example log:
```bash
laconic-bfb01caf98b1b8f7c8db4d33f11b905a-mobymask-1 | http://127.0.0.1:3002/#/members?invitation=%7B%22v%22%3A1%2C%22signedDelegations%22%3A%5B%7B%22signature%22%3A%220x7559bd412f02677d60820e38243acf61547f79339395a34f7d4e1630e645aeb30535fc219f79b6fbd3af0ce3bd05132ad46d2b274a9fbc4c36bc71edd09850891b%22%2C%22delegation%22%3A%7B%22delegate%22%3A%220xc0838c92B2b71756E0eAD5B3C1e1F186baeEAAac%22%2C%22authority%22%3A%220x0000000000000000000000000000000000000000000000000000000000000000%22%2C%22caveats%22%3A%5B%7B%22enforcer%22%3A%220x558024C7d593B840E1BfD83E9B287a5CDad4db15%22%2C%22terms%22%3A%220x0000000000000000000000000000000000000000000000000000000000000000%22%7D%5D%7D%7D%5D%2C%22key%22%3A%220x98da9805821f1802196443e578fd32af567bababa0a249c07c82df01ecaa7d8d%22%7D
```
* Open the invite link in browser to use the mobymask-app.
* Open the invite link in a browser to use the mobymask-app.
NOTE: Before opening the invite link, clear the browser cache (local storage) for http://127.0.0.1:3002 to remove old invitations
* In the debug panel, check if it is connected to the p2p network (It should be connected to atleast one other peer for pubsub to work).
* In the debug panel, check if it is connected to the p2p network (it should be connected to at least one other peer for pubsub to work).
* Create an invite link in the app by clicking on `Create new invite link` button.
@@ -31,24 +31,24 @@
* In a terminal check logs from the watcher peer container.
* Get the container id
* Get the container id:
```bash
laconic-so --stack mobymask-v2 deploy-system ps | grep mobymask-watcher-server
```
* Check logs
* Check logs:
```bash
docker logs -f CONTAINER_ID
docker logs -f <CONTAINER_ID>
```
* It should have received the message, sent transaction to L2 chain and received a transaction receipt with block details.
* It should have received the message, sent transaction to L2 chain and received a transaction receipt for an `invoke` message with block details.
Example log:
```
2023-03-23T10:25:19.771Z vulcanize:peer-listener [10:25:19] Received a message on mobymask P2P network from peer: PeerId(12D3KooWAVNswtcrX12iDYukEoxdQwD34kJyRWcQTfZ4unGg2xjd)
```bash
2023-03-23T10:25:19.771Z vulcanize:peer-listener [10:25:19] Received a message on mobymask P2P network from peer: 12D3KooWAVNswtcrX12iDYukEoxdQwD34kJyRWcQTfZ4unGg2xjd
2023-03-23T10:25:24.143Z laconic:libp2p-utils Transaction receipt for invoke message {
to: '0x558024C7d593B840E1BfD83E9B287a5CDad4db15',
blockNumber: 1996,
@@ -60,7 +60,7 @@
```
* Check the phisher in watcher GQL: http://localhost:3001/graphql
* Use the blockHash from transaction receipt details or query for latest block
* Use the blockHash from transaction receipt details or query for latest block:
```gql
query {
@@ -71,7 +71,7 @@
}
```
* Get the deployed contract address
* Get the deployed contract address:
```bash
laconic-so --stack mobymask-v2 deploy-system exec mobymask-app "cat src/config.json"
@@ -94,7 +94,7 @@
}
```
It should return true for reported phisher names.
It should return `true` for reported phisher names.
* Watcher internally is using L2 chain `eth_getStorageAt` method.
@@ -107,7 +107,7 @@
* Revocation messages can be seen in the debug panel `MESSAGES` tab of other browsers.
* Check the watcher peer logs. It should receive a message and log the transaction receipt for revoke message.
* Check the watcher peer logs. It should receive a message and log the transaction receipt for a `revoke` message.
* Try reporting a phisher from the revoked invitee's browser.
@@ -129,4 +129,4 @@
}
```
It should return false as the invitation/delegation used for reporting phishers has been revoked.
It should return `false` as the invitation/delegation used for reporting phishers has been revoked.