LCOV - code coverage report
Current view: top level - flamenco/runtime - fd_executor.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 9 9 100.0 %
Date: 2026-06-16 09:44:02 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_runtime_fd_executor_h
       2             : #define HEADER_fd_src_flamenco_runtime_fd_executor_h
       3             : 
       4             : #include "info/fd_instr_info.h"
       5             : #include "../../disco/fd_txn_p.h"
       6             : 
       7             : /* https://github.com/anza-xyz/agave/blob/v2.3.1/svm/src/account_loader.rs#L40-L47 */
       8        1179 : #define FD_TRANSACTION_ACCOUNT_BASE_SIZE  (64UL)
       9         219 : #define FD_ADDRESS_LOOKUP_TABLE_BASE_SIZE (8248UL)
      10             : 
      11         972 : #define FD_FEE_PAYER_TXN_IDX (0UL)
      12             : 
      13             : /* FD_EXEC_CU_UPDATE consumes CUs from the current instr ctx
      14             :    and fails in case of error. */
      15         126 : #define FD_EXEC_CU_UPDATE( ctx, cost ) do {                   \
      16         126 :   fd_exec_instr_ctx_t * _ctx = (ctx);                         \
      17         126 :   int err = fd_executor_consume_cus( _ctx->txn_out, (cost) ); \
      18         126 :   if( FD_UNLIKELY( err ) ) return err;                        \
      19         126 :   } while(0)
      20             : 
      21             : // https://github.com/anza-xyz/agave/blob/2e6ca8c1f62db62c1db7f19c9962d4db43d0d550/sdk/src/fee.rs#L82
      22         468 : #define FD_ACCOUNT_DATA_COST_PAGE_SIZE ( 32UL * 1024UL )
      23             : 
      24             : FD_PROTOTYPES_BEGIN
      25             : 
      26             : /* fd_exec_instr_fn_t processes an instruction.  Returns an error code
      27             :    in FD_EXECUTOR_INSTR_{ERR_{...},SUCCESS}. */
      28             : 
      29             : typedef int (* fd_exec_instr_fn_t)( fd_exec_instr_ctx_t * ctx );
      30             : 
      31             : /* Returns 1 if the given pubkey matches one of the BPF loader v1/v2/v3/v4
      32             :    program IDs, and 0 otherwise. */
      33             : uchar
      34             : fd_executor_pubkey_is_bpf_loader( fd_pubkey_t const * pubkey );
      35             : 
      36             : int
      37             : fd_executor_verify_transaction( fd_bank_t const *   bank,
      38             :                                 fd_txn_in_t const * txn_in,
      39             :                                 fd_txn_out_t *      txn_out );
      40             : 
      41             : int
      42             : fd_executor_check_transactions( fd_runtime_t *      runtime,
      43             :                                 fd_bank_t *         bank,
      44             :                                 fd_txn_in_t const * txn_in,
      45             :                                 fd_txn_out_t *      txn_out );
      46             : 
      47             : /* fd_execute_instr creates a new fd_exec_instr_ctx_t and performs
      48             :    instruction processing.  Does fd_spad_t allocations.  Returns an
      49             :    error code in FD_EXECUTOR_INSTR_{ERR_{...},SUCCESS}.
      50             : 
      51             :    IMPORTANT: instr_info must have the same lifetime as txn_ctx. This can
      52             :    be achieved by using fd_executor_acquire_instr_info_elem( txn_ctx ) to
      53             :    acquire an fd_instr_info_t element with the same lifetime as the txn_ctx */
      54             : int
      55             : fd_executor_txn_verify( fd_txn_p_t *  txn_p,
      56             :                         fd_sha512_t * shas[ FD_TXN_ACTUAL_SIG_MAX ] );
      57             : 
      58             : int
      59             : fd_execute_instr( fd_runtime_t *      runtime,
      60             :                   fd_bank_t *         bank,
      61             :                   fd_txn_in_t const * txn_in,
      62             :                   fd_txn_out_t *      txn_out,
      63             :                   fd_instr_info_t *   instr_info );
      64             : 
      65             : /*
      66             :   Execute the given transaction.
      67             : 
      68             :   Makes changes to the accounts DB. */
      69             : int
      70             : fd_execute_txn( fd_runtime_t *      runtime,
      71             :                 fd_bank_t *         bank,
      72             :                 fd_txn_in_t const * txn_in,
      73             :                 fd_txn_out_t *      txn_out );
      74             : 
      75             : int
      76             : fd_executor_validate_transaction_fee_payer( fd_bank_t *         bank,
      77             :                                             fd_txn_in_t const * txn_in,
      78             :                                             fd_txn_out_t *      txn_out );
      79             : 
      80             : int
      81             : fd_executor_setup_accounts_for_txn( fd_runtime_t *      runtime,
      82             :                                     fd_bank_t *         bank,
      83             :                                     fd_txn_in_t const * txn_in,
      84             :                                     fd_txn_out_t *      txn_out );
      85             : 
      86             : void
      87             : fd_executor_setup_accounts_for_txn_bundle( fd_runtime_t *      runtime,
      88             :                                            fd_txn_in_t const * txn_in,
      89             :                                            fd_txn_out_t *      txn_out );
      90             : 
      91             : int
      92             : fd_executor_setup_txn_alut_account_keys( fd_runtime_t *      runtime,
      93             :                                          fd_bank_t *         bank,
      94             :                                          fd_txn_in_t const * txn_in,
      95             :                                          fd_txn_out_t *      txn_out );
      96             : 
      97             : /* fd_executor_instr_strerror converts an FD_EXECUTOR_INSTR_ERR_{...}
      98             :    code into a human readable cstr.  The lifetime of the returned
      99             :    pointer is infinite and the call itself is thread safe.  The
     100             :    returned pointer is always to a non-NULL cstr. */
     101             : 
     102             : FD_FN_CONST char const *
     103             : fd_executor_instr_strerror( int err );
     104             : 
     105             : int
     106             : fd_executor_load_transaction_accounts( fd_bank_t *         bank,
     107             :                                        fd_txn_in_t const * txn_in,
     108             :                                        fd_txn_out_t *      txn_out );
     109             : 
     110             : int
     111             : fd_executor_validate_account_locks( fd_txn_out_t const * txn_out );
     112             : 
     113             : int
     114             : fd_executor_consume_cus( fd_txn_out_t * txn_out,
     115             :                          ulong          cus );
     116             : 
     117             : /* We expose these only for the fuzzing harness.
     118             :    Normally you shouldn't be invoking these manually. */
     119             : int
     120             : fd_instr_stack_push( fd_runtime_t *      runtime,
     121             :                      fd_txn_in_t const * txn_in,
     122             :                      fd_txn_out_t *      txn_out,
     123             :                      fd_instr_info_t *   instr );
     124             : 
     125             : int
     126             : fd_instr_stack_pop( fd_runtime_t *          runtime,
     127             :                     fd_txn_out_t *          txn_out,
     128             :                     fd_instr_info_t const * instr );
     129             : 
     130             : int
     131             : fd_execute_instr_end( fd_exec_instr_ctx_t *   instr_ctx,
     132             :                       fd_instr_info_t const * instr,
     133             :                       int                     instr_exec_result );
     134             : 
     135             : FD_PROTOTYPES_END
     136             : 
     137             : #endif /* HEADER_fd_src_flamenco_runtime_fd_executor_h */

Generated by: LCOV version 1.14