Rename Runtime to MessageProcessor
This commit is contained in:
parent
77bb9e7ffc
commit
a0041cec97
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
extern crate test;
|
extern crate test;
|
||||||
|
|
||||||
use solana_runtime::runtime::*;
|
use solana_runtime::message_processor::*;
|
||||||
use test::Bencher;
|
use test::Bencher;
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::append_vec::AppendVec;
|
use crate::append_vec::AppendVec;
|
||||||
use crate::bank::Result;
|
use crate::bank::Result;
|
||||||
use crate::runtime::has_duplicates;
|
use crate::message_processor::has_duplicates;
|
||||||
use bincode::serialize;
|
use bincode::serialize;
|
||||||
use hashbrown::{HashMap, HashSet};
|
use hashbrown::{HashMap, HashSet};
|
||||||
use log::*;
|
use log::*;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
use crate::accounts::{Accounts, ErrorCounters, InstructionAccounts, InstructionLoaders};
|
use crate::accounts::{Accounts, ErrorCounters, InstructionAccounts, InstructionLoaders};
|
||||||
use crate::blockhash_queue::BlockhashQueue;
|
use crate::blockhash_queue::BlockhashQueue;
|
||||||
use crate::locked_accounts_results::LockedAccountsResults;
|
use crate::locked_accounts_results::LockedAccountsResults;
|
||||||
use crate::runtime::{ProcessInstruction, Runtime};
|
use crate::message_processor::{MessageProcessor, ProcessInstruction};
|
||||||
use crate::status_cache::StatusCache;
|
use crate::status_cache::StatusCache;
|
||||||
use bincode::serialize;
|
use bincode::serialize;
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
|
@ -160,8 +160,8 @@ pub struct Bank {
|
||||||
/// stream for the slot == self.slot
|
/// stream for the slot == self.slot
|
||||||
is_delta: AtomicBool,
|
is_delta: AtomicBool,
|
||||||
|
|
||||||
/// The runtime executation environment
|
/// The Message processor
|
||||||
runtime: Runtime,
|
message_processor: MessageProcessor,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for BlockhashQueue {
|
impl Default for BlockhashQueue {
|
||||||
|
@ -346,7 +346,7 @@ impl Bank {
|
||||||
genesis_block.epoch_warmup,
|
genesis_block.epoch_warmup,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add native programs mandatory for the runtime to function
|
// Add native programs mandatory for the MessageProcessor to function
|
||||||
self.register_native_instruction_processor(
|
self.register_native_instruction_processor(
|
||||||
"solana_system_program",
|
"solana_system_program",
|
||||||
&solana_sdk::system_program::id(),
|
&solana_sdk::system_program::id(),
|
||||||
|
@ -609,15 +609,15 @@ impl Bank {
|
||||||
|
|
||||||
let load_elapsed = now.elapsed();
|
let load_elapsed = now.elapsed();
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
let executed: Vec<Result<()>> = loaded_accounts
|
let executed: Vec<Result<()>> =
|
||||||
|
loaded_accounts
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.zip(txs.iter())
|
.zip(txs.iter())
|
||||||
.map(|(accs, tx)| match accs {
|
.map(|(accs, tx)| match accs {
|
||||||
Err(e) => Err(e.clone()),
|
Err(e) => Err(e.clone()),
|
||||||
Ok((ref mut accounts, ref mut loaders)) => {
|
Ok((ref mut accounts, ref mut loaders)) => self
|
||||||
self.runtime
|
.message_processor
|
||||||
.process_message(tx.message(), loaders, accounts, tick_height)
|
.process_message(tx.message(), loaders, accounts, tick_height),
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
@ -934,7 +934,7 @@ impl Bank {
|
||||||
program_id: Pubkey,
|
program_id: Pubkey,
|
||||||
process_instruction: ProcessInstruction,
|
process_instruction: ProcessInstruction,
|
||||||
) {
|
) {
|
||||||
self.runtime
|
self.message_processor
|
||||||
.add_instruction_processor(program_id, process_instruction);
|
.add_instruction_processor(program_id, process_instruction);
|
||||||
|
|
||||||
// Register a bogus executable account, which will be loaded and ignored.
|
// Register a bogus executable account, which will be loaded and ignored.
|
||||||
|
|
|
@ -6,8 +6,8 @@ mod blockhash_queue;
|
||||||
pub mod bloom;
|
pub mod bloom;
|
||||||
pub mod loader_utils;
|
pub mod loader_utils;
|
||||||
pub mod locked_accounts_results;
|
pub mod locked_accounts_results;
|
||||||
|
pub mod message_processor;
|
||||||
mod native_loader;
|
mod native_loader;
|
||||||
pub mod runtime;
|
|
||||||
mod status_cache;
|
mod status_cache;
|
||||||
mod system_instruction_processor;
|
mod system_instruction_processor;
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ use solana_sdk::transaction::TransactionError;
|
||||||
/// Return true if the slice has any duplicate elements
|
/// Return true if the slice has any duplicate elements
|
||||||
pub fn has_duplicates<T: PartialEq>(xs: &[T]) -> bool {
|
pub fn has_duplicates<T: PartialEq>(xs: &[T]) -> bool {
|
||||||
// Note: This is an O(n^2) algorithm, but requires no heap allocations. The benchmark
|
// Note: This is an O(n^2) algorithm, but requires no heap allocations. The benchmark
|
||||||
// `bench_has_duplicates` in benches/runtime.rs shows that this implementation is
|
// `bench_has_duplicates` in benches/message_processor.rs shows that this implementation is
|
||||||
// ~50 times faster than using HashSet for very short slices.
|
// ~50 times faster than using HashSet for very short slices.
|
||||||
for i in 1..xs.len() {
|
for i in 1..xs.len() {
|
||||||
if xs[i..].contains(&xs[i - 1]) {
|
if xs[i..].contains(&xs[i - 1]) {
|
||||||
|
@ -85,11 +85,11 @@ fn verify_error(err: InstructionError) -> InstructionError {
|
||||||
pub type ProcessInstruction =
|
pub type ProcessInstruction =
|
||||||
fn(&Pubkey, &mut [KeyedAccount], &[u8], u64) -> Result<(), InstructionError>;
|
fn(&Pubkey, &mut [KeyedAccount], &[u8], u64) -> Result<(), InstructionError>;
|
||||||
|
|
||||||
pub struct Runtime {
|
pub struct MessageProcessor {
|
||||||
instruction_processors: Vec<(Pubkey, ProcessInstruction)>,
|
instruction_processors: Vec<(Pubkey, ProcessInstruction)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Runtime {
|
impl Default for MessageProcessor {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
let instruction_processors: Vec<(Pubkey, ProcessInstruction)> = vec![(
|
let instruction_processors: Vec<(Pubkey, ProcessInstruction)> = vec![(
|
||||||
system_program::id(),
|
system_program::id(),
|
||||||
|
@ -102,7 +102,7 @@ impl Default for Runtime {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Runtime {
|
impl MessageProcessor {
|
||||||
/// Add a static entrypoint to intercept intructions before the dynamic loader.
|
/// Add a static entrypoint to intercept intructions before the dynamic loader.
|
||||||
pub fn add_instruction_processor(
|
pub fn add_instruction_processor(
|
||||||
&mut self,
|
&mut self,
|
Loading…
Reference in New Issue