diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml deleted file mode 100644 index e551240d..00000000 --- a/.gitea/workflows/test.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Tests - -on: - pull_request: - branches: '*' - push: - branches: '*' - -jobs: - test: - name: "Run basic test suite" - runs-on: ubuntu-latest - steps: - - name: "Clone project repository" - uses: actions/checkout@v3 - - name: "Install Python" - uses: cerc-io/setup-python@v4 - with: - python-version: '3.8' - - name: "Print Python version" - run: python3 --version - - name: "Install shiv" - run: pip install shiv - - name: "Build local shiv package" - run: ./scripts/build_shiv_package.sh - - name: "Run smoke tests" - run: ./tests/smoke-test/run-smoke-test.sh diff --git a/app/data/compose/docker-compose-fixturenet-eth.yml b/app/data/compose/docker-compose-fixturenet-eth.yml index 508543e4..2eaad084 100644 --- a/app/data/compose/docker-compose-fixturenet-eth.yml +++ b/app/data/compose/docker-compose-fixturenet-eth.yml @@ -58,6 +58,12 @@ services: environment: RUN_BOOTNODE: "true" image: cerc/fixturenet-eth-lighthouse:local + healthcheck: + test: ["CMD", "/scripts/status-internal.sh"] + interval: 10s + timeout: 100s + retries: 3 + start_period: 15s fixturenet-eth-lighthouse-1: hostname: fixturenet-eth-lighthouse-1 diff --git a/app/data/compose/docker-compose-fixturenet-optimism.yml b/app/data/compose/docker-compose-fixturenet-optimism.yml index 142a2251..6dcde5c9 100644 --- a/app/data/compose/docker-compose-fixturenet-optimism.yml +++ b/app/data/compose/docker-compose-fixturenet-optimism.yml @@ -1,47 +1,40 @@ version: '3.7' services: - # Generates and funds the accounts required when setting up the L2 chain (outputs to volume l2_accounts) - # Creates / updates the configuration for L1 contracts deployment - # Deploys the L1 smart contracts (outputs to volume l1_deployment) fixturenet-optimism-contracts: hostname: fixturenet-optimism-contracts image: cerc/optimism-contracts:local - env_file: - - ../config/fixturenet-optimism/l1-params.env - # Waits for L1 endpoint to be up before running the script - command: | - "./wait-for-it.sh -h $${L1_HOST} -p $${L1_PORT} -s -t 60 -- ./run.sh" + depends_on: + fixturenet-eth-geth-1: + condition: service_healthy + fixturenet-eth-bootnode-lighthouse: + condition: service_healthy + environment: + CHAIN_ID: 1212 + L1_RPC: "http://fixturenet-eth-geth-1:8545" + command: "./run.sh" volumes: - - ../config/wait-for-it.sh:/app/packages/contracts-bedrock/wait-for-it.sh - - ../container-build/cerc-optimism-contracts/hardhat-tasks/verify-contract-deployment.ts:/app/packages/contracts-bedrock/tasks/verify-contract-deployment.ts - - ../container-build/cerc-optimism-contracts/hardhat-tasks/rekey-json.ts:/app/packages/contracts-bedrock/tasks/rekey-json.ts - - ../container-build/cerc-optimism-contracts/hardhat-tasks/send-balance.ts:/app/packages/contracts-bedrock/tasks/send-balance.ts + - ../config/fixturenet-optimism/optimism-contracts/rekey-json.ts:/app/packages/contracts-bedrock/tasks/rekey-json.ts + - ../config/fixturenet-optimism/optimism-contracts/send-balance.ts:/app/packages/contracts-bedrock/tasks/send-balance.ts - ../config/fixturenet-optimism/optimism-contracts/update-config.js:/app/packages/contracts-bedrock/update-config.js - ../config/fixturenet-optimism/optimism-contracts/run.sh:/app/packages/contracts-bedrock/run.sh - fixturenet_geth_accounts:/geth-accounts:ro - l2_accounts:/l2-accounts - l1_deployment:/app/packages/contracts-bedrock - extra_hosts: - - "host.docker.internal:host-gateway" - # Generates the config files required for L2 (outputs to volume l2_config) op-node-l2-config-gen: image: cerc/optimism-op-node:local depends_on: fixturenet-optimism-contracts: condition: service_completed_successfully - env_file: - - ../config/fixturenet-optimism/l1-params.env + environment: + L1_RPC: "http://fixturenet-eth-geth-1:8545" volumes: - ../config/fixturenet-optimism/generate-l2-config.sh:/app/generate-l2-config.sh - l1_deployment:/contracts-bedrock:ro - - l2_config:/app + - op_node_data:/app command: ["sh", "/app/generate-l2-config.sh"] - extra_hosts: - - "host.docker.internal:host-gateway" - # Initializes and runs the L2 execution client (outputs to volume l2_geth_data) op-geth: image: cerc/optimism-l2geth:local depends_on: @@ -49,13 +42,12 @@ services: condition: service_started volumes: - ../config/fixturenet-optimism/run-op-geth.sh:/run-op-geth.sh - - l2_config:/op-node:ro + - op_node_data:/op-node:ro - l2_accounts:/l2-accounts:ro - - l2_geth_data:/datadir entrypoint: "sh" command: "/run-op-geth.sh" ports: - - "0.0.0.0:8545:8545" + - "8545" healthcheck: test: ["CMD", "nc", "-vz", "localhost:8545"] interval: 30s @@ -63,54 +55,45 @@ services: retries: 10 start_period: 10s - # Runs the L2 consensus client (Sequencer node) op-node: - env_file: - - ../config/fixturenet-optimism/l1-params.env + environment: + L1_RPC: "http://fixturenet-eth-geth-1:8545" depends_on: op-geth: condition: service_healthy image: cerc/optimism-op-node:local volumes: - ../config/fixturenet-optimism/run-op-node.sh:/app/run-op-node.sh - - l2_config:/op-node-data:ro + - op_node_data:/op-node-data:ro - l2_accounts:/l2-accounts:ro command: ["sh", "/app/run-op-node.sh"] ports: - - "0.0.0.0:8547:8547" + - "8547" healthcheck: test: ["CMD", "nc", "-vz", "localhost:8547"] interval: 30s timeout: 10s retries: 10 start_period: 10s - extra_hosts: - - "host.docker.internal:host-gateway" - # Runs the batcher (takes transactions from the Sequencer and publishes them to L1) op-batcher: - env_file: - - ../config/fixturenet-optimism/l1-params.env + environment: + L1_RPC: "http://fixturenet-eth-geth-1:8545" depends_on: + fixturenet-eth-geth-1: + condition: service_healthy op-node: condition: service_healthy op-geth: condition: service_healthy image: cerc/optimism-op-batcher:local volumes: - - ../config/wait-for-it.sh:/wait-for-it.sh - ../config/fixturenet-optimism/run-op-batcher.sh:/run-op-batcher.sh - l2_accounts:/l2-accounts:ro - entrypoint: ["sh", "-c"] - # Waits for L1 endpoint to be up before running the batcher - command: | - "/wait-for-it.sh -h $${L1_HOST} -p $${L1_PORT} -s -t 60 -- /run-op-batcher.sh" - extra_hosts: - - "host.docker.internal:host-gateway" + entrypoint: "sh" + command: "/run-op-batcher.sh" volumes: - fixturenet_geth_accounts: - l1_deployment: + op_node_data: l2_accounts: - l2_config: - l2_geth_data: + l1_deployment: diff --git a/app/data/compose/docker-compose-mobymask-app.yml b/app/data/compose/docker-compose-mobymask-app.yml deleted file mode 100644 index db95eeac..00000000 --- a/app/data/compose/docker-compose-mobymask-app.yml +++ /dev/null @@ -1,31 +0,0 @@ -version: '3.2' - -services: - # Builds and serves the MobyMask react-app - mobymask-app: - image: cerc/mobymask-ui:local - env_file: - - ../config/watcher-mobymask-v2/mobymask-params.env - # Waits for watcher server to be up before app build - # Required when running with watcher stack to get deployed contract address - command: - - sh - - -c - - ./wait-for-it.sh -h $${WATCHER_HOST} -p $${WATCHER_PORT} -s -t 0 -- ./mobymask-app-start.sh - volumes: - - ../config/wait-for-it.sh:/app/wait-for-it.sh - - ../config/watcher-mobymask-v2/mobymask-app-config.json:/app/src/mobymask-app-config.json - - ../config/watcher-mobymask-v2/mobymask-app-start.sh:/app/mobymask-app-start.sh - - mobymask_deployment:/server - ports: - - "0.0.0.0:3002:3000" - healthcheck: - test: ["CMD", "nc", "-v", "localhost", "3000"] - interval: 20s - timeout: 5s - retries: 15 - start_period: 10s - shm_size: '1GB' - -volumes: - mobymask_deployment: diff --git a/app/data/compose/docker-compose-mobymask-laconicd.yml b/app/data/compose/docker-compose-mobymask-laconicd.yml new file mode 100644 index 00000000..4847aeb3 --- /dev/null +++ b/app/data/compose/docker-compose-mobymask-laconicd.yml @@ -0,0 +1,25 @@ +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-peer-test-app.yml b/app/data/compose/docker-compose-peer-test-app.yml deleted file mode 100644 index 3ddbd308..00000000 --- a/app/data/compose/docker-compose-peer-test-app.yml +++ /dev/null @@ -1,21 +0,0 @@ -version: '3.2' - -services: - peer-test-app: - # Builds and serves the peer-test react-app - image: cerc/react-peer:local - working_dir: /app/packages/test-app - env_file: - - ../config/watcher-mobymask-v2/mobymask-params.env - command: ["sh", "./test-app-start.sh"] - volumes: - - ../config/watcher-mobymask-v2/test-app-config.json:/app/packages/test-app/src/test-app-config.json - - ../config/watcher-mobymask-v2/test-app-start.sh:/app/packages/test-app/test-app-start.sh - ports: - - "0.0.0.0:3003:3000" - healthcheck: - test: ["CMD", "nc", "-v", "localhost", "3000"] - interval: 20s - timeout: 5s - retries: 15 - start_period: 10s diff --git a/app/data/compose/docker-compose-watcher-mobymask-v2.yml b/app/data/compose/docker-compose-watcher-mobymask-v2.yml index 2e014471..ed5c203a 100644 --- a/app/data/compose/docker-compose-watcher-mobymask-v2.yml +++ b/app/data/compose/docker-compose-watcher-mobymask-v2.yml @@ -1,7 +1,6 @@ version: '3.2' services: - # Starts the PostgreSQL database for watcher mobymask-watcher-db: restart: unless-stopped image: postgres:14-alpine @@ -22,55 +21,53 @@ services: retries: 15 start_period: 10s - # Deploys MobyMask contract and generates an invite link - # Deployment is skipped if DEPLOYED_CONTRACT env is already set mobymask: + restart: unless-stopped image: cerc/mobymask:local working_dir: /app/packages/server - env_file: - - ../config/watcher-mobymask-v2/optimism-params.env - - ../config/watcher-mobymask-v2/mobymask-params.env + depends_on: + op-node: + condition: service_healthy + op-geth: + condition: service_healthy + # TODO: Configure env file for ETH RPC URL & private key environment: - ENV=PROD - # Waits for L2 Optimism Geth and Node servers to be up before deploying contract - command: - - sh - - -c - - | - ./wait-for-it.sh -h $${L2_GETH_HOST} -p $${L2_GETH_PORT} -s -t 0 && \ - ./wait-for-it.sh -h $${L2_NODE_HOST} -p $${L2_NODE_PORT} -s -t 0 && \ - ./deploy-and-generate-invite.sh + command: ["sh", "./deploy-invite.sh"] volumes: - - ../config/wait-for-it.sh:/app/packages/server/wait-for-it.sh + # TODO: add a script to set rpc endpoint from env + # add manually if running seperately - ../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 - - mobymask_deployment:/app/packages/server + - ../config/watcher-mobymask-v2/deploy-invite.sh:/app/packages/server/deploy-invite.sh + - moby_data_server:/app/packages/server - fixturenet_geth_accounts:/geth-accounts:ro - extra_hosts: - - "host.docker.internal:host-gateway" + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "3330"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 10s - # Starts the mobymask-v2-watcher server mobymask-watcher-server: + # TODO: pass optimism rpc endpoint restart: unless-stopped depends_on: mobymask-watcher-db: condition: service_healthy mobymask: - condition: service_completed_successfully + condition: service_healthy image: cerc/watcher-mobymask-v2:local - env_file: - - ../config/watcher-mobymask-v2/optimism-params.env - - ../config/watcher-mobymask-v2/mobymask-params.env - command: ["sh", "start-server.sh"] + command: ["sh", "server-start.sh"] volumes: + # TODO: add a script to set rpc endpoint from env + # add manually if running seperately - ../config/watcher-mobymask-v2/watcher-config-template.toml:/app/packages/mobymask-v2-watcher/environments/watcher-config-template.toml - ../config/watcher-mobymask-v2/peer.env:/app/packages/peer/.env - ../config/watcher-mobymask-v2/relay-id.json:/app/packages/mobymask-v2-watcher/relay-id.json - ../config/watcher-mobymask-v2/peer-id.json:/app/packages/mobymask-v2-watcher/peer-id.json - - ../config/watcher-mobymask-v2/start-server.sh:/app/packages/mobymask-v2-watcher/start-server.sh - - mobymask_deployment:/server + - ../config/watcher-mobymask-v2/server-start.sh:/app/packages/mobymask-v2-watcher/server-start.sh + - moby_data_server:/server - fixturenet_geth_accounts:/geth-accounts:ro - # Expose GQL, metrics and relay node ports ports: - "0.0.0.0:3001:3001" - "0.0.0.0:9001:9001" @@ -81,10 +78,50 @@ services: timeout: 5s retries: 15 start_period: 5s - extra_hosts: - - "host.docker.internal:host-gateway" + + # TODO: Move to a separate pod + mobymask-app: + depends_on: + mobymask-watcher-server: + condition: service_healthy + mobymask: + condition: service_healthy + image: cerc/mobymask-ui:local + command: ["sh", "mobymask-app-start.sh"] + volumes: + - ../config/watcher-mobymask-v2/mobymask-app.env:/app/.env + - ../config/watcher-mobymask-v2/mobymask-app-config.json:/app/src/mobymask-app-config.json + - ../config/watcher-mobymask-v2/mobymask-app-start.sh:/app/mobymask-app-start.sh + - moby_data_server:/server + ports: + - "0.0.0.0:3002:3000" + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "3000"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 10s + shm_size: '1GB' + + peer-test-app: + depends_on: + mobymask-watcher-server: + condition: service_healthy + image: cerc/react-peer:local + working_dir: /app/packages/test-app + command: ["sh", "-c", "yarn build && serve -s build"] + volumes: + - ../config/watcher-mobymask-v2/test-app-config.json:/app/packages/test-app/src/config.json + ports: + - "0.0.0.0:3003:3000" + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "3000"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 10s volumes: mobymask_watcher_db_data: - mobymask_deployment: + moby_data_server: fixturenet_geth_accounts: diff --git a/app/data/config/fixturenet-optimism/generate-l2-config.sh b/app/data/config/fixturenet-optimism/generate-l2-config.sh index 9c439f32..25ed2378 100755 --- a/app/data/config/fixturenet-optimism/generate-l2-config.sh +++ b/app/data/config/fixturenet-optimism/generate-l2-config.sh @@ -1,29 +1,5 @@ #!/bin/sh set -e -if [ -n "$CERC_SCRIPT_DEBUG" ]; then - set -x -fi - -# Check existing config if it exists -if [ -f /app/jwt.txt ] && [ -f /app/rollup.json ]; then - echo "Found existing L2 config, cross-checking with L1 deployment config" - - SOURCE_L1_CONF=$(cat /contracts-bedrock/deploy-config/getting-started.json) - EXP_L1_BLOCKHASH=$(echo "$SOURCE_L1_CONF" | jq -r '.l1StartingBlockTag') - EXP_BATCHER=$(echo "$SOURCE_L1_CONF" | jq -r '.batchSenderAddress') - - GEN_L2_CONF=$(cat /app/rollup.json) - GEN_L1_BLOCKHASH=$(echo "$GEN_L2_CONF" | jq -r '.genesis.l1.hash') - GEN_BATCHER=$(echo "$GEN_L2_CONF" | jq -r '.genesis.system_config.batcherAddr') - - if [ "$EXP_L1_BLOCKHASH" = "$GEN_L1_BLOCKHASH" ] && [ "$EXP_BATCHER" = "$GEN_BATCHER" ]; then - echo "Config cross-checked, exiting" - exit 0 - fi - - echo "Existing L2 config doesn't match the L1 deployment config, please clear L2 config volume before starting" - exit 1 -fi op-node genesis l2 \ --deploy-config /contracts-bedrock/deploy-config/getting-started.json \ diff --git a/app/data/config/fixturenet-optimism/l1-params.env b/app/data/config/fixturenet-optimism/l1-params.env deleted file mode 100644 index 93c58805..00000000 --- a/app/data/config/fixturenet-optimism/l1-params.env +++ /dev/null @@ -1,14 +0,0 @@ -# Change if pointing to an external L1 endpoint - -# 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= -L1_PRIV_KEY_2= diff --git a/app/data/container-build/cerc-optimism-contracts/hardhat-tasks/rekey-json.ts b/app/data/config/fixturenet-optimism/optimism-contracts/rekey-json.ts similarity index 100% rename from app/data/container-build/cerc-optimism-contracts/hardhat-tasks/rekey-json.ts rename to app/data/config/fixturenet-optimism/optimism-contracts/rekey-json.ts diff --git a/app/data/config/fixturenet-optimism/optimism-contracts/run.sh b/app/data/config/fixturenet-optimism/optimism-contracts/run.sh index d4585d4a..473b8743 100755 --- a/app/data/config/fixturenet-optimism/optimism-contracts/run.sh +++ b/app/data/config/fixturenet-optimism/optimism-contracts/run.sh @@ -1,45 +1,19 @@ #!/bin/bash set -e -if [ -n "$CERC_SCRIPT_DEBUG" ]; then - set -x -fi -echo "Using L1 RPC endpoint ${L1_RPC}" +# TODO Support restarts; fixturenet-eth-geth currently starts fresh on a restart +# Exit if a deployment already exists (on restarts) +# if [ -d "deployments/getting-started" ]; then +# echo "Deployment directory deployments/getting-started already exists, exiting" +# exit 0 +# fi -IMPORT_1="import './verify-contract-deployment'" -IMPORT_2="import './rekey-json'" -IMPORT_3="import './send-balance'" - -# Append mounted tasks to tasks/index.ts file if not present -if ! grep -Fxq "$IMPORT_1" tasks/index.ts; then - echo "$IMPORT_1" >> tasks/index.ts - echo "$IMPORT_2" >> tasks/index.ts - echo "$IMPORT_3" >> tasks/index.ts -fi +# Append tasks/index.ts file +echo "import './rekey-json'" >> tasks/index.ts +echo "import './send-balance'" >> tasks/index.ts # Update the chainId in the hardhat config -sed -i "/getting-started/ {n; s/.*chainId.*/ chainId: $L1_CHAIN_ID,/}" hardhat.config.ts - -# Exit if a deployment already exists (on restarts) -# Note: fixturenet-eth-geth currently starts fresh on a restart -if [ -d "deployments/getting-started" ]; then - echo "Deployment directory deployments/getting-started found, checking SystemDictator deployment" - - # Read JSON file into variable - SYSTEM_DICTATOR_DETAILS=$(cat deployments/getting-started/SystemDictator.json) - - # Parse JSON into variables - SYSTEM_DICTATOR_ADDRESS=$(echo "$SYSTEM_DICTATOR_DETAILS" | jq -r '.address') - SYSTEM_DICTATOR_TXHASH=$(echo "$SYSTEM_DICTATOR_DETAILS" | jq -r '.transactionHash') - - if yarn hardhat verify-contract-deployment --contract "${SYSTEM_DICTATOR_ADDRESS}" --transaction-hash "${SYSTEM_DICTATOR_TXHASH}"; then - echo "Deployment verfication successful, exiting" - exit 0 - else - echo "Deployment verfication failed, please clear L1 deployment volume before starting" - exit 1 - fi -fi +sed -i "/getting-started/ {n; s/.*chainId.*/ chainId: $CHAIN_ID,/}" hardhat.config.ts # Generate the L2 account addresses yarn hardhat rekey-json --output /l2-accounts/keys.json @@ -55,27 +29,11 @@ BATCHER_ADDRESS=$(echo "$KEYS_JSON" | jq -r '.Batcher.address') SEQUENCER_ADDRESS=$(echo "$KEYS_JSON" | jq -r '.Sequencer.address') # Read the private key of L1 accounts -if [ -f /geth-accounts/accounts.csv ]; then - echo "Using L1 account credentials from the mounted volume" - L1_ADDRESS=$(head -n 1 /geth-accounts/accounts.csv | cut -d ',' -f 2) - L1_PRIV_KEY=$(head -n 1 /geth-accounts/accounts.csv | cut -d ',' -f 3) - L1_ADDRESS_2=$(awk -F, 'NR==2{print $(NF-1)}' /geth-accounts/accounts.csv) - L1_PRIV_KEY_2=$(awk -F, 'NR==2{print $NF}' /geth-accounts/accounts.csv) -else - echo "Using L1 account credentials from env" -fi - -# Select a finalized L1 block as the starting point for roll ups -until FINALIZED_BLOCK=$(cast block finalized --rpc-url "$L1_RPC"); do - echo "Waiting for a finalized L1 block to exist, retrying after 10s" - sleep 10 -done - -L1_BLOCKNUMBER=$(echo "$FINALIZED_BLOCK" | awk '/number/{print $2}') -L1_BLOCKHASH=$(echo "$FINALIZED_BLOCK" | awk '/hash/{print $2}') -L1_BLOCKTIMESTAMP=$(echo "$FINALIZED_BLOCK" | awk '/timestamp/{print $2}') - -echo "Selected L1 block ${L1_BLOCKNUMBER} as the starting block for roll ups" +# TODO: Take from env if /geth-accounts volume doesn't exist to allow using separately running L1 +L1_ADDRESS=$(head -n 1 /geth-accounts/accounts.csv | cut -d ',' -f 2) +L1_PRIV_KEY=$(head -n 1 /geth-accounts/accounts.csv | cut -d ',' -f 3) +L1_ADDRESS_2=$(awk -F, 'NR==2{print $(NF-1)}' /geth-accounts/accounts.csv) +L1_PRIV_KEY_2=$(awk -F, 'NR==2{print $NF}' /geth-accounts/accounts.csv) # Send balances to the above L2 addresses yarn hardhat send-balance --to "${ADMIN_ADDRESS}" --amount 2 --private-key "${L1_PRIV_KEY}" --network getting-started @@ -84,9 +42,19 @@ yarn hardhat send-balance --to "${BATCHER_ADDRESS}" --amount 1000 --private-key echo "Balances sent to L2 accounts" +# Select a finalized L1 block as the starting point for roll ups +# TODO Use web3.js to get the latest finalized block +until CAST_OUTPUT=$(cast block finalized --rpc-url "$L1_RPC"); do + echo "Waiting for a finalized L1 block to exist, retrying after 10s" + sleep 10 +done + +L1_BLOCKHASH=$(echo "$CAST_OUTPUT" | awk '/hash/{print $2}') +L1_BLOCKTIMESTAMP=$(echo "$CAST_OUTPUT" | awk '/timestamp/{print $2}') + # Update the deployment config sed -i 's/"l2OutputOracleStartingTimestamp": TIMESTAMP/"l2OutputOracleStartingTimestamp": '"$L1_BLOCKTIMESTAMP"'/g' deploy-config/getting-started.json -jq --arg chainid "$L1_CHAIN_ID" '.l1ChainID = ($chainid | tonumber)' deploy-config/getting-started.json > tmp.json && mv tmp.json deploy-config/getting-started.json +jq --arg chainid "$CHAIN_ID" '.l1ChainID = ($chainid | tonumber)' deploy-config/getting-started.json > tmp.json && mv tmp.json deploy-config/getting-started.json node update-config.js deploy-config/getting-started.json "$ADMIN_ADDRESS" "$PROPOSER_ADDRESS" "$BATCHER_ADDRESS" "$SEQUENCER_ADDRESS" "$L1_BLOCKHASH" diff --git a/app/data/container-build/cerc-optimism-contracts/hardhat-tasks/send-balance.ts b/app/data/config/fixturenet-optimism/optimism-contracts/send-balance.ts similarity index 100% rename from app/data/container-build/cerc-optimism-contracts/hardhat-tasks/send-balance.ts rename to app/data/config/fixturenet-optimism/optimism-contracts/send-balance.ts diff --git a/app/data/config/fixturenet-optimism/run-op-batcher.sh b/app/data/config/fixturenet-optimism/run-op-batcher.sh index 3cab3e94..38ac3ab9 100755 --- a/app/data/config/fixturenet-optimism/run-op-batcher.sh +++ b/app/data/config/fixturenet-optimism/run-op-batcher.sh @@ -1,8 +1,5 @@ #!/bin/sh set -e -if [ -n "$CERC_SCRIPT_DEBUG" ]; then - set -x -fi # Get BACTHER_KEY from keys.json BATCHER_KEY=$(jq -r '.Batcher.privateKey' /l2-accounts/keys.json | tr -d '"') diff --git a/app/data/config/fixturenet-optimism/run-op-geth.sh b/app/data/config/fixturenet-optimism/run-op-geth.sh index 68f6c5c5..1b4e2b0f 100755 --- a/app/data/config/fixturenet-optimism/run-op-geth.sh +++ b/app/data/config/fixturenet-optimism/run-op-geth.sh @@ -1,53 +1,34 @@ #!/bin/sh set -e -if [ -n "$CERC_SCRIPT_DEBUG" ]; then - set -x -fi + +mkdir datadir + +echo "pwd" > datadir/password # TODO: Add in container build or use other tool -echo "Installing jq" +echo "installing jq" apk update && apk add jq -# Get SEQUENCER key from keys.json +# Get SEQUENCER KEY from keys.json SEQUENCER_KEY=$(jq -r '.Sequencer.privateKey' /l2-accounts/keys.json | tr -d '"') +echo $SEQUENCER_KEY > datadir/block-signer-key -# Initialize op-geth if datadir/geth not found -if [ -f /op-node/jwt.txt ] && [ -d datadir/geth ]; then - echo "Found existing datadir, checking block signer key" +geth account import --datadir=datadir --password=datadir/password datadir/block-signer-key - BLOCK_SIGNER_KEY=$(cat datadir/block-signer-key) +while [ ! -f "/op-node/jwt.txt" ] +do + echo "Config files not created. Checking after 5 seconds." + sleep 5 +done - if [ "$SEQUENCER_KEY" = "$BLOCK_SIGNER_KEY" ]; then - echo "Sequencer and block signer keys match, skipping initialization" - else - echo "Sequencer and block signer keys don't match, please clear L2 geth data volume before starting" - exit 1 - fi -else - echo "Initializing op-geth" +echo "Config files created by op-node, proceeding with script..." - mkdir -p datadir - echo "pwd" > datadir/password - echo $SEQUENCER_KEY > datadir/block-signer-key - - geth account import --datadir=datadir --password=datadir/password datadir/block-signer-key - - while [ ! -f "/op-node/jwt.txt" ] - do - echo "Config files not created. Checking after 5 seconds." - sleep 5 - done - - echo "Config files created by op-node, proceeding with the initialization..." - - geth init --datadir=datadir /op-node/genesis.json - echo "Node Initialized" -fi +cp /op-node/genesis.json ./ +geth init --datadir=datadir genesis.json SEQUENCER_ADDRESS=$(jq -r '.Sequencer.address' /l2-accounts/keys.json | tr -d '"') echo "SEQUENCER_ADDRESS: ${SEQUENCER_ADDRESS}" - -# Run op-geth +cp /op-node/jwt.txt ./ geth \ --datadir ./datadir \ --http \ @@ -68,7 +49,7 @@ geth \ --authrpc.vhosts="*" \ --authrpc.addr=0.0.0.0 \ --authrpc.port=8551 \ - --authrpc.jwtsecret=/op-node/jwt.txt \ + --authrpc.jwtsecret=./jwt.txt \ --rollup.disabletxpoolgossip=true \ --password=./datadir/password \ --allow-insecure-unlock \ diff --git a/app/data/config/fixturenet-optimism/run-op-node.sh b/app/data/config/fixturenet-optimism/run-op-node.sh index f495aeef..3be417d0 100755 --- a/app/data/config/fixturenet-optimism/run-op-node.sh +++ b/app/data/config/fixturenet-optimism/run-op-node.sh @@ -1,8 +1,5 @@ #!/bin/sh set -e -if [ -n "$CERC_SCRIPT_DEBUG" ]; then - set -x -fi # Get SEQUENCER KEY from keys.json SEQUENCER_KEY=$(jq -r '.Sequencer.privateKey' /l2-accounts/keys.json | tr -d '"') diff --git a/app/data/config/wait-for-it.sh b/app/data/config/wait-for-it.sh deleted file mode 100755 index d990e0d3..00000000 --- a/app/data/config/wait-for-it.sh +++ /dev/null @@ -1,182 +0,0 @@ -#!/usr/bin/env bash -# Use this script to test if a given TCP host/port are available - -WAITFORIT_cmdname=${0##*/} - -echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi } - -usage() -{ - cat << USAGE >&2 -Usage: - $WAITFORIT_cmdname host:port [-s] [-t timeout] [-- command args] - -h HOST | --host=HOST Host or IP under test - -p PORT | --port=PORT TCP port under test - Alternatively, you specify the host and port as host:port - -s | --strict Only execute subcommand if the test succeeds - -q | --quiet Don't output any status messages - -t TIMEOUT | --timeout=TIMEOUT - Timeout in seconds, zero for no timeout - -- COMMAND ARGS Execute command with args after the test finishes -USAGE - exit 1 -} - -wait_for() -{ - if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then - echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT" - else - echoerr "$WAITFORIT_cmdname: waiting for $WAITFORIT_HOST:$WAITFORIT_PORT without a timeout" - fi - WAITFORIT_start_ts=$(date +%s) - while : - do - if [[ $WAITFORIT_ISBUSY -eq 1 ]]; then - nc -z $WAITFORIT_HOST $WAITFORIT_PORT - WAITFORIT_result=$? - else - (echo -n > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1 - WAITFORIT_result=$? - fi - if [[ $WAITFORIT_result -eq 0 ]]; then - WAITFORIT_end_ts=$(date +%s) - echoerr "$WAITFORIT_cmdname: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds" - break - fi - sleep 1 - done - return $WAITFORIT_result -} - -wait_for_wrapper() -{ - # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692 - if [[ $WAITFORIT_QUIET -eq 1 ]]; then - timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --quiet --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT & - else - timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT & - fi - WAITFORIT_PID=$! - trap "kill -INT -$WAITFORIT_PID" INT - wait $WAITFORIT_PID - WAITFORIT_RESULT=$? - if [[ $WAITFORIT_RESULT -ne 0 ]]; then - echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT" - fi - return $WAITFORIT_RESULT -} - -# process arguments -while [[ $# -gt 0 ]] -do - case "$1" in - *:* ) - WAITFORIT_hostport=(${1//:/ }) - WAITFORIT_HOST=${WAITFORIT_hostport[0]} - WAITFORIT_PORT=${WAITFORIT_hostport[1]} - shift 1 - ;; - --child) - WAITFORIT_CHILD=1 - shift 1 - ;; - -q | --quiet) - WAITFORIT_QUIET=1 - shift 1 - ;; - -s | --strict) - WAITFORIT_STRICT=1 - shift 1 - ;; - -h) - WAITFORIT_HOST="$2" - if [[ $WAITFORIT_HOST == "" ]]; then break; fi - shift 2 - ;; - --host=*) - WAITFORIT_HOST="${1#*=}" - shift 1 - ;; - -p) - WAITFORIT_PORT="$2" - if [[ $WAITFORIT_PORT == "" ]]; then break; fi - shift 2 - ;; - --port=*) - WAITFORIT_PORT="${1#*=}" - shift 1 - ;; - -t) - WAITFORIT_TIMEOUT="$2" - if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi - shift 2 - ;; - --timeout=*) - WAITFORIT_TIMEOUT="${1#*=}" - shift 1 - ;; - --) - shift - WAITFORIT_CLI=("$@") - break - ;; - --help) - usage - ;; - *) - echoerr "Unknown argument: $1" - usage - ;; - esac -done - -if [[ "$WAITFORIT_HOST" == "" || "$WAITFORIT_PORT" == "" ]]; then - echoerr "Error: you need to provide a host and port to test." - usage -fi - -WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-15} -WAITFORIT_STRICT=${WAITFORIT_STRICT:-0} -WAITFORIT_CHILD=${WAITFORIT_CHILD:-0} -WAITFORIT_QUIET=${WAITFORIT_QUIET:-0} - -# Check to see if timeout is from busybox? -WAITFORIT_TIMEOUT_PATH=$(type -p timeout) -WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH) - -WAITFORIT_BUSYTIMEFLAG="" -if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then - WAITFORIT_ISBUSY=1 - # Check if busybox timeout uses -t flag - # (recent Alpine versions don't support -t anymore) - if timeout &>/dev/stdout | grep -q -e '-t '; then - WAITFORIT_BUSYTIMEFLAG="-t" - fi -else - WAITFORIT_ISBUSY=0 -fi - -if [[ $WAITFORIT_CHILD -gt 0 ]]; then - wait_for - WAITFORIT_RESULT=$? - exit $WAITFORIT_RESULT -else - if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then - wait_for_wrapper - WAITFORIT_RESULT=$? - else - wait_for - WAITFORIT_RESULT=$? - fi -fi - -if [[ $WAITFORIT_CLI != "" ]]; then - if [[ $WAITFORIT_RESULT -ne 0 && $WAITFORIT_STRICT -eq 1 ]]; then - echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess" - exit $WAITFORIT_RESULT - fi - exec "${WAITFORIT_CLI[@]}" -else - exit $WAITFORIT_RESULT -fi 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 deleted file mode 100755 index 743b1525..00000000 --- a/app/data/config/watcher-mobymask-v2/deploy-and-generate-invite.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/sh -set -e -if [ -n "$CERC_SCRIPT_DEBUG" ]; then - set -x -fi - -echo "Using L2 RPC endpoint ${L2_GETH_RPC}" - -if [ -f /geth-accounts/accounts.csv ]; then - echo "Using L1 private key from the mounted volume" - # Read the private key of L1 account to deploy contract - PRIVATE_KEY_DEPLOYER=$(head -n 1 /geth-accounts/accounts.csv | cut -d ',' -f 3) -else - echo "Using PRIVATE_KEY_DEPLOYER from env" -fi - -# Set the private key -jq --arg privateKey "$PRIVATE_KEY_DEPLOYER" '.privateKey = $privateKey' secrets-template.json > secrets.json - -# Set the RPC URL -jq --arg rpcUrl "$L2_GETH_RPC" '.rpcUrl = $rpcUrl' secrets.json > secrets_updated.json && mv secrets_updated.json secrets.json - -export RPC_URL="${L2_GETH_RPC}" - -# Check if DEPLOYED_CONTRACT environment variable set to skip contract deployment -if [[ -n "$DEPLOYED_CONTRACT" ]]; then - echo "DEPLOYED_CONTRACT is set to '$DEPLOYED_CONTRACT'" - echo "Exiting without deploying contract" - exit 0 -fi - -# Check and exit if a deployment already exists (on restarts) -if [ -f ./config.json ]; then - echo "config.json already exists, checking the contract deployment" - - # Read JSON file - DEPLOYMENT_DETAILS=$(cat config.json) - CONTRACT_ADDRESS=$(echo "$DEPLOYMENT_DETAILS" | jq -r '.address') - - cd ../hardhat - if yarn verifyDeployment --network optimism --contract "${CONTRACT_ADDRESS}"; then - echo "Deployment verfication successful" - cd ../server - else - echo "Deployment verfication failed, please clear MobyMask deployment volume before starting" - exit 1 - fi -fi - -# Wait until balance for deployer account is updated -cd ../hardhat -while true; do - ACCOUNT_BALANCE=$(yarn balance --network optimism "$PRIVATE_KEY_DEPLOYER" | grep ETH) - - if [ "$ACCOUNT_BALANCE" != "0.0 ETH" ]; then - echo "Account balance updated: $ACCOUNT_BALANCE" - break # exit the loop - fi - - echo "Account balance not updated: $ACCOUNT_BALANCE" - echo "Checking after 2 seconds" - sleep 2 -done - -cd ../server -npm run deployAndGenerateInvite diff --git a/app/data/config/watcher-mobymask-v2/deploy-invite.sh b/app/data/config/watcher-mobymask-v2/deploy-invite.sh new file mode 100644 index 00000000..2a8e0eb5 --- /dev/null +++ b/app/data/config/watcher-mobymask-v2/deploy-invite.sh @@ -0,0 +1,11 @@ +#!/bin/sh +set -e + +# Read the private key of L1 account to deploy contract +# TODO: Take from env if /geth-accounts volume doesn't exist to allow using separately running L1 +L1_PRIV_KEY=$(head -n 1 /geth-accounts/accounts.csv | cut -d ',' -f 3) + +# Set the private key +jq --arg privateKey "$L1_PRIV_KEY" '.privateKey = ($privateKey)' secrets-template.json > secrets.json + +npm start diff --git a/app/data/config/watcher-mobymask-v2/mobymask-app-config.json b/app/data/config/watcher-mobymask-v2/mobymask-app-config.json index 2ccb816d..3b00674f 100644 --- a/app/data/config/watcher-mobymask-v2/mobymask-app-config.json +++ b/app/data/config/watcher-mobymask-v2/mobymask-app-config.json @@ -1,5 +1,4 @@ { - "name": "MobyMask", "relayNodes": [ "/ip4/127.0.0.1/tcp/9090/ws/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t" ], diff --git a/app/data/config/watcher-mobymask-v2/mobymask-app-start.sh b/app/data/config/watcher-mobymask-v2/mobymask-app-start.sh index 680e2e8a..fa3870cf 100755 --- a/app/data/config/watcher-mobymask-v2/mobymask-app-start.sh +++ b/app/data/config/watcher-mobymask-v2/mobymask-app-start.sh @@ -1,25 +1,9 @@ #!/bin/sh set -e -if [ -n "$CERC_SCRIPT_DEBUG" ]; then - set -x -fi -# Use config from mounted volume if available (when running web-app along with watcher stack) -if [ -f /server/config.json ]; then - echo "Merging config for deployed contract from mounted volume" - # Merging config files to get deployed contract address - jq -s '.[0] * .[1]' /app/src/mobymask-app-config.json /server/config.json > /app/src/config.json -else - echo "Setting deployed contract details from env" +# Merging config files to get deployed contract address +jq -s '.[0] * .[1]' /app/src/mobymask-app-config.json /server/config.json > /app/src/config.json - # Set config values from environment variables - jq --arg address "$DEPLOYED_CONTRACT" \ - --argjson chainId $CHAIN_ID \ - --argjson relayNodes "$RELAY_NODES" \ - '.address = $address | .chainId = $chainId | .relayNodes = $relayNodes' \ - /app/src/mobymask-app-config.json > /app/src/config.json -fi - -REACT_APP_WATCHER_URI="$APP_WATCHER_URL/graphql" npm run build +npm run build serve -s build diff --git a/app/data/config/watcher-mobymask-v2/mobymask-app.env b/app/data/config/watcher-mobymask-v2/mobymask-app.env new file mode 100644 index 00000000..698d3502 --- /dev/null +++ b/app/data/config/watcher-mobymask-v2/mobymask-app.env @@ -0,0 +1 @@ +REACT_APP_WATCHER_URI=http://localhost:3001/graphql diff --git a/app/data/config/watcher-mobymask-v2/mobymask-params.env b/app/data/config/watcher-mobymask-v2/mobymask-params.env deleted file mode 100644 index 890c183b..00000000 --- a/app/data/config/watcher-mobymask-v2/mobymask-params.env +++ /dev/null @@ -1,14 +0,0 @@ -# Change if pointing web app to external watcher endpoint -WATCHER_HOST="mobymask-watcher-server" -WATCHER_PORT=3001 -APP_WATCHER_URL="http://localhost:3001" - -# Set deployed MobyMask contract address to avoid deploying contract in stack -# mobymask-app will use this contract address in config if run separately -DEPLOYED_CONTRACT= - -# Chain ID is used by mobymask web-app for txs -CHAIN_ID=42069 - -# Set relay nodes to be used by web-apps -RELAY_NODES=["/ip4/127.0.0.1/tcp/9090/ws/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t"] diff --git a/app/data/config/watcher-mobymask-v2/optimism-params.env b/app/data/config/watcher-mobymask-v2/optimism-params.env deleted file mode 100644 index 489dd879..00000000 --- a/app/data/config/watcher-mobymask-v2/optimism-params.env +++ /dev/null @@ -1,13 +0,0 @@ -# Change if pointing to an external optimism geth endpoint - -# L2 endpoints -L2_GETH_RPC="http://op-geth:8545" -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/config/watcher-mobymask-v2/secrets-template.json b/app/data/config/watcher-mobymask-v2/secrets-template.json index 1397bbf1..220efc8e 100644 --- a/app/data/config/watcher-mobymask-v2/secrets-template.json +++ b/app/data/config/watcher-mobymask-v2/secrets-template.json @@ -1,5 +1,5 @@ { - "rpcUrl": "", + "rpcUrl": "http://op-geth:8545", "privateKey": "", "baseURI": "http://127.0.0.1:3002/#" } diff --git a/app/data/config/watcher-mobymask-v2/server-start.sh b/app/data/config/watcher-mobymask-v2/server-start.sh new file mode 100755 index 00000000..6b4cd345 --- /dev/null +++ b/app/data/config/watcher-mobymask-v2/server-start.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# Assign deployed contract address from server config +CONTRACT_ADDRESS=$(jq -r '.address' /server/config.json | tr -d '"') +L1_PRIV_KEY_2=$(awk -F, 'NR==2{print $NF}' /geth-accounts/accounts.csv) + +sed "s/REPLACE_WITH_PRIVATE_KEY/${L1_PRIV_KEY_2}/" environments/watcher-config-template.toml > environments/local.toml +sed -i "s/REPLACE_WITH_CONTRACT_ADDRESS/${CONTRACT_ADDRESS}/" environments/local.toml + +echo 'yarn server' +yarn server diff --git a/app/data/config/watcher-mobymask-v2/start-server.sh b/app/data/config/watcher-mobymask-v2/start-server.sh deleted file mode 100755 index 4030e522..00000000 --- a/app/data/config/watcher-mobymask-v2/start-server.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -set -e -if [ -n "$CERC_SCRIPT_DEBUG" ]; then - set -x -fi - -echo "Using L2 RPC endpoint ${L2_GETH_RPC}" - -# Use contract address from environment variable or set from config.json in mounted volume -if [ -n "$DEPLOYED_CONTRACT" ]; then - CONTRACT_ADDRESS="${DEPLOYED_CONTRACT}" -else - # Assign deployed contract address from server config (created by mobymask container after deploying contract) - CONTRACT_ADDRESS=$(jq -r '.address' /server/config.json | tr -d '"') -fi - -if [ -f /geth-accounts/accounts.csv ]; then - echo "Using L1 private key from the mounted volume" - # Read the private key of L1 account for sending txs from peer - PRIVATE_KEY_PEER=$(awk -F, 'NR==2{print $NF}' /geth-accounts/accounts.csv) -else - echo "Using PRIVATE_KEY_PEER from env" -fi - -# Set private key and contract address for watcher peer txs to L2 only if PRIVATE_KEY_PEER variable is set -if [ -n "$PRIVATE_KEY_PEER" ]; then - # Read in config template TOML file and modify it - CONTENT=$(cat environments/watcher-config-template.toml) - NEW_CONTENT=$(echo "$CONTENT" | sed -E "/\[metrics\]/i \\\n\n [server.p2p.peer.l2TxConfig]\n privateKey = \"${PRIVATE_KEY_PEER}\"\n contractAddress = \"${CONTRACT_ADDRESS}\"\n") - - # Write the modified content to a watcher config file - echo "$NEW_CONTENT" > environments/local.toml - - sed -i 's|REPLACE_WITH_L2_GETH_RPC_ENDPOINT|'"${L2_GETH_RPC}"'|' environments/local.toml -else - # Copy template config to watcher config without setting params for peer L2 txs - cp environments/watcher-config-template.toml environments/local.toml -fi - -echo 'yarn server' -yarn server diff --git a/app/data/config/watcher-mobymask-v2/test-app-start.sh b/app/data/config/watcher-mobymask-v2/test-app-start.sh deleted file mode 100755 index de6ccc7c..00000000 --- a/app/data/config/watcher-mobymask-v2/test-app-start.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -set -e -if [ -n "$CERC_SCRIPT_DEBUG" ]; then - set -x -fi - -# Set relay nodes in config from RELAY_NODES environment variable -jq --argjson relayNodes "$RELAY_NODES" \ - '.relayNodes = $relayNodes' \ - ./src/test-app-config.json > ./src/config.json - -yarn build - -serve -s build diff --git a/app/data/config/watcher-mobymask-v2/watcher-config-template.toml b/app/data/config/watcher-mobymask-v2/watcher-config-template.toml index 6b0223c7..ff937678 100644 --- a/app/data/config/watcher-mobymask-v2/watcher-config-template.toml +++ b/app/data/config/watcher-mobymask-v2/watcher-config-template.toml @@ -36,6 +36,10 @@ peerIdFile = './peer-id.json' enableDebugInfo = true + [server.p2p.peer.l2TxConfig] + privateKey = 'REPLACE_WITH_PRIVATE_KEY' + contractAddress = 'REPLACE_WITH_CONTRACT_ADDRESS' + [metrics] host = "0.0.0.0" port = 9000 @@ -55,7 +59,7 @@ [upstream] [upstream.ethServer] gqlApiEndpoint = "http://ipld-eth-server:8083/graphql" - rpcProviderEndpoint = "REPLACE_WITH_L2_GETH_RPC_ENDPOINT" + rpcProviderEndpoint = "http://op-geth:8545" blockDelayInMilliSecs = 60000 [upstream.cache] diff --git a/app/data/container-build/cerc-builder-gerbil/install-dependencies.sh b/app/data/container-build/cerc-builder-gerbil/install-dependencies.sh index 36855a9b..dbbbfe84 100755 --- a/app/data/container-build/cerc-builder-gerbil/install-dependencies.sh +++ b/app/data/container-build/cerc-builder-gerbil/install-dependencies.sh @@ -11,6 +11,6 @@ DEPS=(github.com/fare/gerbil-utils ) ; for i in ${DEPS[@]} ; do echo "Installing gerbil package: $i" - gxpkg install $i + gxpkg install $i && gxpkg build $i done diff --git a/app/data/container-build/cerc-mobymask-ui/Dockerfile b/app/data/container-build/cerc-mobymask-ui/Dockerfile index c04b001d..68e3c77c 100644 --- a/app/data/container-build/cerc-mobymask-ui/Dockerfile +++ b/app/data/container-build/cerc-mobymask-ui/Dockerfile @@ -1,6 +1,6 @@ FROM node:18.15.0-alpine3.16 -RUN apk --update --no-cache add make git jq bash +RUN apk --update --no-cache add make git jq WORKDIR /app diff --git a/app/data/container-build/cerc-mobymask/Dockerfile b/app/data/container-build/cerc-mobymask/Dockerfile index caa3e6b5..c94a1cea 100644 --- a/app/data/container-build/cerc-mobymask/Dockerfile +++ b/app/data/container-build/cerc-mobymask/Dockerfile @@ -1,6 +1,6 @@ FROM node:16.17.1-alpine3.16 -RUN apk --update --no-cache add python3 alpine-sdk jq bash +RUN apk --update --no-cache add python3 alpine-sdk jq WORKDIR /app diff --git a/app/data/container-build/cerc-optimism-contracts/Dockerfile b/app/data/container-build/cerc-optimism-contracts/Dockerfile index cdc98b08..4f244bab 100644 --- a/app/data/container-build/cerc-optimism-contracts/Dockerfile +++ b/app/data/container-build/cerc-optimism-contracts/Dockerfile @@ -1,3 +1,4 @@ +# TODO: Use a node alpine image FROM cerc/foundry:local # Install node (local foundry is a debian based image) diff --git a/app/data/container-build/cerc-optimism-contracts/hardhat-tasks/verify-contract-deployment.ts b/app/data/container-build/cerc-optimism-contracts/hardhat-tasks/verify-contract-deployment.ts deleted file mode 100644 index 5b673ca1..00000000 --- a/app/data/container-build/cerc-optimism-contracts/hardhat-tasks/verify-contract-deployment.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { task } from 'hardhat/config' -import '@nomiclabs/hardhat-ethers' - -task( - 'verify-contract-deployment', - 'Verifies the given contract deployment transaction' -) - .addParam('contract', 'Address of the contract deployed') - .addParam('transactionHash', 'Hash of the deployment transaction') - .setAction(async ({ contract, transactionHash }, { ethers }) => { - const provider = new ethers.providers.JsonRpcProvider( - `${process.env.L1_RPC}` - ) - - // Get the deployment tx receipt - const receipt = await provider.getTransactionReceipt(transactionHash) - if ( - receipt && - receipt.contractAddress && - receipt.contractAddress === contract - ) { - console.log( - `Deployment for contract ${contract} in transaction ${transactionHash} verified` - ) - process.exit(0) - } else { - console.log(`Contract ${contract} deployment verification failed`) - process.exit(1) - } - }) diff --git a/app/data/container-build/cerc-optimism-op-batcher/Dockerfile b/app/data/container-build/cerc-optimism-op-batcher/Dockerfile index 23d6b629..542a075f 100644 --- a/app/data/container-build/cerc-optimism-op-batcher/Dockerfile +++ b/app/data/container-build/cerc-optimism-op-batcher/Dockerfile @@ -25,7 +25,7 @@ RUN make op-batcher VERSION="$VERSION" GOOS=$TARGETOS GOARCH=$TARGETARCH FROM alpine:3.15 -RUN apk add --no-cache jq bash +RUN apk add --no-cache jq COPY --from=builder /app/op-batcher/bin/op-batcher /usr/local/bin diff --git a/app/data/container-build/cerc-react-peer/Dockerfile b/app/data/container-build/cerc-react-peer/Dockerfile index fcc198f3..cc852441 100644 --- a/app/data/container-build/cerc-react-peer/Dockerfile +++ b/app/data/container-build/cerc-react-peer/Dockerfile @@ -1,6 +1,6 @@ FROM node:18.15.0-alpine3.16 -RUN apk --update --no-cache add make git python3 jq +RUN apk --update --no-cache add make git python3 WORKDIR /app diff --git a/app/data/pod-list.txt b/app/data/pod-list.txt index f24c9ed0..79c4171a 100644 --- a/app/data/pod-list.txt +++ b/app/data/pod-list.txt @@ -15,8 +15,7 @@ watcher-erc20 watcher-erc721 watcher-uniswap-v3 watcher-mobymask-v2 -mobymask-app -peer-test-app +mobymask-laconicd test eth-probe keycloak diff --git a/app/data/stacks/build-support/README.md b/app/data/stacks/build-support/README.md index 72001518..b4090d76 100644 --- a/app/data/stacks/build-support/README.md +++ b/app/data/stacks/build-support/README.md @@ -12,10 +12,9 @@ To use a user-supplied registry set these environment variables: Leave `CERC_NPM_REGISTRY_URL` un-set to use the local gitea registry. ### 1. Build support containers -``` -$ laconic-so --stack build-support build-containers -``` -Note that the scheme/gerbil builder container can take a while to build so if you aren't going to build scheme projects it can be skipped with: + +Note: the scheme/gerbil container is excluded as it isn't currently required for the package registry. + ``` $ laconic-so --stack build-support build-containers --exclude cerc/builder-gerbil ``` @@ -23,6 +22,7 @@ $ laconic-so --stack build-support build-containers --exclude cerc/builder-gerbi ``` $ laconic-so --stack package-registry setup-repositories +$ laconic-so --stack package-registry build-containers $ laconic-so --stack package-registry deploy up [+] Running 3/3 ⠿ Network laconic-aecc4a21d3a502b14522db97d427e850_gitea Created 0.0s @@ -36,6 +36,9 @@ Gitea was configured to use host name: gitea.local, ensure that this resolves to Success, gitea is properly initialized $ ``` + +Note: the above commands can take several minutes depending on the specs of your machine. + ### 3. Configure the hostname gitea.local How to do this is OS-dependent but usually involves editing a `hosts` file. For example on Linux add this line to the file `/etc/hosts` (needs sudo): ``` @@ -55,5 +58,5 @@ Now npm packages can be built: Ensure that `CERC_NPM_AUTH_TOKEN` is set with the token printed above when the package-registry stack was deployed (the actual token value will be different than shown in this example): ``` $ export CERC_NPM_AUTH_TOKEN=84fe66a73698bf11edbdccd0a338236b7d1d5c45 -$ laconic-so build-npms --include laconic-sdk +$ laconic-so build-npms --include laconic-sdk,laconic-registry-cli ``` diff --git a/app/data/stacks/fixturenet-optimism/README.md b/app/data/stacks/fixturenet-optimism/README.md index 61ca97b3..5b9dd51b 100644 --- a/app/data/stacks/fixturenet-optimism/README.md +++ b/app/data/stacks/fixturenet-optimism/README.md @@ -2,8 +2,6 @@ Instructions to setup and deploy an end-to-end L1+L2 stack with [fixturenet-eth](../fixturenet-eth/) (L1) and [Optimism](https://stack.optimism.io) (L2) -We support running just the L2 part of stack, given an external L1 endpoint. Follow [l2-only](./l2-only.md) for the same. - ## Setup Clone required repositories: @@ -15,7 +13,7 @@ laconic-so --stack fixturenet-optimism setup-repositories Checkout to the required versions and branches in repos: ```bash -# Optimism +# optimism cd ~/cerc/optimism git checkout @eth-optimism/sdk@0.0.0-20230329025055 ``` @@ -45,21 +43,13 @@ Deploy the stack: laconic-so --stack fixturenet-optimism deploy up ``` -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: +To list down the running containers: ```bash laconic-so --stack fixturenet-optimism deploy ps # With status docker ps - -# Check logs for a container -docker logs -f ``` ## Clean up @@ -70,49 +60,21 @@ Stop all services running in the background: laconic-so --stack fixturenet-optimism deploy down ``` -Clear volumes created by this stack: +Remove volumes created by this stack: ```bash -# List all relevant volumes -docker volume ls -q --filter "name=.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data" +docker volume ls -# Remove all the listed volumes -docker volume rm $(docker volume ls -q --filter "name=.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data") +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 ``` -## Troubleshooting - -* If `op-geth` service aborts or is restarted, the following error might occur in the `op-node` service: - - ```bash - WARN [02-16|21:22:02.868] Derivation process temporary error attempts=14 err="stage 0 failed resetting: temp: failed to find the L2 Heads to start from: failed to fetch L2 block by hash 0x0000000000000000000000000000000000000000000000000000000000000000: failed to determine block-hash of hash 0x0000000000000000000000000000000000000000000000000000000000000000, could not get payload: not found" - ``` - -* This means that the data directory that `op-geth` is using is corrupted and needs to be reinitialized; the containers `op-geth`, `op-node` and `op-batcher` need to be started afresh: - * Stop and remove the concerned containers: - - ```bash - # List the containers - docker ps -f "name=op-geth|op-node|op-batcher" - - # Force stop and remove the listed containers - docker rm -f $(docker ps -qf "name=op-geth|op-node|op-batcher") - ``` - - * Remove the concerned volume: - - ```bash - # List the volume - docker volume ls -q --filter name=l2_geth_data - - # Remove the listed volume - 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 - ## Known Issues -* `fixturenet-eth` currently starts fresh on a restart -* Resource requirements (memory + time) for building the `cerc/foundry` image are on the higher side +* 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) diff --git a/app/data/stacks/fixturenet-optimism/l2-only.md b/app/data/stacks/fixturenet-optimism/l2-only.md deleted file mode 100644 index a1c33717..00000000 --- a/app/data/stacks/fixturenet-optimism/l2-only.md +++ /dev/null @@ -1,87 +0,0 @@ -# fixturenet-optimism - -Instructions to setup and deploy L2 fixturenet using [Optimism](https://stack.optimism.io) - -## Setup - -Prerequisite: An L1 Ethereum RPC endpoint - -Clone required repositories: - -```bash -laconic-so --stack fixturenet-optimism setup-repositories --exclude cerc-io/go-ethereum -``` - -Checkout to the required versions and branches in repos: - -```bash -# Optimism -cd ~/cerc/optimism -git checkout @eth-optimism/sdk@0.0.0-20230329025055 -``` - -Build the container images: - -```bash -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: -* `cerc/foundry` -* `cerc/optimism-contracts` -* `cerc/optimism-l2geth` -* `cerc/optimism-op-batcher` -* `cerc/optimism-op-node` - -## 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 - -* 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 --include fixturenet-optimism -``` - -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 --include fixturenet-optimism ps - -# With status -docker ps - -# Check logs for a container -docker logs -f -``` - -## Clean up - -Stop all services running in the background: - -```bash -laconic-so --stack fixturenet-optimism deploy down --include fixturenet-optimism -``` - -Clear volumes created by this stack: - -```bash -# List all relevant volumes -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=.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data") -``` - -## Troubleshooting - -See [Troubleshooting](./README.md#troubleshooting) \ No newline at end of file diff --git a/app/data/stacks/fixturenet-optimism/stack.yml b/app/data/stacks/fixturenet-optimism/stack.yml index e53623ca..299b1367 100644 --- a/app/data/stacks/fixturenet-optimism/stack.yml +++ b/app/data/stacks/fixturenet-optimism/stack.yml @@ -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 diff --git a/app/data/stacks/mobymask-v2/README.md b/app/data/stacks/mobymask-v2/README.md index 15652efe..18af5b2b 100644 --- a/app/data/stacks/mobymask-v2/README.md +++ b/app/data/stacks/mobymask-v2/README.md @@ -1,9 +1,6 @@ # 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) - -We support running just the watcher part of stack, given an external L2 Optimism endpoint. -Follow [mobymask-only](./mobymask-only.md) for the same. +Instructions to deploy MobyMask v2 watcher stack using [laconic-stack-orchestrator](/README.md#install) ## Setup @@ -33,11 +30,7 @@ git checkout laconic # MobyMask cd ~/cerc/MobyMask -git checkout v0.1.2 - -# Optimism -cd ~/cerc/optimism -git checkout @eth-optimism/sdk@0.0.0-20230329025055 +git checkout v0.1.1 ``` Build the container images: @@ -50,28 +43,40 @@ 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 ``` -* List and check the health status of all the containers using `docker ps` and wait for them to be `healthy` +* Check that all containers are healthy using `docker ps` - 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: + 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 ```bash - docker ps -a | grep "mobymask-app" - - docker restart + laconic-so --stack mobymask-v2 deploy-system up ``` ## Tests -Find the watcher container's id and export it for later use: +Find the watcher container's id: ```bash -export CONTAINER_ID=$(docker ps -q --filter "name=mobymask-watcher-server") +laconic-so --stack mobymask-v2 deploy-system ps | grep "mobymask-watcher-server" +``` + +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 +``` + +In above output the container ID is `5d3aae4b22039fcd1c9b18feeb91318ede1100581e75bb5ac54f9e436066b02c` + +Export it for later use: + +```bash +export CONTAINER_ID= ``` Run the peer tests: @@ -82,11 +87,7 @@ docker exec -w /app/packages/peer $CONTAINER_ID yarn test ## Web Apps -Check that the web-app containers are healthy: - -```bash -docker ps | grep -E 'mobymask-app|peer-test-app' -``` +Check that the status for web-app containers are healthy by using `docker ps` ### mobymask-app @@ -116,12 +117,17 @@ Stop all the services running in background run: laconic-so --stack mobymask-v2 deploy-system down ``` -Clear volumes created by this stack: +Clear volumes: -```bash -# List all relevant volumes -docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*mobymask_deployment|.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data" +* List all volumes -# Remove all the listed volumes -docker volume rm $(docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*mobymask_deployment|.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data") -``` + ```bash + docker volume ls + ``` + +* Remove volumes created by this stack + + Example: + ```bash + docker volume rm laconic-bfb01caf98b1b8f7c8db4d33f11b905a_moby_data_server + ``` diff --git a/app/data/stacks/mobymask-v2/demo.md b/app/data/stacks/mobymask-v2/demo.md index 329b554d..35416780 100644 --- a/app/data/stacks/mobymask-v2/demo.md +++ b/app/data/stacks/mobymask-v2/demo.md @@ -1,22 +1,22 @@ # Demo -* Get the root invite link URL for mobymask-app: +* Get the root invite link URL for mobymask-app - ```bash - docker logs -f $(docker ps -aq --filter name="mobymask-1") + ``` + laconic-so --stack mobymask-v2 deploy-system logs mobymask ``` - The invite link is seen at the end of the logs. Example log: - - ```bash + The invite link is seen at the end of the logs + Example: + ``` 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 a browser to use the mobymask-app. +* Open the invite link in 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 at least 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 atleast one other peer for pubsub to work). * Create an invite link in the app by clicking on `Create new invite link` button. @@ -29,18 +29,26 @@ * In the `MESSAGES` tab of other browsers, a message can be seen with the signed invocations. -* In a terminal, check logs from the watcher peer container: +* In a terminal check logs from the watcher peer container. - ```bash - docker logs -f $(docker ps -aq --filter name="mobymask-watcher-server") - ``` + * Get the container id -* It should have received the message, sent transaction to L2 chain and received a transaction receipt for an `invoke` message with block details. + ```bash + laconic-so --stack mobymask-v2 deploy-system ps | grep mobymask-watcher-server + ``` + + * Check logs + + ```bash + docker logs -f CONTAINER_ID + ``` + +* It should have received the message, sent transaction to L2 chain and received a transaction receipt with block details. Example log: - ```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:19.771Z vulcanize:peer-listener [10:25:19] Received a message on mobymask P2P network from peer: PeerId(12D3KooWAVNswtcrX12iDYukEoxdQwD34kJyRWcQTfZ4unGg2xjd) 2023-03-23T10:25:24.143Z laconic:libp2p-utils Transaction receipt for invoke message { to: '0x558024C7d593B840E1BfD83E9B287a5CDad4db15', blockNumber: 1996, @@ -52,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 { @@ -63,10 +71,10 @@ } ``` - * Get the deployed contract address: + * Get the deployed contract address ```bash - docker exec -it $(docker ps -aq --filter name="mobymask-app") cat src/config.json + laconic-so --stack mobymask-v2 deploy-system exec mobymask-app "cat src/config.json" ``` The value of `address` field is the deployed contract address @@ -86,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. @@ -99,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 a `revoke` message. +* Check the watcher peer logs. It should receive a message and log the transaction receipt for revoke message. * Try reporting a phisher from the revoked invitee's browser. @@ -121,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. diff --git a/app/data/stacks/mobymask-v2/mobymask-only.md b/app/data/stacks/mobymask-v2/mobymask-only.md deleted file mode 100644 index 246d9000..00000000 --- a/app/data/stacks/mobymask-v2/mobymask-only.md +++ /dev/null @@ -1,85 +0,0 @@ -# MobyMask v2 watcher - -Instructions to setup and deploy MobyMask v2 watcher independently - -## Setup - -Prerequisite: L2 Optimism Geth and Node RPC endpoints - -Clone required repositories: - -```bash -laconic-so --stack mobymask-v2 setup-repositories --include cerc-io/MobyMask,cerc-io/watcher-ts -``` - -Checkout to the required versions and branches in repos: - -```bash -# watcher-ts -cd ~/cerc/watcher-ts -git checkout v0.2.34 - -# MobyMask -cd ~/cerc/MobyMask -git checkout v0.1.2 -``` - -Build the container images: - -```bash -laconic-so --stack mobymask-v2 build-containers --include cerc/watcher-mobymask-v2,cerc/mobymask -``` - -This should create the required docker images in the local image registry - -## Deploy - -### 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 -* Update the [optimism-params.env](../../config/watcher-mobymask-v2/optimism-params.env) file with Optimism endpoints and other params for the Optimism running separately - * If `PRIVATE_KEY_PEER` is not set the inline watcher peer will not send txs to L2 on receiving P2P network messages -* 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 - -### Deploy the stack - -```bash -laconic-so --stack mobymask-v2 deploy --include watcher-mobymask-v2 up -``` - -To list down and monitor the running containers: - -```bash -laconic-so --stack mobymask-v2 deploy --include watcher-mobymask-v2 ps - -# With status -docker ps - -# Check logs for a container -docker logs -f -``` - -## Tests - -See [Tests](./README.md#tests) - -## Clean up - -Stop all services running in the background: - -```bash -laconic-so --stack mobymask-v2 deploy --include watcher-mobymask-v2 down -``` - -Clear volumes created by this stack: - -```bash -# List all relevant volumes -docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*mobymask_deployment|.*fixturenet_geth_accounts" - -# Remove all the listed volumes -docker volume rm $(docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*mobymask_deployment|.*fixturenet_geth_accounts") -``` diff --git a/app/data/stacks/mobymask-v2/stack.yml b/app/data/stacks/mobymask-v2/stack.yml index 248351b1..cdcbd663 100644 --- a/app/data/stacks/mobymask-v2/stack.yml +++ b/app/data/stacks/mobymask-v2/stack.yml @@ -27,5 +27,3 @@ pods: - fixturenet-eth - fixturenet-optimism - watcher-mobymask-v2 - - mobymask-app - - peer-test-app diff --git a/app/data/stacks/mobymask-v2/web-apps.md b/app/data/stacks/mobymask-v2/web-apps.md deleted file mode 100644 index 052a7cb7..00000000 --- a/app/data/stacks/mobymask-v2/web-apps.md +++ /dev/null @@ -1,91 +0,0 @@ -# Web Apps - -Instructions to setup and deploy MobyMask and Peer Test web apps - -## Setup - -Prerequisite: Watcher with GQL and relay node endpoints - -Clone required repositories: - -```bash -laconic-so --stack mobymask-v2 setup-repositories --include cerc-io/react-peer,cerc-io/mobymask-ui -``` - -Checkout to the required versions and branches in repos: - -```bash -# react-peer -cd ~/cerc/react-peer -git checkout v0.2.31 - -# mobymask-ui -cd ~/cerc/mobymask-ui -git checkout laconic -``` - -Build the container images: - -```bash -laconic-so --stack mobymask-v2 build-containers --include cerc/react-peer-v2,cerc/mobymask-ui -``` - -This should create the required docker images in the local image registry - -## Deploy - -### 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 - -### Deploy the stack - -For running mobymask-app -```bash -laconic-so --stack mobymask-v2 deploy --include mobymask-app up -``` - -For running peer-test-app -```bash -laconic-so --stack mobymask-v2 deploy --include peer-test-app up -``` - -To list down and monitor the running containers: - -```bash -docker ps - -# Check logs for a container -docker logs -f -``` - -## Clean up - -Stop all services running in the background: - -For mobymask-app -```bash -laconic-so --stack mobymask-v2 deploy --include mobymask-app down -``` - -For peer-test-app -```bash -laconic-so --stack mobymask-v2 deploy --include peer-test-app down -``` - -Clear volumes created by this stack: - -```bash -# List all relevant volumes -docker volume ls -q --filter "name=.*mobymask_deployment" - -# Remove all the listed volumes -docker volume rm $(docker volume ls -q --filter "name=.*mobymask_deployment") -``` diff --git a/app/data/version.txt b/app/data/version.txt index 0c1b3362..7a0035e1 100644 --- a/app/data/version.txt +++ b/app/data/version.txt @@ -1,2 +1,2 @@ # This file should be re-generated running: scripts/update-version-file.sh script -v1.0.36-2515878 +v1.0.35-df23476 diff --git a/scripts/developer-mode-setup.sh b/scripts/developer-mode-setup.sh deleted file mode 100755 index 997c6173..00000000 --- a/scripts/developer-mode-setup.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash -# Script to automate the steps needed to make a cloned project repo runnable on the path -# (beware of PATH having some other file with the same name ahead of ours) -if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then - set -x - echo PATH is $PATH -fi -python3 -m venv venv -source ./venv/bin/activate -pip install --editable . -pip install shiv diff --git a/scripts/first_time_setup.sh b/scripts/first_time_setup.sh new file mode 100755 index 00000000..e8900ce7 --- /dev/null +++ b/scripts/first_time_setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +python3 -m venv venv +source ./venv/bin/activate +pip install --editable . +pip install shiv +shiv -c laconic-so -o laconic-so . +./laconic-so --verbose --local-stack setup-repositories diff --git a/scripts/quick-install-ubuntu.sh b/scripts/quick-install-ubuntu.sh deleted file mode 100755 index 3611abdf..00000000 --- a/scripts/quick-install-ubuntu.sh +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/env bash -if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then - set -x -fi - -install_dir=~/bin - -# First display a reasonable warning to the user unless run with -y -if ! [[ $# -eq 1 && $1 == "-y" ]]; then - echo "**************************************************************************************" - echo "This script requires sudo privilege. It installs Laconic Stack Orchestrator" - echo "into: ${install_dir}. It also *removes* any existing docker installed on" - echo "this machine and then installs the latest docker release as well as other" - echo "required packages." - echo "Only proceed if you are sure you want to make those changes to this machine." - echo "**************************************************************************************" - read -p "Are you sure you want to proceed? " -n 1 -r - echo - if [[ ! $REPLY =~ ^[Yy]$ ]]; then - exit 1 - fi -fi - -# This script assumes root permissions on a fresh Ubuntu Digital Ocean droplet -# with these recommended specs: 16 GB Memory / 8 Intel vCPUs / 320 GB Disk - -# TODO: -# Check python3 is available -# Check machine resources are sufficient - -# dismiss the popups -export DEBIAN_FRONTEND=noninteractive - -## https://docs.docker.com/engine/install/ubuntu/ -## https://superuser.com/questions/518859/ignore-packages-that-are-not-currently-installed-when-using-apt-get-remove1 -packages_to_remove="docker docker-engine docker.io containerd runc" -installed_packages_to_remove="" -for package_to_remove in $(echo $packages_to_remove); do - $(dpkg --info $package_to_remove &> /dev/null) - if [[ $? -eq 0 ]]; then - installed_packages_to_remove="$installed_packages_to_remove $package_to_remove" - fi -done - -# Enable stop on error now, since we needed it off for the code above -set -euo pipefail ## https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ - -if [[ -n "${installed_packages_to_remove}" ]]; then - echo "**************************************************************************************" - echo "Removing existing docker packages" - sudo apt -y remove $installed_packages_to_remove -fi - -echo "**************************************************************************************" -echo "Installing dependencies" -sudo apt -y update - -# laconic-so depends on jq -sudo apt -y install jq -# laconic-so depends on git -sudo apt -y install git -# curl used below -sudo apt -y install jq -# docker repo add depends on gnupg and updated ca-certificates -sudo apt -y install ca-certificates gnupg - -# Add dockerco package repository -sudo mkdir -m 0755 -p /etc/apt/keyrings -curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg -echo \ - "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ - "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \ - sudo tee /etc/apt/sources.list.d/docker.list > /dev/null - -# Penny in the update jar -sudo apt -y update - -echo "**************************************************************************************" -echo "Installing docker" -sudo apt -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin - -# Allow the current user to use Docker -sudo usermod -aG docker $USER - -echo "**************************************************************************************" -echo "Installing laconic-so" -# install latest `laconic-so` -install_filename=${install_dir}/laconic-so -mkdir -p ${install_dir} -curl -L -o ${install_filename} https://github.com/cerc-io/stack-orchestrator/releases/latest/download/laconic-so -chmod +x ${install_filename} - -echo "**************************************************************************************" -# Check if our PATH line is already there -path_add_command="export PATH=\$PATH:${install_dir}" -if ! grep -q "${path_add_command}" ~/.profile -then - echo "Adding this line to the end of ~/.profile:" - echo ${path_add_command} - echo ${path_add_command} >> ~/.profile -fi - -echo "**************************************************************************************" -# PATH set here for commands run in this script -export PATH=$PATH:${install_dir} -echo Installed laconic-so version: $(laconic-so version) - -echo "**************************************************************************************" -echo "The Laconic Stack Orchestrator program laconic-so has been installed at ${install_filename}" -echo "The directory ${install_dir} has been added to PATH in *new* shells via ~/.profile" -echo "**************************************************************************************" -# Message the user to check docker is working for them -echo "Please log in again (docker will not work in this current shell) then:" -echo "test that docker is correctly installed and working for your user by running the" -echo "command below (it should print a message beginning \"Hello from Docker!\"):" -echo -echo "docker run hello-world" -echo