Built-in actors are how the Filecoin network manages and updates global state. This page contains information on how smart contracts can access built-in actors.
Built-in actors are how the Filecoin network manages and updates global state. The global state of the network at a given epoch can be thought of as the set of blocks agreed upon via network consensus in that epoch. This global state is represented as a state tree, which maps an actor to an actor state. An actor state describes the current conditions for an individual actor, such as its FIL balance and its nonce. In Filecoin, actors trigger a state transition by sending a message. Each block in the chain can be thought of as a proposed global state, where the block selected by network consensus sets the new global state. Each block contains a series of messages, and a checkpoint of the current global state after the application of those messages. The Filecoin Virtual Machine (FVM) is the Filecoin network component that is in charge of execution of all actor code.
A basic example of how built-in actors are used in Filecoin is the process by which storage providers prove storage and are subsequently rewarded. The process is as follows:
- 2.The storage provider is awarded storage power based on whether the proof is valid or not.
- 4.During block validation, the
StoragePowerActor’s state, which includes information on storage power allocated to each storage provider, is read.
Each block in the Filecoin chain contains:
- Inline data such as current block height.
- A pointer (CID) to the current state tree.
- A pointer (CID) to the set of messages that, when applied to the network, generated the current state tree.
A Merkle Directed Acyclic Graph (Merkle DAG) is used to map the state tree. and the set of messages. Nodes in the state tree contain information on:
- Actors, like FIL balance, nonce and a pointer (CID) to actor state data.
- Messages in the current block
Like the state tree, a Merkle Directed Acyclic Graph (Merkle DAG) is used to map the set of messages for a given block. Nodes in the messages map contain information on:
- The actor the message was sent to
- The actor that sent the message
- Target method to call on actor being sent the message
- A cryptographic signature for verification
- The amount of FIL transferred between actors
The code that defines an actor in the Filecoin network is separated into different methods. Messages sent to an actor contain information on which method(s) to call, and the input parameters for those methods. Additionally, actor code interacts with a runtime object, which contains information on the general state of network, such as the current epoch, and cryptographic signatures and proof validations. Like smart contracts in other blockchains, actors must pay a gas fee, which is some predetermined amount of FIL to offset the cost (network resources used, etc.) of a transaction. Every actor has a Filecoin balance attributed to it, a state pointer, a code which tells the system what type of actor it is, and a nonce, which tracks the number of messages sent by this actor
The 11 different types of built-in actors are as follows:
CronActorsends messages to the
StorageMarketActorat the end of each epoch. The messages sent by
CronActorindicate to StoragePowerActor and StorageMarketActor how they should maintain internal state and process deferred events. This system actor is instantiated in the genesis block, and interacts directly with the FVM.
InitActorcan initialize new actors on the Filecoin network. This system actor is instantiated in the genesis block, and maintains a table resolving a public key and temporary actor addresses to their canonical ID addresses. The
InitActorinteracts directly with the FVM.
AccountActoris responsible for user accounts. Account actors are not created by the
InitActor, but by sending a message to a public-key style address. The account actor updates the state tree with new actor address, and interacts directly with the FVM.
RewardActormanages unminted Filecoin tokens, and distributes rewards directly to miner actors, where they are locked for vesting. The reward value used for the current epoch is updated at the end of an epoch. The
RewardActorinteracts directly with the FVM.
StorageMarketActoris responsible for processing and managing on-chain deals. This is also the entry point of all storage deals and data into the system. This actor keeps track of storage deals, and the of locked balances of both the client storing data and the storage provider. When a deal is posted on chain through the
StorageMarketActor, the actor will first check if both transacting parties have sufficient balances locked up and include the deal on chain. Additionally, the
StorageMarketActorholds Storage Deal Collateral provided by the storage provider to collateralize deals. This collateral is returned to the storage provider when all deals in the sector successfully conclude. This actor does not interact directly with the FVM.
StorageMinerActoris created by the
StoragePowerActor, and is responsible for storage mining operations and the collection of mining proofs. This actor is a key part of the Filecoin storage mining subsystem, which ensures a storage miner can effectively commit storage to the Filecoin, handles the following:
- Committing new storage
- Continuously proving storage
- Declaring storage faults
- Recovering from storage faults
This actor does not interact directly with the FVM.
MultisigActoris responsible for dealing with operations involving the Filecoin wallet, and represents a group of transaction signers, with a maximum of 256. Signers may be external users or the
MultisigActoritself. This actor does not interact directly with the FVM.
PaymentChannelActorcreates and manages payment channels, a mechanism for off-chain microtransactions for Filecoin dApps to be reconciled on-chain at a later time with less overhead than a standard on-chain transaction, and no gas costs. Payment channels are uni-directional and can be funded by adding to their balance. To create a payment channel and deposit fund, a user calls the
PaymentChannelActor. This actor does not interact directly with the FVM.
StoragePowerActoris responsible for keeping track of the storage power allocated to each storage miner, and has the ability to create a
StorageMinerActor. This actor does not interact directly with the FVM.
VerifiedRegistryActoris responsible for managing Filecoin Plus (Fil+) clients. This actor can add a verified client to the Fil+ program, remove and reclaim expired DataCap allocations and manage claims. This actor does not interact directly with the FVM.