Helper scripts
In this page we provide helper scripts that can be used to monitor the state of the L2 subnets. You do not need to run them all at once -- the documentation will guide you on when to run each script.
The following scripts are run from the root of bitcoin-ipc
repo and assume that you have cloned ipc
and bitcoin-ipc
next to each other (in the same parent directory). They also assume that you have created the necessary config files (see Create wallets and config files) and started the bitcoin monitor and provider binaries (see Run bitcoin monitor and provider).
You may first have to run:
chmod u+x scripts/spin_up_subnet_a.sh
chmod u+x scripts/spin_up_subnet_b.sh
chmod u+x scripts/l2_block_checker.sh
chmod u+x scripts/balancer.sh
chmod u+x scripts/miner.sh
chmod u+x scripts/list_validators.sh
chmod u+x scripts/validator_status.sh
We recommend that you start each of the following scripts in a separate terminal.
Mine blocks on bitcoin
The script mines a regtest block every 10 seconds. You can start this script now.
./scripts/miner.sh
Script getsubnet: Subnet status, as seen from bitcoin
In this following script, make sure that you
update the bitcoin provider port (default in our setup: 3030) and the corresponding auth token (default in our setup: validator1_auth_token), if you have changed them
use the ID of subnet already created.
curl -X POST http://localhost:3030/api \
-H "Content-Type: application/json" \
-H "Authorization: Bearer validator1_auth_token" \
-d '{
"jsonrpc": "2.0",
"method": "getsubnet",
"params": {
"subnet_id": "<THE ID OF A SUBNET HERE>"
},
"id": 1
}' | jq
The command returns, among others, the current committee number (the validator set can change, as we will see in Validator Operations within subnet), the current validator set and the collateral staked by each validator, information on pending committee updates, and information on whether the subnet has been or will be killed.
Script getkillrequests: Submitted kill requests, as seen from bitcoin
The getkillrequests method returns the kill requests, if there are any, for a subnet. We will use it in Kill subnet to keep track of active kill requests and the validators that have voted for each of them. As before, please make sure you
are using the correct port and auth token, if you have changed them
use the subnet id of an already created subnet
curl -X POST http://localhost:3030/api \
-H "Content-Type: application/json" \
-H "Authorization: Bearer validator1_auth_token" \
-d '{
"jsonrpc": "2.0",
"method": "getkillrequests",
"params": {
"subnet_id": "<THE ID OF A SUBNET HERE>"
},
"id": 1
}' | jq
L2 Subnet tools
The following scripts operate on a specific L2 subnet. They can be run only after the docker containers for the subnet have been started and the SubnetID has been added in the ~/.ipc/config.toml
file (In page Spin up the subnet and deploy the validators).
L2 block height
The script queries and prints the current block height of subnet $SUBNET_ID
every 1 second.
./scripts/l2_block_checker.sh $SUBNET_ID
L2 balances
It shows the balance in subnet $SUBNET_ID
of every wallet of type btc
created with ipc-cli
:
./scripts/balancer.sh $SUBNET_ID
Validator status
The following scripts show information for validator 1 and all current validators and their voting power for a subnet. They utilize the RPC offered by the CometBFT instance of validator 1.
status method:
./scripts/validator_status.sh 1
validators method:
./scripts/list_validators.sh 1
In the returned information notice the field voting_power
of each validator.
How the voting power is computed:
The voting power of each validator corresponds to the amount it stakes in the subnet, expressed as an integer between 1 and 10,000.
For example, if four validators stake 2, 1.1, 1.5, and 1.8 bitcoin each, their voting power will be 2000, 1100, 1500, and 1800, respectively.
Spin up subnet A and subnet B
The following tools can be used to start the docker containers for four validators for two subnets. We will use them in Spin up the subnet and deploy the validators.
./internal/spin_up_subnet_a.sh $SUBNET_ID
./internal/spin_up_subnet_b.sh $SUBNET_ID
Last updated