forked from cerc-io/stack-orchestrator
PR to pull over pm-mobymask-v3-demo to upstream repo branch for testing (#761)
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com> Co-authored-by: A. F. Dudley <a.frederick.dudley@gmail.com> Reviewed-on: cerc-io/stack-orchestrator#761
This commit is contained in:
1 parent
2af6ffce77
commit
d6fe5ec47f
20 files changed
+1160
-10
No files matched your search
@@ -0,0 +1,95 @@
|
||||
# MobyMask v3 Demo
|
||||
|
||||
Instructions to setup and deploy an end-to-end MobyMask v3 stack (fixturenet-optimism + watchers + web-app) locally using [laconic-stack-orchestrator](/README.md#install)
|
||||
|
||||
## Setup
|
||||
|
||||
* Clone required repositories:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v3-demo setup-repositories --pull
|
||||
```
|
||||
|
||||
* Build the container images:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v3-demo build-containers
|
||||
```
|
||||
|
||||
* Install MetaMask Flask extension in a chromium browser from chrome web store and follow the setup instructions
|
||||
|
||||
## Deploy
|
||||
|
||||
* Create a spec file for the deployment:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v3-demo deploy init --output mobymask-v3-demo-spec.yml
|
||||
```
|
||||
|
||||
* Create a deployment from the generated spec file:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v3-demo deploy create --spec-file mobymask-v3-demo-spec.yml --deployment-dir mobymask-v3-demo-deployment
|
||||
```
|
||||
|
||||
* Copy over the demo config to place it at an appropriate path:
|
||||
|
||||
```bash
|
||||
cp mobymask-v3-demo-deployment/config/watcher-mobymask-v3-demo/local/config.env mobymask-v3-demo-deployment/
|
||||
```
|
||||
|
||||
### Start the stack
|
||||
|
||||
* Start the deployment:
|
||||
|
||||
```bash
|
||||
laconic-so deployment --dir mobymask-v3-demo-deployment start
|
||||
|
||||
# Useful ports exposed on host
|
||||
# 3001: MobyMask v3 watcher 1 GQL endpoint
|
||||
# 9090: MobyMask v3 watcher 1 relay node endpoint
|
||||
# 9091: MobyMask v3 watcher 2 relay node endpoint
|
||||
# 9092: MobyMask v3 watcher 3 relay node endpoint
|
||||
# 8080: MobyMask snap
|
||||
# 3004: MobyMask v3 app
|
||||
```
|
||||
|
||||
Note: This may take several minutes as it configures and runs the L1, L2 chains and the watchers; you can follow the progress from containers' logs
|
||||
|
||||
* To list and monitor the running containers:
|
||||
|
||||
```bash
|
||||
laconic-so deployment --dir mobymask-v3-demo-deployment ps
|
||||
|
||||
# With status
|
||||
docker ps
|
||||
|
||||
# Check logs for a container
|
||||
docker logs -f <CONTAINER_ID>
|
||||
```
|
||||
|
||||
## Demo
|
||||
|
||||
Follow [demo](./demo.md) to try out the MobyMask app
|
||||
|
||||
## Clean up
|
||||
|
||||
To stop all services running in the background, while preserving data:
|
||||
|
||||
```bash
|
||||
laconic-so deployment --dir mobymask-v3-demo-deployment stop
|
||||
```
|
||||
|
||||
To stop all services and also delete data:
|
||||
|
||||
```bash
|
||||
laconic-so deployment --dir mobymask-v3-demo-deployment stop --delete-volumes
|
||||
|
||||
# Also remove the deployment directory
|
||||
rm -rf mobymask-v3-demo-deployment
|
||||
```
|
||||
|
||||
## Known Issues
|
||||
|
||||
* Resource requirements (memory + time) for building the `cerc/foundry` image are on the higher side
|
||||
* `cerc/optimism-contracts` image is currently based on `cerc/foundry` (Optimism requires foundry installation)
|
||||
@@ -0,0 +1,195 @@
|
||||
# Demo
|
||||
|
||||
## Setup
|
||||
|
||||
* Follow logs and check that all 3 watchers are running in consensus:
|
||||
|
||||
```bash
|
||||
# Follow the logs in three different terminals and keep them running
|
||||
docker logs -f $(docker ps --filter "name=mobymask-watcher-1" -q)
|
||||
docker logs -f $(docker ps --filter "name=mobymask-watcher-2" -q)
|
||||
docker logs -f $(docker ps --filter "name=mobymask-watcher-3" -q)
|
||||
|
||||
# Expected output when all three are running in consensus:
|
||||
# ...
|
||||
# 2024-02-21T10:42:23.932Z laconic:consensus State changed to 3 (FOLLOWER) with term 286
|
||||
# 2024-02-21T10:42:23.932Z laconic:consensus State changed to 2 (CANDIDATE) with term 287
|
||||
# 2024-02-21T10:42:24.406Z laconic:consensus State changed to 1 (LEADER) with term 287
|
||||
# ...
|
||||
|
||||
# At any moment, only one of watchers is the 'LEADER'
|
||||
```
|
||||
|
||||
* In MetaMask, go to settings add a custom network with the following settings:
|
||||
|
||||
```bash
|
||||
# Network name
|
||||
Local Optimism
|
||||
|
||||
# New RPC URL
|
||||
http://127.0.0.1:8545
|
||||
|
||||
# Chain ID
|
||||
42069
|
||||
|
||||
# Currency symbol
|
||||
ETH
|
||||
```
|
||||
|
||||
Switch to the newly added network
|
||||
|
||||
* Import a pre-funded account (using it's private key) for Nitro client in the MobyMask app:
|
||||
|
||||
```bash
|
||||
# PK: 689af8efa8c651a91ad287602527f3af2fe9f6501a7ac4b061667b5a93e037fd
|
||||
# Address: 0xbDA5747bFD65F08deb54cb465eB87D40e51B197E
|
||||
```
|
||||
|
||||
## Run
|
||||
|
||||
### Open MobyMask app
|
||||
|
||||
* Copy the generated invite link from MobyMask deployment container logs:
|
||||
|
||||
```bash
|
||||
docker logs -f $(docker ps -a --filter "name=mobymask-1" -q)
|
||||
|
||||
# A SIGNED DELEGATION/INVITE LINK:
|
||||
# ...
|
||||
# http://127.0.0.1:3004/#/members?invitation=<INVITATION>
|
||||
```
|
||||
|
||||
* Open the invite link in browser where MetaMask was setup
|
||||
|
||||
* In the app’s debug panel (bottom-right), check from `PEERS` and `GRAPH` tabs that the peer gets connected to relay nodes and watcher peers
|
||||
|
||||
* Perform phisher status checks from the app
|
||||
* First 10 queries are served for free; repeat until the free quota is exhausted
|
||||
* Same can be seen in the watcher-1's logs (the app makes all the GQL queries to watcher-1):
|
||||
|
||||
```bash
|
||||
# ...
|
||||
# 2024-02-21T11:01:20.084Z laconic:payments Query rate not configured for "latestBlock", serving free query
|
||||
# 2024-02-21T11:01:20.084Z vulcanize:resolver latestBlock
|
||||
# 2024-02-21T11:01:20.108Z laconic:payments Serving a free query to 0x3c9B491ACA5cf17B6C11E39bbFddCA603F387d41
|
||||
# 2024-02-21T11:01:20.109Z vulcanize:resolver isPhisher 0xf8995f83bbab2bc13fb9a43c6fea4a605616e6f59503f36cbe2ad3abffd0efd3 0xAFA36c47E130d89bcE4470a9030d99f3CEcaD146 TWT:dummyPhisher
|
||||
# 2024-02-21T11:01:20.113Z vulcanize:indexer isPhisher: db miss, fetching from upstream server
|
||||
# ...
|
||||
|
||||
# After free quota has been exhausted:
|
||||
# 2024-02-21T11:06:49.311Z laconic:payments Query rate not configured for "latestBlock", serving free query
|
||||
# 2024-02-21T11:06:49.312Z vulcanize:resolver latestBlock
|
||||
# 2024-02-21T11:06:49.337Z laconic:payments Rejecting query from 0x3c9B491ACA5cf17B6C11E39bbFddCA603F387d41: Free quota exhausted
|
||||
```
|
||||
|
||||
### Setup app's Nitro node
|
||||
|
||||
* Open the `NITRO` tab in debug panel
|
||||
|
||||
* Click on `Connect Wallet` button to connect to MetaMask (use the imported account with funds)
|
||||
|
||||
* Click on `Connect Snap` to install / connect snap; the watcher Nitro clients should show up in the `NITRO` tab
|
||||
|
||||
* Click on `DIRECT FUND` button against watcher-1's Nitro account (`0xAAA6628Ec44A8a742987EF3A114dDFE2D4F7aDCE`) to create a ledger channel with the pre-set amount
|
||||
* Confirm the tx in MetaMask popup; wait some time for the tx to be confirmed and ledger channel to be created
|
||||
* The progress can be followed from watcher-1's logs
|
||||
* The created ledger channel should now be visible in the `NITRO` tab; click on `REFRESH` button otherwise
|
||||
|
||||
* Change amount to `10000` and click on `VIRTUAL FUND` button to create a virtual payment channel
|
||||
* This results in a payment channel between the app and watcher-1
|
||||
* The payment channel's details should now be visible along with a `PAY` and `VIRTUAL DEFUND` buttons
|
||||
|
||||
* Close the debug panel
|
||||
|
||||
### Paid queries and mutations
|
||||
|
||||
* Perform phisher status checks now that a payment channel has been created
|
||||
* Amount set in the debug panel's `NITRO` tab is sent along with each request to the watcher
|
||||
* Check the watcher-1 logs for the received payments:
|
||||
|
||||
```bash
|
||||
# ...
|
||||
# 2024-02-21T11:35:25.538Z ts-nitro:engine {"msg":"Received message","_msg":{"to":"0xAAA662","from":"0x5D12ac","payloadSummaries":[],"proposalSummaries":[],"payments":[{"amount":50,"channelId":"0x654a85725442828f89b497e3973640613c03b5f5ec47302bfa4402d42c07de30"}],"rejectedObjectives":[]}}
|
||||
# 2024-02-21T11:35:25.552Z laconic:payments Query rate not configured for "latestBlock", serving free query
|
||||
# 2024-02-21T11:35:25.553Z vulcanize:resolver latestBlock
|
||||
# 2024-02-21T11:35:25.557Z laconic:payments Received a payment voucher of 50 from 0x5D12acfbBB1caD65fD61983003a50E0CB6900Fd3
|
||||
# 2024-02-21T11:35:25.570Z laconic:payments Serving a paid query for 0x5D12acfbBB1caD65fD61983003a50E0CB6900Fd3
|
||||
# 2024-02-21T11:35:25.570Z vulcanize:resolver isPhisher 0x6a1f0dce967aefd4adf7762c523cde358960236f05734f616ebe69c0abfcb0cc 0xAFA36c47E130d89bcE4470a9030d99f3CEcaD146 TWT:dummyPhisher
|
||||
# 2024-02-21T11:35:25.580Z vulcanize:indexer isPhisher: db miss, fetching from upstream server
|
||||
# ...
|
||||
```
|
||||
|
||||
* Rate for mutations is set to `100` in the watcher; go back to the `NITRO` tab in the debug panel and change amount value besides `PAY` button to >=100
|
||||
|
||||
* Perform a phisher report
|
||||
* Enter a new record(s) and click on `Submit batch to p2p network` button
|
||||
* Among all three watchers running in consensus, whoever is the `LEADER` at time of reporting sends a tx to the chain
|
||||
* Check all the watchers' logs:
|
||||
|
||||
If the payment receiving watcher (1) is leader at that moment:
|
||||
|
||||
```bash
|
||||
# On watcher-1 (payment received + tx sent)
|
||||
# ...
|
||||
# 2024-02-21T11:42:55.088Z vulcanize:libp2p-utils [11:42:55] Received a message on mobymask P2P network from peer: 12D3KooWGXxcwevUY7KCfw8fcGhxqxPaiFMGSU4tgJDjE54QGKzf
|
||||
# 2024-02-21T11:42:55.102Z ts-nitro:engine {"msg":"Received message","_msg":{"to":"0xAAA662","from":"0x5D12ac","payloadSummaries":[],"proposalSummaries":[],"payments":[{"amount":150,"channelId":"0x654a85725442828f89b497e3973640613c03b5f5ec47302bfa4402d42c07de30"}],"rejectedObjectives":[]}}
|
||||
# 2024-02-21T11:42:55.115Z laconic:payments Received a payment voucher of 100 from 0x5D12acfbBB1caD65fD61983003a50E0CB6900Fd3
|
||||
# 2024-02-21T11:42:55.115Z vulcanize:libp2p-utils Payment received for a mutation request from 0x5D12acfbBB1caD65fD61983003a50E0CB6900Fd3
|
||||
# 2024-02-21T11:42:59.115Z vulcanize:libp2p-utils Transaction receipt for invoke message {
|
||||
# to: '0xAFA36c47E130d89bcE4470a9030d99f3CEcaD146',
|
||||
# blockNumber: 4638,
|
||||
# blockHash: '0x23a42bc2ae43771c62b0d59cc48b5858e6e2e488953527ba6a9f5119ae72b42a',
|
||||
# transactionHash: '0xb61cfdfd0ffe937a191a230e1355b9bc5cdd32507f7b4f24a8e6356adf089b64',
|
||||
# effectiveGasPrice: '1500000050',
|
||||
# gasUsed: '136450'
|
||||
# }
|
||||
# ...
|
||||
|
||||
# On other watchers (payment not received + tx not sent)
|
||||
...
|
||||
# 2024-02-21T11:42:50.329Z laconic:consensus State changed to 3 (FOLLOWER) with term 478
|
||||
# 2024-02-21T11:42:55.089Z vulcanize:libp2p-utils [11:42:55] Received a message on mobymask P2P network from peer: 12D3KooWGXxcwevUY7KCfw8fcGhxqxPaiFMGSU4tgJDjE54QGKzf
|
||||
# 2024-02-21T11:42:55.096Z vulcanize:libp2p-utils Not a leader, skipped sending L2 tx
|
||||
# 2024-02-21T11:43:05.095Z vulcanize:libp2p-utils Payment not received
|
||||
# ...
|
||||
```
|
||||
|
||||
If the payment receiving watcher (1) is NOT leader at that moment:
|
||||
|
||||
```bash
|
||||
# On watcher 1 (payment received + tx not sent)
|
||||
# ...
|
||||
# 2024-02-21T11:46:52.049Z vulcanize:libp2p-utils [11:46:52] Received a message on mobymask P2P network from peer: 12D3KooWGXxcwevUY7KCfw8fcGhxqxPaiFMGSU4tgJDjE54QGKzf
|
||||
# 2024-02-21T11:46:52.051Z vulcanize:libp2p-utils Not a leader, skipped sending L2 tx
|
||||
# 2024-02-21T11:46:52.074Z ts-nitro:engine {"msg":"Received message","_msg":{"to":"0xAAA662","from":"0x5D12ac","payloadSummaries":[],"proposalSummaries":[],"payments":[{"amount":450,"channelId":"0x654a85725442828f89b497e3973640613c03b5f5ec47302bfa4402d42c07de30"}],"rejectedObjectives":[]}}
|
||||
# 2024-02-21T11:46:52.097Z laconic:payments Received a payment voucher of 100 from 0x5D12acfbBB1caD65fD61983003a50E0CB6900Fd3
|
||||
# 2024-02-21T11:46:52.097Z vulcanize:libp2p-utils Payment received for a mutation request from 0x5D12acfbBB1caD65fD61983003a50E0CB6900Fd3
|
||||
# ...
|
||||
|
||||
# On the leader watcher (payment not received + tx sent)
|
||||
# ...
|
||||
# 2024-02-21T11:46:40.111Z vulcanize:libp2p-utils Payment not received
|
||||
# 2024-02-21T11:46:52.048Z vulcanize:libp2p-utils [11:46:52] Received a message on mobymask P2P network from peer: 12D3KooWGXxcwevUY7KCfw8fcGhxqxPaiFMGSU4tgJDjE54QGKzf
|
||||
# 2024-02-21T11:46:56.048Z vulcanize:libp2p-utils Transaction receipt for invoke message {
|
||||
# to: '0xAFA36c47E130d89bcE4470a9030d99f3CEcaD146',
|
||||
# blockNumber: 4757,
|
||||
# blockHash: '0x859aa54cb02e8a3f910a01b85c2a7bf9bff7540e83018e7e846f87ca1770e55e',
|
||||
# transactionHash: '0x92f087e4b6ac5604c9d4ecd823d526ca5f8f1bf5c2a92861d6b0f69bd899ba83',
|
||||
# effectiveGasPrice: '1500000050',
|
||||
# gasUsed: '136438'
|
||||
# }
|
||||
```
|
||||
|
||||
* Check phisher status for the reported phishers to confirm state update
|
||||
|
||||
## Clean up
|
||||
|
||||
* From the `NITRO` tab in debug panel, perform `VIRTUAL DEFUND` and `DIRECT DEFUND` (in order) for any payment channels created
|
||||
|
||||
* In the browser's console, delete all indexedDBs:
|
||||
|
||||
```bash
|
||||
await clearNodeStorage()
|
||||
```
|
||||
|
||||
* Remove the snap from MetaMask flask extension
|
||||
@@ -0,0 +1,68 @@
|
||||
# Copyright © 2023 Vulcanize
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
||||
|
||||
from stack_orchestrator.deploy.deployment_context import DeploymentContext
|
||||
from ruamel.yaml import YAML
|
||||
|
||||
|
||||
def create(context: DeploymentContext, extra_args):
|
||||
fixturenet_eth_compose_file = context.deployment_dir.joinpath('compose', 'docker-compose-fixturenet-eth.yml')
|
||||
|
||||
with open(fixturenet_eth_compose_file, 'r') as yaml_file:
|
||||
yaml = YAML()
|
||||
yaml_data = yaml.load(yaml_file)
|
||||
|
||||
new_script = '../config/fixturenet-optimism/run-geth.sh:/opt/testnet/run.sh'
|
||||
if new_script not in yaml_data['services']['fixturenet-eth-geth-1']['volumes']:
|
||||
yaml_data['services']['fixturenet-eth-geth-1']['volumes'].append(new_script)
|
||||
|
||||
with open(fixturenet_eth_compose_file, 'w') as yaml_file:
|
||||
yaml = YAML()
|
||||
yaml.dump(yaml_data, yaml_file)
|
||||
|
||||
# load fixturenet-optimism compose file
|
||||
fixturenet_optimism_compose_file = context.deployment_dir.joinpath(
|
||||
"compose",
|
||||
"docker-compose-fixturenet-optimism.yml"
|
||||
)
|
||||
|
||||
with open(fixturenet_optimism_compose_file, 'r') as yaml_file:
|
||||
yaml = YAML()
|
||||
yaml_data = yaml.load(yaml_file)
|
||||
|
||||
# mount the funding script to volumes
|
||||
fund_accounts_script = (
|
||||
'../config/watcher-mobymask-v3-demo/local/fund-accounts-on-l2.sh'
|
||||
':/app/packages/contracts-bedrock/fund-accounts-on-l2.sh'
|
||||
)
|
||||
yaml_data['services']['fixturenet-optimism-contracts']['volumes'].append(fund_accounts_script)
|
||||
|
||||
# update command to run the script
|
||||
yaml_data['services']['fixturenet-optimism-contracts']['command'] = (
|
||||
'"./wait-for-it.sh -h ${CERC_L1_HOST:-$${DEFAULT_CERC_L1_HOST}}'
|
||||
' -p ${CERC_L1_PORT:-$${DEFAULT_CERC_L1_PORT}} -s -t 60'
|
||||
' -- ./deploy-contracts.sh && ./fund-accounts-on-l2.sh"'
|
||||
)
|
||||
|
||||
# update port mapping for op-geth: 0.0.0.0:8545:8545
|
||||
existing_ports = yaml_data['services']['op-geth']['ports']
|
||||
new_ports = ["0.0.0.0:8545:8545" if "8545" in s else s for s in existing_ports]
|
||||
yaml_data['services']['op-geth']['ports'] = new_ports
|
||||
|
||||
with open(fixturenet_optimism_compose_file, 'w') as yaml_file:
|
||||
yaml = YAML()
|
||||
yaml.dump(yaml_data, yaml_file)
|
||||
|
||||
return None
|
||||
@@ -0,0 +1,47 @@
|
||||
version: "1.0"
|
||||
description: "MobyMask v3 demo stack"
|
||||
name: mobymask-v3-demo
|
||||
repos:
|
||||
# fixturenet repos
|
||||
- git.vdb.to/cerc-io/go-ethereum@v1.11.6-statediff-v5
|
||||
- git.vdb.to/cerc-io/lighthouse
|
||||
- github.com/dboreham/foundry
|
||||
- github.com/ethereum-optimism/optimism@op-node/v1.3.0
|
||||
- github.com/ethereum-optimism/op-geth@v1.101304.0
|
||||
# nitro repo
|
||||
- github.com/cerc-io/ts-nitro@v0.1.15
|
||||
# mobymask watcher repos
|
||||
- github.com/cerc-io/mobymask-v2-watcher-ts@v0.2.4
|
||||
- github.com/cerc-io/MobyMask@v0.1.3
|
||||
# mobymask app repos
|
||||
- github.com/cerc-io/mobymask-snap
|
||||
- github.com/cerc-io/mobymask-ui@v0.2.2
|
||||
containers:
|
||||
# fixturenet images
|
||||
- cerc/go-ethereum
|
||||
- cerc/lighthouse
|
||||
- cerc/lighthouse-cli
|
||||
- cerc/fixturenet-eth-genesis
|
||||
- cerc/fixturenet-eth-geth
|
||||
- cerc/fixturenet-eth-lighthouse
|
||||
- cerc/foundry
|
||||
- cerc/optimism-contracts
|
||||
- cerc/optimism-op-node
|
||||
- cerc/optimism-l2geth
|
||||
- cerc/optimism-op-batcher
|
||||
- cerc/optimism-op-proposer
|
||||
# nitro contract deployment image
|
||||
- cerc/nitro-contracts
|
||||
# mobymask watcher images
|
||||
- cerc/watcher-mobymask-v3
|
||||
- cerc/mobymask
|
||||
# mobymask app images
|
||||
- cerc/mobymask-snap
|
||||
- cerc/mobymask-ui
|
||||
pods:
|
||||
- fixturenet-eth
|
||||
- fixturenet-optimism
|
||||
- nitro-contracts
|
||||
- watcher-mobymask-v3-demo
|
||||
- mobymask-snap
|
||||
- mobymask-app-v3-demo
|
||||
@@ -75,7 +75,7 @@ Create and update an env file to be used in the next step ([defaults](../../conf
|
||||
# Uses a generated peer id if not set (disables consensus)
|
||||
CERC_PEER_ID=
|
||||
|
||||
# Disable payments to upstream ETH server
|
||||
# Enable payments to upstream ETH server
|
||||
CERC_ENABLE_UPSTREAM_PAYMENTS=false
|
||||
```
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ Place the pre-configured watcher alerts rules in Grafana provisioning directory:
|
||||
|
||||
Update the alerting contact points config (`monitoring-watchers-deployment/config/monitoring/grafana/provisioning/alerting/contactpoints.yml`) with desired contact points
|
||||
|
||||
Add corresponding routes to the notification policies config (`monitoring-watchers-deployment/monitoring/grafana/provisioning/alerting/policies.yaml`) with appropriate object-matchers:
|
||||
Add corresponding routes to the notification policies config (`monitoring-watchers-deployment/config/monitoring/grafana/provisioning/alerting/policies.yml`) with appropriate object-matchers:
|
||||
|
||||
```yml
|
||||
...
|
||||
|
||||
Reference in new issue
Block a user