pub trait CallManager: 'static {
type Machine: Machine;
Show 29 methods
// Required methods
fn new(
machine: Self::Machine,
engine: Engine,
gas_limit: u64,
origin: u64,
origin_address: Address,
receiver: Option<u64>,
receiver_address: Address,
nonce: u64,
gas_premium: TokenAmount,
) -> Self;
fn call_actor<K>(
&mut self,
from: u64,
to: Address,
entrypoint: Entrypoint,
params: Option<Block>,
value: &TokenAmount,
gas_limit: Option<Gas>,
read_only: bool,
) -> Result<InvocationResult, ExecutionError>
where K: Kernel<CallManager = Self>;
fn with_transaction(
&mut self,
f: impl FnOnce(&mut Self) -> Result<InvocationResult, ExecutionError>,
) -> Result<InvocationResult, ExecutionError>;
fn finish(self) -> (Result<FinishRet, ExecutionError>, Self::Machine);
fn machine(&self) -> &Self::Machine;
fn machine_mut(&mut self) -> &mut Self::Machine;
fn engine(&self) -> &Engine;
fn gas_tracker(&self) -> &GasTracker;
fn gas_premium(&self) -> &TokenAmount;
fn origin(&self) -> u64;
fn next_actor_address(&self) -> Address;
fn create_actor(
&mut self,
code_id: Cid<64>,
actor_id: u64,
delegated_address: Option<Address>,
) -> Result<(), ExecutionError>;
fn get_call_stack(&self) -> &[(u64, &'static str)];
fn resolve_address(
&self,
address: &Address,
) -> Result<Option<u64>, ExecutionError>;
fn set_actor(
&mut self,
id: u64,
state: ActorState,
) -> Result<(), ExecutionError>;
fn get_actor(&self, id: u64) -> Result<Option<ActorState>, ExecutionError>;
fn delete_actor(&mut self, id: u64) -> Result<(), ExecutionError>;
fn transfer(
&mut self,
from: u64,
to: u64,
value: &TokenAmount,
) -> Result<(), ExecutionError>;
fn nonce(&self) -> u64;
fn invocation_count(&self) -> u64;
fn limiter_mut(&mut self) -> &mut <Self::Machine as Machine>::Limiter;
fn append_event(&mut self, evt: StampedEvent);
fn log(&mut self, msg: String);
fn trace_ipld(&mut self, op: IpldOperation, cid: Cid<64>, size: usize);
// Provided methods
fn price_list(&self) -> &PriceList { ... }
fn context(&self) -> &MachineContext { ... }
fn blockstore(&self) -> &<Self::Machine as Machine>::Blockstore { ... }
fn externs(&self) -> &<Self::Machine as Machine>::Externs { ... }
fn charge_gas(&self, charge: GasCharge) -> Result<GasTimer, ExecutionError> { ... }
}Expand description
The CallManager manages a single call stack.
When a top-level message is executed:
- The
crate::executor::Executorcreates aCallManagerfor that message, giving itself to theCallManager. - The
crate::executor::Executorcalls the specified actor/entrypoint usingCallManager::call_actor(). - The
CallManagerthen constructs aKerneland executes the actual actor code on that kernel. - If an actor calls another actor, the
Kernelwill:- Detach the
CallManagerfrom itself. - Call
CallManager::call_actor()to execute the new message. - Re-attach the
CallManager. - Return.
- Detach the
Required Associated Types§
Sourcetype Machine: Machine
type Machine: Machine
The underlying Machine on top of which this CallManager executes.
Required Methods§
Sourcefn new(
machine: Self::Machine,
engine: Engine,
gas_limit: u64,
origin: u64,
origin_address: Address,
receiver: Option<u64>,
receiver_address: Address,
nonce: u64,
gas_premium: TokenAmount,
) -> Self
fn new( machine: Self::Machine, engine: Engine, gas_limit: u64, origin: u64, origin_address: Address, receiver: Option<u64>, receiver_address: Address, nonce: u64, gas_premium: TokenAmount, ) -> Self
Construct a new call manager.
Sourcefn call_actor<K>(
&mut self,
from: u64,
to: Address,
entrypoint: Entrypoint,
params: Option<Block>,
value: &TokenAmount,
gas_limit: Option<Gas>,
read_only: bool,
) -> Result<InvocationResult, ExecutionError>where
K: Kernel<CallManager = Self>,
fn call_actor<K>(
&mut self,
from: u64,
to: Address,
entrypoint: Entrypoint,
params: Option<Block>,
value: &TokenAmount,
gas_limit: Option<Gas>,
read_only: bool,
) -> Result<InvocationResult, ExecutionError>where
K: Kernel<CallManager = Self>,
Calls an actor at the given address and entrypoint. The type parameter K specifies the the kernel on top of which the target
actor should execute.
Sourcefn with_transaction(
&mut self,
f: impl FnOnce(&mut Self) -> Result<InvocationResult, ExecutionError>,
) -> Result<InvocationResult, ExecutionError>
fn with_transaction( &mut self, f: impl FnOnce(&mut Self) -> Result<InvocationResult, ExecutionError>, ) -> Result<InvocationResult, ExecutionError>
Execute some operation (usually a call_actor) within a transaction.
Sourcefn finish(self) -> (Result<FinishRet, ExecutionError>, Self::Machine)
fn finish(self) -> (Result<FinishRet, ExecutionError>, Self::Machine)
Finishes execution, returning the gas used, machine, and exec trace if requested.
Sourcefn machine_mut(&mut self) -> &mut Self::Machine
fn machine_mut(&mut self) -> &mut Self::Machine
Returns a mutable reference to the machine.
Sourcefn gas_tracker(&self) -> &GasTracker
fn gas_tracker(&self) -> &GasTracker
Returns a reference to the gas tracker.
Returns the gas premium paid by the currently executing message.
Sourcefn next_actor_address(&self) -> Address
fn next_actor_address(&self) -> Address
Get the actor address (f2) that will should be assigned to the next actor created.
This method doesn’t have any side-effects and will continue to return the same address until
create_actor is called next.
Sourcefn create_actor(
&mut self,
code_id: Cid<64>,
actor_id: u64,
delegated_address: Option<Address>,
) -> Result<(), ExecutionError>
fn create_actor( &mut self, code_id: Cid<64>, actor_id: u64, delegated_address: Option<Address>, ) -> Result<(), ExecutionError>
Create a new actor with the given code CID, actor ID, and delegated address. This method does not register the actor with the init actor. It just creates it in the state-tree.
It handles all appropriate gas charging for creating new actors.
fn get_call_stack(&self) -> &[(u64, &'static str)]
Sourcefn resolve_address(
&self,
address: &Address,
) -> Result<Option<u64>, ExecutionError>
fn resolve_address( &self, address: &Address, ) -> Result<Option<u64>, ExecutionError>
Resolve an address into an actor ID, charging gas as appropriate.
Sourcefn set_actor(
&mut self,
id: u64,
state: ActorState,
) -> Result<(), ExecutionError>
fn set_actor( &mut self, id: u64, state: ActorState, ) -> Result<(), ExecutionError>
Sets an actor in the state-tree, charging gas as appropriate. Use create_actor if you want
to create a new actor.
Sourcefn get_actor(&self, id: u64) -> Result<Option<ActorState>, ExecutionError>
fn get_actor(&self, id: u64) -> Result<Option<ActorState>, ExecutionError>
Looks up an actor in the state-tree, charging gas as appropriate.
Sourcefn delete_actor(&mut self, id: u64) -> Result<(), ExecutionError>
fn delete_actor(&mut self, id: u64) -> Result<(), ExecutionError>
Deletes an actor from the state-tree, charging gas as appropriate.
Sourcefn transfer(
&mut self,
from: u64,
to: u64,
value: &TokenAmount,
) -> Result<(), ExecutionError>
fn transfer( &mut self, from: u64, to: u64, value: &TokenAmount, ) -> Result<(), ExecutionError>
Transfers tokens from one actor to another, charging gas as appropriate.
Sourcefn invocation_count(&self) -> u64
fn invocation_count(&self) -> u64
Gets the total invocations done on this call stack.
Sourcefn limiter_mut(&mut self) -> &mut <Self::Machine as Machine>::Limiter
fn limiter_mut(&mut self) -> &mut <Self::Machine as Machine>::Limiter
Limit memory usage throughout a message execution.
Sourcefn append_event(&mut self, evt: StampedEvent)
fn append_event(&mut self, evt: StampedEvent)
Appends an event to the event accumulator.
fn trace_ipld(&mut self, op: IpldOperation, cid: Cid<64>, size: usize)
Provided Methods§
Sourcefn price_list(&self) -> &PriceList
fn price_list(&self) -> &PriceList
Returns the current price list.
Sourcefn context(&self) -> &MachineContext
fn context(&self) -> &MachineContext
Returns the machine context.
Sourcefn blockstore(&self) -> &<Self::Machine as Machine>::Blockstore
fn blockstore(&self) -> &<Self::Machine as Machine>::Blockstore
Returns the blockstore.
Sourcefn charge_gas(&self, charge: GasCharge) -> Result<GasTimer, ExecutionError>
fn charge_gas(&self, charge: GasCharge) -> Result<GasTimer, ExecutionError>
Charge gas.
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.