solana_builtins/prototype.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
//! Prototype layouts for builtins.
use {
crate::core_bpf_migration::CoreBpfMigrationConfig,
solana_program_runtime::invoke_context::BuiltinFunctionWithContext, solana_pubkey::Pubkey,
};
/// Transitions of built-in programs at epoch boundaries when features are activated.
pub struct BuiltinPrototype {
/// Configurations for migrating the builtin to Core BPF.
pub core_bpf_migration_config: Option<CoreBpfMigrationConfig>,
/// Feature ID that enables the builtin program.
/// If None, the built-in program is always enabled.
pub enable_feature_id: Option<Pubkey>,
/// The program's ID.
pub program_id: Pubkey,
/// The program's name, ie "system_program".
pub name: &'static str,
/// The program's entrypoint function.
pub entrypoint: BuiltinFunctionWithContext,
}
impl std::fmt::Debug for BuiltinPrototype {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
let mut builder = f.debug_struct("BuiltinPrototype");
builder.field("program_id", &self.program_id);
builder.field("name", &self.name);
builder.field("enable_feature_id", &self.enable_feature_id);
builder.field("core_bpf_migration_config", &self.core_bpf_migration_config);
builder.finish()
}
}
/// Transitions of stateless built-in programs at epoch boundaries when
/// features are activated.
/// These are built-in programs that don't actually exist, but their address
/// is reserved.
#[derive(Debug)]
pub struct StatelessBuiltinPrototype {
/// Configurations for migrating the stateless builtin to Core BPF.
pub core_bpf_migration_config: Option<CoreBpfMigrationConfig>,
/// The program's ID.
pub program_id: Pubkey,
/// The program's name, ie "feature_gate_program".
pub name: &'static str,
}