pub struct InvokeContext<'a> {
pub transaction_context: &'a mut TransactionContext,
pub program_cache_for_tx_batch: &'a mut ProgramCacheForTxBatch,
pub environment_config: EnvironmentConfig<'a>,
pub execute_time: Option<Measure>,
pub timings: ExecuteDetailsTimings,
pub syscall_context: Vec<Option<SyscallContext>>,
/* private fields */
}Expand description
Main pipeline from runtime to program execution.
Fields§
§transaction_context: &'a mut TransactionContextInformation about the currently executing transaction.
program_cache_for_tx_batch: &'a mut ProgramCacheForTxBatchThe local program cache for the transaction batch.
environment_config: EnvironmentConfig<'a>Runtime configurations used to provision the invocation environment.
execute_time: Option<Measure>Latest measurement not yet accumulated in ExecuteDetailsTimings::execute_us
timings: ExecuteDetailsTimings§syscall_context: Vec<Option<SyscallContext>>Implementations§
Source§impl<'a> InvokeContext<'a>
impl<'a> InvokeContext<'a>
pub fn new( transaction_context: &'a mut TransactionContext, program_cache_for_tx_batch: &'a mut ProgramCacheForTxBatch, environment_config: EnvironmentConfig<'a>, log_collector: Option<Rc<RefCell<LogCollector>>>, compute_budget: ComputeBudget, ) -> Self
pub fn get_environments_for_slot( &self, effective_slot: Slot, ) -> Result<&ProgramRuntimeEnvironments, InstructionError>
Sourcepub fn push(&mut self) -> Result<(), InstructionError>
pub fn push(&mut self) -> Result<(), InstructionError>
Push a stack frame onto the invocation stack
Sourcepub fn get_stack_height(&self) -> usize
pub fn get_stack_height(&self) -> usize
Current height of the invocation stack, top level instructions are height
rialo_s_instruction::TRANSACTION_LEVEL_STACK_HEIGHT
Sourcepub fn native_invoke(
&mut self,
instruction: StableInstruction,
signers: &[Pubkey],
) -> Result<(), InstructionError>
pub fn native_invoke( &mut self, instruction: StableInstruction, signers: &[Pubkey], ) -> Result<(), InstructionError>
Entrypoint for a cross-program invocation from a builtin program
Sourcepub fn prepare_instruction(
&mut self,
instruction: &StableInstruction,
signers: &[Pubkey],
) -> Result<(Vec<InstructionAccount>, Vec<IndexOfAccount>), InstructionError>
pub fn prepare_instruction( &mut self, instruction: &StableInstruction, signers: &[Pubkey], ) -> Result<(Vec<InstructionAccount>, Vec<IndexOfAccount>), InstructionError>
Helper to prepare for process_instruction()
Sourcepub fn prepare_cpi_instruction(
&mut self,
program_id: Pubkey,
account_metas: &[AccountMeta],
signers: &[Pubkey],
) -> Result<(Vec<InstructionAccount>, Vec<IndexOfAccount>), InstructionError>
pub fn prepare_cpi_instruction( &mut self, program_id: Pubkey, account_metas: &[AccountMeta], signers: &[Pubkey], ) -> Result<(Vec<InstructionAccount>, Vec<IndexOfAccount>), InstructionError>
Helper to prepare for process_instruction()
pub fn prepare_instruction_inner( &mut self, callee_program_id: Pubkey, account_metas: &[AccountMeta], signers: &[Pubkey], ) -> Result<(Vec<InstructionAccount>, Vec<IndexOfAccount>), InstructionError>
Sourcepub fn process_instruction(
&mut self,
instruction_data: &[u8],
instruction_accounts: &[InstructionAccount],
program_indices: &[IndexOfAccount],
compute_units_consumed: &mut u64,
timings: &mut ExecuteTimings,
) -> Result<(), InstructionError>
pub fn process_instruction( &mut self, instruction_data: &[u8], instruction_accounts: &[InstructionAccount], program_indices: &[IndexOfAccount], compute_units_consumed: &mut u64, timings: &mut ExecuteTimings, ) -> Result<(), InstructionError>
Processes an instruction and returns how many compute units were used
Sourcepub fn process_precompile<'ix_data>(
&mut self,
precompile: &Precompile,
instruction_data: &[u8],
instruction_accounts: &[InstructionAccount],
program_indices: &[IndexOfAccount],
message_instruction_datas_iter: impl Iterator<Item = &'ix_data [u8]>,
) -> Result<(), InstructionError>
pub fn process_precompile<'ix_data>( &mut self, precompile: &Precompile, instruction_data: &[u8], instruction_accounts: &[InstructionAccount], program_indices: &[IndexOfAccount], message_instruction_datas_iter: impl Iterator<Item = &'ix_data [u8]>, ) -> Result<(), InstructionError>
Processes a precompile instruction
Sourcepub fn get_log_collector(&self) -> Option<Rc<RefCell<LogCollector>>>
pub fn get_log_collector(&self) -> Option<Rc<RefCell<LogCollector>>>
Get this invocation’s LogCollector
Sourcepub fn mock_set_remaining(&self, remaining: u64)
pub fn mock_set_remaining(&self, remaining: u64)
Set compute units
Only use for tests and benchmarks
Sourcepub fn get_compute_budget(&self) -> &ComputeBudget
pub fn get_compute_budget(&self) -> &ComputeBudget
Get this invocation’s compute budget
Sourcepub fn get_feature_set(&self) -> &FeatureSet
pub fn get_feature_set(&self) -> &FeatureSet
Get the current feature set.
Sourcepub fn mock_set_feature_set(&mut self, feature_set: Arc<FeatureSet>)
pub fn mock_set_feature_set(&mut self, feature_set: Arc<FeatureSet>)
Set feature set.
Only use for tests and benchmarks.
Sourcepub fn get_sysvar_cache(&self) -> &SysvarCache
pub fn get_sysvar_cache(&self) -> &SysvarCache
Get cached sysvars
Sourcepub fn get_epoch_total_stake(&self) -> u64
pub fn get_epoch_total_stake(&self) -> u64
Get cached epoch total stake.
Sourcepub fn get_epoch_vote_account_stake(&self, pubkey: &'a Pubkey) -> u64
pub fn get_epoch_vote_account_stake(&self, pubkey: &'a Pubkey) -> u64
Get cached stake for the epoch vote account.
Sourcepub fn get_current_epoch(&self) -> u64
pub fn get_current_epoch(&self) -> u64
Get the CURRENT epoch (the epoch that is actively running).
This is the epoch to use when checking stake activation/deactivation status, unbonding periods, lockup periods, etc.
§Implementation Note
The stake cache stores the NEXT epoch (the epoch being prepared for when
stake changes become effective). We subtract 1 to get the current epoch.
saturating_sub handles the edge case of epoch 0.
Sourcepub fn get_next_epoch(&self) -> u64
pub fn get_next_epoch(&self) -> u64
Get the NEXT epoch (the epoch being prepared in the stake cache).
This is the epoch that accumulated stake changes will become effective in
AFTER the next FreezeStakes call. Most instruction logic should use
get_current_epoch() instead; this method is primarily for internal use
and the FreezeStakes instruction.
Sourcepub fn mock_set_stake_cache_epoch(&mut self, epoch: u64)
pub fn mock_set_stake_cache_epoch(&mut self, epoch: u64)
Set the stake cache epoch for testing.
Only use for tests and benchmarks.
Sourcepub fn freeze_stakes_and_get_validator_stakes(&self) -> Vec<(Pubkey, u64)>
pub fn freeze_stakes_and_get_validator_stakes(&self) -> Vec<(Pubkey, u64)>
Freeze the pending stake cache data and return the validator stakes
as a sorted Vec<(Pubkey, u64)>.
This performs an O(1) clone of the stake cache data (via ImHashMap structural sharing) and pushes it to the stake history. This is typically called by the ValidatorRegistry program’s FreezeStakes instruction to capture the validator set at a specific point. It then extracts validator pubkeys and their stakes from the frozen snapshot.
pub fn get_check_aligned(&self) -> bool
pub fn set_syscall_context( &mut self, syscall_context: SyscallContext, ) -> Result<(), InstructionError>
pub fn get_syscall_context(&self) -> Result<&SyscallContext, InstructionError>
pub fn get_syscall_context_mut( &mut self, ) -> Result<&mut SyscallContext, InstructionError>
Trait Implementations§
Source§impl ContextObject for InvokeContext<'_>
impl ContextObject for InvokeContext<'_>
Auto Trait Implementations§
impl<'a> !Freeze for InvokeContext<'a>
impl<'a> !RefUnwindSafe for InvokeContext<'a>
impl<'a> !Send for InvokeContext<'a>
impl<'a> !Sync for InvokeContext<'a>
impl<'a> Unpin for InvokeContext<'a>
impl<'a> !UnwindSafe for InvokeContext<'a>
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
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>
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>
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 more