Deploy a subnet
Tutorial to deploy your first custom IPC subnet
Ready to test the waters with your first subnet? This guide will deploy a subnet with three local validators orchestrated by ipc-cli. This subnet will be anchored to the public Calibration testnet. This will be a minimal example and may not work on all systems. The full documentation provides more details on each step.
Several steps in this guide involve running long-lived processes. In each of these cases, the guide advises starting a new session. Depending on your set-up, you may do this using tools like screen or tmux, or, if using a graphical environment, by opening a new terminal tab, pane, or window.
Step 1: Prepare your system
Install the basic requirements for IPC
Install system packages:
sudo apt install build-essential clang cmake pkg-config libssl-dev protobuf-compiler git curl.Install Rust. See instructions.
Install cargo-make:
cargo install --force cargo-make.Install Docker. See instructions.
Install Node.js. See instructions.
Install Foundry. See instructions.
Also install the following dependencies (details)
sudo apt update && sudo apt install build-essential libssl-dev mesa-opencl-icd ocl-icd-opencl-dev gcc git bzr jq pkg-config curl clang hwloc libhwloc-dev wget ca-certificates gnupg -yInstall Xcode from App Store or terminal:
xcode-select --installInstall Homebrew. See instructions.
Install dependencies:
brew install jqInstall Rust. See instructions. (if you have homebrew installed rust, you may need to uninstall that if you get errors in the build)
Install Cargo make:
cargo install --force cargo-makeInstall docker. See instructions.
Install Node.js. See instructions.
Install foundry. See instructions.
Building
# make sure that rust has the wasm32 target & use stable version of rustc
rustup target add wasm32-unknown-unknown
rustup default stable
# add your user to the docker group
sudo usermod -aG docker $USER && newgrp docker
# clone this repo and build
git clone https://github.com/consensus-shipyard/ipc.git
cd ipc
make
# building will generate the following binaries
./target/release/ipc-cli --version
./target/release/fendermint --version# make sure that rust has the wasm32 target & use stable version of rustc
rustup target add wasm32-unknown-unknown
rustup default stable
# clone this repo and build
git clone https://github.com/consensus-shipyard/ipc.git
cd ipc/contracts
make gen
cd ..
cargo build --release
# building will generate the following binaries
./target/release/ipc-cli --version
./target/release/fendermint --versionStep 2: Initialize your config
Initialize the config
This should have populated a default config file with all the parameters required to connect to calibration at ~/.ipc/config.toml. Feel free to update this configuration to fit your needs.
You have two options for setting up the contracts: use the public shared contracts or deploy your own private contracts.
Option A: Use Public Shared Contracts
The IPC stack is changing rapidly. To make sure you use the latest contracts deployed on Filecoin Calibration:
Run
nano ~/.ipc/config.tomlto see your configuration
Replace the
gateway_addrandregistry_addrwith the following values. Click on the badges below to take you to the source to copy and paste them or go to this link.
Option B: Deploy Your Own Private Contracts
If you want to deploy your own custom IPC stack of contracts (recommended for production or private testing):
Step 1: Prepare for contract deployment
Step 2: Ensure you have a funded address
Make sure you have an Ethereum address with funds from the Calibration faucet:
Get your address:
ipc-cli wallet show --wallet-type evmFund it at: https://faucet.calibration.fildev.network/
Note your address - you'll need it for the deployment command
Step 3: Compile contracts
Step 4: Deploy the contracts using ipc-cli
Important: Replace <YOUR_ADDRESS_HERE> with your actual Ethereum address that has funds from the faucet. Use the address from step 2 above.
Step 5: Note the deployed contract addresses
After deployment, look for output similar to this in your terminal:
Important: Save these addresses! You'll need them for configuration and they represent YOUR deployed contracts.
Step 6: Update your IPC configuration
Run nano ~/.ipc/config.toml to edit your configuration file and replace the addresses with your newly deployed contracts:
Step 7: Verify deployment (Optional)
You can verify your contracts are working by checking them on the Calibration Explorer:
Go to https://calibration.filfox.info/en
Search for your Gateway and Registry contract addresses
Verify they exist and have been deployed correctly
Step 3: Set up your wallets
Since we are setting up a subnet with multiple validators, we will create a set of wallets to spawn and interact within the subnet.
Create four different wallets (we recommend a minimum of 4 for BFT security)
You can optionally set one of the wallets as your default so you don't have to use the
--fromflag explicitly in some of the commands:
Go to the Calibration faucet and get some funds sent to each of your addresses
Step 4: Create a child subnet
The next step is to create a subnet under
/r314159calibration. Remember to set a default wallet or explicitly specify the wallet from which you want to perform the action with the--fromflag.
This will output your subnet ID, similar to the following:
Make a note of the address of the subnet you created because you will use it below.
Step 5: Join the subnet
Before we deploy the infrastructure for the subnet, we will have to bootstrap the subnet and join from our validators, putting some initial collateral into the subnet and giving our validator address some initial balance in the subnet. For this, we need to send a join command from each of our validators from their validator owner addresses.
Step 6: Deploy the infrastructure
First, we need to export the validator private keys for all wallets into separate files which we will use to set up a validator node.
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.
Replace <YOUR_GATEWAY_DIAMOND_ADDRESS> and <YOUR_SUBNET_REGISTRY_DIAMOND_ADDRESS> with the addresses you got from the make deploy-stack command in Step 2.
Once the first validator is up and running, it will print out the relative information for this validator.
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
RESOLVER_BOOTSTRAPS: /dns/validator-1-fendermint/tcp/26655/p2p/<Peer ID in IPLD Resolver Multiaddress>
Now, run the 2nd validator in a separate terminal.
Now, the 3rd:
And finally, the 4th:
Step 7: Interact with your subnet using the IPC CLI
Make sure
~/.ipc/config.tomlcontains the configuration of your subnet in the "Subnet template" section. Uncomment the section and populate the corresponding fields
Fetch the balances of your wallets using the following command. The result should show the initial balance that you have included for your validator address in genesis:
Step 8: Run a relayer
IPC relies on the role of a specific type of peer on the network called the relayers that are responsible for submitting bottom-up checkpoints that have been finalized in a child subnet to its parent.
This process is key for the commitment of child subnet checkpoints in the parent, and the execution of bottom-up cross-net messages. Without relayers, cross-net messages will only flow from top levels of the hierarchy to the bottom, but not the other way around.
Run the relayer process passing the 0x address of the submitter account:
Last updated