serverSubnet creation

We have now created all the required wallets and configuration files for five validators and two users. We'll now create an L2 subnet and have four validators join it.

To create a subnet, first connect to the bitcoin-ipc container running:

docker exec -it bitcoin-ipc bash

Then run:

# from inside the container
/usr/local/bin/bootstrap_subnet_a_from_container.sh

This is the scripts/bootstrap_subnet_a_from_container.sh script from the bitcoin-ipc repo, which has been mounted in the container for convenience.

It does the following:

  1. It submits to bitcoin-core all required transactions to create a subnet and to join and fund four validators.

  2. It updates the config.json files of all validators in the /root/.ipc directory of the container.

  3. It prints, among others, the SubnetID of the newly created subnet — it is a good idea to export it to an env variable.

circle-info

Before running the previous command, you can start terminal(s) watching the logs of the Monitor and Provider for some validators, as explained in Optional: Helper scripts. This way you can see what is being writen and read from Bitcoin in real time.


Alternative: Install on the host machine

If in page Installation you chose the alternative deployment — hence bitcoin-core , the monitors and providers, and ipc-cli are running on your host machine — then you must also use this alternative approach here to create a child subnet.

Even if you used the default Docker-based deployment, you still have the option to use this alternative approach here to create a child subnet. In that case, you need to run all following commands from inside the bitcoin-ipc container — the ipc and bitcoin-ipc repos can be found in the /root/workspace directory.

Step 1: Create a child subnet

We can now create a subnet under /b4 — Bitcoin Regtest. If you have not created the env variable, replace $WHITELIST with the one you created earlier.

You should see the subnet ID printed to the console. Let's save the subnet ID for later use — we will refer to it as $SUBNET_ID.

You can now start the miner helper script (as described in Optional: Helper scripts) by running the following from the bitcoin-ipc repo:

All monitors should have printed the subnet create message to the console.

circle-check

Step 2: Update the config.toml files

We now need to add the new subnet configuration to all of the following configuration files:

  • ~/.ipc/validator1/config.toml

  • ~/.ipc/validator2/config.toml

  • ~/.ipc/validator3/config.toml

  • ~/.ipc/validator4/config.toml

  • ~/.ipc/validator5/config.toml

  • ~/.ipc/user1/config.toml

  • ~/.ipc/user2/config.toml

  • ~/.ipc/config.toml

It might be easier to leave those files open in an editor, so we can modify them later when we create a second subnet.

A subnet configuration looks as follows. For ease of use, each config.toml file already contains the entry — you only have to replace /b4/t410fyi77izvsakigfjnocb7f3hm52bjdeb76jayo4ti with your SubnetID.

circle-check

Step 3: Join the subnet

Let's have four validators join the subnet with some initial collateral.

Let's include the join transactions in the blockchain by mining a block (not needed if you are running the miner.sh script).

We should see the monitors print the join messages to the console, and also reporting that the subnet has been bootstrapped, like so:

circle-check

Step 4: Fund the validators

circle-exclamation

All validators need to have some balance in the subnet, as they use it to pay transaction fees. Let's fund their accounts with wBTC.

Make sure you mine a block (not needed if you are running the miner.sh script).

You should see the logs being printed, like so:

Last updated