Struct core_processor::Ext
source · pub struct Ext {
pub context: ProcessorContext,
/* private fields */
}
Expand description
Structure providing externalities for running host functions.
Fields§
§context: ProcessorContext
Processor context.
Implementations§
source§impl Ext
impl Ext
sourcepub fn alloc_inner<G: GrowHandler>(
&mut self,
pages_num: u32,
mem: &mut impl Memory
) -> Result<WasmPage, AllocExtError>
pub fn alloc_inner<G: GrowHandler>( &mut self, pages_num: u32, mem: &mut impl Memory ) -> Result<WasmPage, AllocExtError>
Inner alloc realization.
Trait Implementations§
source§impl BackendExternalities for Ext
impl BackendExternalities for Ext
fn into_ext_info(self, memory: &impl Memory) -> Result<ExtInfo, MemoryError>
fn gas_amount(&self) -> GasAmount
source§fn pre_process_memory_accesses(
_reads: &[MemoryInterval],
_writes: &[MemoryInterval],
_gas_left: &mut GasLeft
) -> Result<(), ProcessAccessError>
fn pre_process_memory_accesses( _reads: &[MemoryInterval], _writes: &[MemoryInterval], _gas_left: &mut GasLeft ) -> Result<(), ProcessAccessError>
Pre-process memory access if need.
source§impl CountersOwner for Ext
impl CountersOwner for Ext
source§fn charge_gas_runtime(&mut self, cost: RuntimeCosts) -> Result<(), ChargeError>
fn charge_gas_runtime(&mut self, cost: RuntimeCosts) -> Result<(), ChargeError>
Charge for runtime api call.
source§fn charge_gas_runtime_if_enough(
&mut self,
cost: RuntimeCosts
) -> Result<(), ChargeError>
fn charge_gas_runtime_if_enough( &mut self, cost: RuntimeCosts ) -> Result<(), ChargeError>
Charge for runtime api call if has enough of gas, else just returns error.
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 set_gas_left(&mut self, gas_left: GasLeft)
fn set_gas_left(&mut self, gas_left: GasLeft)
Set gas limit and gas allowance left.
source§impl Externalities for Ext
impl Externalities for Ext
§type UnrecoverableError = UnrecoverableExtError
type UnrecoverableError = UnrecoverableExtError
An error issued in infallible sys-call.
§type FallibleError = FallibleExtError
type FallibleError = FallibleExtError
An error issued in fallible sys-call.
§type AllocError = AllocExtError
type AllocError = AllocExtError
An error issued during allocation.
source§fn alloc(
&mut self,
pages_num: u32,
mem: &mut impl Memory
) -> Result<WasmPage, Self::AllocError>
fn alloc( &mut self, pages_num: u32, mem: &mut impl Memory ) -> Result<WasmPage, Self::AllocError>
Allocate number of pages. Read more
source§fn free(&mut self, page: WasmPage) -> Result<(), Self::AllocError>
fn free(&mut self, page: WasmPage) -> Result<(), Self::AllocError>
Free specific memory page. Read more
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 pay_program_rent(
&mut self,
program_id: ProgramId,
rent: u128
) -> Result<(u128, u32), Self::FallibleError>
fn pay_program_rent( &mut self, program_id: ProgramId, rent: u128 ) -> Result<(u128, u32), Self::FallibleError>
Pay rent for the specified program.
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 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 ProcessorExternalities for Ext
impl ProcessorExternalities for Ext
Empty implementation for non-substrate (and non-lazy-pages) using
source§const LAZY_PAGES_ENABLED: bool = false
const LAZY_PAGES_ENABLED: bool = false
Whether this extension works with lazy pages.
source§fn new(context: ProcessorContext) -> Self
fn new(context: ProcessorContext) -> Self
Create new
source§fn lazy_pages_init_for_program(
_mem: &mut impl Memory,
_prog_id: ProgramId,
_stack_end: Option<WasmPage>,
_globals_config: GlobalsAccessConfig,
_lazy_pages_weights: LazyPagesWeights
)
fn lazy_pages_init_for_program( _mem: &mut impl Memory, _prog_id: ProgramId, _stack_end: Option<WasmPage>, _globals_config: GlobalsAccessConfig, _lazy_pages_weights: LazyPagesWeights )
Protect and save storage keys for pages which has no data
source§fn lazy_pages_post_execution_actions(_mem: &mut impl Memory)
fn lazy_pages_post_execution_actions(_mem: &mut impl Memory)
Lazy pages contract post execution actions
source§fn lazy_pages_status() -> Status
fn lazy_pages_status() -> Status
Returns lazy pages status
Auto Trait Implementations§
impl RefUnwindSafe for Ext
impl Send for Ext
impl Sync for Ext
impl Unpin for Ext
impl UnwindSafe for Ext
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