nit: Move builtins types to builtins file (#19597)
This commit is contained in:
parent
38e1f7c4ba
commit
170927b7c4
|
@ -1,7 +1,4 @@
|
|||
use solana_runtime::{
|
||||
bank::{Builtin, Builtins},
|
||||
builtins::ActivationType,
|
||||
};
|
||||
use solana_runtime::builtins::{ActivationType, Builtin, Builtins};
|
||||
use solana_sdk::pubkey::Pubkey;
|
||||
|
||||
macro_rules! to_builtin {
|
||||
|
|
|
@ -11,8 +11,9 @@ use {
|
|||
solana_banks_server::banks_server::start_local_server,
|
||||
solana_program_runtime::InstructionProcessor,
|
||||
solana_runtime::{
|
||||
bank::{Bank, Builtin, ExecuteTimings},
|
||||
bank::{Bank, ExecuteTimings},
|
||||
bank_forks::BankForks,
|
||||
builtins::Builtin,
|
||||
commitment::BlockCommitmentCache,
|
||||
genesis_utils::{create_genesis_config_with_leader_ex, GenesisConfigInfo},
|
||||
},
|
||||
|
|
|
@ -45,7 +45,7 @@ use crate::{
|
|||
},
|
||||
ancestors::{Ancestors, AncestorsForSerialization},
|
||||
blockhash_queue::BlockhashQueue,
|
||||
builtins::{self, ActivationType},
|
||||
builtins::{self, ActivationType, Builtin, Builtins},
|
||||
epoch_stakes::{EpochStakes, NodeVoteAccounts},
|
||||
inline_spl_token_v2_0,
|
||||
instruction_recorder::InstructionRecorder,
|
||||
|
@ -211,33 +211,6 @@ type RentCollectionCycleParams = (
|
|||
|
||||
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
|
||||
#[derive(AbiExample, Debug, Default)]
|
||||
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
|
||||
#[derive(Debug)]
|
||||
struct CachedExecutorsEntry {
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
use crate::{
|
||||
bank::{Builtin, Builtins},
|
||||
system_instruction_processor,
|
||||
};
|
||||
use crate::system_instruction_processor;
|
||||
use solana_sdk::{
|
||||
feature_set,
|
||||
instruction::InstructionError,
|
||||
|
@ -9,6 +6,10 @@ use solana_sdk::{
|
|||
pubkey::Pubkey,
|
||||
stake, system_program,
|
||||
};
|
||||
use std::fmt;
|
||||
|
||||
#[cfg(RUSTC_WITH_SPECIALIZATION)]
|
||||
use solana_frozen_abi::abi_example::AbiExample;
|
||||
|
||||
fn process_instruction_with_program_logging(
|
||||
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
|
||||
fn genesis_builtins() -> Vec<Builtin> {
|
||||
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
|
||||
///
|
||||
/// 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},
|
||||
ancestors::Ancestors,
|
||||
append_vec::{AppendVec, StoredMetaWriteVersion},
|
||||
bank::{Bank, BankFieldsToDeserialize, BankRc, Builtins},
|
||||
bank::{Bank, BankFieldsToDeserialize, BankRc},
|
||||
blockhash_queue::BlockhashQueue,
|
||||
builtins::Builtins,
|
||||
epoch_stakes::EpochStakes,
|
||||
hardened_unpack::UnpackedAppendVecMap,
|
||||
rent_collector::RentCollector,
|
||||
|
|
|
@ -2,7 +2,8 @@ use {
|
|||
crate::{
|
||||
accounts_db::AccountShrinkThreshold,
|
||||
accounts_index::{AccountSecondaryIndexes, AccountsIndexConfig},
|
||||
bank::{Bank, BankSlotDelta, Builtins},
|
||||
bank::{Bank, BankSlotDelta},
|
||||
builtins::Builtins,
|
||||
hardened_unpack::{unpack_snapshot, ParallelSelector, UnpackError, UnpackedAppendVecMap},
|
||||
serde_snapshot::{
|
||||
bank_from_streams, bank_to_stream, SerdeStyle, SnapshotStorage, SnapshotStorages,
|
||||
|
|
Loading…
Reference in New Issue