solana_builtins/
prototype.rs

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