78 releases (30 stable)

new 4.3.0 Jun 12, 2024
4.1.2 Jan 31, 2024
4.0.0 Oct 31, 2023
3.10.0 Jun 13, 2024
0.4.0 Mar 29, 2022

#1332 in Magic Beans

Download history 4773/week @ 2024-02-26 4412/week @ 2024-03-04 3898/week @ 2024-03-11 5297/week @ 2024-03-18 3294/week @ 2024-03-25 4565/week @ 2024-04-01 6137/week @ 2024-04-08 7623/week @ 2024-04-15 3597/week @ 2024-04-22 2617/week @ 2024-04-29 3443/week @ 2024-05-06 3077/week @ 2024-05-13 2003/week @ 2024-05-20 1722/week @ 2024-05-27 3087/week @ 2024-06-03 3228/week @ 2024-06-10

10,122 downloads per month
Used in 6 crates (4 directly)

MIT/Apache

770KB
17K SLoC

Reference Filecoin VM implementation (v4; dev)

Continuous integration

This repository contains the reference implementation of the Filecoin VM (specs). It is written in Rust, and intended to be integrated via FFI into non-Rust clients (e.g. Lotus, Fuhon), or directly into Rust clients (e.g. Forest). FFI bindings for Go are provided in-repo, and developers are encouraged to contribute bindings for other languages.

See the Project Website for details.

Build requirements

Build instructions

$ git clone https://github.com/filecoin-project/ref-fvm.git
$ cd ref-fvm
$ make

Code structure

Here's what you'll find in each directory:

  • /fvm
    • The core of the Filecoin Virtual Machine. The key concepts are:
      • Machine: an instantiation of the machine, anchored at a specific state root and epoch, ready to intake messages to be applied.
      • Executor: an object to execute messages on a Machine.
      • CallManager: tracks and manages the call stack for a given message.
      • Invocation container (conceptual layer, not explicitly appearing in code): the WASM instance + sandbox under which a given actor in the call stack runs.
      • Kernel: the environment attached to an invocation container for external interactions.
    • There are two API boundaries in the system:
      1. the boundary between the actor code and the Kernel, which is traversed by invoking Syscalls.
      2. the boundary between the FVM and the host node, represented by Externs.
    • Some parts of the FVM are based on the Forest implementation.
  • /sdk
    • Reference SDK implementation to write Filecoin native actors, used by the canonical built-in actors through the Actors FVM Runtime shim.
    • User-defined FVM actors written in Rust can also use this SDK, although it is currently quite rough around the edges. In the next weeks, we expect to sweeten it for improved developer experience.
    • Alternative SDKs will emerge in the community. We also expect community teams to develop SDKs in other WASM-compilable languages such as Swift, Kotlin (using Kotlin Native), and even Go (via the TinyGo compiler).
  • /shared
    • A crate of core types and primitives shared between the FVM and the SDK.
  • /ipld
    • IPLD libraries. Some of which are based on, and adapted from, the Forest implementation.
  • /testing/conformance
    • Contains the test vector runner, as well as benchmarking utilities on top of it.
    • The conformance test runner feeds the test vector corpus located at https://github.com/filecoin-project/fvm-test-vectors into ref-fvm, in order to validate spec conformance.
    • The benchmarking utilities use the criterion Rust library to measure the performance and overhead of ref-fvm across various facets.
    • See the instructions about how to run the tests and the benchmarks.
    • Disclaimers
      • Benchmarks are currently very slow to run, setup and teardown. This is due to using default WASM cache, and will be fixed soon.

License

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


actors and vm forked from ChainSafe/forest commit: 73e8f95a108902c6bef44ee359a8478663844e5b


lib.rs:

(Proper package docs coming shortly; for now this is a holding pen for items we must mention).

Logging

This package emits logs using the log façade. Configure the logging backend of your choice during the initialization of the consuming application.

Dependencies

~54MB
~1M SLoC