LCOV - code coverage report
Current view: top level - flamenco/runtime/program - fd_bpf_loader_program.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 31 0.0 %
Date: 2025-12-04 04:56:06 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_runtime_program_fd_bpf_loader_program_h
       2             : #define HEADER_fd_src_flamenco_runtime_program_fd_bpf_loader_program_h
       3             : 
       4             : /* fd_bpf_loader_v3_program.h is the third version of the BPF loader
       5             :    program.
       6             : 
       7             :    Address: BPFLoaderUpgradeab1e11111111111111111111111 */
       8             : 
       9             : #include "../../progcache/fd_progcache_rec.h"
      10             : #include "../../features/fd_features.h"
      11             : #include "../../types/fd_types.h"
      12             : #include "../../../funk/fd_funk_base.h"
      13             : 
      14             : /* https://github.com/anza-xyz/agave/blob/77daab497df191ef485a7ad36ed291c1874596e5/programs/bpf_loader/src/lib.rs#L67-L69 */
      15             : #define DEFAULT_LOADER_COMPUTE_UNITS     (570UL )
      16             : #define DEPRECATED_LOADER_COMPUTE_UNITS  (1140UL)
      17             : #define UPGRADEABLE_LOADER_COMPUTE_UNITS (2370UL)
      18             : 
      19             : /* https://github.com/anza-xyz/agave/blob/77daab497df191ef485a7ad36ed291c1874596e5/sdk/program/src/bpf_loader_upgradeable.rs#L29-L120 */
      20           0 : #define SIZE_OF_PROGRAM                  (36UL  ) /* UpgradeableLoaderState::size_of_program() */
      21           0 : #define BUFFER_METADATA_SIZE             (37UL  ) /* UpgradeableLoaderState::size_of_buffer_metadata() */
      22           0 : #define PROGRAMDATA_METADATA_SIZE        (45UL  ) /* UpgradeableLoaderState::size_of_programdata_metadata() */
      23           0 : #define SIZE_OF_UNINITIALIZED            (4UL   ) /* UpgradeableLoaderState::size_of_uninitialized() */
      24             : 
      25             : /* InstructionError conversions
      26             :    https://github.com/anza-xyz/agave/blob/ced98f1ebe73f7e9691308afa757323003ff744f/sdk/program/src/program_error.rs#L127-L160 */
      27           0 : #define BUILTIN_BIT_SHIFT                           (32UL)
      28             : 
      29           0 : #define CUSTOM_ZERO                                 ((1UL)  << BUILTIN_BIT_SHIFT)
      30           0 : #define INVALID_ARGUMENT                            ((2UL)  << BUILTIN_BIT_SHIFT)
      31           0 : #define INVALID_INSTRUCTION_DATA                    ((3UL)  << BUILTIN_BIT_SHIFT)
      32           0 : #define INVALID_ACCOUNT_DATA                        ((4UL)  << BUILTIN_BIT_SHIFT)
      33           0 : #define ACCOUNT_DATA_TOO_SMALL                      ((5UL)  << BUILTIN_BIT_SHIFT)
      34           0 : #define INSUFFICIENT_FUNDS                          ((6UL)  << BUILTIN_BIT_SHIFT)
      35           0 : #define INCORRECT_PROGRAM_ID                        ((7UL)  << BUILTIN_BIT_SHIFT)
      36           0 : #define MISSING_REQUIRED_SIGNATURES                 ((8UL)  << BUILTIN_BIT_SHIFT)
      37           0 : #define ACCOUNT_ALREADY_INITIALIZED                 ((9UL)  << BUILTIN_BIT_SHIFT)
      38           0 : #define UNINITIALIZED_ACCOUNT                       ((10UL) << BUILTIN_BIT_SHIFT)
      39           0 : #define NOT_ENOUGH_ACCOUNT_KEYS                     ((11UL) << BUILTIN_BIT_SHIFT)
      40           0 : #define ACCOUNT_BORROW_FAILED                       ((12UL) << BUILTIN_BIT_SHIFT)
      41           0 : #define MAX_SEED_LENGTH_EXCEEDED                    ((13UL) << BUILTIN_BIT_SHIFT)
      42           0 : #define INVALID_SEEDS                               ((14UL) << BUILTIN_BIT_SHIFT)
      43           0 : #define BORSH_IO_ERROR                              ((15UL) << BUILTIN_BIT_SHIFT)
      44           0 : #define ACCOUNT_NOT_RENT_EXEMPT                     ((16UL) << BUILTIN_BIT_SHIFT)
      45           0 : #define UNSUPPORTED_SYSVAR                          ((17UL) << BUILTIN_BIT_SHIFT)
      46           0 : #define ILLEGAL_OWNER                               ((18UL) << BUILTIN_BIT_SHIFT)
      47           0 : #define MAX_ACCOUNTS_DATA_ALLOCATIONS_EXCEEDED      ((19UL) << BUILTIN_BIT_SHIFT)
      48           0 : #define INVALID_ACCOUNT_DATA_REALLOC                ((20UL) << BUILTIN_BIT_SHIFT)
      49           0 : #define MAX_INSTRUCTION_TRACE_LENGTH_EXCEEDED       ((21UL) << BUILTIN_BIT_SHIFT)
      50           0 : #define BUILTIN_PROGRAMS_MUST_CONSUME_COMPUTE_UNITS ((22UL) << BUILTIN_BIT_SHIFT)
      51           0 : #define INVALID_ACCOUNT_OWNER                       ((23UL) << BUILTIN_BIT_SHIFT)
      52           0 : #define ARITHMETIC_OVERFLOW                         ((24UL) << BUILTIN_BIT_SHIFT)
      53           0 : #define IMMUTABLE                                   ((25UL) << BUILTIN_BIT_SHIFT)
      54           0 : #define INCORRECT_AUTHORITY                         ((26UL) << BUILTIN_BIT_SHIFT)
      55             : 
      56             : FD_PROTOTYPES_BEGIN
      57             : 
      58             : /* Mirrors solana_sdk::transaction_context::BorrowedAccount::get_state()
      59             : 
      60             :    Acts on a fd_txn_account_t for ease of API use.
      61             : 
      62             :    https://github.com/anza-xyz/agave/blob/v2.1.14/sdk/src/transaction_context.rs#L965-L969 */
      63             : 
      64             : int
      65             : fd_bpf_loader_program_get_state( fd_txn_account_t const *            acct,
      66             :                                  fd_bpf_upgradeable_loader_state_t * state );
      67             : 
      68             : int
      69             : fd_deploy_program( fd_exec_instr_ctx_t * instr_ctx,
      70             :                    fd_pubkey_t const *   program_key,
      71             :                    uchar const *         programdata,
      72             :                    ulong                 programdata_size );
      73             : 
      74             : int
      75             : fd_bpf_execute( fd_exec_instr_ctx_t *      instr_ctx,
      76             :                 fd_progcache_rec_t const * program,
      77             :                 uchar                      is_deprecated );
      78             : 
      79             : int
      80             : fd_bpf_loader_program_execute( fd_exec_instr_ctx_t * instr_ctx );
      81             : 
      82             : /* Public APIs */
      83             : 
      84             : /* This function is called from `fd_runtime.c` and only performs the ELF
      85             :    and VM validation checks necessary to deploy a program, specifically
      86             :    for the core native program BPF migration. Since this call is done at
      87             :    the epoch boundary every time a new BPF core migration feature is
      88             :    activated, we need to mock up a transaction and instruction context
      89             :    for execution.  We do not do any funk operations here - instead, the
      90             :    BPF cache entry will be created at the end of the block.  Because of
      91             :    this, our logic is slightly different than Agave's.  See the
      92             :    documentation for our `fd_deploy_program` for more information.
      93             : 
      94             :    https://github.com/anza-xyz/agave/blob/v2.1.0/runtime/src/bank/builtins/core_bpf_migration/mod.rs#L155-L233 */
      95             : int
      96             : fd_directly_invoke_loader_v3_deploy( fd_bank_t *         bank,
      97             :                                      fd_funk_t *         funk,
      98             :                                      void *              accdb_shfunk,
      99             :                                      fd_pubkey_t const * program_key,
     100             :                                      uchar const *       elf,
     101             :                                      ulong               elf_sz );
     102             : 
     103             : FD_PROTOTYPES_END
     104             : 
     105             : #endif /* HEADER_fd_src_flamenco_runtime_program_fd_bpf_loader_program_h */

Generated by: LCOV version 1.14