Refactor: Move sdk::process_instruction in program-runtime-crate (#21180)

* Moves the Executor dyn Trait to instruction_processor.rs

* Moves the Logger dyn Trait as well as the ic_msg and ic_logger_msg macros to log_collector.rs,
and moves the stable_log to stable_log.rs

* Moves the ComputeMeter dyn Trait to invoke_context.rs

* Moves the InvokeContext dyn Trait and the ProcessInstructionWithContext type to invoke_context.rs

* Updates cargo files.

* Re-export InvokeContext in program-test

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
This commit is contained in:
Alexander Meißner
2021-11-17 19:35:07 +01:00
committed by GitHub
parent c3e5927d16
commit e540b1cf3c
35 changed files with 319 additions and 317 deletions

View File

@ -14,7 +14,12 @@ use crate::{
};
use log::{log_enabled, trace, Level::Trace};
use solana_measure::measure::Measure;
use solana_program_runtime::instruction_processor::InstructionProcessor;
use solana_program_runtime::{
ic_logger_msg, ic_msg,
instruction_processor::{Executor, InstructionProcessor},
invoke_context::{ComputeMeter, InvokeContext, Logger},
stable_log,
};
use solana_rbpf::{
aligned_memory::AlignedMemory,
ebpf::HOST_ALIGN,
@ -35,12 +40,10 @@ use solana_sdk::{
reject_deployment_of_unresolved_syscalls, requestable_heap_size,
stop_verify_mul64_imm_nonzero,
},
ic_logger_msg, ic_msg,
instruction::{AccountMeta, InstructionError},
keyed_account::{from_keyed_account, keyed_account_at_index, KeyedAccount},
loader_instruction::LoaderInstruction,
loader_upgradeable_instruction::UpgradeableLoaderInstruction,
process_instruction::{stable_log, ComputeMeter, Executor, InvokeContext, Logger},
program_utils::limited_deserialize,
pubkey::Pubkey,
rent::Rent,

View File

@ -316,13 +316,14 @@ pub fn deserialize_parameters_aligned(
#[cfg(test)]
mod tests {
use super::*;
use solana_program_runtime::invoke_context::{prepare_mock_invoke_context, ThisInvokeContext};
use solana_program_runtime::invoke_context::{
prepare_mock_invoke_context, InvokeContext, ThisInvokeContext,
};
use solana_sdk::{
account::{Account, AccountSharedData},
account_info::AccountInfo,
bpf_loader,
entrypoint::deserialize,
process_instruction::InvokeContext,
};
use std::{
cell::RefCell,

View File

@ -1,6 +1,11 @@
use crate::{alloc, BpfError};
use alloc::Alloc;
use solana_program_runtime::instruction_processor::InstructionProcessor;
use solana_program_runtime::{
ic_msg,
instruction_processor::InstructionProcessor,
invoke_context::{ComputeMeter, InvokeContext, Logger},
stable_log,
};
use solana_rbpf::{
aligned_memory::AlignedMemory,
ebpf,
@ -25,13 +30,11 @@ use solana_sdk::{
secp256k1_recover_syscall_enabled, sol_log_data_syscall_enabled,
},
hash::{Hasher, HASH_BYTES},
ic_msg,
instruction::{AccountMeta, Instruction, InstructionError},
keccak,
message::Message,
native_loader,
precompiles::is_precompile,
process_instruction::{stable_log, ComputeMeter, InvokeContext, Logger},
program::MAX_RETURN_DATA,
pubkey::{Pubkey, PubkeyError, MAX_SEEDS, MAX_SEED_LEN},
rent::Rent,