From 5e1791d37a7acec384c3528d29cd5a8079460937 Mon Sep 17 00:00:00 2001 From: Fridrik Asmundsson Date: Wed, 10 Apr 2024 10:30:29 +0000 Subject: [PATCH] Several improvents to deploy subnet script - Fix relayer not starting due to missing argument - Fix bug when default-key was first in the json array - Streamline local deployment by introducing a prepare_local.sh script - Improve documentation for local deployment and document more known issues --- README.md | 2 +- .../README.md | 8 +-- .../deploy.sh | 15 ++++-- .../prepare_local.sh | 50 +++++++++++++++++++ 4 files changed, 67 insertions(+), 8 deletions(-) mode change 100644 => 100755 scripts/deploy_subnet_under_calibration_net/deploy.sh create mode 100755 scripts/deploy_subnet_under_calibration_net/prepare_local.sh diff --git a/README.md b/README.md index e777843e9..8112d7450 100644 --- a/README.md +++ b/README.md @@ -107,4 +107,4 @@ To be able to interact with Calibration and run new subnets, some FIL should be ## Help -If you meet any obstacles join us in **#ipc-help** in the [Filecoin Slack workspace](https://filecoin.io/slack). +If you meet any obstacles join us in **#ipc** in the [Filecoin Slack workspace](https://filecoin.io/slack). diff --git a/scripts/deploy_subnet_under_calibration_net/README.md b/scripts/deploy_subnet_under_calibration_net/README.md index 0da252b41..3d5897d80 100644 --- a/scripts/deploy_subnet_under_calibration_net/README.md +++ b/scripts/deploy_subnet_under_calibration_net/README.md @@ -4,13 +4,13 @@ We currently have a [Github workflow](https://github.com/consensus-shipyard/ipc/actions/workflows/deploy-to-dedicated-host.yaml) to deploy IPC infra to a dedicated host. You can go to the workflow page and click `Run workflow` button on the top right corner to initiate a deployment. ## Deploy to local machine -The same `deploy.sh` script can also be used to deploy locally. This is more or less equivalent to following [quickstart-calibration.md](https://github.com/consensus-shipyard/ipc/blob/main/docs/ipc/quickstart-calibration.md), but much more automated. +The same `deploy.sh` script can also be used to deploy locally. This is more or less equivalent to following [Deploy a subnet](https://docs.ipc.space/quickstarts/deploy-a-subnet), but much more automated. To run this script locally, you need to first manually prepare the environment and files. -1. Make sure you have your ipc repo located at $HOME/ipc. -2. Follow Step 2 and Step 3 in [Github workflow](https://github.com/consensus-shipyard/ipc/actions/workflows/deploy-to-dedicated-host.yaml) to prepare ipc config file and wallets. Remember to go to [Calibration faucet](https://faucet.calibration.fildev.network/funds.html) to fund all of your addresses. -3. Run `bash deploy.sh local` to deploy IPC locally. +1. Run `prepare_local.sh` to generate a local ipc repo +2. Go to [Calibration faucet](https://faucet.calibration.fildev.network/funds.html) to fund all of your addresses. +3. Run `deploy.sh local` to deploy IPC locally. Please also notice that 1. The `deploy.sh` is only for running on Linux. If you are using a Mac, you need to disable all `apt` based dependency installation. You may also need to install bash (version >= 5) to run this script since the script isn't fully compatible with zsh (default shell on Mac). diff --git a/scripts/deploy_subnet_under_calibration_net/deploy.sh b/scripts/deploy_subnet_under_calibration_net/deploy.sh old mode 100644 new mode 100755 index e483a705a..74d9238a4 --- a/scripts/deploy_subnet_under_calibration_net/deploy.sh +++ b/scripts/deploy_subnet_under_calibration_net/deploy.sh @@ -1,12 +1,14 @@ #!/bin/bash # IPC Quick Start Script -# See also https://github.com/consensus-shipyard/ipc/blob/main/docs/ipc/quickstart-calibration.md +# See also https://docs.ipc.space/quickstarts/deploy-a-subnet # Known issues: # 1. Need to previously manual enable sudo without password on the host # 2. You may need to rerun the script after docker installation for the first time -# 2. You may need to manually install nodejs and npm on the host +# 3. You may need to manually install nodejs and npm on the host +# 4. If you get failures related to "deserializing fvm address", check if your +# FM_NETWORK env variable is set correctly (e.g it should either be testnet or mainnet) set -euxo pipefail @@ -35,6 +37,13 @@ else fi fi +# the script assumes there is no default-key, so lets check that early on. +# TODO: Update this script to handle having default-key set +if grep -q default-key ${IPC_CONFIG_FOLDER}/evm_keystore.json; then + echo "Please remove default-key from ${IPC_CONFIG_FOLDER}/evm_keystore.json before running this script" + exit 1 +fi + # Step 1: Prepare system for building and running IPC # Step 1.1: Install build dependencies @@ -282,7 +291,7 @@ done pkill -f "relayer" || true # Start relayer echo "$DASHES Start relayer process (in the background)" -nohup $IPC_CLI checkpoint relayer --subnet $subnet_id > nohup.out 2> nohup.err < /dev/null & +nohup $IPC_CLI checkpoint relayer --subnet $subnet_id --submitter $default_wallet_address > nohup.out 2> nohup.err < /dev/null & # Step 11: Print a summary of the deployment # Remove leading '/' and change middle '/' into '-' diff --git a/scripts/deploy_subnet_under_calibration_net/prepare_local.sh b/scripts/deploy_subnet_under_calibration_net/prepare_local.sh new file mode 100755 index 000000000..05c0842f7 --- /dev/null +++ b/scripts/deploy_subnet_under_calibration_net/prepare_local.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# A script which resets your local .ipc folder so we can run the deploy.sh script for a local deployment +# +# To run: +# 1. Run `./prepare_local.sh` +# 2. Run `./deploy.sh` +# +# Known issues: +# - The deploy.sh script does not run "make docker-build" which can cause errors if its outdated on your +# machine. To fix this, run `make docker-build` in ipc/fendermint folder and rerun the deploy.sh script + +set -eo pipefail + +SCRIPT_DIR=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) +echo "SCRIPT_DIR: $SCRIPT_DIR" + +echo "Installing dependencies..." +cargo install toml-cli + +echo "Removing existing .ipc folder" +rm -rf ~/.ipc + +echo "Copying new .ipc folder" +cp -r $SCRIPT_DIR/.ipc ~/.ipc + +echo "Fetching info about newest current deployment contracts" +hash=$(curl -s https://raw.githubusercontent.com/consensus-shipyard/ipc/cd/contracts/deployments/r314159.json) +echo $hash | jq + +echo "Parsing gateway and registry address..." +gateway_addr=$(echo $hash | jq -r '.gateway_addr') +echo "- Gateway address: $gateway_addr" +registry_addr=$(echo $hash | jq -r '.registry_addr') +echo "- Registry address: $registry_addr" + +echo "Updating config with new gateway and registry address" +toml set ~/.ipc/config.toml subnets[0].config.gateway_addr $gateway_addr > ~/.ipc/config.toml.tmp +toml set ~/.ipc/config.toml.tmp subnets[0].config.registry_addr $registry_addr > ~/.ipc/config.toml.tmp2 +cp ~/.ipc/config.toml.tmp2 ~/.ipc/config.toml + +echo "Setting up wallets" +wallet1=$(cargo run -q -p ipc-cli --release -- wallet new --wallet-type evm | tr -d '"') +echo "- Wallet1: $wallet1" +wallet2=$(cargo run -q -p ipc-cli --release -- wallet new --wallet-type evm | tr -d '"') +echo "- Wallet2: $wallet2" +wallet3=$(cargo run -q -p ipc-cli --release -- wallet new --wallet-type evm | tr -d '"') +echo "- Wallet3: $wallet3" + +echo "--- GO TO Calibration faucet (https://faucet.calibnet.chainsafe-fil.io/) and get some tokens for the wallets ---"