Skip to main content

clone_solana_builtins/
prototype.rs

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