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

Generated by: LCOV version 1.14