Skip to content

Commit

Permalink
Several improvents to deploy subnet script
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
fridrik01 committed Apr 10, 2024
1 parent fdcca99 commit 4f3efdc
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
8 changes: 4 additions & 4 deletions scripts/deploy_subnet_under_calibration_net/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
15 changes: 12 additions & 3 deletions scripts/deploy_subnet_under_calibration_net/deploy.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 '-'
Expand Down
49 changes: 49 additions & 0 deletions scripts/deploy_subnet_under_calibration_net/prepare_local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/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 "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 ---"

0 comments on commit 4f3efdc

Please sign in to comment.