pub struct Ext<LP: LazyPagesInterface> {
pub context: ProcessorContext,
pub current_counter: CounterType,
/* private fields */
}
Expand description
Structure providing externalities for running host functions.
Fields§
§context: ProcessorContext
Processor context.
current_counter: CounterType
Actual gas counter type within wasm module’s global.
Trait Implementations§
Source§impl<LP: LazyPagesInterface> BackendExternalities for Ext<LP>
impl<LP: LazyPagesInterface> BackendExternalities for Ext<LP>
fn gas_amount(&self) -> GasAmount
Source§fn pre_process_memory_accesses(
&mut self,
reads: &[MemoryInterval],
writes: &[MemoryInterval],
gas_counter: &mut u64,
) -> Result<(), ProcessAccessError>
fn pre_process_memory_accesses( &mut self, reads: &[MemoryInterval], writes: &[MemoryInterval], gas_counter: &mut u64, ) -> Result<(), ProcessAccessError>
Pre-process memory access if needed.
Source§impl<LP: LazyPagesInterface> CountersOwner for Ext<LP>
impl<LP: LazyPagesInterface> CountersOwner for Ext<LP>
Source§fn charge_gas_for_token(&mut self, token: CostToken) -> Result<(), ChargeError>
fn charge_gas_for_token(&mut self, token: CostToken) -> Result<(), ChargeError>
Charge for runtime api call.
Source§fn charge_gas_if_enough(&mut self, amount: u64) -> Result<(), ChargeError>
fn charge_gas_if_enough(&mut self, amount: u64) -> Result<(), ChargeError>
Charge gas if enough, else just returns error.
Source§fn current_counter_type(&self) -> CounterType
fn current_counter_type(&self) -> CounterType
Currently set gas counter type.
Source§fn decrease_current_counter_to(&mut self, amount: u64)
fn decrease_current_counter_to(&mut self, amount: u64)
Decreases gas left by fetched single numeric of actual counter.
Source§fn define_current_counter(&mut self) -> u64
fn define_current_counter(&mut self) -> u64
Returns minimal amount of gas counters and set the type of current counter.
Source§fn current_counter_value(&self) -> u64
fn current_counter_value(&self) -> u64
Returns value of gas counter currently set.
Source§impl<LP: LazyPagesInterface> Externalities for Ext<LP>
impl<LP: LazyPagesInterface> Externalities for Ext<LP>
Source§type UnrecoverableError = UnrecoverableExtError
type UnrecoverableError = UnrecoverableExtError
An error issued in infallible syscall.
Source§type FallibleError = FallibleExtError
type FallibleError = FallibleExtError
An error issued in fallible syscall.
Source§type AllocError = AllocExtError
type AllocError = AllocExtError
An error issued during allocation.
Source§fn alloc<Context>(
&mut self,
ctx: &mut Context,
mem: &mut impl Memory<Context>,
pages_num: u32,
) -> Result<WasmPage, Self::AllocError>
fn alloc<Context>( &mut self, ctx: &mut Context, mem: &mut impl Memory<Context>, pages_num: u32, ) -> Result<WasmPage, Self::AllocError>
Allocate number of pages. Read more
Source§fn free_range(
&mut self,
start: WasmPage,
end: WasmPage,
) -> Result<(), Self::AllocError>
fn free_range( &mut self, start: WasmPage, end: WasmPage, ) -> Result<(), Self::AllocError>
Free specific memory range.
Source§fn env_vars(&self, version: u32) -> Result<EnvVars, Self::UnrecoverableError>
fn env_vars(&self, version: u32) -> Result<EnvVars, Self::UnrecoverableError>
Get environment variables currently set in the system and in the form
corresponded to the requested version.
Source§fn block_height(&self) -> Result<u32, Self::UnrecoverableError>
fn block_height(&self) -> Result<u32, Self::UnrecoverableError>
Get the current block height.
Source§fn block_timestamp(&self) -> Result<u64, Self::UnrecoverableError>
fn block_timestamp(&self) -> Result<u64, Self::UnrecoverableError>
Get the current block timestamp.
Source§fn send_init(&mut self) -> Result<u32, Self::FallibleError>
fn send_init(&mut self) -> Result<u32, Self::FallibleError>
Initialize a new incomplete message for another program and return its handle.
Source§fn send_push(
&mut self,
handle: u32,
buffer: &[u8],
) -> Result<(), Self::FallibleError>
fn send_push( &mut self, handle: u32, buffer: &[u8], ) -> Result<(), Self::FallibleError>
Push an extra buffer into message payload by handle.
Source§fn send_push_input(
&mut self,
handle: u32,
offset: u32,
len: u32,
) -> Result<(), Self::FallibleError>
fn send_push_input( &mut self, handle: u32, offset: u32, len: u32, ) -> Result<(), Self::FallibleError>
Push the incoming message buffer into message payload by handle.
Source§fn send_commit(
&mut self,
handle: u32,
msg: HandlePacket,
delay: u32,
) -> Result<MessageId, Self::FallibleError>
fn send_commit( &mut self, handle: u32, msg: HandlePacket, delay: u32, ) -> Result<MessageId, Self::FallibleError>
Complete message and send it to another program.
Source§fn reservation_send_commit(
&mut self,
id: ReservationId,
handle: u32,
msg: HandlePacket,
delay: u32,
) -> Result<MessageId, Self::FallibleError>
fn reservation_send_commit( &mut self, id: ReservationId, handle: u32, msg: HandlePacket, delay: u32, ) -> Result<MessageId, Self::FallibleError>
Complete message and send it to another program using gas from reservation.
Source§fn reply_push(&mut self, buffer: &[u8]) -> Result<(), Self::FallibleError>
fn reply_push(&mut self, buffer: &[u8]) -> Result<(), Self::FallibleError>
Push an extra buffer into reply message.
Source§fn reply_commit(
&mut self,
msg: ReplyPacket,
) -> Result<MessageId, Self::FallibleError>
fn reply_commit( &mut self, msg: ReplyPacket, ) -> Result<MessageId, Self::FallibleError>
Complete reply message and send it to source program.
Source§fn reservation_reply_commit(
&mut self,
id: ReservationId,
msg: ReplyPacket,
) -> Result<MessageId, Self::FallibleError>
fn reservation_reply_commit( &mut self, id: ReservationId, msg: ReplyPacket, ) -> Result<MessageId, Self::FallibleError>
Complete reply message and send it to source program from reservation.
Source§fn reply_to(&self) -> Result<MessageId, Self::FallibleError>
fn reply_to(&self) -> Result<MessageId, Self::FallibleError>
Get the message id of the initial message.
Source§fn signal_from(&self) -> Result<MessageId, Self::FallibleError>
fn signal_from(&self) -> Result<MessageId, Self::FallibleError>
Get the message id which signal issues from.
Source§fn reply_push_input(
&mut self,
offset: u32,
len: u32,
) -> Result<(), Self::FallibleError>
fn reply_push_input( &mut self, offset: u32, len: u32, ) -> Result<(), Self::FallibleError>
Push the incoming message buffer into reply message.
Source§fn source(&self) -> Result<ProgramId, Self::UnrecoverableError>
fn source(&self) -> Result<ProgramId, Self::UnrecoverableError>
Get the source of the message currently being handled.
Source§fn reply_code(&self) -> Result<ReplyCode, Self::FallibleError>
fn reply_code(&self) -> Result<ReplyCode, Self::FallibleError>
Get the reply code if the message being processed.
Source§fn signal_code(&self) -> Result<SignalCode, Self::FallibleError>
fn signal_code(&self) -> Result<SignalCode, Self::FallibleError>
Get the signal code if the message being processed.
Source§fn message_id(&self) -> Result<MessageId, Self::UnrecoverableError>
fn message_id(&self) -> Result<MessageId, Self::UnrecoverableError>
Get the id of the message currently being handled.
Source§fn program_id(&self) -> Result<ProgramId, Self::UnrecoverableError>
fn program_id(&self) -> Result<ProgramId, Self::UnrecoverableError>
Get the id of program itself
Source§fn debug(&self, data: &str) -> Result<(), Self::UnrecoverableError>
fn debug(&self, data: &str) -> Result<(), Self::UnrecoverableError>
Send debug message. Read more
Source§fn lock_payload(
&mut self,
at: u32,
len: u32,
) -> Result<PayloadSliceLock, Self::FallibleError>
fn lock_payload( &mut self, at: u32, len: u32, ) -> Result<PayloadSliceLock, Self::FallibleError>
Takes ownership over payload of the executing message and
returns it in the wrapper
PayloadSliceLock
, which acts
like lock. Read moreSource§fn unlock_payload(
&mut self,
payload_holder: &mut PayloadSliceLock,
) -> UnlockPayloadBound
fn unlock_payload( &mut self, payload_holder: &mut PayloadSliceLock, ) -> UnlockPayloadBound
Reclaims ownership from the payload lock over previously taken payload from the
currently executing message.. Read more
Source§fn size(&self) -> Result<usize, Self::UnrecoverableError>
fn size(&self) -> Result<usize, Self::UnrecoverableError>
Size of currently handled message payload.
Source§fn reserve_gas(
&mut self,
amount: u64,
duration: u32,
) -> Result<ReservationId, Self::FallibleError>
fn reserve_gas( &mut self, amount: u64, duration: u32, ) -> Result<ReservationId, Self::FallibleError>
Reserve some gas for a few blocks.
Source§fn unreserve_gas(
&mut self,
id: ReservationId,
) -> Result<u64, Self::FallibleError>
fn unreserve_gas( &mut self, id: ReservationId, ) -> Result<u64, Self::FallibleError>
Unreserve gas using reservation ID.
Source§fn system_reserve_gas(&mut self, amount: u64) -> Result<(), Self::FallibleError>
fn system_reserve_gas(&mut self, amount: u64) -> Result<(), Self::FallibleError>
Do system reservation.
Source§fn gas_available(&self) -> Result<u64, Self::UnrecoverableError>
fn gas_available(&self) -> Result<u64, Self::UnrecoverableError>
Tell how much gas is left in running context.
Source§fn value_available(&self) -> Result<u128, Self::UnrecoverableError>
fn value_available(&self) -> Result<u128, Self::UnrecoverableError>
Tell how much value is left in running context.
Source§fn wait(&mut self) -> Result<(), Self::UnrecoverableError>
fn wait(&mut self) -> Result<(), Self::UnrecoverableError>
Interrupt the program and reschedule execution for maximum.
Source§fn wait_for(&mut self, duration: u32) -> Result<(), Self::UnrecoverableError>
fn wait_for(&mut self, duration: u32) -> Result<(), Self::UnrecoverableError>
Interrupt the program and reschedule execution in duration.
Source§fn wait_up_to(
&mut self,
duration: u32,
) -> Result<bool, Self::UnrecoverableError>
fn wait_up_to( &mut self, duration: u32, ) -> Result<bool, Self::UnrecoverableError>
Interrupt the program and reschedule execution for maximum,
but not more than duration.
Source§fn wake(
&mut self,
waker_id: MessageId,
delay: u32,
) -> Result<(), Self::FallibleError>
fn wake( &mut self, waker_id: MessageId, delay: u32, ) -> Result<(), Self::FallibleError>
Wake the waiting message and move it to the processing queue.
Source§fn create_program(
&mut self,
packet: InitPacket,
delay: u32,
) -> Result<(MessageId, ProgramId), Self::FallibleError>
fn create_program( &mut self, packet: InitPacket, delay: u32, ) -> Result<(MessageId, ProgramId), Self::FallibleError>
Send init message to create a new program.
Source§fn reply_deposit(
&mut self,
message_id: MessageId,
amount: u64,
) -> Result<(), Self::FallibleError>
fn reply_deposit( &mut self, message_id: MessageId, amount: u64, ) -> Result<(), Self::FallibleError>
Create deposit to handle reply on given message.
Source§fn random(&self) -> Result<(&[u8], u32), Self::UnrecoverableError>
fn random(&self) -> Result<(&[u8], u32), Self::UnrecoverableError>
Returns a random seed for the current block with message id as a subject, along with the time in the past since when it was determinable by chain observers.
Source§fn forbidden_funcs(&self) -> &BTreeSet<SyscallName>
fn forbidden_funcs(&self) -> &BTreeSet<SyscallName>
Return the set of functions that are forbidden to be called.
Source§fn msg_ctx(&self) -> &MessageContext
fn msg_ctx(&self) -> &MessageContext
Return the current message context.
Source§fn send(
&mut self,
msg: HandlePacket,
delay: u32,
) -> Result<MessageId, Self::FallibleError>
fn send( &mut self, msg: HandlePacket, delay: u32, ) -> Result<MessageId, Self::FallibleError>
Send message to another program.
Source§fn reservation_send(
&mut self,
id: ReservationId,
msg: HandlePacket,
delay: u32,
) -> Result<MessageId, Self::FallibleError>
fn reservation_send( &mut self, id: ReservationId, msg: HandlePacket, delay: u32, ) -> Result<MessageId, Self::FallibleError>
Send message to another program using gas from reservation.
Source§fn reply(&mut self, msg: ReplyPacket) -> Result<MessageId, Self::FallibleError>
fn reply(&mut self, msg: ReplyPacket) -> Result<MessageId, Self::FallibleError>
Produce reply to the current message.
Source§fn reservation_reply(
&mut self,
id: ReservationId,
msg: ReplyPacket,
) -> Result<MessageId, Self::FallibleError>
fn reservation_reply( &mut self, id: ReservationId, msg: ReplyPacket, ) -> Result<MessageId, Self::FallibleError>
Produce reply to the current message from reservation.
Source§impl<LP: LazyPagesInterface> ProcessorExternalities for Ext<LP>
Empty implementation for non-substrate (and non-lazy-pages) using
impl<LP: LazyPagesInterface> ProcessorExternalities for Ext<LP>
Empty implementation for non-substrate (and non-lazy-pages) using
Source§fn new(context: ProcessorContext) -> Self
fn new(context: ProcessorContext) -> Self
Create new
Source§fn into_ext_info<Context>(
self,
ctx: &mut Context,
memory: &impl Memory<Context>,
) -> Result<ExtInfo, MemoryError>
fn into_ext_info<Context>( self, ctx: &mut Context, memory: &impl Memory<Context>, ) -> Result<ExtInfo, MemoryError>
Convert externalities into info.
Source§fn lazy_pages_init_for_program<Context>(
ctx: &mut Context,
mem: &mut impl Memory<Context>,
prog_id: ProgramId,
memory_infix: MemoryInfix,
stack_end: Option<WasmPage>,
globals_config: GlobalsAccessConfig,
lazy_pages_costs: LazyPagesCosts,
)
fn lazy_pages_init_for_program<Context>( ctx: &mut Context, mem: &mut impl Memory<Context>, prog_id: ProgramId, memory_infix: MemoryInfix, stack_end: Option<WasmPage>, globals_config: GlobalsAccessConfig, lazy_pages_costs: LazyPagesCosts, )
Protect and save storage keys for pages which has no data
Source§fn lazy_pages_post_execution_actions<Context>(
ctx: &mut Context,
mem: &mut impl Memory<Context>,
)
fn lazy_pages_post_execution_actions<Context>( ctx: &mut Context, mem: &mut impl Memory<Context>, )
Lazy pages program post execution actions
Source§fn lazy_pages_status() -> Status
fn lazy_pages_status() -> Status
Returns lazy pages status
Auto Trait Implementations§
impl<LP> Freeze for Ext<LP>
impl<LP> RefUnwindSafe for Ext<LP>where
LP: RefUnwindSafe,
impl<LP> Send for Ext<LP>where
LP: Send,
impl<LP> Sync for Ext<LP>where
LP: Sync,
impl<LP> Unpin for Ext<LP>where
LP: Unpin,
impl<LP> UnwindSafe for Ext<LP>where
LP: UnwindSafe,
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
The counterpart to
unchecked_from
.Source§impl<T> Upcastable for T
impl<T> Upcastable for T
Source§fn upcast_any_ref(&self) -> &(dyn Any + 'static)
fn upcast_any_ref(&self) -> &(dyn Any + 'static)
upcast ref
Source§fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
upcast mut ref