Running the localnet
Leverage a Dockerized multi-node setup for development.
This page walks through how to spin up a local Recall network with Docker (localnet
) and presumes
you've done the steps described in the preceding setup page.
Overview
The localnet is a three node network that runs in Docker containers. It's a bit intensive to start up but allows you to quickly iterate and build without relying on the remote testnet. It starts up all of the services, provides you with prefunded accounts, and can be useful with any of the Recall developer tooling.
Docker
All scripts use cargo make
to start Docker containers, volumes, and a Docker network. Before
getting started, make sure that Docker is running by checking the status of the Docker daemon:
If it's not running, start it:
Make sure the Docker Desktop app is installed, and then open it.
Make sure you're currently in the ipc
repository's root directory (from the previous setup and
installation step). We'll be running the local network from the scripts
folder.
All scripts use cargo make
to start docker containers, volumes, and a docker network. You can use
docker ps
to check the status of each container. Also, you must run the scripts from the root
of the repo!
Startup & shutdown
A localnet deployments will create a subnet with anvil
as the rootnet (parent). The scripts will
handle localnet validator keys (using the standard anvil
accounts) and configs in the config
folder (defaults to ~/.ipc
). In the root of the ipc
repo, you can run the localnet with the
following Makefile
command:
If you want to, for example, skip the build and dependency installation steps, you can do so with
the following. Namely, after you build the localnet images for the first time, it's common to skip
the build and dependency steps (unless new changes are made to the ipc
codebase).
Lastly, if you're ready to stop the network, you can run the stop script:
Also optional is the recall
CLI, which (if installed) will pre-buy credits for all accounts in the
localnet subnet setup. Follow the instructions in the rust-recall
repo to install it:
here.
The following outlines general observations for how long the localnet deployment process takes and various metrics:
- Deploy + build images: ~7 minutes
- Deploy with prebuilt images: ~5 minutes (i.e.,
SKIP_BUILD=true
) - Blocks: ~1 per second
- Topdown messages: ~2 minutes (e.g., depositing funds from the rootnet)
- Bottomup messages: ~15 seconds
- Stopping the network: ~40–45 seconds
Logging
Deploying a network will log various steps and summary information to the console, including the RPC URLs and contracts. It'll also show the available accounts, private keys, and respective balances.
Once the startup process is complete, each Docker container will also log its own information to the console.
Docker containers
Use docker ps
to list the network's containers. Each validator has six containers, and there are a
few others used across the full network.
You can check a validator's logs with docker logs <container-name>
. The following containers are
created (as shown for validator 0
), and you can replace the 0
with 1
or 2
to inspect the
other validators:
validator-0-fendermint
validator-0-cometbft
validator-0-promtail
validator-0-objects
validator-0-ethapi
validator-0-iroh
prometheus
grafana
anvil
loki
Usage
You can test using the subnet with the
recall
SDK & CLI. Keys are not logged if you're
running a testnet. For localnet, keys are logged with their corresponding balances. You'll notice
the first three accounts correspond to the validators and marked as reserved. If you're trying to do
non-validator actions (e.g., create a bucket or timehub), it's best to avoid these accounts since
nonce race conditions can occur.
You can use then these keys with the recall
SDK and CLI by creating an .env
file and sourcing
it, or by setting the variables in your shell. Keep in mind a NETWORK
variable is used by
fendermint
and ipc-cli
but with a different value, so it's best to use separate terminal windows
when using the recall
CLI alongside the others.
Then, use recall
as normal, e.g., recall account info
or recall bucket create
. Similarly, the
Rust SDK lets you use the localnet
by explicitly initializing it with
recall_sdk::network::Network::Localnet.init()
, or the JS SDK lets you import the localnet
chain.