Runtime

Trait Runtime 

Source
pub trait Runtime<BS: Blockstore>: Syscalls {
Show 25 methods // Required methods fn network_version(&self) -> NetworkVersion; fn message(&self) -> &dyn MessageInfo; fn curr_epoch(&self) -> ChainEpoch; fn validate_immediate_caller_accept_any(&mut self) -> Result<(), ActorError>; fn validate_immediate_caller_is<'a, I>( &mut self, addresses: I, ) -> Result<(), ActorError> where I: IntoIterator<Item = &'a Address>; fn validate_immediate_caller_type<'a, I>( &mut self, types: I, ) -> Result<(), ActorError> where I: IntoIterator<Item = &'a Type>; fn current_balance(&self) -> TokenAmount; fn resolve_address(&self, address: &Address) -> Option<Address>; fn get_actor_code_cid(&self, addr: &Address) -> Option<Cid>; fn get_randomness_from_tickets( &self, personalization: DomainSeparationTag, rand_epoch: ChainEpoch, entropy: &[u8], ) -> Result<Randomness, ActorError>; fn get_randomness_from_beacon( &self, personalization: DomainSeparationTag, rand_epoch: ChainEpoch, entropy: &[u8], ) -> Result<Randomness, ActorError>; fn create<C: Cbor>(&mut self, obj: &C) -> Result<(), ActorError>; fn state<C: Cbor>(&self) -> Result<C, ActorError>; fn transaction<C, RT, F>(&mut self, f: F) -> Result<RT, ActorError> where C: Cbor, F: FnOnce(&mut C, &mut Self) -> Result<RT, ActorError>; fn store(&self) -> &BS; fn send( &self, to: Address, method: MethodNum, params: RawBytes, value: TokenAmount, ) -> Result<RawBytes, ActorError>; fn new_actor_address(&mut self) -> Result<Address, ActorError>; fn create_actor( &mut self, code_id: Cid, address: ActorID, ) -> Result<(), ActorError>; fn delete_actor(&mut self, beneficiary: &Address) -> Result<(), ActorError>; fn resolve_builtin_actor_type(&self, code_id: &Cid) -> Option<Type>; fn get_code_cid_for_type(&self, typ: Type) -> Cid; fn total_fil_circ_supply(&self) -> TokenAmount; fn charge_gas(&mut self, name: &'static str, compute: i64); fn base_fee(&self) -> TokenAmount; // Provided method fn deserialize_params<O: DeserializeOwned>( &self, params: &RawBytes, ) -> Result<O, ActorError> { ... }
}
Expand description

Runtime is the VM’s internal runtime object. this is everything that is accessible to actors, beyond parameters.

Required Methods§

Source

fn network_version(&self) -> NetworkVersion

The network protocol version number at the current epoch.

Source

fn message(&self) -> &dyn MessageInfo

Information related to the current message being executed.

Source

fn curr_epoch(&self) -> ChainEpoch

The current chain epoch number. The genesis block has epoch zero.

Source

fn validate_immediate_caller_accept_any(&mut self) -> Result<(), ActorError>

Validates the caller against some predicate. Exported actor methods must invoke at least one caller validation before returning.

Source

fn validate_immediate_caller_is<'a, I>( &mut self, addresses: I, ) -> Result<(), ActorError>
where I: IntoIterator<Item = &'a Address>,

Source

fn validate_immediate_caller_type<'a, I>( &mut self, types: I, ) -> Result<(), ActorError>
where I: IntoIterator<Item = &'a Type>,

Source

fn current_balance(&self) -> TokenAmount

The balance of the receiver.

Source

fn resolve_address(&self, address: &Address) -> Option<Address>

Resolves an address of any protocol to an ID address (via the Init actor’s table). This allows resolution of externally-provided SECP, BLS, or actor addresses to the canonical form. If the argument is an ID address it is returned directly.

Source

fn get_actor_code_cid(&self, addr: &Address) -> Option<Cid>

Look up the code ID at an actor address.

Source

fn get_randomness_from_tickets( &self, personalization: DomainSeparationTag, rand_epoch: ChainEpoch, entropy: &[u8], ) -> Result<Randomness, ActorError>

Randomness returns a (pseudo)random byte array drawing from the latest ticket chain from a given epoch and incorporating requisite entropy. This randomness is fork dependant but also biasable because of this.

Source

fn get_randomness_from_beacon( &self, personalization: DomainSeparationTag, rand_epoch: ChainEpoch, entropy: &[u8], ) -> Result<Randomness, ActorError>

Randomness returns a (pseudo)random byte array drawing from the latest beacon from a given epoch and incorporating requisite entropy. This randomness is not tied to any fork of the chain, and is unbiasable.

Source

fn create<C: Cbor>(&mut self, obj: &C) -> Result<(), ActorError>

Initializes the state object. This is only valid in a constructor function and when the state has not yet been initialized.

Source

fn state<C: Cbor>(&self) -> Result<C, ActorError>

Loads a readonly copy of the state of the receiver into the argument.

Any modification to the state is illegal and will result in an abort.

Source

fn transaction<C, RT, F>(&mut self, f: F) -> Result<RT, ActorError>
where C: Cbor, F: FnOnce(&mut C, &mut Self) -> Result<RT, ActorError>,

Loads a mutable version of the state into the obj argument and protects the execution from side effects (including message send).

The second argument is a function which allows the caller to mutate the state. The return value from that function will be returned from the call to Transaction().

If the state is modified after this function returns, execution will abort.

The gas cost of this method is that of a Store.Put of the mutated state object.

Source

fn store(&self) -> &BS

Returns reference to blockstore

Source

fn send( &self, to: Address, method: MethodNum, params: RawBytes, value: TokenAmount, ) -> Result<RawBytes, ActorError>

Sends a message to another actor, returning the exit code and return value envelope. If the invoked method does not return successfully, its state changes (and that of any messages it sent in turn) will be rolled back.

Source

fn new_actor_address(&mut self) -> Result<Address, ActorError>

Computes an address for a new actor. The returned address is intended to uniquely refer to the actor even in the event of a chain re-org (whereas an ID-address might refer to a different actor after messages are re-ordered). Always an ActorExec address.

Source

fn create_actor( &mut self, code_id: Cid, address: ActorID, ) -> Result<(), ActorError>

Creates an actor with code codeID and address address, with empty state. May only be called by Init actor.

Source

fn delete_actor(&mut self, beneficiary: &Address) -> Result<(), ActorError>

Deletes the executing actor from the state tree, transferring any balance to beneficiary. Aborts if the beneficiary does not exist. May only be called by the actor itself.

Source

fn resolve_builtin_actor_type(&self, code_id: &Cid) -> Option<Type>

Returns whether the specified CodeCID belongs to a built-in actor.

Source

fn get_code_cid_for_type(&self, typ: Type) -> Cid

Returns the CodeCID for a built-in actor type. The kernel will abort if the supplied type is invalid.

Source

fn total_fil_circ_supply(&self) -> TokenAmount

Returns the total token supply in circulation at the beginning of the current epoch. The circulating supply is the sum of:

  • rewards emitted by the reward actor,
  • funds vested from lock-ups in the genesis state, less the sum of:
  • funds burnt,
  • pledge collateral locked in storage miner actors (recorded in the storage power actor)
  • deal collateral locked by the storage market actor
Source

fn charge_gas(&mut self, name: &'static str, compute: i64)

ChargeGas charges specified amount of gas for execution. name provides information about gas charging point

Source

fn base_fee(&self) -> TokenAmount

Provided Methods§

Source

fn deserialize_params<O: DeserializeOwned>( &self, params: &RawBytes, ) -> Result<O, ActorError>

This function is a workaround for go-implementation’s faulty exit code handling of parameters before version 7

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§