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

Generated by: LCOV version 1.14