solana_builtins/
core_bpf_migration.rs

1use solana_pubkey::Pubkey;
2
3/// Identifies the type of built-in program targeted for Core BPF migration.
4/// The type of target determines whether the program should have a program
5/// account or not, which is checked before migration.
6#[allow(dead_code)] // Remove after first migration is configured.
7#[derive(Debug, PartialEq)]
8pub enum CoreBpfMigrationTargetType {
9    /// A standard (stateful) builtin program must have a program account.
10    Builtin,
11    /// A stateless builtin must not have a program account.
12    Stateless,
13}
14
15/// Configuration for migrating a built-in program to Core BPF.
16#[derive(Debug, PartialEq)]
17pub struct CoreBpfMigrationConfig {
18    /// The address of the source buffer account to be used to replace the
19    /// builtin.
20    pub source_buffer_address: Pubkey,
21    /// The authority to be used as the BPF program's upgrade authority.
22    ///
23    /// Note: If this value is set to `None`, then the migration will ignore
24    /// the source buffer account's authority. If it's set to any `Some(..)`
25    /// value, then the migration will perform a sanity check to ensure the
26    /// source buffer account's authority matches the provided value.
27    pub upgrade_authority_address: Option<Pubkey>,
28    /// The feature gate to trigger the migration to Core BPF.
29    /// Note: This feature gate should never be the same as any builtin's
30    /// `enable_feature_id`. It should always be a feature gate that will be
31    /// activated after the builtin is already enabled.
32    pub feature_id: Pubkey,
33    /// The type of target to replace.
34    pub migration_target: CoreBpfMigrationTargetType,
35    /// Static message used to emit datapoint logging.
36    /// This is used to identify the migration in the logs.
37    /// Should be unique to the migration, ie:
38    /// "migrate_{builtin/stateless}_to_core_bpf_{program_name}".
39    pub datapoint_name: &'static str,
40}