Add solana-program-runtime crate (#19438)

This commit is contained in:
Justin Starry 2021-08-26 17:30:36 -07:00 committed by GitHub
parent 02b050e0f5
commit 2d7f036afd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 1361 additions and 1213 deletions

24
Cargo.lock generated
View File

@ -4492,6 +4492,7 @@ dependencies = [
"rustversion",
"sha3",
"solana-measure",
"solana-program-runtime",
"solana-runtime",
"solana-sdk",
"solana_rbpf",
@ -4735,6 +4736,7 @@ dependencies = [
"solana-net-utils",
"solana-perf",
"solana-poh",
"solana-program-runtime",
"solana-program-test",
"solana-rayon-threadlimit",
"solana-rpc",
@ -5440,6 +5442,24 @@ dependencies = [
"thiserror",
]
[[package]]
name = "solana-program-runtime"
version = "1.8.0"
dependencies = [
"libc",
"libloading",
"log 0.4.14",
"num-derive",
"num-traits",
"rustc_version 0.4.0",
"serde",
"solana-frozen-abi 1.8.0",
"solana-frozen-abi-macro 1.8.0",
"solana-logger 1.8.0",
"solana-sdk",
"thiserror",
]
[[package]]
name = "solana-program-test"
version = "1.8.0"
@ -5458,6 +5478,7 @@ dependencies = [
"solana-banks-server",
"solana-bpf-loader-program",
"solana-logger 1.8.0",
"solana-program-runtime",
"solana-runtime",
"solana-sdk",
"solana-vote-program",
@ -5600,8 +5621,6 @@ dependencies = [
"fnv",
"itertools 0.10.1",
"lazy_static",
"libc",
"libloading",
"log 0.4.14",
"memmap2 0.3.1",
"num-derive",
@ -5622,6 +5641,7 @@ dependencies = [
"solana-measure",
"solana-metrics",
"solana-noop-program",
"solana-program-runtime",
"solana-rayon-threadlimit",
"solana-sdk",
"solana-secp256k1-program",

View File

@ -83,6 +83,7 @@ num_cpus = "1.13.0"
reqwest = { version = "0.11.4", default-features = false, features = ["blocking", "rustls-tls", "json"] }
serde_json = "1.0.66"
serial_test = "0.5.1"
solana-program-runtime = { path = "../program-runtime", version = "=1.8.0" }
solana-stake-program = { path = "../programs/stake", version = "=1.8.0" }
solana-version = { path = "../version", version = "=1.8.0" }
static_assertions = "1.1.0"

View File

@ -191,7 +191,7 @@ impl CostUpdateService {
#[cfg(test)]
mod tests {
use super::*;
use solana_runtime::message_processor::ProgramTiming;
use solana_program_runtime::ProgramTiming;
use solana_sdk::pubkey::Pubkey;
#[test]

View File

@ -0,0 +1,33 @@
[package]
name = "solana-program-runtime"
version = "1.8.0"
description = "Solana program runtime"
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
repository = "https://github.com/solana-labs/solana"
license = "Apache-2.0"
homepage = "https://solana.com/"
documentation = "https://docs.rs/solana-program-runtime"
edition = "2018"
[dependencies]
libc = "0.2.101"
libloading = "0.7.0"
log = "0.4.14"
num-derive = { version = "0.3" }
num-traits = { version = "0.2" }
serde = { version = "1.0.129", features = ["derive", "rc"] }
solana-frozen-abi = { path = "../frozen-abi", version = "=1.8.0" }
solana-frozen-abi-macro = { path = "../frozen-abi/macro", version = "=1.8.0" }
solana-logger = { path = "../logger", version = "=1.8.0" }
solana-sdk = { path = "../sdk", version = "=1.8.0" }
thiserror = "1.0"
[lib]
crate-type = ["lib"]
name = "solana_program_runtime"
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[build-dependencies]
rustc_version = "0.4"

View File

@ -3,7 +3,7 @@
extern crate test;
use log::*;
use solana_runtime::message_processor::{ExecuteDetailsTimings, PreAccount};
use solana_program_runtime::{ExecuteDetailsTimings, PreAccount};
use solana_sdk::{account::AccountSharedData, pubkey, rent::Rent};
use test::Bencher;

1
program-runtime/build.rs Symbolic link
View File

@ -0,0 +1 @@
../frozen-abi/build.rs

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(min_specialization))]
#![allow(clippy::integer_arithmetic)]
mod instruction_processor;
mod native_loader;
pub use instruction_processor::*;
pub use native_loader::*;

View File

@ -5,6 +5,7 @@ use libloading::os::unix::*;
use libloading::os::windows::*;
use log::*;
use num_derive::{FromPrimitive, ToPrimitive};
use serde::Serialize;
use solana_sdk::{
account::ReadableAccount,
decode_error::DecodeError,

View File

@ -21,6 +21,7 @@ solana-banks-client = { path = "../banks-client", version = "=1.8.0" }
solana-banks-server = { path = "../banks-server", version = "=1.8.0" }
solana-bpf-loader-program = { path = "../programs/bpf_loader", version = "=1.8.0" }
solana-logger = { path = "../logger", version = "=1.8.0" }
solana-program-runtime = { path = "../program-runtime", version = "=1.8.0" }
solana-runtime = { path = "../runtime", version = "=1.8.0" }
solana-sdk = { path = "../sdk", version = "=1.8.0" }
solana-vote-program = { path = "../programs/vote", version = "=1.8.0" }

View File

@ -9,6 +9,7 @@ use {
log::*,
solana_banks_client::start_client,
solana_banks_server::banks_server::start_local_server,
solana_program_runtime::InstructionProcessor,
solana_runtime::{
bank::{Bank, Builtin, ExecuteTimings},
bank_forks::BankForks,
@ -324,7 +325,7 @@ impl solana_sdk::program_stubs::SyscallStubs for SyscallStubs {
invoke_context.record_instruction(instruction);
solana_runtime::message_processor::MessageProcessor::process_cross_program_instruction(
InstructionProcessor::process_cross_program_instruction(
&message,
&executables,
&accounts,

View File

@ -2452,7 +2452,7 @@ dependencies = [
"regex",
"sha3",
"solana-measure",
"solana-runtime",
"solana-program-runtime",
"solana-sdk",
"solana_rbpf",
"thiserror",
@ -3099,6 +3099,24 @@ dependencies = [
"thiserror",
]
[[package]]
name = "solana-program-runtime"
version = "1.8.0"
dependencies = [
"libc",
"libloading",
"log",
"num-derive",
"num-traits",
"rustc_version 0.4.0",
"serde",
"solana-frozen-abi 1.8.0",
"solana-frozen-abi-macro 1.8.0",
"solana-logger 1.8.0",
"solana-sdk",
"thiserror",
]
[[package]]
name = "solana-program-test"
version = "1.8.0"
@ -3116,6 +3134,7 @@ dependencies = [
"solana-banks-server",
"solana-bpf-loader-program",
"solana-logger 1.8.0",
"solana-program-runtime",
"solana-runtime",
"solana-sdk",
"solana-vote-program",
@ -3167,8 +3186,6 @@ dependencies = [
"fnv",
"itertools 0.10.1",
"lazy_static",
"libc",
"libloading",
"log",
"memmap2 0.3.1",
"num-derive",
@ -3188,6 +3205,7 @@ dependencies = [
"solana-logger 1.8.0",
"solana-measure",
"solana-metrics",
"solana-program-runtime",
"solana-rayon-threadlimit",
"solana-sdk",
"solana-secp256k1-program",

View File

@ -22,7 +22,7 @@ rand_core = "0.6.3"
libsecp256k1 = "0.6.0"
sha3 = "0.9.1"
solana-measure = { path = "../../measure", version = "=1.8.0" }
solana-runtime = { path = "../../runtime", version = "=1.8.0" }
solana-program-runtime = { path = "../../program-runtime", version = "=1.8.0" }
solana-sdk = { path = "../../sdk", version = "=1.8.0" }
solana_rbpf = "=0.2.14"
thiserror = "1.0"
@ -30,6 +30,7 @@ thiserror = "1.0"
[dev-dependencies]
rand = "0.7.3"
rustversion = "1.0.5"
solana-runtime = { path = "../../runtime", version = "=1.8.0" }
[lib]
crate-type = ["lib"]

View File

@ -14,6 +14,7 @@ use crate::{
};
use log::{log_enabled, trace, Level::Trace};
use solana_measure::measure::Measure;
use solana_program_runtime::InstructionProcessor;
use solana_rbpf::{
aligned_memory::AlignedMemory,
ebpf::HOST_ALIGN,
@ -22,7 +23,6 @@ use solana_rbpf::{
verifier::{self, VerifierError},
vm::{Config, EbpfVm, Executable, InstructionMeter},
};
use solana_runtime::message_processor::MessageProcessor;
use solana_sdk::{
account::{ReadableAccount, WritableAccount},
account_utils::State,
@ -400,7 +400,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>>()?;
MessageProcessor::native_invoke(
InstructionProcessor::native_invoke(
invoke_context,
instruction,
&[0, 1, 6],

View File

@ -1,5 +1,6 @@
use crate::{alloc, BpfError};
use alloc::Alloc;
use solana_program_runtime::InstructionProcessor;
use solana_rbpf::{
aligned_memory::AlignedMemory,
ebpf,
@ -8,7 +9,6 @@ use solana_rbpf::{
question_mark,
vm::{EbpfVm, SyscallObject, SyscallRegistry},
};
use solana_runtime::message_processor::MessageProcessor;
#[allow(deprecated)]
use solana_sdk::sysvar::fees::Fees;
use solana_sdk::{
@ -2332,7 +2332,7 @@ fn call<'a>(
.iter()
.collect::<Vec<&KeyedAccount>>();
let (message, callee_program_id, callee_program_id_index) =
MessageProcessor::create_message(
InstructionProcessor::create_message(
&instruction,
&keyed_account_refs,
&signers,
@ -2399,7 +2399,7 @@ fn call<'a>(
// Process instruction
#[allow(clippy::deref_addrof)]
match MessageProcessor::process_cross_program_instruction(
match InstructionProcessor::process_cross_program_instruction(
&message,
&executables,
&accounts,

View File

@ -23,8 +23,6 @@ flate2 = "1.0.20"
fnv = "1.0.7"
itertools = "0.10.1"
lazy_static = "1.4.0"
libc = "0.2.101"
libloading = "0.7.0"
log = "0.4.14"
memmap2 = "0.3.1"
num-derive = { version = "0.3" }
@ -43,6 +41,7 @@ solana-frozen-abi-macro = { path = "../frozen-abi/macro", version = "=1.8.0" }
solana-logger = { path = "../logger", version = "=1.8.0" }
solana-measure = { path = "../measure", version = "=1.8.0" }
solana-metrics = { path = "../metrics", version = "=1.8.0" }
solana-program-runtime = { path = "../program-runtime", version = "=1.8.0" }
solana-rayon-threadlimit = { path = "../rayon-threadlimit", version = "=1.8.0" }
solana-sdk = { path = "../sdk", version = "=1.8.0" }
solana-secp256k1-program = { path = "../programs/secp256k1", version = "=1.8.0" }

View File

@ -50,7 +50,7 @@ use crate::{
inline_spl_token_v2_0,
instruction_recorder::InstructionRecorder,
log_collector::LogCollector,
message_processor::{ExecuteDetailsTimings, Executors, MessageProcessor},
message_processor::MessageProcessor,
rent_collector::RentCollector,
stake_weighted_timestamp::{
calculate_stake_weighted_timestamp, MaxAllowableDrift, MAX_ALLOWABLE_DRIFT_PERCENTAGE,
@ -68,6 +68,7 @@ use log::*;
use rayon::ThreadPool;
use solana_measure::measure::Measure;
use solana_metrics::{datapoint_debug, inc_new_counter_debug, inc_new_counter_info};
use solana_program_runtime::{ExecuteDetailsTimings, Executors};
#[allow(deprecated)]
use solana_sdk::recent_blockhashes_account;
use solana_sdk::{
@ -5766,10 +5767,10 @@ pub(crate) mod tests {
create_genesis_config_with_leader, create_genesis_config_with_vote_accounts,
GenesisConfigInfo, ValidatorVoteKeypairs,
},
native_loader::NativeLoaderError,
status_cache::MAX_CACHE_ENTRIES,
};
use crossbeam_channel::{bounded, unbounded};
use solana_program_runtime::NativeLoaderError;
#[allow(deprecated)]
use solana_sdk::sysvar::fees::Fees;
use solana_sdk::{

View File

@ -25,7 +25,6 @@ pub mod instruction_recorder;
pub mod loader_utils;
pub mod log_collector;
pub mod message_processor;
mod native_loader;
pub mod neon_evm_program;
pub mod non_circulating_supply;
mod pubkey_bins;

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,6 @@ use {
blockhash_queue::BlockhashQueue,
epoch_stakes::EpochStakes,
hardened_unpack::UnpackedAppendVecMap,
message_processor::MessageProcessor,
rent_collector::RentCollector,
serde_snapshot::future::SerializableStorage,
stakes::Stakes,
@ -21,6 +20,7 @@ use {
log::*,
rayon::prelude::*,
serde::{de::DeserializeOwned, Deserialize, Serialize},
solana_program_runtime::InstructionProcessor,
solana_sdk::{
clock::{Epoch, Slot, UnixTimestamp},
epoch_schedule::EpochSchedule,

View File

@ -78,7 +78,7 @@ pub(crate) struct DeserializableVersionedBank {
pub(crate) unused_accounts: UnusedAccounts,
pub(crate) epoch_stakes: HashMap<Epoch, EpochStakes>,
pub(crate) is_delta: bool,
pub(crate) message_processor: MessageProcessor,
pub(crate) message_processor: InstructionProcessor,
}
impl From<DeserializableVersionedBank> for BankFieldsToDeserialize {
@ -155,7 +155,7 @@ pub(crate) struct SerializableVersionedBank<'a> {
pub(crate) unused_accounts: UnusedAccounts,
pub(crate) epoch_stakes: &'a HashMap<Epoch, EpochStakes>,
pub(crate) is_delta: bool,
pub(crate) message_processor: MessageProcessor,
pub(crate) message_processor: InstructionProcessor,
}
impl<'a> From<crate::bank::BankFieldsToSerialize<'a>> for SerializableVersionedBank<'a> {

View File

@ -308,7 +308,7 @@ mod test_bank_serialize {
// This some what long test harness is required to freeze the ABI of
// Bank's serialization due to versioned nature
#[frozen_abi(digest = "7XCv7DU27QC6iNJ1WYkXY3X4bKu8j6CxAn6morP2u4hu")]
#[frozen_abi(digest = "A9KFf8kLJczP3AMbFXRrqzmruoqMjooTPzdvEwZZ4EP7")]
#[derive(Serialize, AbiExample)]
pub struct BankAbiTestWrapperFuture {
#[serde(serialize_with = "wrapper_future")]