Struct fvm::kernel::default::DefaultKernel
source · pub struct DefaultKernel<C> {
pub caller: ActorID,
pub actor_id: ActorID,
pub method: MethodNum,
pub value_received: TokenAmount,
pub read_only: bool,
pub call_manager: C,
pub blocks: BlockRegistry,
}
Expand description
The “default” Kernel
implementation.
Fields§
§caller: ActorID
§actor_id: ActorID
§method: MethodNum
§value_received: TokenAmount
§read_only: bool
§call_manager: C
The call manager for this call stack. If this kernel calls another actor, it will temporarily “give” the call manager to the other kernel before re-attaching it.
blocks: BlockRegistry
Tracks block data and organizes it through index handles so it can be referred to.
This does not yet reason about reachability.
Trait Implementations§
source§impl<C> ActorOps for DefaultKernel<C>where
C: CallManager,
impl<C> ActorOps for DefaultKernel<C>where
C: CallManager,
source§fn resolve_address(&self, address: &Address) -> Result<ActorID>
fn resolve_address(&self, address: &Address) -> Result<ActorID>
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 next_actor_address(&self) -> Result<Address>
fn next_actor_address(&self) -> Result<Address>
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,
actor_id: ActorID,
delegated_address: Option<Address>,
) -> Result<()>
fn create_actor( &mut self, code_id: Cid, actor_id: ActorID, delegated_address: Option<Address>, ) -> Result<()>
Creates an actor with given
code_cid
, actor_id
, delegated_address
(if specified),
and an empty state.fn install_actor(&mut self, code_id: Cid) -> Result<()>
source§fn get_builtin_actor_type(&self, code_cid: &Cid) -> Result<u32>
fn get_builtin_actor_type(&self, code_cid: &Cid) -> Result<u32>
Returns the actor’s “type” (if builitin) or 0 (if not).
source§fn get_code_cid_for_type(&self, typ: u32) -> Result<Cid>
fn get_code_cid_for_type(&self, typ: u32) -> Result<Cid>
Returns the CodeCID for the supplied built-in actor type.
source§fn balance_of(&self, actor_id: ActorID) -> Result<TokenAmount>
fn balance_of(&self, actor_id: ActorID) -> Result<TokenAmount>
Returns the balance associated with an actor id
source§impl<C> CryptoOps for DefaultKernel<C>where
C: CallManager,
impl<C> CryptoOps for DefaultKernel<C>where
C: CallManager,
source§fn verify_signature(
&self,
sig_type: SignatureType,
signature: &[u8],
signer: &Address,
plaintext: &[u8],
) -> Result<bool>
fn verify_signature( &self, sig_type: SignatureType, signature: &[u8], signer: &Address, plaintext: &[u8], ) -> Result<bool>
Verifies that a signature is valid for an address and plaintext.
source§fn verify_bls_aggregate(
&self,
aggregate_sig: &[u8; 96],
pub_keys: &[[u8; 48]],
plaintexts_concat: &[u8],
plaintext_lens: &[u32],
) -> Result<bool>
fn verify_bls_aggregate( &self, aggregate_sig: &[u8; 96], pub_keys: &[[u8; 48]], plaintexts_concat: &[u8], plaintext_lens: &[u32], ) -> Result<bool>
Verifies a BLS aggregate signature. In the case where there is one signer/signed plaintext,
this is equivalent to verifying a non-aggregated BLS signature. Read more
source§fn recover_secp_public_key(
&self,
hash: &[u8; 32],
signature: &[u8; 65],
) -> Result<[u8; 65]>
fn recover_secp_public_key( &self, hash: &[u8; 32], signature: &[u8; 65], ) -> Result<[u8; 65]>
Given a message hash and its signature, recovers the public key of the signer.
source§fn hash(&self, code: u64, data: &[u8]) -> Result<Multihash>
fn hash(&self, code: u64, data: &[u8]) -> Result<Multihash>
Hashes input
data_in
using with the specified hash function, writing the output to
digest_out
, returning the size of the digest written to digest_out
. If digest_out
is
to small to fit the entire digest, it will be truncated. If too large, the leftover space
will not be overwritten.source§impl<C> DebugOps for DefaultKernel<C>where
C: CallManager,
impl<C> DebugOps for DefaultKernel<C>where
C: CallManager,
source§impl<C> EventOps for DefaultKernel<C>where
C: CallManager,
impl<C> EventOps for DefaultKernel<C>where
C: CallManager,
source§fn emit_event(
&mut self,
event_headers: &[EventEntry],
event_keys: &[u8],
event_values: &[u8],
) -> Result<()>
fn emit_event( &mut self, event_headers: &[EventEntry], event_keys: &[u8], event_values: &[u8], ) -> Result<()>
Records an event emitted throughout execution.
source§impl<C> IpldBlockOps for DefaultKernel<C>where
C: CallManager,
impl<C> IpldBlockOps for DefaultKernel<C>where
C: CallManager,
source§fn block_create(&mut self, codec: u64, data: &[u8]) -> Result<BlockId>
fn block_create(&mut self, codec: u64, data: &[u8]) -> Result<BlockId>
Create a new block. Read more
source§fn block_link(
&mut self,
id: BlockId,
hash_fun: u64,
hash_len: u32,
) -> Result<Cid>
fn block_link( &mut self, id: BlockId, hash_fun: u64, hash_len: u32, ) -> Result<Cid>
Computes a CID for a block. Read more
source§impl<C> Kernel for DefaultKernel<C>where
C: CallManager,
impl<C> Kernel for DefaultKernel<C>where
C: CallManager,
§type CallManager = C
type CallManager = C
The
Kernel
’s CallManager
is§type Limiter = <<C as CallManager>::Machine as Machine>::Limiter
type Limiter = <<C as CallManager>::Machine as Machine>::Limiter
The
Kernel
’s memory allocation tracker.source§fn into_inner(self) -> (Self::CallManager, BlockRegistry)where
Self: Sized,
fn into_inner(self) -> (Self::CallManager, BlockRegistry)where
Self: Sized,
source§fn new(
mgr: C,
blocks: BlockRegistry,
caller: ActorID,
actor_id: ActorID,
method: MethodNum,
value_received: TokenAmount,
read_only: bool,
) -> Self
fn new( mgr: C, blocks: BlockRegistry, caller: ActorID, actor_id: ActorID, method: MethodNum, value_received: TokenAmount, read_only: bool, ) -> Self
source§fn machine(&self) -> &<Self::CallManager as CallManager>::Machine
fn machine(&self) -> &<Self::CallManager as CallManager>::Machine
The kernel’s underlying “machine”.
source§fn limiter_mut(&mut self) -> &mut Self::Limiter
fn limiter_mut(&mut self) -> &mut Self::Limiter
Give access to the limiter of the underlying call manager.
source§fn gas_available(&self) -> Gas
fn gas_available(&self) -> Gas
Returns the remaining gas for the transaction.
source§impl<C> MessageOps for DefaultKernel<C>where
C: CallManager,
impl<C> MessageOps for DefaultKernel<C>where
C: CallManager,
source§fn msg_context(&self) -> Result<MessageContext>
fn msg_context(&self) -> Result<MessageContext>
Message information.
source§impl<C> NetworkOps for DefaultKernel<C>where
C: CallManager,
impl<C> NetworkOps for DefaultKernel<C>where
C: CallManager,
source§fn network_context(&self) -> Result<NetworkContext>
fn network_context(&self) -> Result<NetworkContext>
Network information (epoch, version, etc.).
source§fn tipset_cid(&self, epoch: ChainEpoch) -> Result<Cid>
fn tipset_cid(&self, epoch: ChainEpoch) -> Result<Cid>
The CID of the tipset at the specified epoch.
source§impl<C> RandomnessOps for DefaultKernel<C>where
C: CallManager,
impl<C> RandomnessOps for DefaultKernel<C>where
C: CallManager,
source§fn get_randomness_from_tickets(
&self,
rand_epoch: ChainEpoch,
) -> Result<[u8; 32]>
fn get_randomness_from_tickets( &self, rand_epoch: ChainEpoch, ) -> Result<[u8; 32]>
Randomness returns a (pseudo)random byte array drawing from the latest
ticket chain from a given epoch.
This randomness is fork dependant but also biasable because of this.
source§fn get_randomness_from_beacon(&self, rand_epoch: ChainEpoch) -> Result<[u8; 32]>
fn get_randomness_from_beacon(&self, rand_epoch: ChainEpoch) -> Result<[u8; 32]>
Randomness returns a (pseudo)random byte array drawing from the latest
beacon from a given epoch.
This randomness is not tied to any fork of the chain, and is unbiasable.
source§impl<C> SelfOps for DefaultKernel<C>where
C: CallManager,
impl<C> SelfOps for DefaultKernel<C>where
C: CallManager,
source§fn current_balance(&self) -> Result<TokenAmount>
fn current_balance(&self) -> Result<TokenAmount>
The balance of the receiver.
source§impl<K> SendOps<K> for DefaultKernel<K::CallManager>where
K: Kernel,
impl<K> SendOps<K> for DefaultKernel<K::CallManager>where
K: Kernel,
source§fn send(
&mut self,
recipient: &Address,
method: MethodNum,
params_id: BlockId,
value: &TokenAmount,
gas_limit: Option<Gas>,
flags: SendFlags,
) -> Result<CallResult>
fn send( &mut self, recipient: &Address, method: MethodNum, params_id: BlockId, value: &TokenAmount, gas_limit: Option<Gas>, flags: SendFlags, ) -> Result<CallResult>
Sends a message to another actor.
The method type parameter K is the type of the kernel to instantiate for
the receiving actor. This is necessary to support wrapping a kernel, so the outer
kernel can specify its Self as the receiver’s kernel type, rather than the wrapped
kernel specifying its Self.
This method is part of the Kernel trait so it can refer to the Self::CallManager
associated type necessary to constrain K.
source§impl<K> SyscallHandler<K> for DefaultKernel<K::CallManager>where
K: Kernel + ActorOps + IpldBlockOps + SendOps + UpgradeOps + CryptoOps + DebugOps + EventOps + MessageOps + NetworkOps + RandomnessOps + SelfOps,
impl<K> SyscallHandler<K> for DefaultKernel<K::CallManager>where
K: Kernel + ActorOps + IpldBlockOps + SendOps + UpgradeOps + CryptoOps + DebugOps + EventOps + MessageOps + NetworkOps + RandomnessOps + SelfOps,
source§impl<K> UpgradeOps<K> for DefaultKernel<K::CallManager>where
K: Kernel,
impl<K> UpgradeOps<K> for DefaultKernel<K::CallManager>where
K: Kernel,
source§fn upgrade_actor(
&mut self,
new_code_cid: Cid,
params_id: BlockId,
) -> Result<CallResult>
fn upgrade_actor( &mut self, new_code_cid: Cid, params_id: BlockId, ) -> Result<CallResult>
Upgrades the running actor to the specified code CID.
Auto Trait Implementations§
impl<C> Freeze for DefaultKernel<C>where
C: Freeze,
impl<C> RefUnwindSafe for DefaultKernel<C>where
C: RefUnwindSafe,
impl<C> !Send for DefaultKernel<C>
impl<C> !Sync for DefaultKernel<C>
impl<C> Unpin for DefaultKernel<C>where
C: Unpin,
impl<C> UnwindSafe for DefaultKernel<C>where
C: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> FmtForward for T
impl<T> FmtForward for T
source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
Causes
self
to use its Binary
implementation when Debug
-formatted.source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
Causes
self
to use its Display
implementation when
Debug
-formatted.source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
Causes
self
to use its LowerExp
implementation when
Debug
-formatted.source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
Causes
self
to use its LowerHex
implementation when
Debug
-formatted.source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
Causes
self
to use its Octal
implementation when Debug
-formatted.source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
Causes
self
to use its Pointer
implementation when
Debug
-formatted.source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
Causes
self
to use its UpperExp
implementation when
Debug
-formatted.source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
Causes
self
to use its UpperHex
implementation when
Debug
-formatted.source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self
and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self
and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
Borrows
self
, then passes self.as_ref()
into the pipe function.source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
Mutably borrows
self
, then passes self.as_mut()
into the pipe
function.source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows
self
, then passes self.deref()
into the pipe function.source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> References<RawCodec> for T
impl<T> References<RawCodec> for T
source§impl<T> Tap for T
impl<T> Tap for T
source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B>
of a value. Read moresource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B>
of a value. Read moresource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R>
view of a value. Read moresource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R>
view of a value. Read moresource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target
of a value. Read moresource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target
of a value. Read moresource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap()
only in debug builds, and is erased in release builds.source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls
.tap_borrow()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
Calls
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls
.tap_ref()
only in debug builds, and is erased in release
builds.source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
Calls
.tap_ref_mut()
only in debug builds, and is erased in release
builds.source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref()
only in debug builds, and is erased in release
builds.