This repository includes the reference implementation of all the actors (i.e. smart contracts) responsible for the operation of the IPC (Inter-Planetary Consensus) protocol. These actors are written in Solidity and target Filecoin’s FEVM.
The project accommodates the following main contracts
GatewayDiamond.sol
: Implementation of the IPC Gateway within the Diamond pattern.SubnetActorDiamond.sol
: Reference implementation of an IPC SubnetActor within the Diamond pattern.SubnetRegistry.sol
: Registry contract for seamlessly deploying subnet actors.
The original idea of IPC is presented in these paper, post and video. The protocol has evolved a lot since the original paper, so take it as a high-level description of the system.
The current specification draft is available here.
Before deploying the contract, you'll need to configure the RPC_URL
and PRIVATE_KEY
environmental variables
to point to your network provider and the private key of the address you want to use for the deployment, respectively.
Alternatively, you can rename the env.template
file included in the repo to .env
, set your variables there,
and run source .env
before running the deployment scripts.
To deploy the IPC Solidity contracts in an FEVM network, you can directly run the following:
make deploy-ipc
The scripts run by make
make use of hardhat under the hood. If no network has been configured, the script will automatically try to fetch the chainID of the target network, and perform the deployment according to the configuration in hardhat.config.ts
.
To deploy the contracts in some other network configured in the Hardhat config you can run the following:
make deploy-ipc NETWORK=<network-name>
The production branch is main
.
The main
branch is always compatible with the "stable" release of the IPC agent that's running on Spacenet.
Updates to main
always come from the dev
branch.
The primary development branch is dev
.
dev
contains the most up-to-date software but may not be compatible with the version of the contracts deployed on spacenet and the main
branch of the IPC agent. Only use dev
if doing a full local deployment, but note that the packaged deployment scripts default to checking out main
branches instead of dev
.
The purpose of the Gateway is to
- serve as a register for the subnets of a given chain, dictating the rules for adding and removing new subnets
- route cross chain messages
- store messages that are traveling from upper subnets in the hierarchy down to subnets that are on the same branch of their own chain (top-down messages)
- prepare epoch-defined checkpoints that collect messages traveling from lower levels of the hierarchy upwards (bottom-up messages)
- distribute rewards to SubnetActors of child subnets
The purpose of the SubnetActor is to
- keep track of a subnet’s parameters (name, parent, consensus, staking parameters, status, etc.)
- provide validators with the ability to join and leave the subnet
- manage validators’ stake
- manage the subnet’s status
- allows validators to submit checkpoints and to commit them to the Gateway once the majority is reached
- distribute rewards, received from the Gateway, to validators
The purpose of the SubnetRegistry is to
- deploy instances of the SubnetActor. Its role is to be the subnet actor factory in a subnet.
To build all contracts, run
forge build
The build artifacts (contracts’ ABI .json
files), can be found in the out
directory.
To run all repo tests run
forge test -vvv --ffi
And to generate coverage report run
forge coverage
To create the Rust bindings for the contract you can run:
make compile-abi && make rust-binding
Run make install-dev
to install all necessary dependencies for development.
Before committing:
make format
make lint
make test
make slither
or
make prepare
Use make storage
to check that the storage layout has not been corrupted.
Use make coverage
to get test coverage report.
Please report any bugs using the issue tracker.