circle-playInstallation

This step guides you to install and run all necessary components.

circle-info

By default, all pages in this guide install the required repos and their dependencies using Docker. A single container called bitcoin-ipc downloads the bitcoin-ipc and ipc repos, installs dependencies and builds the repos, runs bitcoin-core , and runs ipc-cli . The bitcoin wallets and Bitcoin-IPC configuration files also live in the container. Nothing is installed on your local machine (apart from Docker). This is the simplest and the recommended option.

Alternatively, you can clone the repos bitcoin-ipc and ipc, and run bitcoin-core and ipc-cli on your local machine, but then you need to locally install all dependencies. This is setup is described in Alternative: Install on the host machine on this page, and all following pages contain an "Alternative" approach, which you need to follow if you opt for the alternative setup.

In both cases, the validator nodes will run in separate Docker containers on your host machine — the difference is that with the default option these containers will be started from inside the bitcoin-ipc container, while with the alternative option the containers will be started from your host machine.

All pages titled "Optional" describe ways to further parametrize this guide, or additional scripts that can give you more background information.

Background

The bitcoin-ipc repo

The bitcoinscalinglabs/bitcoin-ipc repoarrow-up-right contains the following two binaries.

  • Monitor: It monitors the Bitcoin network for new blocks and transactions. It processes transactions with IPC-related data. It saves the data in a local database, configurable by the DATABASE_URL environment variable.

  • Provider: It exposes an HTTP endpoint with a JSON RPC to interact with Bitcoin, and reads data from the local database. It's primarily intented to be used by the ipc-cli, which we will introduce later. It listens on the port configurable by PROVIDER_PORT, defaulting to 3030. It requires an Authorization header with a bearer token to be match the value of PROVIDER_AUTH_TOKEN env var, defaulting to "validator1_auth_token" .

The ipc repo

The bitcoinscalinglabs/ipc repoarrow-up-right is a fork of the standard (Filecoin-based) IPC repoarrow-up-right. It contains the consensus and execution engines used by Bitcoin-IPC validators, and a tool call ipc-cli, which helps validators and clients interact with subnets. For information about what ipc-cli is and how to use it, see the ipc docsarrow-up-right.

Bitcoin Regtest network

This guide is using Regtest, a local Bitcoin chain created on your local machine (or in a Docker container).


Deployment instructions

  1. Install Docker on your machine. This guide has been tested with Docker version 29.1.5. We recommend allowing Docker to use at least 12 GB of RAM.

  2. Delete the ~/.ipc directory, if it exists (the directory is bind-mounted and auto-generated upon starting the bitcoin-ipc container).

  1. Run the bitcoin-ipc container

  1. The script starts a Bitcoin Monitor and a Bitcoin Provider instance for four validators (these validators will later in this guide join Bitcoin-IPC subnets), with log files stored in /root/logs/ in the container. See Optional: Helper scripts for more information on the log files.

  2. If in the future you need to delete the data generated in the container, you can run:

    Attention, this will delete:

    - All bitcoin regtest data

    - All non-default Bitcoin-IPC and bitcoin accounts - All Bitcoin-IPC subnets

More information

The bitcoin-ipc container contains/runs:

  • Bitcoin Core in regtest mode with the required configuration in /root/.bitcoin/bitcoin.conf.

  • The required repos cloned in /workspace/ipc and /workspace/bitcoin-ipc .

  • The ipc-cli tool.

  • Bitcoin wallets and IPC configuration (under /root/.ipc/) for all 5 validators and 2 users, generated using the src/bin/quickstart.rs script upon container creation — the /root/.ipc/ container directory is bind-mounted to the ~/.ipc host directory, for both technical and debugging purposes.

  • The monitor and provider binaries for each validator (validator1validator5) and user (user1, user2), automatically started upon container creation (in the docker-deploy-local/docker-entrypoint.sh script).

  • The captured logs for each monitor and provider instance in the /root/logs/ directory inside the container.

  • Sets the required environment variables for the demo (see docker-compose.yml in the bitcoin-ipc repo).

  • The script /workspace/bitcoin-ipc/scripts/miner.sh that mines regtest blocks every 10 seconds (started automatically upon container creation).

  • A script to quickly create, join, and fund a subnet in /usr/local/bin/bootstrap_subnet_from_container.sh (not run automatically - we will use it in a following step).

  • Scripts to spin up docker containers for the validator nodes of two subnets: /usr/local/bin/spin_up_subnet_a_from_container.sh and /usr/local/bin/spin_up_subnet_b_from_container.sh (not run automatically - we will use them in a following step).

  • It exposes ports 3030-3034 and 3040-3041, where the Bitcoin provider instances of the validators and users are listening — these will be used by the Docker containers of each validators.

  • It persists bitcoin data (directory /root/.bitcoin) and IPC data (directory /root/.ipc) to a Docker volume, so they survive restarts of the container).

  • The host Docker socket (`/var/run/docker.sock`) is mounted into this container, so we can later build and run host-managed containers (i.e., the containers cometbft, fendermint, and ethapi for each validator) from inside this container.

More information about the bitcoin-ipc container can be found in the docker-deploy-local/README.md file of the bitcoin-ipc repo.


Alternative: Install on the host machine

circle-exclamation

Before we start creating subnets, let's set up the necessary components.

We'll start by setting up a local Bitcoin Regtest network, setting up Bitcoin IPC components, and finally installing the IPC Client that supports Bitcoin.

Step 1: Install, configure, and start Bitcoin Core

Follow the installation instructions for your operating system provided on the Bitcoin Core download pagearrow-up-right.

To verify the installation: Open a terminal or command prompt and verify that bitcoind and bitcoin-cli are installed correctly:

Ensure that the Bitcoin data directory exists. The default locations for different operating systems are:

Create or edit the bitcoin.conf file in the Bitcoin data directory and add the following configuration to enable regtest, your own local network. The contents of the bitcoin.conf file should be:

You can replace user and pass with your desired username and password (in which case you will have to change these values for each validator and user of this demo — this documentation will guide you). Start Bitcoin Core daemon:

To verify bitcoind is running:

The output should show the chain as regtest.

Step 2: Bitcoin-ipc repo

Install Rust

The project is build on Rust, do first we need to install it. For this, follow the official instructionsarrow-up-right. We require version at least 1.87.0.

To verify the Rust installation:

Download and build the bitcoin-ipc repo

In this step we will download and build the bitcoinscalinglabs/bitcoin-ipc repoarrow-up-right. As we will explain, this contains the components that interact with the Bitcoin Network.

Add binaries to path

After building the project, both monitor and provider binaries are available in bitcoin-ipc/target/release directory. For ease of use let's add both binaries to our path:

By default, the monitor and provider read the .env file in the current directory. For a full list of env variables see the .env.example file. You can specify a different file by passing a relative path to the --env flag, like so: monitor --env=custom.env and provider --env=custom.env .

circle-exclamation
circle-check

With both monitor and provider installed, it's time to setup ipc-cli.

Step 3: IPC repo and ipc-cli

In this step we will download and build the bitcoinscalinglabs/ipc repoarrow-up-right.

Download and build the ipc repo

Install the basic requirements for IPC:

Also install the following dependencies (detailsarrow-up-right)

Building the repo:

circle-info

NOTE: this step may take a while to compile, depending on OS version and hardware build

After following the instructions, you should now have the following binaries available:

Add the binaries to path

For ease of use we can make aliases for these binaries. You can use

Build docker images

One final thing is to build the fendermint local docker image:

To verify the image is available:

Step 4: Generate wallets and config files

We provide a script that automates the setup for wallets and configuration files for five validators and two users.

Before running it:

  • Make sure that ~/.ipc does not exist. The script will not override it.

From within the bitcoin-ipc repo run:

circle-exclamation

The script prints the the IPC address (aka ETH address) and the X-Only public key of each validator and user, as well as a whitelist consisting of the first four validators (to be used when creating a subnet).

circle-check

For ease of use, you can extract the IPC address and the whitelist into env variables:

The ~/.ipc directory should have the following structure:

the ~/.ipc directory after the quickstart script

Step 5: Run Monitor and Provider for each validator

In this step we start the monitor and provider binaries, which we will use throughout the whole demo. Make sure every process is run in a separate terminal window/pane. Also make sure you are in the bitcoin-ipc repo and have run cargo build --release.

circle-check

Validator 1

Validator 2

Validator 3

Validator 4

Validator 5

User 1

User 2

Last updated