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:
committed by
GitHub
parent
c3e5927d16
commit
e540b1cf3c
8
programs/bpf/Cargo.lock
generated
8
programs/bpf/Cargo.lock
generated
@ -2795,6 +2795,7 @@ name = "solana-bpf-rust-mem"
|
||||
version = "1.9.0"
|
||||
dependencies = [
|
||||
"solana-program 1.9.0",
|
||||
"solana-program-runtime",
|
||||
"solana-program-test",
|
||||
"solana-sdk",
|
||||
]
|
||||
@ -2879,6 +2880,7 @@ name = "solana-bpf-rust-sanity"
|
||||
version = "1.9.0"
|
||||
dependencies = [
|
||||
"solana-program 1.9.0",
|
||||
"solana-program-runtime",
|
||||
"solana-program-test",
|
||||
"solana-sdk",
|
||||
]
|
||||
@ -2917,6 +2919,7 @@ name = "solana-bpf-rust-sysvar"
|
||||
version = "1.9.0"
|
||||
dependencies = [
|
||||
"solana-program 1.9.0",
|
||||
"solana-program-runtime",
|
||||
"solana-program-test",
|
||||
"solana-sdk",
|
||||
]
|
||||
@ -3036,6 +3039,7 @@ dependencies = [
|
||||
name = "solana-compute-budget-program"
|
||||
version = "1.9.0"
|
||||
dependencies = [
|
||||
"solana-program-runtime",
|
||||
"solana-sdk",
|
||||
]
|
||||
|
||||
@ -3047,6 +3051,7 @@ dependencies = [
|
||||
"chrono",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"solana-program-runtime",
|
||||
"solana-sdk",
|
||||
]
|
||||
|
||||
@ -3310,7 +3315,9 @@ dependencies = [
|
||||
name = "solana-program-runtime"
|
||||
version = "1.9.0"
|
||||
dependencies = [
|
||||
"base64 0.13.0",
|
||||
"bincode",
|
||||
"itertools 0.10.1",
|
||||
"libc",
|
||||
"libloading",
|
||||
"log",
|
||||
@ -3578,6 +3585,7 @@ dependencies = [
|
||||
"solana-frozen-abi-macro 1.9.0",
|
||||
"solana-logger 1.9.0",
|
||||
"solana-metrics",
|
||||
"solana-program-runtime",
|
||||
"solana-sdk",
|
||||
"thiserror",
|
||||
]
|
||||
|
@ -18,14 +18,13 @@ use solana_runtime::{
|
||||
genesis_utils::{create_genesis_config, GenesisConfigInfo},
|
||||
loader_utils::load_program,
|
||||
};
|
||||
use solana_program_runtime::invoke_context::with_mock_invoke_context;
|
||||
use solana_program_runtime::invoke_context::{with_mock_invoke_context, InvokeContext};
|
||||
use solana_sdk::{
|
||||
bpf_loader,
|
||||
client::SyncClient,
|
||||
entrypoint::SUCCESS,
|
||||
instruction::{AccountMeta, Instruction},
|
||||
message::Message,
|
||||
process_instruction::InvokeContext,
|
||||
pubkey::Pubkey,
|
||||
signature::{Keypair, Signer},
|
||||
};
|
||||
|
@ -16,6 +16,7 @@ no-entrypoint = []
|
||||
solana-program = { path = "../../../../sdk/program", version = "=1.9.0" }
|
||||
|
||||
[dev-dependencies]
|
||||
solana-program-runtime = { path = "../../../../program-runtime", version = "=1.9.0" }
|
||||
solana-program-test = { path = "../../../../program-test", version = "=1.9.0" }
|
||||
solana-sdk = { path = "../../../../sdk", version = "=1.9.0" }
|
||||
|
||||
|
@ -16,6 +16,7 @@ test-bpf = []
|
||||
solana-program = { path = "../../../../sdk/program", version = "=1.9.0" }
|
||||
|
||||
[dev-dependencies]
|
||||
solana-program-runtime = { path = "../../../../program-runtime", version = "=1.9.0" }
|
||||
solana-program-test = { path = "../../../../program-test", version = "=1.9.0" }
|
||||
solana-sdk = { path = "../../../../sdk", version = "=1.9.0" }
|
||||
|
||||
|
@ -13,6 +13,7 @@ edition = "2018"
|
||||
solana-program = { path = "../../../../sdk/program", version = "=1.9.0" }
|
||||
|
||||
[dev-dependencies]
|
||||
solana-program-runtime = { path = "../../../../program-runtime", version = "=1.9.0" }
|
||||
solana-program-test = { path = "../../../../program-test", version = "=1.9.0" }
|
||||
solana-sdk = { path = "../../../../sdk", version = "=1.9.0" }
|
||||
|
||||
|
@ -31,7 +31,7 @@ use solana_runtime::{
|
||||
upgrade_program,
|
||||
},
|
||||
};
|
||||
use solana_program_runtime::invoke_context::with_mock_invoke_context;
|
||||
use solana_program_runtime::invoke_context::{with_mock_invoke_context, InvokeContext};
|
||||
use solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount},
|
||||
account_utils::StateMut,
|
||||
@ -43,7 +43,6 @@ use solana_sdk::{
|
||||
instruction::{AccountMeta, CompiledInstruction, Instruction, InstructionError},
|
||||
loader_instruction,
|
||||
message::{Message, SanitizedMessage},
|
||||
process_instruction::InvokeContext,
|
||||
pubkey::Pubkey,
|
||||
signature::{keypair_from_seed, Keypair, Signer},
|
||||
system_instruction::{self, MAX_PERMITTED_DATA_LENGTH},
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -10,6 +10,7 @@ license = "Apache-2.0"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
solana-program-runtime = { path = "../../program-runtime", version = "=1.9.0" }
|
||||
solana-sdk = { path = "../../sdk", version = "=1.9.0" }
|
||||
|
||||
[lib]
|
||||
|
@ -1,4 +1,5 @@
|
||||
use solana_sdk::{instruction::InstructionError, process_instruction::InvokeContext};
|
||||
use solana_program_runtime::invoke_context::InvokeContext;
|
||||
use solana_sdk::instruction::InstructionError;
|
||||
|
||||
pub fn process_instruction(
|
||||
_first_instruction_account: usize,
|
||||
|
@ -14,11 +14,11 @@ bincode = "1.3.3"
|
||||
chrono = { version = "0.4.11", features = ["serde"] }
|
||||
serde = "1.0.130"
|
||||
serde_derive = "1.0.103"
|
||||
solana-program-runtime = { path = "../../program-runtime", version = "=1.9.0" }
|
||||
solana-sdk = { path = "../../sdk", version = "=1.9.0" }
|
||||
|
||||
[dev-dependencies]
|
||||
solana-logger = { path = "../../logger", version = "=1.9.0" }
|
||||
solana-program-runtime = { path = "../../program-runtime", version = "=1.9.0" }
|
||||
|
||||
[lib]
|
||||
crate-type = ["lib"]
|
||||
|
@ -2,12 +2,12 @@
|
||||
|
||||
use crate::ConfigKeys;
|
||||
use bincode::deserialize;
|
||||
use solana_program_runtime::{ic_msg, invoke_context::InvokeContext};
|
||||
use solana_sdk::{
|
||||
account::{ReadableAccount, WritableAccount},
|
||||
feature_set, ic_msg,
|
||||
feature_set,
|
||||
instruction::InstructionError,
|
||||
keyed_account::keyed_account_at_index,
|
||||
process_instruction::InvokeContext,
|
||||
program_utils::limited_deserialize,
|
||||
pubkey::Pubkey,
|
||||
};
|
||||
|
@ -19,8 +19,8 @@ serde_derive = "1.0.103"
|
||||
solana-frozen-abi = { path = "../../frozen-abi", version = "=1.9.0" }
|
||||
solana-frozen-abi-macro = { path = "../../frozen-abi/macro", version = "=1.9.0" }
|
||||
solana-metrics = { path = "../../metrics", version = "=1.9.0" }
|
||||
solana-sdk = { path = "../../sdk", version = "=1.9.0" }
|
||||
solana-program-runtime = { path = "../../program-runtime", version = "=1.9.0" }
|
||||
solana-sdk = { path = "../../sdk", version = "=1.9.0" }
|
||||
solana-vote-program = { path = "../vote", version = "=1.9.0" }
|
||||
solana-config-program = { path = "../config", version = "=1.9.0" }
|
||||
thiserror = "1.0"
|
||||
|
@ -1,12 +1,11 @@
|
||||
use {
|
||||
crate::{config, stake_state::StakeAccount},
|
||||
log::*,
|
||||
solana_program_runtime::invoke_context::get_sysvar,
|
||||
solana_program_runtime::invoke_context::{get_sysvar, InvokeContext},
|
||||
solana_sdk::{
|
||||
feature_set,
|
||||
instruction::InstructionError,
|
||||
keyed_account::{from_keyed_account, get_signers, keyed_account_at_index},
|
||||
process_instruction::InvokeContext,
|
||||
program_utils::limited_deserialize,
|
||||
stake::{
|
||||
instruction::StakeInstruction,
|
||||
|
@ -4,15 +4,14 @@
|
||||
//! * own mining pools
|
||||
|
||||
use {
|
||||
solana_program_runtime::{ic_msg, invoke_context::InvokeContext},
|
||||
solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount, WritableAccount},
|
||||
account_utils::{State, StateMut},
|
||||
clock::{Clock, Epoch},
|
||||
feature_set::stake_merge_with_unmatched_credits_observed,
|
||||
ic_msg,
|
||||
instruction::{checked_add, InstructionError},
|
||||
keyed_account::KeyedAccount,
|
||||
process_instruction::InvokeContext,
|
||||
pubkey::Pubkey,
|
||||
rent::{Rent, ACCOUNT_STORAGE_OVERHEAD},
|
||||
stake::{
|
||||
|
@ -20,12 +20,10 @@ solana-frozen-abi = { path = "../../frozen-abi", version = "=1.9.0" }
|
||||
solana-frozen-abi-macro = { path = "../../frozen-abi/macro", version = "=1.9.0" }
|
||||
solana-logger = { path = "../../logger", version = "=1.9.0" }
|
||||
solana-metrics = { path = "../../metrics", version = "=1.9.0" }
|
||||
solana-program-runtime = { path = "../../program-runtime", version = "=1.9.0" }
|
||||
solana-sdk = { path = "../../sdk", version = "=1.9.0" }
|
||||
thiserror = "1.0"
|
||||
|
||||
[dev-dependencies]
|
||||
solana-program-runtime = { path = "../../program-runtime", version = "=1.9.0" }
|
||||
|
||||
[build-dependencies]
|
||||
rustc_version = "0.4"
|
||||
|
||||
|
@ -9,13 +9,13 @@ use log::*;
|
||||
use num_derive::{FromPrimitive, ToPrimitive};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use solana_metrics::inc_new_counter_info;
|
||||
use solana_program_runtime::invoke_context::InvokeContext;
|
||||
use solana_sdk::{
|
||||
decode_error::DecodeError,
|
||||
feature_set,
|
||||
hash::Hash,
|
||||
instruction::{AccountMeta, Instruction, InstructionError},
|
||||
keyed_account::{from_keyed_account, get_signers, keyed_account_at_index, KeyedAccount},
|
||||
process_instruction::InvokeContext,
|
||||
program_utils::limited_deserialize,
|
||||
pubkey::Pubkey,
|
||||
system_instruction,
|
||||
|
Reference in New Issue
Block a user