These instructions will create a new IPC subnet, with a single validator node and connect it to the Filecoin Calibration testnet. In production use you would configure this with multiple validators, but for the purposes of testing and development, we just create a single validator here.
On Linux (links and instructions for Ubuntu):
- 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 Foundry. See instructions.
On MacOS:
- Install Xcode from App Store or terminal: xcode-select --install
- Install Homebrew: https://brew.sh/
- Install dependencies: brew install jq
- Install Rust: https://www.rust-lang.org/tools/install (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-make
- Install docker: https://docs.docker.com/desktop/install/mac-install/
- Install foundry: https://book.getfoundry.sh/getting-started/installation
# make sure that rust has the wasm32 target
rustup target add wasm32-unknown-unknown
# Linux only: 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/contracts
make gen
cd ..
cargo build --release
# building will generate the following binaries
./target/release/ipc-cli --version
./target/release/fendermint --version
**NOTE: All places below where you are expected to provide values, instead of copy-pasting the command as is are marked with <PLEASE PUT ...>**
**NOTE: These steps have been tested with [this IPC commit](https://github.com/consensus-shipyard/ipc-monorepo/commits/7fbfe9ad4cec47bc6d027cebd626eb3a200f128b)**
## CLI
The following is a way to run the `ipc-cli`:
cargo run -p ipc-cli --release -- --help
Maybe use it with an alias:
```shell
alias ipc-cli="cargo run -q -p ipc-cli --release --"
Initialize the config file:
❯ cargo run -q -p ipc-cli --release -- config init
[2024-01-25T16:54:13Z INFO ipc_cli::commands::config::init] Empty config populated successful in /home/aakoshh/.ipc/config.toml
❯ cat ~/.ipc/config.toml
keystore_path = "~/.ipc"
# Filecoin Calibration
[[subnets]]
id = "/r314159"
[subnets.config]
network_type = "fevm"
provider_http = "https://api.calibration.node.glif.io/rpc/v1"
gateway_addr = "0x5cF14D2Af9BBd5456Ea532639f1DB355B9BaCBf8"
registry_addr = "0x7308C4A503a12521215718cbCa98F951E9aAB9B5"
# Subnet template - uncomment and adjust before using
# [[subnets]]
# id = "/r314159/<SUBNET_ID>"
# [subnets.config]
# network_type = "fevm"
# provider_http = "https://<RPC_ADDR>/"
# gateway_addr = "0x77aa40b105843728088c0132e43fc44348881da8"
# registry_addr = "0x74539671a1d2f1c8f200826baba665179f53a1b7"
The Gateway and Registry addresses under Filecoin Calibration section are that of already deployed contracts.
Now let's create a wallets:
❯ ipc-cli wallet new --wallet-type evm
[2024-01-26T10:25:38Z INFO ipc_wallet::evm::persistent] key store does not exist, initialized to empty key store
"0x06a47133d41d0eb523b5b483e5492ea94f87aed3"
That will be our validators' public key. Now we have to go to https://faucet.calibration.fildev.network/ and ask for funds for each one. The web form will show what looks like the CID of a transaction.
Let's use one of the accounts created above to create a subnet:
❯ ipc-cli subnet create --parent /r314159 --min-validator-stake 1 --min-validators 1 --bottomup-check-period 30 --from <PLEASE PUT ACCOUNT ADDRESS> --permission-mode collateral --supply-source-kind native
[2024-01-26T10:32:50Z INFO ipc_provider::manager::evm::manager] creating subnet on evm with params: ConstructorParams { min_activation_collateral: 1000000000000000000, min_cross_msg_fee: 1000000000000, min_validators: 1, bottom_up_check_period: 30, ipc_gateway_addr: 0x5cF14D2Af9BBd5456Ea532639f1DB355B9BaCBf8, active_validators_limit: 100, majority_percentage: 60, consensus: 0, power_scale: 3, permission_mode: 0, supply_source: SupplySource { kind: 0, token_address: 0x0000000000000000000000000000000000000000 }, parent_id: SubnetID { root: 314159, route: [] } }
[2024-01-26T10:33:31Z INFO ipc_cli::commands::subnet::create] created subnet actor with id: /r314159/t410fzi3d5onhzdpsmtcoimiauxr3z3t5txs2vquep7a
Great, it created /r314159/t410fzi3d5onhzdpsmtcoimiauxr3z3t5txs2vquep7a
Note down the public key of validators who will join the subnet:
❯ ipc-cli wallet pub-key --wallet-type evm --address <PLEASE PUT WALLET ADDRESS>
0413d4e26b3de6c083a9ba1b575fd6afa3c8685a9310083a2878038820aadfb49bddd4e4cec6554380a1a1b124fae6a757cb30a8af09fbf025d03614a0b860a4fb
Then join them.
First validator:
❯ ipc-cli subnet join --from=<PLEASE PUT WALLET ADDRESS> --subnet=<PLEASE PUT SUBNET ID> --collateral=10 --public-key=<PLEASE PUT PUBLIC KEY RELATED TO ADDRESS 1> --initial-balance 1
[2024-01-26T10:39:57Z INFO ipc_cli::commands::subnet::join] pre-funding address with 1
[2024-01-26T10:39:57Z INFO ipc_provider::manager::evm::manager] interacting with evm subnet contract: 0xca36…de5a with balance: 1000000000000000000
[2024-01-26T10:40:00Z INFO ipc_provider::manager::evm::manager] interacting with evm subnet contract: 0xca36…de5a with collateral: 10000000000000000000
joined at epoch: 1297975
First we need to export the validator private key the wallet into a file.
❯ ipc-cli wallet export --wallet-type evm --address <PLEASE PUT ADDRESS 1> --hex > ~/.ipc/validator_1.sk
exported new wallet with address "0x06a47133d41d0eb523b5b483e5492ea94f87aed3" in file "/home/aakoshh/.ipc/validator_1.sk"
Let's start our validator.
I need to disable pulling the published fendermint
image so we can work with the latest, built locally with make docker-build
.
cargo make --makefile infra/fendermint/Makefile.toml \
-e NODE_NAME=validator-1 \
-e PRIVATE_KEY_PATH=<PLEASE PUT FULL PATH TO validator_1.sk> \
-e SUBNET_ID=<PLEASE PUT SUBNET ID> \
-e CMT_P2P_HOST_PORT=26656 \
-e CMT_RPC_HOST_PORT=26657 \
-e ETHAPI_HOST_PORT=8545 \
-e RESOLVER_HOST_PORT=26655 \
-e PARENT_REGISTRY=0x7308C4A503a12521215718cbCa98F951E9aAB9B5 \
-e PARENT_GATEWAY=0x5cF14D2Af9BBd5456Ea532639f1DB355B9BaCBf8 \
-e FM_PULL_SKIP=1 \
child-validator
Note:
- Use full path to PRIVATE_KEY_PATH, don't path with "~"
- Do not change values of any port unless you have to
The output looks like this:
❯ cargo make --makefile infra/fendermint/Makefile.toml \
-e NODE_NAME=validator-1 \
-e PRIVATE_KEY_PATH=/home/aakoshh/.ipc/validator_1.sk \
-e SUBNET_ID=/r314159/t410fzi3d5onhzdpsmtcoimiauxr3z3t5txs2vquep7a \
-e CMT_P2P_HOST_PORT=26656 \
-e CMT_RPC_HOST_PORT=26657 \
-e ETHAPI_HOST_PORT=8545 \
-e RESOLVER_HOST_PORT=26655 \
-e PARENT_REGISTRY=0x7308C4A503a12521215718cbCa98F951E9aAB9B5 \
-e PARENT_GATEWAY=0x5cF14D2Af9BBd5456Ea532639f1DB355B9BaCBf8 \
child-validator
[cargo-make] INFO - cargo make 0.37.8
[cargo-make] INFO - Calling cargo metadata to extract project info
[cargo-make] INFO - Cargo metadata done
[cargo-make] INFO - Build File: infra/fendermint/Makefile.toml
[cargo-make] INFO - Task: child-validator
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: legacy-migration
[cargo-make] INFO - Execute Command: "docker" "stop" "validator-1-cometbft"
Error response from daemon: No such container: validator-1-cometbft
[cargo-make] INFO - Execute Command: "docker" "rm" "--force" "validator-1-cometbft"
Error response from daemon: No such container: validator-1-cometbft
[cargo-make] INFO - Execute Command: "docker" "stop" "validator-1-fendermint"
Error response from daemon: No such container: validator-1-fendermint
[cargo-make] INFO - Execute Command: "docker" "rm" "--force" "validator-1-fendermint"
Error response from daemon: No such container: validator-1-fendermint
[cargo-make] INFO - Execute Command: "docker" "stop" "validator-1-ethapi"
Error response from daemon: No such container: validator-1-ethapi
[cargo-make] INFO - Execute Command: "docker" "rm" "--force" "validator-1-ethapi"
Error response from daemon: No such container: validator-1-ethapi
[cargo-make] INFO - Execute Command: "docker" "network" "rm" "r314159-t410fzi3d5onhzdpsmtcoimiauxr3z3t5txs2vquep7a"
Error response from daemon: network r314159-t410fzi3d5onhzdpsmtcoimiauxr3z3t5txs2vquep7a not found
[cargo-make] INFO - Skipping Task: fendermint-pull Skipped pulling fendermint Docker image.
[cargo-make] INFO - Running Task: node-clear
clearing all IPC data
[cargo-make] INFO - Running Task: node-mkdir
creating directories: /home/aakoshh/.ipc/r314159-t410fzi3d5onhzdpsmtcoimiauxr3z3t5txs2vquep7a/validator-1 /home/aakoshh/.ipc/r314159-t410fzi3d5onhzdpsmtcoimiauxr3z3t5txs2vquep7a/validator-1/validator-1/fendermint /home/aakoshh/.ipc/r314159-t410fzi3d5onhzdpsmtcoimiauxr3z3t5txs2vquep7a/validator-1/validator-1/cometbft
[cargo-make] INFO - Execute Command: "docker" "network" "create" "r314159-t410fzi3d5onhzdpsmtcoimiauxr3z3t5txs2vquep7a"
713c1543276c4696f169235e551bc35b3694677347b4010b3fc6fa03b6247eff
[cargo-make] INFO - Execute Command: "docker" "pull" "cometbft/cometbft:v0.37.x"
v0.37.x: Pulling from cometbft/cometbft
Digest: sha256:e6220583125171b617e79e112c8fbff5c9c56d569bf53c5faea3b124cf1b432a
Status: Image is up to date for cometbft/cometbft:v0.37.x
docker.io/cometbft/cometbft:v0.37.x
[cargo-make] INFO - Execute Command: "docker" "network" "create" "r314159-t410fzi3d5onhzdpsmtcoimiauxr3z3t5txs2vquep7a"
Error response from daemon: network with name r314159-t410fzi3d5onhzdpsmtcoimiauxr3z3t5txs2vquep7a already exists
[cargo-make] INFO - Running Task: cometbft-init
Running cometbft init to create (default) configuration for docker run.
I[2024-01-26|13:37:32.190] Generated private validator module=main keyFile=/cometbft/config/priv_validator_key.json stateFile=/cometbft/data/priv_validator_state.json
I[2024-01-26|13:37:32.190] Generated node key module=main path=/cometbft/config/node_key.json
I[2024-01-26|13:37:32.190] Generated genesis file module=main path=/cometbft/config/genesis.json
I[2024-01-26|13:37:32.213] Found private validator module=main keyFile=/cometbft/config/priv_validator_key.json stateFile=/cometbft/data/priv_validator_state.json
I[2024-01-26|13:37:32.213] Found node key module=main path=/cometbft/config/node_key.json
I[2024-01-26|13:37:32.213] Found genesis file module=main path=/cometbft/config/genesis.json
[cargo-make] INFO - Running Task: set-seeds
[cargo-make] INFO - Running Task: addr-book-enable
[cargo-make] INFO - Running Task: set-external-addr
[cargo-make] INFO - Running Task: duplicate-ip-enable
[cargo-make] INFO - Running Task: fendermint-deps
fendermint:latest
ghcr.io/consensus-shipyard/fendermint:latest
ghcr.io/consensus-shipyard/fendermint:<none>
fendermint image already exists
fendermint latest 6e2f0fa57445 33 minutes ago 248MB
ghcr.io/consensus-shipyard/fendermint latest 44acf3f9daa7 20 hours ago 203MB
ghcr.io/consensus-shipyard/fendermint <none> 94c788a2e80f 2 months ago 210MB
[cargo-make] INFO - Running Task: subnet-fetch-genesis
[cargo-make] INFO - Running Task: genesis-write
[cargo-make] INFO - Running Task: fendermint-new-network-key
[cargo-make] INFO - Running Task: subnet-convert-eth-key
[cargo-make] INFO - Running Task: testnode-export-keys
[cargo-make] INFO - Running Task: fendermint-start-validator
b25863d0d9a2ae96f406025c6fbec28b9e4a3c681bc136f830e5f982f1c6cd55
[cargo-make] INFO - Execute Command: "docker" "pull" "cometbft/cometbft:v0.37.x"
v0.37.x: Pulling from cometbft/cometbft
Digest: sha256:e6220583125171b617e79e112c8fbff5c9c56d569bf53c5faea3b124cf1b432a
Status: Image is up to date for cometbft/cometbft:v0.37.x
docker.io/cometbft/cometbft:v0.37.x
[cargo-make] INFO - Running Task: cometbft-start
74966a462a538c9a7843aa626ad10d377f531599bb425397eea4eacb78758ae8
[cargo-make] INFO - Running Task: cometbft-wait
[cargo-make] INFO - Running Task: ethapi-start
55e9f15003c0796694a2e96e3c265467851d00b3d552d2a2b11a789d827f5c7d
[cargo-make] INFO - Running Task: node-report
#################################
# #
# Subnet node ready! 🚀 #
# #
#################################
Subnet ID:
/r314159/t410fzi3d5onhzdpsmtcoimiauxr3z3t5txs2vquep7a
Eth API:
http://0.0.0.0:8545
Chain ID:
489021674837045
Fendermint API:
http://localhost:26658
CometBFT API:
http://0.0.0.0:26657
CometBFT node ID:
092a95385ccc6fcebe1fad0e77ee8105ef6bf965
CometBFT P2P:
http://0.0.0.0:26656
IPLD Resolver Multiaddress:
/ip4/0.0.0.0/tcp/26655/p2p/16Uiu2HAmGa3jAm2yPrCGbi3Y95B9b1Mv6KAx7f7VjXT6Srem2bjC
[cargo-make] INFO - Build Done in 32.76 seconds.