Spin up the subnet and deploy the validators
So far we created an L2 subnet with four validators using metadata operations on Bitcoin L1. Now we are spinning up "physically" the subnet and validators using docker.
Prerequisites
Please make sure you have successfully run all steps in the previous page Subnet creation and initialisation. In particular, make sure that sufficiently many validators have submitted the join and fund commands for the newly created subnet.
Option A: Using automated scripts
Step 1: Spin-up docker containers
We have provided a script that automates spinning up the subnets. The script assumes that you have used the ports, wallet names, and authentication tokens as described in these docs, and that you have already created and joined a subnet with four validators, and that the monitor and provider binaries for those validators are running.
Make sure docker is running on your machine.
The only input to the script is the subnet id. From the bitcoin-ipc repo, run
./scripts/spin_up_subnet_a.sh $SUBNET_ID
Attention:
The scripts outputs a CometBFT ID
and a Resolver Address
. This looks like:
CometBFT ID: 1938b373fb77b24215320bc31dbf7f33469d980e
Resolver Address: 16Uiu2HAmURvM8XziBhzB57YBMQ2fiT8RvUkGpACeCzn1rV8zQQVv
We will need this information later when we start a fifth validator for the subnet. Please note them down and/or create the following environment variables:
export CometBftID=<The CometBFT ID>
export ResolverAddress=<The Resolver Address>
Verify on docker that the containers are up and running — for each validator there should be three containers: validatorX-fendermint
, validatorX-cometbft
, and validatorX-ethapi
.
Step 2: Check the status of the subnet
You can now use the the scripts provided in Helper scripts to check the status of the subnet.
In particular, you can use
./scripts/l2_block_checker.sh $SUBNET_ID
to verify that the subnet is producing blocks, and
./scripts/balancer.sh $SUBNET_ID
or
ipc-cli wallet balances --wallet-type btc --subnet $SUBNET_ID
to check the balances in the subnet.
Option B: Manually deploy the validators
Step 1: Deploy the infrastructure
Let's start our first validator which the rest of the validators will bootstrap from. Make sure you have docker running before running this command.
cargo make --makefile infra/fendermint/Makefile.toml \
-e NODE_NAME=validator-1 \
-e SUBNET_ID=<SUBNET_ID> \
-e PRIVATE_KEY_PATH=$HOME/.ipc/validator1/validator.sk \
-e CMT_P2P_HOST_PORT=26656 \
-e CMT_RPC_HOST_PORT=26657 \
-e ETHAPI_HOST_PORT=8545 \
-e RESOLVER_HOST_PORT=26655 \
-e PARENT_ENDPOINT="http://host.docker.internal:3030/api" \
-e PARENT_AUTH_TOKEN="validator1_auth_token" \
-e TOPDOWN_CHAIN_HEAD_DELAY=0 \
-e TOPDOWN_PROPOSAL_DELAY=0 \
-e FM_PULL_SKIP=1 \
child-validator
TOPDOWN_CHAIN_HEAD_DELAY
specifies "the number of blocks to delay before reporting a height as final on the parent chain". TOPDOWN_PROPOSAL_DELAY
specifies "the number of blocks on top of TOPDOWN_CHAIN_HEAD_DELAY
to wait before proposing a height as final on the parent chain". These parameters are used by standard IPC, but when the parent chain is bitcoin the finalization period is handled by the bitcoin monitor (by default, 0 blocks for bitcoin regtest and 6 for bitcoin mainnet, but these values can be configured). Hence, we do not need to specify additional delay on the fendermint level.
Once the first validator is up and running, it will print out the relative information for this validator.
This is shown in this video guide.
#################################
# #
# Subnet node ready! 🚀 #
# #
#################################
Subnet ID:
/b4/t410f6b2qto756ox3qfoonq4ii6pdrylxwyretgpixuy
Eth API:
http://0.0.0.0:8545
Chain ID:
3684170297508395
Fendermint API:
http://localhost:26658
CometBFT API:
http://0.0.0.0:26657
CometBFT node ID:
ca644ac3194d39a2834f5d98e141d682772c149b
CometBFT P2P:
http://0.0.0.0:26656
IPLD Resolver Multiaddress:
/ip4/0.0.0.0/tcp/26655/p2p/16Uiu2HAkwhrWn9hYFQMR2QmW5Ky7HJKSGVkT8xKnQr1oUGCkqWms
You'll need the final component of the IPLD Resolver Multiaddress
(the peer ID
) and the CometBFT node ID
for the next nodes to start.
BOOTSTRAPS: <CometBFT node ID for validator1>@validator-1-cometbft:26656
// An example ca644ac3194d39a2834f5d98e141d682772c149b@validator-1-cometbft:26656
RESOLVER_BOOTSTRAPS: /dns/validator-1-fendermint/tcp/26655/p2p/<Peer ID in IPLD Resolver Multiaddress>, where <PeerID> is the last part of the IPLD Resolver Multiaddress
// An example /dns/validator-1-fendermint/tcp/26655/p2p/16Uiu2HAkwhrWn9hYFQMR2QmW5Ky7HJKSGVkT8xKnQr1oUGCkqWms
Attention:
We will need this information later when we start a fifth validator for the subnet. Please note them down and/or create the following environment variables:
export CometBftID=<The CometBFT ID>
export ResolverAddress=<The Resolver Address>
Now, let's start the rest of the validators:
# Run second validator
cargo make --makefile infra/fendermint/Makefile.toml \
-e NODE_NAME=validator-2 \
-e SUBNET_ID=<SUBNET_ID> \
-e PRIVATE_KEY_PATH=$HOME/.ipc/validator2/validator.sk \
-e CMT_P2P_HOST_PORT=26756 \
-e CMT_RPC_HOST_PORT=26757 \
-e ETHAPI_HOST_PORT=8645 \
-e RESOLVER_HOST_PORT=26755 \
-e BOOTSTRAPS=<BOOTSTRAPS> \
-e RESOLVER_BOOTSTRAPS=<RESOLVER_BOOTSTRAPS> \
-e PARENT_ENDPOINT="http://host.docker.internal:3031/api" \
-e PARENT_AUTH_TOKEN="validator2_auth_token" \
-e TOPDOWN_CHAIN_HEAD_DELAY=0 \
-e TOPDOWN_PROPOSAL_DELAY=0 \
-e FM_PULL_SKIP=1 \
child-validator
# Run third validator
cargo make --makefile infra/fendermint/Makefile.toml \
-e NODE_NAME=validator-3 \
-e SUBNET_ID=<SUBNET_ID> \
-e PRIVATE_KEY_PATH=$HOME/.ipc/validator3/validator.sk \
-e CMT_P2P_HOST_PORT=26856 \
-e CMT_RPC_HOST_PORT=26857 \
-e ETHAPI_HOST_PORT=8745 \
-e RESOLVER_HOST_PORT=26855 \
-e BOOTSTRAPS=<BOOTSTRAPS> \
-e RESOLVER_BOOTSTRAPS=<RESOLVER_BOOTSTRAPS> \
-e PARENT_ENDPOINT="http://host.docker.internal:3032/api" \
-e PARENT_AUTH_TOKEN="validator3_auth_token" \
-e TOPDOWN_CHAIN_HEAD_DELAY=0 \
-e TOPDOWN_PROPOSAL_DELAY=0 \
-e FM_PULL_SKIP=1 \
child-validator
# Run fourth validator
cargo make --makefile infra/fendermint/Makefile.toml \
-e NODE_NAME=validator-4 \
-e SUBNET_ID=<SUBNET_ID> \
-e PRIVATE_KEY_PATH=$HOME/.ipc/validator4/validator.sk \
-e CMT_P2P_HOST_PORT=26956 \
-e CMT_RPC_HOST_PORT=26957 \
-e ETHAPI_HOST_PORT=8845 \
-e RESOLVER_HOST_PORT=26955 \
-e BOOTSTRAPS=<BOOTSTRAPS> \
-e RESOLVER_BOOTSTRAPS=<RESOLVER_BOOTSTRAPS> \
-e PARENT_ENDPOINT="http://host.docker.internal:3033/api" \
-e PARENT_AUTH_TOKEN="validator4_auth_token" \
-e TOPDOWN_CHAIN_HEAD_DELAY=0 \
-e TOPDOWN_PROPOSAL_DELAY=0 \
-e FM_PULL_SKIP=1 \
child-validator
Last updated