nit: Move builtins types to builtins file (#19597)
This commit is contained in:
@ -1,7 +1,4 @@
|
|||||||
use solana_runtime::{
|
use solana_runtime::builtins::{ActivationType, Builtin, Builtins};
|
||||||
bank::{Builtin, Builtins},
|
|
||||||
builtins::ActivationType,
|
|
||||||
};
|
|
||||||
use solana_sdk::pubkey::Pubkey;
|
use solana_sdk::pubkey::Pubkey;
|
||||||
|
|
||||||
macro_rules! to_builtin {
|
macro_rules! to_builtin {
|
||||||
|
@ -11,8 +11,9 @@ use {
|
|||||||
solana_banks_server::banks_server::start_local_server,
|
solana_banks_server::banks_server::start_local_server,
|
||||||
solana_program_runtime::InstructionProcessor,
|
solana_program_runtime::InstructionProcessor,
|
||||||
solana_runtime::{
|
solana_runtime::{
|
||||||
bank::{Bank, Builtin, ExecuteTimings},
|
bank::{Bank, ExecuteTimings},
|
||||||
bank_forks::BankForks,
|
bank_forks::BankForks,
|
||||||
|
builtins::Builtin,
|
||||||
commitment::BlockCommitmentCache,
|
commitment::BlockCommitmentCache,
|
||||||
genesis_utils::{create_genesis_config_with_leader_ex, GenesisConfigInfo},
|
genesis_utils::{create_genesis_config_with_leader_ex, GenesisConfigInfo},
|
||||||
},
|
},
|
||||||
|
@ -45,7 +45,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
ancestors::{Ancestors, AncestorsForSerialization},
|
ancestors::{Ancestors, AncestorsForSerialization},
|
||||||
blockhash_queue::BlockhashQueue,
|
blockhash_queue::BlockhashQueue,
|
||||||
builtins::{self, ActivationType},
|
builtins::{self, ActivationType, Builtin, Builtins},
|
||||||
epoch_stakes::{EpochStakes, NodeVoteAccounts},
|
epoch_stakes::{EpochStakes, NodeVoteAccounts},
|
||||||
inline_spl_token_v2_0,
|
inline_spl_token_v2_0,
|
||||||
instruction_recorder::InstructionRecorder,
|
instruction_recorder::InstructionRecorder,
|
||||||
@ -211,33 +211,6 @@ type RentCollectionCycleParams = (
|
|||||||
|
|
||||||
type EpochCount = u64;
|
type EpochCount = u64;
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct Builtin {
|
|
||||||
pub name: String,
|
|
||||||
pub id: Pubkey,
|
|
||||||
pub process_instruction_with_context: ProcessInstructionWithContext,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Builtin {
|
|
||||||
pub fn new(
|
|
||||||
name: &str,
|
|
||||||
id: Pubkey,
|
|
||||||
process_instruction_with_context: ProcessInstructionWithContext,
|
|
||||||
) -> Self {
|
|
||||||
Self {
|
|
||||||
name: name.to_string(),
|
|
||||||
id,
|
|
||||||
process_instruction_with_context,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Debug for Builtin {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
write!(f, "Builtin [name={}, id={}]", self.name, self.id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Copy-on-write holder of CachedExecutors
|
/// Copy-on-write holder of CachedExecutors
|
||||||
#[derive(AbiExample, Debug, Default)]
|
#[derive(AbiExample, Debug, Default)]
|
||||||
struct CowCachedExecutors {
|
struct CowCachedExecutors {
|
||||||
@ -283,26 +256,6 @@ impl CowCachedExecutors {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(RUSTC_WITH_SPECIALIZATION)]
|
|
||||||
impl AbiExample for Builtin {
|
|
||||||
fn example() -> Self {
|
|
||||||
Self {
|
|
||||||
name: String::default(),
|
|
||||||
id: Pubkey::default(),
|
|
||||||
process_instruction_with_context: |_, _, _| Ok(()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct Builtins {
|
|
||||||
/// Builtin programs that are always available
|
|
||||||
pub genesis_builtins: Vec<Builtin>,
|
|
||||||
|
|
||||||
/// Builtin programs activated dynamically by feature
|
|
||||||
pub feature_builtins: Vec<(Builtin, Pubkey, ActivationType)>,
|
|
||||||
}
|
|
||||||
|
|
||||||
const MAX_CACHED_EXECUTORS: usize = 100; // 10 MB assuming programs are around 100k
|
const MAX_CACHED_EXECUTORS: usize = 100; // 10 MB assuming programs are around 100k
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct CachedExecutorsEntry {
|
struct CachedExecutorsEntry {
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::system_instruction_processor;
|
||||||
bank::{Builtin, Builtins},
|
|
||||||
system_instruction_processor,
|
|
||||||
};
|
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
feature_set,
|
feature_set,
|
||||||
instruction::InstructionError,
|
instruction::InstructionError,
|
||||||
@ -9,6 +6,10 @@ use solana_sdk::{
|
|||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
stake, system_program,
|
stake, system_program,
|
||||||
};
|
};
|
||||||
|
use std::fmt;
|
||||||
|
|
||||||
|
#[cfg(RUSTC_WITH_SPECIALIZATION)]
|
||||||
|
use solana_frozen_abi::abi_example::AbiExample;
|
||||||
|
|
||||||
fn process_instruction_with_program_logging(
|
fn process_instruction_with_program_logging(
|
||||||
process_instruction: ProcessInstructionWithContext,
|
process_instruction: ProcessInstructionWithContext,
|
||||||
@ -41,6 +42,59 @@ macro_rules! with_program_logging {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(AbiExample, Debug, Clone)]
|
||||||
|
pub enum ActivationType {
|
||||||
|
NewProgram,
|
||||||
|
NewVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct Builtin {
|
||||||
|
pub name: String,
|
||||||
|
pub id: Pubkey,
|
||||||
|
pub process_instruction_with_context: ProcessInstructionWithContext,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Builtin {
|
||||||
|
pub fn new(
|
||||||
|
name: &str,
|
||||||
|
id: Pubkey,
|
||||||
|
process_instruction_with_context: ProcessInstructionWithContext,
|
||||||
|
) -> Self {
|
||||||
|
Self {
|
||||||
|
name: name.to_string(),
|
||||||
|
id,
|
||||||
|
process_instruction_with_context,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for Builtin {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
write!(f, "Builtin [name={}, id={}]", self.name, self.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(RUSTC_WITH_SPECIALIZATION)]
|
||||||
|
impl AbiExample for Builtin {
|
||||||
|
fn example() -> Self {
|
||||||
|
Self {
|
||||||
|
name: String::default(),
|
||||||
|
id: Pubkey::default(),
|
||||||
|
process_instruction_with_context: |_, _, _| Ok(()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct Builtins {
|
||||||
|
/// Builtin programs that are always available
|
||||||
|
pub genesis_builtins: Vec<Builtin>,
|
||||||
|
|
||||||
|
/// Builtin programs activated dynamically by feature
|
||||||
|
pub feature_builtins: Vec<(Builtin, Pubkey, ActivationType)>,
|
||||||
|
}
|
||||||
|
|
||||||
/// Builtin programs that are always available
|
/// Builtin programs that are always available
|
||||||
fn genesis_builtins() -> Vec<Builtin> {
|
fn genesis_builtins() -> Vec<Builtin> {
|
||||||
vec![
|
vec![
|
||||||
@ -72,12 +126,6 @@ fn genesis_builtins() -> Vec<Builtin> {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(AbiExample, Debug, Clone)]
|
|
||||||
pub enum ActivationType {
|
|
||||||
NewProgram,
|
|
||||||
NewVersion,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Builtin programs activated dynamically by feature
|
/// Builtin programs activated dynamically by feature
|
||||||
///
|
///
|
||||||
/// Note: If the feature_builtin is intended to replace another builtin program, it must have a new
|
/// Note: If the feature_builtin is intended to replace another builtin program, it must have a new
|
||||||
|
@ -7,8 +7,9 @@ use {
|
|||||||
accounts_index::{AccountSecondaryIndexes, AccountsIndexConfig},
|
accounts_index::{AccountSecondaryIndexes, AccountsIndexConfig},
|
||||||
ancestors::Ancestors,
|
ancestors::Ancestors,
|
||||||
append_vec::{AppendVec, StoredMetaWriteVersion},
|
append_vec::{AppendVec, StoredMetaWriteVersion},
|
||||||
bank::{Bank, BankFieldsToDeserialize, BankRc, Builtins},
|
bank::{Bank, BankFieldsToDeserialize, BankRc},
|
||||||
blockhash_queue::BlockhashQueue,
|
blockhash_queue::BlockhashQueue,
|
||||||
|
builtins::Builtins,
|
||||||
epoch_stakes::EpochStakes,
|
epoch_stakes::EpochStakes,
|
||||||
hardened_unpack::UnpackedAppendVecMap,
|
hardened_unpack::UnpackedAppendVecMap,
|
||||||
rent_collector::RentCollector,
|
rent_collector::RentCollector,
|
||||||
|
@ -2,7 +2,8 @@ use {
|
|||||||
crate::{
|
crate::{
|
||||||
accounts_db::AccountShrinkThreshold,
|
accounts_db::AccountShrinkThreshold,
|
||||||
accounts_index::{AccountSecondaryIndexes, AccountsIndexConfig},
|
accounts_index::{AccountSecondaryIndexes, AccountsIndexConfig},
|
||||||
bank::{Bank, BankSlotDelta, Builtins},
|
bank::{Bank, BankSlotDelta},
|
||||||
|
builtins::Builtins,
|
||||||
hardened_unpack::{unpack_snapshot, ParallelSelector, UnpackError, UnpackedAppendVecMap},
|
hardened_unpack::{unpack_snapshot, ParallelSelector, UnpackError, UnpackedAppendVecMap},
|
||||||
serde_snapshot::{
|
serde_snapshot::{
|
||||||
bank_from_streams, bank_to_stream, SerdeStyle, SnapshotStorage, SnapshotStorages,
|
bank_from_streams, bank_to_stream, SerdeStyle, SnapshotStorage, SnapshotStorages,
|
||||||
|
Reference in New Issue
Block a user