Refactor: Cleanup InstructionProcessor (#21404)
* Moves create_message(), native_invoke() and process_cross_program_instruction() from the InstructionProcessor to the InvokeContext so that they can have a useful "self" parameter. * Moves InstructionProcessor into InvokeContext and Bank. * Moves ExecuteDetailsTimings into its own file. * Moves Executor into invoke_context.rs * Moves PreAccount into its own file. * impl AbiExample for BuiltinPrograms
This commit is contained in:
committed by
GitHub
parent
e922c2da9d
commit
b78f5b6032
2
programs/bpf/Cargo.lock
generated
2
programs/bpf/Cargo.lock
generated
@ -3260,8 +3260,6 @@ dependencies = [
|
||||
"num-traits",
|
||||
"rustc_version 0.4.0",
|
||||
"serde",
|
||||
"solana-frozen-abi 1.9.0",
|
||||
"solana-frozen-abi-macro 1.9.0",
|
||||
"solana-logger 1.9.0",
|
||||
"solana-sdk",
|
||||
"thiserror",
|
||||
|
@ -16,8 +16,7 @@ use log::{log_enabled, trace, Level::Trace};
|
||||
use solana_measure::measure::Measure;
|
||||
use solana_program_runtime::{
|
||||
ic_logger_msg, ic_msg,
|
||||
instruction_processor::{Executor, InstructionProcessor},
|
||||
invoke_context::{ComputeMeter, InvokeContext},
|
||||
invoke_context::{ComputeMeter, Executor, InvokeContext},
|
||||
log_collector::LogCollector,
|
||||
stable_log,
|
||||
};
|
||||
@ -486,7 +485,7 @@ fn process_loader_upgradeable_instruction(
|
||||
.iter()
|
||||
.map(|seeds| Pubkey::create_program_address(*seeds, caller_program_id))
|
||||
.collect::<Result<Vec<Pubkey>, solana_sdk::pubkey::PubkeyError>>()?;
|
||||
InstructionProcessor::native_invoke(invoke_context, instruction, signers.as_slice())?;
|
||||
invoke_context.native_invoke(instruction, signers.as_slice())?;
|
||||
|
||||
// Load and verify the program bits
|
||||
let executor = create_executor(
|
||||
|
@ -2,7 +2,6 @@ use crate::{alloc, BpfError};
|
||||
use alloc::Alloc;
|
||||
use solana_program_runtime::{
|
||||
ic_logger_msg, ic_msg,
|
||||
instruction_processor::InstructionProcessor,
|
||||
invoke_context::{ComputeMeter, InvokeContext},
|
||||
log_collector::LogCollector,
|
||||
stable_log,
|
||||
@ -2157,9 +2156,9 @@ fn call<'a>(
|
||||
signers_seeds_len,
|
||||
memory_mapping,
|
||||
)?;
|
||||
let (message, caller_write_privileges, program_indices) =
|
||||
InstructionProcessor::create_message(&instruction, &signers, &invoke_context)
|
||||
.map_err(SyscallError::InstructionError)?;
|
||||
let (message, caller_write_privileges, program_indices) = invoke_context
|
||||
.create_message(&instruction, &signers)
|
||||
.map_err(SyscallError::InstructionError)?;
|
||||
check_authorized_program(&instruction.program_id, &instruction.data, *invoke_context)?;
|
||||
let (account_indices, mut accounts) = syscall.translate_accounts(
|
||||
&message,
|
||||
@ -2173,14 +2172,14 @@ fn call<'a>(
|
||||
invoke_context.record_instruction(&instruction);
|
||||
|
||||
// Process instruction
|
||||
InstructionProcessor::process_cross_program_instruction(
|
||||
&message,
|
||||
&program_indices,
|
||||
&account_indices,
|
||||
&caller_write_privileges,
|
||||
*invoke_context,
|
||||
)
|
||||
.map_err(SyscallError::InstructionError)?;
|
||||
invoke_context
|
||||
.process_cross_program_instruction(
|
||||
&message,
|
||||
&program_indices,
|
||||
&account_indices,
|
||||
&caller_write_privileges,
|
||||
)
|
||||
.map_err(SyscallError::InstructionError)?;
|
||||
|
||||
// Copy results back to caller
|
||||
for (callee_account, caller_account) in accounts.iter_mut() {
|
||||
|
Reference in New Issue
Block a user