Built-in Filecoin actors (v7)

This repo contains the code for the on-chain built-in actors that power the Filecoin network starting from network version 16.

These actors are written in Rust and are designed to operate inside the Filecoin Virtual Machine. A reference implementation of the latter exists at filecoin-project/ref-fvm.

The build process of this repo compiles every actor into Wasm bytecode and generates an aggregate bundle to be imported by all clients. The structure of this bundle is standardized. Read below for details.

This codebase is on track to be canonicalized in FIP-0031. As a result, this actor implementation will be the only one recognized by the network.

Pre-FVM actors

Actors for the following network versions are provided as well:

Importable bundle

The main output of this repo is a CARv1 archive bundling all Wasm bytecode for all actors into a single file, with the following characteristics:

The CARv1 is embedded as a byte slice at the root of the library, and exported under the BUNDLE_CAR public const, for easier consumption by Rust code.

Precompiled actor bundles may also be provided as release binaries in this repo, if requested by implementors.

Releasing

First install jq (with your favorite package manager) and cargo-edit (with cargo install cargo-edit).

To cut a new patch version, run:

bash make release

To cut a major version, append BUMP=major

bash make release BUMP=major

These commands will:

  1. Run all tests/checks.
  2. Bump the version of the actor runtime, all actors, and the actor bundle.
  3. Update runtime/actor versions in workspace crates.

When you're happy, commit the version bump changes.

Run make publish to publish all packages to crates.io. This will likely take a while as it re-builds everything from scratch for validation (multiple times).

Finally, repeat the "release" step with make release BUMP=alpha, and commit that.

Instructions for client implementations

Obtaining an actors bundle

There are two options:

  1. Building from source.
  2. Downloading the precompiled release bundle from GitHub.

Instructions to build from source (option 1):

  1. Clone the repo.
  2. Check out the relevant branch or tag (see Versioning section below).
  3. cargo build from the workspace root.
  4. Copy the CARv1 file generated the location printed in this log line: warning: bundle=/path/to/repo/target/debug/build/filecoin_canonical_actors_bundle-aef13b28a60e195b/out/bundle/bundle.car All output is printed as a warning only due to limitations in the Cargo build script mechanisms.

Both options are compatible with automation via scripts or CI pipelines.

Integrating an actors bundle

This part is implementation-specific. Options include:

  1. Embedding the bundle's CARv1 bytes into the distribution's binary.
  2. Downloading CARv1 files on start (with some form of checksumming for added security).

Loading and using the actors bundle with ref-fvm

Once the implementation has validated the authenticity of the bundle, it is expected to do the following:

  1. Import the CARv1 into the blockstore.
  2. Retain the root CID in memory, indexed by network version.
  3. Feed the root CID to ref-fvm's Machine constructor, to tell ref-fvm which CodeCID maps to which built-in actor.

Multiple network version support

Because every network version may be backed by different actor code, implementations should be ready to load multiple actor bundles and index them by network version.

When instantiating the ref-fvm Machine, both the network version and the corresponding Manifest root CID must be passed.

Versioning

A fair question is how crate versioning relates to the protocol concept of ActorVersion. We adopt a policy similar to specs-actors:

Development versions will use qualifiers such as -rc (release candidate).

As an example of application of this policy to a v10 actor version lineage:

About this codebase

Relation to specs-actors

This repo supersedes specs-actors, and fulfils two roles: - executable specification of built-in actors. - canonical, portable implementation of built-in actors.

Credits

This codebase was originally forked from the actors v6 implementation of the Forest client, and was adapted to the FVM environment.

Community

Because this codebase is a common good across all Filecoin client implementations, it serves as a convergence area for all Core Devs regardless of the implementation or project they identify with.

License

Dual-licensed: MIT, Apache Software License v2, by way of the Permissive License Stack.