Refactor: Merge MessageProcessor into InvokeContext (#20165)
* Inlines MessageProcessor::execute_instruction() in MessageProcessor::process_message(). * Moves MessageProcessor::create_pre_accounts() into ThisInvokeContext::push(). * Hoists ThisInvokeContext::new() out of loop inside MessageProcessor::process_message(). * Moves MessageProcessor::verify_account_references() and MessageProcessor::verify() into InvokeContext::verify().
This commit is contained in:
committed by
GitHub
parent
9542bae56e
commit
df6905c3a6
@ -58,12 +58,19 @@ pub trait InvokeContext {
|
||||
message: &Message,
|
||||
instruction: &CompiledInstruction,
|
||||
program_indices: &[usize],
|
||||
account_indices: &[usize],
|
||||
account_indices: Option<&[usize]>,
|
||||
) -> Result<(), InstructionError>;
|
||||
/// Pop a stack frame from the invocation stack
|
||||
fn pop(&mut self);
|
||||
/// Current depth of the invocation stake
|
||||
fn invoke_depth(&self) -> usize;
|
||||
/// Verify the results of an instruction
|
||||
fn verify(
|
||||
&mut self,
|
||||
message: &Message,
|
||||
instruction: &CompiledInstruction,
|
||||
program_indices: &[usize],
|
||||
) -> Result<(), InstructionError>;
|
||||
/// Verify and update PreAccount state based on program execution
|
||||
fn verify_and_update(
|
||||
&mut self,
|
||||
@ -92,6 +99,8 @@ pub trait InvokeContext {
|
||||
fn add_executor(&self, pubkey: &Pubkey, executor: Arc<dyn Executor>);
|
||||
/// Get the completed loader work that can be re-used across executions
|
||||
fn get_executor(&self, pubkey: &Pubkey) -> Option<Arc<dyn Executor>>;
|
||||
/// Set which instruction in the message is currently being recorded
|
||||
fn set_instruction_index(&mut self, instruction_index: usize);
|
||||
/// Record invoked instruction
|
||||
fn record_instruction(&self, instruction: &Instruction);
|
||||
/// Get the bank's active feature set
|
||||
@ -492,7 +501,7 @@ impl<'a> InvokeContext for MockInvokeContext<'a> {
|
||||
_message: &Message,
|
||||
_instruction: &CompiledInstruction,
|
||||
_program_indices: &[usize],
|
||||
_account_indices: &[usize],
|
||||
_account_indices: Option<&[usize]>,
|
||||
) -> Result<(), InstructionError> {
|
||||
self.invoke_stack.push(InvokeContextStackFrame::new(
|
||||
*_key,
|
||||
@ -506,6 +515,14 @@ impl<'a> InvokeContext for MockInvokeContext<'a> {
|
||||
fn invoke_depth(&self) -> usize {
|
||||
self.invoke_stack.len()
|
||||
}
|
||||
fn verify(
|
||||
&mut self,
|
||||
_message: &Message,
|
||||
_instruction: &CompiledInstruction,
|
||||
_program_indices: &[usize],
|
||||
) -> Result<(), InstructionError> {
|
||||
Ok(())
|
||||
}
|
||||
fn verify_and_update(
|
||||
&mut self,
|
||||
_instruction: &CompiledInstruction,
|
||||
@ -553,6 +570,7 @@ impl<'a> InvokeContext for MockInvokeContext<'a> {
|
||||
fn get_executor(&self, _pubkey: &Pubkey) -> Option<Arc<dyn Executor>> {
|
||||
None
|
||||
}
|
||||
fn set_instruction_index(&mut self, _instruction_index: usize) {}
|
||||
fn record_instruction(&self, _instruction: &Instruction) {}
|
||||
fn is_feature_active(&self, feature_id: &Pubkey) -> bool {
|
||||
!self.disabled_features.contains(feature_id)
|
||||
|
Reference in New Issue
Block a user