Line data Source code
1 : #ifndef HEADER_fd_src_flamenco_runtime_program_fd_buildin_programs_h 2 : #define HEADER_fd_src_flamenco_runtime_program_fd_buildin_programs_h 3 : 4 : #include "../../fd_flamenco_base.h" 5 : #include "../../runtime/fd_system_ids.h" 6 : #include "../../features/fd_features.h" 7 : #include "../context/fd_exec_epoch_ctx.h" 8 : #include "../context/fd_exec_slot_ctx.h" 9 : #include "../fd_system_ids.h" 10 : #include "../fd_system_ids_pp.h" 11 : 12 0 : #define NO_ENABLE_FEATURE_ID ULONG_MAX 13 : 14 : /* https://github.com/anza-xyz/agave/blob/v2.1.0/runtime/src/bank/builtins/core_bpf_migration/mod.rs#L43-L66 15 : Configuration for migrating a built-in program to Core BPF */ 16 : struct fd_core_bpf_migration_config { 17 : fd_pubkey_t const * source_buffer_address; 18 : fd_pubkey_t * upgrade_authority_address; 19 : ulong enable_feature_offset; 20 : fd_pubkey_t const * builtin_program_id; 21 : }; 22 : typedef struct fd_core_bpf_migration_config fd_core_bpf_migration_config_t; 23 : 24 : /* https://github.com/anza-xyz/agave/blob/v2.1.0/runtime/src/bank/builtins/prototypes.rs#L7-L13 25 : Transitions of built-in programs at epoch boundaries when features are activated */ 26 : struct fd_builtin_program { 27 : fd_pubkey_t const * pubkey; 28 : char const * data; 29 : ulong enable_feature_offset; 30 : fd_core_bpf_migration_config_t const * core_bpf_migration_config; 31 : }; 32 : typedef struct fd_builtin_program fd_builtin_program_t; 33 : 34 : /* https://github.com/anza-xyz/agave/blob/v2.1.0/runtime/src/bank/builtins/prototypes.rs#L31-L35 35 : Transitions of stateless built-in programs at epoch boundaries when features are activated */ 36 : struct fd_stateless_builtin_program { 37 : fd_pubkey_t const * pubkey; 38 : fd_core_bpf_migration_config_t const * core_bpf_migration_config; 39 : }; 40 : typedef struct fd_stateless_builtin_program fd_stateless_builtin_program_t; 41 : 42 : FD_PROTOTYPES_BEGIN 43 : 44 : /* Initialize the builtin program accounts */ 45 : void 46 : fd_builtin_programs_init( fd_exec_slot_ctx_t * slot_ctx ); 47 : 48 : void 49 : fd_write_builtin_account( fd_exec_slot_ctx_t * slot_ctx, 50 : fd_pubkey_t const pubkey, 51 : char const * data, 52 : ulong sz ); 53 : 54 : fd_builtin_program_t const * 55 : fd_builtins( void ); 56 : 57 : ulong 58 : fd_num_builtins( void ); 59 : 60 : fd_stateless_builtin_program_t const * 61 : fd_stateless_builtins( void ); 62 : 63 : ulong 64 : fd_num_stateless_builtins( void ); 65 : 66 : /* `migrated_yet` is an output value thats set based on the rules below: 67 : 68 : | Return Value | *migrated_yet | Description | 69 : |--------------|-------------------|--------------------------------------------------------------------------| 70 : | 0 | 0 | Program is not a migrating builtin program | 71 : | 1 | 0 | Program is a migrating builtin program id, BUT has not been migrated yet | 72 : | 1 | 1 | Program is a migrating builtin program id, AND has been migrated to BPF | 73 : */ 74 : uchar 75 : fd_is_migrating_builtin_program( fd_exec_txn_ctx_t const * txn_ctx, 76 : fd_pubkey_t const * pubkey, 77 : uchar * migrated_yet ); 78 : 79 : uchar 80 : fd_is_non_migrating_builtin_program( fd_pubkey_t const * pubkey ); 81 : 82 : FD_PROTOTYPES_END 83 : 84 : #endif /* HEADER_fd_src_flamenco_runtime_program_fd_buildin_programs_h */