Add force rebuild option #329

Merged
telackey merged 8 commits from dboreham/rebuild-option into main 2023-04-14 20:19:28 +00:00
25 changed files with 117 additions and 55 deletions
Showing only changes of commit 023746bd5f - Show all commits

2
.gitignore vendored
View File

@ -5,4 +5,4 @@ laconic-so
laconic_stack_orchestrator.egg-info
__pycache__
*~
build

View File

@ -121,7 +121,9 @@ def command(ctx, include, exclude, force_rebuild, extra_build_args):
# Originally we used the PEP 584 merge operator:
# envs = {"CERC_NPM_AUTH_TOKEN": npm_registry_url_token} | ({"CERC_SCRIPT_DEBUG": "true"} if debug else {})
# but that isn't available in Python 3.8 (default in Ubuntu 20) so for now we use dict.update:
envs = {"CERC_NPM_AUTH_TOKEN": npm_registry_url_token}
envs = {"CERC_NPM_AUTH_TOKEN": npm_registry_url_token,
"LACONIC_HOSTED_CONFIG_FILE": "config-hosted.yml" # Convention used by our web app packages
}
envs.update({"CERC_SCRIPT_DEBUG": "true"} if debug else {})
envs.update({"CERC_FORCE_REBUILD": "true"} if force_rebuild else {})
envs.update({"CERC_CONTAINER_EXTRA_BUILD_ARGS": extra_build_args} if extra_build_args else {})

View File

@ -22,6 +22,7 @@ services:
- ../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
- peers_ids:/peers
- mobymask_deployment:/server
ports:
- "0.0.0.0:3002:3000"
@ -37,3 +38,4 @@ services:
volumes:
mobymask_deployment:
peers_ids:

View File

@ -14,6 +14,7 @@ services:
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
- peers_ids:/peers
ports:
- "0.0.0.0:3003:3000"
healthcheck:
@ -24,3 +25,6 @@ services:
start_period: 10s
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
peers_ids:

View File

@ -70,15 +70,15 @@ services:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
CERC_L2_GETH_RPC: ${CERC_L2_GETH_RPC}
CERC_PRIVATE_KEY_PEER: ${CERC_PRIVATE_KEY_PEER}
CERC_RELAY_PEERS: ${CERC_RELAY_PEERS}
CERC_RELAY_ANNOUNCE_DOMAIN: ${CERC_RELAY_ANNOUNCE_DOMAIN}
CERC_ENABLE_PEER_L2_TXS: ${CERC_ENABLE_PEER_L2_TXS}
CERC_DEPLOYED_CONTRACT: ${CERC_DEPLOYED_CONTRACT}
command: ["sh", "start-server.sh"]
volumes:
- ../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
- peers_ids:/app/packages/mobymask-v2-watcher/peers
- mobymask_deployment:/server
- fixturenet_geth_accounts:/geth-accounts:ro
# Expose GQL, metrics and relay node ports
@ -97,5 +97,6 @@ services:
volumes:
mobymask_watcher_db_data:
peers_ids:
mobymask_deployment:
fixturenet_geth_accounts:

View File

@ -101,7 +101,7 @@ node update-config.js deploy-config/getting-started.json "$ADMIN_ADDRESS" "$PROP
echo "Updated the deployment config"
# Create a .env file
echo "CERC_L1_RPC=$CERC_L1_RPC" > .env
echo "L1_RPC=$CERC_L1_RPC" > .env
echo "PRIVATE_KEY_DEPLOYER=$ADMIN_PRIV_KEY" >> .env
echo "Deploying the L1 smart contracts, this will take a while..."

View File

@ -1,8 +1,6 @@
{
"name": "MobyMask",
"relayNodes": [
"/ip4/127.0.0.1/tcp/9090/ws/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t"
],
"relayNodes": [],
"peer": {
"enableDebugInfo": true
}

View File

@ -9,22 +9,32 @@ CERC_DEPLOYED_CONTRACT="${CERC_DEPLOYED_CONTRACT:-${DEFAULT_CERC_DEPLOYED_CONTRA
CERC_RELAY_NODES="${CERC_RELAY_NODES:-${DEFAULT_CERC_RELAY_NODES}}"
CERC_APP_WATCHER_URL="${CERC_APP_WATCHER_URL:-${DEFAULT_CERC_APP_WATCHER_URL}}"
# If not set (or []), check the mounted volume for relay peer id
if [ -z "$CERC_RELAY_NODES" ] || [ "$CERC_RELAY_NODES" = "[]" ]; then
echo "CERC_RELAY_NODES not provided, taking from the mounted volume"
CERC_RELAY_NODES="[\"/ip4/127.0.0.1/tcp/9090/ws/p2p/$(jq -r '.id' /peers/relay-id.json)\"]"
fi
echo "Using CERC_RELAY_NODES $CERC_RELAY_NODES"
# 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"
echo "Taking config for deployed contract from mounted volume"
# Set config values from environment variables
jq --arg address "$CERC_DEPLOYED_CONTRACT" \
--argjson chainId $CERC_CHAIN_ID \
--argjson relayNodes "$CERC_RELAY_NODES" \
'.address = $address | .chainId = $chainId | .relayNodes = $relayNodes' \
/app/src/mobymask-app-config.json > /app/src/config.json
# Get deployed contract address and chain id
CERC_DEPLOYED_CONTRACT=$(jq -r '.address' /server/config.json | tr -d '"')
CERC_CHAIN_ID=$(jq -r '.chainId' /server/config.json)
else
echo "Taking deployed contract details from env"
fi
# Export config values in a json file
jq --arg address "$CERC_DEPLOYED_CONTRACT" \
--argjson chainId "$CERC_CHAIN_ID" \
--argjson relayNodes "$CERC_RELAY_NODES" \
'.address = $address | .chainId = $chainId | .relayNodes = $relayNodes' \
/app/src/mobymask-app-config.json > /app/src/config.json
REACT_APP_WATCHER_URI="$CERC_APP_WATCHER_URL/graphql" npm run build
serve -s build

View File

@ -5,6 +5,12 @@ DEFAULT_CERC_WATCHER_HOST="mobymask-watcher-server"
DEFAULT_CERC_WATCHER_PORT=3001
DEFAULT_CERC_APP_WATCHER_URL="http://localhost:3001"
# Set of relay peers to connect to from the relay node
DEFAULT_CERC_RELAY_PEERS=[]
# Domain to be used in the relay node's announce address
DEFAULT_CERC_RELAY_ANNOUNCE_DOMAIN=
# Base URI for mobymask-app (used for generating invite)
DEFAULT_CERC_MOBYMASK_APP_BASE_URI="http://127.0.0.1:3002/#"
@ -18,5 +24,5 @@ DEFAULT_CERC_DEPLOYED_CONTRACT=
# Chain ID is used by mobymask web-app for txs
DEFAULT_CERC_CHAIN_ID=42069
# Set relay nodes to be used by web-apps
DEFAULT_CERC_RELAY_NODES=["/ip4/127.0.0.1/tcp/9090/ws/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t"]
# Set of relay nodes to be used by web-apps
DEFAULT_CERC_RELAY_NODES=[]

View File

@ -1,5 +0,0 @@
{
"id": "12D3KooWK6myjc8r1KBnfP9igp31qJkPaVfsKDjKrjoSefV5SDEo",
"privKey": "CAESQJMHbMaH+UEOtjGOzXYtoPO/cdHakCtN1hcnknIWzx/6ie1lxb+8kfzBjwt7apfj8fHlTCYSIVK8Q2AWu9a2h3g=",
"pubKey": "CAESIIntZcW/vJH8wY8Le2qX4/Hx5UwmEiFSvENgFrvWtod4"
}

View File

@ -1 +0,0 @@
RELAY="/ip4/127.0.0.1/tcp/9090/ws/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t"

View File

@ -1,5 +0,0 @@
{
"id": "12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t",
"privKey": "CAESQGsqG5o4VlWJZM9XlA3MjabyZOXWQ2MLZU5AhBQsjXGt9iSlGtTuNOrHX5xSRgLBxLuMoqWsjGxE/dDB9c46RI8=",
"pubKey": "CAESIPYkpRrU7jTqx1+cUkYCwcS7jKKlrIxsRP3QwfXOOkSP"
}

View File

@ -7,11 +7,34 @@ fi
CERC_L2_GETH_RPC="${CERC_L2_GETH_RPC:-${DEFAULT_CERC_L2_GETH_RPC}}"
CERC_PRIVATE_KEY_PEER="${CERC_PRIVATE_KEY_PEER:-${DEFAULT_CERC_PRIVATE_KEY_PEER}}"
CERC_RELAY_PEERS="${CERC_RELAY_PEERS:-${DEFAULT_CERC_RELAY_PEERS}}"
CERC_RELAY_ANNOUNCE_DOMAIN="${CERC_RELAY_ANNOUNCE_DOMAIN:-${DEFAULT_CERC_RELAY_ANNOUNCE_DOMAIN}}"
CERC_ENABLE_PEER_L2_TXS="${CERC_ENABLE_PEER_L2_TXS:-${DEFAULT_CERC_ENABLE_PEER_L2_TXS}}"
CERC_DEPLOYED_CONTRACT="${CERC_DEPLOYED_CONTRACT:-${DEFAULT_CERC_DEPLOYED_CONTRACT}}"
echo "Using L2 RPC endpoint ${CERC_L2_GETH_RPC}"
# Check for peer ids in ./peers folder, create if not present
if [ -f ./peers/relay-id.json ]; then
echo "Using peer id for relay node from the mounted volume"
else
echo "Creating a new peer id for relay node"
cd ../peer
yarn create-peer -f ../mobymask-v2-watcher/peers/relay-id.json
cd ../mobymask-v2-watcher
fi
if [ -f ./peers/peer-id.json ]; then
echo "Using peer id for peer node from the mounted volume"
else
echo "Creating a new peer id for peer node"
cd ../peer
yarn create-peer -f ../mobymask-v2-watcher/peers/peer-id.json
cd ../mobymask-v2-watcher
fi
CERC_RELAY_MULTIADDR="/dns4/mobymask-watcher-server/tcp/9090/ws/p2p/$(jq -r '.id' ./peers/relay-id.json)"
# Use contract address from environment variable or set from config.json in mounted volume
if [ -n "$CERC_DEPLOYED_CONTRACT" ]; then
CONTRACT_ADDRESS="${CERC_DEPLOYED_CONTRACT}"
@ -28,11 +51,13 @@ else
echo "Using CERC_PRIVATE_KEY_PEER from env"
fi
# Read in the config template TOML file and modify it
WATCHER_CONFIG_TEMPLATE=$(cat environments/watcher-config-template.toml)
WATCHER_CONFIG=$(echo "$WATCHER_CONFIG_TEMPLATE" | \
sed -E "s/REPLACE_WITH_CERC_ENABLE_PEER_L2_TXS/${CERC_ENABLE_PEER_L2_TXS}/g; \
sed -E "s|REPLACE_WITH_CERC_RELAY_PEERS|${CERC_RELAY_PEERS}|g; \
s/REPLACE_WITH_CERC_RELAY_ANNOUNCE_DOMAIN/${CERC_RELAY_ANNOUNCE_DOMAIN}/g; \
s|REPLACE_WITH_CERC_RELAY_MULTIADDR|${CERC_RELAY_MULTIADDR}|g; \
s/REPLACE_WITH_CERC_ENABLE_PEER_L2_TXS/${CERC_ENABLE_PEER_L2_TXS}/g; \
s/REPLACE_WITH_CERC_PRIVATE_KEY_PEER/${CERC_PRIVATE_KEY_PEER}/g; \
s/REPLACE_WITH_CONTRACT_ADDRESS/${CONTRACT_ADDRESS}/g; \
s|REPLACE_WITH_CERC_L2_GETH_RPC_ENDPOINT|${CERC_L2_GETH_RPC}| ")
@ -40,5 +65,8 @@ WATCHER_CONFIG=$(echo "$WATCHER_CONFIG_TEMPLATE" | \
# Write the modified content to a new file
echo "$WATCHER_CONFIG" > environments/local.toml
# Write the relay node's multiaddr to /app/packages/peer/.env for running tests
echo "RELAY=\"$CERC_RELAY_MULTIADDR\"" > /app/packages/peer/.env
echo 'yarn server'
yarn server

View File

@ -1,7 +1,5 @@
{
"relayNodes": [
"/ip4/127.0.0.1/tcp/9090/ws/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t"
],
"relayNodes": [],
"peer": {
"enableDebugInfo": true
}

View File

@ -6,7 +6,15 @@ fi
CERC_RELAY_NODES="${CERC_RELAY_NODES:-${DEFAULT_CERC_RELAY_NODES}}"
# Set relay nodes in config from CERC_RELAY_NODES environment variable
# If not set (or []), check the mounted volume for relay peer id
if [ -z "$CERC_RELAY_NODES" ] || [ "$CERC_RELAY_NODES" = "[]" ]; then
echo "CERC_RELAY_NODES not provided, taking from the mounted volume"
CERC_RELAY_NODES="[\"/ip4/127.0.0.1/tcp/9090/ws/p2p/$(jq -r '.id' /peers/relay-id.json)\"]"
fi
echo "Using CERC_RELAY_NODES $CERC_RELAY_NODES"
# Set relay nodes in config using CERC_RELAY_NODES
jq --argjson relayNodes "$CERC_RELAY_NODES" \
'.relayNodes = $relayNodes' \
./src/test-app-config.json > ./src/config.json

View File

@ -26,14 +26,15 @@
[server.p2p.relay]
host = "0.0.0.0"
port = 9090
relayPeers = []
peerIdFile = './relay-id.json'
relayPeers = REPLACE_WITH_CERC_RELAY_PEERS
peerIdFile = './peers/relay-id.json'
announce = 'REPLACE_WITH_CERC_RELAY_ANNOUNCE_DOMAIN'
enableDebugInfo = true
[server.p2p.peer]
relayMultiaddr = '/dns4/mobymask-watcher-server/tcp/9090/ws/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t'
relayMultiaddr = 'REPLACE_WITH_CERC_RELAY_MULTIADDR'
pubSubTopic = 'mobymask'
peerIdFile = './peer-id.json'
peerIdFile = './peers/peer-id.json'
enableDebugInfo = true
enableL2Txs = REPLACE_WITH_CERC_ENABLE_PEER_L2_TXS

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash
# Build a local version of the task executor for act-runner
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
docker build -t cerc/act-runner-task-executor:local -f ${CERC_REPO_BASE_DIR}/act_runner/Dockerfile.task-executor ${build_command_args} ${CERC_REPO_BASE_DIR}/act_runner
docker build -t cerc/act-runner-task-executor:local -f ${CERC_REPO_BASE_DIR}/hosting/gitea/Dockerfile.task-executor ${build_command_args} ${CERC_REPO_BASE_DIR}/hosting

View File

@ -1,7 +1,7 @@
#!/bin/bash
# Usage: build-npm-package-local-dependencies.sh <registry-url> <publish-with-this-version>
# Runs build-npm-package.sh after first fixing up yarn.lock to use a local
# npm registry for all packages in a spcific scope (currently @cerc-io and @lirewine)
# npm registry for all packages in a specific scope (currently @cerc-io, @lirewine and @muknsys)
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x
fi
@ -18,7 +18,7 @@ set -e
local_npm_registry_url=$1
package_publish_version=$2
# If we need to handle an additional scope, add it to the list below:
npm_scopes_to_handle=("@cerc-io" "@lirewine")
npm_scopes_to_handle=("@cerc-io" "@lirewine" "@muknsys")
for npm_scope_for_local in ${npm_scopes_to_handle[@]}
do
# We need to configure the local registry

View File

@ -24,6 +24,7 @@ package_name=$( cat package.json | jq -r .name )
local_npm_registry_url=$1
npm config set @cerc-io:registry ${local_npm_registry_url}
npm config set @lirewine:registry ${local_npm_registry_url}
npm config set @muknsys:registry ${local_npm_registry_url}
# Workaround bug in npm unpublish where it needs the url to be of the form //<foo> and not http://<foo>
local_npm_registry_url_fixed=$( echo ${local_npm_registry_url} | sed -e 's/^http[s]\{0,1\}://')
npm config set -- ${local_npm_registry_url_fixed}:_authToken ${CERC_NPM_AUTH_TOKEN}

View File

@ -16,7 +16,11 @@ task('send-balance', 'Sends Ether to a specified Ethereum account')
to,
value: ethers.utils.parseEther(amount),
})
const txReceipt = await tx.wait()
console.log(`Balance sent to: ${to}, from: ${wallet.address}`)
console.log(
`Block: { number: ${txReceipt.blockNumber}, hash: ${txReceipt.blockHash} }`
)
console.log(`Transaction hash: ${tx.hash}`)
})

View File

@ -122,8 +122,8 @@ 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|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data"
docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*peers_ids|.*mobymask_deployment|.*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=.*mobymask_watcher_db_data|.*mobymask_deployment|.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data")
docker volume rm $(docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*peers_ids|.*mobymask_deployment|.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data")
```

View File

@ -57,6 +57,12 @@ Create and update an env file to be used in the next step ([defaults](../../conf
# (used for generating a root invite link after deploying the contract)
CERC_MOBYMASK_APP_BASE_URI="http://127.0.0.1:3002/#"
# (Optional) Set of relay peers to connect to from the relay node
CERC_RELAY_PEERS=[]
# (Optional) Domain to be used in the relay node's announce address
CERC_RELAY_ANNOUNCE_DOMAIN=
# Set to false for disabling watcher peer to send txs to L2
CERC_ENABLE_PEER_L2_TXS=true
@ -112,8 +118,8 @@ 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"
docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*peers_ids|.*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")
docker volume rm $(docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*peers_ids|.*mobymask_deployment|.*fixturenet_geth_accounts")
```

View File

@ -41,8 +41,10 @@ This should create the required docker images in the local image registry
Create and update an env file to be used in the next step ([defaults](../../config/watcher-mobymask-v2/mobymask-params.env)):
```bash
# Set relay nodes to be used by the web-app
CERC_RELAY_NODES=["/ip4/127.0.0.1/tcp/9090/ws/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t"]
# Set of relay nodes to be used by the web-app
# (use double quotes " for strings)
# Eg. CERC_RELAY_NODES=["/dns4/example.com/tcp/443/wss/p2p/12D3KooWGHmDDCc93XUWL16FMcTPCGu2zFaMkf67k8HZ4gdQbRDr"]
CERC_RELAY_NODES=[]
# Also add if running MobyMask app:
@ -111,8 +113,8 @@ Clear volumes created by this stack:
```bash
# List all relevant volumes
docker volume ls -q --filter "name=.*mobymask_deployment"
docker volume ls -q --filter "name=.*mobymask_deployment|.*peers_ids"
# Remove all the listed volumes
docker volume rm $(docker volume ls -q --filter "name=.*mobymask_deployment")
docker volume rm $(docker volume ls -q --filter "name=.*mobymask_deployment|.*peers_ids")
```

View File

@ -1,5 +1,7 @@
# Specification
(note this page is out of date)
## Implementation

View File

@ -60,7 +60,7 @@ sudo apt -y install jq
# laconic-so depends on git
sudo apt -y install git
# curl used below
sudo apt -y install jq
sudo apt -y install curl
# docker repo add depends on gnupg and updated ca-certificates
sudo apt -y install ca-certificates gnupg