Trait forest_filecoin::shim::fvm_latest::call_manager::CallManager
source · pub trait CallManager: 'static {
type Machine: Machine;
Show 27 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);
// 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::Executor
creates aCallManager
for that message, giving itself to theCallManager
. - The
crate::executor::Executor
calls the specified actor/entrypoint usingCallManager::call_actor()
. - The
CallManager
then constructs aKernel
and executes the actual actor code on that kernel. - If an actor calls another actor, the
Kernel
will:- Detach the
CallManager
from 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.
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.