From 484a9e015deac138869be235e6e21f5cf5468bf6 Mon Sep 17 00:00:00 2001 From: nabarun Date: Wed, 5 Apr 2023 12:20:03 +0530 Subject: [PATCH] Modify mobymask container to stop running server and update readmes --- .../docker-compose-fixturenet-optimism.yml | 4 +- .../docker-compose-mobymask-laconicd.yml | 25 ---- .../docker-compose-watcher-mobymask-v2.yml | 1 - .../config/fixturenet-optimism/l1-params.env | 7 +- .../deploy-and-generate-invite.sh | 2 +- .../watcher-mobymask-v2/optimism-params.env | 5 + .../scripts/deploy-and-generate-invite.ts | 133 ------------------ app/data/pod-list.txt | 3 +- app/data/stacks/fixturenet-optimism/README.md | 4 +- .../stacks/fixturenet-optimism/l2-only.md | 4 +- app/data/stacks/mobymask-v2/README.md | 4 +- app/data/stacks/mobymask-v2/demo.md | 9 -- app/data/stacks/mobymask-v2/mobymask-only.md | 4 +- 13 files changed, 25 insertions(+), 180 deletions(-) delete mode 100644 app/data/compose/docker-compose-mobymask-laconicd.yml delete mode 100644 app/data/container-build/cerc-mobymask/scripts/deploy-and-generate-invite.ts diff --git a/app/data/compose/docker-compose-fixturenet-optimism.yml b/app/data/compose/docker-compose-fixturenet-optimism.yml index d2e96d3f..142a2251 100644 --- a/app/data/compose/docker-compose-fixturenet-optimism.yml +++ b/app/data/compose/docker-compose-fixturenet-optimism.yml @@ -55,7 +55,7 @@ services: entrypoint: "sh" command: "/run-op-geth.sh" ports: - - "8545" + - "0.0.0.0:8545:8545" healthcheck: test: ["CMD", "nc", "-vz", "localhost:8545"] interval: 30s @@ -77,7 +77,7 @@ services: - l2_accounts:/l2-accounts:ro command: ["sh", "/app/run-op-node.sh"] ports: - - "8547" + - "0.0.0.0:8547:8547" healthcheck: test: ["CMD", "nc", "-vz", "localhost:8547"] interval: 30s diff --git a/app/data/compose/docker-compose-mobymask-laconicd.yml b/app/data/compose/docker-compose-mobymask-laconicd.yml deleted file mode 100644 index 4847aeb3..00000000 --- a/app/data/compose/docker-compose-mobymask-laconicd.yml +++ /dev/null @@ -1,25 +0,0 @@ -version: "3.2" - -services: - laconicd: - restart: unless-stopped - image: cerc/laconicd:local - command: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"] - volumes: - - ../config/fixturenet-laconicd/create-fixturenet.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh - ports: - - "9473" - - "8545" - - "8546" - - "1317" - healthcheck: - test: ["CMD", "nc", "-v", "localhost", "8545"] - interval: 20s - timeout: 5s - retries: 15 - start_period: 10s - -networks: - # https://docs.docker.com/compose/networking/#configure-the-default-network - default: - name: mobymask-v2-network diff --git a/app/data/compose/docker-compose-watcher-mobymask-v2.yml b/app/data/compose/docker-compose-watcher-mobymask-v2.yml index e8597aa7..bd585519 100644 --- a/app/data/compose/docker-compose-watcher-mobymask-v2.yml +++ b/app/data/compose/docker-compose-watcher-mobymask-v2.yml @@ -39,7 +39,6 @@ services: - ../config/wait-for-it.sh:/app/packages/server/wait-for-it.sh - ../config/watcher-mobymask-v2/secrets-template.json:/app/packages/server/secrets-template.json - ../config/watcher-mobymask-v2/deploy-and-generate-invite.sh:/app/packages/server/deploy-and-generate-invite.sh - - ../container-build/cerc-mobymask/scripts/deploy-and-generate-invite.ts:/app/packages/server/deploy-and-generate-invite.ts - moby_data_server:/app/packages/server - fixturenet_geth_accounts:/geth-accounts:ro extra_hosts: diff --git a/app/data/config/fixturenet-optimism/l1-params.env b/app/data/config/fixturenet-optimism/l1-params.env index 31876523..93c58805 100644 --- a/app/data/config/fixturenet-optimism/l1-params.env +++ b/app/data/config/fixturenet-optimism/l1-params.env @@ -1,8 +1,13 @@ # Change if pointing to an external L1 endpoint -L1_RPC="http://fixturenet-eth-geth-1:8545" + +# L1 endpoint L1_CHAIN_ID=1212 +L1_RPC="http://fixturenet-eth-geth-1:8545" L1_HOST="fixturenet-eth-geth-1" L1_PORT=8545 + +# Credentials for accounts on L1 to send balance to Optimism Proxy contract from +# (enables them to do transactions on L2) L1_ADDRESS= L1_PRIV_KEY= L1_ADDRESS_2= diff --git a/app/data/config/watcher-mobymask-v2/deploy-and-generate-invite.sh b/app/data/config/watcher-mobymask-v2/deploy-and-generate-invite.sh index 6d53aeb4..615a525c 100755 --- a/app/data/config/watcher-mobymask-v2/deploy-and-generate-invite.sh +++ b/app/data/config/watcher-mobymask-v2/deploy-and-generate-invite.sh @@ -19,4 +19,4 @@ jq --arg privateKey "$PRIVATE_KEY_DEPLOYER" '.privateKey = $privateKey' secrets- export L2_GETH_URL="http://${L2_GETH_HOST}:${L2_GETH_PORT}" jq --arg rpcUrl "$L2_GETH_URL" '.rpcUrl = $rpcUrl' secrets.json > secrets_updated.json && mv secrets_updated.json secrets.json -npx ts-node deploy-and-generate-invite.ts +npm run deployAndGenerateInvite diff --git a/app/data/config/watcher-mobymask-v2/optimism-params.env b/app/data/config/watcher-mobymask-v2/optimism-params.env index ec71bc4b..bafb37a8 100644 --- a/app/data/config/watcher-mobymask-v2/optimism-params.env +++ b/app/data/config/watcher-mobymask-v2/optimism-params.env @@ -1,7 +1,12 @@ # Change if pointing to an external optimism geth endpoint + +# L2 endpoints +# TODO: Add another env for complete URL to handle https L2_GETH_HOST="op-geth" L2_GETH_PORT=8545 L2_NODE_HOST="op-node" L2_NODE_PORT=8547 + +# Credentials for accounts to perform txs on L2 PRIVATE_KEY_DEPLOYER= PRIVATE_KEY_PEER= diff --git a/app/data/container-build/cerc-mobymask/scripts/deploy-and-generate-invite.ts b/app/data/container-build/cerc-mobymask/scripts/deploy-and-generate-invite.ts deleted file mode 100644 index 6895ac51..00000000 --- a/app/data/container-build/cerc-mobymask/scripts/deploy-and-generate-invite.ts +++ /dev/null @@ -1,133 +0,0 @@ -import { ethers } from "ethers"; -import fs from 'fs'; -import path from 'path'; - -// Workaround for missing types -const { generateUtil } = require('eth-delegatable-utils'); - -const phisherRegistryArtifacts = require('../hardhat/artifacts/contracts/PhisherRegistry.sol/PhisherRegistry.json'); -const { privateKey, rpcUrl, baseURI } = require('./secrets.json'); - - -const DEFAULT_BASE_URI = 'https://mobymask.com/#'; - -const configPath = path.join(__dirname, './config.json'); -const { abi } = phisherRegistryArtifacts; - -let provider = new ethers.providers.JsonRpcProvider(rpcUrl); -let signer: ethers.Wallet; -let _chainId: string; -let _name: string = 'MobyMask'; - -setupSigner() - .then(setupContract) - .then(signDelegation) - .catch(console.error); - -async function setupSigner () { - if (privateKey) { - signer = new ethers.Wallet(privateKey, provider) - } -} - -async function setupContract (): Promise { - try { - const config = JSON.parse(fs.readFileSync(configPath, 'utf8')); - const { address, chainId, name } = config; - _name = name; - _chainId = chainId; - return attachToContract(address) - } catch (err) { - console.log('No config detected, deploying contract and creating one.'); - return deployContract() - } -} - -async function deployContract () { - const Registry = new ethers.ContractFactory(abi, phisherRegistryArtifacts.bytecode, signer); - const _name = 'MobyMask'; - const registry = await Registry.deploy(_name); - - const address = registry.address; - fs.writeFileSync(configPath, JSON.stringify({ address, name: _name, chainId: registry.deployTransaction.chainId }, null, 2)); - try { - return await registry.deployed(); - } catch (err) { - console.log('Deployment failed, trying to attach to existing contract.', err); - throw err; - } -} - -async function attachToContract(address: string) { - const Registry = new ethers.Contract(address, abi, signer); - const registry = await Registry.attach(address); - console.log('Attaching to existing contract'); - const deployed = await registry.deployed(); - return deployed; -} - -type Invocation = { - transaction: Transaction, - authority: SignedDelegation[], -}; - -type Transaction = { - to: string, - gasLimit: string, - data: string, -}; - -type SignedDelegation = { - delegation: Delegation, - signature: string, -} - -type Delegation = { - delegate: string, - authority: string, - caveats: Caveat[], -}; - -type Caveat = { - enforcer: string, - terms: string, -} - -type SignedInvocation = { - invocation: Invocation, - signature: string, -} - -async function signDelegation (registry: ethers.Contract) { - const { chainId } = await provider.getNetwork(); - const utilOpts = { - chainId, - verifyingContract: registry.address, - name: _name, - }; - console.log('util opts', utilOpts); - const util = generateUtil(utilOpts) - const delegate = ethers.Wallet.createRandom(); - - // Prepare the delegation message. - // This contract is also a revocation enforcer, so it can be used for caveats: - const delegation = { - delegate: delegate.address, - authority: '0x0000000000000000000000000000000000000000000000000000000000000000', - caveats: [{ - enforcer: registry.address, - terms: '0x0000000000000000000000000000000000000000000000000000000000000000', - }], - }; - - // Owner signs the delegation: - const signedDelegation = util.signDelegation(delegation, signer.privateKey); - const invitation = { - v:1, - signedDelegations: [signedDelegation], - key: delegate.privateKey, - } - console.log('A SIGNED DELEGATION/INVITE LINK:'); - console.log(JSON.stringify(invitation, null, 2)); - console.log((baseURI ?? DEFAULT_BASE_URI) + '/members?invitation=' + encodeURIComponent(JSON.stringify(invitation))); -} diff --git a/app/data/pod-list.txt b/app/data/pod-list.txt index 79c4171a..f24c9ed0 100644 --- a/app/data/pod-list.txt +++ b/app/data/pod-list.txt @@ -15,7 +15,8 @@ watcher-erc20 watcher-erc721 watcher-uniswap-v3 watcher-mobymask-v2 -mobymask-laconicd +mobymask-app +peer-test-app test eth-probe keycloak diff --git a/app/data/stacks/fixturenet-optimism/README.md b/app/data/stacks/fixturenet-optimism/README.md index c98392a2..49e61dbd 100644 --- a/app/data/stacks/fixturenet-optimism/README.md +++ b/app/data/stacks/fixturenet-optimism/README.md @@ -76,8 +76,10 @@ Clear volumes created by this stack: # List all relevant volumes docker volume ls -q --filter name=laconic* +docker volume ls -q --filter "name=.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data" + # Remove all the listed volumes -docker volume rm $(docker volume ls -q --filter name=laconic*) +docker volume rm $(docker volume ls -q --filter "name=.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data") ``` ## Troubleshooting diff --git a/app/data/stacks/fixturenet-optimism/l2-only.md b/app/data/stacks/fixturenet-optimism/l2-only.md index 55eab385..456a1edf 100644 --- a/app/data/stacks/fixturenet-optimism/l2-only.md +++ b/app/data/stacks/fixturenet-optimism/l2-only.md @@ -76,10 +76,10 @@ Clear volumes created by this stack: ```bash # List all relevant volumes -docker volume ls -q --filter name=laconic* +docker volume ls -q --filter "name=.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data" # Remove all the listed volumes -docker volume rm $(docker volume ls -q --filter name=laconic*) +docker volume rm $(docker volume ls -q --filter "name=.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data") ``` ## Troubleshooting diff --git a/app/data/stacks/mobymask-v2/README.md b/app/data/stacks/mobymask-v2/README.md index 7627504b..0da86128 100644 --- a/app/data/stacks/mobymask-v2/README.md +++ b/app/data/stacks/mobymask-v2/README.md @@ -132,11 +132,11 @@ Clear volumes: * List all relevant volumes: ```bash - docker volume ls -q --filter name=laconic* + docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*moby_data_server|.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data" ``` * Remove all the listed volumes: ```bash - docker volume rm $(docker volume ls -q --filter name=laconic*) + docker volume rm $(docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*moby_data_server|.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data") ``` diff --git a/app/data/stacks/mobymask-v2/demo.md b/app/data/stacks/mobymask-v2/demo.md index ac05b29e..8a5049c4 100644 --- a/app/data/stacks/mobymask-v2/demo.md +++ b/app/data/stacks/mobymask-v2/demo.md @@ -4,9 +4,6 @@ ```bash laconic-so --stack mobymask-v2 deploy-system logs mobymask - - # If only running watcher-mobymask-v2 pod - laconic-so --stack mobymask-v2 deploy-system --include watcher-mobymask-v2 logs mobymask ``` The invite link is seen at the end of the logs. Example log: @@ -38,9 +35,6 @@ ```bash laconic-so --stack mobymask-v2 deploy-system ps | grep mobymask-watcher-server - - # If only running watcher-mobymask-v2 pod - laconic-so --stack mobymask-v2 deploy-system --include watcher-mobymask-v2 ps | grep mobymask-watcher-server ``` * Check logs: @@ -81,9 +75,6 @@ ```bash laconic-so --stack mobymask-v2 deploy-system exec mobymask-app "cat src/config.json" - - # If only running watcher-mobymask-v2 pod - laconic-so --stack mobymask-v2 deploy-system --include watcher-mobymask-v2 exec mobymask-app "cat src/config.json" ``` The value of `address` field is the deployed contract address diff --git a/app/data/stacks/mobymask-v2/mobymask-only.md b/app/data/stacks/mobymask-v2/mobymask-only.md index 505507d2..a85eb7f4 100644 --- a/app/data/stacks/mobymask-v2/mobymask-only.md +++ b/app/data/stacks/mobymask-v2/mobymask-only.md @@ -106,7 +106,7 @@ Clear volumes created by this stack: ```bash # List all relevant volumes -docker volume ls -q --filter name=laconic* +docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*moby_data_server|.*fixturenet_geth_accounts" # Remove all the listed volumes -docker volume rm $(docker volume ls -q --filter name=laconic*) +docker volume rm $(docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*moby_data_server|.*fixturenet_geth_accounts") ```